import{Cn as e,Ja as t,Qa as n,Sn as r,Sr as i,Ya as a,an as o,bn as s,cn as c,cr as l,er as u,fr as d,hr as f,io as p,jn as m,mn as h,nr as g,on as _,pr as v,rn as y,tr as b,vr as x,vt as S,wt as C}from"./index.dkY5s53S.js";var w=p(n(),1),T=x(`div`,{target:`e3xlboh0`})(({theme:e,$hideChevron:t})=>({display:`flex`,alignItems:`center`,gap:e.spacing.threeXS,marginRight:t?0:`calc(-${e.iconSizes.lg} * 0.25)`})),E=x(`div`,{target:`e3xlboh1`})(({theme:e})=>({display:`inline-flex`,marginTop:e.spacing.threeXS})),D=x(`div`,{target:`e3xlboh2`})(({theme:e})=>({display:`flex`,alignItems:`center`,gap:e.spacing.sm,whiteSpace:`nowrap`})),O=x(`span`,{target:`e3xlboh3`})(({theme:e})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,width:e.iconSizes.md,color:e.colors.bodyText})),k=x(`li`,{target:`e3xlboh4`})(({theme:e})=>({display:`flex`,alignItems:`center`,marginTop:e.spacing.twoXS,marginBottom:e.spacing.twoXS,padding:0,background:`transparent`,cursor:`pointer`,listStyle:`none`,minWidth:e.sizes.minMenuWidth})),A={primary:b.PRIMARY,secondary:b.SECONDARY,tertiary:b.TERTIARY},j=(0,w.memo)(function({item:e,$isHighlighted:n,onClick:r,onMouseEnter:i,onKeyDown:o,$disabled:s,$isFocused:c,$size:l,resetMenu:u,renderAll:f,...p}){let{icon:m,text:g}=v(e.label);return t(k,{...p,role:`menuitem`,onClick:r,onMouseEnter:i,onKeyDown:o,children:t(S,{$isHighlighted:n,children:a(D,{children:[m&&t(O,{"aria-hidden":`true`,children:t(d,{iconValue:m,size:`md`})}),t(h,{source:g,allowHTML:!1,isLabel:!0,disableLinks:!0})]})})})});function M(n){let{disabled:p,element:h,widgetMgr:v,fragmentId:x}=n,[S,D]=(0,w.useState)(!1),O=(0,w.useContext)(m),k=l(),M=A[h.type]??b.SECONDARY,N=(0,w.useMemo)(()=>h.options.map(e=>({label:e,value:e})),[h.options]),P=p||h.disabled||h.options.length===0,F=f(h.icon,h.label),I=(0,w.useCallback)(e=>{D(!1),!P&&v.setStringTriggerValue(h,e.item.value,{fromUi:!0},x)},[P,h,v,x]);return t(_,{className:`stMenuButton`,"data-testid":`stMenuButton`,children:t(s,{triggerType:e.click,placement:r.bottomLeft,isOpen:S,onClickOutside:()=>D(!1),onEsc:()=>D(!1),ignoreBoundary:O,popoverMargin:i(k.spacing.twoXS),renderAll:!0,content:()=>t(C,{items:N,onItemSelect:I,overrides:{List:{props:{role:`menu`},style:{backgroundColor:k.colors.bgColor,paddingTop:k.spacing.threeXS,paddingBottom:k.spacing.threeXS,paddingLeft:k.spacing.xs,paddingRight:k.spacing.xs,boxShadow:`none`,outline:`none`}},Option:{component:j}}}),overrides:{Body:{props:{"data-testid":`stMenuButtonBody`},style:()=>({...c(k),borderTopLeftRadius:k.radii.xl,borderTopRightRadius:k.radii.xl,borderBottomRightRadius:k.radii.xl,borderBottomLeftRadius:k.radii.xl,marginRight:k.spacing.lg,marginBottom:k.spacing.lg,maxHeight:`70vh`,overflow:`auto`})}},children:t(`div`,{children:t(o,{help:h.help,containerWidth:!0,children:t(u,{"data-testid":`stMenuButtonButton`,kind:M,size:g.SMALL,disabled:P,containerWidth:!0,onClick:()=>D(!S),"aria-haspopup":`menu`,"aria-expanded":S,children:a(T,{$hideChevron:F,children:[t(y,{icon:h.icon,label:h.label}),!F&&t(E,{"aria-hidden":`true`,children:t(d,{iconValue:S?`:material/expand_less:`:`:material/expand_more:`,size:`lg`})})]})})})})})})}var N=(0,w.memo)(M);export{N as default};