import{k as K,X as W,aF as M,G as k,_ as Q,d as q,bE as X,n as g,bF as z,L as Y,q as J,s as C,o as p,w as I,v as H,x as h,O as N,Y as P,Q as x,P as R,c as $,F as ee,z as A,y as te,T as oe,bg as ne,af as w,aK as _,A as se,Z as D,B as ie,an as ae,bH as O,bI as le}from"./index-BXlk60bP.js";import{a7 as re,g as V,$ as a,n as v,a1 as Z,d as B,i as ce}from"./common-vYHpopNV.js";const G=["success","info","warning","error"],ue=K({customClass:{type:String,default:""},dangerouslyUseHTMLString:Boolean,duration:{type:Number,default:4500},icon:{type:M},id:{type:String,default:""},message:{type:k([String,Object,Function]),default:""},offset:{type:Number,default:0},onClick:{type:k(Function),default:()=>{}},onClose:{type:k(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:[...G,""],default:""},zIndex:Number,closeIcon:{type:M,default:W}}),fe={destroy:()=>!0},de=q({name:"ElNotification"}),pe=q({...de,props:ue,emits:fe,setup(t,{expose:s}){const o=t,{ns:n,zIndex:c}=X("notification"),{nextZIndex:d,currentZIndex:u}=c,i=re(!1);let r;const l=g(()=>{const e=o.type;return e&&z[o.type]?n.m(e):""}),f=g(()=>o.type&&z[o.type]||o.icon),m=g(()=>o.position.endsWith("right")?"right":"left"),E=g(()=>o.position.startsWith("top")?"top":"bottom"),U=g(()=>{var e;return{[E.value]:`${o.offset}px`,zIndex:(e=o.zIndex)!=null?e:u.value}});function S(){o.duration>0&&({stop:r}=ne(()=>{i.value&&b()},o.duration))}function L(){r==null||r()}function b(){i.value=!1}function j({code:e}){e===w.delete||e===w.backspace?L():e===w.esc?i.value&&b():S()}return Y(()=>{S(),d(),i.value=!0}),J(document,"keydown",j),s({visible:i,close:b}),(e,Ce)=>(p(),C(oe,{name:a(n).b("fade"),onBeforeLeave:e.onClose,onAfterLeave:he=>e.$emit("destroy"),persisted:""},{default:I(()=>[H(h("div",{id:e.id,class:v([a(n).b(),e.customClass,a(m)]),style:V(a(U)),role:"alert",onMouseenter:L,onMouseleave:S,onClick:e.onClick},[a(f)?(p(),C(a(P),{key:0,class:v([a(n).e("icon"),a(l)])},{default:I(()=>[(p(),C(x(a(f))))]),_:1},8,["class"])):N("v-if",!0),h("div",{class:v(a(n).e("group"))},[h("h2",{class:v(a(n).e("title")),textContent:Z(e.title)},null,10,["textContent"]),H(h("div",{class:v(a(n).e("content")),style:V(e.title?void 0:{margin:0})},[R(e.$slots,"default",{},()=>[e.dangerouslyUseHTMLString?(p(),$(ee,{key:1},[N(" Caution here, message could've been compromised, never use user's input as message "),h("p",{innerHTML:e.message},null,8,["innerHTML"])],2112)):(p(),$("p",{key:0},Z(e.message),1))])],6),[[A,e.message]]),e.showClose?(p(),C(a(P),{key:0,class:v(a(n).e("closeBtn")),onClick:te(b,["stop"])},{default:I(()=>[(p(),C(x(e.closeIcon)))]),_:1},8,["class","onClick"])):N("v-if",!0)],2)],46,["id","onClick"]),[[A,i.value]])]),_:3},8,["name","onBeforeLeave","onAfterLeave"]))}});var me=Q(pe,[["__file","notification.vue"]]);const T={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[]},F=16;let ve=1;const y=function(t={},s){if(!se)return{close:()=>{}};(B(t)||_(t))&&(t={message:t});const o=t.position||"top-right";let n=t.offset||0;T[o].forEach(({vm:f})=>{var m;n+=(((m=f.el)==null?void 0:m.offsetHeight)||0)+F}),n+=F;const c=`notification_${ve++}`,d=t.onClose,u={...t,offset:n,id:c,onClose:()=>{ye(c,o,d)}};let i=document.body;D(t.appendTo)?i=t.appendTo:B(t.appendTo)&&(i=document.querySelector(t.appendTo)),D(i)||(i=document.body);const r=document.createElement("div"),l=ie(me,u,ce(u.message)?u.message:_(u.message)?()=>u.message:null);return l.appContext=ae(s)?y._context:s,l.props.onDestroy=()=>{O(null,r)},O(l,r),T[o].push({vm:l}),i.appendChild(r.firstElementChild),{close:()=>{l.component.exposed.visible.value=!1}}};G.forEach(t=>{y[t]=(s={},o)=>((B(s)||_(s))&&(s={message:s}),y({...s,type:t},o))});function ye(t,s,o){const n=T[s],c=n.findIndex(({vm:l})=>{var f;return((f=l.component)==null?void 0:f.props.id)===t});if(c===-1)return;const{vm:d}=n[c];if(!d)return;o==null||o(d);const u=d.el.offsetHeight,i=s.split("-")[0];n.splice(c,1);const r=n.length;if(!(r<1))for(let l=c;l<r;l++){const{el:f,component:m}=n[l].vm,E=Number.parseInt(f.style[i],10)-u-F;m.props.offset=E}}function ge(){for(const t of Object.values(T))t.forEach(({vm:s})=>{s.component.exposed.visible.value=!1})}y.closeAll=ge;y._context=null;const Ee=le(y,"$notify");export{Ee as E};
