"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const index_d = require("../../../../../../../packages/index.d.js");
const httpEnum = require("../../../../../../../enums/httpEnum.js");
require("../../../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
require("../../../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js");
require("../../../../../../../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js");
const type = require("../../../../../../../utils/type.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.js");
require("../../../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
require("../../../../../../../enums/pageEnum.js");
require("../../../../../../../router/index.js");
require("../../../../../../../store/modules/designStore/designStore.js");
require("../../../../../../../settings/designSetting.js");
require("../../../../../../../components/GoLoading/index.js");
require("../../../../../../../components/GoSkeleton/index.vue.js");
const icon = require("../../../../../../../plugins/icon.js");
const index_d$1 = require("../../index.d.js");
const index = require("../ChartDataMonacoEditor/index.vue.js");
const useFile_hooks = require("../../hooks/useFile.hooks.js");
const useTargetData_hook = require("../../../hooks/useTargetData.hook.js");
const runtimeCore_esmBundler = require("../../../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const reactivity_esmBundler = require("../../../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js");
const shared_esmBundler = require("../../../../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.js");
const runtimeDom_esmBundler = require("../../../../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js");
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    show: {
      type: Boolean,
      required: false
    },
    ajax: {
      type: Boolean,
      required: true
    }
  },
  setup(__props) {
    const { targetData } = useTargetData_hook.useTargetData();
    const tableTitle = ["字段", "映射", "状态"];
    const { HelpOutlineIcon } = icon.icon.ionicons5;
    const { DocumentAddIcon, DocumentDownloadIcon } = icon.icon.carbon;
    const source = reactivity_esmBundler.ref();
    const dimensions = reactivity_esmBundler.ref();
    const dimensionsAndSource = reactivity_esmBundler.ref();
    const noData = reactivity_esmBundler.ref(false);
    const { uploadFileListRef, customRequest, beforeUpload, download } = useFile_hooks.useFile(targetData);
    const filterShow = runtimeCore_esmBundler.computed(() => {
      return targetData.value.request.requestDataType !== httpEnum.RequestDataTypeEnum.STATIC;
    });
    const isCharts = runtimeCore_esmBundler.computed(() => {
      return targetData.value.chartConfig.chartFrame === index_d.ChartFrameEnum.ECHARTS;
    });
    const matchingHandle = (mapping) => {
      let res = index_d$1.DataResultEnum.SUCCESS;
      for (let i = 0; i < source.value.length; i++) {
        if (source.value[i][mapping] === void 0) {
          res = index_d$1.DataResultEnum.FAILURE;
          return res;
        }
      }
      return index_d$1.DataResultEnum.SUCCESS;
    };
    const dimensionsAndSourceHandle = () => {
      try {
        return dimensions.value.map((dimensionsItem, index2) => {
          return index2 === 0 ? {
            // 字段
            field: "通用标识",
            // 映射
            mapping: dimensionsItem,
            // 结果
            result: index_d$1.DataResultEnum.NULL
          } : {
            field: `数据项-${index2}`,
            mapping: dimensionsItem,
            result: matchingHandle(dimensionsItem)
          };
        });
      } catch (error) {
        return [];
      }
    };
    runtimeCore_esmBundler.watch(
      () => {
        var _a, _b;
        return (_b = (_a = targetData.value) == null ? void 0 : _a.option) == null ? void 0 : _b.dataset;
      },
      (newData) => {
        var _a, _b;
        if (newData && ((_b = (_a = targetData == null ? void 0 : targetData.value) == null ? void 0 : _a.chartConfig) == null ? void 0 : _b.chartFrame) === index_d.ChartFrameEnum.ECHARTS) {
          source.value = newData;
          if (isCharts.value) {
            dimensions.value = newData.dimensions;
            dimensionsAndSource.value = dimensionsAndSourceHandle();
          }
        } else if (newData !== void 0 && newData !== null) {
          dimensionsAndSource.value = null;
          source.value = newData;
        } else {
          noData.value = true;
          source.value = "此组件无数据源";
        }
        if (type.isArray(newData)) {
          dimensionsAndSource.value = null;
        }
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      const _component_n_badge = runtimeCore_esmBundler.resolveComponent("n-badge");
      const _component_n_text = runtimeCore_esmBundler.resolveComponent("n-text");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      const _component_n_table = runtimeCore_esmBundler.resolveComponent("n-table");
      const _component_n_timeline_item = runtimeCore_esmBundler.resolveComponent("n-timeline-item");
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_upload = runtimeCore_esmBundler.resolveComponent("n-upload");
      const _component_n_tooltip = runtimeCore_esmBundler.resolveComponent("n-tooltip");
      const _component_n_code = runtimeCore_esmBundler.resolveComponent("n-code");
      const _component_n_card = runtimeCore_esmBundler.resolveComponent("n-card");
      const _component_n_timeline = runtimeCore_esmBundler.resolveComponent("n-timeline");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_timeline, { class: "go-chart-configurations-timeline" }, {
        default: runtimeCore_esmBundler.withCtx(() => [
          runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_timeline_item, {
            type: "info",
            title: reactivity_esmBundler.unref(index_d$1.TimelineTitleEnum).MAPPING
          }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(_component_n_table, { striped: "" }, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createElementVNode("thead", null, [
                    runtimeCore_esmBundler.createElementVNode("tr", null, [
                      (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(tableTitle, (item) => {
                        return runtimeCore_esmBundler.createElementVNode("th", { key: item }, shared_esmBundler.toDisplayString(item), 1);
                      }), 64))
                    ])
                  ]),
                  runtimeCore_esmBundler.createElementVNode("tbody", null, [
                    (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(dimensionsAndSource.value, (item, index2) => {
                      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("tr", { key: index2 }, [
                        runtimeCore_esmBundler.createElementVNode("td", null, shared_esmBundler.toDisplayString(item.field), 1),
                        runtimeCore_esmBundler.createElementVNode("td", null, shared_esmBundler.toDisplayString(item.mapping), 1),
                        runtimeCore_esmBundler.createElementVNode("td", null, [
                          item.result === 0 ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_space, { key: 0 }, {
                            default: runtimeCore_esmBundler.withCtx(() => [
                              runtimeCore_esmBundler.createVNode(_component_n_badge, {
                                dot: "",
                                type: "success"
                              }),
                              runtimeCore_esmBundler.createVNode(_component_n_text, null, {
                                default: runtimeCore_esmBundler.withCtx(() => [
                                  runtimeCore_esmBundler.createTextVNode("无")
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_space, { key: 1 }, {
                            default: runtimeCore_esmBundler.withCtx(() => [
                              runtimeCore_esmBundler.createVNode(_component_n_badge, {
                                dot: "",
                                type: item.result === 1 ? "success" : "error"
                              }, null, 8, ["type"]),
                              runtimeCore_esmBundler.createVNode(_component_n_text, null, {
                                default: runtimeCore_esmBundler.withCtx(() => [
                                  runtimeCore_esmBundler.createTextVNode("匹配" + shared_esmBundler.toDisplayString(item.result === 1 ? "成功" : "失败"), 1)
                                ]),
                                _: 2
                              }, 1024)
                            ]),
                            _: 2
                          }, 1024))
                        ])
                      ]);
                    }), 128))
                  ])
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["title"]), [
            [runtimeDom_esmBundler.vShow, isCharts.value && dimensionsAndSource.value]
          ]),
          runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_timeline_item, {
            color: "#97846c",
            title: reactivity_esmBundler.unref(index_d$1.TimelineTitleEnum).FILTER
          }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(_component_n_space, {
                size: 18,
                vertical: ""
              }, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createVNode(_component_n_text, { depth: "3" }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createTextVNode("过滤器默认处理接口返回值的「data」字段")
                    ]),
                    _: 1
                  }),
                  runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(index.default))
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["title"]), [
            [runtimeDom_esmBundler.vShow, filterShow.value]
          ]),
          runtimeCore_esmBundler.createVNode(_component_n_timeline_item, {
            type: "success",
            title: reactivity_esmBundler.unref(index_d$1.TimelineTitleEnum).CONTENT
          }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(_component_n_space, { vertical: "" }, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createVNode(_component_n_space, { class: "source-btn-box" }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createVNode(_component_n_upload, {
                        "file-list": reactivity_esmBundler.unref(uploadFileListRef),
                        "onUpdate:fileList": _cache[0] || (_cache[0] = ($event) => reactivity_esmBundler.isRef(uploadFileListRef) ? uploadFileListRef.value = $event : null),
                        "show-file-list": false,
                        customRequest: reactivity_esmBundler.unref(customRequest),
                        onBeforeUpload: reactivity_esmBundler.unref(beforeUpload)
                      }, {
                        default: runtimeCore_esmBundler.withCtx(() => [
                          runtimeCore_esmBundler.createVNode(_component_n_space, null, {
                            default: runtimeCore_esmBundler.withCtx(() => [
                              !__props.ajax ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_button, {
                                key: 0,
                                class: "sourceBtn-item",
                                disabled: noData.value
                              }, {
                                icon: runtimeCore_esmBundler.withCtx(() => [
                                  runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                                    default: runtimeCore_esmBundler.withCtx(() => [
                                      runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(DocumentAddIcon))
                                    ]),
                                    _: 1
                                  })
                                ]),
                                default: runtimeCore_esmBundler.withCtx(() => [
                                  runtimeCore_esmBundler.createTextVNode(" 导入（json / txt） ")
                                ]),
                                _: 1
                              }, 8, ["disabled"])) : runtimeCore_esmBundler.createCommentVNode("", true)
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["file-list", "customRequest", "onBeforeUpload"]),
                      runtimeCore_esmBundler.createElementVNode("div", null, [
                        runtimeCore_esmBundler.createVNode(_component_n_button, {
                          class: "sourceBtn-item",
                          disabled: noData.value,
                          onClick: reactivity_esmBundler.unref(download)
                        }, {
                          icon: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                              default: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(DocumentDownloadIcon))
                              ]),
                              _: 1
                            })
                          ]),
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createTextVNode(" 下载 ")
                          ]),
                          _: 1
                        }, 8, ["disabled", "onClick"]),
                        runtimeCore_esmBundler.createVNode(_component_n_tooltip, { trigger: "hover" }, {
                          trigger: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_icon, {
                              class: "go-ml-1",
                              size: "21",
                              depth: 3
                            }, {
                              default: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(HelpOutlineIcon))
                              ]),
                              _: 1
                            })
                          ]),
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_text, { depth: "3" }, {
                              default: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createTextVNode("点击【下载】查看完整数据")
                              ]),
                              _: 1
                            })
                          ]),
                          _: 1
                        })
                      ])
                    ]),
                    _: 1
                  }),
                  runtimeCore_esmBundler.createVNode(_component_n_card, { size: "small" }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createVNode(_component_n_code, {
                        code: reactivity_esmBundler.unref(type.toString)(source.value),
                        language: "json"
                      }, null, 8, ["code"])
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["title"])
        ]),
        _: 1
      });
    };
  }
});
exports.default = _sfc_main;
