import { reactive as ue, onMounted as pe, computed as X, resolveComponent as U, openBlock as A, createBlock as oe, unref as v, withCtx as F, createElementVNode as u, toDisplayString as R, createElementBlock as G, Fragment as se, renderList as ae, normalizeClass as fe, createVNode as J, createCommentVNode as ne, mergeProps as et, createTextVNode as he, ref as we, nextTick as ce, watch as Ve, isRef as tt, createApp as lt, markRaw as Te, shallowRef as ot, onBeforeMount as nt, onUnmounted as it, renderSlot as rt, createSlots as st, normalizeStyle as Ee, withDirectives as at, vShow as ct } from "vue";
import { e as Fe, A as ut, T as dt, D as ft, i as ht, L as pt, a as le, H as mt } from "./@visactor.js";
import { _ as Ne, u as gt, D as yt } from "./vendor.js";
import ke from "vuedraggable";
/* empty css    */
import { download as bt, formatSummaryCell as vt } from "./composition.js";
import { e as wt } from "./element-plus.js";
const Ct = { class: "hp100 flexMode g16 p16" }, _t = { class: "w200 hp100 border radius8 fs14" }, xt = { class: "flexMode vc h36 p8 bg-gray3 border-b txt-nowrap" }, St = { class: "p4" }, Tt = ["onClick"], Et = { class: "txt-nowrap" }, kt = {
  class: "flexMode vs hp100 border radius8",
  style: { width: "calc(100% - 12.5rem)" }
}, $t = { class: "wp50 border-r fs14" }, Mt = { class: "flexMode vc g8 h36 p8 bg-gray3 border-b txt-nowrap" }, Lt = { class: "tagArea blue small" }, At = { class: "p4" }, Vt = {
  key: 0,
  class: "absCenter tag rect"
}, Ft = { class: "flexMode vc g8" }, Nt = ["txt", "onClick"], Ht = { class: "wp50 border-r fs14" }, Ot = { class: "flexMode vc g8 h36 p8 bg-gray3 border-b txt-nowrap" }, zt = { class: "tagArea blue small" }, It = {
  class: "relative",
  style: { height: "calc(100% - 2.25rem)" }
}, Rt = {
  class: "relative p4 bg-body",
  style: { height: "30%" }
}, Bt = {
  key: 0,
  class: "absCenter tag rect"
}, Dt = { class: "columnItem flexMode vc hb h40 g8 p4-8 mb4 radius4 border bg-white" }, jt = { class: "flexMode vc g8 txt-nowrap" }, Kt = { class: "flexMode vc g8" }, Wt = ["txt", "onClick"], Ut = { class: "h16 flexMode hc vc g4" }, Gt = { class: "fs10" }, qt = {
  class: "relative p4",
  style: { height: "calc(70% - 1rem)" }
}, Jt = {
  key: 0,
  class: "absCenter tag rect"
}, Yt = { class: "columnItem flexMode vc hb h40 g8 p4-8 mb4 radius4 border" }, Zt = { class: "flexMode vc g8 txt-nowrap" }, Pt = { class: "flexMode vc g4" }, Xt = ["txt", "onClick"], Qt = ["txt", "onClick"], el = /* @__PURE__ */ Object.assign({
  name: "MvcVTableColumnConfig",
  inheritAttrs: !1
}, {
  __name: "ColumnConfig",
  props: {
    tableName: {
      type: String,
      default: ""
    }
  },
  emits: "close",
  setup(c, { emit: t }) {
    const n = c, e = ue({
      loading: !1,
      type: "normal",
      columns: {
        normal: [],
        mmp: [],
        asa: []
      },
      fixed: [],
      visible: [],
      selection: [],
      operation: [],
      columnType: {},
      mounted: !1
    });
    pe(() => {
      o();
    });
    const i = t, o = () => {
      i("mounted");
      const h = JSON.parse(localStorage.getItem(`${n.tableName}_Column`)), a = {};
      h.forEach((l) => {
        l.type && (a[l.type] = !0), l.visible ? l.type === "selection" ? e.selection.push(l) : l.type === "operation" ? e.operation.push(l) : l.label && (l.fixed ? e.fixed.push(l) : e.visible.push(l)) : l.type === "mmp" ? e.columns.mmp.push(l) : l.type === "asa" ? e.columns.asa.push(l) : e.columns.normal.push(l);
      }), e.columnType = a;
    }, p = (h) => {
      e.type = h;
    }, b = (h, a) => {
      h.visible = !0, e.visible.unshift(h), h.type ? e.columns[h.type].splice(a, 1) : e.columns.normal.splice(a, 1);
    }, m = (h, a) => {
      e.fixed.unshift(h), e.visible.splice(a, 1);
    }, w = (h, a) => {
      e.visible.unshift(h), e.fixed.splice(a, 1);
    }, x = (h, a) => {
      e.visible.splice(a, 1), h.type ? e.columns[h.type].unshift(h) : e.columns.normal.unshift(h);
    }, N = async () => {
      e.loading = !0, window.$pm(() => {
        const { fixed: h, visible: a, columns: l, selection: _, operation: g } = e;
        let $ = [];
        Object.keys(l).map((M) => {
          $ = $.concat(l[M]);
        }), h.forEach((M) => M.fixed = "left"), $.forEach((M) => M.visible = !1);
        const L = _.concat(h, a, $, g);
        L.forEach((M, ee) => M.sort = ee), localStorage.setItem(`${n.tableName}_Column`, JSON.stringify(L)), e.loading = !1, i("close"), i("init-column");
      });
    }, D = () => {
      e.loading = !0, localStorage.removeItem(`${n.tableName}_Column`), window.$pm(() => {
        e.loading = !1, i("close"), i("init-column");
      }, 4);
    }, r = X(() => {
      var h;
      return ((h = globalThis.$config.options) == null ? void 0 : h.drawerHeight) || 540;
    }), f = X(() => (r.value * 0.3).toFixed(0)), T = X(() => (r.value * 0.7 - 26).toFixed(0)), B = X(() => [
      {
        label: "Base Info",
        value: "normal"
      },
      {
        label: "Asa Metrics",
        value: "asa",
        hide: !e.columnType.asa
      },
      {
        label: "MMP Metrics",
        value: "mmp",
        hide: !e.columnType.mmp
      }
    ]);
    return (h, a) => {
      const l = U("el-scrollbar"), _ = U("DrawerArea");
      return A(), oe(_, {
        loading: v(e).loading,
        noscroll: "",
        "cancel-txt": "Reset",
        "cancel-icon": "im-reload",
        class: "MvcVTableColumnConfig",
        onCancel: D,
        onSubmit: N
      }, {
        default: F(() => [
          u("div", Ct, [
            u("div", _t, [
              u("div", xt, R(h.$l("Column Type")), 1),
              u("div", St, [
                (A(!0), G(se, null, ae(v(B), (g) => (A(), G("div", {
                  key: g.value,
                  class: fe(["typeItem p8-16 mb4 radius4", [v(e).type === g.value && "active", g.hide && "hide"]]),
                  onClick: ($) => p(g.value)
                }, [
                  u("span", Et, R(g.label), 1)
                ], 10, Tt))), 128))
              ])
            ]),
            u("div", kt, [
              u("div", $t, [
                u("div", Mt, [
                  u("span", null, R(h.$l("Columns")), 1),
                  u("span", Lt, R(v(e).columns[v(e).type].length), 1)
                ]),
                J(l, { style: { height: "calc(100% - 2.25rem)" } }, {
                  default: F(() => [
                    u("div", At, [
                      v(e).columns[v(e).type].length === 0 ? (A(), G("span", Vt, R(h.$l("No Columns")), 1)) : ne("", !0),
                      (A(!0), G(se, null, ae(v(e).columns[v(e).type], (g, $) => (A(), G("div", {
                        key: g.prop,
                        class: "columnItem flexMode vc hb h40 g8 p4-8 mb4 border radius4 txt-nowrap"
                      }, [
                        u("span", null, R(h.$l(g.label)), 1),
                        u("div", Ft, [
                          u("div", {
                            class: "tipbtn left",
                            txt: h.$l("Visible"),
                            onClick: (L) => b(g, $)
                          }, [...a[0] || (a[0] = [
                            u("i", { class: "imicon im-plus-square fs20 txt-p hover" }, null, -1)
                          ])], 8, Nt)
                        ])
                      ]))), 128))
                    ])
                  ]),
                  _: 1
                })
              ]),
              u("div", Ht, [
                u("div", Ot, [
                  u("span", null, R(h.$l("Visible Columns")), 1),
                  u("span", zt, R(v(e).visible.length), 1)
                ]),
                u("div", It, [
                  u("div", Rt, [
                    v(e).fixed.length === 0 ? (A(), G("span", Bt, R(h.$l("No Fixed Columns")), 1)) : ne("", !0),
                    J(l, { height: v(f) }, {
                      default: F(() => [
                        J(v(ke), {
                          list: v(e).fixed,
                          "item-key": (g) => g,
                          handle: ".im-handle",
                          "ghost-class": "ghost"
                        }, {
                          item: F(({ element: g, index: $ }) => [
                            u("div", Dt, [
                              u("div", jt, [
                                a[1] || (a[1] = u("div", { class: "flexMode hc vc w24 h24 radius4 grab hover-bg-fa" }, [
                                  u("i", { class: "imicon im-handle" })
                                ], -1)),
                                u("span", null, R(h.$l(g.label)), 1)
                              ]),
                              u("div", Kt, [
                                u("div", {
                                  class: "tipbtn red left",
                                  txt: h.$l("Unfixed"),
                                  onClick: (L) => w(g, $)
                                }, [...a[2] || (a[2] = [
                                  u("i", { class: "imicon im-minus-square fs20 txt-p hover" }, null, -1)
                                ])], 8, Wt)
                              ])
                            ])
                          ]),
                          _: 1
                        }, 8, ["list", "item-key"])
                      ]),
                      _: 1
                    }, 8, ["height"])
                  ]),
                  u("div", Ut, [
                    a[3] || (a[3] = u("i", { class: "imicon im-doubleup fs12" }, null, -1)),
                    u("span", Gt, R(h.$l("Fixed")), 1),
                    a[4] || (a[4] = u("i", { class: "imicon im-doubleup fs12" }, null, -1))
                  ]),
                  u("div", qt, [
                    v(e).visible.length === 0 ? (A(), G("span", Jt, R(h.$l("No Columns")), 1)) : ne("", !0),
                    J(l, { height: v(T) }, {
                      default: F(() => [
                        J(v(ke), {
                          list: v(e).visible,
                          "item-key": (g) => g,
                          options: { lockAxis: "y" },
                          handle: ".im-handle",
                          "ghost-class": "ghost"
                        }, {
                          item: F(({ element: g, index: $ }) => [
                            u("div", Yt, [
                              u("div", Zt, [
                                a[5] || (a[5] = u("div", { class: "flexMode hc vc w24 h24 radius4 grab hover-bg-fa" }, [
                                  u("i", { class: "imicon im-handle" })
                                ], -1)),
                                u("span", null, R(h.$l(g.label)), 1)
                              ]),
                              u("div", Pt, [
                                u("div", {
                                  class: "tipbtn left",
                                  txt: h.$l("Fixed"),
                                  onClick: (L) => m(g, $)
                                }, [...a[6] || (a[6] = [
                                  u("i", { class: "imicon im-plus-square fs20 txt-p hover" }, null, -1)
                                ])], 8, Xt),
                                u("div", {
                                  class: "tipbtn red left",
                                  txt: h.$l("Hide"),
                                  onClick: (L) => x(g, $)
                                }, [...a[7] || (a[7] = [
                                  u("i", { class: "imicon im-close-square fs20 txt-p hover" }, null, -1)
                                ])], 8, Qt)
                              ])
                            ])
                          ]),
                          _: 1
                        }, 8, ["list", "item-key"])
                      ]),
                      _: 1
                    }, 8, ["height"])
                  ])
                ])
              ])
            ])
          ])
        ]),
        _: 1
      }, 8, ["loading"]);
    };
  }
}), tl = /* @__PURE__ */ Ne(el, [["__scopeId", "data-v-73161392"]]), ll = { class: "p16" }, ol = { class: "flexMode vc hb p16 border radius8 bg-white" }, nl = { class: "flexMode vc g8" }, il = { class: "m0" }, rl = { class: "p16" }, sl = { class: "sticky flexMode vc g16 pb16 z9 backdrop radius4" }, al = { class: "fw700" }, cl = { class: "flexMode vc g8" }, ul = /* @__PURE__ */ Object.assign({
  name: "MvcVTableColumnDownload",
  inheritAttrs: !1
}, {
  __name: "ColumnDownload",
  props: {
    tableName: {
      type: String,
      default: ""
    },
    list: {
      type: Array,
      default: () => []
    },
    selection: {
      type: Array,
      default: () => []
    }
  },
  emits: ["mounted"],
  setup(c, { emit: t }) {
    const n = c, e = ue({
      loading: !1,
      columns: [],
      checked: [],
      useHead: !1,
      onlySelection: !1,
      mounted: !1
    });
    pe(() => {
      o();
    });
    const i = t, o = () => {
      i("mounted"), p(), b();
    }, p = () => {
      const a = JSON.parse(localStorage.getItem(`${n.tableName}_Column`)), l = ["selection", "operation"];
      e.columns = a.filter(
        (_) => !l.includes(_.type) && _.label
      );
    }, b = () => {
      n.selection.length && (e.onlySelection = !0);
    }, m = (a, l) => {
      a ? l.children.forEach((_) => {
        _.visible = !0;
      }) : l.children.forEach((_) => {
        _.visible = !1;
      });
    }, w = (a) => {
      window.$copy(N({ type: a }));
    }, x = async () => {
      e.loading = !0;
      try {
        const a = N("download");
        let l = e.fileName || D.value;
        l && !l.toLowerCase().endsWith(".csv") && (l = `${l}.csv`), await bt({ content: a, filename: l, bom: !0 });
      } finally {
        e.loading = !1;
      }
    }, N = (a) => {
      const l = e.onlySelection ? n.selection : n.list, _ = {}, g = [];
      e.columns.filter((q) => q.visible).forEach((q) => {
        g.push(window.$l(q.label)), _[q.prop] = !0;
      });
      let $ = "", L = [], M = a === "download" ? "," : "	";
      ["download", "withHeadCopy"].includes(a) && ($ = g.join(M) + `
`);
      let ee = [], te;
      return Object.keys(_).forEach((q, H) => {
        q.includes("country") && (te = H);
        const k = [];
        l.forEach((W) => {
          W[q] !== void 0 && k.push(W[q]);
        }), ee.push(k);
      }), ee.forEach((q, H) => {
        !e.useCountryCode && te === H ? q.forEach((k, W) => {
          let P = k;
          window.$getType(k) === "Array" ? P = k.map((ie) => h[ie.toUpperCase()].label.$l()).join(",") : window.$getType(k) === "String" ? P = k.split(",").map((ie) => h[ie.toUpperCase()].label.$l()).join(",") : P = JSON.stringify(k), L[W] ? L[W] += P + M : L[W] = P + M;
        }) : q.forEach((k, W) => {
          L[W] ? L[W] += k + M : L[W] = k + M;
        });
      }), `${$}${L.join(`
`)}`;
    }, D = X(() => {
      const a = window.$d().format("YYYYMMDDHHmmss");
      return `${n.tableName}_${a}`;
    }), r = X(() => {
      const a = {};
      return e.columns.forEach((l) => {
        const _ = l.type ? l.type : "normal", g = {
          label: T[_],
          type: _,
          visible: 0
        };
        a[_] ? (a[_].children.push(l), l.visible && a[_].visible++) : (g.children = [l], l.visible && g.visible++, a[_] = g);
      }), Object.keys(a).forEach((l) => {
        const _ = a[l].visible === a[l].children.length, g = a[l].visible === 0;
        _ ? (a[l].checkstatus = !0, a[l].indeterminate = !1) : g ? (a[l].checkstatus = !1, a[l].indeterminate = !1) : (a[l].checkstatus = !1, a[l].indeterminate = !0);
      }), a;
    }), f = X(() => {
      const a = [];
      for (let _ in r.value)
        a.push(r.value[_].children);
      return a.flat().filter((_) => _.visible).length <= 0;
    }), T = {
      asa: "Asa Metrics",
      normal: "Base Info",
      mmp: "MMP Metrics"
    };
    "Check All".$l(), "Cancel All".$l();
    const B = [
      {
        label: "Pure Data",
        value: "pureDataCopy",
        icon: "im-list"
      },
      {
        label: "With Table Head",
        value: "withHeadCopy",
        icon: "im-header"
      }
    ], h = {};
    return (a, l) => {
      const _ = U("el-checkbox"), g = U("el-button"), $ = U("el-dropdown-item"), L = U("el-dropdown-menu"), M = U("el-dropdown"), ee = U("el-switch"), te = U("Input"), q = U("DrawerArea");
      return A(), oe(q, et(a.$attrs, { class: "MvcVTableColumnDownload" }), {
        cancel: F(() => [
          J(te, {
            modelValue: v(e).fileName,
            "onUpdate:modelValue": l[2] || (l[2] = (H) => v(e).fileName = H),
            icon: "catalog",
            placeholder: v(D),
            class: "w600"
          }, {
            prefix: F(() => [...l[4] || (l[4] = [
              u("i", { class: "imicon im-file-text" }, null, -1)
            ])]),
            append: F(() => [
              J(g, {
                loading: v(e).loading,
                disabled: v(f),
                onClick: x
              }, {
                icon: F(() => [...l[5] || (l[5] = [
                  u("i", { class: "imicon im-download" }, null, -1)
                ])]),
                default: F(() => [
                  he(" " + R(a.$l("Download")), 1)
                ]),
                _: 1
              }, 8, ["loading", "disabled"])
            ]),
            _: 1
          }, 8, ["modelValue", "placeholder"])
        ]),
        submit: F(() => [...l[6] || (l[6] = [])]),
        default: F(() => [
          u("div", ll, [
            u("div", ol, [
              u("div", null, [
                u("div", nl, [
                  u("h4", il, R(a.$l("Total")), 1),
                  u("span", null, R(n.list.length), 1)
                ]),
                n.selection.length ? (A(), oe(_, {
                  key: 0,
                  modelValue: v(e).onlySelection,
                  "onUpdate:modelValue": l[0] || (l[0] = (H) => v(e).onlySelection = H),
                  label: `${a.$l("Only Selection")}: ${n.selection.length}`
                }, null, 8, ["modelValue", "label"])) : ne("", !0)
              ]),
              J(M, {
                trigger: "click",
                placement: "bottom",
                onCommand: w
              }, {
                dropdown: F(() => [
                  J(L, null, {
                    default: F(() => [
                      (A(), G(se, null, ae(B, (H, k) => J($, {
                        key: k,
                        command: H.command
                      }, {
                        default: F(() => [
                          u("i", {
                            class: fe(["imicon", H.icon])
                          }, null, 2),
                          he(" " + R(H.label.$l()), 1)
                        ]),
                        _: 2
                      }, 1032, ["command"])), 64))
                    ]),
                    _: 1
                  })
                ]),
                default: F(() => [
                  J(g, {
                    type: "primary",
                    class: "reverse"
                  }, {
                    icon: F(() => [...l[3] || (l[3] = [
                      u("i", { class: "imicon im-down" }, null, -1)
                    ])]),
                    default: F(() => [
                      he(" " + R(a.$l("Copy to Clipboard")), 1)
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ])
          ]),
          u("div", rl, [
            (A(!0), G(se, null, ae(v(r), (H) => (A(), G("div", {
              key: H.type
            }, [
              u("div", sl, [
                u("span", al, R(H.label), 1),
                J(_, {
                  modelValue: H.checkstatus,
                  "onUpdate:modelValue": (k) => H.checkstatus = k,
                  indeterminate: H.indeterminate,
                  label: a.$l("Check All"),
                  onChange: (k) => m(k, H)
                }, null, 8, ["modelValue", "onUpdate:modelValue", "indeterminate", "label", "onChange"])
              ]),
              (A(!0), G(se, null, ae(H.children, (k, W) => (A(), oe(_, {
                modelValue: k.visible,
                "onUpdate:modelValue": (P) => k.visible = P,
                key: W,
                label: k.label,
                value: k.value,
                class: "fullCheckbox border mb8"
              }, {
                default: F(() => {
                  var P;
                  return [
                    u("div", cl, [
                      u("span", null, R(k.label), 1),
                      (P = k.prop) != null && P.includes("country") ? (A(), oe(ee, {
                        key: 0,
                        modelValue: v(e).useCountryCode,
                        "onUpdate:modelValue": l[1] || (l[1] = (ie) => v(e).useCountryCode = ie),
                        "inline-prompt": "",
                        "active-text": "Use Alpha-2 Code",
                        "inactive-text": "Use Country Name",
                        class: "primarySwitch"
                      }, null, 8, ["modelValue"])) : ne("", !0)
                    ])
                  ];
                }),
                _: 2
              }, 1032, ["modelValue", "onUpdate:modelValue", "label", "value"]))), 128))
            ]))), 128))
          ])
        ]),
        _: 1
      }, 16);
    };
  }
});
class dl {
  constructor(t) {
    this.editorType = "Input", this.eventHandlers = [], this.editorConfig = t != null && typeof t == "object" && !Array.isArray(t) ? t : /* @__PURE__ */ Object.create(null);
  }
  getInputElement() {
    return this.element;
  }
  createElement() {
    this.eventHandlers = [];
    const t = document.createElement("input");
    t.setAttribute("type", "text"), this.editorConfig.readonly && t.setAttribute("readonly", `${this.editorConfig.readonly}`), t.style.position = "absolute", t.style.padding = "4px", t.style.width = "100%", t.style.boxSizing = "border-box", t.style.borderRadius = "0px", t.style.setProperty(
      "background-color",
      "var(--el-fill-color-blank, var(--el-bg-color, #ffffff))"
    ), t.style.setProperty(
      "color",
      "var(--el-input-text-color, var(--el-text-color-regular, #606266))"
    ), t.style.setProperty("border", "2px solid var(--el-border-color, #dcdfe6)");
    const n = () => {
      t.style.setProperty("border-color", "var(--el-color-primary)"), t.style.outline = "none";
    };
    t.addEventListener("focus", n), this.eventHandlers.push({ type: "focus", handler: n });
    const e = () => {
      if (t.style.setProperty("border-color", "var(--el-border-color)"), this.table && this.element && this.element.style.opacity === "0") {
        const b = this.table.stateManager.select.cellPos;
        (b.col !== this.col || b.row !== this.row) && this.onEnd();
      }
    };
    t.addEventListener("blur", e), this.eventHandlers.push({ type: "blur", handler: e }), this.element = t, this.container.appendChild(t);
    const i = (b) => {
      var m, w;
      b.key === "a" && (b.ctrlKey || b.metaKey) && ((w = (m = this.table) == null ? void 0 : m.editorManager) != null && w.editingEditor) && b.stopPropagation();
    };
    t.addEventListener("keydown", i), this.eventHandlers.push({ type: "keydown", handler: i });
    const o = (b) => {
      b.preventDefault();
    };
    t.addEventListener("wheel", o), this.eventHandlers.push({ type: "wheel", handler: o });
    const p = (b) => {
      var m;
      ((m = this.element) == null ? void 0 : m.style.opacity) === "0" && b.preventDefault();
    };
    t.addEventListener("paste", p), this.eventHandlers.push({ type: "paste", handler: p });
  }
  setValue(t) {
    this.element.value = t !== void 0 ? t : "";
  }
  getValue() {
    var t;
    return (t = this.element) == null ? void 0 : t.value;
  }
  prepareEdit({ referencePosition: t, container: n, table: e, col: i, row: o }) {
    this.container = n, this.table = e, this.col = i, this.row = o;
    const p = this.table.stateManager.select.cellPos;
    p.col === this.col && p.row === this.row && (this.element ? n.contains(this.element) || (this.element.parentElement.removeChild(this.element), this.container.appendChild(this.element)) : this.createElement(), this.element.style.opacity = "0", this.element.style.pointerEvents = "none", t != null && t.rect && this.adjustPosition(t.rect), this.element.focus());
  }
  onStart({
    value: t,
    referencePosition: n,
    container: e,
    endEdit: i,
    table: o,
    col: p,
    row: b
  }) {
    this.container = e, this.successCallback = i, this.table = o, this.col = p, this.row = b, this.element ? e.contains(this.element) || (this.element.parentElement.removeChild(this.element), this.container.appendChild(this.element)) : (this.createElement(), n != null && n.rect && this.adjustPosition(n.rect)), t != null && this.setValue(t), this.element.style.opacity = "1", this.element.style.pointerEvents = "auto", this.element.focus();
  }
  adjustPosition(t) {
    const n = t.top - 1, e = t.left - 1, i = t.width + 2, o = t.height + 2;
    this.element.style.top = `${n}px`, this.element.style.left = `${e}px`, this.element.style.width = `${i}px`, this.element.style.height = `${o}px`;
  }
  endEditing() {
  }
  onEnd() {
    if (!this.element) return;
    const t = this.element;
    this.eventHandlers.forEach(({ type: e, handler: i }) => {
      t.removeEventListener(e, i);
    }), this.eventHandlers = [];
    const n = t.parentNode;
    if (n)
      try {
        n.removeChild(t);
      } catch (e) {
        if (e instanceof Error && e.name !== "NotFoundError")
          throw e;
      }
    this.element = void 0;
  }
  isEditorElement(t) {
    return t === this.element;
  }
  validateValue() {
    return !0;
  }
}
const $e = /* @__PURE__ */ new Set();
function fl(c, t, n) {
  const e = String(c || "t").replace(/[^a-zA-Z0-9_]/g, "_"), i = String(t || "c").replace(/[^a-zA-Z0-9_]/g, "_"), o = `mvframe_input_${e}_${i}`;
  if ($e.has(o))
    return o;
  const p = n != null && typeof n == "object" && !Array.isArray(n) ? n : /* @__PURE__ */ Object.create(null);
  return Fe(o, new dl(p)), $e.add(o), o;
}
const hl = /* @__PURE__ */ Object.assign({
  name: "VTableElementSelectEditor",
  inheritAttrs: !1
}, {
  __name: "VTableElementSelectEditor",
  props: {
    modelValue: {
      type: [String, Number],
      default: void 0
    },
    /** 与列 `vtable.editorValues` 一致：字符串列表，或 `{ value, label }` */
    values: {
      type: Array,
      default: () => []
    }
  },
  emits: ["update:modelValue", "commit"],
  setup(c, { expose: t, emit: n }) {
    const e = c, i = n, o = we(e.modelValue), p = we(null);
    pe(() => {
      ce(() => {
        var w, x;
        (x = (w = p.value) == null ? void 0 : w.focus) == null || x.call(w);
      });
    });
    const b = (w) => {
      i("update:modelValue", w), i("commit", w);
    }, m = X(() => (e.values || []).map((x) => {
      if (x != null && typeof x == "object") {
        const N = "value" in x ? x.value : "v" in x ? x.v : x.label ?? x.text, D = "label" in x ? x.label : "text" in x ? x.text : String(N);
        return { value: N, label: D };
      }
      return { value: x, label: String(x) };
    }));
    return Ve(
      () => e.modelValue,
      (w) => {
        o.value = w;
      }
    ), t({
      focus: () => {
        var w, x;
        return (x = (w = p.value) == null ? void 0 : w.focus) == null ? void 0 : x.call(w);
      },
      getModelValue: () => o.value
    }), (w, x) => {
      const N = U("el-option"), D = U("el-select");
      return A(), oe(D, {
        ref_key: "selRef",
        ref: p,
        modelValue: v(o),
        "onUpdate:modelValue": x[0] || (x[0] = (r) => tt(o) ? o.value = r : null),
        class: "TableSelect",
        size: "large",
        filterable: "",
        teleported: !1,
        "automatic-dropdown": "",
        onChange: b
      }, {
        default: F(() => [
          (A(!0), G(se, null, ae(v(m), (r) => (A(), oe(N, {
            key: String(r.value),
            label: r.label,
            value: r.value
          }, null, 8, ["label", "value"]))), 128))
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
}), Me = /* @__PURE__ */ new Set();
class pl {
  constructor(t) {
    this.editorConfig = t || /* @__PURE__ */ Object.create(null), this.editorType = "Input", this.container = null, this.successCallback = null, this._rootEl = null, this._app = null, this._current = void 0;
  }
  /**
   * @param {Object} args
   * @param {HTMLElement} args.container
   * @param {unknown} args.value
   * @param {{ rect?: { top: number; left: number; width: number; height: number } }} [args.referencePosition]
   * @param {() => void} args.endEdit
   */
  onStart(t) {
    const { container: n, value: e, referencePosition: i, endEdit: o } = t;
    this.container = n, this.successCallback = o, this._current = e, this._rootEl = document.createElement("div"), this._rootEl.className = "MvcVTableElementSelectRoot", this._rootEl.style.position = "absolute", this._rootEl.style.boxSizing = "border-box", this._rootEl.style.zIndex = "30", n.appendChild(this._rootEl);
    const p = this.editorConfig.values ?? [];
    this._app = lt(hl, {
      modelValue: e,
      values: p,
      onCommit: (b) => {
        this._current = b, typeof this.successCallback == "function" && this.successCallback();
      }
    }), this._app.use(wt), this._app.mount(this._rootEl), i != null && i.rect && this.adjustPosition(i.rect);
  }
  getValue() {
    return this._current;
  }
  /** @param {unknown} value */
  setValue(t) {
    this._current = t;
  }
  /** @param {{ top: number; left: number; width: number; height: number }} rect */
  adjustPosition(t) {
    if (!this._rootEl)
      return;
    const n = t.top - 1, e = t.left - 1, i = t.width + 2, o = t.height + 2;
    this._rootEl.style.top = `${n}px`, this._rootEl.style.left = `${e}px`, this._rootEl.style.width = `${i}px`, this._rootEl.style.height = `${o}px`;
  }
  /** @param {EventTarget | null} target */
  isEditorElement(t) {
    return !t || !this._rootEl || !(t instanceof Node) ? !1 : this._rootEl.contains(t);
  }
  endEditing() {
  }
  onEnd() {
    var t;
    if (this._app) {
      try {
        this._app.unmount();
      } catch {
      }
      this._app = null;
    }
    if ((t = this._rootEl) != null && t.parentNode)
      try {
        this._rootEl.parentNode.removeChild(this._rootEl);
      } catch {
      }
    this._rootEl = null, this.container = null;
  }
}
function ml(c, t, n) {
  if (!Array.isArray(n) || !n.length)
    return "";
  const e = String(c || "t").replace(/[^a-zA-Z0-9_]/g, "_"), i = String(t || "c").replace(/[^a-zA-Z0-9_]/g, "_"), o = `mvframe_list_${e}_${i}`;
  return Me.has(o) || (Fe(
    o,
    new pl({ values: [...n] })
  ), Me.add(o)), o;
}
function K(c, t = "") {
  return typeof document > "u" ? t : getComputedStyle(document.documentElement).getPropertyValue(c).trim() || t;
}
const gl = 8;
function Le(c, t) {
  var B, h;
  if (typeof c != "string" || !c || typeof document > "u")
    return null;
  const e = `${typeof ((h = (B = globalThis.$config) == null ? void 0 : B.iconfont) == null ? void 0 : h.prefix) == "string" && globalThis.$config.iconfont.prefix ? globalThis.$config.iconfont.prefix : "imc"}-${c}`, i = document.getElementById(e);
  if (!i || i.tagName.toLowerCase() !== "symbol")
    return null;
  const o = i.getAttribute("viewBox") || "", p = i.innerHTML, m = `<svg xmlns="http://www.w3.org/2000/svg"${o ? ` viewBox="${o.replace(/"/g, "&quot;")}"` : ""}>${p}</svg>`, w = (t == null ? void 0 : t.width) ?? 20, x = (t == null ? void 0 : t.height) ?? 20, N = (t == null ? void 0 : t.positionType) ?? "inlineFront", r = {
    type: "svg",
    name: (t == null ? void 0 : t.id) != null && String(t.id) !== "" ? String(t.id) : c,
    svg: m,
    width: w,
    height: x,
    positionType: N
  };
  if ((t == null ? void 0 : t.interactive) !== !1) {
    r.interactive = !0;
    const a = (t == null ? void 0 : t.cursor) ?? "pointer";
    if (a && (r.cursor = a), (t == null ? void 0 : t.hover) !== !1) {
      const l = t != null && t.hover && typeof t.hover == "object" ? t.hover : {};
      r.hover = {
        bgColor: l.bgColor ?? K("--color-bg-menu-item-hover", "rgba(0, 0, 0, 0.06)")
      }, l.width != null && (r.hover.width = l.width), l.height != null && (r.hover.height = l.height), l.image != null && (r.hover.image = l.image);
    }
  } else
    r.interactive = !1;
  const T = t == null ? void 0 : t.tooltip;
  if (T != null && typeof T == "object" && typeof T.title == "string" && T.title !== "") {
    const a = typeof globalThis.$l == "function" ? globalThis.$l(T.title) : T.title;
    r.tooltip = {
      ...T,
      title: a,
      placement: T.placement ?? "top"
    };
  }
  return r;
}
function He(c) {
  if (Array.isArray(c)) {
    const t = [];
    for (const n of c) {
      const e = He(n);
      e != null && (Array.isArray(e) ? t.push(...e) : t.push(e));
    }
    if (t.length === 0)
      return null;
    if (t.length > 1)
      for (let n = 0; n < t.length; n++)
        t[n].marginRight = n < t.length - 1 ? gl : 0;
    return t.length === 1 ? t[0] : t;
  }
  return typeof c == "string" ? Le(c) : c && typeof c == "object" && typeof c.name == "string" ? Le(c.name, c) : null;
}
const re = "_vtableSelect";
function Oe(c) {
  return `_${c}SwitchLoading`;
}
function ze(c) {
  return `_${c}EditorLoading`;
}
function yl(c, t, n, e) {
  const i = typeof n == "string" && n ? n : e(t), o = c.disable;
  c.disable = (p) => {
    try {
      const b = p.table.getCellOriginRecord(p.col, p.row);
      if (b && b[i] === !0)
        return !0;
    } catch {
    }
    return typeof o == "function" ? o(p) : o === !0;
  };
}
function bl(c, t, n) {
  yl(
    c,
    t,
    n,
    Oe
  );
}
function vl(c, t, n) {
  const e = typeof n == "string" && n ? n : ze(t), i = c.editor;
  if (i != null) {
    if (typeof i == "string") {
      const o = i;
      c.editor = (p) => {
        try {
          const b = p.table.getCellOriginRecord(p.col, p.row);
          if (b && b[e] === !0)
            return;
        } catch {
        }
        return o;
      };
      return;
    }
    if (typeof i == "function") {
      const o = i;
      c.editor = (p) => {
        try {
          const b = p.table.getCellOriginRecord(p.col, p.row);
          if (b && b[e] === !0)
            return;
        } catch {
        }
        return o(p);
      };
    }
  }
}
function Ie(c) {
  return c.fixed === "right" ? "right" : c.fixed === "left" || c.fixed === !0 ? "left" : !1;
}
const be = {
  /** 去掉最左侧外边（左为 0） */
  noOuterStart: [1, 1, 1, 0],
  /** 去掉最右侧外边（右为 0） */
  noOuterEnd: [1, 0, 1, 1],
  /** 仅一列时两侧外边都去掉 */
  noOuterBoth: [1, 0, 1, 0]
};
function wl(c) {
  const t = c.field;
  if (!t)
    return;
  const n = c.style;
  c.style = (e) => {
    let i = {};
    if (typeof n == "function") {
      const w = n(e);
      w && typeof w == "object" && (i = { ...w });
    } else n && typeof n == "object" && (i = { ...n });
    let o = !1;
    try {
      const w = e.table.getCellOriginRecord(e.col, e.row);
      o = (w == null ? void 0 : w[t]) === !0;
    } catch {
    }
    const p = K(
      "--color-on-primary-text",
      K("--color-txt-white", "#ffffff")
    ), b = K("--color-txt-p", "#555555"), m = o ? p : b;
    return { ...i, fill: m, color: m };
  };
}
function ve(c, t) {
  const n = t === "both" ? be.noOuterBoth : t === "start" ? be.noOuterStart : be.noOuterEnd, e = c.style, i = c.headerStyle;
  c.style = (o) => ({ ...typeof e == "function" ? { ...e(o) || {} } : { ...e && typeof e == "object" ? e : {} }, borderLineWidth: n }), c.headerStyle = (o) => ({ ...typeof i == "function" ? { ...i(o) || {} } : {
    ...i && typeof i == "object" ? i : {}
  }, borderLineWidth: n });
}
function Cl(c, t) {
  if (!c || !(t != null && t.length))
    return;
  const n = `${c}_Column`;
  if (localStorage.getItem(n))
    return;
  const e = t.filter(Boolean).map((i, o) => ({
    prop: i.type === "selection" ? re : i.field,
    labelKey: i.labelKey ?? i.title,
    label: i.labelKey ?? i.title,
    sort: o,
    visible: i.visible !== !1,
    fixed: Ie(i),
    nomove: i.nomove,
    type: i.type === "selection" ? "selection" : i.type === "operation" ? "operation" : i.type || void 0,
    resizable: !0,
    width: i.width
  }));
  localStorage.setItem(n, JSON.stringify(e));
}
function _l(c) {
  if (!c)
    return null;
  try {
    const t = localStorage.getItem(`${c}_Column`);
    return t ? JSON.parse(t) : null;
  } catch {
    return null;
  }
}
function xl({
  tableName: c,
  columnMetas: t,
  summaryData: n,
  summaryMetricProp: e
}) {
  const i = Array.isArray(t) ? t.filter((r) => r != null) : [], o = _l(c);
  let p;
  o != null && o.length ? p = o.slice().sort((r, f) => r.sort - f.sort).filter((r) => r != null && r.visible) : p = i.map((r, f) => ({
    prop: r.type === "selection" ? re : r.field,
    labelKey: r.labelKey ?? r.title,
    label: r.labelKey ?? r.title,
    sort: f,
    visible: r.visible !== !1,
    fixed: Ie(r),
    type: r.type === "selection" ? "selection" : r.type === "operation" ? "operation" : r.type,
    width: r.width
  }));
  const b = [];
  let m = 0, w = !0, x = !1;
  const N = (r) => {
    var T, B;
    const f = Ae(r, e);
    return f !== void 0 ? f : Ae(r, (B = (T = globalThis.$config) == null ? void 0 : T.table) == null ? void 0 : B.summaryMetric);
  };
  for (const r of p) {
    if (r == null)
      continue;
    if (r.type === "selection") {
      x = !0, b.push({
        field: re,
        title: "",
        width: r.width ?? 48,
        minWidth: 48,
        headerType: "checkbox",
        cellType: "checkbox"
      }), w && m++;
      continue;
    }
    const f = i.find((g) => g.field === r.prop);
    let T = {}, B, h;
    if (f != null && f.vtable && typeof f.vtable == "object") {
      T = { ...f.vtable }, h = T.cellSelectable, delete T.cellSelectable, B = T.mvcIcon, delete T.mvcIcon, delete T.switchLoadingKey, delete T.editorLoadingKey;
      const g = T.inputEditor === !0, $ = T.inputEditorConfig;
      delete T.inputEditor, delete T.inputEditorConfig;
      const L = T.editorValues;
      if (delete T.editorValues, g && c && r.prop != null && r.prop !== "") {
        const M = fl(
          c,
          r.prop,
          $
        );
        M && (T.editor = M);
      }
      if (Array.isArray(L) && L.length && c) {
        const M = ml(
          c,
          r.prop,
          L
        );
        M && (T.editor = M);
      }
    }
    const a = (f == null ? void 0 : f.minWidth) ?? 80, l = {
      field: r.prop,
      title: globalThis.$l(r.labelKey ?? r.label),
      width: r.width ?? (f == null ? void 0 : f.width) ?? a,
      minWidth: a,
      cellType: "text",
      ...T
    };
    if (l.icon == null && B != null) {
      const g = He(B);
      g && (l.icon = g);
    }
    if (l.cellType === "switch" && r.prop != null && r.prop !== "" && (wl(l), bl(
      l,
      r.prop,
      f != null && f.vtable && typeof f.vtable.switchLoadingKey == "string" ? f.vtable.switchLoadingKey : void 0
    )), l.editor && r.prop != null && r.prop !== "" && vl(
      l,
      r.prop,
      f != null && f.vtable && typeof f.vtable.editorLoadingKey == "string" ? f.vtable.editorLoadingKey : void 0
    ), n && typeof n == "object") {
      const g = n[r.prop];
      l.aggregation = {
        aggregationType: ut.CUSTOM,
        aggregationFun: () => g === void 0 ? "" : g,
        formatFun: ($) => vt(r.prop, $, N(r.prop))
      };
    }
    (r.type === "operation" || h === !1) && (l.disableSelect = !0, l.disableHeaderSelect = !0), b.push(l);
    const _ = r.fixed === "left" || r.fixed === !0;
    w && _ ? m++ : _ || (w = !1);
  }
  let D = 0;
  for (let r = p.length - 1; r >= 0; r--) {
    const f = p[r];
    if (f.type === "selection")
      break;
    if (f.fixed === "right")
      D++;
    else
      break;
  }
  return b.length === 1 ? ve(b[0], "both") : b.length > 1 && (ve(b[0], "start"), ve(b[b.length - 1], "end")), { columns: b, frozenColCount: m, rightFrozenColCount: D, hasSelection: x };
}
function Ae(c, t) {
  if (t != null)
    return typeof t == "function" ? t(c) : t[c];
}
function Sl(c = {}) {
  const { frameSideLines: t = !1 } = c, n = K("--color-border", "#e5e5e5"), e = K("--color-white", "#ffffff"), i = K("--color-bg-page-header", e), o = K("--color-bg-menu-children", "#f9f9f9"), p = K("--color-txt-h2", "#333333"), b = K("--color-txt-p", "#555555"), m = K("--color-primary", "#007bff"), w = K("--color-primary-bg-txt", "rgba(0, 123, 255, 0.12)"), x = K(
    "--color-vtable-hover-cross",
    "rgba(0, 123, 255, 0.045)"
  ), N = K("--color-on-primary-text", "#ffffff"), D = K("--color-bg-body", "#fafafa"), r = K("--color-txt-tip", "#999999"), f = typeof document < "u" && getComputedStyle(document.body).fontFamily || "system-ui,sans-serif", B = {
    underlayBackgroundColor: e,
    defaultStyle: {
      borderColor: n
    },
    headerStyle: {
      bgColor: i,
      color: (h) => {
        var L, M, ee, te;
        const { col: a, row: l, table: _ } = h, g = _.columnHeaderLevelCount ?? 1;
        if (typeof l != "number" || l < 0 || l >= g || (M = (L = _.options) == null ? void 0 : L.select) != null && M.disableHeaderSelect)
          return p;
        const $ = (ee = _.stateManager) == null ? void 0 : ee.select;
        if (!((te = $ == null ? void 0 : $.ranges) != null && te.length) || $.highlightScope === "none")
          return p;
        try {
          if (ht(_.stateManager, a, l))
            return N;
        } catch {
        }
        return p;
      },
      fontSize: 14,
      fontFamily: f,
      fontWeight: "600",
      borderColor: n,
      hover: {
        cellBgColor: w
      },
      select: {
        cellBgColor: m,
        inlineColumnBgColor: m
      }
    },
    bodyStyle: {
      bgColor: (h) => {
        const { row: a, table: l } = h, _ = l.columnHeaderLevelCount ?? 1, g = a - _;
        return g < 0 || g % 2 === 0 ? e : D;
      },
      color: b,
      fontSize: 14,
      fontFamily: f,
      borderColor: n,
      hover: {
        cellBgColor: x,
        inlineRowBgColor: x,
        inlineColumnBgColor: x
      }
    },
    bottomFrozenStyle: {
      bgColor: o,
      color: b,
      borderColor: n,
      fontFamily: f,
      fontSize: 14
    },
    frameStyle: {
      borderColor: n,
      borderLineWidth: t ? [0, 1, 0, 1] : [0, 0, 0, 0],
      innerBorder: !0,
      cornerRadius: 0,
      shadowBlur: 0
    },
    scrollStyle: {
      scrollRailColor: o,
      scrollSliderColor: r,
      hoverOn: !0,
      visible: "scrolling",
      width: 8
    },
    // 见 vtable create-select-border：`overlay` 会给选区 rect 填 `cellBgColor`，易盖住单元格文本；
    // `replace` 时 fill 为 false，只保留描边，文字保持可读。
    selectionStyle: {
      cellBorderColor: m,
      cellBorderLineWidth: 2,
      selectionFillMode: "replace"
    },
    frozenColumnLine: {
      border: {
        lineColor: n,
        lineWidth: 1,
        bgColor: e
      }
    },
    tooltipStyle: {
      bgColor: K("--color-bg-menu", e),
      color: b,
      fontFamily: f,
      fontSize: 12
    },
    functionalIconsStyle: {
      sort_color: m,
      sort_color_2: r,
      frozen_color: m
    },
    /** 未配置时 VTable 默认勾选项与表体底色接近，选中态几乎不可见 */
    checkboxStyle: {
      size: 16,
      defaultFill: e,
      defaultStroke: r,
      checkedFill: m,
      checkedStroke: m
    },
    /**
     * 开关：打开态轨道 `--color-primary`；标签字色由列 `style` 在 columns 内按
     * `--color-on-primary-text` / `--color-txt-p` 自动区分（见 wrapSwitchColumnLabelStyle）。
     */
    switchStyle: {
      boxWidth: 30,
      boxHeight: 16,
      circleRadius: 6,
      checkedFill: m,
      uncheckedFill: n,
      circleFill: e
    }
  };
  return new dt(B, ft);
}
function Tl(c = {}) {
  const t = K("--color-txt-tip", "#999999"), n = typeof document < "u" && getComputedStyle(document.body).fontFamily || "system-ui,sans-serif", e = typeof globalThis.$l == "function" && globalThis.$l("No Data") || "No Data", i = c.text !== void 0 && c.text !== "" ? c.text : e, o = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96"><g fill="none" stroke="${t}" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"><rect x="16" y="28" width="64" height="48" rx="4"/><path d="M16 40h64"/><ellipse cx="48" cy="52" rx="14" ry="6"/></g><circle cx="48" cy="20" r="7" fill="${t}" opacity="0.18"/></svg>`;
  return {
    displayMode: "basedOnContainer",
    spaceBetweenTextAndIcon: 16,
    text: i,
    textStyle: {
      fontSize: 14,
      fontFamily: n,
      fontWeight: "normal",
      color: t,
      lineHeight: 22,
      ...c.textStyle
    },
    icon: c.icon !== void 0 ? c.icon : {
      image: o,
      width: 72,
      height: 72
    }
  };
}
const El = {
  key: 0,
  class: "flexMode vc"
}, kl = { class: "tableArea relative radius ctx-auto" }, $l = {
  key: 1,
  class: "tableFooter relative flexMode vc h56 p16 xscroll nobar z9"
}, Ml = /* @__PURE__ */ Object.assign({
  name: "MvcVTable",
  inheritAttrs: !1
}, {
  __name: "index",
  props: {
    /** 列定义（替代 `<Table>` 下 `el-table-column` slot；与 ColumnConfig 存储的 `prop` 对齐） */
    columnMetas: {
      type: Array,
      default: () => []
    },
    defaultLoading: {
      type: Boolean,
      default: !0
    },
    tableName: {
      type: String,
      default: ""
    },
    autoHeader: {
      type: Boolean,
      default: !0
    },
    headerClass: {
      type: String,
      default: ""
    },
    height: {
      type: [String, Number],
      default: 0
    },
    minusHeight: {
      type: [String, Number],
      default: 0
    },
    defer: {
      type: Boolean,
      default: !1
    },
    rowKey: {
      type: String,
      default: ""
    },
    tool: {
      type: [Object, Boolean],
      default: () => ({
        download: !0,
        refresh: !0,
        column: !0,
        showLabel: !1
      })
    },
    noheader: {
      type: Boolean,
      default: !1
    },
    nofooter: {
      type: Boolean,
      default: !1
    },
    loadData: {
      type: Function,
      default: () => ({
        list: [],
        total: 0
      })
    },
    /**
     * 树形懒加载：`columnMetas[].vtable.tree === true` 且行上 `children: true` 时，用户展开会触发；
     * 返回子行记录数组（字段与根行一致为佳；含勾选列时需带 `_vtableSelect`）。
     *
     * @type {undefined|((args: { record: Record<string, unknown>; col: number; row: number }) => Promise<unknown[]> | unknown[])}
     */
    loadTreeChildren: {
      type: Function,
      default: null
    },
    /** 树列缩进像素，仅当存在 `tree` 列时写入 `hierarchyIndent` */
    hierarchyIndent: {
      type: Number,
      default: 20
    },
    pageSize: {
      type: Number,
      default: 0
    },
    pageSizes: {
      type: Array,
      default: () => [10, 20, 50, 100]
    },
    summaryMetric: {
      type: [Object, Function],
      default: null
    },
    /** 空数据主文案；空串时沿用 `$l('No Data')` */
    emptyText: {
      type: String,
      default: ""
    },
    /**
     * 列宽模式。`autoWidth` 按表头/内容自动算宽，列上的 `width` 常不生效；
     * `standard` 使用列定义中的 `width` / `minWidth`（与 columnMetas、列配置一致）。
     */
    widthMode: {
      type: String,
      default: "standard"
    },
    /**
     * 是否在横向铺满容器时扩展列宽。与 `widthMode: 'standard'` 同用时，为 true 会把多余宽度分给可伸缩列；
     * 为 false 时更贴近配置的像素宽度（总宽不足容器时右侧留白，超出则横向滚动）。
     */
    autoFillWidth: {
      type: Boolean,
      default: !1
    },
    /**
     * 可编辑列（如 ListEditor 下拉）进入编辑的触发方式；下拉列常用 `click`。
     * @see https://visactor.io/vtable/guide/edit/edit_cell
     */
    editCellTrigger: {
      type: [String, Array],
      default: "click"
    },
    /**
     * `loadData` / 分页 / 刷新后 `syncVTable` 完成时是否将纵向滚动置顶。
     * 为 false 时不再滚动（替代仅依赖 `window.config?.table?.scrollToTop` 的旧行为）。
     */
    scrollToTopOnLoad: {
      type: Boolean,
      default: !0
    },
    /**
     * 整表是否允许单元格选区（与列 `vtable.cellSelectable: false` 叠加；本项为 `false` 时整表不可选）。
     * 透传 VTable `options.select`：`disableSelect`、`disableHeaderSelect`、`disableDragSelect`。
     */
    cellSelectable: {
      type: Boolean,
      default: !0
    }
  },
  emits: [
    "selection-change",
    "refresh",
    "switch-change",
    "cell-value-change",
    // 单元格内图标点击（mvcIcon / 列 icon；树展开等内置图标会带 funcType）
    "icon-click"
  ],
  setup(c, { expose: t, emit: n }) {
    const e = c, i = ue({
      loading: !0,
      selection: []
    }), o = ue({
      list: [],
      total: 0,
      page: 1,
      pageSize: 50,
      summary: !1,
      nopagination: !1
    }), p = ue({
      current: "",
      list: [
        {
          title: "Table Column Customization",
          size: 1024,
          cpt: Te(tl)
        },
        {
          title: "Download from Current Table",
          cpt: Te(ul)
        }
      ]
    }), b = we(null), m = ot(null);
    let w, x = !1, N, D, r = 0;
    const f = ue({
      show: !1,
      left: 0,
      top: 0,
      width: 0,
      height: 0
    });
    let T = { col: -1, row: -1 }, B = null;
    nt(() => {
      a();
    }), pe(() => {
      var s;
      e.tableName && ((s = e.columnMetas) != null && s.length) && Cl(e.tableName, e.columnMetas), typeof MutationObserver < "u" && (N = new MutationObserver(() => {
        clearTimeout(D), D = setTimeout(Ce, 80);
      }), N.observe(document.documentElement, {
        attributes: !0,
        attributeFilter: ["class"]
      })), l();
    });
    const h = n, a = () => {
      i.loading = e.defaultLoading, e.pageSize && (o.pageSize = e.pageSize);
    }, l = () => {
      e.defer === !1 && de();
    }, _ = (s, y) => {
      if (!y)
        return s;
      for (const d of s)
        (!(re in d) || d[re] !== !0) && (d[re] = !1);
      return s;
    }, g = () => xl({
      tableName: e.tableName,
      columnMetas: e.columnMetas,
      summaryData: o.summary || null,
      summaryMetricProp: e.summaryMetric
    }), $ = (s) => {
      const y = [];
      for (const d of s)
        d != null && d.field && (d.cellType === "switch" || d.cellType === "checkbox") && y.push(d.field);
      return y;
    }, L = (s) => {
      const y = [];
      for (const d of s)
        !(d != null && d.field) || !d.editor || y.push(d.field);
      return y;
    }, M = () => {
      var V, O;
      const s = m.value;
      if (!((V = s == null ? void 0 : s.stateManager) != null && V.checkedState) || !((O = s.dataSource) != null && O.getIndexKey))
        return;
      const y = g(), d = $(y.columns);
      if (!d.length)
        return;
      const S = s.stateManager.checkedState;
      for (let j = 0; j < o.list.length; j++) {
        const C = String(s.dataSource.getIndexKey(j)), E = S.get(C);
        if (E)
          for (const z of d)
            Object.prototype.hasOwnProperty.call(E, z) && (o.list[j][z] = E[z] === !0);
      }
    }, ee = (s) => {
      var S, V;
      const y = (S = e.columnMetas) == null ? void 0 : S.find((O) => O != null && O.field === s), d = (V = y == null ? void 0 : y.vtable) == null ? void 0 : V.switchLoadingKey;
      return typeof d == "string" && d ? d : Oe(s);
    }, te = (s) => {
      var S, V;
      const y = (S = e.columnMetas) == null ? void 0 : S.find((O) => O != null && O.field === s), d = (V = y == null ? void 0 : y.vtable) == null ? void 0 : V.editorLoadingKey;
      return typeof d == "string" && d ? d : ze(s);
    }, q = () => {
      M();
      const s = re;
      if (!g().hasSelection) {
        i.selection = [], h("selection-change", []);
        return;
      }
      const d = o.list.filter((S) => S[s] === !0);
      i.selection = d, h("selection-change", d);
    }, H = () => {
      if (B != null && m.value)
        try {
          m.value.off(B);
        } catch {
        }
      B = null;
    }, k = () => {
      const s = m.value;
      if (!s || !f.show)
        return;
      const { col: y, row: d } = T;
      if (!(!Number.isFinite(y) || !Number.isFinite(d)))
        try {
          const S = s.getCellRelativeRect(y, d);
          if (!S)
            return;
          const V = S.width != null ? S.width : S.right - S.left, O = S.height != null ? S.height : S.bottom - S.top;
          f.left = S.left, f.top = S.top, f.width = Math.max(0, V), f.height = Math.max(0, O);
        } catch {
        }
    }, W = () => {
      f.show = !1, T = { col: -1, row: -1 }, f.left = 0, f.top = 0, f.width = 0, f.height = 0, H();
    }, P = (s, y, d) => {
      H(), T = { col: y, row: d }, f.show = !0, ce(() => {
        if (k(), !s || m.value !== s)
          return;
        const S = () => {
          k();
        };
        B = s.on(
          le.SCROLL,
          S
        );
      });
    }, ie = (s, y) => {
      const d = m.value;
      !d || !Number.isFinite(s) || !Number.isFinite(y) || P(d, s, y);
    }, Re = (s) => {
      if (x)
        return;
      x = !0;
      const y = () => {
        q();
      }, d = (C) => {
        var z, Y;
        try {
          (Y = (z = s.editorManager) == null ? void 0 : z.cancelEdit) == null || Y.call(z);
        } catch {
        }
        y();
        const E = C == null ? void 0 : C.field;
        typeof E != "string" || !E || h("switch-change", {
          field: E,
          checked: C.checked === !0,
          row: C.originData,
          loadingKey: ee(E),
          col: C.col,
          cellRow: C.row
        });
      }, S = (C) => {
        const E = C == null ? void 0 : C.field;
        if (typeof E != "string" || !E)
          return;
        const z = g();
        if (!new Set(L(z.columns)).has(E))
          return;
        const Z = C.recordIndex;
        let Q;
        try {
          Q = s.getCellOriginRecord(C.col, C.row);
        } catch {
          Q = void 0;
        }
        if (Q == null) {
          const I = Number(Z);
          Number.isFinite(I) && I >= 0 && I < o.list.length && Number.isInteger(I) && (Q = o.list[I]);
        }
        h("cell-value-change", {
          field: E,
          row: Q,
          recordIndex: Z,
          currentValue: C.currentValue,
          changedValue: C.changedValue,
          rawValue: C.rawValue,
          col: C.col,
          cellRow: C.row,
          loadingKey: te(E)
        });
      }, V = (C) => {
        if (m.value !== s || C == null)
          return;
        const E = C.col, z = C.row, Y = g(), Z = Number.isFinite(E) && E >= 0 && E < Y.columns.length ? Y.columns[E] : null, Q = (Z == null ? void 0 : Z.field) ?? null;
        let I = null;
        try {
          I = s.getCellOriginRecord(E, z);
        } catch {
          I = null;
        }
        let ye = null;
        if (I != null && Array.isArray(o.list)) {
          const Se = o.list.indexOf(I);
          Se >= 0 ? ye = Se : I && typeof I.index == "number" && (ye = I.index);
        }
        h("icon-click", {
          field: Q,
          col: E,
          row: z,
          iconName: C.name,
          funcType: C.funcType,
          record: I,
          recordIndex: ye,
          nativeEvent: C.event
        });
      }, O = () => {
        typeof globalThis.requestAnimationFrame != "function" || r !== 0 || (r = globalThis.requestAnimationFrame(() => {
          var E, z, Y, Z, Q, I;
          r = 0;
          const C = m.value;
          if (!(!C || C !== s))
            try {
              (z = (E = C.scenegraph) == null ? void 0 : E.clearCells) == null || z.call(E), (Y = C.clearCellStyleCache) == null || Y.call(C), (Q = (Z = C.scenegraph) == null ? void 0 : Z.createSceneGraph) == null || Q.call(Z, !0), (I = C.render) == null || I.call(C);
            } catch {
            }
        }));
      }, j = (C) => {
        if ((C == null ? void 0 : C.hierarchyState) !== mt.expand || typeof e.loadTreeChildren != "function")
          return;
        const E = C.originData;
        if (E == null || E.children !== !0)
          return;
        const z = C.col, Y = C.row;
        !Number.isFinite(z) || !Number.isFinite(Y) || (async () => {
          P(s, z, Y);
          try {
            const Z = await e.loadTreeChildren({ record: E, col: z, row: Y }), Q = Array.isArray(Z) ? Z : [], I = m.value;
            if (!I || I !== s)
              return;
            I.setRecordChildren(Q, z, Y);
          } catch {
          } finally {
            W();
          }
        })();
      };
      s.on(le.CHECKBOX_STATE_CHANGE, y), s.on(le.SWITCH_STATE_CHANGE, d), s.on(le.CHANGE_CELL_VALUE, S), s.on(
        le.TREE_HIERARCHY_STATE_CHANGE,
        j
      ), s.on(
        le.SELECTED_CHANGED,
        O
      ), s.on(
        le.SELECTED_CLEAR,
        O
      ), s.on(
        le.DRAG_SELECT_END,
        O
      ), s.on(le.ICON_CLICK, V);
    }, Be = () => Tl({
      text: e.emptyText || void 0
    }), De = () => Sl({
      frameSideLines: o.list.length === 0
    }), me = () => {
      const s = g(), y = _(o.list, s.hasSelection), d = 40, S = s.columns.some((V) => (V == null ? void 0 : V.tree) === !0);
      return {
        records: y,
        columns: s.columns,
        frozenColCount: s.frozenColCount,
        rightFrozenColCount: s.rightFrozenColCount ?? 0,
        widthMode: e.widthMode,
        autoFillWidth: e.autoFillWidth,
        heightMode: "standard",
        defaultRowHeight: d,
        defaultHeaderRowHeight: d,
        ...S && e.hierarchyIndent > 0 ? { hierarchyIndent: e.hierarchyIndent } : {},
        theme: De(),
        /**
         * 表体单元格悬停：整行 + 整列交叉高亮（主题 `bodyStyle.hover` 已配 cell / inlineRow / inlineColumn）。
         * `disableHeaderHover: true` 避免在表头悬停时同样触发交叉带，与「非表头才延伸」一致；表头无指针悬停底色。
         */
        hover: {
          highlightMode: "cross",
          disableHeaderHover: !0
        },
        select: {
          highlightInRange: !0,
          ...e.cellSelectable === !1 ? {
            disableSelect: !0,
            disableHeaderSelect: !0,
            disableDragSelect: !0
          } : {}
        },
        emptyTip: Be(),
        editCellTrigger: e.editCellTrigger
      };
    }, Ce = async () => {
      var s;
      if (!(!m.value || i.loading || !((s = e.columnMetas) != null && s.length)))
        try {
          await m.value.updateOption(me());
        } catch {
        }
    }, je = () => {
      if (r !== 0 && globalThis.cancelAnimationFrame && (globalThis.cancelAnimationFrame(r), r = 0), clearTimeout(D), N == null || N.disconnect(), N = void 0, w == null || w.disconnect(), w = void 0, x = !1, W(), m.value) {
        try {
          m.value.release();
        } catch {
        }
        m.value = null;
      }
    }, _e = async () => {
      var y;
      if (await ce(), !b.value || i.loading || !((y = e.columnMetas) != null && y.length))
        return;
      const s = me();
      if (m.value ? await m.value.updateOption(s) : (m.value = new pt(b.value, s), Re(m.value), w = new ResizeObserver(() => {
        var d, S;
        (S = (d = m.value) == null ? void 0 : d.resize) == null || S.call(d), k();
      }), w.observe(b.value)), m.value && e.scrollToTopOnLoad)
        try {
          m.value.scrollTop = 0;
        } catch {
        }
    }, Ke = (s) => {
      de(s);
    }, de = async (s = {}) => {
      if (s.refresh && i.loading)
        return;
      i.loading = !0;
      const y = {
        pageSize: s.pageSize || o.pageSize,
        pageStart: s.pageStart || o.page
      };
      s.refresh && (y.remote = !0);
      const { list: d = [], total: S, summary: V } = await e.loadData(y) || {};
      o.list = d.map((O, j) => (O.index = j, O)), S === void 0 ? (o.total = o.list.length, o.nopagination = !0) : (o.total = S, o.nopagination = !1), V ? o.summary = V : o.summary = !1, i.loading = !1, await _e();
    }, We = () => {
      de({
        pageStart: 1
      });
    }, Ue = () => {
      de();
    }, Ge = () => {
      i.loading || (de({ refresh: !0 }), h("refresh"));
    }, qe = () => {
      p.current = 0;
    }, Je = () => {
      p.current = 1;
    }, Ye = async () => {
      await _e();
    }, Ze = async ({ i: s, row: y }) => {
      var d, S, V, O;
      if (o.list[s] = y, m.value) {
        await ce();
        try {
          (S = (d = m.value.editorManager) == null ? void 0 : d.cancelEdit) == null || S.call(d);
        } catch {
        }
        await ce();
        try {
          await m.value.updateOption(me()), await ce(), (O = (V = m.value).resize) == null || O.call(V);
        } catch {
        }
      }
    }, Pe = X(() => ({
      left: `${f.left}px`,
      top: `${f.top}px`,
      width: `${f.width}px`,
      height: `${f.height}px`
    })), Xe = X(() => {
      var y;
      let s = e.height || ((y = globalThis.$config.options) == null ? void 0 : y.pageHeight) || 640;
      return e.noheader === !1 && (s -= 64), e.nofooter === !1 && (s -= 56), s -= e.minusHeight, s;
    }), Qe = X(() => o.nopagination === !0 ? "total" : "total,->,prev,pager,next,sizes"), ge = X(() => {
      if (e.tool) {
        const {
          column: s = !0,
          download: y = !0,
          refresh: d = !0,
          showLabel: S
        } = e.tool;
        return {
          column: s,
          download: y,
          refresh: d,
          showLabel: S
        };
      } else
        return !1;
    }), xe = X(() => {
      if (!ge.value)
        return [];
      const s = gt.lang("common.vTableTool") || {}, y = ge.value, d = [];
      return y.refresh && d.push({
        key: "refresh",
        txt: s.refresh,
        icon: "im-reload",
        onClick: Ge
      }), y.column && d.push({
        key: "column",
        txt: s.column,
        icon: "im-layout",
        onClick: qe
      }), y.download && d.push({
        key: "download",
        txt: s.download,
        icon: "im-download",
        onClick: Je
      }), d;
    });
    return Ve(
      () => e.cellSelectable,
      () => {
        Ce();
      }
    ), it(() => {
      je();
    }), t({
      initTable: Ke,
      editRow: Ze,
      showCellLoadMask: ie,
      hideCellLoadMask: W
    }), (s, y) => {
      const d = U("Loading"), S = U("el-button"), V = U("el-pagination"), O = U("Card");
      return A(), oe(O, {
        class: "MvcVTable",
        "body-class": "p0"
      }, {
        default: F(() => [
          J(d, {
            loading: v(i).loading
          }, null, 8, ["loading"]),
          e.noheader === !1 ? (A(), G("div", {
            key: 0,
            class: fe(["tableHeader flexMode hb g12 p16", e.autoHeader ? "minh64" : "h64"])
          }, [
            u("div", {
              class: fe(["flexMode vc flexGrow maxwp100", e.headerClass])
            }, [
              rt(s.$slots, "header", {}, void 0, !0)
            ], 2),
            v(xe).length ? (A(), G("div", El, [
              (A(!0), G(se, null, ae(v(xe), (j) => (A(), oe(S, {
                key: j.key,
                class: "tipbtn bottom fs20",
                txt: j.txt,
                rect: "",
                onClick: j.onClick
              }, st({
                icon: F(() => [
                  u("i", {
                    class: fe(["imicon", j.icon])
                  }, null, 2)
                ]),
                _: 2
              }, [
                v(ge).showLabel ? {
                  name: "default",
                  fn: F(() => [
                    he(R(j.txt), 1)
                  ]),
                  key: "0"
                } : void 0
              ]), 1032, ["txt", "onClick"]))), 128))
            ])) : ne("", !0)
          ], 2)) : ne("", !0),
          u("div", kl, [
            u("div", {
              class: "vtableWrapper relative wp100 z1",
              style: Ee({ height: `${v(Xe)}px` })
            }, [
              u("div", {
                ref_key: "vtableHost",
                ref: b,
                class: "vtableHost relative wp100 vtableHostFill"
              }, null, 512),
              at(u("div", {
                class: "treeCellLoadMask abs flexMode hc vc",
                style: Ee(v(Pe))
              }, [...y[2] || (y[2] = [
                u("i", { class: "imicon im-loading ani-rotate fs18 txt-primary loadMaskIcon" }, null, -1)
              ])], 4), [
                [ct, v(f).show]
              ])
            ], 4)
          ]),
          e.nofooter === !1 ? (A(), G("div", $l, [
            J(V, {
              "current-page": v(o).page,
              "onUpdate:currentPage": y[0] || (y[0] = (j) => v(o).page = j),
              background: "",
              total: v(o).total,
              "default-page-size": v(o).pageSize,
              "page-sizes": e.pageSizes,
              "pager-count": 5,
              layout: v(Qe),
              class: "wp100",
              onSizeChange: We,
              onCurrentChange: Ue
            }, null, 8, ["current-page", "total", "default-page-size", "page-sizes", "layout"])
          ])) : ne("", !0),
          J(yt, {
            current: v(p).current,
            "onUpdate:current": y[1] || (y[1] = (j) => v(p).current = j),
            "table-name": e.tableName,
            drawer: v(p).list,
            list: v(o).list,
            selection: v(i).selection,
            onInitColumn: Ye
          }, null, 8, ["current", "table-name", "drawer", "list", "selection"])
        ]),
        _: 3
      });
    };
  }
}), zl = /* @__PURE__ */ Ne(Ml, [["__scopeId", "data-v-a13ba899"]]);
export {
  zl as default
};
