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