import{a as e,i as t,n,t as r}from"./jsx-runtime-CutOxEx1.js";import{n as i,t as a}from"./notifications-BrcI-_N-.js";var o=t({default:()=>m}),s=e(n(),1),c=r(),l=null,u=new Set,d=()=>u.forEach(e=>{try{e()}catch{}}),f=e=>{l===null&&(l=e,d())},p=e=>{l===e&&(l=null,d(),d())};function m({onNavigate:e}){let[t,n]=(0,s.useState)([]),r=(0,s.useRef)(Symbol(`toast-host`)),[o,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=r.current,t=()=>{f(e),d(l===e)};return u.add(t),t(),()=>{u.delete(t),p(e)}},[]),(0,s.useEffect)(()=>{if(!o)return;let e=e=>{let t=e?.detail;if(!t?.title)return;let r=`${String(t.key||`toast`).trim()}:${Date.now()}`,i={...t,id:r};n(e=>[...e.filter(e=>e.key!==t.key),i].slice(-3));let a=Math.max(1500,Number(t.ttlMs||3200)||3200);window.setTimeout(()=>{n(e=>e.filter(e=>e.id!==r))},a)};return window.addEventListener(a,e),window.setTimeout(i,0),()=>window.removeEventListener(a,e)},[o]);let m=(0,s.useMemo)(()=>t.slice(-3),[t]),h=(0,s.useMemo)(()=>m.filter(e=>e.placement!==`bottom-right`),[m]),g=(0,s.useMemo)(()=>m.filter(e=>e.placement===`bottom-right`),[m]);if(!o||!m.length)return null;let _=t=>t.map(t=>{let r=!!t.path&&!!e;return(0,c.jsxs)(`button`,{type:`button`,onClick:()=>{r&&(e?.(String(t.path||``)),n(e=>e.filter(e=>e.id!==t.id)))},className:`pointer-events-auto rounded-2xl border px-4 py-3 text-left shadow-sm transition-colors`,style:{borderColor:`var(--border)`,background:`var(--surface)`,color:`var(--text-1)`,cursor:r?`pointer`:`default`},children:[(0,c.jsx)(`div`,{className:`text-sm font-semibold`,children:t.title}),t.description?(0,c.jsx)(`div`,{className:`mt-1 text-xs leading-5`,style:{color:`var(--text-2)`},children:t.description}):null]},t.id)});return(0,c.jsxs)(c.Fragment,{children:[h.length?(0,c.jsx)(`div`,{className:`pointer-events-none fixed right-4 top-4 z-[120] flex w-[min(360px,calc(100vw-24px))] flex-col gap-2`,children:_(h)}):null,g.length?(0,c.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-[120] flex w-[min(360px,calc(100vw-24px))] flex-col gap-2`,children:_(g)}):null]})}export{o as n,m as t};