"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 cloneDeep = require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/cloneDeep.js");
const noData = require("../../../../../../../assets/images/canvas/noData.png.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");
require("../../../../../../../store/modules/designStore/designStore.js");
const plugin = require("../../../../../../../utils/plugin.js");
require("../../../../../../../components/GoLoading/index.js");
require("../../../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
require("../../../../../../../components/GoSkeleton/index.vue.js");
const icon = require("../../../../../../../plugins/icon.js");
const chartEditStore = require("../../../../../../../store/modules/chartEditStore/chartEditStore.js");
const chartEditStore_d = require("../../../../../../../store/modules/chartEditStore/chartEditStore.d.js");
const index = require("../CreateColorRender/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 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 _withScopeId = (n) => (runtimeCore_esmBundler.pushScopeId("data-v-1aebdbd9"), n = n(), runtimeCore_esmBundler.popScopeId(), n);
const _hoisted_1 = { class: "create-content" };
const _hoisted_2 = { class: "create-color-setting-box" };
const _hoisted_3 = {
  key: 1,
  class: "no-data go-flex-center"
};
const _hoisted_4 = ["src"];
const _hoisted_5 = { class: "color-list-box" };
const _hoisted_6 = { class: "color-list" };
const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ runtimeCore_esmBundler.createElementVNode("span", null, " 创建 ", -1));
const _hoisted_8 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ runtimeCore_esmBundler.createElementVNode("span", null, " 应用数据 ", -1));
const _hoisted_9 = { class: "go-flex-items-center" };
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    modelShow: Boolean
  },
  emits: ["update:modelShow", "editSaveHandle"],
  setup(__props, { emit }) {
    const props = __props;
    const { DuplicateOutlineIcon, TrashIcon, ArrowDownIcon } = icon.icon.ionicons5;
    const defaultColor = {
      id: utils.getUUID(),
      name: "未命名",
      color: ["#6ae5bb", "#69e3de", "#5ac5ee", "#5ac4ee", "#4498ec", "#3c7ddf"]
    };
    const chartEditStore$1 = chartEditStore.useChartEditStore();
    const modelShowRef = reactivity_esmBundler.ref(false);
    let colorList = reactivity_esmBundler.reactive(chartEditStore$1.getEditCanvasConfig.chartCustomThemeColorInfo || []);
    const updateColor = reactivity_esmBundler.ref(void 0);
    const selectColor = reactivity_esmBundler.reactive({
      selectInfo: colorList[0]
    });
    runtimeCore_esmBundler.watch(
      () => props.modelShow,
      (newValue) => {
        modelShowRef.value = newValue;
        if (newValue) {
          if (colorList.length)
            selectColor.selectInfo = colorList[0];
        }
      }
    );
    const selectColorId = runtimeCore_esmBundler.computed(() => {
      var _a;
      return (_a = selectColor == null ? void 0 : selectColor.selectInfo) == null ? void 0 : _a.id;
    });
    const selectThemeColor = runtimeCore_esmBundler.computed(() => chartEditStore$1.getEditCanvasConfig.chartThemeColor);
    const selectHandle = (item) => {
      if (item.id === selectColorId.value)
        return;
      if (updateColor.value !== void 0) {
        plugin.goDialog({
          message: "当前有变动未保存，是否直接放弃修改？",
          onPositiveCallback: () => {
            updateColor.value = void 0;
            selectColor.selectInfo = item;
          }
        });
      } else {
        selectColor.selectInfo = item;
      }
    };
    const createColor = () => {
      const positiveHandle = () => {
        const newData = { ...cloneDeep.default(defaultColor), id: utils.getUUID() };
        selectColor.selectInfo = newData;
        colorList.push(newData);
        selectHandle(newData);
        updateColor.value = newData;
        saveHandle(false);
      };
      if (updateColor.value !== void 0) {
        plugin.goDialog({
          message: "当前有变动未保存，是否直接放弃修改？",
          onPositiveCallback: () => {
            updateColor.value = void 0;
            positiveHandle();
          }
        });
      } else {
        positiveHandle();
      }
    };
    const deleteHandle = (index2) => {
      const positiveHandle = () => {
        colorList.splice(index2, 1);
        chartEditStore$1.setEditCanvasConfig(chartEditStore_d.EditCanvasConfigEnum.CHART_CUSTOM_THEME_COLOR_INFO, cloneDeep.default(colorList));
        runtimeCore_esmBundler.nextTick(() => {
          if (colorList.length) {
            selectHandle(colorList[index2 - 1 > -1 ? index2 - 1 : index2]);
          } else {
            selectColor.selectInfo = void 0;
          }
        });
      };
      if (updateColor.value !== void 0) {
        plugin.goDialog({
          message: "当前有变动未保存，是否直接放弃修改？",
          onPositiveCallback: () => {
            updateColor.value = void 0;
            positiveHandle();
          }
        });
      } else {
        plugin.goDialog({
          message: `是否删除此颜色？`,
          onPositiveCallback: () => {
            positiveHandle();
          }
        });
      }
    };
    const updateColorHandle = (newColor) => {
      updateColor.value = newColor;
    };
    const saveHandle = (onMessage = true) => {
      if (!updateColor.value)
        return;
      const index2 = colorList.findIndex((item) => {
        var _a;
        return item.id === ((_a = updateColor.value) == null ? void 0 : _a.id);
      });
      if (index2 !== -1) {
        onMessage && window.$message.success("数据应用成功！");
        const updateColorPrefix = cloneDeep.default({ ...updateColor.value, name: updateColor.value.name || "未定义" });
        colorList.splice(index2, 1, updateColorPrefix);
        updateColor.value = void 0;
        const selectTheme = chartEditStore$1.getEditCanvasConfig.chartThemeColor;
        chartEditStore$1.setEditCanvasConfig(chartEditStore_d.EditCanvasConfigEnum.CHART_THEME_COLOR, "dark");
        runtimeCore_esmBundler.nextTick(() => {
          chartEditStore$1.setEditCanvasConfig(chartEditStore_d.EditCanvasConfigEnum.CHART_CUSTOM_THEME_COLOR_INFO, cloneDeep.default(colorList));
          chartEditStore$1.setEditCanvasConfig(chartEditStore_d.EditCanvasConfigEnum.CHART_THEME_COLOR, selectTheme);
        });
      } else {
        window.$message.error("数据应用失败！");
      }
    };
    const closeHandle = () => {
      const positiveHandle = () => {
        updateColor.value = void 0;
        selectColor.selectInfo = void 0;
        emit("update:modelShow", false);
      };
      if (updateColor.value !== void 0) {
        plugin.goDialog({
          message: "当前有变动未保存，是否直接放弃修改？",
          onPositiveCallback: () => {
            positiveHandle();
          }
        });
      } else {
        positiveHandle();
      }
    };
    const colorBackgroundImage = (item) => {
      return `linear-gradient(to right, ${item.color[0]} 0%, ${item.color[5]} 100%)`;
    };
    return (_ctx, _cache) => {
      const _component_n_text = runtimeCore_esmBundler.resolveComponent("n-text");
      const _component_n_timeline_item = runtimeCore_esmBundler.resolveComponent("n-timeline-item");
      const _component_n_timeline = runtimeCore_esmBundler.resolveComponent("n-timeline");
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_badge = runtimeCore_esmBundler.resolveComponent("n-badge");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      const _component_n_divider = runtimeCore_esmBundler.resolveComponent("n-divider");
      const _component_n_a = runtimeCore_esmBundler.resolveComponent("n-a");
      const _component_n_ellipsis = runtimeCore_esmBundler.resolveComponent("n-ellipsis");
      const _component_n_card = runtimeCore_esmBundler.resolveComponent("n-card");
      const _component_n_tooltip = runtimeCore_esmBundler.resolveComponent("n-tooltip");
      const _component_n_modal = runtimeCore_esmBundler.resolveComponent("n-modal");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_modal, {
        class: "go-chart-create-color",
        show: modelShowRef.value,
        "onUpdate:show": _cache[0] || (_cache[0] = ($event) => modelShowRef.value = $event),
        "mask-closable": false,
        closeOnEsc: false
      }, {
        default: runtimeCore_esmBundler.withCtx(() => [
          runtimeCore_esmBundler.createVNode(_component_n_card, {
            bordered: false,
            role: "dialog",
            size: "small",
            "aria-modal": "true",
            style: { "width": "900px", "height": "720px" }
          }, {
            header: runtimeCore_esmBundler.withCtx(() => []),
            "header-extra": runtimeCore_esmBundler.withCtx(() => []),
            action: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(_component_n_space, { justify: "end" }, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createVNode(_component_n_button, { onClick: closeHandle }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createTextVNode("操作完成")
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createElementVNode("div", _hoisted_1, [
                runtimeCore_esmBundler.createElementVNode("div", _hoisted_2, [
                  selectColorId.value ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index.default), {
                    key: 0,
                    selectColor: selectColor.selectInfo,
                    onUpdateColor: updateColorHandle
                  }, null, 8, ["selectColor"])) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_3, [
                    runtimeCore_esmBundler.createElementVNode("img", {
                      src: reactivity_esmBundler.unref(noData.default),
                      alt: "暂无数据"
                    }, null, 8, _hoisted_4),
                    runtimeCore_esmBundler.createVNode(_component_n_text, { depth: 3 }, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createTextVNode("暂未选择自定义颜色")
                      ]),
                      _: 1
                    })
                  ]))
                ]),
                runtimeCore_esmBundler.createElementVNode("div", _hoisted_5, [
                  runtimeCore_esmBundler.createVNode(_component_n_timeline, {
                    class: "pond-item-timeline",
                    style: { "width": "20px" }
                  }, {
                    default: runtimeCore_esmBundler.withCtx(() => [
                      runtimeCore_esmBundler.createVNode(_component_n_timeline_item, { type: "info" }),
                      runtimeCore_esmBundler.createVNode(_component_n_timeline_item, { type: "success" })
                    ]),
                    _: 1
                  }),
                  runtimeCore_esmBundler.createElementVNode("div", _hoisted_6, [
                    runtimeCore_esmBundler.createVNode(_component_n_space, null, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(_component_n_button, {
                          class: shared_esmBundler.normalizeClass(["create-btn", { "is-full": !!!selectColorId.value }]),
                          type: "primary",
                          ghost: !!!selectColorId.value,
                          secondary: !!selectColorId.value,
                          onClick: createColor
                        }, {
                          icon: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                              default: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(DuplicateOutlineIcon))
                              ]),
                              _: 1
                            })
                          ]),
                          default: runtimeCore_esmBundler.withCtx(() => [
                            _hoisted_7
                          ]),
                          _: 1
                        }, 8, ["class", "ghost", "secondary"]),
                        selectColorId.value ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_badge, {
                          key: 0,
                          show: updateColor.value !== void 0,
                          dot: ""
                        }, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_button, {
                              class: "create-btn",
                              type: "info",
                              secondary: "",
                              onClick: saveHandle
                            }, {
                              icon: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                                  default: runtimeCore_esmBundler.withCtx(() => [
                                    runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(ArrowDownIcon))
                                  ]),
                                  _: 1
                                })
                              ]),
                              default: runtimeCore_esmBundler.withCtx(() => [
                                _hoisted_8
                              ]),
                              _: 1
                            })
                          ]),
                          _: 1
                        }, 8, ["show"])) : runtimeCore_esmBundler.createCommentVNode("", true)
                      ]),
                      _: 1
                    }),
                    runtimeCore_esmBundler.createVNode(_component_n_divider, { style: { "margin": "10px 0" } }),
                    !selectColorId.value ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_text, {
                      key: 0,
                      class: "not-data-text",
                      depth: 3
                    }, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createTextVNode(" 暂无自定义颜色， "),
                        runtimeCore_esmBundler.createVNode(_component_n_a, { onClick: createColor }, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createTextVNode("立即创建")
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })) : runtimeCore_esmBundler.createCommentVNode("", true),
                    (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(reactivity_esmBundler.unref(colorList), (item, index2) => {
                      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
                        class: "color-card-box",
                        key: index2
                      }, [
                        runtimeCore_esmBundler.createVNode(_component_n_card, {
                          class: shared_esmBundler.normalizeClass(["color-card", { selected: item.id === selectColorId.value }]),
                          size: "small",
                          hoverable: "",
                          embedded: "",
                          onClick: ($event) => selectHandle(item)
                        }, {
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createElementVNode("div", _hoisted_9, [
                              runtimeCore_esmBundler.createVNode(_component_n_ellipsis, { style: { "text-align": "left", "width": "70px" } }, {
                                default: runtimeCore_esmBundler.withCtx(() => [
                                  runtimeCore_esmBundler.createTextVNode(shared_esmBundler.toDisplayString(item.name), 1)
                                ]),
                                _: 2
                              }, 1024),
                              (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(item.color, (colorItem, index22) => {
                                return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("span", {
                                  class: "theme-color-item",
                                  key: index22,
                                  style: shared_esmBundler.normalizeStyle({ backgroundColor: colorItem })
                                }, null, 4);
                              }), 128))
                            ]),
                            runtimeCore_esmBundler.createElementVNode("div", {
                              class: "theme-bottom",
                              style: shared_esmBundler.normalizeStyle({ backgroundImage: colorBackgroundImage(item) })
                            }, null, 4)
                          ]),
                          _: 2
                        }, 1032, ["class", "onClick"]),
                        runtimeCore_esmBundler.createVNode(_component_n_tooltip, { trigger: "hover" }, {
                          trigger: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createVNode(_component_n_button, {
                              text: "",
                              disabled: item.id === selectThemeColor.value,
                              onClick: ($event) => deleteHandle(index2)
                            }, {
                              default: runtimeCore_esmBundler.withCtx(() => [
                                runtimeCore_esmBundler.createVNode(_component_n_icon, {
                                  class: "go-ml-1 go-cursor-pointer",
                                  size: "16",
                                  depth: 3
                                }, {
                                  default: runtimeCore_esmBundler.withCtx(() => [
                                    runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(TrashIcon))
                                  ]),
                                  _: 1
                                })
                              ]),
                              _: 2
                            }, 1032, ["disabled", "onClick"])
                          ]),
                          default: runtimeCore_esmBundler.withCtx(() => [
                            runtimeCore_esmBundler.createTextVNode(" 删除自定义颜色 ")
                          ]),
                          _: 2
                        }, 1024)
                      ]);
                    }), 128))
                  ])
                ])
              ])
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["show"]);
    };
  }
});
exports.default = _sfc_main;
