import{shallowRef as R,createVNode as g,defineComponent as k,computed as O}from"vue";import P from"@ant-design/icons-vue/CloseOutlined";import N from"../_util/classNames.mjs";import{wrapPromiseFn as F}from"../_util/util.mjs";import b from"../config-provider/hooks/useConfigInject.mjs";import"../vc-notification/Notification.mjs";import w from"../vc-notification/useNotification.mjs";import{getMotion as D}from"../vc-trigger/utils/motionUtil.mjs";import{PureContent as E}from"./PurePanel.mjs";import M from"./style/index.mjs";const S=8,T=3,H=k({name:"Holder",inheritAttrs:!1,props:["top","prefixCls","getContainer","maxCount","duration","rtl","transitionName","onAllRemoved","animation","staticGetContainer"],setup(e,{expose:s}){const{getPrefixCls:C,getPopupContainer:u}=b("message",e),o=O(()=>C("message",e.prefixCls)),[,y]=M(o),d=()=>{const r=e.top??S;return{left:"50%",transform:"translateX(-50%)",top:typeof r=="number"?`${r}px`:r}},v=()=>N(y.value,e.rtl?`${o.value}-rtl`:""),t=()=>D({prefixCls:o.value,animation:e.animation??"move-up",transitionName:e.transitionName}),f=g("span",{class:`${o.value}-close-x`},[g(P,{class:`${o.value}-close-icon`},null)]),[n,l]=w({getStyles:d,prefixCls:o.value,getClassName:v,motion:t,closable:!1,closeIcon:f,duration:e.duration??T,getContainer:e.staticGetContainer??u.value,maxCount:e.maxCount,onAllRemoved:e.onAllRemoved});return s({...n,prefixCls:o,hashId:y}),l}});let h=0;function K(e){const s=R(null),C=Symbol("messageHolderKey"),u=t=>{s.value?.close(t)},o=t=>{if(!s.value){const p=()=>{};return p.then=()=>{},p}const{open:f,prefixCls:n,hashId:l}=s.value,r=`${n}-notice`,{content:a,icon:c,type:i,key:x,class:I,onClose:A,...$}=t;let m=x;return m==null&&(h+=1,m=`antd-message-${h}`),F(p=>(f({...$,key:m,content:()=>g(E,{prefixCls:n,type:i,icon:typeof c=="function"?c():c},{default:()=>[typeof a=="function"?a():a]}),placement:"top",class:N(i&&`${r}-${i}`,l,I),onClose:()=>{A?.(),p()}}),()=>{u(m)}))},d={open:o,destroy:t=>{t!==void 0?u(t):s.value?.destroy()}};return["info","success","warning","error","loading"].forEach(t=>{const f=(n,l,r)=>{let a;n&&typeof n=="object"&&"content"in n?a=n:a={content:n};let c,i;typeof l=="function"?i=l:(c=l,i=r);const x={onClose:i,duration:c,...a,type:t};return o(x)};d[t]=f}),[d,()=>g(H,{key:C,...e,ref:s},null)]}function Q(e){return K(e)}export{Q as default,K as useInternalMessage};
