import{c as e,i as t}from"./preload-helper-B45gAKPr.js";import{pn as n}from"./iframe-GmIo3IOR.js";var r,i,a=t((()=>{r=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},i=(e=>e?r(e):r)}));function o(e,t=c){let n=s.useSyncExternalStore(e.subscribe,s.useCallback(()=>t(e.getState()),[e,t]),s.useCallback(()=>t(e.getInitialState()),[e,t]));return s.useDebugValue(n),n}var s,c,l,u,d=t((()=>{s=e(n(),1),a(),c=e=>e,l=e=>{let t=i(e),n=e=>o(t,e);return Object.assign(n,t),n},u=(e=>e?l(e):l)})),f=t((()=>{a(),d()})),p,m,h,g,_,v,y,b=t((()=>{f(),p=null,m=e=>(p=e,()=>{p===e&&(p=null)}),h=()=>{if(!p)throw Error(`Notifications store is not bound. Wrap app with NotificationsProvider.`);return p},g=Object.freeze({push:e=>h().getState().actions.push(e),upsert:e=>h().getState().actions.upsert(e),update:(e,t)=>h().getState().actions.update(e,t),dismiss:e=>h().getState().actions.dismiss(e),clear:()=>h().getState().actions.clear(),success:(e,t)=>h().getState().actions.push({type:`success`,message:e,...t}),info:(e,t)=>h().getState().actions.push({type:`info`,message:e,...t}),warning:(e,t)=>h().getState().actions.push({type:`warning`,message:e,...t}),error:(e,t)=>h().getState().actions.push({type:`error`,message:e,...t}),progress:(e,t)=>{let n=h(),r=t?.id;r&&n.getState().actions.upsert({id:r,type:`info`,title:t?.title,message:e,dismissible:!1});let i=r??n.getState().actions.push({type:`info`,title:t?.title,message:e,dismissible:!1});return{id:i,update:e=>g.update(i,{message:e}),success:(e,t=2500)=>g.update(i,{type:`success`,message:e,dismissible:!0,ttlMs:t}),error:(e,t=5e3)=>g.update(i,{type:`error`,message:e,dismissible:!0,ttlMs:t}),dismiss:()=>g.dismiss(i)}}}),_=()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`,v=6,y=()=>{let e=new Map,t=t=>{let n=e.get(t);n&&(window.clearTimeout(n),e.delete(t))},n=(n,r,i=1e4)=>{if(t(r),i<=0)return;let a=window.setTimeout(()=>{n.getState().actions.dismiss(r)},i);e.set(r,a)},r=i()((i,a)=>({items:[],actions:{push:e=>{let t=e.id??_(),a=Date.now(),o={id:t,type:e.type,title:e.title,message:e.message,createdAt:a,ttlMs:e.ttlMs,dismissible:e.dismissible??!0,actions:e.actions};return i(e=>({items:[o,...e.items.filter(e=>e.id!==t)].slice(0,v)})),n(r,t,o.ttlMs),t},update:(e,t)=>{let{items:o}=a(),s=o.findIndex(t=>t.id===e);if(s===-1)return!1;let c=o[s],l={...c,...t,id:c.id,createdAt:c.createdAt};return i(t=>({items:t.items.map(t=>t.id===e?l:t)})),`ttlMs`in t&&n(r,e,l.ttlMs),!0},upsert:e=>a().actions.update(e.id,{type:e.type,title:e.title,message:e.message,ttlMs:e.ttlMs,dismissible:e.dismissible})?e.id:a().actions.push(e),dismiss:e=>{t(e),i(t=>({items:t.items.filter(t=>t.id!==e)}))},clear:()=>{e.forEach(e=>window.clearTimeout(e)),e.clear(),i({items:[]})}}}));return r}}));export{u as a,f as i,m as n,d as o,y as r,o as s,b as t};