import { defineComponent as R, inject as h, computed as x, ref as B, useTemplateRef as v, openBlock as l, createElementBlock as I, unref as e, createBlock as o, normalizeClass as s, createCommentVNode as a, withCtx as S, renderSlot as $ } from "vue";
import { t as H } from "./locale.js";
import N from "./Checkbox.js";
import { D as b } from "./DataView.keys-aSOnA4AD.js";
import "es-toolkit/compat";
import "es-toolkit";
import "./Module.keys-DcqBbvvT.js";
import "./Illustration.vue_vue_type_script_setup_true_lang-Bs1KwoBm.js";
import { T as A } from "./Table.keys-LHQf6FEH.js";
import m from "./TableHeaderCell.js";
import { _ as g } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const j = /* @__PURE__ */ R({
  __name: "TableHeaderRow",
  props: {
    allRowsSelected: { type: Boolean, default: !1 },
    someRowsSelected: { type: Boolean, default: !1 }
  },
  emits: ["select"],
  setup(_, { expose: k, emit: y }) {
    const r = _, T = y, i = h(A.key);
    if (!i)
      throw new Error("TableHeaderRow must be used within a Table component");
    const { hasCustomExpandToggle: E, isSchemaDriven: c, isExpandable: C, isSelectable: n } = i, p = x(() => (n == null ? void 0 : n.value) && !(c != null && c.value)), { hasToolbar: d } = h(b.key, b.defaults), w = B(0), u = v("rowElement");
    k({
      rowElement: u
    });
    function f() {
      T("select"), w.value++;
    }
    return (t, O) => (l(), I("tr", {
      ref_key: "rowElement",
      ref: u,
      class: "stash-table-header-row",
      "data-test": "stash-table-header-row"
    }, [
      e(d) && p.value ? (l(), o(m, {
        key: 0,
        class: s(["stash-table-header-row__selection-cell-empty", t.$style["row-control-cell"]]),
        "data-test": "table-row-header|selection-cell-empty"
      }, null, 8, ["class"])) : a("", !0),
      !e(d) && p.value ? (l(), o(m, {
        key: 1,
        class: s(["stash-table-header-row__selection-cell min-w-12", t.$style["row-control-cell"]]),
        "data-test": "table-row-header|selection-cell"
      }, {
        default: S(() => [
          e(d) ? a("", !0) : (l(), o(N, {
            key: w.value,
            class: s(t.$style["row-selection-checkbox"]),
            checked: r.allRowsSelected,
            indeterminate: r.someRowsSelected && !r.allRowsSelected,
            title: e(H)("ll.selectAll"),
            "onUpdate:indeterminate": f,
            "onUpdate:checked": f
          }, null, 8, ["class", "checked", "indeterminate", "title"]))
        ]),
        _: 1
      }, 8, ["class"])) : a("", !0),
      e(C) && !e(E) ? (l(), o(m, {
        key: 2,
        class: s(t.$style["row-control-cell"]),
        "data-test": "table-row-header-expansion-cell"
      }, null, 8, ["class"])) : a("", !0),
      $(t.$slots, "default")
    ], 512));
  }
}), J = {
  "row-selection-checkbox": "_row-selection-checkbox_Bbtnq",
  "row-control-cell": "_row-control-cell_HvGlb"
}, M = {
  $style: J
}, Q = /* @__PURE__ */ g(j, [["__cssModules", M]]);
export {
  Q as default
};
//# sourceMappingURL=TableHeaderRow.js.map
