import{L as B,R as y,ak as p,N as k,aF as z,O as L,Z as v,o as M,q as N,e as s,m as b,aA as j,P as U,I as V,aG as q,V as h,au as F,aH as H,av as A,r as D,aw as G,aI as R}from"./index-BDh_pN-M.js";import{L as Z}from"./index-Bg8xNGen.js";let m=0;function _(e){e?(m||document.body.classList.add("van-toast--unclickable"),m++):m&&(m--,m||document.body.classList.remove("van-toast--unclickable"))}const[E,i]=L("toast"),J=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],K={icon:String,show:Boolean,type:k("text"),overlay:Boolean,message:y,iconSize:y,duration:z(2e3),position:k("middle"),teleport:[String,Object],wordBreak:String,className:p,iconPrefix:String,transition:k("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:p,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:y};var Q=B({name:E,props:K,emits:["update:show"],setup(e,{emit:t,slots:a}){let c,r=!1;const d=()=>{const o=e.show&&e.forbidClick;r!==o&&(r=o,_(r))},u=o=>t("update:show",o),g=()=>{e.closeOnClick&&u(!1)},f=()=>clearTimeout(c),P=()=>{const{icon:o,type:n,iconSize:C,iconPrefix:I,loadingType:T}=e;if(o||n==="success"||n==="fail")return s(V,{name:o||n,size:C,class:i("icon"),classPrefix:I},null);if(n==="loading")return s(Z,{class:i("loading"),size:C,type:T},null)},x=()=>{const{type:o,message:n}=e;if(a.message)return s("div",{class:i("text")},[a.message()]);if(q(n)&&n!=="")return o==="html"?s("div",{key:0,class:i("text"),innerHTML:String(n)},null):s("div",{class:i("text")},[n])};return v(()=>[e.show,e.forbidClick],d),v(()=>[e.show,e.type,e.message,e.duration],()=>{f(),e.show&&e.duration>0&&(c=setTimeout(()=>{u(!1)},e.duration))}),M(d),N(d),()=>s(U,b({class:[i([e.position,e.wordBreak==="normal"?"break-normal":e.wordBreak,{[e.type]:!e.icon}]),e.className],lockScroll:!1,onClick:g,onClosed:f,"onUpdate:show":u},j(e,J)),{default:()=>[P(),x()]})}});const W={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let l=[],X=!1,O=h({},W);const Y=new Map;function S(e){return H(e)?e:{message:e}}function $(){const{instance:e}=A({setup(){const t=D(""),{open:a,state:c,close:r,toggle:d}=G(),u=()=>{},g=()=>s(Q,b(c,{onClosed:u,"onUpdate:show":d}),null);return v(t,f=>{c.message=f}),R().render=g,{open:a,close:r,message:t}}});return e}function ee(){if(!l.length||X){const e=$();l.push(e)}return l[l.length-1]}function te(e={}){if(!F)return{};const t=ee(),a=S(e);return t.open(h({},O,Y.get(a.type||O.type),a)),t}const w=e=>t=>te(h({type:e},S(t))),se=w("loading"),ie=w("success"),le=w("fail"),ce=e=>{l.length&&l[0].close()};export{ie as a,le as b,se as c,ce as d,Q as e,te as s};
