import { defineComponent as H, computed as R, watch as $, ref as b, onMounted as V, nextTick as h, watchPostEffect as I, unref as e, createElementBlock as p, openBlock as r, createElementVNode as a, createVNode as l, withCtx as z, Fragment as f, renderList as u, createBlock as c, normalizeStyle as y, createCommentVNode as L } from "vue";
/* empty css                             */
import M from "./TdCell.vue.js";
import F from "./assets/TableIcon.vue.js";
import O from "./TrHead.vue.js";
import P from "./ThCell.vue.js";
import W from "./TrBody.vue.js";
import j from "./ColumnCaret.vue.js";
/* empty css                   */
import { tapIf as q } from "@milaboratories/helpers";
import { useResize as A } from "./composition/useResize.js";
import G from "./RowsCommandMenu.vue.js";
import J from "./ColumnsCommandMenu.vue.js";
import K from "./TScroll.vue.js";
import { createState as Q } from "./state.js";
import "../../composition/useTheme.js";
import { useEventListener as U } from "../../composition/useEventListener.js";
/* empty css                           */
/* empty css                       */
/* empty css               */
import "../../global/resizeObserver.js";
import "../../layout/PlBlockPage/PlBlockPageTitleTeleportTarget.js";
/* empty css                                          */
import "@vueuse/core";
import "../PlSvg/registry.js";
import "../../layout/PlPlaceholder/PlPlaceholder.vue2.js";
/* empty css                                         */
/* empty css                                          */
/* empty css                               */
/* empty css                             */
/* empty css                                  */
/* empty css                       */
/* empty css                                     */
/* empty css                            */
/* empty css                                                */
import "canonicalize";
/* empty css                     */
/* empty css                                */
/* empty css                                */
/* empty css                              */
/* empty css                              */
/* empty css                            */
/* empty css                                      */
/* empty css                                  */
/* empty css                              */
/* empty css                             */
/* empty css                                  */
/* empty css                                        */
/* empty css                                    */
/* empty css                             */
/* empty css                                          */
/* empty css                                      */
/* empty css                                     */
/* empty css                                        */
import "@vueuse/integrations/useSortable";
/* empty css                            */
import "@platforma-sdk/model";
/* empty css                                    */
/* empty css                                      */
/* empty css                                  */
/* empty css                                */
/* empty css                             */
/* empty css                                */
/* empty css                                      */
/* empty css                                */
/* empty css                                                */
import "d3-selection";
import "d3-axis";
import "d3-array";
import "d3-scale";
import "../../colors/color.js";
import "../../colors/gradient.js";
const X = { class: "command-menu__container" }, Y = {
  key: 0,
  class: "table-body__no-data"
}, Z = { class: "carets" }, go = /* @__PURE__ */ H({
  __name: "TableComponent",
  props: {
    settings: {}
  },
  emits: ["update:data", "change:sort"],
  setup(D, { emit: T }) {
    const B = T, _ = D, t = Q(_), g = R(() => t.data.rows.length === 0), N = R(() => ({
      height: g.value ? "212px" : t.data.bodyHeight + "px"
    }));
    $(t.data, (i) => B("update:data", i), { deep: !0 }), $(_, () => d);
    const w = b(), S = b(), v = b(), d = () => {
      q(v.value, (i) => {
        t.updateDimensions(i.getBoundingClientRect());
      });
    }, k = t.tableColumns, x = t.tableRows, { mouseDown: C } = A(t, w);
    V(() => {
      h(d);
    }), I(() => {
      e(_.settings), h(d);
    }), U(window, "resize", () => h(d));
    const E = (i) => {
      i.preventDefault(), t.updateOffsets(i);
    };
    return (i, m) => (r(), p("div", {
      ref_key: "tableRef",
      ref: w,
      class: "data-table",
      onMousedown: m[2] || (m[2] = //@ts-ignore
      (...o) => e(C) && e(C)(...o))
    }, [
      a("div", X, [
        l(G),
        l(J)
      ]),
      a("div", {
        ref_key: "headRef",
        ref: S,
        class: "table-head"
      }, [
        l(O, null, {
          default: z(() => [
            (r(!0), p(f, null, u(e(k), (o, s) => (r(), c(P, {
              key: s,
              col: o,
              style: y(o.style),
              "onChange:sort": m[0] || (m[0] = (n) => i.$emit("change:sort", n))
            }, null, 8, ["col", "style"]))), 128))
          ]),
          _: 1
        })
      ], 512),
      a("div", {
        ref_key: "bodyRef",
        ref: v,
        class: "table-body",
        style: y(N.value),
        onWheel: E
      }, [
        g.value ? (r(), p("div", Y, [
          a("div", null, [
            l(F),
            m[3] || (m[3] = a("div", null, "No Data To Show", -1))
          ])
        ])) : L("", !0),
        (r(!0), p(f, null, u(e(x), (o, s) => (r(), c(W, {
          key: s,
          row: o
        }, {
          default: z(() => [
            (r(!0), p(f, null, u(o.cells, (n) => (r(), c(M, {
              key: n.column.id + ":" + s,
              cell: n,
              style: y(n.style)
            }, null, 8, ["cell", "style"]))), 128))
          ]),
          _: 2
        }, 1032, ["row"]))), 128))
      ], 36),
      a("div", Z, [
        (r(!0), p(f, null, u(e(k), (o, s) => (r(), c(j, {
          key: s,
          column: o,
          style: y(o.style),
          "onChange:sort": m[1] || (m[1] = (n) => i.$emit("change:sort", n))
        }, null, 8, ["column", "style"]))), 128))
      ]),
      l(K, {
        offset: e(t).data.scrollTop,
        "window-size": e(t).data.bodyHeight,
        "data-size": e(t).data.dataHeight,
        "onChange:offset": e(t).updateScrollTop
      }, null, 8, ["offset", "window-size", "data-size", "onChange:offset"])
    ], 544));
  }
});
export {
  go as default
};
//# sourceMappingURL=TableComponent.vue.js.map
