customizable-toast-notification 3.20.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ import type {
2
+ ToastOptions,
3
+ ToastHandle,
4
+ ToastPromiseMessages,
5
+ ToastGlobalConfig,
6
+ } from '../index.js';
7
+
8
+ export declare class ToastService {
9
+ success(message: string, options?: Partial<ToastOptions>): Promise<ToastHandle>;
10
+ error(message: string, options?: Partial<ToastOptions>): Promise<ToastHandle>;
11
+ warning(message: string, options?: Partial<ToastOptions>): Promise<ToastHandle>;
12
+ info(message: string, options?: Partial<ToastOptions>): Promise<ToastHandle>;
13
+ loading(message: string, options?: Partial<ToastOptions>): Promise<ToastHandle>;
14
+ custom(message: string | ToastOptions, options?: Partial<ToastOptions>): Promise<ToastHandle>;
15
+ show(options: ToastOptions): Promise<ToastHandle>;
16
+ promise<T>(
17
+ promiseOrFn: Promise<T> | (() => Promise<T> | T),
18
+ messages?: ToastPromiseMessages,
19
+ options?: ToastOptions
20
+ ): Promise<T>;
21
+ dismiss(target?: string | ToastHandle | HTMLElement | Promise<ToastHandle>): Promise<void>;
22
+ dismissAll(): Promise<void>;
23
+ clear(): Promise<void>;
24
+ setConfig(options?: Partial<ToastGlobalConfig>): ToastGlobalConfig;
25
+ getConfig(): ToastGlobalConfig;
26
+ resetConfig(): ToastGlobalConfig;
27
+ static ɵfac: unknown;
28
+ static ɵprov: unknown;
29
+ }
30
+
31
+ export function injectToast(): ToastService;
32
+
33
+ export const toast: ToastService;
34
+
35
+ export {
36
+ createToast,
37
+ toastPromise,
38
+ dismiss,
39
+ dismissAll,
40
+ clear,
41
+ setConfig,
42
+ getConfig,
43
+ resetConfig,
44
+ } from '../index.js';
@@ -0,0 +1,126 @@
1
+ /*!
2
+ * Customizable Toast Notifications
3
+ * Build: 2026-10-27 11:02:51
4
+ * Cache-Buster: 1793098971889
5
+ * Author: Priyanshu Patel
6
+ * Email: priyanshu.alt191@gmail.com
7
+ * License: Apache-2.0
8
+ * Dependencies: None
9
+ * Created: July 31, 2024
10
+ * A lightweight and fully customizable toast notification library
11
+ * designed for seamless integration with any JavaScript or framework-based UI.
12
+ * Supports flexible positioning, theming, icons, animations, and timing options
13
+ * out of the box — with CTA support and zero dependencies.
14
+ */const Me=Object.freeze({maxVisible:3,maxQueueSize:100,zIndex:9999,targetNode:null,disableInlineStyles:!1,reducedMotion:"auto",defaultPosition:"bottom-right",theme:"light",stacked:!1,swipeToDismiss:!0,sound:!1,icon:!0,pauseOnHover:!1,priorityQueue:!1,shadowDom:!1,trapFocus:!1,priorityScorer:null,onMetrics:null,debug:!1}),M={...Me};function ct(t){return t&&typeof t=="object"&&typeof t.appendChild=="function"}function ye(t={}){if(!t||typeof t!="object"||Array.isArray(t))return v();const{maxVisible:e,maxQueueSize:n,zIndex:r,targetNode:s,disableInlineStyles:o,reducedMotion:i,defaultPosition:c,theme:l,stacked:u,swipeToDismiss:d,sound:a,icon:f,pauseOnHover:m,priorityQueue:p,shadowDom:g,trapFocus:E,priorityScorer:T,onMetrics:w,debug:S}=t;if(g!==void 0&&(M.shadowDom=!!g),E!==void 0&&(M.trapFocus=!!E),S!==void 0&&(M.debug=!!S),e!==void 0){const b=Number(e);Number.isFinite(b)&&b>0&&(M.maxVisible=Math.max(1,Math.floor(b)))}if(n!==void 0){const b=Number(n);Number.isFinite(b)&&b>=0&&(M.maxQueueSize=Math.floor(b))}if(r!==void 0){const b=Number(r);Number.isFinite(b)&&(M.zIndex=Math.trunc(b))}if(s!==void 0&&(M.targetNode=s&&typeof s=="object"&&typeof s.appendChild=="function"?s:null),o!==void 0&&(M.disableInlineStyles=!!o),i!==void 0){const b=String(i||"auto").toLowerCase();["auto","always","never"].includes(b)&&(M.reducedMotion=b,typeof document<"u"&&(b==="always"?document.documentElement.setAttribute("data-toast-reduced-motion","always"):b==="never"?document.documentElement.setAttribute("data-toast-reduced-motion","never"):document.documentElement.removeAttribute("data-toast-reduced-motion")))}if(c!==void 0){const b=String(c||"").toLowerCase().trim();b&&(M.defaultPosition=b)}if(l!==void 0){const b=String(l||"light").toLowerCase();["light","dark","high-contrast","compact","spacious","glass"].includes(b)&&(M.theme=b,typeof document<"u"&&document.documentElement.setAttribute("data-toast-theme",b))}return u!==void 0&&(M.stacked=!!u),d!==void 0&&(M.swipeToDismiss=!!d),a!==void 0&&(M.sound=!!a),f!==void 0&&(M.icon=!!f),m!==void 0&&(M.pauseOnHover=!!m),p!==void 0&&(M.priorityQueue=!!p),T!==void 0&&(M.priorityScorer=typeof T=="function"?T:null),w!==void 0&&(M.onMetrics=typeof w=="function"?w:null),v()}function he(){return Object.assign(M,Me),typeof document<"u"&&(document.documentElement.removeAttribute("data-toast-theme"),document.documentElement.removeAttribute("data-toast-reduced-motion")),v()}function v(){return{...M}}function ut(){return ct(M.targetNode)?M.targetNode:typeof document<"u"?document.body:null}function q(){if(M.reducedMotion==="always")return!0;if(M.reducedMotion==="never")return!1;try{return!!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{return!1}}let ae=0;function dt(t=typeof globalThis<"u"?globalThis.crypto:null){if(t&&typeof t.getRandomValues=="function"){const r=new Uint16Array(1);return t.getRandomValues(r),r[0].toString(36).padStart(3,"0").slice(-3)}const e=typeof performance<"u"&&typeof performance.now=="function"?Math.floor(performance.now()*1e3):0;return((Date.now()^e)&65535).toString(36).padStart(3,"0").slice(-3)}const ft=dt();function mt(){ae=0}function Ne(t="toast"){const e=typeof t=="string"?t.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):"",n=e&&!/^[0-9]/.test(e)?e:"toast",r=Date.now().toString(36);ae=ae+1&16777215;const s=ae.toString(36);return`${n}-${r}-${ft}${s}`}async function pt(t,e){const n=document.createElement(t);return n.id=Ne(e),n}async function yt(t){if(!t)return!0;try{if(typeof t.remove=="function")return t.remove(),!0}catch{}try{if(t.parentNode)return t.parentNode.removeChild(t),!0}catch{}return!1}async function ht(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.endsWith("s")&&!e.endsWith("ms")){const r=Number.parseFloat(e)*1e3;return Number.isFinite(r)&&r>=0?r:500}const n=Number.parseFloat(e);return Number.isFinite(n)&&n>=0?n:500}return 500}class gt{constructor(e=200){this.maxSize=e,this.map=new Map}get(e){if(!this.map.has(e))return;const n=this.map.get(e);return this.map.delete(e),this.map.set(e,n),n}set(e,n){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxSize){const r=this.map.keys().next().value;this.map.delete(r)}this.map.set(e,n)}}const ge=new gt(200),bt={black:[0,0,0],white:[255,255,255],gray:[128,128,128],grey:[128,128,128],red:[255,0,0],green:[0,128,0],blue:[0,0,255],yellow:[255,255,0],orange:[255,165,0],purple:[128,0,128],transparent:[255,255,255]},be={};Object.entries(bt).forEach(([t,[e,n,r]])=>{const s=l=>{const u=l/255;return u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)},o=.2126*s(e)+.7152*s(n)+.0722*s(r),i=(o+.05)/.05,c=1.05/(o+.05);be[t.toLowerCase()]=i>=c?"#000000":"#ffffff"});function Z(t){if(!t)return"#ffffff";const e=String(t),n=ge.get(e);if(n)return n;if(be[t?.toLowerCase()]){const h=be[t.toLowerCase()];return ge.set(e,h),h}let r,s,o;function i(h){if(typeof h!="string")return h;let y=h.trim(),x=0;for(;y.toLowerCase().startsWith("var(")&&y.endsWith(")")&&x<5;){x++;const _=y.slice(4,-1).trim(),I=_.indexOf(","),B=(I===-1?_:_.slice(0,I)).trim(),N=I===-1?"":_.slice(I+1).trim();if(!B.startsWith("--"))return y;let R="";try{typeof document<"u"&&typeof getComputedStyle=="function"&&(R=getComputedStyle(document.documentElement).getPropertyValue(B).trim())}catch{}if(R)y=R;else if(N)y=N;else break}return y}function c(h){const y=h?.match(/^#(?:([0-9a-f]{3,4})|([0-9a-f]{6})|([0-9a-f]{8}))$/i);if(y){let k=y[1]||y[2]||y[3];if((k.length===3||k.length===4)&&(k=k.slice(0,3).split("").map(L=>L+L).join("")),k.length>=6){const L=Number.parseInt(k.slice(0,2),16),C=Number.parseInt(k.slice(2,4),16),te=Number.parseInt(k.slice(4,6),16);if(Number.isFinite(L)&&Number.isFinite(C)&&Number.isFinite(te))return{r:L,g:C,b:te}}return null}const x=k=>{if(typeof k!="string")return Number(k);const L=k.trim();return L.endsWith("%")?Math.round(Number.parseFloat(L)/100*255):Number(L)},_=h?.match(/rgba?\(\s*([\d.]+%?)\s*,\s*([\d.]+%?)\s*,\s*([\d.]+%?)(?:\s*,\s*[\d.%]+)?\s*\)/i);if(_){const k=Math.min(255,Math.max(0,x(_[1]))),L=Math.min(255,Math.max(0,x(_[2]))),C=Math.min(255,Math.max(0,x(_[3])));if(Number.isFinite(k)&&Number.isFinite(L)&&Number.isFinite(C))return{r:k,g:L,b:C}}const I=h?.match(/rgba?\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+%?)(?:\s*\/\s*[\d.%]+)?\s*\)/i);if(I){const k=Math.min(255,Math.max(0,x(I[1]))),L=Math.min(255,Math.max(0,x(I[2]))),C=Math.min(255,Math.max(0,x(I[3])));if(Number.isFinite(k)&&Number.isFinite(L)&&Number.isFinite(C))return{r:k,g:L,b:C}}const B=k=>{const L=k.trim().toLowerCase();let C=Number.parseFloat(L);return Number.isFinite(C)?(L.endsWith("turn")?C=C*360:L.endsWith("grad")?C=C*360/400:L.endsWith("rad")&&(C=C*180/Math.PI),(C%360+360)%360/360):0},N=h?.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.%]+)?\s*\)/i),R=!N&&h?.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*[\d.%]+)?\s*\)/i),z=N||R;if(z){const k=B(z[1]),L=Math.min(1,Math.max(0,Number(z[2])/100)),C=Math.min(1,Math.max(0,Number(z[3])/100));if(L===0){const U=Math.round(C*255);return{r:U,g:U,b:U}}const te=(U,pe,lt)=>{let Y=lt;return Y<0&&(Y+=1),Y>1&&(Y-=1),Y<1/6?U+(pe-U)*6*Y:Y<1/2?pe:Y<2/3?U+(pe-U)*(2/3-Y)*6:U},se=C<.5?C*(1+L):C+L-C*L,me=2*C-se;return{r:Math.round(te(me,se,k+1/3)*255),g:Math.round(te(me,se,k)*255),b:Math.round(te(me,se,k-1/3)*255)}}return null}try{const h=typeof t=="string"?t.trim():String(t||""),y=i(h).trim(),x=c(y);if(!x)throw new Error("Unknown color");({r,g:s,b:o}=x)}catch{r=s=o=128}const l=(h,y,x)=>{h/=255,y/=255,x/=255;const _=Math.max(h,y,x),I=Math.min(h,y,x);let B,N,R=(_+I)/2;if(_===I)B=N=0;else{const z=_-I;switch(N=R>.5?z/(2-_-I):z/(_+I),_){case h:B=(y-x)/z+(y<x?6:0);break;case y:B=(x-h)/z+2;break;case x:B=(h-y)/z+4}B/=6}return[B*360,N,R]},u=(h,y,x)=>{h/=360;let _,I,B;if(y===0)_=I=B=x;else{const N=(k,L,C)=>(C<0&&(C+=1),C>1&&(C-=1),C<.16666666666666666?k+(L-k)*6*C:C<.5?L:C<.6666666666666666?k+(L-k)*(.6666666666666666-C)*6:k),R=x<.5?x*(1+y):x+y-x*y,z=2*x-R;_=N(z,R,h+1/3),I=N(z,R,h),B=N(z,R,h-1/3)}return[Math.round(_*255),Math.round(I*255),Math.round(B*255)]},d=(h,y,x)=>{const _=[h,y,x].map(I=>(I/=255,I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4)));return .2126*_[0]+.7152*_[1]+.0722*_[2]},a=(h,y)=>{const x=d(...h),_=d(...y);return(Math.max(x,_)+.05)/(Math.min(x,_)+.05)},f=(h,y,x)=>`#${h.toString(16).padStart(2,"0")}${y.toString(16).padStart(2,"0")}${x.toString(16).padStart(2,"0")}`;let[m,p,g]=l(r,s,o);const E=4.5;let T=g<.5?Math.min(g+.5,1):Math.max(g-.5,0),[w,S,b]=u(m,p,T);if(a([r,s,o],[w,S,b])<E){const h=a([r,s,o],[0,0,0]),y=a([r,s,o],[255,255,255]);[w,S,b]=h>=y?[0,0,0]:[255,255,255]}const F=f(w,S,b);return ge.set(e,F),F}const De=new Set(["DIV","SPAN","P","BR","STRONG","B","EM","I","U","SMALL","UL","OL","LI","A","IMG","PRE","CODE","MARK"]),Be=new Set(["href","src","alt","title","class","target","rel","loading"]),xt=new Set(["SCRIPT","STYLE","IFRAME","NOSCRIPT","OBJECT","EMBED","SVG","MATH","AUDIO","VIDEO","CANVAS","TEMPLATE"]),xe=/^\s*(?:https?:|mailto:|data:image\/(?:png|jpe?g|gif|webp|avif|bmp|ico);|\/(?!\/|\\)|\.\/|\.\.\/|#)/i;function vt(){try{return!!(typeof window<"u"&&window.DOMPurify&&typeof window.DOMPurify.sanitize=="function")}catch{}return!1}function wt(t,e){const n=[];Array.from(t.attributes||[]).forEach(s=>{const o=s.name.toLowerCase(),i=s.value;if(!e.has(o)||o.startsWith("on")){n.push(s.name);return}if(o==="href"||o==="src"){const c=typeof i=="string"?i.trim().toLowerCase():"";if((c.startsWith("javascript:")||c.startsWith("vbscript:")||c.startsWith("data:"))&&!(o==="src"&&c.startsWith("data:image/")&&!c.startsWith("data:image/svg+xml"))){if(o==="href"){t.setAttribute("href","#");return}n.push(s.name);return}if(!xe.test(i)){if(o==="href"){t.setAttribute("href","#");return}n.push(s.name);return}}if(o==="target"&&typeof i=="string"&&i.trim().toLowerCase()==="_blank"){const c=(t.getAttribute("rel")||"").split(/\s+/).filter(Boolean);c.includes("noopener")||c.push("noopener"),c.includes("noreferrer")||c.push("noreferrer"),t.setAttribute("rel",c.join(" "))}}),n.forEach(s=>t.removeAttribute(s));const r=t.getAttribute("target");if(t.tagName==="A"&&typeof r=="string"&&r.trim().toLowerCase()==="_blank"){const s=(t.getAttribute("rel")||"").split(/\s+/).filter(Boolean);s.includes("noopener")||s.push("noopener"),s.includes("noreferrer")||s.push("noreferrer"),t.setAttribute("rel",s.join(" "))}}function ve(t,e,n){if(t.nodeType===Node.TEXT_NODE)return document.createTextNode(t.nodeValue);if(t.nodeType===Node.COMMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return null;const r=t.tagName.toUpperCase();if(xt.has(r)||r.includes("SCRIPT")||r.includes("<")||r.includes(">"))return null;if(!e.has(r)){const o=document.createDocumentFragment();return Array.from(t.childNodes).forEach(i=>{const c=ve(i,e,n);c&&o.appendChild(c)}),o}const s=document.createElement(t.tagName);return Array.from(t.attributes||[]).forEach(o=>{s.setAttribute(o.name,o.value)}),wt(s,n),Array.from(t.childNodes).forEach(o=>{const i=ve(o,e,n);i&&s.appendChild(i)}),s}function St(t){if(typeof DOMParser<"u")try{const n=new DOMParser().parseFromString(t,"text/html");if(n&&n.body)return n.body}catch{}if(typeof document<"u"){const e=document.createElement("template");if("content"in e)return e.innerHTML=t,e.content;const n=document.createElement("div");return n.innerHTML=t,n}return null}function Ct(t){if(!t||typeof t!="string")return"";const e=St(t);if(!e)return"";const n=document.createDocumentFragment();Array.from(e.childNodes).forEach(s=>{const o=ve(s,De,Be);o&&n.appendChild(o)});const r=document.createElement("div");return r.appendChild(n),r.querySelectorAll('a[target="_blank"]').forEach(s=>{const o=(s.getAttribute("rel")||"").split(/\s+/).filter(Boolean);o.includes("noopener")||o.push("noopener"),o.includes("noreferrer")||o.push("noreferrer"),s.setAttribute("rel",o.join(" "))}),r.innerHTML}function we(t,e={}){if(typeof t!="string"||!t.trim())return"";try{if(!e.forceFallback&&vt()){const r=window.DOMPurify.sanitize(t,{ALLOWED_TAGS:Array.from(De),ALLOWED_ATTR:Array.from(Be),ALLOWED_URI_REGEXP:xe}),s=document.createElement("div");return s.innerHTML=r,s.querySelectorAll("a[href]").forEach(o=>{const i=o.getAttribute("href")||"";xe.test(i)||o.setAttribute("href","#")}),s.querySelectorAll('a[target="_blank"]').forEach(o=>{const i=(o.getAttribute("rel")||"").split(/\s+/).filter(Boolean);i.includes("noopener")||i.push("noopener"),i.includes("noreferrer")||i.push("noreferrer"),o.setAttribute("rel",i.join(" "))}),s.innerHTML}}catch(n){console.warn("DOMPurify sanitization failed, falling back:",n)}return Ct(t)}function Pe(t={}){if(typeof document>"u")return null;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n=Number(e.size),r=Number.isFinite(n)&&n>0?n:14,s=typeof e.color=="string"&&e.color.trim()?e.color.trim():"currentColor",o=/[\r\n<>"';]/.test(s)||/^\s*javascript:/i.test(s)?"currentColor":s,i=typeof e.text=="string"?e.text:"",c=document.createElement("span");c.className="toast-loader",c.setAttribute("role","status"),c.setAttribute("aria-label",i||"Loading");const l=v();l.disableInlineStyles||(c.style.display="inline-flex",c.style.alignItems="center",c.style.gap="8px");const u="http://www.w3.org/2000/svg",d=document.createElementNS(u,"svg");d.setAttribute("width",String(r)),d.setAttribute("height",String(r)),d.setAttribute("viewBox","0 0 50 50"),d.setAttribute("aria-hidden","true");const a=document.createElementNS(u,"circle");if(a.classList.add("toast-loader-circle"),a.setAttribute("cx","25"),a.setAttribute("cy","25"),a.setAttribute("r","20"),a.setAttribute("fill","none"),a.setAttribute("stroke",o),a.setAttribute("stroke-width","4"),a.setAttribute("stroke-linecap","round"),l.disableInlineStyles||(a.style.opacity="0.85",a.style.strokeDasharray="90",a.style.strokeDashoffset="60",a.style.transformOrigin="center",q()||(a.style.animation="toast-spinner 1s linear infinite")),d.appendChild(a),c.appendChild(d),i){const f=document.createElement("span");f.className="toast-loader-label",l.disableInlineStyles||(f.style.fontSize="13px"),f.textContent=i,c.appendChild(f)}if(!l.disableInlineStyles&&typeof document<"u"&&!document.getElementById("toast-spinner-styles"))try{const f=document.createElement("style");f.id="toast-spinner-styles",f.textContent="@keyframes toast-spinner { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }";const m=document.head||document.documentElement;m&&m.appendChild(f)}catch{}return c}function ze(t,e,n){const r=e?.cta;if(!r||typeof r!="object")return;const s=Array.isArray(r)?r.filter(c=>c&&typeof c=="object"):[r];if(s.length===0)return;const o=[];s.forEach((c,l)=>{if(!c||typeof c!="object")return;const u={...c};u.label||(u.label=s.length>1?`Action ${l+1}`:"CTA Label Missing!");const d=u.variant==="link"||!u.variant&&!!u.href,a=document.createElement(d?"a":"button");if(d){if(u.href){const y=String(u.href).trim(),x=/^(javascript:|vbscript:|data:(?!image\/[a-z0-9.+-]+;base64,))/i.test(y);a.href=x?"#":y}else a.setAttribute("role","button"),a.tabIndex=0;u.target&&(a.target=u.target);const h=new Set((u.rel||"").split(/\s+/).filter(Boolean));typeof u.target=="string"&&u.target.trim().toLowerCase()==="_blank"&&(h.add("noopener"),h.add("noreferrer")),a.rel=Array.from(h).join(" ")}else a.type="button";a.setAttribute("aria-label",u.ariaLabel||u.label);const f=u.textColor||u.color||e.textColor||Z(e.backgroundColor),m=u.backgroundColor||u.background||(e.backgroundColor?Fe(e.backgroundColor):"rgba(255,255,255,0.15)"),g=(typeof f=="string"?f.trim():"").match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);let E="rgba(128, 128, 128, 0.3)";g&&(E=`${g[1].length===3?`#${g[1][0]}${g[1][0]}${g[1][1]}${g[1][1]}${g[1][2]}${g[1][2]}`:`#${g[1]}`}44`),a.className="toast-cta";const T=e.fontDirection==="rtl";v().disableInlineStyles||Object.assign(a.style,{marginLeft:T?"0px":l===0?"10px":"6px",marginRight:T?l===0?"10px":"6px":"0px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:`1px solid ${E}`,color:f,background:m,cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0",display:"inline-flex",alignItems:"center",textDecoration:"none",outline:"none"}),a.textContent=u.label;const w=async h=>{if(!a._isExecuting){a._isExecuting=!0;try{if(typeof u.onClick=="function"){const y=u.onClick(h);y?.then&&await y}}catch(y){console.error("CTA onClick handler error:",y)}finally{a._isExecuting=!1,u.autoClose!==!1&&typeof n=="function"&&await n(t)}}},S=h=>{d&&!u.href&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),w(h))};a.addEventListener("click",w),d&&!u.href&&a.addEventListener("keydown",S);const b=()=>{a.removeEventListener("click",w),d&&!u.href&&a.removeEventListener("keydown",S)};a._cleanup=b,o.push(b);const F=t.querySelector(".toast-undo-btn")||t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");F?t.insertBefore(a,F):t.appendChild(a)});const i=t._cleanupCTA;t._cleanupCTA=()=>{i?.(),o.forEach(c=>c())}}function We(t,e,n){const r=e?.undo;if(!r)return;const s=typeof r=="function";if(!s&&(typeof r!="object"||Array.isArray(r)))return;const o=s?{onUndo:r}:{...r},i=typeof o.label=="string"&&o.label.trim()?o.label.trim():typeof e?.undoText=="string"&&e.undoText.trim()?e.undoText.trim():"Undo",c=Number(e?.duration),l=o.showCountdown!==!1&&Number.isFinite(c)&&c>0,u=document.createElement("button");u.type="button",u.className="toast-undo-btn",u.setAttribute("aria-label",`${i} action`);const d=e.textColor||Z(e.backgroundColor),a=e.backgroundColor?Fe(e.backgroundColor):"rgba(255,255,255,0.18)",m=(typeof d=="string"?d.trim():"").match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);let p="rgba(128, 128, 128, 0.35)";m&&(p=`${m[1].length===3?`#${m[1][0]}${m[1][0]}${m[1][1]}${m[1][1]}${m[1][2]}${m[1][2]}`:`#${m[1]}`}55`);const g=e.fontDirection==="rtl";v().disableInlineStyles||Object.assign(u.style,{marginLeft:g?"0px":"10px",marginRight:g?"10px":"0px",padding:"5px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"700",lineHeight:"1",border:`1px solid ${p}`,color:d,background:a,cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0",display:"inline-flex",alignItems:"center",gap:"4px"});let E=Math.max(1,Math.ceil((c||2500)/1e3));const T=()=>{u.textContent=l?`${i} (${E}s)`:i};T();let w=null,S=!1;l&&(w=setInterval(()=>{S||(E=Math.max(0,E-1),T(),E<=0&&w&&(clearInterval(w),w=null))},1e3),typeof w?.unref=="function"&&w.unref()),t._pauseUndo=()=>{S=!0},t._resumeUndo=()=>{S=!1};const b=()=>{w&&(clearInterval(w),w=null),t._pauseUndo=null,t._resumeUndo=null},F=async y=>{b(),u.removeEventListener("click",F);try{if(typeof o.onUndo=="function"){const x=o.onUndo(y,t);x?.then&&await x}}catch(x){console.error("Undo action error:",x)}finally{typeof n=="function"&&await n(t)}};u.addEventListener("click",F),u._cleanup=()=>{b(),u.removeEventListener("click",F)},t._cleanupUndo=()=>{b(),u.removeEventListener("click",F)};const h=t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");h?t.insertBefore(u,h):t.appendChild(u)}function Re(t,e,n){const r=document.createElement("button");r.type="button";const s=typeof e?.closeAriaLabel=="string"&&e.closeAriaLabel.trim()?e.closeAriaLabel.trim():"Close notification";r.setAttribute("aria-label",s),r.setAttribute("title",s),r.textContent="\xD7";const o=e.textColor||Z(e.backgroundColor);r.className="toast-close-btn";const i=e.fontDirection==="rtl";v().disableInlineStyles||Object.assign(r.style,{background:"none",border:"none",color:o,fontSize:"18px",marginLeft:i?"0px":"10px",marginRight:i?"10px":"0px",cursor:"pointer",lineHeight:"1",padding:"0 4px",flexShrink:"0",display:"inline-flex",alignItems:"center",justifyContent:"center"});const c=()=>{typeof n=="function"&&n(t)};r.addEventListener("click",c),t._cleanupCloseButton=()=>{r.removeEventListener("click",c)},t.appendChild(r)}function Fe(t){return t&&Z(t)==="#000000"?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"}function $e(){if(typeof document>"u"||document.getElementById("toast-progress-indeterminate-styles"))return;const t=document.createElement("style");t.id="toast-progress-indeterminate-styles",t.textContent=`
15
+ @keyframes toast-progress-indeterminate {
16
+ 0% { left: 0%; width: 0%; }
17
+ 50% { left: 20%; width: 60%; }
18
+ 100% { left: 100%; width: 0%; }
19
+ }
20
+ @keyframes toast-progress-indeterminate-rtl {
21
+ 0% { right: 0%; width: 0%; }
22
+ 50% { right: 20%; width: 60%; }
23
+ 100% { right: 100%; width: 0%; }
24
+ }
25
+ .toast-progress-bar-indeterminate {
26
+ animation: toast-progress-indeterminate 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
27
+ }
28
+ .toast-progress-bar-indeterminate-rtl {
29
+ animation: toast-progress-indeterminate-rtl 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
30
+ }
31
+ `;const e=document.head||document.documentElement;e&&e.appendChild(t)}function He(t,e,n={}){if(t==null)return null;if(t==="indeterminate")return"indeterminate";let r;return typeof t=="string"?r=Number.parseFloat(t.trim()):r=Number(t),Number.isFinite(r)?(e&&r>0&&r<1&&(e._progressRatioMode=!0),((n.progressNormalized||e?._progressRatioMode)&&r>0&&r<=1||r>0&&r<1)&&(r=r*100),Math.min(100,Math.max(0,r))):0}function je(t,e={}){if(!t)return;const n=document.createElement("div");n.className="toast-progress-bar",t._progressBar=n;const r=e.borderRadius||"0",s=Number.parseInt(r,10),o=Number.isFinite(s)&&s>0?s:0;let i=4,c="4px";if(typeof e.progressHeight=="number"&&Number.isFinite(e.progressHeight)&&e.progressHeight>0)i=e.progressHeight,c=`${i}px`;else if(typeof e.progressHeight=="string"&&e.progressHeight.trim()){const T=e.progressHeight.trim(),w=Number.parseFloat(T);Number.isFinite(w)&&w>0&&(T.endsWith("rem")||T.endsWith("em")?(i=w*16,c=T):(i=w,c=/^\d+(\.\d+)?$/.test(T)?`${w}px`:T))}const l=Number(e.duration??2500),u=Math.max(0,l+5),d=Math.min(o,i*2),a=o>0?`calc(100% - ${d*2}px)`:"100%",f=e.progressDirection==="reverse"||e.progressDirection==="increasing"||e.progressDirection==="ltr",m=e.fontDirection==="rtl"||e.progressDirection==="rtl"||t?.style?.direction==="rtl";n._leftOffset=d,n._finalWidth=a,n._isReverse=f,n._isRtl=m;const p=e.progressBarColor||e.progressColor||"currentColor",g=typeof n.animate=="function";v().disableInlineStyles||Object.assign(n.style,{position:"absolute",left:m?"auto":`${d}px`,right:m?`${d}px`:"auto",height:c,background:p,width:f?"0%":`${a}`,transition:g?"none":`width ${u}ms linear`,[e.progressPosition==="top"?"top":"bottom"]:"0",borderRadius:`${i/2}px`,opacity:"0.8",zIndex:"2",willChange:"width"}),t.appendChild(n);const E=e.progress==="indeterminate"||!!e.showProgressBar&&(e.duration===0||e.duration===1/0)&&e.progress===void 0;if(n._isIndeterminate=E,n._isManualProgress=e.progress!==void 0&&e.progress!=="indeterminate",E){if(n.classList.add("toast-progress-bar-indeterminate"),m&&n.classList.add("toast-progress-bar-indeterminate-rtl"),!v().disableInlineStyles){$e();const T=m?"toast-progress-indeterminate-rtl":"toast-progress-indeterminate";n.style.animation=`${T} 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite`}n.style.width=a;return}if(e.progress!==void 0){const T=He(e.progress,t,e);n.style.width=`${T}%`,n.style.transition="width 200ms ease";return}if(e.duration===0||e.duration===1/0){n.style.width="0%";return}if(q())n.style.display="none";else if(typeof n.animate=="function"){const T=f?[{width:"0%"},{width:a}]:[{width:a},{width:"0%"}];t._progressAnimation=n.animate(T,{duration:u,easing:"linear",fill:"forwards",delay:50})}else n.style.transition=`width ${u}ms linear`,requestAnimationFrame(()=>{n.style.width=f?a:"0%"})}function Tt(t){if(!t||t._hasAnimated)return;if(q()){t._hasAnimated=!0,t.style.transition="none",t.style.opacity="1",t.style.transform="translateY(0)",t.classList.add("active");return}const e=()=>{if(!t._hasAnimated){t._hasAnimated=!0;try{t.offsetHeight}catch{}requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="none",t.classList.add("active")})}};t.isConnected?e():requestAnimationFrame(()=>{t.isConnected?e():requestAnimationFrame(()=>{e()})})}function qe(t,e){if(!t||typeof t.addEventListener!="function")return;let n=0,r=0,s=0,o=0,i=!1,c=!1,l=null,u=!1;const d=()=>{u&&(u=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",m))},a=p=>{if(!p||p.button!==void 0&&p.button!==0)return;const g=p.target;if(g&&typeof g.closest=="function"&&g.closest("button, a, input, textarea, select, label"))return;let E=p;p.touches&&p.touches.length>0?(E=p.touches[0],l=E.identifier??null):l=null,n=E.clientX,r=E.clientY,s=n,o=Date.now(),i=!0,c=!1,t._originalTransition=t.style.transition||"",t.style.transition="none",t.style.userSelect="none",!u&&typeof window<"u"&&(u=!0,window.addEventListener("mousemove",f,{passive:!1}),window.addEventListener("mouseup",m,{passive:!0}))},f=p=>{if(!i||!p)return;let g=p;if(p.touches)if(l!==null){for(let b=0;b<p.touches.length;b++)if(p.touches[b].identifier===l){g=p.touches[b];break}}else p.touches.length>0&&(g=p.touches[0]);const E=g.clientX,T=g.clientY,w=E-n,S=T-r;if(!c){if(Math.abs(w)>8&&Math.abs(w)>Math.abs(S))c=!0;else if(Math.abs(S)>8){i=!1,t.style.userSelect="",d();return}}if(c){s=E;const b=Math.max(0,1-Math.abs(w)/280);!v().disableInlineStyles&&!q()&&(t.style.transform=`translateX(${w}px)`,t.style.opacity=String(b)),p.cancelable&&p.preventDefault()}},m=()=>{if(d(),l=null,!i||!c){i=!1,t.style.userSelect="";return}i=!1,t.style.userSelect="";const p=s-n,g=Math.max(1,Date.now()-o),T=(g>0?Math.abs(p)/g:0)>=.65&&Math.abs(p)>=50,w=T?50:75;if(Math.abs(p)>=w){const S=p>0?320:-320,b=T?120:180;!v().disableInlineStyles&&!q()&&(t.style.transition=`transform ${b}ms ease-out, opacity ${b}ms ease-out`,t.style.transform=`translateX(${S}px)`,t.style.opacity="0"),t._swipeTimeout&&clearTimeout(t._swipeTimeout),t._swipeTimeout=setTimeout(()=>{t._swipeTimeout=null,typeof e=="function"&&e(t)},b),typeof t._swipeTimeout?.unref=="function"&&t._swipeTimeout.unref()}else if(!v().disableInlineStyles&&!q()){const S="cubic-bezier(0.34, 1.56, 0.64, 1)";t.style.transition=`transform 200ms ${S}, opacity 200ms ease`,t.style.transform="translateX(0)",t.style.opacity="1",t._snapbackTimer&&clearTimeout(t._snapbackTimer),t._snapbackTimer=setTimeout(()=>{t._snapbackTimer=null,t.style.transform="none",t._originalTransition&&(t.style.transition=t._originalTransition)},200),typeof t._snapbackTimer?.unref=="function"&&t._snapbackTimer.unref()}};t.addEventListener("touchstart",a,{passive:!0}),t.addEventListener("touchmove",f,{passive:!1}),t.addEventListener("touchend",m,{passive:!0}),t.addEventListener("touchcancel",m,{passive:!0}),t.addEventListener("mousedown",a,{passive:!0}),t._cleanupSwipe=()=>{t._swipeTimeout&&(clearTimeout(t._swipeTimeout),t._swipeTimeout=null),t._snapbackTimer&&(clearTimeout(t._snapbackTimer),t._snapbackTimer=null),d(),t.removeEventListener("touchstart",a),t.removeEventListener("touchmove",f),t.removeEventListener("touchend",m),t.removeEventListener("touchcancel",m),t.removeEventListener("mousedown",a)}}function Et(t){if(!t||typeof t.querySelectorAll!="function")return null;const e=typeof document<"u"&&document.activeElement&&document.activeElement!==document.body?document.activeElement:null,n=()=>Array.from(t.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(i=>{try{if(typeof i.offsetWidth=="number"&&typeof i.offsetHeight=="number"){const c=typeof window<"u"&&window.getComputedStyle?window.getComputedStyle(i):null;if(c&&(c.display==="none"||c.visibility==="hidden"))return!1;if(typeof document<"u"&&document.body&&(document.body.offsetWidth>0||document.body.offsetHeight>0)&&i.offsetWidth===0&&i.offsetHeight===0)return i===document.activeElement}return!0}catch{return!0}}),r=i=>{if(i.defaultPrevented||i.key!=="Tab"||!t.isConnected)return;const c=n();if(c.length===0)return;const l=c[0],u=c[c.length-1];i.shiftKey?(document.activeElement===l||!t.contains(document.activeElement))&&(u.focus(),i.preventDefault()):(document.activeElement===u||!t.contains(document.activeElement))&&(l.focus(),i.preventDefault())};t.addEventListener("keydown",r),typeof document<"u"&&document.addEventListener("keydown",r);const s=setTimeout(()=>{const i=n();i.length>0&&typeof i[0].focus=="function"&&i[0].focus()},30);typeof s?.unref=="function"&&s.unref();const o=()=>{if(clearTimeout(s),t.removeEventListener("keydown",r),typeof document<"u"&&document.removeEventListener("keydown",r),e&&typeof e.focus=="function"&&e.isConnected)try{e.focus()}catch{}};return t._cleanupFocusTrap=o,o}const At="http://www.w3.org/2000/svg",kt=new Set(["svg","g","path","circle","rect","line","polyline","polygon","ellipse","title","desc","defs","clippath","use"]),Lt=new Set(["viewbox","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","d","cx","cy","r","x","y","x1","y1","x2","y2","points","rx","ry","transform","role","aria-hidden","focusable","xmlns","preserveaspectratio","class","id","href","xlink:href"]);function _t(t=""){return/^\s*javascript:/i.test(t)}function Se(t){const e=typeof DOMParser<"u"?DOMParser:typeof window<"u"&&window.DOMParser?window.DOMParser:null;if(!e)return null;try{const r=new e().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return null;const s=r.documentElement;if(!s||s.tagName.toLowerCase()!=="svg")return null;const o=i=>{if(i.nodeType===3)return document.createTextNode(i.textContent||"");if(i.nodeType!==1)return null;const c=i.tagName.toLowerCase();if(!kt.has(c))return null;const l=document.createElementNS(At,c);if(i.attributes)for(let u=0;u<i.attributes.length;u++){const d=i.attributes[u],a=d.name,f=a.toLowerCase(),m=d.value||"";f.startsWith("on")||Lt.has(f)&&((f==="href"||f==="xlink:href")&&(_t(m)||c==="use"&&m&&!m.startsWith("#"))||l.setAttribute(a,m))}if(i.childNodes)for(let u=0;u<i.childNodes.length;u++){const d=o(i.childNodes[u]);d&&l.appendChild(d)}return l};return o(s)}catch{return null}}const j={success:`
32
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
33
+ <path d="M20 6L9 17l-5-5"/>
34
+ </svg>
35
+ `,error:`
36
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
37
+ <circle cx="12" cy="12" r="10"/>
38
+ <line x1="15" y1="9" x2="9" y2="15"/>
39
+ <line x1="9" y1="9" x2="15" y2="15"/>
40
+ </svg>
41
+ `,warning:`
42
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
43
+ <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
44
+ <line x1="12" y1="9" x2="12" y2="13"/>
45
+ <line x1="12" y1="17" x2="12.01" y2="17"/>
46
+ </svg>
47
+ `,info:`
48
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
49
+ <circle cx="12" cy="12" r="10"/>
50
+ <line x1="12" y1="16" x2="12" y2="12"/>
51
+ <line x1="12" y1="8" x2="12.01" y2="8"/>
52
+ </svg>
53
+ `};function Ue(t={}){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};let n=e.icon;if(n===void 0){const l=v().icon;l!==void 0&&(n=l)}if(typeof n=="function")try{n=n(e)}catch(l){console.warn("options.icon callback error:",l),n=null}if(n===!1||n===""||n===null||typeof document>"u")return null;const r=e.type,s=v(),o=document.createElement("i");o.className="toast-icon",o.setAttribute("aria-hidden","true");const i=e.fontDirection==="rtl";if(s.disableInlineStyles||Object.assign(o.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginLeft:i?"8px":"0px",marginRight:i?"0px":"8px",lineHeight:"1",fontStyle:"normal"}),n&&typeof n=="object"&&(n.nodeType===1||n.nodeType===11||typeof HTMLElement<"u"&&n instanceof HTMLElement)&&typeof n.cloneNode=="function")return o.appendChild(n.cloneNode(!0)),o;if(typeof n=="string"&&n.trim()){const l=n.trim(),d={check:j.success,checkmark:j.success,success:j.success,cross:j.error,error:j.error,alert:j.warning,warning:j.warning,circle:j.info,info:j.info}[l.toLowerCase()];if(d){const a=Se(d.trim());return a&&o.appendChild(a),o}if(l.startsWith("<svg")&&l.endsWith("</svg>")){const a=Se(l);a?(a.setAttribute("aria-hidden","true"),a.setAttribute("focusable","false"),a.getAttribute("width")||a.setAttribute("width","18"),a.getAttribute("height")||a.setAttribute("height","18"),o.appendChild(a)):o.textContent=l}else o.textContent=l;return o}const c=typeof r=="string"?r.toLowerCase().trim():"";if((n===!0||n===void 0)&&c&&j[c]){const l=Se(j[c].trim());return l&&o.appendChild(l),o}return null}function It(t,e,n){const r=String(t||"").toLowerCase(),s=r.includes("top"),o=r.includes("left"),i=r.includes("right"),c=String(e||"").toLowerCase().trim();return c==="fade"?"none":c==="pop"?"scale(0.6)":c==="zoom"||c==="scale"?"scale(0.75)":c==="flip"?"perspective(600px) rotateX(45deg)":c==="slide"?o?"translateX(-100%)":i?"translateX(100%)":s?"translateY(-100%)":"translateY(100%)":n?r.includes("center")&&!s&&!r.includes("bottom")?o?"translateX(-36px) scale(0.92)":i?"translateX(36px) scale(0.92)":"scale(0.85)":s?"translateY(-36px) scale(0.92)":"translateY(36px) scale(0.92)":c==="bounce"?s?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":s?"translateY(-20px)":"translateY(20px)"}async function Mt(t,e,n){const r=v(),s=String(e?.animationType||"").toLowerCase().trim(),o=!!e?.spring||s==="spring",i=o?400:await ht(e?.animationDuration),c=`${i}ms`,l=o?"cubic-bezier(0.34, 1.56, 0.64, 1)":typeof e?.animationEasing=="string"&&e.animationEasing.trim()?e.animationEasing.trim():"ease";t._animationType=e?.animationType;const u=typeof e?.className=="string"&&e.className.trim()?` ${e.className.trim()}`:"",d=s?` toast-anim-${s}`:"";t.className=`toast toast-${e?.type??"info"}${d}${u}`;const a=e?.theme||r.theme;a&&t.setAttribute("data-toast-theme",String(a).toLowerCase());const f=typeof e?.borderRadius=="number"?`${e.borderRadius}px`:e?.borderRadius,m=typeof e?.maxWidth=="number"?`${e.maxWidth}px`:e?.maxWidth,p=o?`${Math.min(300,i)}ms`:c,g=o?"ease":l;r.disableInlineStyles||Object.assign(t.style,{background:e?.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:f,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:m,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",pointerEvents:"auto",transition:`opacity ${p} ${g}, transform ${c} ${l}`,transform:It(e?.position,e?.animationType,o),zIndex:String(r.zIndex),direction:e?.fontDirection&&e.fontDirection!=="auto"?e.fontDirection:void 0});const E=e?.type==="error",T=e?.role||"alert",w=e?.ariaLive||(E?"assertive":"polite");t.setAttribute("role",T),t.setAttribute("aria-live",w),t.tabIndex=0,t._animationDuration=i;const S=document.createElement("span");S.className="toast-message",t._messageSpan=S,e?.wrapText==="truncate"||e?.wrapText==="ellipsis"||e?.wrapText===!1||!e?.wrapText?(S.classList.add("is-truncated"),r.disableInlineStyles||Object.assign(S.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"normal",overflow:"hidden",textOverflow:"ellipsis"})):r.disableInlineStyles||Object.assign(S.style,{display:"block",whiteSpace:"normal"});const F=typeof e?.fontSize=="number"?`${e.fontSize}px`:e?.fontSize;r.disableInlineStyles||Object.assign(S.style,{flex:"1",padding:e?.fontPadding,fontFamily:e?.fontFamily,fontSize:F,fontWeight:e?.fontWeight,lineHeight:e?.fontLineHeight,color:e?.textColor,userSelect:"text",wordBreak:"break-word",overflow:"hidden",textOverflow:"ellipsis",direction:e?.fontDirection&&e.fontDirection!=="auto"?e.fontDirection:void 0});const h=!!e.allowHtml,y=e.message??"",x=Ue(e);if(x&&t.appendChild(x),e.loader||e.showLoader){const B=Pe(e.loader||{});S.appendChild(B);const N=document.createElement("span");N.className="toast-message-spacer",r.disableInlineStyles||(N.style.display="inline-block",N.style.width="8px"),S.appendChild(N)}if(h&&typeof y=="string"&&y.trim().length>0)try{const B=we(y),N=document.createElement("div");for(N.innerHTML=B;N.firstChild;)S.appendChild(N.firstChild)}catch(B){console.warn("HTML message sanitization failed, falling back to text:",B),S.appendChild(document.createTextNode(String(y)))}else S.appendChild(document.createTextNode(String(y)));if(S.setAttribute("title",S.textContent||""),t.appendChild(S),e?.cta&&typeof e.cta=="object"&&ze(t,e,n),e?.undo&&We(t,e,n),e?.showCloseButton&&Re(t,e,n),e?.showProgressBar!==!1&&(e?.showProgressBar||e?.progress!==void 0)&&je(t,e),(e?.swipeToDismiss!==void 0?e.swipeToDismiss:r.swipeToDismiss)!==!1&&qe(t,n),e?.sound!==void 0?e.sound:r.sound){if(typeof e?.sound=="string"&&typeof window<"u"&&typeof window.Audio=="function")try{new window.Audio(e.sound).play().catch(()=>{})}catch{}else if(typeof e?.onSound=="function")try{e.onSound(e)}catch{}}(e?.trapFocus??r.trapFocus)&&Et(t)}async function Ye(t={},e){try{const n=v(),r=document.createElement("div"),s=t?.position||n.defaultPosition,o=String(s).toLowerCase().trim();let i="auto",c="auto",l="auto",u="auto",d="none";o.startsWith("top")?i="20px":(o.startsWith("bottom")||o.includes("below"))&&(c="20px"),o.startsWith("left")?l="20px":o.startsWith("right")?u="20px":o==="center"?(l="50%",i="50%",d="translate(-50%, -50%)"):o.includes("center")?o.includes("left")?(l="20px",i="50%",d="translateY(-50%)"):o.includes("right")?(u="20px",i="50%",d="translateY(-50%)"):o.includes("top")?(i="20px",l="50%",d="translateX(-50%)"):o.includes("bottom")&&(c="20px",l="50%",d="translateX(-50%)"):(u="20px",c="20px"),r.className="toast-emergency",r.tabIndex=0,r.setAttribute("role","alert"),r.setAttribute("aria-live","assertive"),n.disableInlineStyles||Object.assign(r.style,{background:"#333",color:"white",padding:"10px 15px",position:"fixed",top:i,bottom:c,left:l,right:u,transform:d,zIndex:String(n.zIndex+100),borderRadius:"3px",maxWidth:"250px",wordWrap:"break-word",boxShadow:"0 2px 10px rgba(0,0,0,0.3)"});const a=document.createElement("div"),f=document.createElement("span");if(f.className="toast-emergency-message",n.disableInlineStyles||(f.style.display="inline-block"),t.allowHtml)try{const T=we(String(t.message||"Emergency Toast Showing!")),w=document.createElement("div");for(w.innerHTML=T;w.firstChild;)f.appendChild(w.firstChild)}catch{f.appendChild(document.createTextNode(String(t.message||"Emergency Toast Showing!")))}else f.textContent=String(t.message||"Emergency Toast Creation Showing!");a.appendChild(f);const m=document.createElement("button");for(m.type="button",m.className="toast-emergency-close",m.setAttribute("aria-label","Close emergency notification"),n.disableInlineStyles||Object.assign(m.style,{float:"right",marginLeft:"10px",fontWeight:"bold",cursor:"pointer",background:"transparent",border:"none",color:"inherit",padding:"0",font:"inherit"}),m.textContent="\xD7",a.appendChild(m);r.firstChild;)r.removeChild(r.firstChild);r.appendChild(a);let p=null;const g=()=>{p&&clearTimeout(p),m.removeEventListener("click",g),r.remove(),typeof e=="function"&&e(r)};m.addEventListener("click",g);const E=Number(t?.duration)||2500;return p=setTimeout(()=>{m.removeEventListener("click",g),r.remove(),typeof e=="function"&&e(r)},E),typeof p?.unref=="function"&&p.unref(),r}catch(n){return console.error("Emergency toast creation failed:",n),typeof e=="function"&&e(null),null}}async function Nt(t,e){let n;const s="toast";try{return n=await pt("div",s),await Mt(n,t,e),n}catch(o){return console.warn("toast creation failed with error showing fallback one: ",o),n=await Ye(t,e),n}}const le=new Map,re=new Map;function ce(t){if(!t||typeof t!="string")return"bottom-right";const e=t.toLowerCase().trim();if(!e)return"bottom-right";const r=e.replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-");return{"center-top":"top-center","center-bottom":"bottom-center","center-left":"left-center","center-right":"right-center",top:"top-center",bottom:"bottom-center"}[r]||r}function Xe(t){return`toast-container-${ce(t)}`}function Dt(t){if(!t)return;const e=typeof t=="string"&&t.startsWith("toast-container-")?t:Xe(t);le.delete(e),re.delete(e)}function Bt(){return ut()}function Pt(t,e){return t?typeof t.getElementById=="function"?t.getElementById(e):typeof t.querySelector=="function"?t.querySelector(`#${e}`):null:null}function zt(t,e){return!t||!e?!1:e===document.body?t.isConnected&&t.ownerDocument===document:typeof e.contains=="function"?e.contains(t):t.isConnected&&t.ownerDocument===document}function Ve(t){const e=v();t.className="toast-container-base",!e.disableInlineStyles&&(t.style.position="fixed",t.style.zIndex=String(e.zIndex),t.style.pointerEvents="none",t.style.inset="auto 10px 10px auto",t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.flexDirection="column",t.style.overflow="visible")}async function Ge(t={},e){const n=v(),r=Xe(t?.position||n.defaultPosition);let s=Bt();if(!s)throw new Error("Toast container root is unavailable");if(!!(t?.shadowDom??n.shadowDom)&&typeof document<"u"&&typeof document.createElement=="function"){let c=null;try{c=s.querySelector?s.querySelector("#toast-shadow-host"):null}catch{}if(c||(c=document.createElement("div"),c.id="toast-shadow-host",c.style.position="fixed",c.style.zIndex=String(n.zIndex||9999),c.style.pointerEvents="none",c.style.inset="0",c.style.overflow="visible",s.appendChild(c)),!c.shadowRoot&&typeof c.attachShadow=="function")try{c.attachShadow({mode:"open"})}catch{}if(c.shadowRoot&&(s=c.shadowRoot,!s.querySelector("style[data-toast-shadow-style]"))){const l=document.createElement("style");l.setAttribute("data-toast-shadow-style","true"),l.textContent=`
54
+ :host { position: fixed; inset: 0; pointer-events: none; z-index: ${n.zIndex||9999}; }
55
+ * { box-sizing: border-box; }
56
+ .toast-container-base {
57
+ position: fixed;
58
+ z-index: ${n.zIndex||9999};
59
+ pointer-events: none;
60
+ display: flex;
61
+ justify-content: space-between;
62
+ align-items: center;
63
+ flex-direction: column;
64
+ overflow: visible;
65
+ inset: auto 10px 10px auto;
66
+ contain: layout style;
67
+ }
68
+ [data-stacked="true"] .toast-outer-wrapper {
69
+ transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), margin 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease;
70
+ }
71
+ [data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="expanded"] {
72
+ transform: none;
73
+ margin-top: 0px;
74
+ margin-bottom: 10px;
75
+ opacity: 1;
76
+ pointer-events: auto;
77
+ }
78
+ [data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="0"] {
79
+ transform: scale(1);
80
+ margin-top: 0px;
81
+ margin-bottom: 0px;
82
+ opacity: 1;
83
+ z-index: 30;
84
+ pointer-events: auto;
85
+ }
86
+ [data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="1"] {
87
+ transform: scale(0.95) translateY(-10px);
88
+ margin-top: -55px;
89
+ margin-bottom: 0px;
90
+ opacity: 0.9;
91
+ z-index: 20;
92
+ pointer-events: auto;
93
+ }
94
+ [data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="1"] {
95
+ transform: scale(0.95) translateY(10px);
96
+ margin-top: 0px;
97
+ margin-bottom: -55px;
98
+ }
99
+ [data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="2"] {
100
+ transform: scale(0.90) translateY(-20px);
101
+ margin-top: -55px;
102
+ margin-bottom: 0px;
103
+ opacity: 0.75;
104
+ z-index: 10;
105
+ pointer-events: auto;
106
+ }
107
+ [data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="2"] {
108
+ transform: scale(0.90) translateY(20px);
109
+ margin-top: 0px;
110
+ margin-bottom: -55px;
111
+ }
112
+ [data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
113
+ transform: scale(0.85) translateY(-30px);
114
+ margin-top: -55px;
115
+ margin-bottom: 0px;
116
+ opacity: 0;
117
+ z-index: 1;
118
+ pointer-events: none;
119
+ }
120
+ [data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
121
+ transform: scale(0.85) translateY(30px);
122
+ margin-top: 0px;
123
+ margin-bottom: -55px;
124
+ }
125
+ `,s.appendChild(l)}}if(re.has(r))return re.get(r);const i=(async()=>{const c=le.get(r);if(zt(c,s))return c;c&&le.delete(r);let l=Pt(s,r);if(l)Ve(l),typeof e=="function"&&await e(l,t);else{const u=s?.ownerDocument||(typeof document<"u"?document:null);if(!u)throw new Error("Document is unavailable");l=u.createElement("div"),l.id=r,l.setAttribute("role","status"),l.setAttribute("aria-atomic","true"),Ve(l),typeof e=="function"&&await e(l,t),s.appendChild(l)}if(typeof s.querySelectorAll=="function"){const u=s.querySelectorAll(`#${r}`);if(u.length>1)for(let d=1;d<u.length;d++)try{u[d].remove()}catch{}}return le.set(r,l),l})();re.set(r,i);try{return await i}finally{re.delete(r)}}const Ke=new Set(["top-left","top-right","bottom-left","bottom-right","top-center","bottom-center","center-top","center-bottom","left-center","right-center","center-left","center-right","top-full-width","bottom-full-width","center"]),Qe=new Set(["top","bottom"]),Je=[...Ke,...Qe];function Wt(t){return Ke.has(t)}function Rt(t){if(t?.classList)for(let e=0;e<Je.length;e++)t.classList.remove("toast-position-"+Je[e])}async function Ze(t,e={}){if(!t||!e||typeof e!="object")throw new Error("Invalid container or position!");const n=v(),r=String(e?.position||n.defaultPosition||"bottom-right").toLowerCase().trim().replace(/\s+/g,"-");let s=r;if(!Wt(r)&&!Qe.has(r)&&(console.warn(`Unknown position "${e.position}", defaulting to "bottom-right"`),s="bottom-right"),Rt(t),t.classList?.add("toast-position-"+s),v().disableInlineStyles)return;Ft(t);const o=$t(s);Ht(t,o)||jt(t,o)||qt(t,o)}function Ft(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",t.style.maxWidth="calc(100vw - 20px)",t.style.boxSizing="border-box"}function $t(t){const e=t.toLowerCase().trim(),n=e==="top-full-width"||e==="bottom-full-width",r=e.startsWith("top")||e.endsWith("top"),s=e.startsWith("bottom")||e.endsWith("bottom")||e.includes("below"),o=e.startsWith("left")||e.endsWith("left"),i=e.startsWith("right")||e.endsWith("right"),c=e.includes("center");return{hasTop:r,hasBottom:s,hasLeft:o,hasRight:i,hasCenter:c,hasFullWidth:n}}function Ht(t,e){return e.hasFullWidth?(t.style.maxWidth="100vw",e.hasTop?(t.style.top="10px",t.style.left="10px",t.style.right="10px",!0):e.hasBottom?(t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0):!1):!1}function jt(t,e){return e.hasCenter?e.hasTop&&!e.hasLeft&&!e.hasRight?(t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0):e.hasBottom&&!e.hasLeft&&!e.hasRight?(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0):e.hasLeft&&!e.hasTop&&!e.hasBottom?(t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0):e.hasRight&&!e.hasTop&&!e.hasBottom?(t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0):!e.hasLeft&&!e.hasRight&&!e.hasTop&&!e.hasBottom?(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0):!1:!1}function qt(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop?t.style.top="10px":t.style.bottom="10px",e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.left="50%",t.style.transform="translateX(-50%)")}class Ut{constructor(e,n){this.callback=typeof e=="function"?e:()=>{};const r=n===1/0,s=Number.isFinite(n)&&n>=0?n:r?1/0:0;this.delay=s,this.remaining=s,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1,this.isInfinite=r}start(){return this.isCompleted||this.timeoutId||this.isInfinite?this:(this.isPaused=!1,this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null;try{this.callback()}catch(e){console.error("PausableTimer callback error:",e)}},this.remaining),typeof this.timeoutId?.unref=="function"&&this.timeoutId.unref(),this)}pause(){if(this.isPaused||!this.timeoutId||this.isCompleted)return this;clearTimeout(this.timeoutId),this.timeoutId=null;const e=Math.max(0,Date.now()-this.startTime);return this.remaining=Math.min(this.delay,Math.max(0,this.remaining-e)),this.isPaused=!0,this}resume(){return!this.isPaused||this.isCompleted?this:(this.isPaused=!1,this.start(),this)}clear(){return this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.isCompleted=!0,this}getRemainingTime(){return this.isCompleted?0:this.isPaused?this.remaining:this.timeoutId?Math.max(0,this.remaining-(Date.now()-this.startTime)):this.delay}}const $=new Map,W=new Map,D=[];let G=0,ue=0;function Oe(){return{activeCount:$.size,queueDepth:D.length,visibleCount:G,droppedCount:ue,timestamp:Date.now()}}function P(){const t=v();if(typeof t.onMetrics=="function")try{t.onMetrics(Oe())}catch(e){console.error("onMetrics callback error:",e)}}function X(t){if(typeof t?.options?.priority=="number"&&Number.isFinite(t.options.priority))return t.options.priority;const e=t?.priority?.score;if(typeof e=="number"&&Number.isFinite(e))return e;const n=v();if(typeof n.priorityScorer=="function")try{const s=n.priorityScorer({type:t?.options?.type||"info",message:t?.options?.message||"",duration:t?.options?.duration,options:t?.options});if(typeof s=="number"&&Number.isFinite(s))return s;if(s&&typeof s.score=="number"&&Number.isFinite(s.score))return s.score}catch(s){console.warn("[Toast] Custom priorityScorer error, falling back to built-in:",s)}return{error:80,warning:60,info:40,success:20}[t?.options?.type]||0}function K(t){if(!t||!t.children||!(t.getAttribute("data-stacked")==="true"))return;if(!t._stackedInitialized&&typeof t.addEventListener=="function"){t._stackedInitialized=!0;const i=()=>{t._isExpanded=!0,K(t)},c=()=>{t._isExpanded=!1,K(t)},l=()=>{t._isExpanded=!0,K(t)},u=d=>{t.contains(d.relatedTarget)||(t._isExpanded=!1,K(t))};t.addEventListener("mouseenter",i),t.addEventListener("mouseleave",c),t.addEventListener("focusin",l),t.addEventListener("focusout",u),t._stackedCleanup=()=>{t.removeEventListener("mouseenter",i),t.removeEventListener("mouseleave",c),t.removeEventListener("focusin",l),t.removeEventListener("focusout",u),t._stackedInitialized=!1}}if(!t.children||t.children.length===0)return;const n=Array.from(t.children),r=n.length,s=!!t._isExpanded,o=!!(t.id&&t.id.includes("top"));n.forEach((i,c)=>{const l=r-1-c,u=s?"expanded":l>=3?"overflow":String(l);if(typeof i.setAttribute=="function"&&i.setAttribute("data-stacked-depth",u),!v().disableInlineStyles)if(i.style.transition="transform 240ms cubic-bezier(0.16, 1, 0.3, 1), margin 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease",s)i.style.transform="none",i.style.marginTop="0px",i.style.marginBottom="10px",i.style.opacity="1",i.style.zIndex=String(100+c),i.style.pointerEvents="auto";else if(l===0)i.style.transform="scale(1)",i.style.marginTop="0px",i.style.marginBottom="0px",i.style.opacity="1",i.style.zIndex="30",i.style.pointerEvents="auto";else if(l===1){const d=o?10:-10;i.style.transform=`scale(0.95) translateY(${d}px)`,i.style.marginTop=o?"0px":"-55px",i.style.marginBottom=o?"-55px":"0px",i.style.opacity="0.9",i.style.zIndex="20",i.style.pointerEvents="auto"}else if(l===2){const d=o?20:-20;i.style.transform=`scale(0.90) translateY(${d}px)`,i.style.marginTop=o?"0px":"-55px",i.style.marginBottom=o?"-55px":"0px",i.style.opacity="0.75",i.style.zIndex="10",i.style.pointerEvents="auto"}else{const d=o?30:-30;i.style.transform=`scale(0.85) translateY(${d}px)`,i.style.marginTop=o?"0px":"-55px",i.style.marginBottom=o?"-55px":"0px",i.style.opacity="0",i.style.zIndex="1",i.style.pointerEvents="none"}})}function Yt(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return e>>>0}function Xt(t={}){const e=t&&typeof t=="object"?t:{};if(e.id!==void 0&&e.id!==null&&e.id!=="")return String(e.id);if(e.tag!==void 0&&e.tag!==null&&e.tag!==""){const o=ce(e.position||"bottom-right");return`tag:${String(e.tag).trim()}:${o}`}if(e.groupId!==void 0&&e.groupId!==null&&e.groupId!==""){const o=ce(e.position||"bottom-right");return`group:${String(e.groupId).trim()}:${o}`}const n=String(e.type||"info").trim().toLowerCase(),r=Yt(String(e.message||"")).toString(16),s=ce(e.position||"bottom-right");return`${n}|${r}|${s}`}async function Vt(t={}){try{const e=Xt(t);if($.has(e)){const r=$.get(e);if(!r)throw new Error(`Active toast with key ${e} not found`);return r.count++,(t.tag||t.groupId)&&t.message&&r.toast?._messageSpan&&(r.toast._messageSpan.textContent=String(t.message),r.toast._messageSpan.title=String(t.message)),r.timer?.clear(),r.timer=ne(r.toast,t),await de(r),await Ee(r),P(),e}if(W.has(e)){const r=W.get(e);if(!r)throw new Error(`Pending toast with key ${e} not found`);return r.count++,(t.tag||t.groupId)&&t.message&&(r.options={...r.options,...t}),e}const n={options:t,count:1,rafId:0};return W.set(e,n),n.rafId=requestAnimationFrame(async()=>{const r=W.get(e);if(r){if(W.delete(e),G>=v().maxVisible){const s={options:r.options,key:e,count:r.count},o=v().maxQueueSize??100;if(o<=0){ue++,P();return}const i=D.find(l=>l.key===e);if(i){i.count+=r.count,typeof r.options?.priority=="number"&&(i.options={...i.options,...r.options},i.priority={score:X(i)}),P();return}const c=typeof r.options?.priority=="number"||typeof v().priorityScorer=="function"||D.some(l=>typeof l?.options?.priority=="number");if(c&&(s.priority={score:X(s)}),D.length>=o){if(c){const l=X(s);let u=0,d=X(D[0]);for(let a=1;a<D.length;a++){const f=X(D[a]);f<d&&(u=a,d=f)}if(l<=d){ue++,P();return}D.splice(u,1)}else D.shift();ue++}D.push(s),c&&D.sort((l,u)=>X(u)-X(l)),P(),await tt();return}try{await et(r.options,e,r.count)}catch(s){console.error("showToast failed:",s)}}}),e}catch(e){console.error("showToast failed:",e)}}async function et(t,e,n){try{if(!t||typeof t!="object")throw new TypeError("options must be an object");G++;const r=await Ge(t,Ze);if(!r)throw new Error("Failed to create toast container");const s=await Nt(t,V);if(!s)throw new Error("Toast element creation failed");const o=document.createElement("div");o.className="toast-outer-wrapper",v().disableInlineStyles||Object.assign(o.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%",pointerEvents:"auto"});const i=document.createElement("div");i.className="toast-inner-wrapper",v().disableInlineStyles||Object.assign(i.style,{position:"relative",overflow:"hidden",zIndex:"1"}),i.appendChild(s),o.appendChild(i),r.id.includes("toast-container-")&&(r.appendChild(o),t.stacked&&r.setAttribute("data-stacked","true"),r.getAttribute("data-stacked")==="true"&&K(r)),Tt(s);const c=t.pauseOnHover!==!1&&(t.pauseOnHover===!0||!!t.cta||!!v().pauseOnHover),l={outer:o,toast:s,options:t,count:Math.max(1,Math.floor(n??0)),pauseOnHover:c};$.set(e,l),s._key=e,P(),l.count>1&&await Ee(l),l.timer=ne(s,t),await de(l)}catch(r){console.error("Something went wrong: ",r),G=Math.max(0,G-1),P(),(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(await Ye(t,V))}}async function Gt(){try{if(W.size>0){const[r,s]=Array.from(W.entries()).at(-1);s?.rafId&&cancelAnimationFrame(s.rafId),W.delete(r),P();return}if($.size===0){if(D.length>0){D.pop(),P();return}return}let t=null;const e=Array.from($.values());if(e.length>0){const r=e.at(-1);t=r.toast||r.outer&&r.outer.querySelector('[id^="toast-"]')}if(t||document.querySelectorAll('[id^="toast-container-"]').forEach(s=>{const o=Array.from(s.children||[]);if(o.length===0)return;const i=o.at(-1);i&&(t=i.querySelector('[id^="toast-"]')||i)}),!t)return;const n=t._key?t:t.querySelector('[id^="toast-"]')||t;await V(n)}catch(t){console.error("dismissMostRecent failed:",t)}}async function Kt(){try{for(const[,e]of W)e?.rafId&&cancelAnimationFrame(e.rafId);W.clear(),D.length=0,P();const t=Array.from($.values()).map(e=>e.toast).filter(Boolean);await Promise.allSettled(t.map(async e=>{try{await V(e)}catch(n){console.warn("closeAllToasts: failed to close one toast:",n)}}))}catch(t){console.error("closeAllToasts failed:",t)}}const Ce=Gt,Qt=Kt;function ne(t,e){const n=Number(e?.duration);if(e?.duration===1/0||typeof e?.duration=="number"&&e?.duration<=0)return null;const s=(Number.isFinite(n)&&n>0?n:2500)+5,o=new Ut(()=>{V(t).catch(console.error)},s);return o.start(),o}async function de(t){if(!t.pauseOnHover||!t.outer||!t.timer)return;t.outer._pauseCleanup?.();const{outer:e,timer:n,toast:r}=t,s=()=>{if(r?._progressAnimation)try{r._progressAnimation.pause()}catch{}else if(r?._progressBar)try{if(r._progressBar._isIndeterminate)r._progressBar.style.animationPlayState="paused";else if(!r._progressBar._isManualProgress){const d=window.getComputedStyle(r._progressBar).width;r._progressBar._pausedWidth=d,r._progressBar.style.transition="none",r._progressBar.style.width=d}}catch{}},o=()=>{if(r?._progressAnimation)try{r._progressAnimation.play()}catch{}else if(r?._progressBar)try{if(r._progressBar._isIndeterminate)r._progressBar.style.animationPlayState="running";else if(!r._progressBar._isManualProgress){if(r._progressBar._pausedWidth){const d=n.getRemainingTime?.()??1e3,a=r._progressBar._isReverse,f=r._progressBar._finalWidth||"100%";r._progressBar.style.transition=`width ${Math.max(0,d)}ms linear`,r._progressBar.offsetWidth,r._progressBar.style.width=a?f:"0%",r._progressBar._pausedWidth=null}}}catch{}},i=()=>{n.pause(),s(),r?._pauseUndo?.(),r?.classList.add("toast-paused")},c=()=>{n.resume(),o(),r?._resumeUndo?.(),r?.classList.remove("toast-paused")},l=d=>{d?.target&&typeof d.target.matches=="function"&&d.target.matches("[tabindex], div, span, button, a")&&(n.pause(),s(),r?._pauseUndo?.(),r?.classList.add("toast-paused"))},u=d=>{e.contains(d.relatedTarget)||(n.resume(),o(),r?._resumeUndo?.(),r?.classList.remove("toast-paused"))};e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",c),e.addEventListener("focusin",l),e.addEventListener("focusout",u),e._pauseCleanup=()=>{e.removeEventListener("mouseenter",i),e.removeEventListener("mouseleave",c),e.removeEventListener("focusin",l),e.removeEventListener("focusout",u)}}async function V(t){if(t?._key)return oe(t._key)}async function oe(t){try{if(!t)return;const e=$.get(t),n=W.get(t);if(n){cancelAnimationFrame(n.rafId),W.delete(t),P();return}const r=D.findIndex(u=>u.key===t);if(r!==-1){D.splice(r,1),P();return}if(!e)return;if(e.timer?.clear(),e.outer?._pauseCleanup?.(),e.toast?._cleanupCloseButton?.(),e.toast?._cleanupCTA?.(),e.toast?._cleanupUndo?.(),e.toast?._cleanupSwipe?.(),e.toast?._cleanupFocusTrap?.(),e.toast?._cleanup?.(),e.toast?._progressAnimation)try{e.toast._progressAnimation.pause()}catch{}const s=e.outer?.querySelector(".toast-count-badge");s?._scaleTimer&&(clearTimeout(s._scaleTimer),s._scaleTimer=null),e.toast?.querySelector("button, a")?._cleanup?.(),$.delete(t),G=Math.max(0,G-1),P(),s&&s.remove();const i=e.toast?._animationDuration??400,c=Math.min(i,300);if(e.toast){if(!v().disableInlineStyles){const u=String(e.options?.position||e.outer?.parentElement?.id||"").toLowerCase(),d=u.includes("top"),a=u.includes("left"),f=u.includes("right"),m=String(e.options?.animationType||"").toLowerCase().trim();let p="translateY(20px)";if(q())e.toast.style.transition="none",e.toast.style.opacity="0";else{m==="fade"?p="none":m==="pop"?p="scale(0.6)":m==="zoom"||m==="scale"?p="scale(0.75)":m==="flip"?p="perspective(600px) rotateX(-45deg)":m==="slide"?p=a?"translateX(-100%)":f?"translateX(100%)":d?"translateY(-100%)":"translateY(100%)":m==="bounce"?p=d?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":(e.options?.spring||m==="spring")&&(p=d?"translateY(-28px) scale(0.94)":"translateY(28px) scale(0.94)");const g=typeof e.options?.animationEasing=="string"&&e.options.animationEasing.trim()?e.options.animationEasing.trim():e.options?.spring||m==="spring"?"cubic-bezier(0.16, 1, 0.3, 1)":"ease-in";e.toast.style.transition=`opacity ${c}ms ${g}, transform ${c}ms ${g}`,e.toast.style.opacity="0",e.toast.style.transform=p}}e.toast.classList.remove("active")}const l=e.outer?.parentElement;if(await Jt(e.outer,e.toast,c),l&&l.children.length===0&&l.id?.startsWith("toast-container-"))try{l._stackedCleanup?.(),Dt(l.id),l.remove()}catch{}else l&&l.getAttribute("data-stacked")==="true"&&K(l);await tt()}catch(e){console.error("Closing Toast failed!: ",e)}}let Te=!1;async function tt(){if(!Te){Te=!0;try{const t=v();for((t.priorityQueue||typeof t.priorityScorer=="function"||D.some(e=>e.options?.priorityQueue||typeof e.options?.priority=="number"))&&D.length>1&&D.sort((e,n)=>X(n)-X(e));G<t.maxVisible&&D.length;){const e=D.shift();if($.has(e.key)){const n=$.get(e.key);n.count+=e.count,(e.options.tag||e.options.groupId)&&e.options.message&&n.toast?._messageSpan&&(n.toast._messageSpan.textContent=String(e.options.message),n.toast._messageSpan.title=String(e.options.message),n.timer?.clear(),n.timer=ne(n.toast,e.options)),await Ee(n),P();continue}await et(e.options,e.key,e.count)}P()}finally{Te=!1}}}async function Jt(t,e,n=400){return t?new Promise(r=>{let s=!1,o=null;const i=e||t.firstElementChild||t,c=()=>{if(!s){s=!0,o&&(clearTimeout(o),o=null);try{i?.removeEventListener?.("transitionend",l,!0)}catch{}yt(t).catch(console.error),r()}};if(q()||n<=0){c();return}const l=d=>{try{if(d.target!==i)return;(d.propertyName==="transform"||(!i.style.transform||i.style.transform==="none"||i.style.transform==="initial")&&d.propertyName==="opacity")&&c()}catch(a){console.error("removeWithTransition error:",a)}};if(!i)return c();try{i.addEventListener("transitionend",l,!0)}catch(d){console.error("removeWithTransition error:",d)}const u=n+100;o=setTimeout(c,u),typeof o?.unref=="function"&&o.unref()}):Promise.resolve()}async function Ee({outer:t,count:e}){if(!t||!(t instanceof HTMLElement))throw new Error("updateBadge: outer must be a valid HTMLElement");if(e<2){const r=t.querySelector(".toast-count-badge");r&&r.remove();return}let n=t.querySelector(".toast-count-badge");n||(n=document.createElement("span"),n.className="toast-count-badge",n.setAttribute("aria-label",`${e} identical notifications`),v().disableInlineStyles||Object.assign(n.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),t.appendChild(n)),n.textContent=e>99?"99+":String(e);try{q()||(n._scaleTimer&&clearTimeout(n._scaleTimer),n.style.transform="scale(1.2)",n._scaleTimer=setTimeout(()=>{n.style.transform="scale(1)",n._scaleTimer=null},150),typeof n._scaleTimer?.unref=="function"&&n._scaleTimer.unref())}catch(r){console.error("updateBadge animation error:",r)}}async function rt(t,e={}){if(!t||typeof e!="object"||e===null)return;if(W.has(t)){const a=W.get(t);a.options={...a.options,...e};return}const n=D.find(a=>a.key===t);if(n){n.options={...n.options,...e};return}const r=$.get(t);if(!r||!r.toast)return;const s={...r.options};r.options={...r.options,...e};const o=r.toast,i=o._messageSpan||o.querySelector(".toast-message")||o.querySelector("span:not(.toast-count-badge)");if(e.message!==void 0){const a=String(e.message??""),f=e.allowHtml!==void 0?!!e.allowHtml:!!r.options.allowHtml,m=(e.type==="success"||e.type==="error"||e.type==="warning"||e.type==="info")&&e.showLoader!==!0;if(i){const p=i.querySelector(".toast-loader");if(i.innerHTML="",p&&e.showLoader!==!1&&e.loader!==null&&!m){i.appendChild(p);const g=document.createElement("span");g.style.display="inline-block",g.style.width="8px",i.appendChild(g)}if(f&&a.trim().length>0)try{const g=we(a),E=document.createElement("div");for(E.innerHTML=g;E.firstChild;)i.appendChild(E.firstChild)}catch{i.appendChild(document.createTextNode(a))}else i.appendChild(document.createTextNode(a));i.setAttribute("title",i.textContent||"")}}const c=(e.type==="success"||e.type==="error"||e.type==="warning"||e.type==="info")&&e.showLoader!==!0;if(e.showLoader===!1||e.loader===null||c){const a=i?.querySelector(".toast-loader");a&&(a.nextSibling&&a.nextSibling.nodeName==="SPAN"&&a.nextSibling.remove(),a.remove())}else if((e.showLoader===!0||e.loader&&typeof e.loader=="object")&&i&&!i.querySelector(".toast-loader")){const a=Pe(e.loader||{});i.insertBefore(a,i.firstChild);const f=document.createElement("span");f.style.display="inline-block",f.style.width="8px",i.insertBefore(f,a.nextSibling)}if(e.type){const a=String(e.type).toLowerCase().trim();o.className=o.className.replace(/\btoast-(info|success|error|warning)\b/g,`toast-${a}`);const f=a==="error";if(e.role?o.setAttribute("role",e.role):o.setAttribute("role","alert"),o.setAttribute("aria-live",e.ariaLive||(f?"assertive":"polite")),!e.backgroundColor){const m={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"};m[a]&&(o.style.background=m[a],o.style.backgroundColor=m[a])}}if(e.icon!==void 0||e.type!==void 0){const a=o?.querySelector(".toast-icon");a&&a.remove();const f={...r.options,...e},m=Ue(f);m&&(i?o.insertBefore(m,i):o.appendChild(m))}if(e.backgroundColor&&(o.style.background=e.backgroundColor,o.style.backgroundColor=e.backgroundColor),e.textColor)o.style.color=e.textColor,i&&(i.style.color=e.textColor);else if(e.type||e.backgroundColor){const a=o.style.backgroundColor||o.style.background;if(a){const f=Z(a);o.style.color=f,i&&(i.style.color=f)}}if(e.borderRadius!==void 0){const a=typeof e.borderRadius=="number"?`${e.borderRadius}px`:e.borderRadius;o.style.borderRadius=a}if(e.maxWidth!==void 0){const a=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth;o.style.maxWidth=a}if(e.fontDirection!==void 0){const a=e.fontDirection!=="auto"?e.fontDirection:"";o.style.direction=a,i&&(i.style.direction=a);const f=a==="rtl";o.querySelectorAll(".toast-cta, .toast-undo-btn, .toast-close-btn").forEach(m=>{m.style.marginLeft=f?"0px":"10px",m.style.marginRight=f?"10px":"0px"})}if(e.fontSize!==void 0){const a=typeof e.fontSize=="number"?`${e.fontSize}px`:e.fontSize;o.style.fontSize=a,i&&(i.style.fontSize=a)}if(e.fontFamily!==void 0&&(o.style.fontFamily=e.fontFamily,i&&(i.style.fontFamily=e.fontFamily)),e.fontWeight!==void 0){const a=typeof e.fontWeight=="number"?String(e.fontWeight):e.fontWeight;o.style.fontWeight=a,i&&(i.style.fontWeight=a)}if(e.fontLineHeight!==void 0&&(o.style.lineHeight=e.fontLineHeight,i&&(i.style.lineHeight=e.fontLineHeight)),e.fontPadding!==void 0&&i&&(i.style.padding=e.fontPadding),e.wrapText!==void 0&&i&&(e.wrapText==="truncate"||e.wrapText==="ellipsis"||e.wrapText===!1||!e.wrapText?(i.classList.add("is-truncated"),v().disableInlineStyles||Object.assign(i.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"normal",overflow:"hidden",textOverflow:"ellipsis"})):(i.classList.remove("is-truncated"),v().disableInlineStyles||Object.assign(i.style,{display:"block",WebkitBoxOrient:"",WebkitLineClamp:"",whiteSpace:"normal",overflow:"visible",textOverflow:"clip"}))),e.role!==void 0&&o.setAttribute("role",e.role),e.ariaLive!==void 0&&o.setAttribute("aria-live",e.ariaLive),e.className!==void 0){const a=s.className;a&&typeof a=="string"&&o.classList.remove(...a.trim().split(/\s+/)),e.className&&typeof e.className=="string"&&o.classList.add(...e.className.trim().split(/\s+/))}let l=o.querySelector(".toast-progress-bar");if(e.showProgressBar===!1){if(o._progressAnimation){try{o._progressAnimation.cancel()}catch{}o._progressAnimation=null}l&&l.remove(),o._progressBar=null,l=null}else!l&&e.showProgressBar!==!1&&(e.progress!==void 0||e.showProgressBar===!0||e.duration&&Number(e.duration)>0||r.options.duration&&Number(r.options.duration)>0)&&(je(o,{...r.options,...e,showProgressBar:!0}),l=o.querySelector(".toast-progress-bar"));if(l){if(e.progress!==void 0)if(e.progress==="indeterminate"){if(l._isIndeterminate=!0,l._isManualProgress=!1,o._progressAnimation){try{o._progressAnimation.cancel()}catch{}o._progressAnimation=null}l.classList.add("toast-progress-bar-indeterminate");const a=l._isRtl||e.fontDirection==="rtl"||e.progressDirection==="rtl";if(a&&l.classList.add("toast-progress-bar-indeterminate-rtl"),!v().disableInlineStyles){$e();const f=a?"toast-progress-indeterminate-rtl":"toast-progress-indeterminate";l.style.animation=`${f} 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite`}l.style.width=l._finalWidth||"100%"}else{const a=He(e.progress,o,{...r.options,...e});l._isIndeterminate=!1,l._isManualProgress=!0,l.classList.remove("toast-progress-bar-indeterminate"),l.classList.remove("toast-progress-bar-indeterminate-rtl"),l.style.animation="none";const f=typeof window<"u"&&window.getComputedStyle?window.getComputedStyle(l).width:null;if(o._progressAnimation){try{o._progressAnimation.cancel()}catch{}o._progressAnimation=null}f&&(l.style.transition="none",l.style.width=f,l.offsetWidth),l.style.transition="width 200ms ease",l.style.width=`${a}%`}if((e.progressBarColor||e.progressColor)&&(l.style.background=e.progressBarColor||e.progressColor),e.progressPosition&&(l.style.top=e.progressPosition==="top"?"0":"auto",l.style.bottom=e.progressPosition==="bottom"?"0":"auto"),e.progressHeight!==void 0){const a=typeof e.progressHeight=="number"?`${e.progressHeight}px`:e.progressHeight;l.style.height=a}}if(e.animationType!==void 0&&(r.options.animationType=e.animationType,o._animationType=e.animationType),e.spring!==void 0&&(r.options.spring=e.spring),e.swipeToDismiss!==void 0&&(r.options.swipeToDismiss=e.swipeToDismiss,e.swipeToDismiss===!1?(o._cleanupSwipe?.(),o._cleanupSwipe=null):e.swipeToDismiss===!0&&!o._cleanupSwipe&&qe(o,V)),e.duration!==void 0){r.timer?.clear();const a=Number(e.duration);if(Number.isFinite(a)&&a>0){if(r.timer=ne(o,{duration:a}),await de(r),l&&(e.progress===void 0&&(l._isManualProgress=!1),!l._isManualProgress&&!l._isIndeterminate)){const f=a+5;if(o._progressAnimation){try{o._progressAnimation.cancel()}catch{}const m=l._isReverse,p=l._finalWidth||"100%",g=m?[{width:"0%"},{width:p}]:[{width:p},{width:"0%"}];o._progressAnimation=l.animate(g,{duration:f,easing:"linear",fill:"forwards",delay:0})}else{l.style.transition=`width ${f}ms linear`;const m=l._isReverse,p=l._finalWidth||"100%";l.style.width=m?p:"0%"}}if(o.classList.contains("toast-paused")&&(r.timer.pause(),o._progressAnimation))try{o._progressAnimation.pause()}catch{}}else if(r.timer=null,l&&!l._isManualProgress&&!l._isIndeterminate){if(o._progressAnimation){try{o._progressAnimation.cancel()}catch{}o._progressAnimation=null}l.style.width="0%"}}else(r.options.duration===0||!r.timer)&&(e.type==="success"||e.type==="error"||e.type==="warning"||e.showLoader===!1)&&(r.options.duration=2500,r.timer?.clear(),r.timer=ne(o,{duration:2500}),await de(r));if(e.cta!==void 0&&(o._cleanupCTA&&(o._cleanupCTA(),o._cleanupCTA=null),o.querySelectorAll(".toast-cta").forEach(a=>a.remove()),e.cta&&typeof e.cta=="object")){const a={...r.options,...e};ze(o,a,V)}if(e.undo!==void 0&&(o._cleanupUndo&&(o._cleanupUndo(),o._cleanupUndo=null),o.querySelectorAll(".toast-undo-btn").forEach(a=>a.remove()),e.undo)){const a={...r.options,...e};We(o,a,V)}if(e.showCloseButton!==void 0){const a=o.querySelector(".toast-close-btn");if(e.showCloseButton===!1)o._cleanupCloseButton&&(o._cleanupCloseButton(),o._cleanupCloseButton=null),a&&a.remove();else if(e.showCloseButton===!0&&!a){const f={...r.options,...e};Re(o,f,V)}}if(e.sound!==void 0?!!e.sound:!!(e.type&&(r.options.sound||v().sound))){if(typeof e.sound=="string"&&typeof window<"u"&&typeof window.Audio=="function")try{new window.Audio(e.sound).play().catch(()=>{})}catch{}else if(typeof e.onSound=="function")try{e.onSound(e)}catch{}}const d=o.closest('[id^="toast-container-"]');d&&(e.stacked===!0?(d.setAttribute("data-stacked","true"),K(d)):e.stacked===!1?(d.removeAttribute("data-stacked"),d._stackedCleanup?.(),Array.from(d.children).forEach(a=>{a.removeAttribute("data-stacked-depth"),a.style.transform="",a.style.marginTop="",a.style.marginBottom="10px",a.style.opacity="",a.style.zIndex="",a.style.pointerEvents="auto"})):d.getAttribute("data-stacked")==="true"&&K(d))}let Ae={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"};const Zt={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!",loading:"Loading, please wait..."};let ke={},Le=!1,_e=null;async function Ot(){if(!Le&&!(typeof window>"u"||typeof document>"u")){if(document.readyState==="complete"||document.readyState==="interactive"){Le=!0;return}_e||(_e=new Promise(t=>{document.addEventListener("DOMContentLoaded",()=>{Le=!0,t()},{once:!0})})),await _e}}async function er(t={}){try{const e=await nr(t);return await rr(e),await Vt(e)}catch(e){return console.error("CreateToast failed:",e),null}}async function tr(t={}){return typeof window<"u"&&typeof document<"u"?(await Ot(),await er(t)):(console.warn("ToastNotification: running in non-browser environment, no DOM available."),null)}async function rr(t){try{return await Ge(t,Ze)}catch(e){return console.error("Failed to create toast container:",e),v().targetNode||document.body}}function Q(t,e){const n=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{...n,message:String(t)}:t instanceof Error?{...n,message:t.message||String(t)}:typeof t=="object"&&t!==null&&!Array.isArray(t)?{...n,...t}:{...n}}async function nr(t){const e=Q(t),n=v(),r=String(e?.position??n.defaultPosition).toLowerCase().trim(),s=r?.includes("top-full-width")||r?.includes("bottom-full-width")?"100vw":"400px",i={...{allowHtml:!1,sanitizeHtml:!0,pauseOnHover:void 0,duration:2500,position:n.defaultPosition,type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressBarColor:void 0,progressHeight:"4px",progressPosition:"bottom",progressDirection:"decreasing",animationType:"default",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:s},...e};i.message=e?.message??i.message;try{if(!i.backgroundColor){const c=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)")?.matches;i.backgroundColor=Ae?.[i.type]??(c?"#f5f5f5":"#111111")}}catch(c){console.warn("Background color resolution failed:",c),i.backgroundColor||(i.backgroundColor="#111111")}try{i.message=i.message||ke[i.type]||Zt[i.type]||"No Message Provided!"}catch(c){console.warn("Default message resolution failed:",c)}try{!i.textColor&&i.backgroundColor&&(i.textColor=Z(i.backgroundColor))}catch(c){console.warn("Text color resolution failed:",c)}try{const c=e?.progressBarColor||e?.progressColor;c?(i.progressColor=c,i.progressBarColor=c):!i.progressColor&&i.backgroundColor&&(i.progressColor=i.textColor||Z(i.backgroundColor),i.progressBarColor=i.progressColor)}catch(c){console.warn("Progress bar color resolution failed:",c)}return typeof i.message!="string"&&(i.message="No Message Provided!"),i}function or(t){try{if(t&&typeof t=="object"&&!Array.isArray(t)){const e=["success","error","warning","info"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(Ae={...Ae,...n})}}catch(e){console.error("setDefaultColors failed:",e)}}function ir(t){try{if(t&&typeof t=="object"&&!Array.isArray(t)){const e=["success","error","warning","info"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(ke={...ke,...n})}}catch(e){console.error("setDefaultMessages failed:",e)}}let J=!1,H=null;async function sr(t){if(J&&H)try{await H}catch(e){console.warn("Previous close operation failed (continuing anyway):",e)}return t()}const ar=tr;async function A(t={},e){const n=Q(t,e),r=await sr(()=>ar(n));return{id:r,dismiss:()=>r?oe(r):Promise.resolve(),update:s=>r?rt(r,s):Promise.resolve()}}A.success=(t,e)=>{const n=Q(t,e);return A({...n,type:"success"})},A.error=(t,e)=>{const n=Q(t,e);return A({...n,type:"error"})},A.warning=(t,e)=>{const n=Q(t,e);return A({...n,type:"warning"})},A.info=(t,e)=>{const n=Q(t,e);return A({...n,type:"info"})},A.loading=(t,e)=>{const n=Q(t,e);return A({type:"info",showLoader:!0,duration:0,showProgressBar:!1,pauseOnHover:!1,...n})},A.custom=(t,e)=>{const n=Q(t,e);return A({allowHtml:!0,...n})};const lr=A.success,cr=A.error,ur=A.warning,dr=A.info,fr=A.loading,mr=A.custom,fe=async t=>{let e=t;if(t&&typeof t.then=="function")try{e=await t}catch{return}J=!0,H=(async()=>{try{typeof e=="string"&&e.length>0?await oe(e):e&&typeof e=="object"?typeof e.dismiss=="function"?await e.dismiss():e._key&&typeof e._key=="string"?await oe(e._key):e.id&&typeof e.id=="string"?await oe(e.id):await Ce():await Ce()}finally{J=!1,H=null}})(),await H},O=async()=>{J=!0,H=(async()=>{try{await Qt()}finally{J=!1,H=null}})(),await H},nt=O,ot=O,it=1440*60*1e3;async function ie(t,e={},n={}){const r=e&&typeof e=="object"?e:{},s=n&&typeof n=="object"?n:{},o=r.loading??"Loading...",i=typeof o=="object"&&o!==null&&!Array.isArray(o)?{...s,type:"info",duration:it,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0,...o}:{...s,type:"info",message:String(o),duration:it,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0},c=await A(i),l={...s,pauseOnHover:s.pauseOnHover};try{const d=await(typeof t=="function"?t():t),a=typeof r.success=="function"?r.success(d):r.success??"Done!",f=typeof a=="object"&&a!==null&&!Array.isArray(a)?{...l,type:"success",showLoader:!1,...a}:{...l,type:"success",showLoader:!1,message:String(a)};return c&&typeof c.update=="function"&&await c.update(f),d}catch(u){const d=typeof r.error=="function"?r.error(u):r.error??"Something went wrong.",a=typeof d=="object"&&d!==null&&!Array.isArray(d)?{...l,type:"error",showLoader:!1,...d}:{...l,type:"error",showLoader:!1,message:String(d)};throw c&&typeof c.update=="function"&&await c.update(a),u}}A.promise=ie,A.dismiss=fe,A.dismissAll=O,A.clear=O;const pr="4.0.1";function st(t=typeof window<"u"?window:null){if(!t||!t.document||t.__customizableToastEscapeAttached)return;t.__customizableToastEscapeAttached=!0;const e=n=>{if(n.key==="Escape"||n.key==="Esc")(async()=>{try{J=!0,H=(async()=>{try{await Ce()}finally{J=!1,H=null}})(),await H}catch(r){console.error("Escape key dismiss failed:",r),J=!1,H=null}})();else if(n.key==="F6"||(n.altKey||n.metaKey)&&(n.key==="t"||n.key==="T")){const s=(v().targetNode&&typeof v().targetNode.querySelectorAll=="function"?v().targetNode:t.document).querySelectorAll('[id^="toast-container-"] [id^="toast-"]');if(s.length>0){const o=s[s.length-1],i=o.querySelector("button, a, [tabindex='0']");i&&typeof i.focus=="function"?i.focus():typeof o.focus=="function"&&o.focus()}}};t.addEventListener("keydown",e,{passive:!0})}typeof window<"u"&&typeof document<"u"&&st(window);try{typeof window<"u"&&(window.customizableToast={setConfig:ye,getConfig:v,resetConfig:he,shouldReduceMotion:q,version:pr,createToast:A,success:lr,error:cr,warning:ur,info:dr,loading:fr,custom:mr,setDefaultColors:or,setDefaultMessages:ir,noop:O,dismiss:fe,dismissAll:O,clear:O,toastPromise:ie,promise:ie,updateToastByKey:rt,generateToastId:Ne,resetToastIdCounter:mt,getToastMetrics:Oe,initKeyboardShortcuts:st})}catch(t){console.error("Global assignment failed:",t)}class ee{success(e,n){return A.success(e,n)}error(e,n){return A.error(e,n)}warning(e,n){return A.warning(e,n)}info(e,n){return A.info(e,n)}loading(e,n){return A.loading(e,n)}custom(e,n){return A.custom(e,n)}show(e){return A(e)}promise(e,n,r){return ie(e,n,r)}dismiss(e){return fe(e)}dismissAll(){return ot()}clear(){return nt()}setConfig(e){return ye(e)}getConfig(){return v()}resetConfig(){return he()}}ee.\u0275fac=function(e){return new(e||ee)},ee.\u0275prov={token:ee,providedIn:"root",factory:ee.\u0275fac};let Ie=null;function at(){return Ie||(Ie=new ee),Ie}const yr=at();export{ee as ToastService,nt as clear,A as createToast,fe as dismiss,ot as dismissAll,v as getConfig,at as injectToast,he as resetConfig,ye as setConfig,yr as toast,ie as toastPromise};
126
+ //# sourceMappingURL=angular.esm.mjs.map