"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react/jsx-runtime");require("@styled/tokens");var o=require("react"),l=require("@styled/jsx"),R=require("@styled/css");require("../feedback/callout.js");var O=require("../feedback/loading-spinner.js");require("../feedback/progress-bar.js"),require("./checkbox.js"),require("./dropdown-selector.js"),require("./popover.js"),require("./radio.js"),require("./segmented-control.js"),require("./switch.js"),require("./text.js"),require("./portal.js"),require("../../hooks/useToast.js"),require("../../recipes/toast.js"),require("../feedback/tooltip.js");var E=require("../../recipes/button.js"),q=require("create-slots"),d=require("react-aria");const S=q.createSlot(({children:e,...t})=>i.jsx(l.Flex,{alignItems:"center",justifyContent:"center",children:o.Children.map(e,r=>o.cloneElement(r,t))})),w=q.createSlot(({children:e,...t})=>i.jsx(l.Flex,{alignItems:"center",justifyContent:"center",children:o.Children.map(e,r=>o.cloneElement(r,t))})),k=({variant:e="primary",size:t="md"})=>{const r=e==="primary"||e==="negative",c=e==="neutral"||e==="tertiary";return i.jsx(O.LoadingSpinner,{size:{sm:20,md:24,lg:28}[t],strokeWidth:2.5,inverted:r,neutral:c})},C=o.forwardRef((e,t)=>{const{label:r,variant:c="primary",textStyle:z,size:p="md",disabled:m,expand:v,validating:x,iconSize:N,onHover:g,centerContent:h}=e,u=N||(p==="sm"?16:24),b=r&&v&&!h,n=E.button({variant:c,textStyle:z,expand:v,size:p,validating:x,iconOnly:!r}),P=o.useRef(null),j=t||P,{buttonProps:B}=d.useButton({...e,isDisabled:m??!1},j),{hoverProps:F}=d.useHover({isDisabled:m??!1}),{isFocusVisible:H,focusProps:I}=d.useFocusRing();return q.createHost(e.children,f=>{const s=f.get(S),a=f.get(w),y=u/4;return i.jsx("button",{className:R.cx(n.button,"group",!r&&n.iconContainer,H&&n.focus),ref:j,...d.mergeProps(B,F,I),"aria-disabled":m,onMouseEnter:g,onTouchStart:g,children:x?i.jsx(k,{variant:c,size:p}):i.jsxs(l.HStack,{w:"full",gap:2,justify:r&&(s||a)&&!h?"space-between":"center",children:[s&&{...s,props:{className:s.props.color?void 0:n.icon,width:u,height:u,...s.props}},a&&b&&i.jsx(l.Box,{w:y}),r&&i.jsx("span",{className:n.label,children:r}),s&&b&&i.jsx(l.Box,{w:y}),a&&{...a,props:{className:a.props.color?void 0:n.icon,width:u,height:u,...a.props}}]})})})}),D=Object.assign(C,{LeadingIcon:S,TrailingIcon:w});C.displayName="Button",exports.default=D;
//# sourceMappingURL=button.js.map
