import { defineComponent, useCssVars, unref, toRefs, watch, ref, openBlock, createElementBlock, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString, createTextVNode } from "vue";
import "./index.vue_vue_type_style_index_0_scoped_true_lang.mjs";
import _export_sfc from "../../../../_virtual/plugin-vue_export-helper.mjs";
const _hoisted_1 = { class: "table" };
const _hoisted_2 = { class: "tHeader" };
const _hoisted_3 = { class: "tBorder" };
const _hoisted_4 = ["title"];
const _hoisted_5 = { class: "unit" };
const __default__ = defineComponent({ name: "ETableFix" });
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    chartConfig: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const props = __props;
    useCssVars((_ctx) => ({
      "dc746c8e": unref(headerHeight) + "px",
      "5c94a95d": unref(fontSize) + "px",
      "85d0a526": unref(color),
      "62d75ffb": unref(headerBGC),
      "56783bdd": unref(fontWeight),
      "8277e5c0": unref(headerSpace) + "px",
      "750f4eba": unref(borderHeight) + "px",
      "28631029": unref(tBorderFontSize) + "px",
      "10b53802": unref(borderSpace) + "px",
      "9e6a76ae": unref(borderFontWeight),
      "1ea455be": unref(borderColor),
      "51db2149": unref(unitColor),
      "6618e7c8": unref(unitSize) + "px",
      "75bd7845": unref(borderBGC) ? unref(borderBGC) : unref(firstLineBgColor),
      "43f6245f": unref(borderBGCeven) ? unref(borderBGCeven) : unref(SecondLineBgColor),
      "79a976fe": unref(borderBGC) ? unref(borderBGC) : unref(thirdlyLineBgColor),
      "c9fbe924": unref(firstLineLeftColor),
      "92a13b44": unref(SecondLineLeftColor),
      "1a9889ea": unref(thirdlyLineLeftColor),
      "7b5275fc": unref(borderBGC),
      "011ec916": unref(borderBGCeven)
    }));
    const { dataset, tBorder, tHeader } = toRefs(props.chartConfig.option);
    const { columns, data } = toRefs(dataset.value);
    const { fontSize, headerHeight, headerSpace, color, headerBGC, fontWeight } = toRefs(tHeader.value);
    const {
      firstLineBgColor,
      firstLineLeftColor,
      SecondLineBgColor,
      SecondLineLeftColor,
      thirdlyLineBgColor,
      thirdlyLineLeftColor,
      borderHeight,
      borderSpace,
      fontSize: tBorderFontSize,
      fontWeight: borderFontWeight,
      color: borderColor,
      unitColor,
      unitSize,
      borderBGC,
      borderBGCeven
    } = toRefs(tBorder.value);
    watch(
      () => props.chartConfig.option.dataset,
      (n) => {
        getOtherLineWidth();
        init();
      },
      {
        deep: false
      }
    );
    let otherWidth = ref(null);
    console.log(columns.value);
    let init = () => {
      columns.value.forEach((item) => {
        let { width } = item;
        let singleWidth;
        if (typeof width == "number") {
          singleWidth = width + "px";
        } else if (typeof width == "string") {
          singleWidth = width;
        }
        item.style = { width: singleWidth || otherWidth.value };
      });
    };
    let getOtherLineWidth = () => {
      let calcString = "100%";
      columns.value.forEach((item) => {
        if (typeof item.width == "number") {
          calcString += ` - ${item.width + "px"}`;
        } else if (typeof item.width == "string") {
          calcString += ` - ${item.width}`;
        }
      });
      let remainingArrLength = columns.value.filter((item) => {
        return !item.width;
      }).length;
      otherWidth.value = `calc((${calcString}) / ${remainingArrLength})`;
    };
    getOtherLineWidth();
    init();
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(unref(columns), (item, index) => {
            return openBlock(), createElementBlock("div", {
              key: index,
              style: normalizeStyle({
                textAlign: "left",
                ...item.style
              })
            }, toDisplayString(item.title), 5);
          }), 128))
        ]),
        createElementVNode("div", _hoisted_3, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(unref(dataset).data, (item, index) => {
            return openBlock(), createElementBlock("div", { key: index }, [
              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(columns), (jtem, jndex) => {
                return openBlock(), createElementBlock("div", {
                  key: jndex,
                  style: normalizeStyle({
                    textAlign: jtem.align || "left",
                    ...jtem.style
                  }),
                  title: item[jtem.key]
                }, [
                  createTextVNode(toDisplayString(item[jtem.key]) + " ", 1),
                  createElementVNode("span", _hoisted_5, toDisplayString(jtem.unit || ""), 1)
                ], 12, _hoisted_4);
              }), 128))
            ]);
          }), 128))
        ])
      ]);
    };
  }
});
var _ETableList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-692ab220"]]);
export { _ETableList as default };
