"use client";
import { jsxs as r, jsx as a } from "react/jsx-runtime";
import { useState as y } from "react";
import { cn as o } from "../../utils/cn/cn.es.js";
import i from "../../components/FilterMenu/filterMenu.module.css";
import { Typography as m } from "../Typography/Typography.es.js";
import { Icon as L } from "../Icon/Icon.es.js";
import { EIconName as d } from "../Icon/constants.es.js";
function w({
  label: p,
  open: h = !1,
  multiple: f,
  options: b,
  selectedValue: l,
  headerNode: t,
  onSelect: u
}) {
  const [c, N] = y(h), g = () => N((e) => !e);
  return /* @__PURE__ */ r("div", { className: i.root, children: [
    /* @__PURE__ */ r("button", { className: i.toggleButton, onClick: g, children: [
      /* @__PURE__ */ a(m, { defaultVariant: "labelLg", emphasis: !0, children: p }),
      /* @__PURE__ */ a(L, { name: c ? d.REMOVE : d.PLUS, className: i.toggleIcon })
    ] }),
    /* @__PURE__ */ a("div", { className: o(i.menu, c && i.isOpen), role: "menu", children: /* @__PURE__ */ r("div", { className: i.menuContent, children: [
      t,
      b.map((e, s) => /* @__PURE__ */ r("ul", { className: i.subOptions, children: [
        e.label && /* @__PURE__ */ a(
          "li",
          {
            className: o(i.divider, {
              [i.dividerLine]: !!(t || s !== 0)
            }),
            children: /* @__PURE__ */ a(
              m,
              {
                as: "div",
                defaultVariant: "bodyMd",
                weight: "medium",
                className: i.dividerLabel,
                children: e.label
              }
            )
          },
          s
        ),
        e.values.map(({ value: n, label: v }) => /* @__PURE__ */ a("li", { className: i.option, onClick: () => u(n, e), children: /* @__PURE__ */ a(
          m,
          {
            as: "div",
            defaultVariant: "bodyMd",
            className: o(i.optionLabel, {
              [i.selected]: f ? l == null ? void 0 : l.includes(n) : n === l
            }),
            children: v
          }
        ) }, n))
      ] }, `${e.label}_${s}`))
    ] }) })
  ] });
}
export {
  w as FilterMenu
};
