import { jsx as t } from "react/jsx-runtime";
import { createContext as P, useContext 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-BjcDZ5eb.es.js";
import { chakra as S } from "@chakra-ui/react/styled-system";
import { e as N } from "./extract-style-props-BdibuNZ7.es.js";
import { $ as T } from "./mergeProps-Dsl8k3Ig.es.js";
import { $ as k, a as _ } from "./useDisclosureState-CWZTR2xM.es.js";
const f = /* @__PURE__ */ P(void 0);
function b() {
  const o = R(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: "collapsibleMotion"
}), D = /* @__PURE__ */ j("div", "root"), V = /* @__PURE__ */ m("button", "trigger"), q = /* @__PURE__ */ m("div", "content"), C = /* @__PURE__ */ c(
  ({
    children: o,
    defaultExpanded: s = !1,
    isExpanded: r,
    onExpandedChange: i,
    isDisabled: e = !1,
    ...l
  }, n) => {
    const a = k({
      defaultExpanded: s,
      isExpanded: r,
      onExpandedChange: i
    }), 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, ...r }, i) => {
  const { buttonProps: e, isDisabled: l } = b(), n = T(r, 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: i, ...a, asChild: !0, children: /* @__PURE__ */ t(E, { ...p, children: o }) });
});
u.displayName = "CollapsibleMotion.Trigger";
const x = /* @__PURE__ */ c(({ children: o, ...s }, r) => {
  const { panelProps: i, isExpanded: e } = b(), l = d(null), n = y(v(l, r));
  return /* @__PURE__ */ t(q, { ref: n, ...s, ...i, 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 {
  C,
  u as a,
  x as b,
  L as c
};
//# sourceMappingURL=collapsible-motion-DvtUDuxb.es.js.map
