"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");
require("../../../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
const utils = require("../../../../../../../utils/utils.js");
require("../../../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
require("../../../../../../../enums/pageEnum.js");
require("../../../../../../../router/index.js");
const designStore = 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 http = require("../../../../../../../api/http.js");
require("../../../../../../../components/Pages/ChartItemSetting/SettingItem.vue.js");
const SettingItemBox = require("../../../../../../../components/Pages/ChartItemSetting/SettingItemBox.vue.js");
require("../../../../../../../store/modules/chartEditStore/chartEditStore.js");
require("../../../../../../../components/Pages/ChartItemSetting/StylesSetting.vue.js");
const index$1 = require("./components/ChartDataPondControl/index.vue.js");
const useTargetData_hook = require("../../../hooks/useTargetData.hook.js");
const index = require("../ChartDataMatchingAndShow/index.vue.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 runtimeDom_esmBundler = require("../../../../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.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 _hoisted_1 = { class: "go-chart-data-pond" };
const _hoisted_2 = { class: "go-absolute-center" };
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  setup(__props) {
    runtimeDom_esmBundler.useCssVars((_ctx) => ({
      "5189590e": themeColor.value
    }));
    const designStore$1 = designStore.useDesignStore();
    const { HelpOutlineIcon, FlashIcon, PulseIcon, FishIcon } = icon.icon.ionicons5;
    const { targetData, chartEditStore } = useTargetData_hook.useTargetData();
    const {
      requestDataPond,
      requestInterval: GlobalRequestInterval,
      requestIntervalUnit: GlobalRequestIntervalUnit
    } = reactivity_esmBundler.toRefs(chartEditStore.getRequestGlobalConfig);
    const loading = reactivity_esmBundler.ref(false);
    const controlModel = reactivity_esmBundler.ref(false);
    const showMatching = reactivity_esmBundler.ref(false);
    let firstFocus = 0;
    let lastFilter = void 0;
    const pondData = runtimeCore_esmBundler.computed(() => {
      const selectId = targetData.value.request.requestDataPondId;
      if (!selectId)
        return void 0;
      const data = requestDataPond.value.filter((item) => {
        return selectId === item.dataPondId;
      });
      return data[0];
    });
    const themeColor = runtimeCore_esmBundler.computed(() => {
      return designStore$1.getAppTheme;
    });
    const controlModelHandle = () => {
      controlModel.value = true;
    };
    const sendHandle = async () => {
      var _a;
      if (!((_a = targetData.value) == null ? void 0 : _a.request)) {
        window.$message.warning("请选择一个公共接口！");
        return;
      }
      loading.value = true;
      try {
        const res = await http.customizeHttp(reactivity_esmBundler.toRaw(targetData.value.request), reactivity_esmBundler.toRaw(chartEditStore.getRequestGlobalConfig));
        loading.value = false;
        if (res) {
          if (!(res == null ? void 0 : res.data) && !targetData.value.filter) {
            window["$message"].warning("您的数据不符合默认格式，请配置过滤器！");
            showMatching.value = true;
            return;
          }
          targetData.value.option.dataset = utils.newFunctionHandle(res == null ? void 0 : res.data, res, targetData.value.filter);
          showMatching.value = true;
          return;
        }
        window["$message"].warning("没有拿到返回值，请检查接口！");
      } catch (error) {
        console.error(error);
        loading.value = false;
        window["$message"].warning("数据异常，请检查参数！");
      }
    };
    runtimeCore_esmBundler.watchEffect(() => {
      var _a;
      const filter = (_a = targetData.value) == null ? void 0 : _a.filter;
      if (lastFilter !== filter && firstFocus) {
        lastFilter = filter;
        sendHandle();
      }
      firstFocus++;
    });
    runtimeCore_esmBundler.onBeforeUnmount(() => {
      lastFilter = null;
    });
    return (_ctx, _cache) => {
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_input = runtimeCore_esmBundler.resolveComponent("n-input");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_card = runtimeCore_esmBundler.resolveComponent("n-card");
      const _component_n_tooltip = runtimeCore_esmBundler.resolveComponent("n-tooltip");
      const _component_go_skeleton = runtimeCore_esmBundler.resolveComponent("go-skeleton");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, [
        runtimeCore_esmBundler.createElementVNode("div", _hoisted_1, [
          runtimeCore_esmBundler.createVNode(_component_n_card, { class: "n-card-shallow" }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), {
                name: "请求名称",
                alone: true
              }, {
                default: runtimeCore_esmBundler.withCtx(() => {
                  var _a;
                  return [
                    runtimeCore_esmBundler.createVNode(_component_n_input, {
                      size: "small",
                      placeholder: ((_a = pondData.value) == null ? void 0 : _a.dataPondName) || "暂无",
                      disabled: true
                    }, {
                      prefix: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(_component_n_icon, { component: reactivity_esmBundler.unref(FishIcon) }, null, 8, ["component"])
                      ]),
                      _: 1
                    }, 8, ["placeholder"])
                  ];
                }),
                _: 1
              }),
              runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), {
                name: "接口地址",
                alone: true
              }, {
                default: runtimeCore_esmBundler.withCtx(() => {
                  var _a;
                  return [
                    runtimeCore_esmBundler.createVNode(_component_n_input, {
                      size: "small",
                      placeholder: ((_a = pondData.value) == null ? void 0 : _a.dataPondRequestConfig.requestUrl) || "暂无",
                      disabled: true
                    }, {
                      prefix: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(_component_n_icon, { component: reactivity_esmBundler.unref(FlashIcon) }, null, 8, ["component"])
                      ]),
                      _: 1
                    }, 8, ["placeholder"])
                  ];
                }),
                _: 1
              }),
              runtimeCore_esmBundler.createElementVNode("div", {
                class: "edit-text",
                onClick: controlModelHandle
              }, [
                runtimeCore_esmBundler.createElementVNode("div", _hoisted_2, [
                  runtimeCore_esmBundler.createVNode(_component_n_button, {
                    type: "primary",
                    secondary: ""
                  }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createTextVNode("编辑配置")
                    ]),
                    _: 1
                  })
                ])
              ])
            ]),
            _: 1
          })
        ]),
        runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), { alone: true }, {
          name: runtimeCore_esmBundler.withCtx(() => [
            runtimeCore_esmBundler.createTextVNode(" 测试 "),
            runtimeCore_esmBundler.createVNode(_component_n_tooltip, { trigger: "hover" }, {
              trigger: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createVNode(_component_n_icon, {
                  size: "21",
                  depth: 3
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(HelpOutlineIcon))
                  ]),
                  _: 1
                })
              ]),
              default: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createTextVNode(" 默认赋值给 dataset 字段 ")
              ]),
              _: 1
            })
          ]),
          default: runtimeCore_esmBundler.withCtx(() => [
            runtimeCore_esmBundler.createVNode(_component_n_button, {
              type: "primary",
              ghost: "",
              onClick: sendHandle
            }, {
              icon: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(FlashIcon))
                  ]),
                  _: 1
                })
              ]),
              default: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createTextVNode(" 发送请求 ")
              ]),
              _: 1
            })
          ]),
          _: 1
        }),
        runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(index.default), {
          show: showMatching.value && !loading.value,
          ajax: true
        }, null, 8, ["show"]),
        runtimeCore_esmBundler.createVNode(_component_go_skeleton, {
          load: loading.value,
          repeat: 3
        }, null, 8, ["load"]),
        runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(index$1.default), {
          modelShow: controlModel.value,
          "onUpdate:modelShow": _cache[0] || (_cache[0] = ($event) => controlModel.value = $event),
          onSendHandle: sendHandle
        }, null, 8, ["modelShow"])
      ], 64);
    };
  }
});
exports.default = _sfc_main;
