"use client";
import * as React from "react";
import { triggerOpenStateMapping } from "../../utils/collapsibleOpenStateMapping.js";
import { transitionStatusMapping } from "../../utils/stateAttributesMapping.js";
import { useRenderElement } from "../../utils/useRenderElement.js";
import { useCollapsibleRootContext } from "../root/CollapsibleRootContext.js";
import { useButton } from "../../use-button/useButton.js";
const stateAttributesMapping = {
  ...triggerOpenStateMapping,
  ...transitionStatusMapping
};
const CollapsibleTrigger = /* @__PURE__ */ React.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
  const {
    panelId,
    open,
    handleTrigger,
    state,
    disabled: contextDisabled
  } = useCollapsibleRootContext();
  const {
    className,
    disabled = contextDisabled,
    id,
    render,
    nativeButton = true,
    ...elementProps
  } = componentProps;
  const {
    getButtonProps,
    buttonRef
  } = useButton({
    disabled,
    focusableWhenDisabled: true,
    native: nativeButton
  });
  const props = React.useMemo(() => ({
    "aria-controls": open ? panelId : void 0,
    "aria-expanded": open,
    disabled,
    onClick: handleTrigger
  }), [panelId, disabled, open, handleTrigger]);
  const element = useRenderElement("button", componentProps, {
    state,
    ref: [forwardedRef, buttonRef],
    props: [props, elementProps, getButtonProps],
    stateAttributesMapping
  });
  return element;
});
if (process.env.NODE_ENV !== "production") CollapsibleTrigger.displayName = "CollapsibleTrigger";
export {
  CollapsibleTrigger
};
//# sourceMappingURL=CollapsibleTrigger.js.map
