import{A as c,a9 as T}from"./index-c4393848.js";import{r as f,m,D as S,o as v,i as A,g as O,J as _,M as D,u as d}from"./app-a39c937f.js";import{c as w}from"./index-70cab76c.js";import{c as E}from"./utils-836e31d3.js";const g=1,M=1e6,o={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"};let u=0;function y(){return u=(u+1)%Number.MAX_VALUE,u.toString()}const p=new Map;function l(e){if(p.has(e))return;const t=setTimeout(()=>{p.delete(e),r({type:o.REMOVE_TOAST,toastId:e})},M);p.set(e,t)}const s=f({toasts:[]});function r(e){switch(e.type){case o.ADD_TOAST:s.value.toasts=[e.toast,...s.value.toasts].slice(0,g);break;case o.UPDATE_TOAST:s.value.toasts=s.value.toasts.map(t=>t.id===e.toast.id?{...t,...e.toast}:t);break;case o.DISMISS_TOAST:{const{toastId:t}=e;t?l(t):s.value.toasts.forEach(a=>{l(a.id)}),s.value.toasts=s.value.toasts.map(a=>a.id===t||t===void 0?{...a,open:!1}:a);break}case o.REMOVE_TOAST:e.toastId===void 0?s.value.toasts=[]:s.value.toasts=s.value.toasts.filter(t=>t.id!==e.toastId);break}}function U(){return{toasts:m(()=>s.value.toasts),toast:I,dismiss:e=>r({type:o.DISMISS_TOAST,toastId:e})}}function I(e){const t=y(),a=n=>r({type:o.UPDATE_TOAST,toast:{...n,id:t}}),i=()=>r({type:o.DISMISS_TOAST,toastId:t});return r({type:o.ADD_TOAST,toast:{...e,id:t,open:!0,onOpenChange:n=>{n||i()}}}),{id:t,dismiss:i,update:a}}const b=w("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),B=S({__name:"Toast",props:{class:{},variant:{},onOpenChange:{type:Function},defaultOpen:{type:Boolean},forceMount:{type:Boolean},type:{},open:{type:Boolean},duration:{},asChild:{type:Boolean},as:{}},emits:["escapeKeyDown","pause","resume","swipeStart","swipeMove","swipeCancel","swipeEnd","update:open"],setup(e,{emit:t}){const a=e,i=t;return(n,h)=>(v(),A(d(T),D({...a,...d(c)(i)},{class:d(E)(d(b)({variant:a.variant}),a.class),"onUpdate:open":n.onOpenChange}),{default:O(()=>[_(n.$slots,"default")]),_:3},16,["class","onUpdate:open"]))}});export{B as _,U as u};
