import { defineComponent as g, useCssModule as x, inject as h, computed as s, openBlock as n, createElementBlock as b, normalizeClass as c, unref as e, createElementVNode as T, renderSlot as E, createBlock as y, createCommentVNode as d } from "vue";
import "es-toolkit";
import "./Module.keys-DcqBbvvT.js";
import "es-toolkit/compat";
import I from "./Icon.js";
import { D as w } from "./DataView.keys-aSOnA4AD.js";
import "./Illustration.vue_vue_type_script_setup_true_lang-Bs1KwoBm.js";
import "@leaflink/snitch";
import { T as A } from "./Table.keys-LHQf6FEH.js";
import { _ as N } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const O = {
  key: 0,
  class: "relative h-4 w-3"
}, B = /* @__PURE__ */ g({
  __name: "TableHeaderCell",
  props: {
    sortId: { default: "" },
    schemaDrivenHeader: { default: void 0 }
  },
  setup(k) {
    const r = k, t = x(), m = h(A.key);
    if (!m)
      throw new Error("TableHeaderCell must be used within a Table component");
    const { density: p, hasActions: C } = m, o = s(() => !!r.schemaDrivenHeader), H = s(
      () => o.value && !!r.schemaDrivenHeader.column.getIsPinned()
    ), { currentSortId: D, currentSortOrder: v, updateCurrentSort: f } = h(
      w.key,
      w.defaults
    ), l = s(() => o.value ? r.schemaDrivenHeader.column.getCanSort() : !!r.sortId), a = s(() => o.value ? !!r.schemaDrivenHeader.column.getIsSorted() : D.value === r.sortId), _ = s(() => o.value ? r.schemaDrivenHeader.column.getIsSorted() : a.value && v.value ? v.value : !1);
    function S(i) {
      var u;
      if (o.value) {
        (u = r.schemaDrivenHeader.column.getToggleSortingHandler()) == null || u(i);
        return;
      }
      l.value && typeof f == "function" && f(r.sortId, { shouldEmit: !0 });
    }
    return (i, u) => (n(), b("th", {
      class: c(["stash-table-header-cell border-b border-r border-ice-200 p-3 text-xs font-medium text-ice-900", [
        e(t).root,
        {
          "bg-white": !a.value,
          "stash-table-header-cell--sorted bg-blue-100": a.value,
          [e(t)["root--density-compact"]]: e(p) === "compact",
          [e(t)["root--density-comfortable"]]: e(p) === "comfortable",
          [e(t)["has-actions"]]: e(C),
          [e(t)["pinned-sticky"]]: H.value,
          "cursor-pointer": l.value
        }
      ]]),
      "data-test": "stash-table-header-cell",
      onClick: S
    }, [
      T("div", {
        class: c(["flex justify-between", e(t)["content-wrapper"]])
      }, [
        E(i.$slots, "default"),
        l.value ? (n(), b("div", O, [
          !a.value || _.value === "asc" ? (n(), y(I, {
            key: 0,
            class: c(["absolute text-ice-700", [e(t).caret, e(t)["caret-up"]]]),
            "data-test": "icon|caret-up",
            name: "caret-up",
            size: "dense"
          }, null, 8, ["class"])) : d("", !0),
          !a.value || _.value === "desc" ? (n(), y(I, {
            key: 1,
            class: c(["absolute text-ice-700", [e(t).caret, e(t)["caret-down"]]]),
            "data-test": "icon|caret-down",
            name: "caret-down",
            size: "dense"
          }, null, 8, ["class"])) : d("", !0)
        ])) : d("", !0)
      ], 2)
    ], 2));
  }
}), M = "_root_xomol", j = "_caret_eaO3f", z = {
  root: M,
  "pinned-sticky": "_pinned-sticky_eAQmt",
  "has-actions": "_has-actions_xMqv6",
  "content-wrapper": "_content-wrapper_Ouv9o",
  "caret-up": "_caret-up_8fbav",
  "caret-down": "_caret-down_A-Q5Y",
  caret: j,
  "root--density-comfortable": "_root--density-comfortable_aKIJs"
}, J = {
  $style: z
}, F = /* @__PURE__ */ N(B, [["__cssModules", J]]);
export {
  F as default
};
//# sourceMappingURL=TableHeaderCell.js.map
