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