customizable-toast-notification 3.20.1 → 4.0.0
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.
- package/CHANGELOG.md +29 -0
- package/README.md +56 -132
- package/dist/angular.cjs +117 -0
- package/dist/angular.cjs.map +1 -0
- package/dist/angular.d.ts +44 -0
- package/dist/angular.esm.mjs +117 -0
- package/dist/angular.esm.mjs.map +1 -0
- package/dist/index.cjs +106 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.d.ts +0 -12
- package/dist/index.css.map +2 -2
- package/dist/index.d.ts +28 -630
- package/dist/index.esm.mjs +105 -4
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +105 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/react.cjs +117 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +44 -0
- package/dist/react.esm.mjs +117 -0
- package/dist/react.esm.mjs.map +1 -0
- package/dist/solid.cjs +117 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.ts +45 -0
- package/dist/solid.esm.mjs +117 -0
- package/dist/solid.esm.mjs.map +1 -0
- package/dist/svelte.cjs +117 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.ts +50 -0
- package/dist/svelte.esm.mjs +117 -0
- package/dist/svelte.esm.mjs.map +1 -0
- package/dist/vue.cjs +117 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.ts +45 -0
- package/dist/vue.esm.mjs +117 -0
- package/dist/vue.esm.mjs.map +1 -0
- package/package.json +20 -28
|
@@ -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,117 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Customizable Toast Notifications
|
|
3
|
+
* Build: 2026-10-27 09:46:57
|
|
4
|
+
* Cache-Buster: 1793094417148
|
|
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}),I={...Me};function ut(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:h,trapFocus:x,priorityScorer:S,onMetrics:E,debug:M}=t;if(h!==void 0&&(I.shadowDom=!!h),x!==void 0&&(I.trapFocus=!!x),M!==void 0&&(I.debug=!!M),e!==void 0){const g=Number(e);Number.isFinite(g)&&g>0&&(I.maxVisible=Math.max(1,Math.floor(g)))}if(n!==void 0){const g=Number(n);Number.isFinite(g)&&g>=0&&(I.maxQueueSize=Math.floor(g))}if(r!==void 0){const g=Number(r);Number.isFinite(g)&&(I.zIndex=Math.trunc(g))}if(s!==void 0&&(I.targetNode=s&&typeof s=="object"&&typeof s.appendChild=="function"?s:null),o!==void 0&&(I.disableInlineStyles=!!o),i!==void 0){const g=String(i||"auto").toLowerCase();["auto","always","never"].includes(g)&&(I.reducedMotion=g,typeof document<"u"&&(g==="always"?document.documentElement.setAttribute("data-toast-reduced-motion","always"):g==="never"?document.documentElement.setAttribute("data-toast-reduced-motion","never"):document.documentElement.removeAttribute("data-toast-reduced-motion")))}if(c!==void 0){const g=String(c||"").toLowerCase().trim();g&&(I.defaultPosition=g)}if(l!==void 0){const g=String(l||"light").toLowerCase();["light","dark","high-contrast","compact","spacious","glass"].includes(g)&&(I.theme=g,typeof document<"u"&&document.documentElement.setAttribute("data-toast-theme",g))}return u!==void 0&&(I.stacked=!!u),d!==void 0&&(I.swipeToDismiss=!!d),a!==void 0&&(I.sound=!!a),f!==void 0&&(I.icon=!!f),m!==void 0&&(I.pauseOnHover=!!m),p!==void 0&&(I.priorityQueue=!!p),S!==void 0&&(I.priorityScorer=typeof S=="function"?S:null),E!==void 0&&(I.onMetrics=typeof E=="function"?E:null),v()}function he(){return Object.assign(I,Me),typeof document<"u"&&(document.documentElement.removeAttribute("data-toast-theme"),document.documentElement.removeAttribute("data-toast-reduced-motion")),v()}function v(){return{...I}}function dt(){return ut(I.targetNode)?I.targetNode:typeof document<"u"?document.body:null}function q(){if(I.reducedMotion==="always")return!0;if(I.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 ft(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 mt=ft();function pt(){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}-${mt}${s}`}async function yt(t,e){const n=document.createElement(t);return n.id=Ne(e),n}async function ht(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 gt(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 bt{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 bt(200),vt={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(vt).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 y=be[t.toLowerCase()];return ge.set(e,y),y}let r,s,o;function i(y){if(typeof y!="string")return y;let b=y.trim(),w=0;for(;b.toLowerCase().startsWith("var(")&&b.endsWith(")")&&w<5;){w++;const A=b.slice(4,-1).trim(),k=A.indexOf(","),B=(k===-1?A:A.slice(0,k)).trim(),R=k===-1?"":A.slice(k+1).trim();if(!B.startsWith("--"))return b;let F="";try{typeof document<"u"&&typeof getComputedStyle=="function"&&(F=getComputedStyle(document.documentElement).getPropertyValue(B).trim())}catch{}if(F)b=F;else if(R)b=R;else break}return b}function c(y){const b=y?.match(/^#(?:([0-9a-f]{3,4})|([0-9a-f]{6})|([0-9a-f]{8}))$/i);if(b){let L=b[1]||b[2]||b[3];if((L.length===3||L.length===4)&&(L=L.slice(0,3).split("").map(_=>_+_).join("")),L.length>=6){const _=Number.parseInt(L.slice(0,2),16),C=Number.parseInt(L.slice(2,4),16),te=Number.parseInt(L.slice(4,6),16);if(Number.isFinite(_)&&Number.isFinite(C)&&Number.isFinite(te))return{r:_,g:C,b:te}}return null}const w=L=>{if(typeof L!="string")return Number(L);const _=L.trim();return _.endsWith("%")?Math.round(Number.parseFloat(_)/100*255):Number(_)},A=y?.match(/rgba?\(\s*([\d.]+%?)\s*,\s*([\d.]+%?)\s*,\s*([\d.]+%?)(?:\s*,\s*[\d.%]+)?\s*\)/i);if(A){const L=Math.min(255,Math.max(0,w(A[1]))),_=Math.min(255,Math.max(0,w(A[2]))),C=Math.min(255,Math.max(0,w(A[3])));if(Number.isFinite(L)&&Number.isFinite(_)&&Number.isFinite(C))return{r:L,g:_,b:C}}const k=y?.match(/rgba?\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+%?)(?:\s*\/\s*[\d.%]+)?\s*\)/i);if(k){const L=Math.min(255,Math.max(0,w(k[1]))),_=Math.min(255,Math.max(0,w(k[2]))),C=Math.min(255,Math.max(0,w(k[3])));if(Number.isFinite(L)&&Number.isFinite(_)&&Number.isFinite(C))return{r:L,g:_,b:C}}const B=L=>{const _=L.trim().toLowerCase();let C=Number.parseFloat(_);return Number.isFinite(C)?(_.endsWith("turn")?C=C*360:_.endsWith("grad")?C=C*360/400:_.endsWith("rad")&&(C=C*180/Math.PI),(C%360+360)%360/360):0},R=y?.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.%]+)?\s*\)/i),F=!R&&y?.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*[\d.%]+)?\s*\)/i),z=R||F;if(z){const L=B(z[1]),_=Math.min(1,Math.max(0,Number(z[2])/100)),C=Math.min(1,Math.max(0,Number(z[3])/100));if(_===0){const U=Math.round(C*255);return{r:U,g:U,b:U}}const te=(U,pe,ct)=>{let Y=ct;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+_):C+_-C*_,me=2*C-se;return{r:Math.round(te(me,se,L+1/3)*255),g:Math.round(te(me,se,L)*255),b:Math.round(te(me,se,L-1/3)*255)}}return null}try{const y=typeof t=="string"?t.trim():String(t||""),b=i(y).trim(),w=c(b);if(!w)throw new Error("Unknown color");({r,g:s,b:o}=w)}catch{r=s=o=128}const l=(y,b,w)=>{y/=255,b/=255,w/=255;const A=Math.max(y,b,w),k=Math.min(y,b,w);let B,R,F=(A+k)/2;if(A===k)B=R=0;else{const z=A-k;switch(R=F>.5?z/(2-A-k):z/(A+k),A){case y:B=(b-w)/z+(b<w?6:0);break;case b:B=(w-y)/z+2;break;case w:B=(y-b)/z+4}B/=6}return[B*360,R,F]},u=(y,b,w)=>{y/=360;let A,k,B;if(b===0)A=k=B=w;else{const R=(L,_,C)=>(C<0&&(C+=1),C>1&&(C-=1),C<.16666666666666666?L+(_-L)*6*C:C<.5?_:C<.6666666666666666?L+(_-L)*(.6666666666666666-C)*6:L),F=w<.5?w*(1+b):w+b-w*b,z=2*w-F;A=R(z,F,y+1/3),k=R(z,F,y),B=R(z,F,y-1/3)}return[Math.round(A*255),Math.round(k*255),Math.round(B*255)]},d=(y,b,w)=>{const A=[y,b,w].map(k=>(k/=255,k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)));return .2126*A[0]+.7152*A[1]+.0722*A[2]},a=(y,b)=>{const w=d(...y),A=d(...b);return(Math.max(w,A)+.05)/(Math.min(w,A)+.05)},f=(y,b,w)=>`#${y.toString(16).padStart(2,"0")}${b.toString(16).padStart(2,"0")}${w.toString(16).padStart(2,"0")}`;let[m,p,h]=l(r,s,o);const x=4.5;let S=h<.5?Math.min(h+.5,1):Math.max(h-.5,0),[E,M,g]=u(m,p,S);if(a([r,s,o],[E,M,g])<x){const y=a([r,s,o],[0,0,0]),b=a([r,s,o],[255,255,255]);[E,M,g]=y>=b?[0,0,0]:[255,255,255]}const D=f(E,M,g);return ge.set(e,D),D}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"]),ve=/^\s*(?:https?:|mailto:|data:image\/(?:png|jpe?g|gif|webp|avif|bmp|ico);|\/(?!\/|\\)|\.\/|\.\.\/|#)/i;function wt(){try{return!!(typeof window<"u"&&window.DOMPurify&&typeof window.DOMPurify.sanitize=="function")}catch{}return!1}function St(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(!ve.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 xe(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=xe(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)}),St(s,n),Array.from(t.childNodes).forEach(o=>{const i=xe(o,e,n);i&&s.appendChild(i)}),s}function Ct(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 Tt(t){if(!t||typeof t!="string")return"";const e=Ct(t);if(!e)return"";const n=document.createDocumentFragment();Array.from(e.childNodes).forEach(s=>{const o=xe(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&&wt()){const r=window.DOMPurify.sanitize(t,{ALLOWED_TAGS:Array.from(De),ALLOWED_ATTR:Array.from(Be),ALLOWED_URI_REGEXP:ve}),s=document.createElement("div");return s.innerHTML=r,s.querySelectorAll("a[href]").forEach(o=>{const i=o.getAttribute("href")||"";ve.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 Tt(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 b=String(u.href).trim(),w=/^(javascript:|vbscript:|data:(?!image\/[a-z0-9.+-]+;base64,))/i.test(b);a.href=w?"#":b}else a.setAttribute("role","button"),a.tabIndex=0;u.target&&(a.target=u.target);const y=new Set((u.rel||"").split(/\s+/).filter(Boolean));typeof u.target=="string"&&u.target.trim().toLowerCase()==="_blank"&&(y.add("noopener"),y.add("noreferrer")),a.rel=Array.from(y).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)"),h=(typeof f=="string"?f.trim():"").match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);let x="rgba(128, 128, 128, 0.3)";h&&(x=`${h[1].length===3?`#${h[1][0]}${h[1][0]}${h[1][1]}${h[1][1]}${h[1][2]}${h[1][2]}`:`#${h[1]}`}44`),a.className="toast-cta";const S=e.fontDirection==="rtl";v().disableInlineStyles||Object.assign(a.style,{marginLeft:S?"0px":l===0?"10px":"6px",marginRight:S?l===0?"10px":"6px":"0px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:`1px solid ${x}`,color:f,background:m,cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0",display:"inline-flex",alignItems:"center",textDecoration:"none",outline:"none"}),a.textContent=u.label;const E=async y=>{if(!a._isExecuting){a._isExecuting=!0;try{if(typeof u.onClick=="function"){const b=u.onClick(y);b?.then&&await b}}catch(b){console.error("CTA onClick handler error:",b)}finally{a._isExecuting=!1,u.autoClose!==!1&&typeof n=="function"&&await n(t)}}},M=y=>{d&&!u.href&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),E(y))};a.addEventListener("click",E),d&&!u.href&&a.addEventListener("keydown",M);const g=()=>{a.removeEventListener("click",E),d&&!u.href&&a.removeEventListener("keydown",M)};a._cleanup=g,o.push(g);const D=t.querySelector(".toast-undo-btn")||t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");D?t.insertBefore(a,D):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 h=e.fontDirection==="rtl";v().disableInlineStyles||Object.assign(u.style,{marginLeft:h?"0px":"10px",marginRight:h?"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 x=Math.max(1,Math.ceil((c||2500)/1e3));const S=()=>{u.textContent=l?`${i} (${x}s)`:i};S();let E=null,M=!1;l&&(E=setInterval(()=>{M||(x=Math.max(0,x-1),S(),x<=0&&E&&(clearInterval(E),E=null))},1e3),typeof E?.unref=="function"&&E.unref()),t._pauseUndo=()=>{M=!0},t._resumeUndo=()=>{M=!1};const g=()=>{E&&(clearInterval(E),E=null),t._pauseUndo=null,t._resumeUndo=null},D=async b=>{g(),u.removeEventListener("click",D);try{if(typeof o.onUndo=="function"){const w=o.onUndo(b,t);w?.then&&await w}}catch(w){console.error("Undo action error:",w)}finally{typeof n=="function"&&await n(t)}};u.addEventListener("click",D),u._cleanup=()=>{g(),u.removeEventListener("click",D)},t._cleanupUndo=()=>{g(),u.removeEventListener("click",D)};const y=t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");y?t.insertBefore(u,y):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 x=e.progressHeight.trim(),S=Number.parseFloat(x);Number.isFinite(S)&&S>0&&(x.endsWith("rem")||x.endsWith("em")?(i=S*16,c=x):(i=S,c=/^\d+(\.\d+)?$/.test(x)?`${S}px`:x))}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";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:`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 h=e.progress==="indeterminate"||!!e.showProgressBar&&(e.duration===0||e.duration===1/0)&&e.progress===void 0;if(n._isIndeterminate=h,n._isManualProgress=e.progress!==void 0&&e.progress!=="indeterminate",h){if(n.classList.add("toast-progress-bar-indeterminate"),m&&n.classList.add("toast-progress-bar-indeterminate-rtl"),!v().disableInlineStyles){$e();const x=m?"toast-progress-indeterminate-rtl":"toast-progress-indeterminate";n.style.animation=`${x} 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite`}n.style.width=a;return}if(e.progress!==void 0){const x=He(e.progress,t,e);n.style.width=`${x}%`,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 x=f?[{width:"0%"},{width:a}]:[{width:a},{width:"0%"}];t._progressAnimation=n.animate(x,{duration:u,easing:"linear",fill:"forwards",delay:50})}else n.style.transition=`width ${u}ms linear`,requestAnimationFrame(()=>{n.style.width=f?a:"0%"})}function qe(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 Ue(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 h=p.target;if(h&&typeof h.closest=="function"&&h.closest("button, a, input, textarea, select, label"))return;let x=p;p.touches&&p.touches.length>0?(x=p.touches[0],l=x.identifier??null):l=null,n=x.clientX,r=x.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 h=p;if(p.touches)if(l!==null){for(let g=0;g<p.touches.length;g++)if(p.touches[g].identifier===l){h=p.touches[g];break}}else p.touches.length>0&&(h=p.touches[0]);const x=h.clientX,S=h.clientY,E=x-n,M=S-r;if(!c){if(Math.abs(E)>8&&Math.abs(E)>Math.abs(M))c=!0;else if(Math.abs(M)>8){i=!1,t.style.userSelect="",d();return}}if(c){s=x;const g=Math.max(0,1-Math.abs(E)/280);!v().disableInlineStyles&&!q()&&(t.style.transform=`translateX(${E}px)`,t.style.opacity=String(g)),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,h=Math.max(1,Date.now()-o),S=(h>0?Math.abs(p)/h:0)>=.65&&Math.abs(p)>=50,E=S?50:75;if(Math.abs(p)>=E){const M=p>0?320:-320,g=S?120:180;!v().disableInlineStyles&&!q()&&(t.style.transition=`transform ${g}ms ease-out, opacity ${g}ms ease-out`,t.style.transform=`translateX(${M}px)`,t.style.opacity="0"),t._swipeTimeout&&clearTimeout(t._swipeTimeout),t._swipeTimeout=setTimeout(()=>{t._swipeTimeout=null,typeof e=="function"&&e(t)},g),typeof t._swipeTimeout?.unref=="function"&&t._swipeTimeout.unref()}else if(!v().disableInlineStyles&&!q()){const M="cubic-bezier(0.34, 1.56, 0.64, 1)";t.style.transition=`transform 200ms ${M}, 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.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 Ye(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==="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 gt(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()}`:"";t.className=`toast toast-${e?.type??"info"}${u}`;const d=typeof e?.borderRadius=="number"?`${e.borderRadius}px`:e?.borderRadius,a=typeof e?.maxWidth=="number"?`${e.maxWidth}px`:e?.maxWidth,f=o?`${Math.min(300,i)}ms`:c,m=o?"ease":l;r.disableInlineStyles||Object.assign(t.style,{background:e?.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:d,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:a,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",pointerEvents:"auto",transition:`opacity ${f} ${m}, 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 p=e?.type==="error",h=e?.role||"alert",x=e?.ariaLive||(p?"assertive":"polite");t.setAttribute("role",h),t.setAttribute("aria-live",x),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 M=typeof e?.fontSize=="number"?`${e.fontSize}px`:e?.fontSize;r.disableInlineStyles||Object.assign(S.style,{flex:"1",padding:e?.fontPadding,fontFamily:e?.fontFamily,fontSize:M,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 g=!!e.allowHtml,D=e.message??"",y=Ye(e);if(y&&t.appendChild(y),e.loader||e.showLoader){const A=Pe(e.loader||{});S.appendChild(A);const k=document.createElement("span");k.className="toast-message-spacer",r.disableInlineStyles||(k.style.display="inline-block",k.style.width="8px"),S.appendChild(k)}if(g&&typeof D=="string"&&D.trim().length>0)try{const A=we(D),k=document.createElement("div");for(k.innerHTML=A;k.firstChild;)S.appendChild(k.firstChild)}catch(A){console.warn("HTML message sanitization failed, falling back to text:",A),S.appendChild(document.createTextNode(String(D)))}else S.appendChild(document.createTextNode(String(D)));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&&Ue(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),qe(t)}async function Xe(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 S=we(String(t.message||"Emergency Toast Showing!")),E=document.createElement("div");for(E.innerHTML=S;E.firstChild;)f.appendChild(E.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 h=()=>{p&&clearTimeout(p),m.removeEventListener("click",h),r.remove(),typeof e=="function"&&e(r)};m.addEventListener("click",h);const x=Number(t?.duration)||2500;return p=setTimeout(()=>{m.removeEventListener("click",h),r.remove(),typeof e=="function"&&e(r)},x),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 yt("div",s),await Mt(n,t,e),n}catch(o){return console.warn("toast creation failed with error showing fallback one: ",o),n=await Xe(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 Ve(t){return`toast-container-${ce(t)}`}function Dt(t){if(!t)return;const e=typeof t=="string"&&t.startsWith("toast-container-")?t:Ve(t);le.delete(e),re.delete(e)}function Bt(){return dt()}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 Ge(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="hidden")}async function Ke(t={},e){const n=v(),r=Ve(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: hidden;
|
|
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
|
+
}
|
|
97
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
98
|
+
transform: scale(0.90) translateY(-20px);
|
|
99
|
+
margin-top: -55px;
|
|
100
|
+
margin-bottom: 0px;
|
|
101
|
+
opacity: 0.75;
|
|
102
|
+
z-index: 10;
|
|
103
|
+
pointer-events: auto;
|
|
104
|
+
}
|
|
105
|
+
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
106
|
+
transform: scale(0.90) translateY(20px);
|
|
107
|
+
}
|
|
108
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
|
|
109
|
+
transform: scale(0.85) translateY(-30px);
|
|
110
|
+
margin-top: -55px;
|
|
111
|
+
margin-bottom: 0px;
|
|
112
|
+
opacity: 0;
|
|
113
|
+
z-index: 1;
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
}
|
|
116
|
+
`,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)Ge(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"),Ge(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 Qe=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"]),Je=new Set(["top","bottom"]),Ze=[...Qe,...Je];function Wt(t){return Qe.has(t)}function Rt(t){if(t?.classList)for(let e=0;e<Ze.length;e++)t.classList.remove("toast-position-"+Ze[e])}async function Oe(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)&&!Je.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="none"}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,N=[];let G=0,ue=0;function et(){return{activeCount:$.size,queueDepth:N.length,visibleCount:G,droppedCount:ue,timestamp:Date.now()}}function P(){const t=v();if(typeof t.onMetrics=="function")try{t.onMetrics(et())}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="-55px",i.style.marginBottom="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="-55px",i.style.marginBottom="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="-55px",i.style.marginBottom="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=N.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"||N.some(l=>typeof l?.options?.priority=="number");if(c&&(s.priority={score:X(s)}),N.length>=o){if(c){const l=X(s);let u=0,d=X(N[0]);for(let a=1;a<N.length;a++){const f=X(N[a]);f<d&&(u=a,d=f)}if(l<=d){ue++,P();return}N.splice(u,1)}else N.shift();ue++}N.push(s),c&&N.sort((l,u)=>X(u)-X(l)),P(),await rt();return}try{await tt(r.options,e,r.count)}catch(s){console.error("showToast failed:",s)}}}),e}catch(e){console.error("showToast failed:",e)}}async function tt(t,e,n){try{if(!t||typeof t!="object")throw new TypeError("options must be an object");G++;const r=await Ke(t,Oe);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)),qe(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 Xe(t,V))}}async function Gt(){try{if($.size===0){if(W.size>0){const[r,s]=Array.from(W.entries()).at(-1);s?.rafId&&cancelAnimationFrame(s.rafId),W.delete(r),P();return}if(N.length>0){N.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(),N.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.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 ie(t._key)}async function ie(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=N.findIndex(u=>u.key===t);if(r!==-1){N.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.cancel()}catch{}e.toast._progressAnimation=null}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)";q()?(e.toast.style.transition="none",e.toast.style.opacity="0"):(m==="fade"?p="none":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)"),e.toast.style.transition=`opacity ${c}ms ease-in, transform ${c}ms ease-in`,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 rt()}catch(e){console.error("Closing Toast failed!: ",e)}}let Te=!1;async function rt(){if(!Te){Te=!0;try{const t=v();for((t.priorityQueue||typeof t.priorityScorer=="function"||N.some(e=>e.options?.priorityQueue||typeof e.options?.priority=="number"))&&N.length>1&&N.sort((e,n)=>X(n)-X(e));G<t.maxVisible&&N.length;){const e=N.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 tt(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{}ht(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 nt(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=N.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 h=document.createElement("span");h.style.display="inline-block",h.style.width="8px",i.appendChild(h)}if(f&&a.trim().length>0)try{const h=we(a),x=document.createElement("div");for(x.innerHTML=h;x.firstChild;)i.appendChild(x.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])}}if(e.icon!==void 0||e.type!==void 0){const a=o?.querySelector(".toast-icon");a&&a.remove();const f={...r.options,...e},m=Ye(f);m&&(i?o.insertBefore(m,i):o.appendChild(m))}if(e.backgroundColor&&(o.style.background=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.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)&&(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});if(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",o._progressAnimation){try{o._progressAnimation.cancel()}catch{}o._progressAnimation=null}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&&Ue(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&&!l._isManualProgress&&!l._isIndeterminate){const f=a+5;if(o._progressAnimation){try{o._progressAnimation.cancel()}catch{}const m=l._isReverse,p=l._finalWidth||"100%",h=m?[{width:"0%"},{width:p}]:[{width:p},{width:"0%"}];o._progressAnimation=l.animate(h,{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%"}}}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 Ke(t,Oe)}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 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&&(Ae={...Ae,...n})}}catch(e){console.error("setDefaultColors failed:",e)}}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&&(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 T(t={},e){const n=Q(t,e),r=await sr(()=>ar(n));return{id:r,dismiss:()=>r?ie(r):Promise.resolve(),update:s=>r?nt(r,s):Promise.resolve()}}T.success=(t,e)=>{const n=Q(t,e);return T({...n,type:"success"})},T.error=(t,e)=>{const n=Q(t,e);return T({...n,type:"error"})},T.warning=(t,e)=>{const n=Q(t,e);return T({...n,type:"warning"})},T.info=(t,e)=>{const n=Q(t,e);return T({...n,type:"info"})},T.loading=(t,e)=>{const n=Q(t,e);return T({type:"info",showLoader:!0,duration:0,showProgressBar:!1,pauseOnHover:!1,...n})},T.custom=(t,e)=>{const n=Q(t,e);return T({allowHtml:!0,...n})};const lr=T.success,cr=T.error,ur=T.warning,dr=T.info,fr=T.loading,mr=T.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 ie(e):e&&typeof e=="object"?typeof e.dismiss=="function"?await e.dismiss():e._key&&typeof e._key=="string"?await ie(e._key):e.id&&typeof e.id=="string"?await ie(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},it=O,ot=O,st=1440*60*1e3;async function oe(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:st,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0,...o}:{...s,type:"info",message:String(o),duration:st,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0},c=await T(i),l={...s,pauseOnHover:s.pauseOnHover};try{const d=await(typeof t=="function"?t():t);if(c&&typeof c.dismiss=="function")try{await c.dismiss()}catch{}const a=typeof r.success=="function"?r.success(d):r.success??"Done!",f=typeof a=="object"&&a!==null&&!Array.isArray(a)?{...l,type:"success",...a}:{...l,type:"success",message:String(a)};return await T(f),d}catch(u){if(c&&typeof c.dismiss=="function")try{await c.dismiss()}catch{}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",...d}:{...l,type:"error",message:String(d)};throw await T(a),u}}T.promise=oe,T.dismiss=fe,T.dismissAll=O,T.clear=O;const pr="4.0.0";function at(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"&&at(window);try{typeof window<"u"&&(window.customizableToast={setConfig:ye,getConfig:v,resetConfig:he,shouldReduceMotion:q,version:pr,createToast:T,success:lr,error:cr,warning:ur,info:dr,loading:fr,custom:mr,setDefaultColors:ir,setDefaultMessages:or,noop:O,dismiss:fe,dismissAll:O,clear:O,toastPromise:oe,promise:oe,updateToastByKey:nt,generateToastId:Ne,resetToastIdCounter:pt,getToastMetrics:et,initKeyboardShortcuts:at})}catch(t){console.error("Global assignment failed:",t)}class ee{success(e,n){return T.success(e,n)}error(e,n){return T.error(e,n)}warning(e,n){return T.warning(e,n)}info(e,n){return T.info(e,n)}loading(e,n){return T.loading(e,n)}custom(e,n){return T.custom(e,n)}show(e){return T(e)}promise(e,n,r){return oe(e,n,r)}dismiss(e){return fe(e)}dismissAll(){return ot()}clear(){return it()}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 lt(){return Ie||(Ie=new ee),Ie}const yr=lt();export{ee as ToastService,it as clear,T as createToast,fe as dismiss,ot as dismissAll,v as getConfig,lt as injectToast,he as resetConfig,ye as setConfig,yr as toast,oe as toastPromise};
|
|
117
|
+
//# sourceMappingURL=angular.esm.mjs.map
|