import{j as t}from"./jsx-runtime.D_zvdyIk.js";import{u as x}from"./useRetimer.BHB_FC9c.js";import{I as f}from"./iconify.pctX9hd_.js";import{u as m}from"./index.RTTH55m1.js";import{e as p,f as h,b,o as k,d as g}from"./announcement.BEAU5c3r.js";import{r as l}from"./index.BIRwh3HZ.js";import{t as d}from"./index.D6gWSuiN.js";const j=1e3,u={info:{color:"#3b82f6",icon:"ri:information-line"},warning:{color:"#eab308",icon:"ri:alert-line"},success:{color:"#22c55e",icon:"ri:checkbox-circle-line"},important:{color:"#ef4444",icon:"ri:error-warning-line"}};function y(e){if(e.color)return e.color;const o=e.type??"info";return u[o]?.color??u.info.color}function v(e){const o=e.type??"info";return u[o]?.icon??u.info.icon}function w({announcement:e}){const o=y(e),s=v(e);return t.jsxs("div",{className:"flex w-full flex-col gap-2 border-l-4 pl-3",style:{borderLeftColor:o},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(f,{icon:s,className:"h-4 w-4 shrink-0 opacity-70"}),t.jsx("span",{className:"font-semibold text-sm",children:e.title})]}),t.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:e.content}),e.link&&t.jsxs("a",{href:e.link.url,target:e.link.external?"_blank":void 0,rel:e.link.external?"noopener noreferrer":void 0,className:"inline-flex items-center gap-1 text-primary text-sm hover:underline",children:[e.link.text??"Learn more",e.link.external&&t.jsx(f,{icon:"ri:external-link-line",className:"h-3 w-3"})]})]})}function E({announcement:e,toastId:o}){const[s,i]=l.useState(!1),n=x(),r=()=>{i(!0),n(setTimeout(()=>g(e.id),j))},c=()=>{i(!1),n(null)};return t.jsxs("output",{className:`block w-full min-w-50 rounded-lg border border-border/50 bg-card/95 p-4 shadow-lg backdrop-blur-md transition-all duration-200 ${s?"scale-[1.02] shadow-xl":""}`,onMouseEnter:r,onMouseLeave:c,children:[t.jsx(w,{announcement:e}),t.jsxs("div",{className:"mt-3 flex items-center justify-between border-border/50 border-t pt-2 text-muted-foreground text-xs",children:[t.jsx("button",{onClick:k,className:"text-primary hover:underline",type:"button",children:"View all"}),t.jsx("button",{onClick:()=>d.dismiss(o),className:"opacity-70 hover:opacity-100",type:"button",children:"Dismiss"})]})]})}function S(){const e=m(p),o=m(h),s=m(b),i=l.useRef(new Set);return l.useEffect(()=>{s&&d.dismiss()},[s]),l.useEffect(()=>{if(!e)return;const n=[];for(const r of o){if(i.current.has(r.id))continue;i.current.add(r.id);const c=setTimeout(()=>{d.custom(a=>t.jsx(E,{announcement:r,toastId:a}),{id:r.id,duration:5e3})},500+o.indexOf(r)*200);n.push(c)}return()=>n.forEach(clearTimeout)},[e,o]),l.useEffect(()=>{if(!e)return;const n=c=>{const a=document.querySelector("[data-sonner-toaster]");a&&!a.contains(c.target)&&d.dismiss()},r=setTimeout(()=>{document.addEventListener("click",n)},100);return()=>{clearTimeout(r),document.removeEventListener("click",n)}},[e]),null}export{S as A,v as a,y as g};
