import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{A as a,Lt as o,Rt as s,St as c,_t as l,bt as u,ft as d,kt as f,vt as p,w as m,zt as h}from"./src.sR_9Xh2m.js";import{t as g}from"./useEmotionTheme.61kSPILX.js";import{l as _}from"./utils.C5b8Q4FE.js";import{i as v,n as y,t as b}from"./DynamicIcon.BDXbm0Of.js";import{c as x,n as S,u as C}from"./useCopyToClipboard.CEiWWO_K.js";var w=e(t()),T=i(`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=i(`div`,{target:`e3xlboh1`})(({theme:e})=>({display:`inline-flex`,marginTop:e.spacing.threeXS})),D=i(`div`,{target:`e3xlboh2`})(({theme:e})=>({display:`flex`,alignItems:`center`,gap:e.spacing.sm,whiteSpace:`nowrap`})),O=i(`span`,{target:`e3xlboh3`})(({theme:e})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,width:e.iconSizes.md,color:e.colors.bodyText})),k=i(`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:s.PRIMARY,secondary:s.SECONDARY,tertiary:s.TERTIARY},j=(0,w.memo)(function({item:e,$isHighlighted:t,onClick:i,onMouseEnter:a,onKeyDown:o,$disabled:s,$isFocused:l,$size:u,resetMenu:d,renderAll:f,...p}){let{icon:h,text:g}=y(e.label);return n(k,{...p,role:`menuitem`,onClick:i,onMouseEnter:a,onKeyDown:o,children:n(m,{$isHighlighted:t,children:r(D,{children:[h&&n(O,{"aria-hidden":`true`,children:n(b,{iconValue:h,size:`md`})}),n(c,{source:g,allowHTML:!1,isLabel:!0,largerLabel:!1,disableLinks:!0})]})})})});function M(e){let{disabled:t,element:i,widgetMgr:c,fragmentId:m}=e,[y,D]=(0,w.useState)(!1),O=(0,w.useContext)(f),k=g(),M=A[i.type]??s.SECONDARY,N=(0,w.useMemo)(()=>i.options.map(e=>({label:e,value:e})),[i.options]),P=t||i.disabled||i.options.length===0,F=v(i.icon,i.label),I=(0,w.useCallback)(e=>{D(!1),!P&&c.setStringTriggerValue(i,e.item.value,{fromUi:!0},m)},[P,i,c,m]);return n(p,{className:`stMenuButton`,"data-testid":`stMenuButton`,children:n(S,{triggerType:C.click,placement:x.bottomLeft,isOpen:y,onClickOutside:()=>D(!1),onEsc:()=>D(!1),ignoreBoundary:O,popoverMargin:_(k.spacing.twoXS),renderAll:!0,content:()=>n(a,{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:()=>({...u(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:n(`div`,{children:n(l,{help:i.help,containerWidth:!0,children:n(o,{"data-testid":`stMenuButtonButton`,kind:M,size:h.SMALL,disabled:P,containerWidth:!0,onClick:()=>D(!y),"aria-haspopup":`menu`,"aria-expanded":y,children:r(T,{$hideChevron:F,children:[n(d,{icon:i.icon,label:i.label}),!F&&n(E,{"aria-hidden":`true`,children:n(b,{iconValue:y?`:material/expand_less:`:`:material/expand_more:`,size:`lg`})})]})})})})})})}var N=(0,w.memo)(M);export{N as default};