"use strict";const B=require("./tslib.es6-C4EgNkz1.js"),n=require("react"),C=require("classnames"),H=require("./forwardRef-DBQKIlPy.js");require("./array.polyfill.flat-5BAolFdk.js");const L=require("./icon-I30uh1Ov.js"),A=require("./progress-spinner-DTmNtD59.js"),D=require("./icons/ebay-icon-chevron-down-12/index.js"),P={cta:"cta-",fake:"fake-",expand:"expand-",default:""},u=t=>{var{type:r="default",children:a}=t,s=B.__rest(t,["type","children"]);return n.createElement("span",Object.assign({className:`${P[r]}btn__cell`},s),n.createElement(n.Fragment,null,a))},T=()=>n.createElement(u,null,n.createElement(A.EbayProgressSpinner,null)),G=({className:t,children:r})=>n.createElement("span",{className:C(t,"btn__text")},r),J=({children:t})=>t?n.createElement(u,null,n.createElement(G,null,t),n.createElement(D.EbayIconChevronDown12,null)):n.createElement(D.EbayIconChevronDown12,null),M=t=>{var{priority:r="secondary",variant:a="standard",size:s,bodyState:y,split:q,transparent:S=!1,fluid:_=!1,disabled:b,partiallyDisabled:N,children:o,onKeyDown:k=()=>{},onEscape:I=()=>{},truncate:R=!1,href:i,className:K,forwardedRef:f,borderless:p,fixedHeight:E}=t,m=B.__rest(t,["priority","variant","size","bodyState","split","transparent","fluid","disabled","partiallyDisabled","children","onKeyDown","onEscape","truncate","href","className","forwardedRef","borderless","fixedHeight"]);const e=i?"fake-btn":"btn",O={primary:`${e}--primary`,secondary:`${e}--secondary`,tertiary:`${e}--tertiary`,none:""},c={large:`${e}--large`,small:`${e}--small`},j={start:`${e}--split-start`,end:`${e}--split-end`},z=a==="destructive",d=a==="form",$=y==="loading",h=y==="expand",F=d&&(U(o)||h&&!o),g=C(e,K,O[d||p?"none":r],c[s],j[q],z&&`${e}--destructive`,d&&`${e}--form`,F&&`${e}--slim`,S&&`${e}--transparent`,_&&`${e}--fluid`,R&&`${e}--truncated`,p&&`${e}--borderless`,E&&(c[s]?`${c[s]}-${E}`:`${e}--fixed-height`)),v=l=>{k(l),(l.key==="Escape"||l.key==="Esc")&&I(l)},w=Q(o,{isLoading:$,isExpand:h}),x=$?"polite":null;return i?n.createElement("a",Object.assign({className:g,href:b?void 0:i,ref:f,onKeyDown:v,"aria-live":x},m),w):n.createElement("button",Object.assign({disabled:b,"aria-disabled":N,"aria-live":x,className:g,ref:f,onKeyDown:v},m),w)};function Q(t,{isLoading:r,isExpand:a}){switch(!0){case r:return n.createElement(T,null);case a:return n.createElement(J,null,t);default:return t}}function U(t){const r=n.Children.toArray(t);return r.length===1&&r[0].type===L.EbayIcon}const V=H.withForwardRef(M);exports.EbayButton=V;exports.EbayButtonCell=u;
