"use client";
import { j as d } from "../../../node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.mjs";
import { Accordion as u } from "@mantine/core";
import i from "../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.mjs";
import b from "../Button/index.mjs";
import B from "../Checkbox/index.mjs";
import n from "./OptionsAccordion.module.scss.mjs";
function E({
  options: r,
  setOptions: f,
  classNames: t,
  ...k
}) {
  function l(e, h) {
    const c = r;
    for (const o in r)
      for (const x in r[o])
        c[o][x].selected = !1;
    c[e][h].selected = !0, f({
      ...r,
      ...c
    });
  }
  function p(e) {
    const h = r;
    for (const c in r[e])
      h[e][c].selected = !1;
    f({
      ...r,
      ...h
    });
  }
  function O(e) {
    const h = r[e], c = [];
    return Object.keys(h).forEach(
      (o, x) => c.push(
        /* @__PURE__ */ d.jsxs(
          "div",
          {
            style: {
              display: "flex",
              flexDirection: "row",
              justifyContent: "space-between",
              alignItems: "center"
            },
            className: i(n.optionRow, t == null ? void 0 : t.optionRow),
            children: [
              /* @__PURE__ */ d.jsx(
                B,
                {
                  type: "secondary",
                  checked: r[e][o].selected,
                  onChange: (C) => {
                    const y = {};
                    y[e] = r[e], y[e][o].selected = C.target.checked, f({
                      ...r,
                      ...y
                    });
                  },
                  "data-testid": `${o}-checkbox`,
                  children: /* @__PURE__ */ d.jsx(
                    "div",
                    {
                      className: i(
                        n.checkboxBody,
                        t != null && t.checkboxBody ? t == null ? void 0 : t.checkboxBody : "body"
                      ),
                      children: r[e][o].displayName ?? o
                    }
                  )
                }
              ),
              /* @__PURE__ */ d.jsx(
                b,
                {
                  type: "link",
                  size: "small",
                  onClick: () => l(e, o),
                  className: n.onlyButton,
                  "data-testid": `${o}-only-button`,
                  children: "Only"
                }
              )
            ]
          },
          `${e}-${o}-${x}-item`
        )
      )
    ), /* @__PURE__ */ d.jsxs(u.Item, { value: e, children: [
      /* @__PURE__ */ d.jsx(u.Control, { children: /* @__PURE__ */ d.jsx("div", { className: i("title-sm", n.sectionTitle), children: e }) }),
      /* @__PURE__ */ d.jsxs(u.Panel, { children: [
        /* @__PURE__ */ d.jsx("div", { className: i(n.panelList, t == null ? void 0 : t.panelList), children: c }),
        /* @__PURE__ */ d.jsx(
          b,
          {
            type: "tertiary",
            size: "small",
            onClick: () => p(e),
            className: n.clearButton,
            "data-testid": `${e}-clear-filter`,
            children: /* @__PURE__ */ d.jsx("div", { className: "button-sm", children: "Clear filter" })
          },
          `${e}-clear-filter`
        )
      ] })
    ] }, e);
  }
  const j = [];
  return Object.keys(r).forEach((e) => {
    j.push(O(e));
  }), // chevron position right is not being respected here
  /* @__PURE__ */ d.jsx(
    u,
    {
      unstyled: !0,
      variant: "contained",
      classNames: {
        panel: i(n.panel, t == null ? void 0 : t.panel),
        item: i(n.item, t == null ? void 0 : t.item),
        content: i(n.content, t == null ? void 0 : t.content),
        control: i(n.control, t == null ? void 0 : t.control),
        chevron: i(n.chevron, t == null ? void 0 : t.chevron),
        root: i(n.root, t == null ? void 0 : t.root),
        label: i(n.label, t == null ? void 0 : t.label),
        icon: i(n.icon, t == null ? void 0 : t.icon),
        itemTitle: i(n.itemTitle, t == null ? void 0 : t.itemTitle)
      },
      multiple: !0,
      ...k,
      children: j
    }
  );
}
export {
  E as OptionsAccordion
};
//# sourceMappingURL=index.mjs.map
