juice-toast 1.4.0 → 1.4.2

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.
@@ -1,9 +1,4 @@
1
- /**
2
- * 2026 (C) OpenDN Foundation
3
- * v1.3.4 (Nearing End of Support notifier)
4
- * ESM (ECMAScript Module)
5
- */
6
- "use strict";let isBrowser="undefined"!=typeof window&&"undefined"!=typeof document,reduceMotion=isBrowser&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class PriorityQueue{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(e){return Math.floor((e-1)/2)}_left(e){return 2*e+1}_right(e){return 2*e+2}_swap(e,t){[this._heap[e],this._heap[t]]=[this._heap[t],this._heap[e]]}push(e,t=0){let i={item:e,priority:t,seq:PriorityQueue._seq=(PriorityQueue._seq||0)+1};this._heap.push(i),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);let e=this._heap.pop();return this._siftDown(0),e.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(e){for(;e>0;){let t=this._parent(e);if(0>=this._compare(e,t))break;this._swap(e,t),e=t}}_siftDown(e){for(;;){let t=this._left(e),i=this._right(e),s=this._heap.length,o=e;if(t<s&&this._compare(t,o)>0&&(o=t),i<s&&this._compare(i,o)>0&&(o=i),o===e)break;this._swap(e,o),e=o}}_compare(e,t){let i=this._heap[e],s=this._heap[t];return i.priority!==s.priority?i.priority-s.priority:s.seq-i.seq}}let __cssInjected=!1,BASE_CSS=`
1
+ var ft=Object.defineProperty,gt=Object.defineProperties,bt=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,it=(e,t,o)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,W=(e,t)=>{for(var o in t||(t={}))at.call(t,o)&&it(e,o,t[o]);if(U)for(var o of U(t))st.call(t,o)&&it(e,o,t[o]);return e},B=(e,t)=>gt(e,bt(t)),yt=(e,t)=>{var o={};for(var r in e)at.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&U)for(var r of U(e))t.indexOf(r)<0&&st.call(e,r)&&(o[r]=e[r]);return o};const y=typeof window!="undefined"&&typeof document!="undefined",vt=y&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class q{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(t){return Math.floor((t-1)/2)}_left(t){return 2*t+1}_right(t){return 2*t+2}_swap(t,o){[this._heap[t],this._heap[o]]=[this._heap[o],this._heap[t]]}push(t,o=0){const r={item:t,priority:o,seq:q._seq=(q._seq||0)+1};this._heap.push(r),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const t=this._heap.pop();return this._siftDown(0),t.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(t){for(;t>0;){const o=this._parent(t);if(this._compare(t,o)<=0)break;this._swap(t,o),t=o}}_siftDown(t){for(;;){const o=this._left(t),r=this._right(t),l=this._heap.length;let c=t;if(o<l&&this._compare(o,c)>0&&(c=o),r<l&&this._compare(r,c)>0&&(c=r),c===t)break;this._swap(t,c),t=c}}_compare(t,o){const r=this._heap[t],l=this._heap[o];return r.priority!==l.priority?r.priority-l.priority:l.seq-r.seq}}let H=!1;const J=`
7
2
  /* JuiceToast base (v1.4.0) */
8
3
  #juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
9
4
  #juice-toast-root[data-position="bottom-right"],#juice-toast-root-bottom-right{bottom:20px;right:20px;flex-direction:column-reverse;align-items:flex-end}
@@ -23,4 +18,96 @@
23
18
  .jt-actions{display:flex;gap:8px;margin-top:10px}
24
19
  .jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent}
25
20
  .jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear}
26
- `;function injectCSS(e=BASE_CSS){if(!isBrowser||__cssInjected)return;let t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),__cssInjected=!0}let uid=(()=>{let e=1;return()=>"jt-"+e++})();function now(){return Date.now()}function merge(e,t){return Object.assign({},e||{},t||{})}function clamp(e,t,i){return Math.max(t,Math.min(i,e))}function sanitizeHTML(e){if(!e)return"";let t=document.createElement("template");t.innerHTML=e,t.content.querySelectorAll("script, style, [onload], [onerror], [onclick], iframe").forEach(e=>e.remove());let i=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6"];return!function e(t){Array.from(t.childNodes).forEach(t=>{1===t.nodeType&&(i.includes(t.tagName.toLowerCase())?e(t):t.replaceWith(...Array.from(t.childNodes)))})}(t.content),t.innerHTML}let themes={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},sizePreset={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},TYPE_ANIMATION={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},juiceToast={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new PriorityQueue,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,setup(e={}){let{duration:t,maxVisible:i,...s}=e;t&&(this._defaults.duration=t),i&&(this._defaults.maxVisible=i),this._config=merge(this._config,s),this._registerTypes()},use(e){"function"==typeof e&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){themes[e]=merge(themes[e]||{},t)},setTheme(e){this._theme=e,isBrowser&&this._roots.forEach(t=>t.dataset.theme=e)},clear(){this._queue=new PriorityQueue,this._queueDedupe.clear()},destroy(){this.clear(),isBrowser&&(this._roots.forEach(e=>e.remove()),this._roots.clear())},promise(e,t={}){if(!e||"function"!=typeof e.then){this._warn("promise expects a Promise");return}let i={id:uid()},s=i.id,o=t.timeout;this._enqueue("loading",{...normalizeState(t.loading,"Loading..."),groupId:s,duration:0});let r=null;o&&(r=setTimeout(()=>{this._enqueue("error",{message:t.timeoutMessage||"Request timeout",groupId:s}),n()},o));let n=()=>{r&&clearTimeout(r)};return e.then(e=>{n(),this._enqueue("success",{...resolveState(t.success,e,"Success"),groupId:s})}).catch(e=>{n(),this._enqueue("error",{...resolveState(t.error,e,"Error"),groupId:s})}),{cancel:()=>{this._enqueue("info",{message:t.cancelMessage||"Cancelled",groupId:s}),r&&clearTimeout(r)}}},_registerTypes(){Object.keys(this._config).forEach(e=>{if("function"==typeof this[e]&&!this[e].__auto)return;let t=t=>this._enqueue(e,t);t.__auto=!0,this[e]=t})},_enqueue(e,t={}){let i=this._priorityMap?.[t.priority]??2,s=t.dedupeKey;if(s&&this._queueDedupe.has(s)){this._defaults.dev&&console.log("[JuiceToast] deduped",s);return}let o={id:uid(),type:e,payload:t,priority:i};s&&this._queueDedupe.add(s),this._queue.push(o,i),this._processQueue()},_processQueue(){if(!isBrowser)return;let e=this._defaults.maxVisible;for(;this._queue.size>0;){let t=this._queue.pop();if(!t)break;let i=t.payload?.position||"bottom-right",s=this._getRoot(i),o=Array.from(s.children).length;if(o>=e){this._queue.push(t,t.priority-.001);break}this._showToast(t.type,t.payload,t.id)}},_getRoot(e="bottom-right"){if(!isBrowser)return null;if(this._roots.has(e))return this._roots.get(e);let t=document.createElement("div");switch(t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":default:t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)"}return document.body.appendChild(t),this._roots.set(e,t),t},_warn(e){this._defaults.dev&&"undefined"!=typeof console&&console.warn("[JuiceToast]",e)},_playSound(e){if(!isBrowser)return;let t="string"==typeof e&&e?e:this._defaults.playSound;if(t)try{let i=new Audio(t);i.volume=.6,i.play().catch(()=>{})}catch(s){}},_updateStackPositionsFor(e){let t=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),t.forEach((e,t)=>{let i=t;e.style.setProperty("--jt-stack-y",`-${12*i}px`),e.style.setProperty("--jt-stack-scale",1-.04*i),e.style.setProperty("--jt-stack-opacity",1-.12*i),e.style.zIndex=1e3-i})},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(i){this._warn("Plugin error: "+i.message)}})},_normalizeGlass(e){if(!0===e)return 60;if(!e)return 0;let t=Number(e);return Number.isFinite(t)?clamp(t,0,100):0},_showToast(e,t={},i){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);let s=this._config[e]||{},o="object"==typeof t?t:{message:String(t)},r=merge(s,o);r.icon=r.icon??r.icon_left_top,r.position=r.position??r.toast??"bottom-right",r.closable=r.closable??r.closeable??!0,r.duration=r.duration??this._defaults.duration;let n=themes[r.theme||this._theme]||{},a=i||uid(),l=document.createElement("div");if(l.className="juice-toast",l.dataset.toastId=a,l.dataset.position=r.position,l.tabIndex=0,l.setAttribute("role","status"),l.style.position="relative",l.style.pointerEvents="auto",l.style.background=r.bg||n.bg,l.style.color=r.color||n.color,l.style.border=r.border||n.border||"none",r.size&&sizePreset[r.size]){let c=sizePreset[r.size];c.width&&(l.style.width=c.width),c.padding&&(l.style.padding=c.padding)}let d=document.createElement("div");if(d.className="jt-content",r.title){let p=document.createElement("div");p.className="jt-title",p.textContent=r.title,d.appendChild(p)}let u=document.createElement("div");if(u.className="jt-message",r.html)u.innerHTML=sanitizeHTML(r.html);else if("string"==typeof r.message){let h=r.message.split(/(`[^`]+`)/g);h.forEach(e=>{if(e.startsWith("`")&&e.endsWith("`")){let t=document.createElement("code");t.textContent=e.slice(1,-1),u.appendChild(t)}else u.appendChild(document.createTextNode(e))})}else r.message&&(u.textContent=String(r.message));if(d.appendChild(u),Array.isArray(r.actions)&&r.actions.length){let f=document.createElement("div");f.className="jt-actions",r.actions.forEach(e=>{let t=document.createElement("button");t.className="jt-action",t.textContent=e.label||"Action",t.onclick=t=>{t.stopPropagation(),e.onClick?.(t),e.closeOnClick&&A()},f.appendChild(t)}),d.appendChild(f)}let m=null;if(r.icon){if((m=document.createElement("i")).className=["icon",r.iconPack||"",r.icon].join(" ").trim(),r.iconSize&&(m.style.fontSize=r.iconSize),!reduceMotion){let g=r.iconAnim||TYPE_ANIMATION[e];g&&m.classList.add(g)}(r.iconLink||r.iconAnimate)&&(m.classList.add("icon-clickable"),m.addEventListener("click",e=>{e.stopPropagation(),r.iconAnimate&&(m.classList.remove(r.iconAnimate),m.offsetWidth,m.classList.add(r.iconAnimate)),r.iconLink&&window.open(r.iconLink,"_blank","noopener")}))}m&&"right"===r.iconPosition?(l.appendChild(d),l.appendChild(m)):m&&"top"===r.iconPosition?(l.classList.add("jt-icon-top"),l.appendChild(m),l.appendChild(d)):(m&&l.appendChild(m),l.appendChild(d));let $=null;if(r.progress&&(r.duration??this._defaults.duration)>0&&(($=document.createElement("div")).className="jt-progress",r.progressColor&&($.style.background=r.progressColor),l.appendChild($)),r.undo){let y=document.createElement("button");y.className="jt-action",y.textContent="Undo",y.onclick=()=>{try{r.undo()}catch(e){}A()},d.appendChild(y)}if(r.closable){let x=document.createElement("span");x.className="juice-toast-close",x.tabIndex=0,x.textContent="\xd7",x.addEventListener("click",e=>{e.stopPropagation(),A()}),l.appendChild(x)}let b=this._getRoot(r.position||"bottom-right");if(!b)return;if(r.groupId){let v=Array.from(b.children).find(e=>e.dataset.groupId===r.groupId);if(v){let _=v.querySelector(".jt-count");_||((_=document.createElement("span")).className="jt-count",_.style.marginLeft="6px",v.querySelector(".jt-title")?.appendChild(_),_.textContent="1"),_.textContent=String(parseInt(_.textContent||"1")+1);return}l.dataset.groupId=r.groupId}let j=this._defaults.maxVisible;j&&b.children.length>=j&&b.removeChild(b.firstElementChild),b.appendChild(l);let w={id:a,toast:l,cfg:r,createdAt:now(),remaining:r.duration??this._defaults.duration,raf:null,timer:null,start:now(),paused:!1};this._activeMap.set(a,w),this._runPlugins({toast:l,cfg:r,type:e,root:b}),this._updateStackPositionsFor(b),requestAnimationFrame(()=>l.classList.add("show"));let E=0,k=0,C=0,L=0,S=!1,T=e=>{let t=e.touches?e.touches[0]:e;E=t.clientX,k=t.clientY,S=!0,w.paused=!0,l.style.transition="none"},P=e=>{if(!S)return;let t=e.touches?e.touches[0]:e;Math.abs(C=t.clientX-E)>Math.abs(L=t.clientY-k)?l.style.transform=`translateX(${C}px)`:l.style.transform=`translateY(${L}px)`},q=()=>{S=!1,w.paused=!1,l.style.transition="";let e=Math.abs(C)>(this._defaults.swipeThreshold||60);e?(l.style.transform=`translateX(${C>0?1e3:-1e3}px)`,setTimeout(A,220)):l.style.transform="",E=k=C=L=0};l.addEventListener("touchstart",T,{passive:!0}),l.addEventListener("mousedown",T),window.addEventListener("touchmove",P,{passive:!0}),window.addEventListener("mousemove",P),window.addEventListener("touchend",q),window.addEventListener("mouseup",q);let z=()=>w.paused=!0,I=()=>w.paused=!1;l.addEventListener("mouseenter",z),l.addEventListener("mouseleave",I),l.addEventListener("focusin",z),l.addEventListener("focusout",I);let M=r.duration??this._defaults.duration;if(M>0){w.start=now(),w.remaining=M;let N=()=>{if(this._activeMap.has(a)){if(w.paused)w.start=now();else{let e=now()-w.start;w.remaining-=e,w.start=now()}if($){let t=Math.max(0,w.remaining/M);$.style.transform=`scaleX(${t})`}w.remaining<=0?(l.classList.remove("show"),setTimeout(A,280)):w.raf=requestAnimationFrame(N)}};w.raf=requestAnimationFrame(N)}function A(){if(!juiceToast._activeMap.has(a))return;l.classList.add("hide"),l.removeEventListener("touchstart",T),l.removeEventListener("mousedown",T),window.removeEventListener("touchmove",P),window.removeEventListener("mousemove",P),window.removeEventListener("touchend",q),window.removeEventListener("mouseup",q),l.removeEventListener("mouseenter",z),l.removeEventListener("mouseleave",I),l.removeEventListener("focusin",z),l.removeEventListener("focusout",I);let e=juiceToast._activeMap.get(a);e?.raf&&cancelAnimationFrame(e.raf),e?.timer&&clearTimeout(e.timer),juiceToast._activeMap.delete(a);let t=l.parentNode;t&&t.removeChild(l),t&&juiceToast._updateStackPositionsFor(t)}return r.undoTimeout&&(w.timer=setTimeout(A,r.undoTimeout)),(r.playSound||this._defaults.playSound)&&this._playSound(r.playSound||this._defaults.playSound),a},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function normalizeState(e,t){return e?"string"==typeof e?{message:e}:e:{message:t}}function resolveState(e,t,i){return e?"function"==typeof e?{message:e(t)}:"string"==typeof e?{message:e}:e:{message:i}}juiceToast.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export default juiceToast;export{juiceToast};
21
+
22
+ /* avatar specific */
23
+ .jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0}
24
+
25
+ /* ---------------- Modal ---------------- */
26
+ /* Overlay */
27
+ .jt-modal-overlay{
28
+ position:fixed;
29
+ inset:0;
30
+ display:flex;
31
+ align-items:center;
32
+ justify-content:center;
33
+ padding:20px;
34
+ background:rgba(15,23,42,.55);
35
+ backdrop-filter:blur(6px) saturate(120%);
36
+ -webkit-backdrop-filter:blur(6px) saturate(120%);
37
+ opacity:0;
38
+ transition:opacity .25s ease;
39
+ z-index:10000;
40
+ }
41
+ .jt-modal-overlay.show{
42
+ opacity:1;
43
+ }
44
+
45
+ /* Base modal */
46
+ .jt-modal{
47
+ width:100%;
48
+ max-width:520px;
49
+ border-radius:18px;
50
+ padding:24px;
51
+
52
+ opacity:0;
53
+ transform:translateY(40px) scale(.96);
54
+ transition:
55
+ transform .35s cubic-bezier(.16,1,.3,1),
56
+ opacity .25s ease;
57
+ }
58
+
59
+ .jt-modal.show{
60
+ opacity:1;
61
+ transform:translateY(0) scale(1);
62
+ }
63
+
64
+ .jt-modal-header{
65
+ font-size:18px;
66
+ font-weight:600;
67
+ letter-spacing:.3px;
68
+ margin-bottom:10px;
69
+ }
70
+
71
+ .jt-modal-body{
72
+ font-size:14.5px;
73
+ line-height:1.6;
74
+ opacity:.85;
75
+ margin-bottom:22px;
76
+ }
77
+
78
+ .jt-modal-actions{
79
+ display:flex;
80
+ justify-content:flex-end;
81
+ gap:12px;
82
+ }
83
+
84
+ .jt-modal-btn{
85
+ min-width:88px;
86
+ padding:8px 16px;
87
+ border-radius:12px;
88
+ font-size:13.5px;
89
+ font-weight:500;
90
+ cursor:pointer;
91
+ transition:all .2s ease;
92
+ border:1px solid rgba(255,255,255,.08);
93
+ background:rgba(255,255,255,.04);
94
+ color:inherit;
95
+ }
96
+ .jt-modal-btn:hover{
97
+ background:rgba(255,255,255,.08);
98
+ transform:translateY(-1px);
99
+ }
100
+ .jt-modal-btn:active{
101
+ transform:translateY(0);
102
+ }
103
+
104
+ .jt-modal-btn.primary{
105
+ background:#6366f1;
106
+ border-color:#6366f1;
107
+ color:#fff;
108
+ }
109
+ .jt-modal-btn.primary:hover{
110
+ background:#5458ee;
111
+ }
112
+ `;function rt(e=J){if(!y||H)return;if(document.getElementById("juice-toast-style")){H=!0;return}const t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),H=!0}const K=(()=>{let e=1;return()=>"jt-"+e++})();function _(){return Date.now()}function F(e,t){return Object.assign({},e||{},t||{})}function xt(e,t,o){return Math.max(t,Math.min(o,e))}function lt(e){if(!e)return"";const t=document.createElement("template");t.innerHTML=e,t.content.querySelectorAll("script, style, iframe").forEach(r=>r.remove());const o=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function r(l){Array.from(l.childNodes).forEach(c=>{if(c.nodeType===1){const h=c.tagName.toLowerCase();o.includes(h)?(Array.from(c.attributes||[]).forEach(g=>{const m=g.name.toLowerCase(),f=g.value||"";(m.startsWith("on")||(m==="href"||m==="src"||m==="xlink:href")&&f.trim().toLowerCase().startsWith("javascript:")||h==="img"&&m==="srcset")&&c.removeAttribute(g.name)}),r(c)):c.replaceWith(...Array.from(c.childNodes))}})})(t.content),t.innerHTML}const P={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ct={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},_t={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},j={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new q,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],setup(e={}){const t=e,{duration:o,maxVisible:r}=t,l=yt(t,["duration","maxVisible"]);o&&(this._defaults.duration=o),r&&(this._defaults.maxVisible=r),this._config=F(this._config,l),this._registerTypes()},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){P[e]=F(P[e]||{},t)},setTheme(e){this._theme=e,y&&this._roots.forEach(t=>t.dataset.theme=e)},clear(){this._queue=new q,this._queueDedupe.clear()},destroy(){this.clear(),y&&(this._roots.forEach(e=>e.remove()),this._roots.clear())},promise(e,t={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const o={id:K()}.id,r=t.timeout;this._enqueue("loading",B(W({},jt(t.loading,"Loading...")),{groupId:o,duration:0}));let l=null;r&&(l=setTimeout(()=>{this._enqueue("error",{message:t.timeoutMessage||"Request timeout",groupId:o}),c()},r));const c=()=>{l&&clearTimeout(l)};return e.then(h=>{c(),this._enqueue("success",B(W({},dt(t.success,h,"Success")),{groupId:o}))}).catch(h=>{c(),this._enqueue("error",B(W({},dt(t.error,h,"Error")),{groupId:o}))}),{cancel:()=>{this._enqueue("info",{message:t.cancelMessage||"Cancelled",groupId:o}),l&&clearTimeout(l)}}},modal(e={}){var t;if(!y)return;this._defaults.injectCSS!==!1&&rt(this._defaults.css||J);const o=F({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},e),r=P[o.theme]||P.dark,l=document.createElement("div");l.className="jt-modal-overlay",o.block?l.style.pointerEvents="all":l.style.pointerEvents="none",o.blur||(l.style.backdropFilter="none",l.style.webkitBackdropFilter="none");const c=document.createElement("div");if(c.className=`jt-modal jt-anim-${o.animation}`,c.style.background=r.bg,c.style.color=r.color,c.style.border=r.border||"none",o.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=o.title,c.appendChild(m)}const h=document.createElement("div");if(h.className="jt-modal-body",o.html?h.innerHTML=lt(o.html):h.textContent=o.message||"",c.appendChild(h),(t=o.actions)!=null&&t.length){const m=document.createElement("div");m.className="jt-modal-actions",o.actions.forEach(f=>{const w=document.createElement("button");w.className="jt-modal-btn"+(f.primary?" primary":""),w.textContent=f.label||"OK",w.onclick=M=>{var S;M.stopPropagation(),(S=f.onClick)==null||S.call(f,M),f.closeOnClick!==!1&&g()},m.appendChild(w)}),c.appendChild(m)}l.appendChild(c),document.body.appendChild(l),o.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{l.classList.add("show"),c.classList.add("show")});const g=()=>{l.classList.remove("show"),c.classList.remove("show"),setTimeout(()=>{l.remove(),o.block&&(document.body.style.overflow="")},300)};if(o.closable){o.closeOnOverlay&&l.addEventListener("click",f=>{f.target===l&&g()});const m=f=>{f.key==="Escape"&&(g(),document.removeEventListener("keydown",m))};document.addEventListener("keydown",m)}return{close:g}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const t=o=>this._enqueue(e,o);t.__auto=!0,this[e]=t})},_enqueue(e,t={}){var o,r;const l=(r=(o=this._priorityMap)==null?void 0:o[t.priority])!=null?r:2,c=t.dedupeKey;if(c&&this._queueDedupe.has(c)){this._defaults.dev&&console.log("[JuiceToast] deduped",c);return}const h={id:K(),type:e,payload:t,priority:l};c&&this._queueDedupe.add(c),this._queue.push(h,l),this._processQueue()},_processQueue(){var e;if(!y)return;const t=this._defaults.maxVisible;for(;this._queue.size>0;){const o=this._queue.pop();if(!o)break;const r=((e=o.payload)==null?void 0:e.position)||"bottom-right",l=this._getRoot(r);if(Array.from(l.children).length>=t){this._queue.push(o,o.priority-.001);break}this._showToast(o.type,o.payload,o.id)}},_getRoot(e="bottom-right"){if(!y)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;default:t.style.bottom="20px",t.style.right="20px"}return document.body.appendChild(t),this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_playSound(e){if(!y)return;const t=typeof e=="string"&&e?e:this._defaults.playSound;if(t)try{const o=new Audio(t);o.volume=.6,o.play().catch(()=>{})}catch(o){}},_updateStackPositionsFor(e){const t=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),t.forEach((o,r)=>{const l=r,c=l*12;o.style.setProperty("--jt-stack-y",`-${c}px`),o.style.setProperty("--jt-stack-scale",1-l*.04),o.style.setProperty("--jt-stack-opacity",1-l*.12),o.style.zIndex=1e3-l})},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(o){this._warn("Plugin error: "+o.message)}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const t=Number(e);return Number.isFinite(t)?xt(t,0,100):0},_showToast(e,t={},o){var r,l,c,h,g,m,f,w,M,S,Q,G,Z;if(!y)return;this._defaults.injectCSS!==!1&&rt(this._defaults.css||J);const ut=this._config[e]||{},pt=typeof t=="object"?t:{message:String(t)},n=F(ut,pt);n.icon=(r=n.icon)!=null?r:n.icon_left_top,n.position=(c=(l=n.position)!=null?l:n.toast)!=null?c:"bottom-right",n.closable=(g=(h=n.closable)!=null?h:n.closeable)!=null?g:!0,n.duration=(m=n.duration)!=null?m:this._defaults.duration;const Y=P[n.theme||this._theme]||{},v=o||K(),a=document.createElement("div");if(a.className="juice-toast",a.dataset.toastId=v,a.dataset.position=n.position,a.tabIndex=0,a.setAttribute("role","status"),a.style.position="relative",a.style.pointerEvents="auto",a.style.background=n.bg||Y.bg,a.style.color=n.color||Y.color,a.style.border=n.border||Y.border||"none",n.size&&ct[n.size]){const s=ct[n.size];s.width&&(a.style.width=s.width),s.padding&&(a.style.padding=s.padding)}const b=document.createElement("div");if(b.className="jt-content",n.title){const s=document.createElement("div");s.className="jt-title",s.textContent=n.title,b.appendChild(s)}const k=document.createElement("div");if(k.className="jt-message",n.html?k.innerHTML=lt(n.html):typeof n.message=="string"?n.message.split(/(`[^`]+`)/g).forEach(s=>{if(s.startsWith("`")&&s.endsWith("`")){const d=document.createElement("code");d.textContent=s.slice(1,-1),k.appendChild(d)}else k.appendChild(document.createTextNode(s))}):n.message&&(k.textContent=String(n.message)),b.appendChild(k),Array.isArray(n.actions)&&n.actions.length){const s=document.createElement("div");s.className="jt-actions",n.actions.forEach(d=>{const I=document.createElement("button");I.className="jt-action",I.textContent=d.label||"Action",I.onclick=ot=>{var nt;ot.stopPropagation(),(nt=d.onClick)==null||nt.call(d,ot),d.closeOnClick&&L()},s.appendChild(I)}),b.appendChild(s)}let p=null;if(n.icon){if(p=document.createElement("i"),p.className=["icon",n.iconPack||"",n.icon].join(" ").trim(),n.iconSize&&(p.style.fontSize=n.iconSize),!vt){const s=n.iconAnim||_t[e];s&&p.classList.add(s)}(n.iconLink||n.iconAnimate)&&(p.classList.add("icon-clickable"),p.addEventListener("click",s=>{s.stopPropagation(),n.iconAnimate&&(p.classList.remove(n.iconAnimate),p.offsetWidth,p.classList.add(n.iconAnimate)),n.iconLink&&window.open(n.iconLink,"_blank","noopener")}))}let u=null;if(n.avatar){u=document.createElement("img");const s=typeof n.avatar=="string"&&n.avatar?n.avatar:n.avatarSrc||"";s&&(u.src=s),u.alt=n.avatarAlt||n.title||"avatar",u.className="jt-avatar",u.loading=n.avatarLazy?"lazy":"eager",u.style.width=u.style.width||"36px",u.style.height=u.style.height||"36px",u.style.borderRadius=u.style.borderRadius||"50%",u.style.objectFit=u.style.objectFit||"cover",u.style.flexShrink="0";const d=n.avatarPosition||"left";d==="left"?u.style.marginRight=(f=n.avatarSpacing)!=null?f:"10px":d==="right"?u.style.marginLeft=(w=n.avatarSpacing)!=null?w:"10px":d==="top"&&(u.style.marginBottom=(M=n.avatarSpacing)!=null?M:"8px")}const D=n.avatarPosition||"left";u&&D==="top"?(a.classList.add("jt-avatar-top"),a.style.flexDirection="column",a.style.alignItems="flex-start",a.appendChild(u),p&&n.iconPosition==="top"?(a.appendChild(p),a.appendChild(b)):p&&n.iconPosition==="right"?(a.appendChild(b),a.appendChild(p)):(p&&a.appendChild(p),a.appendChild(b))):(a.style.flexDirection="row",a.style.alignItems="center",u&&D==="left"&&a.appendChild(u),p&&n.iconPosition==="right"?(a.appendChild(b),a.appendChild(p)):p&&n.iconPosition==="top"?(a.classList.add("jt-icon-top"),a.appendChild(p),a.appendChild(b)):(p&&a.appendChild(p),a.appendChild(b)),u&&D==="right"&&a.appendChild(u));let E=null;if(n.progress&&((S=n.duration)!=null?S:this._defaults.duration)>0&&(E=document.createElement("div"),E.className="jt-progress",n.progressColor&&(E.style.background=n.progressColor),a.appendChild(E)),n.undo){const s=document.createElement("button");s.className="jt-action",s.textContent="Undo",s.onclick=()=>{try{n.undo()}catch(d){}L()},b.appendChild(s)}if(n.closable){const s=document.createElement("span");s.className="juice-toast-close",s.tabIndex=0,s.textContent="\xD7",s.addEventListener("click",d=>{d.stopPropagation(),L()}),a.appendChild(s)}const x=this._getRoot(n.position||"bottom-right");if(!x)return;if(n.groupId){const s=Array.from(x.children).find(d=>d.dataset.groupId===n.groupId);if(s){let d=s.querySelector(".jt-count");d||(d=document.createElement("span"),d.className="jt-count",d.style.marginLeft="6px",(Q=s.querySelector(".jt-title"))==null||Q.appendChild(d),d.textContent="1"),d.textContent=String(parseInt(d.textContent||"1")+1);return}a.dataset.groupId=n.groupId}const tt=this._defaults.maxVisible;tt&&x.children.length>=tt&&x.removeChild(x.firstElementChild),x.appendChild(a);const i={id:v,toast:a,cfg:n,createdAt:_(),remaining:(G=n.duration)!=null?G:this._defaults.duration,raf:null,timer:null,start:_(),paused:!1,_boundMove:null,_boundUp:null};this._activeMap.set(v,i),this._runPlugins({toast:a,cfg:n,type:e,root:x}),this._updateStackPositionsFor(x),requestAnimationFrame(()=>a.classList.add("show"));let X=0,R=0,C=0,T=0,$=!1;const A=s=>{const d=s.touches?s.touches[0]:s;X=d.clientX,R=d.clientY,$=!0,i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null),a.style.transition="none",i._boundMove=mt,i._boundUp=ht,document.addEventListener("touchmove",i._boundMove,{passive:!0}),document.addEventListener("mousemove",i._boundMove),document.addEventListener("touchend",i._boundUp),document.addEventListener("mouseup",i._boundUp)},mt=s=>{if(!$)return;const d=s.touches?s.touches[0]:s;C=d.clientX-X,T=d.clientY-R,Math.abs(C)>Math.abs(T)?a.style.transform=`translateX(${C}px)`:a.style.transform=`translateY(${T}px)`},ht=()=>{$=!1,i.paused=!1,a.style.transition="",Math.abs(C)>(this._defaults.swipeThreshold||60)?(a.style.transform=`translateX(${C>0?1e3:-1e3}px)`,setTimeout(L,220)):a.style.transform="",X=R=C=T=0,i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),V()};a.addEventListener("touchstart",A,{passive:!0}),a.addEventListener("mousedown",A);const N=()=>{i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null)},z=()=>{i.paused&&(i.paused=!1,i.start=_(),V())};a.addEventListener("mouseenter",N),a.addEventListener("mouseleave",z),a.addEventListener("focusin",N),a.addEventListener("focusout",z);const O=(Z=n.duration)!=null?Z:this._defaults.duration;function et(){if(!j._activeMap.has(v))return;if(i.paused){i.raf=null,i.start=_();return}const s=_()-i.start;if(i.remaining-=s,i.start=_(),E){const d=Math.max(0,i.remaining/O);E.style.transform=`scaleX(${d})`}if(i.remaining<=0){a.classList.remove("show"),setTimeout(L,280),i.raf=null;return}i.raf=requestAnimationFrame(et)}function V(){O<=0||i.raf||i.paused||(i.start=_(),i.raf=requestAnimationFrame(et))}O>0&&(i.start=_(),i.remaining=O,V());function L(){if(!j._activeMap.has(v))return;a.classList.add("hide"),a.removeEventListener("touchstart",A),a.removeEventListener("mousedown",A),i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),a.removeEventListener("mouseenter",N),a.removeEventListener("mouseleave",z),a.removeEventListener("focusin",N),a.removeEventListener("focusout",z);const s=j._activeMap.get(v);s!=null&&s.raf&&(cancelAnimationFrame(s.raf),s.raf=null),s!=null&&s.timer&&(clearTimeout(s.timer),s.timer=null),j._activeMap.delete(v);const d=a.parentNode;d&&d.removeChild(a),d&&j._updateStackPositionsFor(d)}return n.undoTimeout&&(i.timer=setTimeout(L,n.undoTimeout)),(n.playSound||this._defaults.playSound)&&this._playSound(n.playSound||this._defaults.playSound),v},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function jt(e,t){return e?typeof e=="string"?{message:t}:e:{message:t}}function dt(e,t,o){return e?typeof e=="function"?{message:e(t)}:typeof e=="string"?{message:e}:e:{message:o}}j.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{j as default,j as juiceToast};
113
+ //# sourceMappingURL=juice-toast.esm.js.map
@@ -1,16 +1,113 @@
1
- !function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=t():"function"==typeof define&&define.amd?define(t):e.juiceToast=t()}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(){"use strict";let e="undefined"!=typeof window&&"undefined"!=typeof document,t=e&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class i{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(e){return Math.floor((e-1)/2)}_left(e){return 2*e+1}_right(e){return 2*e+2}_swap(e,t){[this._heap[e],this._heap[t]]=[this._heap[t],this._heap[e]]}push(e,t=0){let s={item:e,priority:t,seq:i._seq=(i._seq||0)+1};this._heap.push(s),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);let e=this._heap.pop();return this._siftDown(0),e.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(e){for(;e>0;){let t=this._parent(e);if(0>=this._compare(e,t))break;this._swap(e,t),e=t}}_siftDown(e){for(;;){let t=this._left(e),i=this._right(e),s=this._heap.length,o=e;if(t<s&&this._compare(t,o)>0&&(o=t),i<s&&this._compare(i,o)>0&&(o=i),o===e)break;this._swap(e,o),e=o}}_compare(e,t){let i=this._heap[e],s=this._heap[t];return i.priority!==s.priority?i.priority-s.priority:s.seq-i.seq}}let s=!1,o=`/* JuiceToast base (v1.4.1) */
2
- #juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
3
- #juice-toast-root[data-position="bottom-right"],#juice-toast-root-bottom-right{bottom:20px;right:20px;flex-direction:column-reverse;align-items:flex-end}
4
- #juice-toast-root[data-position="top-right"]{top:20px;right:20px;flex-direction:column;align-items:flex-end}
5
- #juice-toast-root[data-position="bottom-left"]{bottom:20px;left:20px;flex-direction:column-reverse;align-items:flex-start}
6
- #juice-toast-root[data-position="top-left"]{top:20px;left:20px;flex-direction:column;align-items:flex-start}
7
- #juice-toast-root[data-position="top-center"],#juice-toast-root[data-position="bottom-center"]{left:50%;transform:translateX(-50%)}
8
- .juice-toast{pointer-events:auto;min-width:220px;max-width:420px;padding:12px 16px;margin:6px 0;border-radius:10px;background:linear-gradient(180deg,rgba(30,30,30,.95),rgba(20,20,20,.95));color:#fff;display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;transition:opacity .28s ease,transform .32s ease}
9
- .juice-toast.show{opacity:1;transform:translateY(0)}
10
- .juice-toast.hide{opacity:0;transform:translateY(12px);pointer-events:none}
11
- .juice-toast .icon{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06)}
12
- .jt-content{display:flex;flex-direction:column;gap:4px;flex:1}
13
- .jt-title{font-weight:700;font-size:13px}.jt-message{font-size:13px;opacity:.95}
14
- .jt-actions{display:flex;gap:8px;margin-top:10px}.jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent}
15
- .jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear}
16
- `,n,a=(n=1,()=>"jt-"+n++);function r(){return Date.now()}function l(e,t){return Object.assign({},e||{},t||{})}let d={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},p={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},c={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new i,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,setup(e={}){let{duration:t,maxVisible:i,...s}=e;t&&(this._defaults.duration=t),i&&(this._defaults.maxVisible=i),this._config=l(this._config,s),this._registerTypes()},use(e){"function"==typeof e&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){d[e]=l(d[e]||{},t)},setTheme(t){this._theme=t,e&&this._roots.forEach(e=>e.dataset.theme=t)},clear(){this._queue=new i,this._queueDedupe.clear()},destroy(){this.clear(),e&&(this._roots.forEach(e=>e.remove()),this._roots.clear())},promise(e,t={}){if(!e||"function"!=typeof e.then){this._warn("promise expects a Promise");return}let i={id:a()},s=i.id,o=t.timeout;var n,r="Loading...";this._enqueue("loading",{...(n=t.loading,n?"string"==typeof n?{message:n}:n:{message:r}),groupId:s,duration:0});let l=null;o&&(l=setTimeout(()=>{this._enqueue("error",{message:t.timeoutMessage||"Request timeout",groupId:s}),d()},o));let d=()=>{l&&clearTimeout(l)};return e.then(e=>{d(),this._enqueue("success",{...u(t.success,e,"Success"),groupId:s})}).catch(e=>{d(),this._enqueue("error",{...u(t.error,e,"Error"),groupId:s})}),{cancel:()=>{this._enqueue("info",{message:t.cancelMessage||"Cancelled",groupId:s}),l&&clearTimeout(l)}}},_registerTypes(){Object.keys(this._config).forEach(e=>{if("function"==typeof this[e]&&!this[e].__auto)return;let t=t=>this._enqueue(e,t);t.__auto=!0,this[e]=t})},_enqueue(e,t={}){let i=this._priorityMap?.[t.priority]??2,s=t.dedupeKey;if(s&&this._queueDedupe.has(s)){this._defaults.dev&&console.log("[JuiceToast] deduped",s);return}let o={id:a(),type:e,payload:t,priority:i};s&&this._queueDedupe.add(s),this._queue.push(o,i),this._processQueue()},_processQueue(){if(!e)return;let t=this._defaults.maxVisible;for(;this._queue.size>0;){let i=this._queue.pop();if(!i)break;let s=i.payload?.position||"bottom-right",o=this._getRoot(s),n=Array.from(o.children).length;if(n>=t){this._queue.push(i,i.priority-.001);break}this._showToast(i.type,i.payload,i.id)}},_getRoot(t="bottom-right"){if(!e)return null;if(this._roots.has(t))return this._roots.get(t);let i=document.createElement("div");switch(i.id=`juice-toast-root-${t}`,i.dataset.position=t,i.dataset.theme=this._theme,i.style.pointerEvents="none",i.style.display="flex",t){case"top-left":i.style.top="20px",i.style.left="20px";break;case"top-right":i.style.top="20px",i.style.right="20px";break;case"bottom-left":i.style.bottom="20px",i.style.left="20px";break;case"bottom-right":default:i.style.bottom="20px",i.style.right="20px";break;case"top-center":i.style.top="20px",i.style.left="50%",i.style.transform="translateX(-50%)";break;case"bottom-center":i.style.bottom="20px",i.style.left="50%",i.style.transform="translateX(-50%)"}return document.body.appendChild(i),this._roots.set(t,i),i},_warn(e){this._defaults.dev&&"undefined"!=typeof console&&console.warn("[JuiceToast]",e)},_playSound(t){if(!e)return;let i="string"==typeof t&&t?t:this._defaults.playSound;if(i)try{let s=new Audio(i);s.volume=.6,s.play().catch(()=>{})}catch(o){}},_updateStackPositionsFor(e){let t=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),t.forEach((e,t)=>{let i=t;e.style.setProperty("--jt-stack-y",`-${12*i}px`),e.style.setProperty("--jt-stack-scale",1-.04*i),e.style.setProperty("--jt-stack-opacity",1-.12*i),e.style.zIndex=1e3-i})},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(i){this._warn("Plugin error: "+i.message)}})},_normalizeGlass(e){var t;if(!0===e)return 60;if(!e)return 0;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.min(100,t=i)):0},_showToast(i,n={},c){if(!e)return;!1!==this._defaults.injectCSS&&function t(i=o){if(!e||s)return;let n=document.createElement("style");n.id="juice-toast-style",n.textContent=i,document.head.appendChild(n),s=!0}(this._defaults.css||o);let u=this._config[i]||{},f="object"==typeof n?n:{message:String(n)},m=l(u,f);m.icon=m.icon??m.icon_left_top,m.position=m.position??m.toast??"bottom-right",m.closable=m.closable??m.closeable??!0,m.duration=m.duration??this._defaults.duration;let g=d[m.theme||this._theme]||{},$=c||a(),y=document.createElement("div");if(y.className="juice-toast",y.dataset.toastId=$,y.dataset.position=m.position,y.tabIndex=0,y.setAttribute("role","status"),y.style.position="relative",y.style.pointerEvents="auto",y.style.background=m.bg||g.bg,y.style.color=m.color||g.color,y.style.border=m.border||g.border||"none",m.size&&p[m.size]){let x=p[m.size];x.width&&(y.style.width=x.width),x.padding&&(y.style.padding=x.padding)}let b=document.createElement("div");if(b.className="jt-content",m.title){let v=document.createElement("div");v.className="jt-title",v.textContent=m.title,b.appendChild(v)}let _=document.createElement("div");if(_.className="jt-message",m.html)_.innerHTML=function e(t){if(!t)return"";let i=document.createElement("template");i.innerHTML=t,i.content.querySelectorAll("script, style, [onload], [onerror], [onclick], iframe").forEach(e=>e.remove());let s=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6"];return!function e(t){Array.from(t.childNodes).forEach(t=>{1===t.nodeType&&(s.includes(t.tagName.toLowerCase())?e(t):t.replaceWith(...Array.from(t.childNodes)))})}(i.content),i.innerHTML}(m.html);else if("string"==typeof m.message){let j=m.message.split(/(`[^`]+`)/g);j.forEach(e=>{if(e.startsWith("`")&&e.endsWith("`")){let t=document.createElement("code");t.textContent=e.slice(1,-1),_.appendChild(t)}else _.appendChild(document.createTextNode(e))})}else m.message&&(_.textContent=String(m.message));if(b.appendChild(_),Array.isArray(m.actions)&&m.actions.length){let E=document.createElement("div");E.className="jt-actions",m.actions.forEach(e=>{let t=document.createElement("button");t.className="jt-action",t.textContent=e.label||"Action",t.onclick=t=>{t.stopPropagation(),e.onClick?.(t),e.closeOnClick&&J()},E.appendChild(t)}),b.appendChild(E)}let k=null;if(m.icon){if((k=document.createElement("i")).className=["icon",m.iconPack||"",m.icon].join(" ").trim(),m.iconSize&&(k.style.fontSize=m.iconSize),!t){let w=m.iconAnim||h[i];w&&k.classList.add(w)}(m.iconLink||m.iconAnimate)&&(k.classList.add("icon-clickable"),k.addEventListener("click",e=>{e.stopPropagation(),m.iconAnimate&&(k.classList.remove(m.iconAnimate),k.offsetWidth,k.classList.add(m.iconAnimate)),m.iconLink&&window.open(m.iconLink,"_blank","noopener")}))}k&&"right"===m.iconPosition?(y.appendChild(b),y.appendChild(k)):k&&"top"===m.iconPosition?(y.classList.add("jt-icon-top"),y.appendChild(k),y.appendChild(b)):(k&&y.appendChild(k),y.appendChild(b));let C=null;if(m.progress&&(m.duration??this._defaults.duration)>0&&((C=document.createElement("div")).className="jt-progress",m.progressColor&&(C.style.background=m.progressColor),y.appendChild(C)),m.undo){let L=document.createElement("button");L.className="jt-action",L.textContent="Undo",L.onclick=()=>{try{m.undo()}catch(e){}J()},b.appendChild(L)}if(m.closable){let q=document.createElement("span");q.className="juice-toast-close",q.tabIndex=0,q.textContent="\xd7",q.addEventListener("click",e=>{e.stopPropagation(),J()}),y.appendChild(q)}let S=this._getRoot(m.position||"bottom-right");if(!S)return;if(m.groupId){let P=Array.from(S.children).find(e=>e.dataset.groupId===m.groupId);if(P){let T=P.querySelector(".jt-count");T||((T=document.createElement("span")).className="jt-count",T.style.marginLeft="6px",P.querySelector(".jt-title")?.appendChild(T),T.textContent="1"),T.textContent=String(parseInt(T.textContent||"1")+1);return}y.dataset.groupId=m.groupId}let N=this._defaults.maxVisible;N&&S.children.length>=N&&S.removeChild(S.firstElementChild),S.appendChild(y);let z={id:$,toast:y,cfg:m,createdAt:r(),remaining:m.duration??this._defaults.duration,raf:null,timer:null,start:r(),paused:!1};this._activeMap.set($,z),this._runPlugins({toast:y,cfg:m,type:i,root:S}),this._updateStackPositionsFor(S),requestAnimationFrame(()=>y.classList.add("show"));let I=0,M=0,A=0,X=0,D=!1,Y=e=>{let t=e.touches?e.touches[0]:e;I=t.clientX,M=t.clientY,D=!0,z.paused=!0,y.style.transition="none"},F=e=>{if(!D)return;let t=e.touches?e.touches[0]:e;Math.abs(A=t.clientX-I)>Math.abs(X=t.clientY-M)?y.style.transform=`translateX(${A}px)`:y.style.transform=`translateY(${X}px)`},R=()=>{D=!1,z.paused=!1,y.style.transition="";let e=Math.abs(A)>(this._defaults.swipeThreshold||60);e?(y.style.transform=`translateX(${A>0?1e3:-1e3}px)`,setTimeout(J,220)):y.style.transform="",I=M=A=X=0};y.addEventListener("touchstart",Y,{passive:!0}),y.addEventListener("mousedown",Y),window.addEventListener("touchmove",F,{passive:!0}),window.addEventListener("mousemove",F),window.addEventListener("touchend",R),window.addEventListener("mouseup",R);let U=()=>z.paused=!0,V=()=>z.paused=!1;y.addEventListener("mouseenter",U),y.addEventListener("mouseleave",V),y.addEventListener("focusin",U),y.addEventListener("focusout",V);let W=m.duration??this._defaults.duration;if(W>0){z.start=r(),z.remaining=W;let H=()=>{if(this._activeMap.has($)){if(z.paused)z.start=r();else{let e=r()-z.start;z.remaining-=e,z.start=r()}if(C){let t=Math.max(0,z.remaining/W);C.style.transform=`scaleX(${t})`}z.remaining<=0?(y.classList.remove("show"),setTimeout(J,280)):z.raf=requestAnimationFrame(H)}};z.raf=requestAnimationFrame(H)}let J=()=>{if(!this._activeMap.has($))return;y.classList.add("hide"),y.removeEventListener("touchstart",Y),y.removeEventListener("mousedown",Y),window.removeEventListener("touchmove",F),window.removeEventListener("mousemove",F),window.removeEventListener("touchend",R),window.removeEventListener("mouseup",R),y.removeEventListener("mouseenter",U),y.removeEventListener("mouseleave",V),y.removeEventListener("focusin",U),y.removeEventListener("focusout",V),z.raf&&cancelAnimationFrame(z.raf),z.timer&&clearTimeout(z.timer),this._activeMap.delete($);let e=y.parentNode;e&&e.removeChild(y),e&&this._updateStackPositionsFor(e)};return m.undoTimeout&&(z.timer=setTimeout(J,m.undoTimeout)),(m.playSound||this._defaults.playSound)&&this._playSound(m.playSound||this._defaults.playSound),$},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function u(e,t,i){return e?"function"==typeof e?{message:e(t)}:"string"==typeof e?{message:e}:e:{message:i}}let h={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"};return c.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),c});
1
+ (function(w,S){typeof exports=="object"&&typeof module!="undefined"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(w=typeof globalThis!="undefined"?globalThis:w||self,S(w.juiceToast={}))})(this,(function(w){"use strict";var S=Object.defineProperty,me=Object.defineProperties,he=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,te=(t,e,n)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))Z.call(e,n)&&te(t,n,e[n]);if(N)for(var n of N(e))ee.call(e,n)&&te(t,n,e[n]);return t},R=(t,e)=>me(t,he(e)),fe=(t,e)=>{var n={};for(var r in t)Z.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&N)for(var r of N(t))e.indexOf(r)<0&&ee.call(t,r)&&(n[r]=t[r]);return n};const y=typeof window!="undefined"&&typeof document!="undefined",ge=y&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class T{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(e){return Math.floor((e-1)/2)}_left(e){return 2*e+1}_right(e){return 2*e+2}_swap(e,n){[this._heap[e],this._heap[n]]=[this._heap[n],this._heap[e]]}push(e,n=0){const r={item:e,priority:n,seq:T._seq=(T._seq||0)+1};this._heap.push(r),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const e=this._heap.pop();return this._siftDown(0),e.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(e){for(;e>0;){const n=this._parent(e);if(this._compare(e,n)<=0)break;this._swap(e,n),e=n}}_siftDown(e){for(;;){const n=this._left(e),r=this._right(e),l=this._heap.length;let c=e;if(n<l&&this._compare(n,c)>0&&(c=n),r<l&&this._compare(r,c)>0&&(c=r),c===e)break;this._swap(e,c),e=c}}_compare(e,n){const r=this._heap[e],l=this._heap[n];return r.priority!==l.priority?r.priority-l.priority:l.seq-r.seq}}let $=!1;const V=`
2
+ /* JuiceToast base (v1.4.0) */
3
+ #juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
4
+ #juice-toast-root[data-position="bottom-right"],#juice-toast-root-bottom-right{bottom:20px;right:20px;flex-direction:column-reverse;align-items:flex-end}
5
+ #juice-toast-root[data-position="top-right"]{top:20px;right:20px;flex-direction:column;align-items:flex-end}
6
+ #juice-toast-root[data-position="bottom-left"]{bottom:20px;left:20px;flex-direction:column-reverse;align-items:flex-start}
7
+ #juice-toast-root[data-position="top-left"]{top:20px;left:20px;flex-direction:column;align-items:flex-start}
8
+ #juice-toast-root[data-position="top-center"],#juice-toast-root[data-position="bottom-center"]{left:50%;transform:translateX(-50%)}
9
+ .juice-toast{pointer-events:auto;min-width:220px;max-width:420px;padding:12px 16px;margin:6px 0;border-radius:10px;background:linear-gradient(180deg,rgba(30,30,30,.95),rgba(20,20,20,.95));color:#fff;display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;transition:opacity .28s ease,transform .32s ease}
10
+ @keyframes jt-slide-in{0%{opacity:0;transform:translateY(20px) scale(0.95)}100%{opacity:1;transform:translateY(0) scale(1)}}
11
+ @keyframes jt-slide-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(20px) scale(0.95)}}
12
+ .juice-toast.show{animation:jt-slide-in .32s cubic-bezier(0.4,0,0.2,1) forwards;opacity:1;transform:translateY(0)}
13
+ .juice-toast.hide{animation:jt-slide-out .28s cubic-bezier(0.4,0,0.2,1) forwards;opacity:0;transform:translateY(12px);pointer-events:none}
14
+ .juice-toast .icon{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06)}
15
+ .jt-content{display:flex;flex-direction:column;gap:4px;flex:1}
16
+ .jt-title{font-weight:700;font-size:13px}
17
+ .jt-message{font-size:13px;opacity:.95}
18
+ .jt-actions{display:flex;gap:8px;margin-top:10px}
19
+ .jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent}
20
+ .jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear}
21
+
22
+ /* avatar specific */
23
+ .jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0}
24
+
25
+ /* ---------------- Modal ---------------- */
26
+ /* Overlay */
27
+ .jt-modal-overlay{
28
+ position:fixed;
29
+ inset:0;
30
+ display:flex;
31
+ align-items:center;
32
+ justify-content:center;
33
+ padding:20px;
34
+ background:rgba(15,23,42,.55);
35
+ backdrop-filter:blur(6px) saturate(120%);
36
+ -webkit-backdrop-filter:blur(6px) saturate(120%);
37
+ opacity:0;
38
+ transition:opacity .25s ease;
39
+ z-index:10000;
40
+ }
41
+ .jt-modal-overlay.show{
42
+ opacity:1;
43
+ }
44
+
45
+ /* Base modal */
46
+ .jt-modal{
47
+ width:100%;
48
+ max-width:520px;
49
+ border-radius:18px;
50
+ padding:24px;
51
+
52
+ opacity:0;
53
+ transform:translateY(40px) scale(.96);
54
+ transition:
55
+ transform .35s cubic-bezier(.16,1,.3,1),
56
+ opacity .25s ease;
57
+ }
58
+
59
+ .jt-modal.show{
60
+ opacity:1;
61
+ transform:translateY(0) scale(1);
62
+ }
63
+
64
+ .jt-modal-header{
65
+ font-size:18px;
66
+ font-weight:600;
67
+ letter-spacing:.3px;
68
+ margin-bottom:10px;
69
+ }
70
+
71
+ .jt-modal-body{
72
+ font-size:14.5px;
73
+ line-height:1.6;
74
+ opacity:.85;
75
+ margin-bottom:22px;
76
+ }
77
+
78
+ .jt-modal-actions{
79
+ display:flex;
80
+ justify-content:flex-end;
81
+ gap:12px;
82
+ }
83
+
84
+ .jt-modal-btn{
85
+ min-width:88px;
86
+ padding:8px 16px;
87
+ border-radius:12px;
88
+ font-size:13.5px;
89
+ font-weight:500;
90
+ cursor:pointer;
91
+ transition:all .2s ease;
92
+ border:1px solid rgba(255,255,255,.08);
93
+ background:rgba(255,255,255,.04);
94
+ color:inherit;
95
+ }
96
+ .jt-modal-btn:hover{
97
+ background:rgba(255,255,255,.08);
98
+ transform:translateY(-1px);
99
+ }
100
+ .jt-modal-btn:active{
101
+ transform:translateY(0);
102
+ }
103
+
104
+ .jt-modal-btn.primary{
105
+ background:#6366f1;
106
+ border-color:#6366f1;
107
+ color:#fff;
108
+ }
109
+ .jt-modal-btn.primary:hover{
110
+ background:#5458ee;
111
+ }
112
+ `;function ne(t=V){if(!y||$)return;if(document.getElementById("juice-toast-style")){$=!0;return}const e=document.createElement("style");e.id="juice-toast-style",e.textContent=t,document.head.appendChild(e),$=!0}const W=(()=>{let t=1;return()=>"jt-"+t++})();function v(){return Date.now()}function z(t,e){return Object.assign({},t||{},e||{})}function be(t,e,n){return Math.max(e,Math.min(n,t))}function oe(t){if(!t)return"";const e=document.createElement("template");e.innerHTML=t,e.content.querySelectorAll("script, style, iframe").forEach(r=>r.remove());const n=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function r(l){Array.from(l.childNodes).forEach(c=>{if(c.nodeType===1){const h=c.tagName.toLowerCase();n.includes(h)?(Array.from(c.attributes||[]).forEach(g=>{const m=g.name.toLowerCase(),f=g.value||"";(m.startsWith("on")||(m==="href"||m==="src"||m==="xlink:href")&&f.trim().toLowerCase().startsWith("javascript:")||h==="img"&&m==="srcset")&&c.removeAttribute(g.name)}),r(c)):c.replaceWith(...Array.from(c.childNodes))}})})(e.content),e.innerHTML}const P={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},se={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},ye={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},x={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new T,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],setup(t={}){const e=t,{duration:n,maxVisible:r}=e,l=fe(e,["duration","maxVisible"]);n&&(this._defaults.duration=n),r&&(this._defaults.maxVisible=r),this._config=z(this._config,l),this._registerTypes()},use(t){typeof t=="function"&&this._plugins.push(t)},addType(t,e={}){this._config[t]=e,this._registerTypes()},defineTheme(t,e={}){P[t]=z(P[t]||{},e)},setTheme(t){this._theme=t,y&&this._roots.forEach(e=>e.dataset.theme=t)},clear(){this._queue=new T,this._queueDedupe.clear()},destroy(){this.clear(),y&&(this._roots.forEach(t=>t.remove()),this._roots.clear())},promise(t,e={}){if(!t||typeof t.then!="function"){this._warn("promise expects a Promise");return}const n={id:W()}.id,r=e.timeout;this._enqueue("loading",R(X({},ve(e.loading,"Loading...")),{groupId:n,duration:0}));let l=null;r&&(l=setTimeout(()=>{this._enqueue("error",{message:e.timeoutMessage||"Request timeout",groupId:n}),c()},r));const c=()=>{l&&clearTimeout(l)};return t.then(h=>{c(),this._enqueue("success",R(X({},ae(e.success,h,"Success")),{groupId:n}))}).catch(h=>{c(),this._enqueue("error",R(X({},ae(e.error,h,"Error")),{groupId:n}))}),{cancel:()=>{this._enqueue("info",{message:e.cancelMessage||"Cancelled",groupId:n}),l&&clearTimeout(l)}}},modal(t={}){var e;if(!y)return;this._defaults.injectCSS!==!1&&ne(this._defaults.css||V);const n=z({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},t),r=P[n.theme]||P.dark,l=document.createElement("div");l.className="jt-modal-overlay",n.block?l.style.pointerEvents="all":l.style.pointerEvents="none",n.blur||(l.style.backdropFilter="none",l.style.webkitBackdropFilter="none");const c=document.createElement("div");if(c.className=`jt-modal jt-anim-${n.animation}`,c.style.background=r.bg,c.style.color=r.color,c.style.border=r.border||"none",n.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=n.title,c.appendChild(m)}const h=document.createElement("div");if(h.className="jt-modal-body",n.html?h.innerHTML=oe(n.html):h.textContent=n.message||"",c.appendChild(h),(e=n.actions)!=null&&e.length){const m=document.createElement("div");m.className="jt-modal-actions",n.actions.forEach(f=>{const k=document.createElement("button");k.className="jt-modal-btn"+(f.primary?" primary":""),k.textContent=f.label||"OK",k.onclick=q=>{var A;q.stopPropagation(),(A=f.onClick)==null||A.call(f,q),f.closeOnClick!==!1&&g()},m.appendChild(k)}),c.appendChild(m)}l.appendChild(c),document.body.appendChild(l),n.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{l.classList.add("show"),c.classList.add("show")});const g=()=>{l.classList.remove("show"),c.classList.remove("show"),setTimeout(()=>{l.remove(),n.block&&(document.body.style.overflow="")},300)};if(n.closable){n.closeOnOverlay&&l.addEventListener("click",f=>{f.target===l&&g()});const m=f=>{f.key==="Escape"&&(g(),document.removeEventListener("keydown",m))};document.addEventListener("keydown",m)}return{close:g}},_registerTypes(){Object.keys(this._config).forEach(t=>{if(typeof this[t]=="function"&&!this[t].__auto)return;const e=n=>this._enqueue(t,n);e.__auto=!0,this[t]=e})},_enqueue(t,e={}){var n,r;const l=(r=(n=this._priorityMap)==null?void 0:n[e.priority])!=null?r:2,c=e.dedupeKey;if(c&&this._queueDedupe.has(c)){this._defaults.dev&&console.log("[JuiceToast] deduped",c);return}const h={id:W(),type:t,payload:e,priority:l};c&&this._queueDedupe.add(c),this._queue.push(h,l),this._processQueue()},_processQueue(){var t;if(!y)return;const e=this._defaults.maxVisible;for(;this._queue.size>0;){const n=this._queue.pop();if(!n)break;const r=((t=n.payload)==null?void 0:t.position)||"bottom-right",l=this._getRoot(r);if(Array.from(l.children).length>=e){this._queue.push(n,n.priority-.001);break}this._showToast(n.type,n.payload,n.id)}},_getRoot(t="bottom-right"){if(!y)return null;if(this._roots.has(t))return this._roots.get(t);const e=document.createElement("div");switch(e.id=`juice-toast-root-${t}`,e.dataset.position=t,e.dataset.theme=this._theme,e.style.pointerEvents="none",e.style.display="flex",t){case"top-left":e.style.top="20px",e.style.left="20px";break;case"top-right":e.style.top="20px",e.style.right="20px";break;case"bottom-left":e.style.bottom="20px",e.style.left="20px";break;case"bottom-right":e.style.bottom="20px",e.style.right="20px";break;case"top-center":e.style.top="20px",e.style.left="50%",e.style.transform="translateX(-50%)";break;case"bottom-center":e.style.bottom="20px",e.style.left="50%",e.style.transform="translateX(-50%)";break;default:e.style.bottom="20px",e.style.right="20px"}return document.body.appendChild(e),this._roots.set(t,e),e},_warn(t){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",t)},_playSound(t){if(!y)return;const e=typeof t=="string"&&t?t:this._defaults.playSound;if(e)try{const n=new Audio(e);n.volume=.6,n.play().catch(()=>{})}catch(n){}},_updateStackPositionsFor(t){const e=Array.from(t.children);t.dataset.position&&t.dataset.position.includes("bottom"),e.forEach((n,r)=>{const l=r,c=l*12;n.style.setProperty("--jt-stack-y",`-${c}px`),n.style.setProperty("--jt-stack-scale",1-l*.04),n.style.setProperty("--jt-stack-opacity",1-l*.12),n.style.zIndex=1e3-l})},_runPlugins(t){this._plugins.forEach(e=>{try{e(t)}catch(n){this._warn("Plugin error: "+n.message)}})},_normalizeGlass(t){if(t===!0)return 60;if(!t)return 0;const e=Number(t);return Number.isFinite(e)?be(e,0,100):0},_showToast(t,e={},n){var r,l,c,h,g,m,f,k,q,A,ie,re,le;if(!y)return;this._defaults.injectCSS!==!1&&ne(this._defaults.css||V);const xe=this._config[t]||{},_e=typeof e=="object"?e:{message:String(e)},o=z(xe,_e);o.icon=(r=o.icon)!=null?r:o.icon_left_top,o.position=(c=(l=o.position)!=null?l:o.toast)!=null?c:"bottom-right",o.closable=(g=(h=o.closable)!=null?h:o.closeable)!=null?g:!0,o.duration=(m=o.duration)!=null?m:this._defaults.duration;const B=P[o.theme||this._theme]||{},_=n||W(),s=document.createElement("div");if(s.className="juice-toast",s.dataset.toastId=_,s.dataset.position=o.position,s.tabIndex=0,s.setAttribute("role","status"),s.style.position="relative",s.style.pointerEvents="auto",s.style.background=o.bg||B.bg,s.style.color=o.color||B.color,s.style.border=o.border||B.border||"none",o.size&&se[o.size]){const a=se[o.size];a.width&&(s.style.width=a.width),a.padding&&(s.style.padding=a.padding)}const b=document.createElement("div");if(b.className="jt-content",o.title){const a=document.createElement("div");a.className="jt-title",a.textContent=o.title,b.appendChild(a)}const E=document.createElement("div");if(E.className="jt-message",o.html?E.innerHTML=oe(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(a=>{if(a.startsWith("`")&&a.endsWith("`")){const d=document.createElement("code");d.textContent=a.slice(1,-1),E.appendChild(d)}else E.appendChild(document.createTextNode(a))}):o.message&&(E.textContent=String(o.message)),b.appendChild(E),Array.isArray(o.actions)&&o.actions.length){const a=document.createElement("div");a.className="jt-actions",o.actions.forEach(d=>{const D=document.createElement("button");D.className="jt-action",D.textContent=d.label||"Action",D.onclick=ue=>{var pe;ue.stopPropagation(),(pe=d.onClick)==null||pe.call(d,ue),d.closeOnClick&&M()},a.appendChild(D)}),b.appendChild(a)}let p=null;if(o.icon){if(p=document.createElement("i"),p.className=["icon",o.iconPack||"",o.icon].join(" ").trim(),o.iconSize&&(p.style.fontSize=o.iconSize),!ge){const a=o.iconAnim||ye[t];a&&p.classList.add(a)}(o.iconLink||o.iconAnimate)&&(p.classList.add("icon-clickable"),p.addEventListener("click",a=>{a.stopPropagation(),o.iconAnimate&&(p.classList.remove(o.iconAnimate),p.offsetWidth,p.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let u=null;if(o.avatar){u=document.createElement("img");const a=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";a&&(u.src=a),u.alt=o.avatarAlt||o.title||"avatar",u.className="jt-avatar",u.loading=o.avatarLazy?"lazy":"eager",u.style.width=u.style.width||"36px",u.style.height=u.style.height||"36px",u.style.borderRadius=u.style.borderRadius||"50%",u.style.objectFit=u.style.objectFit||"cover",u.style.flexShrink="0";const d=o.avatarPosition||"left";d==="left"?u.style.marginRight=(f=o.avatarSpacing)!=null?f:"10px":d==="right"?u.style.marginLeft=(k=o.avatarSpacing)!=null?k:"10px":d==="top"&&(u.style.marginBottom=(q=o.avatarSpacing)!=null?q:"8px")}const H=o.avatarPosition||"left";u&&H==="top"?(s.classList.add("jt-avatar-top"),s.style.flexDirection="column",s.style.alignItems="flex-start",s.appendChild(u),p&&o.iconPosition==="top"?(s.appendChild(p),s.appendChild(b)):p&&o.iconPosition==="right"?(s.appendChild(b),s.appendChild(p)):(p&&s.appendChild(p),s.appendChild(b))):(s.style.flexDirection="row",s.style.alignItems="center",u&&H==="left"&&s.appendChild(u),p&&o.iconPosition==="right"?(s.appendChild(b),s.appendChild(p)):p&&o.iconPosition==="top"?(s.classList.add("jt-icon-top"),s.appendChild(p),s.appendChild(b)):(p&&s.appendChild(p),s.appendChild(b)),u&&H==="right"&&s.appendChild(u));let C=null;if(o.progress&&((A=o.duration)!=null?A:this._defaults.duration)>0&&(C=document.createElement("div"),C.className="jt-progress",o.progressColor&&(C.style.background=o.progressColor),s.appendChild(C)),o.undo){const a=document.createElement("button");a.className="jt-action",a.textContent="Undo",a.onclick=()=>{try{o.undo()}catch(d){}M()},b.appendChild(a)}if(o.closable){const a=document.createElement("span");a.className="juice-toast-close",a.tabIndex=0,a.textContent="\xD7",a.addEventListener("click",d=>{d.stopPropagation(),M()}),s.appendChild(a)}const j=this._getRoot(o.position||"bottom-right");if(!j)return;if(o.groupId){const a=Array.from(j.children).find(d=>d.dataset.groupId===o.groupId);if(a){let d=a.querySelector(".jt-count");d||(d=document.createElement("span"),d.className="jt-count",d.style.marginLeft="6px",(ie=a.querySelector(".jt-title"))==null||ie.appendChild(d),d.textContent="1"),d.textContent=String(parseInt(d.textContent||"1")+1);return}s.dataset.groupId=o.groupId}const ce=this._defaults.maxVisible;ce&&j.children.length>=ce&&j.removeChild(j.firstElementChild),j.appendChild(s);const i={id:_,toast:s,cfg:o,createdAt:v(),remaining:(re=o.duration)!=null?re:this._defaults.duration,raf:null,timer:null,start:v(),paused:!1,_boundMove:null,_boundUp:null};this._activeMap.set(_,i),this._runPlugins({toast:s,cfg:o,type:t,root:j}),this._updateStackPositionsFor(j),requestAnimationFrame(()=>s.classList.add("show"));let J=0,K=0,L=0,O=0,Q=!1;const I=a=>{const d=a.touches?a.touches[0]:a;J=d.clientX,K=d.clientY,Q=!0,i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null),s.style.transition="none",i._boundMove=je,i._boundUp=we,document.addEventListener("touchmove",i._boundMove,{passive:!0}),document.addEventListener("mousemove",i._boundMove),document.addEventListener("touchend",i._boundUp),document.addEventListener("mouseup",i._boundUp)},je=a=>{if(!Q)return;const d=a.touches?a.touches[0]:a;L=d.clientX-J,O=d.clientY-K,Math.abs(L)>Math.abs(O)?s.style.transform=`translateX(${L}px)`:s.style.transform=`translateY(${O}px)`},we=()=>{Q=!1,i.paused=!1,s.style.transition="",Math.abs(L)>(this._defaults.swipeThreshold||60)?(s.style.transform=`translateX(${L>0?1e3:-1e3}px)`,setTimeout(M,220)):s.style.transform="",J=K=L=O=0,i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),G()};s.addEventListener("touchstart",I,{passive:!0}),s.addEventListener("mousedown",I);const U=()=>{i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null)},F=()=>{i.paused&&(i.paused=!1,i.start=v(),G())};s.addEventListener("mouseenter",U),s.addEventListener("mouseleave",F),s.addEventListener("focusin",U),s.addEventListener("focusout",F);const Y=(le=o.duration)!=null?le:this._defaults.duration;function de(){if(!x._activeMap.has(_))return;if(i.paused){i.raf=null,i.start=v();return}const a=v()-i.start;if(i.remaining-=a,i.start=v(),C){const d=Math.max(0,i.remaining/Y);C.style.transform=`scaleX(${d})`}if(i.remaining<=0){s.classList.remove("show"),setTimeout(M,280),i.raf=null;return}i.raf=requestAnimationFrame(de)}function G(){Y<=0||i.raf||i.paused||(i.start=v(),i.raf=requestAnimationFrame(de))}Y>0&&(i.start=v(),i.remaining=Y,G());function M(){if(!x._activeMap.has(_))return;s.classList.add("hide"),s.removeEventListener("touchstart",I),s.removeEventListener("mousedown",I),i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),s.removeEventListener("mouseenter",U),s.removeEventListener("mouseleave",F),s.removeEventListener("focusin",U),s.removeEventListener("focusout",F);const a=x._activeMap.get(_);a!=null&&a.raf&&(cancelAnimationFrame(a.raf),a.raf=null),a!=null&&a.timer&&(clearTimeout(a.timer),a.timer=null),x._activeMap.delete(_);const d=s.parentNode;d&&d.removeChild(s),d&&x._updateStackPositionsFor(d)}return o.undoTimeout&&(i.timer=setTimeout(M,o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),_},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function ve(t,e){return t?typeof t=="string"?{message:e}:t:{message:e}}function ae(t,e,n){return t?typeof t=="function"?{message:t(e)}:typeof t=="string"?{message:t}:t:{message:n}}x.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),w.default=x,w.juiceToast=x,Object.defineProperty(w,"__esModule",{value:!0})}));
113
+ //# sourceMappingURL=juice-toast.umd.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "juice-toast",
3
- "version": "1.4.0",
4
- "description": "Zero dependency JavaScript toast notification library with animations, dark mode, auto CSS injection, and mobile support",
3
+ "version": "1.4.2",
4
+ "description": "Zero dependency JavaScript toast notification library with animations, dark mode, auto CSS injection, and mobile support",
5
5
  "keywords": [
6
6
  "toast",
7
7
  "toast-js",
@@ -16,7 +16,7 @@
16
16
  "vanilla-js-toast",
17
17
  "frontend-ui",
18
18
  "browser-notification"
19
- ],
19
+ ],
20
20
  "license": "MIT",
21
21
  "author": "KhairyK",
22
22
  "homepage": "https://github.com/KhairyK/juiceToast",
@@ -32,18 +32,16 @@
32
32
  "node": ">=19"
33
33
  },
34
34
  "scripts": {
35
- "format": "npx prettier --write src/"
35
+ "format": "npx prettier --write src/",
36
+ "build": "npx rollup -c"
36
37
  },
37
38
  "module": "dist/juice-toast.esm.js",
38
39
  "types": "dist/juice-toast.d.ts",
39
40
  "exports": {
40
41
  ".": {
41
42
  "import": "./dist/juice-toast.esm.js",
42
- "types": "./dist/juice-toast.d.ts"
43
- },
44
- "./ios": {
45
- "import": "./dist/juice-toast.ios.js",
46
- "types": "./dist/juice-toast-ios.d.ts"
43
+ "types": "./dist/juice-toast.d.ts",
44
+ "require": "./dist/juice-toast.umd.js"
47
45
  }
48
46
  },
49
47
  "files": [
@@ -65,6 +63,9 @@
65
63
  "unpkg": "dist/juice-toast.esm.js",
66
64
  "jsdelivr": "dist/juice-toast.esm.js",
67
65
  "devDependencies": {
68
- "prettier": "^3.8.1"
66
+ "esbuild": "^0.27.3",
67
+ "prettier": "^3.8.1",
68
+ "rollup": "^4.59.0",
69
+ "rollup-plugin-esbuild": "^6.2.1"
69
70
  }
70
71
  }