"use strict";const n=require("react/jsx-runtime"),l=require("react"),_=require("./button-BR4fvcmi.cjs.js"),E=require("./icon-button-CeB8_Yyr.cjs.js"),p=require("./menu-Dno8yFDE.cjs.js"),N=require("./icon-RyFjTAmU.cjs.js"),T=require("@chakra-ui/react"),o=require("./normalize-messages-CaDzkuUm.cjs.js"),O=require("@commercetools/nimbus-icons"),{withProvider:$,withContext:d}=T.createSlotRecipeContext({key:"splitButton"}),k=$("div","root"),F=d("div","buttonGroup"),G=d("button","primaryButton"),K=d("button","dropdownTrigger"),L={noActionsAvailable:"No actions available"},V={noActionsAvailable:"Keine Aktionen verfügbar"},W={noActionsAvailable:"No hay acciones disponibles"},H={noActionsAvailable:"Aucune action disponible"},J={noActionsAvailable:"Não há ações disponíveis"},Q={en:o.normalizeMessages(L),de:o.normalizeMessages(V),es:o.normalizeMessages(W),"fr-FR":o.normalizeMessages(H),"pt-BR":o.normalizeMessages(J)},I=b=>{const S=o.useLocalizedStringFormatter(Q),{size:x="md",variant:m="solid",colorPalette:v,isDisabled:g=!1,"aria-label":D,onAction:a,isOpen:j,defaultOpen:y,onOpenChange:C,icon:h}=b,f={size:x,variant:m,colorPalette:v},M=t=>{if(!l.isValidElement(t)||!t.props)return!1;const e=t.props;return"id"in e&&typeof e.id=="string"},A=t=>!l.isValidElement(t)||!t.props?!1:"children"in t.props,c=b.children,B=t=>{let e=!1;return l.Children.forEach(t,r=>{if(!e){if(M(r)&&!r.props.isDisabled){e=!0;return}A(r)&&(e=B(r.props.children))}}),e},q=()=>{const t=[],e=u=>{l.Children.forEach(u,s=>{M(s)&&t.push({content:s.props.children,isDisabled:s.props.isDisabled||!1,actionId:s.props.id}),A(s)&&e(s.props.children)})};return e(c),t.find(u=>!u.isDisabled)||t[0]||{content:S.format("noActionsAvailable"),isDisabled:!0,actionId:null}},z=B(c),i=q(),P=()=>{!i.isDisabled&&i.actionId&&a&&a(i.actionId)},R=g||i.isDisabled,w=g||!z;return n.jsx(k,{variant:m,"data-mode":"split",children:n.jsxs(F,{children:[n.jsx(G,{asChild:!0,children:n.jsxs(_.Button,{...f,isDisabled:R,onPress:P,children:[h&&n.jsx(N.Icon,{children:h}),i.content]})}),n.jsxs(p.Menu.Root,{trigger:"press",isOpen:j,defaultOpen:y,onOpenChange:C,placement:"bottom end",selectionMode:"none",onAction:a?t=>a(String(t)):void 0,children:[n.jsx(p.Menu.Trigger,{asChild:!0,children:n.jsx(K,{asChild:!0,children:n.jsx(E.IconButton,{...f,"aria-label":D,isDisabled:w,children:n.jsx(O.KeyboardArrowDown,{})})})}),n.jsx(p.Menu.Content,{children:c})]})]})})};I.displayName="SplitButton";exports.SplitButton=I;
//# sourceMappingURL=split-button-B4gVhpP9.cjs.js.map
