import { jsx as i, jsxs as A } from "react/jsx-runtime";
import { createSlotRecipeContext as z } from "@chakra-ui/react";
import { $ as D, a as B } from "./Button-C9AKe3Kt.es.js";
import { a as P, d as O, e as R, $ as q, g as J } from "./utils-CrjF8U_E.es.js";
import { $ as w, a as L } from "./mergeProps-B-cqsBhL.es.js";
import { $ as g } from "./filterDOMProps-Cxz9cAAv.es.js";
import c, { useMemo as m, useEffect as Q, forwardRef as C, useContext as S, createContext as p } from "react";
import { $ as K } from "./useFocusRing-CZQUsztf.es.js";
import { $ as U, a as X } from "./useDisclosureState-CPUsvP5-.es.js";
import { $ as Y } from "./useControlledState-3TGZUXux.es.js";
import { e as $ } from "./extract-style-props-CMyV-es-.es.js";
import { KeyboardArrowRight as Z } from "@commercetools/nimbus-icons";
import { F as k } from "./flex-BqxAMF-7.es.js";
import { useSlotRecipe as ee } from "@chakra-ui/react/styled-system";
function te(o) {
  let { allowsMultipleExpanded: e = !1, isDisabled: s = !1 } = o, [t, a] = Y(m(() => o.expandedKeys ? new Set(o.expandedKeys) : void 0, [
    o.expandedKeys
  ]), m(() => o.defaultExpandedKeys ? new Set(o.defaultExpandedKeys) : /* @__PURE__ */ new Set(), [
    o.defaultExpandedKeys
  ]), o.onExpandedChange);
  return Q(() => {
    if (!e && t.size > 1) {
      let d = t.values().next().value;
      d != null && a(/* @__PURE__ */ new Set([
        d
      ]));
    }
  }), {
    allowsMultipleExpanded: e,
    isDisabled: s,
    expandedKeys: t,
    setExpandedKeys: a,
    toggleKey(d) {
      let n;
      e ? (n = new Set(t), n.has(d) ? n.delete(d) : n.add(d)) : n = new Set(t.has(d) ? [] : [
        d
      ]), a(n);
    }
  };
}
const F = /* @__PURE__ */ p(null), oe = /* @__PURE__ */ C(function(e, s) {
  let t = te(e), a = P({
    ...e,
    defaultClassName: "react-aria-DisclosureGroup",
    values: {
      isDisabled: t.isDisabled,
      state: t
    }
  }), d = g(e, {
    global: !0
  });
  return /* @__PURE__ */ c.createElement("div", {
    ...d,
    ...a,
    ref: s,
    "data-disabled": e.isDisabled || void 0
  }, /* @__PURE__ */ c.createElement(F.Provider, {
    value: t
  }, a.children));
}), de = /* @__PURE__ */ p(null), ae = /* @__PURE__ */ p(null), N = /* @__PURE__ */ p(null), se = /* @__PURE__ */ C(function(e, s) {
  [e, s] = q(e, s, de);
  let t = S(F), { id: a, ...d } = e, n = L();
  a || (a = n);
  let l = t ? t.expandedKeys.has(a) : e.isExpanded, r = U({
    ...e,
    isExpanded: l,
    onExpandedChange(G) {
      var x;
      t && t.toggleKey(a), (x = e.onExpandedChange) === null || x === void 0 || x.call(e, G);
    }
  }), u = c.useRef(null), b = e.isDisabled || t?.isDisabled || !1, { buttonProps: M, panelProps: _ } = X({
    ...e,
    isExpanded: l,
    isDisabled: b
  }, r, u), { isFocusVisible: y, focusProps: j } = K({
    within: !0
  }), v = P({
    ...e,
    id: void 0,
    defaultClassName: "react-aria-Disclosure",
    values: {
      isExpanded: r.isExpanded,
      isDisabled: b,
      isFocusVisibleWithin: y,
      state: r
    }
  }), T = g(d, {
    global: !0
  });
  return /* @__PURE__ */ c.createElement(R, {
    values: [
      [
        D,
        {
          slots: {
            [J]: {},
            trigger: M
          }
        }
      ],
      [
        N,
        {
          panelProps: _,
          panelRef: u
        }
      ],
      [
        ae,
        r
      ]
    ]
  }, /* @__PURE__ */ c.createElement("div", {
    ...w(T, v, j),
    ref: s,
    "data-expanded": r.isExpanded || void 0,
    "data-disabled": b || void 0,
    "data-focus-visible-within": y || void 0
  }, v.children));
}), ne = /* @__PURE__ */ C(function(e, s) {
  let { role: t = "group" } = e, { panelProps: a, panelRef: d } = S(N), { isFocusVisible: n, focusProps: l } = K({
    within: !0
  }), r = P({
    ...e,
    defaultClassName: "react-aria-DisclosurePanel",
    values: {
      isFocusVisibleWithin: n
    }
  }), u = g(e, {
    global: !0,
    labelable: !0
  });
  return /* @__PURE__ */ c.createElement("div", {
    ...w(u, r, a, l),
    ref: O(s, d),
    role: t,
    "data-focus-visible-within": n || void 0
  }, /* @__PURE__ */ c.createElement(R, {
    values: [
      [
        D,
        null
      ]
    ]
  }, e.children));
}), { withProvider: re, withContext: f } = /* @__PURE__ */ z({
  key: "nimbusAccordion"
}), ie = /* @__PURE__ */ re("div", "root"), le = /* @__PURE__ */ f("div", "disclosure"), ce = /* @__PURE__ */ f("button", "trigger"), fe = /* @__PURE__ */ f("div", "panel"), ue = /* @__PURE__ */ f("div", "accordionTitle"), h = /* @__PURE__ */ f("div", "headerContentRight"), V = (o) => {
  const { ref: e, ...s } = o, t = ee({ key: "nimbusAccordion" }), [a, d] = t.splitVariantProps(s), [n, l] = $(d);
  return /* @__PURE__ */ i(ie, { ref: e, ...a, ...n, asChild: !0, children: /* @__PURE__ */ i(oe, { ...l }) });
};
V.displayName = "Accordion.Root";
const H = ({
  children: o,
  value: e,
  ref: s,
  ...t
}) => {
  const [a, d] = $(t), n = {
    ...d,
    id: e
    // React Aria uses id for the key
  };
  return /* @__PURE__ */ i(
    le,
    {
      "data-value": e,
      ref: s,
      ...a,
      asChild: !0,
      children: /* @__PURE__ */ i(se, { ...n, children: o })
    }
  );
};
H.displayName = "Accordion.Item";
const E = ({
  children: o,
  ref: e,
  ...s
}) => /* @__PURE__ */ i(h, { ref: e, ...s, children: o });
E.displayName = "Accordion.HeaderRightContent";
const I = ({
  children: o,
  ref: e,
  ...s
}) => {
  const [t, a] = $(s), d = m(() => {
    const n = [], l = [];
    return c.Children.forEach(o, (r) => {
      c.isValidElement(r) && (r.type === E || r.type === h) ? l.push(r) : n.push(r);
    }), { main: n, rightContent: l };
  }, [o]);
  return /* @__PURE__ */ A(
    k,
    {
      justifyContent: "space-between",
      alignItems: "center",
      borderBottom: "solid-25",
      borderColor: "neutral.4",
      ...t,
      children: [
        /* @__PURE__ */ i(ce, { ref: e, slot: "trigger", asChild: !0, children: /* @__PURE__ */ A(B, { ...a, children: [
          /* @__PURE__ */ i(Z, {}),
          /* @__PURE__ */ i(ue, { children: d.main })
        ] }) }),
        d.rightContent.length > 0 && /* @__PURE__ */ i(h, { children: d.rightContent })
      ]
    }
  );
};
I.displayName = "Accordion.Header";
const W = ({
  children: o,
  ref: e,
  ...s
}) => {
  const [t, a] = $(s);
  return /* @__PURE__ */ i(fe, { ref: e, ...t, asChild: !0, children: /* @__PURE__ */ i(ne, { ...a, children: o }) });
};
W.displayName = "Accordion.Content";
const Re = {
  /**
   * # Accordion.Root
   *
   * The root container for the accordion component.
   * Provides context and configuration for all accordion items.
   *
   * @example
   * ```tsx
   * <Accordion.Root>
   *   <Accordion.Item>
   *     <Accordion.Header>Title</Accordion.Header>
   *     <Accordion.Content>Content</Accordion.Content>
   *   </Accordion.Item>
   * </Accordion.Root>
   * ```
   */
  Root: V,
  /**
   * # Accordion.Item
   *
   * An individual accordion item containing a header and collapsible content.
   * Multiple items can be placed within an Accordion.Root.
   *
   * @example
   * ```tsx
   * <Accordion.Item value="item-1">
   *   <Accordion.Header>Title</Accordion.Header>
   *   <Accordion.Content>Content</Accordion.Content>
   * </Accordion.Item>
   * ```
   */
  Item: H,
  /**
   * # Accordion.Header
   *
   * The clickable header that expands/collapses the accordion content.
   * Handles keyboard and mouse interactions for accordion activation.
   *
   * @example
   * ```tsx
   * <Accordion.Header>
   *   Click to expand
   * </Accordion.Header>
   * ```
   */
  Header: I,
  /**
   * # Accordion.Content
   *
   * The collapsible content area that is shown/hidden when the header is activated.
   * Contains the main content of the accordion item.
   *
   * @example
   * ```tsx
   * <Accordion.Content>
   *   <p>This content will be shown when expanded.</p>
   * </Accordion.Content>
   * ```
   */
  Content: W,
  /**
   * # Accordion.HeaderRightContent
   *
   * Optional content that appears on the right side of the accordion header.
   * Useful for adding actions, badges, or additional information.
   *
   * @example
   * ```tsx
   * <Accordion.Header>
   *   Title
   *   <Accordion.HeaderRightContent>
   *     <Button>Action</Button>
   *   </Accordion.HeaderRightContent>
   * </Accordion.Header>
   * ```
   */
  HeaderRightContent: E
};
export {
  Re as A,
  W as a,
  I as b,
  E as c,
  H as d,
  V as e
};
//# sourceMappingURL=accordion-CGL9rTeb.es.js.map
