"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("../../../../../store/modules/designStore/designStore.js");
require("../../../../../settings/designSetting.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 cloneDeep = require("../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/cloneDeep.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("../../../../../../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");
require("../../../../../components/GoLoading/index.js");
const useChartDataFetch_hook = require("../../../../../hooks/useChartDataFetch.hook.js");
require("../../../../../api/axios.js");
require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/index.js");
require("../../../../../store/modules/langStore/langStore.js");
const chartEditStore = require("../../../../../store/modules/chartEditStore/chartEditStore.js");
const config = require("./config.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-66b968b8"), n = n(), runtimeCore_esmBundler.popScopeId(), n);
const _hoisted_1 = { class: "label-column" };
const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ runtimeCore_esmBundler.createElementVNode("div", { class: "laset" }, " ", -1));
const _hoisted_3 = { class: "capsule-container" };
const _hoisted_4 = {
  key: 0,
  class: "capsule-item-value"
};
const _hoisted_5 = { class: "unit-label" };
const _hoisted_6 = {
  key: 0,
  class: "unit-text"
};
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    chartConfig: {
      type: Object,
      default: () => ({})
    }
  },
  setup(__props) {
    const props = __props;
    const state = reactivity_esmBundler.reactive({
      defaultConfig: config.option,
      mergedConfig: null,
      capsuleLength: [],
      capsuleValue: [],
      labelData: [],
      capsuleItemHeight: ""
    });
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option,
      (newVal) => {
        calcData(newVal);
      },
      {
        deep: true
      }
    );
    const calcData = (data, type) => {
      let cloneConfig = cloneDeep.default(props.chartConfig.option || {});
      state.mergedConfig = cloneConfig;
      if (type == "preview") {
        cloneConfig.dataset = data;
      }
      calcCapsuleLengthAndLabelData(state.mergedConfig.dataset);
    };
    const calcCapsuleLengthAndLabelData = (dataset) => {
      try {
        const { source } = dataset;
        if (!source || !source.length)
          return;
        state.capsuleItemHeight = numberSizeHandle(state.mergedConfig.itemHeight);
        const capsuleValue = source.map((item) => item[state.mergedConfig.dataset.dimensions[1]]);
        const maxValue = Math.max(...capsuleValue);
        state.capsuleValue = capsuleValue;
        state.capsuleLength = capsuleValue.map((v) => maxValue ? v / maxValue : 0);
        const oneFifth = maxValue / 5;
        const labelData = Array.from(new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth))));
        state.labelData = labelData;
      } catch (error) {
        console.warn(error);
      }
    };
    const numberSizeHandle = (val) => {
      return val + "px";
    };
    runtimeCore_esmBundler.onMounted(() => {
      calcData(props.chartConfig.option);
    });
    useChartDataFetch_hook.useChartDataFetch(props.chartConfig, chartEditStore.useChartEditStore, (newData) => {
      calcData(newData, "preview");
    });
    return (_ctx, _cache) => {
      return state.mergedConfig ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
        key: 0,
        class: "go-dv-capsule-chart",
        style: shared_esmBundler.normalizeStyle({
          fontSize: numberSizeHandle(state.mergedConfig.valueFontSize),
          paddingLeft: numberSizeHandle(state.mergedConfig.paddingLeft),
          paddingRight: numberSizeHandle(state.mergedConfig.paddingRight)
        })
      }, [
        runtimeCore_esmBundler.createElementVNode("div", _hoisted_1, [
          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(state.mergedConfig.dataset.source, (item) => {
            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
              key: item[state.mergedConfig.dataset.dimensions[0]],
              style: shared_esmBundler.normalizeStyle({ height: state.capsuleItemHeight, lineHeight: state.capsuleItemHeight })
            }, shared_esmBundler.toDisplayString(item[state.mergedConfig.dataset.dimensions[0]]), 5);
          }), 128)),
          _hoisted_2
        ]),
        runtimeCore_esmBundler.createElementVNode("div", _hoisted_3, [
          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(state.capsuleLength, (capsule, index) => {
            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
              key: index,
              class: "capsule-item",
              style: shared_esmBundler.normalizeStyle({ height: state.capsuleItemHeight })
            }, [
              runtimeCore_esmBundler.createElementVNode("div", {
                class: "capsule-item-column",
                style: shared_esmBundler.normalizeStyle(`width: ${capsule * 100}%; background-color: ${state.mergedConfig.colors[index % state.mergedConfig.colors.length]};height:calc(100% - ${2}px);`)
              }, [
                state.mergedConfig.showValue ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_4, shared_esmBundler.toDisplayString(state.capsuleValue[index]), 1)) : runtimeCore_esmBundler.createCommentVNode("", true)
              ], 4)
            ], 4);
          }), 128)),
          runtimeCore_esmBundler.createElementVNode("div", _hoisted_5, [
            (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(state.labelData, (label, index) => {
              return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
                key: label + index
              }, shared_esmBundler.toDisplayString(label), 1);
            }), 128))
          ])
        ]),
        state.mergedConfig.unit ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_6, shared_esmBundler.toDisplayString(state.mergedConfig.unit), 1)) : runtimeCore_esmBundler.createCommentVNode("", true)
      ], 4)) : runtimeCore_esmBundler.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
