import{r}from"./index-76f1ce5c.js";import{C as L,P as M,O,c as b,m as s,R as K,T as U,S as A,I as F}from"./tooltip.esm-3f4b62d9.js";function d(){return d=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(n[o]=a[o])}return n},d.apply(this,arguments)}function p(n){return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(n)}function H(n,t){if(p(n)!=="object"||n===null)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var o=a.call(n,t||"default");if(p(o)!=="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function J(n){var t=H(n,"string");return p(t)==="symbol"?t:String(t)}function c(n,t,a){return t=J(t),t in n?Object.defineProperty(n,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[t]=a,n}var g=L.extend({defaultProps:{__TYPE:"Button",badge:null,badgeClassName:null,className:null,children:void 0,disabled:!1,icon:null,iconPos:"left",label:null,link:!1,loading:!1,loadingIcon:null,outlined:!1,raised:!1,rounded:!1,severity:null,size:null,text:!1,tooltip:null,tooltipOptions:null,visible:!0}});function P(n,t){var a=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);t&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),a.push.apply(a,o)}return a}function X(n){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?P(Object(a),!0).forEach(function(o){c(n,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(a)):P(Object(a)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(a,o))})}return n}var Y=r.memo(r.forwardRef(function(n,t){var a,o=r.useContext(M),e=g.getProps(n,o),h=g.setMetaData({props:e}),i=h.ptm,u=r.useRef(t);if(r.useEffect(function(){O.combinedRefs(u,t)},[u,t]),e.visible===!1)return null;var N=function(){var l=b("p-button-icon p-c",c({},"p-button-icon-".concat(e.iconPos),e.label)),m=s({className:l},i("icon"));l=b(l,{"p-button-loading-icon":e.loading});var C=s({className:l},i("loadingIcon")),z=e.loading?e.loadingIcon||r.createElement(A,d({},C,{spin:!0})):e.icon;return F.getJSXIcon(z,X({},m),{props:e})},E=function(){if(e.label){var l=s({className:"p-button-label p-c"},i("label"));return r.createElement("span",l,e.label)}return!e.children&&!e.label&&r.createElement("span",{className:"p-button-label p-c",dangerouslySetInnerHTML:{__html:"&nbsp;"}})},S=function(){if(e.badge){var l=b("p-badge",e.badgeClassName),m=s({className:l},i("badge"));return r.createElement("span",m,e.badge)}return null},f=e.disabled||e.loading,w=!f||e.tooltipOptions&&e.tooltipOptions.showOnDisabled,_=O.isNotEmpty(e.tooltip)&&w,j={large:"lg",small:"sm"},v=j[e.size],B=b("p-button p-component",e.className,(a={"p-button-icon-only":(e.icon||e.loading)&&!e.label&&!e.children,"p-button-vertical":(e.iconPos==="top"||e.iconPos==="bottom")&&e.label,"p-disabled":f,"p-button-loading":e.loading,"p-button-outlined":e.outlined,"p-button-raised":e.raised,"p-button-link":e.link,"p-button-text":e.text,"p-button-rounded":e.rounded,"p-button-loading-label-only":e.loading&&!e.icon&&e.label},c(a,"p-button-loading-".concat(e.iconPos),e.loading&&e.label),c(a,"p-button-".concat(v),v),c(a,"p-button-".concat(e.severity),e.severity),a)),I=N(),x=E(),D=S(),R=e.label?e.label+(e.badge?" "+e.badge:""):e["aria-label"],T=s({ref:u,"aria-label":R,className:B,disabled:f},g.getOtherProps(e),i("root"));return r.createElement(r.Fragment,null,r.createElement("button",T,I,x,e.children,D,r.createElement(K,null)),_&&r.createElement(U,d({target:u,content:e.tooltip},e.tooltipOptions,{pt:i("tooltip")})))}));Y.displayName="Button";export{Y as B};
