"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 SettingItem = require("../../../../../../../components/Pages/ChartItemSetting/SettingItem.vue2.js");
const SettingItemBox = require("../../../../../../../components/Pages/ChartItemSetting/SettingItemBox.vue.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");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.js");
const httpEnum = require("../../../../../../../enums/httpEnum.js");
const eventEnum = require("../../../../../../../enums/eventEnum.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");
const plugin = require("../../../../../../../utils/plugin.js");
require("../../../../../../../components/GoLoading/index.js");
require("../../../../../../../components/GoSkeleton/index.vue.js");
const icon = require("../../../../../../../plugins/icon.js");
require("../../../../../../../store/modules/chartEditStore/chartEditStore.js");
const index_d = require("../../../../../../../packages/index.d.js");
require("../../../../../../../components/Pages/ChartItemSetting/StylesSetting.vue.js");
const noData = require("../../../../../../../assets/images/canvas/noData.png.js");
const useTargetData_hook = require("../../../hooks/useTargetData.hook.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 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 _hoisted_1 = {
  key: 0,
  class: "no-data go-flex-center"
};
const _hoisted_2 = ["src"];
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  setup(__props) {
    const { CloseIcon, AddIcon, HelpOutlineIcon } = icon.icon.ionicons5;
    const { targetData, chartEditStore } = useTargetData_hook.useTargetData();
    const requestParamsTypeList = [httpEnum.RequestParamsTypeEnum.PARAMS, httpEnum.RequestParamsTypeEnum.HEADER];
    const interactActions = runtimeCore_esmBundler.computed(() => {
      const interactActions2 = targetData.value.interactActions;
      if (!interactActions2)
        return [];
      return interactActions2.map((value) => ({
        label: value.interactName,
        value: value.interactType
      }));
    });
    const option = runtimeCore_esmBundler.computed(() => {
      return targetData.value.option;
    });
    const fnGetRequest = (id, key) => {
      var _a, _b;
      if (!id)
        return {};
      const globalConfigPindApr = (_a = chartEditStore.requestGlobalConfig.requestDataPond.find((item) => {
        return item.dataPondId === id;
      })) == null ? void 0 : _a.dataPondRequestConfig.requestParams;
      if (globalConfigPindApr)
        return globalConfigPindApr[key];
      return (_b = chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]) == null ? void 0 : _b.request.requestParams[key];
    };
    const fnDimensionsAndSource = (interactOn) => {
      if (!interactOn || !targetData.value.interactActions)
        return [];
      const tableData = targetData.value.interactActions.find((item) => {
        return item.interactType === interactOn;
      });
      return (tableData == null ? void 0 : tableData.componentEmitEvents[option.value[eventEnum.COMPONENT_INTERACT_EVENT_KET]]) || [];
    };
    const fnEventsOptions = () => {
      var _a;
      const fnFlattern = (data) => {
        return data.reduce(
          (iter, val) => {
            if (!val.groupList && val.request.requestDataType === httpEnum.RequestDataTypeEnum.AJAX && val.request.requestUrl) {
              iter.push(val);
            }
            return val.groupList && val.groupList.length > 0 ? [...iter, ...fnFlattern(val.groupList)] : iter;
          },
          []
        );
      };
      const filterOptionList = fnFlattern(chartEditStore.componentList).filter((item) => {
        const isNotSelf = item.id !== targetData.value.id;
        const isNotStatic = item.chartConfig.chartFrame !== index_d.ChartFrameEnum.STATIC;
        const isNotGroup = !item.isGroup;
        return isNotSelf && isNotStatic && isNotGroup;
      });
      const mapOptionList = filterOptionList.map((item) => ({
        id: item.id,
        title: item.chartConfig.title,
        disabled: false,
        type: "componentList"
      }));
      const requestDataPond = chartEditStore.requestGlobalConfig.requestDataPond.map((item) => ({
        id: item.dataPondId,
        title: item.dataPondName,
        disabled: false,
        type: "requestDataPond"
      }));
      const tarArr = requestDataPond.concat(mapOptionList);
      (_a = targetData.value.events.interactEvents) == null ? void 0 : _a.forEach((iaItem) => {
        tarArr.forEach((optionItem) => {
          if (optionItem.id === iaItem.interactComponentId) {
            optionItem.disabled = true;
          }
        });
      });
      return tarArr;
    };
    const evAddEventsFn = () => {
      targetData.value.events.interactEvents.push({
        interactOn: void 0,
        interactComponentId: void 0,
        interactFn: {}
      });
    };
    const evDeleteEventsFn = (index) => {
      plugin.goDialog({
        message: "是否删除此关联交互模块?",
        onPositiveCallback: () => {
          targetData.value.events.interactEvents.splice(index, 1);
        }
      });
    };
    return (_ctx, _cache) => {
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_text = runtimeCore_esmBundler.resolveComponent("n-text");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      const _component_n_divider = runtimeCore_esmBundler.resolveComponent("n-divider");
      const _component_n_tag = runtimeCore_esmBundler.resolveComponent("n-tag");
      const _component_n_select = runtimeCore_esmBundler.resolveComponent("n-select");
      const _component_n_input_group = runtimeCore_esmBundler.resolveComponent("n-input-group");
      const _component_n_tooltip = runtimeCore_esmBundler.resolveComponent("n-tooltip");
      const _component_n_table = runtimeCore_esmBundler.resolveComponent("n-table");
      const _component_n_card = runtimeCore_esmBundler.resolveComponent("n-card");
      const _component_n_collapse_item = runtimeCore_esmBundler.resolveComponent("n-collapse-item");
      return interactActions.value.length ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_collapse_item, {
        key: 0,
        title: "组件交互",
        name: "1"
      }, {
        "header-extra": runtimeCore_esmBundler.withCtx(() => [
          runtimeCore_esmBundler.createVNode(_component_n_button, {
            type: "primary",
            tertiary: "",
            size: "small",
            onClick: runtimeDom_esmBundler.withModifiers(evAddEventsFn, ["stop"])
          }, {
            icon: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(AddIcon))
                ]),
                _: 1
              })
            ]),
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createTextVNode(" 新增 ")
            ]),
            _: 1
          }, 8, ["onClick"])
        ]),
        default: runtimeCore_esmBundler.withCtx(() => [
          !reactivity_esmBundler.unref(targetData).events.interactEvents.length ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_1, [
            runtimeCore_esmBundler.createElementVNode("img", {
              src: reactivity_esmBundler.unref(noData.default),
              alt: "暂无数据"
            }, null, 8, _hoisted_2),
            runtimeCore_esmBundler.createVNode(_component_n_text, { depth: 3 }, {
              default: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createTextVNode("暂无内容")
              ]),
              _: 1
            })
          ])) : runtimeCore_esmBundler.createCommentVNode("", true),
          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(reactivity_esmBundler.unref(targetData).events.interactEvents, (item, cardIndex) => {
            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_card, {
              key: cardIndex,
              class: "n-card-shallow",
              size: "small"
            }, {
              default: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createVNode(_component_n_space, { justify: "space-between" }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_text, null, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createTextVNode("关联组件 - " + shared_esmBundler.toDisplayString(cardIndex + 1), 1)
                      ]),
                      _: 2
                    }, 1024),
                    runtimeCore_esmBundler.createVNode(_component_n_button, {
                      type: "error",
                      text: "",
                      size: "small",
                      onClick: ($event) => evDeleteEventsFn(cardIndex)
                    }, {
                      icon: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(CloseIcon))
                          ]),
                          _: 1
                        })
                      ]),
                      _: 2
                    }, 1032, ["onClick"])
                  ]),
                  _: 2
                }, 1024),
                runtimeCore_esmBundler.createVNode(_component_n_divider, { style: { "margin": "10px 0" } }),
                runtimeCore_esmBundler.createVNode(_component_n_tag, {
                  bordered: false,
                  type: "primary"
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createTextVNode(" 选择目标组件 ")
                  ]),
                  _: 1
                }),
                runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), {
                  name: "触发事件",
                  alone: true
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    interactActions.value ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_input_group, { key: 0 }, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(_component_n_select, {
                          class: "select-type-options",
                          value: item.interactOn,
                          "onUpdate:value": ($event) => item.interactOn = $event,
                          size: "tiny",
                          options: interactActions.value
                        }, null, 8, ["value", "onUpdate:value", "options"])
                      ]),
                      _: 2
                    }, 1024)) : runtimeCore_esmBundler.createCommentVNode("", true)
                  ]),
                  _: 2
                }, 1024),
                runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), { alone: true }, {
                  name: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_text, null, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createTextVNode("绑定")
                      ]),
                      _: 1
                    }),
                    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.createVNode(_component_n_text, null, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createTextVNode("不支持「静态组件」支持「组件」「公共APi」")
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ]),
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_select, {
                      class: "select-type-options",
                      "value-field": "id",
                      "label-field": "title",
                      size: "tiny",
                      filterable: "",
                      placeholder: "仅展示符合条件的组件",
                      value: item.interactComponentId,
                      "onUpdate:value": ($event) => item.interactComponentId = $event,
                      options: fnEventsOptions()
                    }, null, 8, ["value", "onUpdate:value", "options"])
                  ]),
                  _: 2
                }, 1024),
                fnDimensionsAndSource(item.interactOn).length ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(SettingItemBox.default), {
                  key: 0,
                  name: "查询结果",
                  alone: true
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_table, {
                      size: "small",
                      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(["参数", "说明"], (item2) => {
                              return runtimeCore_esmBundler.createElementVNode("th", { key: item2 }, shared_esmBundler.toDisplayString(item2), 1);
                            }), 64))
                          ])
                        ]),
                        runtimeCore_esmBundler.createElementVNode("tbody", null, [
                          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(fnDimensionsAndSource(item.interactOn), (cItem, index) => {
                            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("tr", { key: index }, [
                              runtimeCore_esmBundler.createElementVNode("td", null, shared_esmBundler.toDisplayString(cItem.value), 1),
                              runtimeCore_esmBundler.createElementVNode("td", null, shared_esmBundler.toDisplayString(cItem.label), 1)
                            ]);
                          }), 128))
                        ])
                      ]),
                      _: 2
                    }, 1024)
                  ]),
                  _: 2
                }, 1024)) : runtimeCore_esmBundler.createCommentVNode("", true),
                runtimeCore_esmBundler.createVNode(_component_n_tag, {
                  bordered: false,
                  type: "primary"
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createTextVNode(" 关联目标请求参数 ")
                  ]),
                  _: 1
                }),
                (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(requestParamsTypeList, (requestParamsItem) => {
                  return runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(SettingItemBox.default), {
                    name: requestParamsItem,
                    key: requestParamsItem
                  }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(fnGetRequest(item.interactComponentId, requestParamsItem), (ovlValue, ovlKey, index) => {
                        return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(SettingItem.default), {
                          key: index,
                          name: `${ovlKey}`
                        }, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_select, {
                              size: "tiny",
                              value: item.interactFn[ovlKey],
                              "onUpdate:value": ($event) => item.interactFn[ovlKey] = $event,
                              options: fnDimensionsAndSource(item.interactOn),
                              clearable: ""
                            }, null, 8, ["value", "onUpdate:value", "options"])
                          ]),
                          _: 2
                        }, 1032, ["name"]);
                      }), 128)),
                      runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_text, {
                        class: "go-pt-1",
                        depth: "3"
                      }, {
                        default: runtimeCore_esmBundler.withCtx(() => [
                          runtimeCore_esmBundler.createTextVNode(" 暂无数据 ")
                        ]),
                        _: 2
                      }, 1536), [
                        [runtimeDom_esmBundler.vShow, JSON.stringify(fnGetRequest(item.interactComponentId, requestParamsItem)) === "{}"]
                      ])
                    ]),
                    _: 2
                  }, 1032, ["name"]);
                }), 64))
              ]),
              _: 2
            }, 1024);
          }), 128))
        ]),
        _: 1
      })) : runtimeCore_esmBundler.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
