import{r as a,P as he,Z as M,b as L,O as A,c as D,I as Q,d as xe,D as V}from"./app-BZJf8lgN.js";import{C as Ee,u as Ce,P as Ie,R as Ne}from"./button.esm-D_cwsnQR.js";import{C as Se}from"./csstransition.esm-BNRxTMOa.js";import{u as ne,d as we,e as _e,g as Te}from"./hooks.esm-UVLztt_0.js";import{C as Oe}from"./index.esm-CygY3Qsw.js";import{a as Pe,T as ke,E as je,I as Me}from"./index.esm-B5zYYMSp.js";import{T as Re}from"./index.esm-hRnQzR_k.js";function F(){return F=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},F.apply(null,arguments)}function K(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}function Ae(e){if(Array.isArray(e))return K(e)}function Le(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function oe(e,n){if(e){if(typeof e=="string")return K(e,n);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?K(e,n):void 0}}function De(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Y(e){return Ae(e)||Le(e)||oe(e)||De()}function He(e){if(Array.isArray(e))return e}function Be(e,n){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var o,r,h,x,m=[],p=!0,d=!1;try{if(h=(t=t.call(e)).next,n===0){if(Object(t)!==t)return;p=!1}else for(;!(p=(o=h.call(t)).done)&&(m.push(o.value),m.length!==n);p=!0);}catch(c){d=!0,r=c}finally{try{if(!p&&t.return!=null&&(x=t.return(),Object(x)!==x))return}finally{if(d)throw r}}return m}}function Ue(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function W(e,n){return He(e)||Be(e,n)||oe(e,n)||Ue()}function _(e){"@babel/helpers - typeof";return _=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},_(e)}function Ze(e,n){if(_(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,n);if(_(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function $e(e){var n=Ze(e,"string");return _(n)=="symbol"?n:n+""}function ae(e,n,t){return(n=$e(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Xe=`
@layer primereact {
    .p-toast {
        width: calc(100% - var(--toast-indent, 0px));
        max-width: 25rem;
    }
    
    .p-toast-message-icon {
        flex-shrink: 0;
    }
    
    .p-toast-message-content {
        display: flex;
        align-items: flex-start;
    }
    
    .p-toast-message-text {
        flex: 1 1 auto;
    }
    
    .p-toast-summary {
        overflow-wrap: anywhere;
    }
    
    .p-toast-detail {
        overflow-wrap: anywhere;
    }
    
    .p-toast-top-center {
        transform: translateX(-50%);
    }
    
    .p-toast-bottom-center {
        transform: translateX(-50%);
    }
    
    .p-toast-center {
        min-width: 20vw;
        transform: translate(-50%, -50%);
    }
    
    .p-toast-icon-close {
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        position: relative;
    }
    
    .p-toast-icon-close.p-link {
        cursor: pointer;
    }
    
    /* Animations */
    .p-toast-message-enter {
        opacity: 0;
        transform: translateY(50%);
    }
    
    .p-toast-message-enter-active {
        opacity: 1;
        transform: translateY(0);
        transition: transform 0.3s, opacity 0.3s;
    }
    
    .p-toast-message-enter-done {
        transform: none;
    }
    
    .p-toast-message-exit {
        opacity: 1;
        max-height: 1000px;
    }
    
    .p-toast .p-toast-message.p-toast-message-exit-active {
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        overflow: hidden;
        transition: max-height 0.45s cubic-bezier(0, 1, 0, 1), opacity 0.3s, margin-bottom 0.3s;
    }
}
`,Je={root:function(n){var t=n.props,o=n.context;return D("p-toast p-component p-toast-"+t.position,t.className,{"p-input-filled":o&&o.inputStyle==="filled"||L.inputStyle==="filled","p-ripple-disabled":o&&o.ripple===!1||L.ripple===!1})},message:{message:function(n){var t=n.severity;return D("p-toast-message",ae({},"p-toast-message-".concat(t),t))},content:"p-toast-message-content",buttonicon:"p-toast-icon-close-icon",closeButton:"p-toast-icon-close p-link",icon:"p-toast-message-icon",text:"p-toast-message-text",summary:"p-toast-summary",detail:"p-toast-detail"},transition:"p-toast-message"},ze={root:function(n){var t=n.props;return{position:"fixed",top:t.position==="top-right"||t.position==="top-left"||t.position==="top-center"?"20px":t.position==="center"?"50%":null,right:(t.position==="top-right"||t.position==="bottom-right")&&"20px",bottom:(t.position==="bottom-left"||t.position==="bottom-right"||t.position==="bottom-center")&&"20px",left:t.position==="top-left"||t.position==="bottom-left"?"20px":t.position==="center"||t.position==="top-center"||t.position==="bottom-center"?"50%":null}}},R=Ee.extend({defaultProps:{__TYPE:"Toast",id:null,className:null,content:null,style:null,baseZIndex:0,position:"top-right",transitionOptions:null,appendTo:"self",onClick:null,onRemove:null,onShow:null,onHide:null,onMouseEnter:null,onMouseLeave:null,children:void 0},css:{classes:Je,styles:Xe,inlineStyles:ze}});function ee(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function l(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?ee(Object(t),!0).forEach(function(o){ae(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ee(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})}return e}var re=a.memo(a.forwardRef(function(e,n){var t=ne(),o=e.messageInfo,r=e.metaData,h=e.ptCallbacks,x=h.ptm,m=h.ptmo,p=h.cx,d=e.index,c=o.message,g=c.severity,H=c.content,T=c.summary,O=c.detail,B=c.closable,P=c.life,w=c.sticky,U=c.className,Z=c.style,$=c.contentClassName,X=c.contentStyle,y=c.icon,s=c.closeIcon,i=c.pt,f={index:d},u=l(l({},r),f),E=a.useState(!1),N=W(E,2),k=N[0],j=N[1],se=Te(function(){J()},P||3e3,!w&&!k),ie=W(se,1),q=ie[0],C=function(v,b){return x(v,l({hostName:e.hostName},b))},J=function(){q(),e.onClose&&e.onClose(o)},G=function(v){e.onClick&&!(V.hasClass(v.target,"p-toast-icon-close")||V.hasClass(v.target,"p-toast-icon-close-icon"))&&e.onClick(o.message)},le=function(v){e.onMouseEnter&&e.onMouseEnter(v),!v.defaultPrevented&&(w||(q(),j(!0)))},ce=function(v){e.onMouseLeave&&e.onMouseLeave(v),!v.defaultPrevented&&(w||j(!1))},ue=function(){var v=t({className:p("message.buttonicon")},C("buttonicon",u),m(i,"buttonicon",l(l({},f),{},{hostName:e.hostName}))),b=s||a.createElement(Re,v),I=Q.getJSXIcon(b,l({},v),{props:e}),z=t({type:"button",className:p("message.closeButton"),onClick:J,"aria-label":e.ariaCloseLabel||xe("close")},C("closeButton",u),m(i,"closeButton",l(l({},f),{},{hostName:e.hostName})));return B!==!1?a.createElement("div",null,a.createElement("button",z,I,a.createElement(Ne,null))):null},me=function(){if(o){var v=A.getJSXElement(H,{message:o.message,onClick:G,onClose:J}),b=t({className:p("message.icon")},C("icon",u),m(i,"icon",l(l({},f),{},{hostName:e.hostName}))),I=y;if(!y)switch(g){case"info":I=a.createElement(Me,b);break;case"warn":I=a.createElement(je,b);break;case"error":I=a.createElement(ke,b);break;case"success":I=a.createElement(Oe,b);break}var z=Q.getJSXIcon(I,l({},b),{props:e}),de=t({className:p("message.text")},C("text",u),m(i,"text",l(l({},f),{},{hostName:e.hostName}))),ge=t({className:p("message.summary")},C("summary",u),m(i,"summary",l(l({},f),{},{hostName:e.hostName}))),be=t({className:p("message.detail")},C("detail",u),m(i,"detail",l(l({},f),{},{hostName:e.hostName})));return v||a.createElement(a.Fragment,null,z,a.createElement("div",de,a.createElement("span",ge,T),O&&a.createElement("div",be,O)))}return null},pe=me(),fe=ue(),ve=t({ref:n,className:D(U,p("message.message",{severity:g})),style:Z,role:"alert","aria-live":"assertive","aria-atomic":"true",onClick:G,onMouseEnter:le,onMouseLeave:ce},C("message",u),m(i,"root",l(l({},f),{},{hostName:e.hostName}))),ye=t({className:D($,p("message.content")),style:X},C("content",u),m(i,"content",l(l({},f),{},{hostName:e.hostName})));return a.createElement("div",ve,a.createElement("div",ye,pe,fe))}));re.displayName="ToastMessage";var te=0,Ye=a.memo(a.forwardRef(function(e,n){var t=ne(),o=a.useContext(he),r=R.getProps(e,o),h=a.useState([]),x=W(h,2),m=x[0],p=x[1],d=a.useRef(null),c={props:r,state:{messages:m}},g=R.setMetaData(c);Ce(R.css.styles,g.isUnstyled,{name:"toast"});var H=function(s){s&&p(function(i){return T(i,s,!0)})},T=function(s,i,f){var u;if(Array.isArray(i)){var E=i.reduce(function(k,j){return k.push({_pId:te++,message:j}),k},[]);f?u=s?[].concat(Y(s),Y(E)):E:u=E}else{var N={_pId:te++,message:i};f?u=s?[].concat(Y(s),[N]):[N]:u=[N]}return u},O=function(){M.clear(d.current),p([])},B=function(s){p(function(i){return T(i,s,!1)})},P=function(s){var i=A.isNotEmpty(s._pId)?s._pId:s.message||s;p(function(f){return f.filter(function(u){return u._pId!==s._pId&&!A.deepEquals(u.message,i)})}),r.onRemove&&r.onRemove(s.message||i)},w=function(s){P(s)},U=function(){r.onShow&&r.onShow()},Z=function(){m.length===1&&M.clear(d.current),r.onHide&&r.onHide()};we(function(){M.set("toast",d.current,o&&o.autoZIndex||L.autoZIndex,r.baseZIndex||o&&o.zIndex.toast||L.zIndex.toast)},[m,r.baseZIndex]),_e(function(){M.clear(d.current)}),a.useImperativeHandle(n,function(){return{props:r,show:H,replace:B,remove:P,clear:O,getElement:function(){return d.current}}});var $=function(){var s=t({ref:d,id:r.id,className:g.cx("root",{context:o}),style:g.sx("root")},R.getOtherProps(r),g.ptm("root")),i=t({classNames:g.cx("transition"),timeout:{enter:300,exit:300},options:r.transitionOptions,unmountOnExit:!0,onEntered:U,onExited:Z},g.ptm("transition"));return a.createElement("div",s,a.createElement(Pe,null,m&&m.map(function(f,u){var E=a.createRef();return a.createElement(Se,F({nodeRef:E,key:f._pId},i),e.content?A.getJSXElement(e.content,{message:f.message}):a.createElement(re,{hostName:"Toast",ref:E,messageInfo:f,index:u,onClick:r.onClick,onClose:w,onMouseEnter:r.onMouseEnter,onMouseLeave:r.onMouseLeave,closeIcon:r.closeIcon,ptCallbacks:g,metaData:c}))})))},X=$();return a.createElement(Ie,{element:X,appendTo:r.appendTo})}));Ye.displayName="Toast";export{Ye as T};
//# sourceMappingURL=toast.esm-CYGIlaDH.js.map
