import { jsx as t } from "react/jsx-runtime";
import { useContext as P, createContext as R, forwardRef as c, useRef as d } from "react";
import { createSlotRecipeContext as h, mergeRefs as v, Presence as w } from "@chakra-ui/react";
import { $ as y } from "./useObjectRef-CaJ5pgjX.es.js";
import { a as E } from "./Button-C9AKe3Kt.es.js";
import { chakra as S } from "@chakra-ui/react/styled-system";
import { e as N } from "./extract-style-props-CMyV-es-.es.js";
import { $ as T } from "./mergeProps-B-cqsBhL.es.js";
import { $ as k, a as _ } from "./useDisclosureState-CPUsvP5-.es.js";
const f = /* @__PURE__ */ R(void 0);
function b() {
  const o = P(f);
  if (o === void 0)
    throw new Error(
      "useCollapsibleMotionContext must be used within a CollapsibleMotion.Root component"
    );
  return o;
}
const { withProvider: j, withContext: m } = /* @__PURE__ */ h({
  key: "nimbusCollapsibleMotion"
}), D = /* @__PURE__ */ j("div", "root"), V = /* @__PURE__ */ m("button", "trigger"), q = /* @__PURE__ */ m("div", "content"), C = /* @__PURE__ */ c(
  ({
    children: o,
    defaultExpanded: s = !1,
    isExpanded: i,
    onExpandedChange: r,
    isDisabled: e = !1,
    ...l
  }, n) => {
    const a = k({
      defaultExpanded: s,
      isExpanded: i,
      onExpandedChange: r
    }), p = d(null), { buttonProps: $, panelProps: M } = _(
      { isDisabled: e },
      a,
      p
    ), g = {
      isDisabled: e,
      isExpanded: a.isExpanded,
      buttonProps: $,
      panelProps: M,
      panelRef: p
    };
    return /* @__PURE__ */ t(f.Provider, { value: g, children: /* @__PURE__ */ t(D, { ref: n, ...l, children: o }) });
  }
);
C.displayName = "CollapsibleMotion.Root";
const u = /* @__PURE__ */ c(({ children: o, asChild: s, ...i }, r) => {
  const { buttonProps: e, isDisabled: l } = b(), n = T(i, e, {
    disabled: l
  });
  if (s)
    return /* @__PURE__ */ t(S.button, { asChild: !0, ...n, children: o });
  const [a, p] = N(n);
  return /* @__PURE__ */ t(V, { ref: r, ...a, asChild: !0, children: /* @__PURE__ */ t(E, { ...p, children: o }) });
});
u.displayName = "CollapsibleMotion.Trigger";
const x = /* @__PURE__ */ c(({ children: o, ...s }, i) => {
  const { panelProps: r, isExpanded: e } = b(), l = d(null), n = y(v(l, i));
  return /* @__PURE__ */ t(q, { ref: n, ...s, ...r, asChild: !0, children: /* @__PURE__ */ t(
    w,
    {
      present: e,
      animationName: {
        _open: "slide-from-top, fade-in",
        _closed: "slide-to-top, fade-out"
      },
      animationDuration: "fast",
      children: o
    }
  ) });
});
x.displayName = "CollapsibleMotion.Content";
const L = {
  /**
   * # CollapsibleMotion.Root
   *
   * The root container component that manages state and provides context.
   * Handles both controlled and uncontrolled modes for expanded/collapsed state.
   *
   * @example
   * ```tsx
   * <CollapsibleMotion.Root defaultExpanded={false}>
   *   <CollapsibleMotion.Trigger>Toggle</CollapsibleMotion.Trigger>
   *   <CollapsibleMotion.Content>Content here</CollapsibleMotion.Content>
   * </CollapsibleMotion.Root>
   * ```
   */
  Root: C,
  /**
   * # CollapsibleMotion.Trigger
   *
   * The trigger button that toggles the collapsible content.
   * Handles keyboard and mouse interactions with proper ARIA attributes.
   *
   * @example
   * ```tsx
   * <CollapsibleMotion.Trigger>
   *   Click to expand
   * </CollapsibleMotion.Trigger>
   * ```
   */
  Trigger: u,
  /**
   * # CollapsibleMotion.Content
   *
   * The collapsible content container with smooth expand/collapse animations.
   * Automatically handles ARIA attributes for accessibility.
   *
   * @example
   * ```tsx
   * <CollapsibleMotion.Content>
   *   <Text>Your collapsible content</Text>
   * </CollapsibleMotion.Content>
   * ```
   */
  Content: x
};
export {
  L as C,
  x as a,
  C as b,
  u as c
};
//# sourceMappingURL=collapsible-motion-Bwe4uYjG.es.js.map
