import{c as Ae,r,u as oe,j as n,B as Fe,P as j,V as se,a as je,b as W,d as P,e as _e,R as De,f as Le,g as Me,h as _,X as Oe,i as ke,k as Ve}from"./index-BMIwdYku.js";import{c as Ke,u as $e}from"./index-uCALUfYL.js";import{P as He}from"./index-BACa9A6_.js";var J="ToastProvider",[Q,We,Xe]=Ke("Toast"),[re,ft]=Ae("Toast",[Xe]),[Ue,X]=re(J),ne=e=>{const{__scopeToast:t,label:o="Notification",duration:s=5e3,swipeDirection:u="right",swipeThreshold:d=50,children:p}=e,[v,w]=r.useState(null),[a,b]=r.useState(0),E=r.useRef(!1),D=r.useRef(!1);return o.trim()||console.error(`Invalid prop \`label\` supplied to \`${J}\`. Expected non-empty \`string\`.`),n.jsx(Q.Provider,{scope:t,children:n.jsx(Ue,{scope:t,label:o,duration:s,swipeDirection:u,swipeThreshold:d,toastCount:a,viewport:v,onViewportChange:w,onToastAdd:r.useCallback(()=>b(R=>R+1),[]),onToastRemove:r.useCallback(()=>b(R=>R-1),[]),isFocusedToastEscapeKeyDownRef:E,isClosePausedRef:D,children:p})})};ne.displayName=J;var ae="ToastViewport",Ye=["F8"],q="toast.viewportPause",z="toast.viewportResume",ie=r.forwardRef((e,t)=>{const{__scopeToast:o,hotkey:s=Ye,label:u="Notifications ({hotkey})",...d}=e,p=X(ae,o),v=We(o),w=r.useRef(null),a=r.useRef(null),b=r.useRef(null),E=r.useRef(null),D=oe(t,E,p.onViewportChange),R=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=p.toastCount>0;r.useEffect(()=>{const c=y=>{var m;s.length!==0&&s.every(T=>y[T]||y.code===T)&&((m=E.current)==null||m.focus())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[s]),r.useEffect(()=>{const c=w.current,y=E.current;if(N&&c&&y){const f=()=>{if(!p.isClosePausedRef.current){const g=new CustomEvent(q);y.dispatchEvent(g),p.isClosePausedRef.current=!0}},m=()=>{if(p.isClosePausedRef.current){const g=new CustomEvent(z);y.dispatchEvent(g),p.isClosePausedRef.current=!1}},T=g=>{!c.contains(g.relatedTarget)&&m()},x=()=>{c.contains(document.activeElement)||m()};return c.addEventListener("focusin",f),c.addEventListener("focusout",T),c.addEventListener("pointermove",f),c.addEventListener("pointerleave",x),window.addEventListener("blur",f),window.addEventListener("focus",m),()=>{c.removeEventListener("focusin",f),c.removeEventListener("focusout",T),c.removeEventListener("pointermove",f),c.removeEventListener("pointerleave",x),window.removeEventListener("blur",f),window.removeEventListener("focus",m)}}},[N,p.isClosePausedRef]);const l=r.useCallback(({tabbingDirection:c})=>{const f=v().map(m=>{const T=m.ref.current,x=[T,...nt(T)];return c==="forwards"?x:x.reverse()});return(c==="forwards"?f.reverse():f).flat()},[v]);return r.useEffect(()=>{const c=E.current;if(c){const y=f=>{var x,g,S;const m=f.altKey||f.ctrlKey||f.metaKey;if(f.key==="Tab"&&!m){const L=document.activeElement,A=f.shiftKey;if(f.target===c&&A){(x=a.current)==null||x.focus();return}const I=l({tabbingDirection:A?"backwards":"forwards"}),V=I.findIndex(i=>i===L);B(I.slice(V+1))?f.preventDefault():A?(g=a.current)==null||g.focus():(S=b.current)==null||S.focus()}};return c.addEventListener("keydown",y),()=>c.removeEventListener("keydown",y)}},[v,l]),n.jsxs(Fe,{ref:w,role:"region","aria-label":u.replace("{hotkey}",R),tabIndex:-1,style:{pointerEvents:N?void 0:"none"},children:[N&&n.jsx(G,{ref:a,onFocusFromOutsideViewport:()=>{const c=l({tabbingDirection:"forwards"});B(c)}}),n.jsx(Q.Slot,{scope:o,children:n.jsx(j.ol,{tabIndex:-1,...d,ref:D})}),N&&n.jsx(G,{ref:b,onFocusFromOutsideViewport:()=>{const c=l({tabbingDirection:"backwards"});B(c)}})]})});ie.displayName=ae;var ce="ToastFocusProxy",G=r.forwardRef((e,t)=>{const{__scopeToast:o,onFocusFromOutsideViewport:s,...u}=e,d=X(ce,o);return n.jsx(se,{"aria-hidden":!0,tabIndex:0,...u,ref:t,style:{position:"fixed"},onFocus:p=>{var a;const v=p.relatedTarget;!((a=d.viewport)!=null&&a.contains(v))&&s()}})});G.displayName=ce;var k="Toast",Be="toast.swipeStart",qe="toast.swipeMove",ze="toast.swipeCancel",Ge="toast.swipeEnd",ue=r.forwardRef((e,t)=>{const{forceMount:o,open:s,defaultOpen:u,onOpenChange:d,...p}=e,[v,w]=$e({prop:s,defaultProp:u??!0,onChange:d,caller:k});return n.jsx(je,{present:o||v,children:n.jsx(Ze,{open:v,...p,ref:t,onClose:()=>w(!1),onPause:W(e.onPause),onResume:W(e.onResume),onSwipeStart:P(e.onSwipeStart,a=>{a.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:P(e.onSwipeMove,a=>{const{x:b,y:E}=a.detail.delta;a.currentTarget.setAttribute("data-swipe","move"),a.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${b}px`),a.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${E}px`)}),onSwipeCancel:P(e.onSwipeCancel,a=>{a.currentTarget.setAttribute("data-swipe","cancel"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),a.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:P(e.onSwipeEnd,a=>{const{x:b,y:E}=a.detail.delta;a.currentTarget.setAttribute("data-swipe","end"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),a.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${b}px`),a.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${E}px`),w(!1)})})})});ue.displayName=k;var[Je,Qe]=re(k,{onClose(){}}),Ze=r.forwardRef((e,t)=>{const{__scopeToast:o,type:s="foreground",duration:u,open:d,onClose:p,onEscapeKeyDown:v,onPause:w,onResume:a,onSwipeStart:b,onSwipeMove:E,onSwipeCancel:D,onSwipeEnd:R,...N}=e,l=X(k,o),[c,y]=r.useState(null),f=oe(t,i=>y(i)),m=r.useRef(null),T=r.useRef(null),x=u||l.duration,g=r.useRef(0),S=r.useRef(x),L=r.useRef(0),{onToastAdd:A,onToastRemove:U}=l,F=W(()=>{var h;(c==null?void 0:c.contains(document.activeElement))&&((h=l.viewport)==null||h.focus()),p()}),I=r.useCallback(i=>{!i||i===1/0||(window.clearTimeout(L.current),g.current=new Date().getTime(),L.current=window.setTimeout(F,i))},[F]);r.useEffect(()=>{const i=l.viewport;if(i){const h=()=>{I(S.current),a==null||a()},C=()=>{const M=new Date().getTime()-g.current;S.current=S.current-M,window.clearTimeout(L.current),w==null||w()};return i.addEventListener(q,C),i.addEventListener(z,h),()=>{i.removeEventListener(q,C),i.removeEventListener(z,h)}}},[l.viewport,x,w,a,I]),r.useEffect(()=>{d&&!l.isClosePausedRef.current&&I(x)},[d,x,l.isClosePausedRef,I]),r.useEffect(()=>(A(),()=>U()),[A,U]);const V=r.useMemo(()=>c?we(c):null,[c]);return l.viewport?n.jsxs(n.Fragment,{children:[V&&n.jsx(et,{__scopeToast:o,role:"status","aria-live":s==="foreground"?"assertive":"polite","aria-atomic":!0,children:V}),n.jsx(Je,{scope:o,onClose:F,children:_e.createPortal(n.jsx(Q.ItemSlot,{scope:o,children:n.jsx(De,{asChild:!0,onEscapeKeyDown:P(v,()=>{l.isFocusedToastEscapeKeyDownRef.current||F(),l.isFocusedToastEscapeKeyDownRef.current=!1}),children:n.jsx(j.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":d?"open":"closed","data-swipe-direction":l.swipeDirection,...N,ref:f,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:P(e.onKeyDown,i=>{i.key==="Escape"&&(v==null||v(i.nativeEvent),i.nativeEvent.defaultPrevented||(l.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:P(e.onPointerDown,i=>{i.button===0&&(m.current={x:i.clientX,y:i.clientY})}),onPointerMove:P(e.onPointerMove,i=>{if(!m.current)return;const h=i.clientX-m.current.x,C=i.clientY-m.current.y,M=!!T.current,O=["left","right"].includes(l.swipeDirection),K=["left","up"].includes(l.swipeDirection)?Math.min:Math.max,Se=O?K(0,h):0,Ie=O?0:K(0,C),Y=i.pointerType==="touch"?10:2,$={x:Se,y:Ie},ee={originalEvent:i,delta:$};M?(T.current=$,H(qe,E,ee,{discrete:!1})):te($,l.swipeDirection,Y)?(T.current=$,H(Be,b,ee,{discrete:!1}),i.target.setPointerCapture(i.pointerId)):(Math.abs(h)>Y||Math.abs(C)>Y)&&(m.current=null)}),onPointerUp:P(e.onPointerUp,i=>{const h=T.current,C=i.target;if(C.hasPointerCapture(i.pointerId)&&C.releasePointerCapture(i.pointerId),T.current=null,m.current=null,h){const M=i.currentTarget,O={originalEvent:i,delta:h};te(h,l.swipeDirection,l.swipeThreshold)?H(Ge,R,O,{discrete:!0}):H(ze,D,O,{discrete:!0}),M.addEventListener("click",K=>K.preventDefault(),{once:!0})}})})})}),l.viewport)})]}):null}),et=e=>{const{__scopeToast:t,children:o,...s}=e,u=X(k,t),[d,p]=r.useState(!1),[v,w]=r.useState(!1);return st(()=>p(!0)),r.useEffect(()=>{const a=window.setTimeout(()=>w(!0),1e3);return()=>window.clearTimeout(a)},[]),v?null:n.jsx(He,{asChild:!0,children:n.jsx(se,{...s,children:d&&n.jsxs(n.Fragment,{children:[u.label," ",o]})})})},tt="ToastTitle",de=r.forwardRef((e,t)=>{const{__scopeToast:o,...s}=e;return n.jsx(j.div,{...s,ref:t})});de.displayName=tt;var ot="ToastDescription",le=r.forwardRef((e,t)=>{const{__scopeToast:o,...s}=e;return n.jsx(j.div,{...s,ref:t})});le.displayName=ot;var pe="ToastAction",fe=r.forwardRef((e,t)=>{const{altText:o,...s}=e;return o.trim()?n.jsx(ve,{altText:o,asChild:!0,children:n.jsx(Z,{...s,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${pe}\`. Expected non-empty \`string\`.`),null)});fe.displayName=pe;var me="ToastClose",Z=r.forwardRef((e,t)=>{const{__scopeToast:o,...s}=e,u=Qe(me,o);return n.jsx(ve,{asChild:!0,children:n.jsx(j.button,{type:"button",...s,ref:t,onClick:P(e.onClick,u.onClose)})})});Z.displayName=me;var ve=r.forwardRef((e,t)=>{const{__scopeToast:o,altText:s,...u}=e;return n.jsx(j.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":s||void 0,...u,ref:t})});function we(e){const t=[];return Array.from(e.childNodes).forEach(s=>{if(s.nodeType===s.TEXT_NODE&&s.textContent&&t.push(s.textContent),rt(s)){const u=s.ariaHidden||s.hidden||s.style.display==="none",d=s.dataset.radixToastAnnounceExclude==="";if(!u)if(d){const p=s.dataset.radixToastAnnounceAlt;p&&t.push(p)}else t.push(...we(s))}}),t}function H(e,t,o,{discrete:s}){const u=o.originalEvent.currentTarget,d=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:o});t&&u.addEventListener(e,t,{once:!0}),s?Me(u,d):u.dispatchEvent(d)}var te=(e,t,o=0)=>{const s=Math.abs(e.x),u=Math.abs(e.y),d=s>u;return t==="left"||t==="right"?d&&s>o:!d&&u>o};function st(e=()=>{}){const t=W(e);Le(()=>{let o=0,s=0;return o=window.requestAnimationFrame(()=>s=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(o),window.cancelAnimationFrame(s)}},[t])}function rt(e){return e.nodeType===e.ELEMENT_NODE}function nt(e){const t=[],o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const u=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||u?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;o.nextNode();)t.push(o.currentNode);return t}function B(e){const t=document.activeElement;return e.some(o=>o===t?!0:(o.focus(),document.activeElement!==t))}var at=ne,Te=ie,xe=ue,Ee=de,ye=le,ge=fe,he=Z;const it=at,be=r.forwardRef(({className:e,...t},o)=>n.jsx(Te,{ref:o,className:_("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));be.displayName=Te.displayName;const ct=ke("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"}}),Pe=r.forwardRef(({className:e,variant:t,...o},s)=>n.jsx(xe,{ref:s,className:_(ct({variant:t}),e),...o}));Pe.displayName=xe.displayName;const ut=r.forwardRef(({className:e,...t},o)=>n.jsx(ge,{ref:o,className:_("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));ut.displayName=ge.displayName;const Ce=r.forwardRef(({className:e,...t},o)=>n.jsx(he,{ref:o,className:_("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsx(Oe,{className:"h-4 w-4"})}));Ce.displayName=he.displayName;const Re=r.forwardRef(({className:e,...t},o)=>n.jsx(Ee,{ref:o,className:_("text-sm font-semibold",e),...t}));Re.displayName=Ee.displayName;const Ne=r.forwardRef(({className:e,...t},o)=>n.jsx(ye,{ref:o,className:_("text-sm opacity-90",e),...t}));Ne.displayName=ye.displayName;function mt(){const{toasts:e}=Ve();return n.jsxs(it,{children:[e.map(function({id:t,title:o,description:s,action:u,...d}){return n.jsxs(Pe,{...d,children:[n.jsxs("div",{className:"grid gap-1",children:[o&&n.jsx(Re,{children:o}),s&&n.jsx(Ne,{children:s})]}),u,n.jsx(Ce,{})]},t)}),n.jsx(be,{})]})}export{mt as Toaster};