import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{n as r,t as i}from"./notifications-DlOY8IMT.js";var a=e(t(),1),o=n(),s=null,c=new Set,l=()=>c.forEach(e=>{try{e()}catch{}}),u=e=>{s===null&&(s=e,l())},d=e=>{s===e&&(s=null,l(),l())};function f({onNavigate:e}){let[t,n]=(0,a.useState)([]),l=(0,a.useRef)(Symbol(`toast-host`)),[f,p]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=l.current,t=()=>{u(e),p(s===e)};return c.add(t),t(),()=>{c.delete(t),d(e)}},[]),(0,a.useEffect)(()=>{if(!f)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(i,e),window.setTimeout(r,0),()=>window.removeEventListener(i,e)},[f]);let m=(0,a.useMemo)(()=>t.slice(-3),[t]),h=(0,a.useMemo)(()=>m.filter(e=>e.placement!==`bottom-right`),[m]),g=(0,a.useMemo)(()=>m.filter(e=>e.placement===`bottom-right`),[m]);if(!f||!m.length)return null;let _=t=>t.map(t=>{let r=!!t.path&&!!e;return(0,o.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,o.jsx)(`div`,{className:`text-sm font-semibold`,children:t.title}),t.description?(0,o.jsx)(`div`,{className:`mt-1 text-xs leading-5`,style:{color:`var(--text-2)`},children:t.description}):null]},t.id)});return(0,o.jsxs)(o.Fragment,{children:[h.length?(0,o.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,o.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{f as t};