import{C as e,K as t,L as n,Q as r,Qt as i,S as a,St as o,T as s,Ut as c,Y as l,cn as u,dt as d,f,ft as p,g as m,in as h,j as g,k as _,kt as v,m as y,n as b,nn as x,o as S,tt as C,w,x as T,zt as E}from"./vue.runtime.esm-bundler-DpGzKKN4.js";import{C as D,J as O,M as k,V as A,X as j,b as M,c as N,et as P,y as F}from"./style-DGCNsUJ6.js";import{B as I,H as L,Ot as R,Vt as z,f as B,jt as V,l as H,rt as U}from"./vnode-DU8g6Rf7.js";var W=[`primary`,`success`,`info`,`warning`,`error`],G=F({customClass:{type:String,default:``},dangerouslyUseHTMLString:Boolean,duration:{type:Number,default:4500},icon:{type:L},id:{type:String,default:``},message:{type:M([String,Object,Function]),default:``},offset:{type:Number,default:0},onClick:{type:M(Function),default:()=>void 0},onClose:{type:M(Function),required:!0},position:{type:String,values:[`top-right`,`top-left`,`bottom-right`,`bottom-left`],default:`top-right`},showClose:{type:Boolean,default:!0},title:{type:String,default:``},type:{type:String,values:[...W,``],default:``},zIndex:Number,closeIcon:{type:L,default:U}}),K={destroy:()=>!0},q=z(g({...g({name:`ElNotification`}),props:G,emits:K,setup(n,{expose:i}){let c=n,{ns:g,zIndex:_}=N(`notification`),{nextZIndex:S,currentZIndex:E}=_,D=o(!1),A,j=T(()=>{let e=c.type;return e&&I[c.type]?g.m(e):``}),M=T(()=>c.type&&I[c.type]||c.icon),P=T(()=>c.position.endsWith(`right`)?`right`:`left`),F=T(()=>c.position.startsWith(`top`)?`top`:`bottom`),L=T(()=>({[F.value]:`${c.offset}px`,zIndex:c.zIndex??E.value}));function z(){c.duration>0&&({stop:A}=O(()=>{D.value&&U()},c.duration))}function V(){A?.()}function U(){D.value=!1}function W(e){switch(H(e)){case B.delete:case B.backspace:V();break;case B.esc:D.value&&U();break;default:z();break}}return t(()=>{z(),S(),D.value=!0}),k(document,`keydown`,W),i({visible:D,close:U}),(t,n)=>(l(),e(b,{name:v(g).b(`fade`),onBeforeLeave:t.onClose,onAfterLeave:e=>t.$emit(`destroy`),persisted:``},{default:d(()=>[p(a(`div`,{id:t.id,class:x([v(g).b(),t.customClass,v(P)]),style:h(v(L)),role:`alert`,onMouseenter:V,onMouseleave:z,onClick:t.onClick},[v(M)?(l(),e(v(R),{key:0,class:x([v(g).e(`icon`),v(j)])},{default:d(()=>[(l(),e(C(v(M))))]),_:1},8,[`class`])):w(`v-if`,!0),a(`div`,{class:x(v(g).e(`group`))},[a(`h2`,{class:x(v(g).e(`title`)),textContent:u(t.title)},null,10,[`textContent`]),p(a(`div`,{class:x(v(g).e(`content`)),style:h(t.title?void 0:{margin:0})},[r(t.$slots,`default`,{},()=>[t.dangerouslyUseHTMLString?(l(),s(m,{key:1},[w(` Caution here, message could've been compromised, never use user's input as message `),a(`p`,{innerHTML:t.message},null,8,[`innerHTML`])],2112)):(l(),s(`p`,{key:0},u(t.message),1))])],6),[[f,t.message]]),t.showClose?(l(),e(v(R),{key:0,class:x(v(g).e(`closeBtn`)),onClick:y(U,[`stop`])},{default:d(()=>[(l(),e(C(t.closeIcon)))]),_:1},8,[`class`,`onClick`])):w(`v-if`,!0)],2)],46,[`id`,`onClick`]),[[f,D.value]])]),_:3},8,[`name`,`onBeforeLeave`,`onAfterLeave`]))}}),[[`__file`,`notification.vue`]]);E();var J={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[]},Y=16,X=1,Z=function(e={},t){if(!A)return{close:()=>void 0};(i(e)||n(e))&&(e={message:e});let r=e.position||`top-right`,a=e.offset||0;J[r].forEach(({vm:e})=>{a+=(e.el?.offsetHeight||0)+Y}),a+=Y;let o=`notification_${X++}`,s=e.onClose,l={...e,offset:a,id:o,onClose:()=>{Q(o,r,s)}},u=document.body;j(e.appendTo)?u=e.appendTo:i(e.appendTo)&&(u=document.querySelector(e.appendTo)),j(u)||(D(`ElNotification`,`the appendTo option is not an HTMLElement. Falling back to document.body.`),u=document.body);let d=document.createElement(`div`),f=_(q,l,c(l.message)?l.message:n(l.message)?()=>l.message:null);return f.appContext=P(t)?Z._context:t,f.props.onDestroy=()=>{S(null,d)},S(f,d),J[r].push({vm:f}),u.appendChild(d.firstElementChild),{close:()=>{f.component.exposed.visible.value=!1}}};W.forEach(e=>{Z[e]=(t={},r)=>((i(t)||n(t))&&(t={message:t}),Z({...t,type:e},r))});function Q(e,t,n){let r=J[t],i=r.findIndex(({vm:t})=>t.component?.props.id===e);if(i===-1)return;let{vm:a}=r[i];if(!a)return;n?.(a);let o=a.el.offsetHeight,s=t.split(`-`)[0];r.splice(i,1);let c=r.length;if(!(c<1))for(let e=i;e<c;e++){let{el:t,component:n}=r[e].vm,i=Number.parseInt(t.style[s],10)-o-Y;n.props.offset=i}}function $(){for(let e of Object.values(J))e.forEach(({vm:e})=>{e.component.exposed.visible.value=!1})}function ee(e=`top-right`){let t=J[e][0]?.vm.component?.props?.offset||0;for(let{vm:n}of J[e])n.component.props.offset=t,t+=(n.el?.offsetHeight||0)+Y}Z.closeAll=$,Z.updateOffsets=ee,Z._context=null;var te=V(Z,`$notify`);export{te as t};