@editora/toast 2.0.10 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(v,A){typeof exports=="object"&&typeof module!="undefined"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(v=typeof globalThis!="undefined"?globalThis:v||self,A(v.EditoraToast={}))})(this,(function(v){"use strict";class A{constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(i=>i.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class z{constructor(t){this.queue=[],this.visible=[],this.config=this.normalizeConfig(t)}enqueue(t){var o;const e=this.findDuplicate(t);if(e&&((o=t.options.preventDuplicate)!=null?o:this.config.preventDuplicate))return{show:[],hide:[],rejected:e};const s=[];if(t.options.important&&this.visible.length>=this.maxVisible){const r=this.removeLowestPriorityVisible();return this.visible.push(t),{show:[t],hide:r?[...s,r]:s}}this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.sortQueue();const i=this.processQueue();return{show:i.show,hide:[...s,...i.hide]}}dequeue(t){return this.removeFromCollections(t)?{show:this.processQueue().show,hide:[]}:{show:[],hide:[]}}updateConfig(t){return this.config=this.normalizeConfig({...this.config,...t}),this.sortQueue(),this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}isVisible(t){return this.visible.some(e=>e.id===t)}clear(){const t=[...this.visible,...this.queue];return this.queue=[],this.visible=[],t}processQueue(){const t=[],e=[];for(;this.visible.length>this.maxVisible;){const s=this.visible.pop();s&&e.push(s)}for(;this.visible.length<this.maxVisible&&this.queue.length>0;){const s=this.queue.shift();if(!s)break;this.visible.push(s),t.push(s)}return{show:t,hide:e}}removeLowestPriorityVisible(){if(this.visible.length===0)return;let t=0;for(let e=1;e<this.visible.length;e+=1)(this.visible[e].options.priority||0)<(this.visible[t].options.priority||0)&&(t=e);return this.visible.splice(t,1)[0]}removeFromCollections(t){const e=this.visible.findIndex(i=>i.id===t);if(e!==-1)return this.visible.splice(e,1)[0];const s=this.queue.findIndex(i=>i.id===t);if(s!==-1)return this.queue.splice(s,1)[0]}findDuplicate(t){const e=t.options.dedupeScope||this.config.dedupeScope,s=e==="visible"?this.visible:e==="queue"?this.queue:[...this.visible,...this.queue],i=this.getDedupeKey(t);return s.find(o=>this.getDedupeKey(o)===i)}getDedupeKey(t){return t.options.dedupeKey||`${t.options.level||"info"}:${t.options.title||""}:${t.options.message||""}:${t.options.description||""}`}sortQueue(){this.queue.sort((t,e)=>{const s=(e.options.priority||0)-(t.options.priority||0);return s!==0?s:t.createdAt-e.createdAt})}get maxVisible(){return Math.max(1,this.config.visibleToasts||this.config.maxVisible||1)}normalizeConfig(t){return{...t,maxVisible:t.visibleToasts||t.maxVisible}}}const N=new Set(["a","b","strong","i","em","u","s","del","ins","mark","small","sub","sup","code","kbd","br","span","p","ul","ol","li"]),F=new Set(["script","style","iframe","frame","frameset","object","embed","applet","noscript","template","svg","math","form","input","button","textarea","select","option","head","title","link","meta","base","audio","video","canvas"]),I=/^(?:https?:|mailto:|tel:)/i;function Y(c){const t=c.replace(/[\u0000- \u007f-\u009f]/g,"");return t?I.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t):!1}function O(c,t,e){for(const s of Array.from(c.childNodes)){if(s.nodeType===Node.TEXT_NODE){t.appendChild(e.createTextNode(s.textContent||""));continue}if(s.nodeType!==Node.ELEMENT_NODE)continue;const i=s,o=i.localName.toLowerCase();if(F.has(o))continue;if(!N.has(o)){O(i,t,e);continue}const r=e.createElement(o);if(o==="a"){const n=i.getAttribute("href");n&&Y(n)&&(r.setAttribute("href",n.trim()),/^(?:https?:)?\/\//i.test(n.trim())&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")));const a=i.getAttribute("title");a&&r.setAttribute("title",a)}O(i,r,e),t.appendChild(r)}}function V(c,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();O(e.content,s,document),c.textContent="",c.appendChild(s)}class X{constructor(t={}){var e,s,i,o;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(o=t.precision)!=null?o:.01}}animate(t,e,s,i,o){const r={...this.config,...o};let n,a=!1;const l=Object.keys(e).reduce((h,T)=>(h[T]=e[T].from,h),{}),d=Object.keys(e).reduce((h,T)=>(h[T]=0,h),{}),f=()=>{if(a)return;let h=!0;Object.keys(e).forEach(w=>{const P=e[w].to,$=l[w],p=d[w],y=-r.stiffness*($-P),m=-r.damping*p,x=(y+m)/r.mass;d[w]+=x*.016,l[w]+=d[w]*.016,(Math.abs($-P)>r.precision||Math.abs(p)>r.precision)&&(h=!1)});const T=Object.keys(l).reduce((w,P)=>{const $=e[P].unit||"px";return w[P]=`${l[P]}${$}`,w},{});s(T),h?(a=!0,i==null||i()):n=requestAnimationFrame(f)};return n=requestAnimationFrame(f),()=>{a=!0,n&&cancelAnimationFrame(n)}}}class j{constructor(){this.springAnimation=new X}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):await this.animateCssShow(t);break;default:await this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):await this.animateCssHide(t);break;default:await this.animateCssHide(t);break}}async updateToast(t,e,s,i){i.type==="custom"&&i.update&&await Promise.resolve(i.update(t,e,s))}animateCssShow(t){return new Promise(e=>{requestAnimationFrame(()=>{t.classList.add("show"),window.setTimeout(e,220)})})}animateCssHide(t){return new Promise(e=>{t.classList.remove("show"),t.classList.add("hiding"),window.setTimeout(e,220)})}async animateSpringShow(t,e){return new Promise(s=>{var r,n,a;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const o=((r=t.parentElement)==null?void 0:r.classList.contains("editora-toast-bottom-right"))||((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-left"))||((a=t.parentElement)==null?void 0:a.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${o}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var d,f,h;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",n=e.duration||800,a=r==="gentle"?.05:r==="strong"?.15:.1,l=o==="up"?30:o==="down"?-30:o==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1-a})`:`translateY(${l}px) scale(${1-a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.05:i==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var d,f,h;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.distance||100,n=e.easing||"ease-out",a=e.duration||400,l=o==="up"?`translateY(${r}px)`:o==="down"?`translateY(-${r}px)`:o==="left"?`translateX(${r}px)`:`translateX(-${r}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${n}, transform ${a}ms ${n}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"down",o=e.distance||100,r=e.easing||"ease-in",n=e.duration||300,a=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${r}, transform ${n}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-out",n=e.duration||500;t.style.setProperty("transform-origin",o,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${r}, transform ${n}ms ${r}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-in",n=e.duration||300;t.style.setProperty("transform-origin",o,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${r}, transform ${n}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"forward",n=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const a=r==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},n)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"backward",n=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const a=r==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},n)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||300;let n="translateY(0) translateX(0)";i!=="none"&&(n=i==="up"?`translateY(${o}px)`:i==="down"?`translateY(-${o}px)`:i==="left"?`translateX(${o}px)`:`translateX(-${o}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",n,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||200;let n="translateY(0) translateX(0)";i!=="none"&&(n=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",n,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var d,f,h;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",n=e.duration||1e3,a=r==="gentle"?.1:r==="strong"?.3:.2,l=o==="up"?40:o==="down"?-40:o==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1+a})`:`translateY(${l}px) scale(${1+a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.1:i==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||360,o=e.direction||"clockwise",r=e.origin||"center",n=e.duration||500,a=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||180,o=e.direction||"counterclockwise",r=e.origin||"center",n=e.duration||300,a=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}}const q=new j;class W{constructor(t){this.containers=new Map,this.cssInjected=!1,this.config=t}updateConfig(t){this.config=t,this.containers.forEach((e,s)=>{this.applyContainerStyles(e,s),this.applyStackState(e)})}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");return e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite"),e.dataset.expand=String(this.config.expand),e.dataset.stack=String(this.config.stack),this.applyContainerStyles(e,t),document.body.appendChild(e),this.containers.set(t,e),this.injectCSS(),e}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,s.dataset.level=e.level||"info",e.customClass&&e.customClass.split(/\s+/).filter(Boolean).forEach(n=>s.classList.add(n)),s.setAttribute("role",e.role||(e.level==="error"?"alert":"status")),s.setAttribute("aria-atomic","true"),e.ariaLive&&e.ariaLive!=="off"&&s.setAttribute("aria-live",e.ariaLive);const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(this.config.richColors||i==="colored")&&s.setAttribute("data-rich-colors","true"),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const r=this.createContent(t);if(e.progress){const n=document.createElement("div");n.className="editora-toast-progress-track",n.setAttribute("role","progressbar"),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax","100"),n.setAttribute("aria-valuenow",String(Math.min(100,Math.max(0,e.progress.value))));const a=document.createElement("div");if(a.className="editora-toast-progress-bar",a.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`,e.progress.showPercentage){const l=document.createElement("span");l.className="editora-toast-progress-text",l.textContent=`${Math.round(e.progress.value)}%`,n.appendChild(l)}n.appendChild(a),r.appendChild(n)}if(s.appendChild(r),e.actions&&e.actions.length>0){const n=document.createElement("div");n.className="editora-toast-actions",e.actions.forEach(a=>n.appendChild(this.createActionButton(a,t))),s.appendChild(n)}return(e.closable||e.closeButton)&&s.appendChild(this.createCloseButton(t)),e.pauseOnHover&&(s.addEventListener("mouseenter",()=>this.pauseToast(t)),s.addEventListener("mouseleave",()=>this.resumeToast(t))),e.pauseOnFocus&&(s.addEventListener("focusin",()=>this.pauseToast(t)),s.addEventListener("focusout",()=>this.resumeToast(t))),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var o,r;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s),this.applyStackState(e);const i=t.options.animation||this.config.animation||{type:"css"};if(await q.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(r=(o=t.options).onShow)==null||r.call(o),!t.options.persistent&&t.options.duration!==0){const n=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},n)}}async hideToast(t){var s,i;if(!t.element)return;t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0);const e=t.options.animation||this.config.animation||{type:"css"};if(await q.hideToast(t.element,t,e),t.element&&t.element.parentNode){const o=t.element.parentElement;t.element.parentNode.removeChild(t.element),t.element=void 0,o&&this.applyStackState(o)}(i=(s=t.options).onHide)==null||i.call(s)}async updateToast(t,e){var o,r,n;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await q.updateToast(t.element,t,e,s);return}if(Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g,""),t.element.classList.add(`editora-toast-${e.level}`),t.element.dataset.level=e.level),e.title!==void 0||e.description!==void 0||e.message!==void 0||e.icon!==void 0||e.render){const a=t.element.querySelector(".editora-toast-content"),l=this.createContent(t);a==null||a.replaceWith(l)}const i=(o=e.closeButton)!=null?o:e.closable;if(i!==void 0){t.options.closable=i,t.options.closeButton=i;const a=t.element.querySelector(".editora-toast-close");i&&!a?t.element.appendChild(this.createCloseButton(t)):!i&&a&&a.remove()}if(e.progress!==void 0){let a=t.element.querySelector(".editora-toast-progress-track");if(e.progress){if(!a){a=document.createElement("div"),a.className="editora-toast-progress-track",a.setAttribute("role","progressbar"),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax","100");const d=t.element.querySelector(".editora-toast-content");d&&d.appendChild(a)}a.setAttribute("aria-valuenow",String(Math.min(100,Math.max(0,e.progress.value))));const l=a.querySelector(".editora-toast-progress-bar");if(l&&(l.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`),e.progress.showPercentage){let d=a.querySelector(".editora-toast-progress-text");d||(d=document.createElement("span"),d.className="editora-toast-progress-text",a.insertBefore(d,a.firstChild)),d.textContent=`${Math.round(e.progress.value)}%`}else{const d=a.querySelector(".editora-toast-progress-text");d&&d.remove()}}else a&&a.remove()}if(e.actions!==void 0||e.action!==void 0||e.cancel!==void 0){let a=t.element.querySelector(".editora-toast-actions");const l=t.options.actions||[];l.length>0?(a?a.innerHTML="":(a=document.createElement("div"),a.className="editora-toast-actions",t.element.appendChild(a)),a&&l.forEach(d=>a.appendChild(this.createActionButton(d,t)))):a&&a.remove()}if((e.duration!==void 0||e.persistent!==void 0||e.level!==void 0)&&(t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0),!t.options.persistent&&t.options.duration!==0)){const a=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},a)}(n=(r=t.options).onUpdate)==null||n.call(r,e)}createContent(t){const e=t.options,s=document.createElement("div");if(s.className="editora-toast-content",e.icon){const o=document.createElement("span");o.className="editora-toast-icon",o.setAttribute("aria-hidden","true"),o.textContent=e.icon,s.appendChild(o)}const i=document.createElement("div");if(i.className="editora-toast-body",e.render)i.appendChild(e.render(t));else{if(e.title){const o=document.createElement("div");o.className="editora-toast-title",o.textContent=e.title,i.appendChild(o)}if(e.message){const o=document.createElement("div");o.className="editora-toast-message",e.html?V(o,e.message):o.textContent=e.message,i.appendChild(o)}if(e.description){const o=document.createElement("div");o.className="editora-toast-description",o.textContent=e.description,i.appendChild(o)}}return s.appendChild(i),s}createCloseButton(t){const e=document.createElement("button");return e.className="editora-toast-close",e.setAttribute("type","button"),e.setAttribute("aria-label","Close notification"),e.textContent="×",e.onclick=()=>t.dismiss(),e}createActionButton(t,e){const s=document.createElement("button");return s.className=`editora-toast-action ${t.primary?"primary":""}`,s.textContent=t.label,t.altText&&s.setAttribute("aria-label",t.altText),s.onclick=i=>{i.stopPropagation(),t.onClick(),t.dismissOnClick!==!1&&e.dismiss()},s}applyContainerStyles(t,e){const s=this.toCssLength(this.config.offset),i=this.toCssLength(this.config.mobileOffset),o=this.toCssLength(this.config.gap);t.dataset.position=e,t.dataset.expand=String(this.config.expand),t.dataset.stack=String(this.config.stack),t.style.setProperty("--editora-toast-offset",s),t.style.setProperty("--editora-toast-mobile-offset",i),t.style.setProperty("--editora-toast-gap",o);const r={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"flex",flexDirection:e.startsWith("top")?"column":"column-reverse",gap:o,pointerEvents:"none",maxWidth:"100%",boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:"",alignItems:e.includes("center")?"center":"stretch"};switch(e){case"top-left":r.top=`max(${s}, env(safe-area-inset-top))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":r.top=`max(${s}, env(safe-area-inset-top))`,r.left="50%",r.transform="translateX(-50%)";break;case"top-right":r.top=`max(${s}, env(safe-area-inset-top))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left="50%",r.transform="translateX(-50%)";break;case"bottom-right":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":r.top="50%",r.left="50%",r.transform="translate(-50%, -50%)",r.alignItems="center";break}Object.assign(t.style,r),t.style.setProperty("--editora-toast-mobile-left",i)}applyStackState(t){const e=Array.from(t.querySelectorAll(".editora-toast"));e.forEach((s,i)=>{const o=e.length-i-1;s.dataset.index=String(i),s.dataset.front=String(o===0),s.style.setProperty("--editora-toast-index",String(i)),s.style.setProperty("--editora-toast-before",String(o))})}toCssLength(t){return typeof t=="number"?`${t}px`:t||"16px"}pauseToast(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}resumeToast(t){if(!t.options.persistent&&t.options.duration!==0){const e=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},e)}}addSwipeDismiss(t,e){let s=0,i=0,o=!1;const r=e.options.swipeDirection||this.config.swipeDirection||"any",n=40;let a="",l=!1;const d='button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]',f=()=>{t.style.transform=a,t.style.transition="",t.style.cursor="",t.style.userSelect=""},h=(p,y)=>{if("changedTouches"in p||"touches"in p){const m=y?p.changedTouches:p.touches,g=m&&m[0];return g?{x:g.clientX,y:g.clientY}:null}return{x:p.clientX,y:p.clientY}},T=p=>{const y=p.target;if(y instanceof Element&&t.contains(y)&&y.closest(d)||"button"in p&&p.button!==0)return;const m=h(p,!1);m&&(o=!0,l=!1,s=m.x,i=m.y,a=t.style.transform||"")},w=p=>{var b,B;if(!o)return;const y=h(p,!1);if(!y)return;const m=y.x-s,g=y.y-i,x=5;if(!l&&(Math.abs(m)>x||Math.abs(g)>x)&&(l=!0,t.style.transition="none",t.style.cursor="grabbing",t.style.userSelect="none",(B=(b=window.getSelection)==null?void 0:b.call(window))==null||B.removeAllRanges()),l){const S=Math.abs(g)>Math.abs(m)?25:20,U=Math.min(Math.max(m*.2,-S),S),_=Math.min(Math.max(g*.2,-S),S);t.style.transform=`${a} translate(${U}px, ${_}px)`,p.cancelable&&p.preventDefault()}},P=p=>{if(!o)return;o=!1;const y=l;if(f(),!y)return;const m=h(p,!0);if(!m)return;const g=m.x-s,x=m.y-i;let b=!1;const S=r==="vertical"||r==="up"||r==="down"?35:n;switch(r){case"any":b=Math.abs(g)>n||Math.abs(x)>n;break;case"horizontal":b=Math.abs(g)>n;break;case"vertical":b=Math.abs(x)>S;break;case"left":b=g<-n;break;case"right":b=g>n;break;case"up":b=x<-S;break;case"down":b=x>S;break}b&&e.dismiss()},$=()=>{o&&(o=!1,l=!1,f())};t.addEventListener("dragstart",p=>p.preventDefault()),t.addEventListener("touchstart",T,{passive:!0}),t.addEventListener("touchmove",w,{passive:!1}),t.addEventListener("touchend",P),t.addEventListener("touchcancel",$),t.addEventListener("mousedown",T),t.addEventListener("mousemove",w),t.addEventListener("mouseup",P),t.addEventListener("mouseleave",P)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){if(t.options.ariaLive==="off")return;const e=document.createElement("div");e.setAttribute("aria-live",t.options.ariaLive||(t.options.level==="error"?"assertive":"polite")),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden";const s=[t.options.title,t.options.message,t.options.description].filter(Boolean).join(". ");e.textContent=`${t.options.level||"info"}: ${s}`,document.body.appendChild(e),setTimeout(()=>{e.remove()},1e3)}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,o,r;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((r=(o=e.ownerNode)==null?void 0:o.textContent)==null?void 0:r.includes("editora-toast"))})){const e=document.createElement("style");e.setAttribute("data-editora-toast-fallback","true"),e.textContent=".editora-toast{box-sizing:border-box;pointer-events:auto}.editora-toast-container{box-sizing:border-box;pointer-events:none}.editora-toast.show{opacity:1;transform:translateY(0) scale(1)}.editora-toast.hiding{opacity:0}",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class G{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(i=>i.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const i=this.hooks[t];if(!(!i||i.length===0))for(const o of i)try{await o(e,...s)}catch(r){console.error(`Error in ${t} hook:`,r)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const i=`editor:${t}`;this.trigger(i,e,...s)}async handlePromise(t,e,s,i){e();try{const o=await t;return s(o),o}catch(o){throw i(o),o}}async batchShow(t){const e=t.map(i=>this.beforeShow(i));await Promise.all(e);const s=t.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(t){const e=t.map(i=>this.beforeHide(i));await Promise.all(e);const s=t.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const D={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!0,stack:!1,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!1,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class H{constructor(t={}){this.idCounter=0,this.pausedToasts=new Set,this.pendingShows=new Map,this.subscribers=new Set,this.config=this.normalizeConfig({...D,...t}),this.store=new A(this.config),this.queue=new z(this.config),this.renderer=new W(this.config),this.lifecycle=new G,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:this.normalizeToastOptions({...this.config,...t},t),createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:r=>this.update(e,r)},i=this.lifecycle.beforeShow(s).then(async()=>{const r=this.queue.enqueue(s);r.rejected||(this.store.addToast(s),await this.hideToasts(r.hide,!0),await this.showToasts(r.show),this.notify())});this.pendingShows.set(e,i);const o=()=>{this.pendingShows.get(e)===i&&this.pendingShows.delete(e)};return i.then(o,o),s}update(t,e){const s=this.pendingShows.get(t);if(s)return s.then(()=>this.update(t,e),()=>{}),!0;const i=this.store.getToast(t);return i?(this.lifecycle.beforeUpdate(i,e).then(async()=>{const o=this.normalizeToastOptions({...i.options,...e},e);this.store.updateToast(t,{options:o}),this.queue.isVisible(t)&&await this.renderer.updateToast(i,e),this.lifecycle.afterUpdate(i,e),this.notify()}),!0):!1}dismiss(t){const e=this.pendingShows.get(t);if(e)return e.then(()=>this.dismiss(t),()=>{}),!0;const s=this.store.getToast(t);return s?(this.lifecycle.beforeHide(s).then(async()=>{const i=this.queue.isVisible(t),o=this.queue.dequeue(t);i&&await this.renderer.hideToast(s),this.store.removeToast(t),this.lifecycle.afterHide(s),await this.showToasts(o.show),this.notify()}),!0):!1}clear(){const t=this.queue.clear();Promise.all(t.map(e=>this.hideOne(e,!1))).then(()=>{this.store.clear(),this.notify()})}async promise(t,e){var i,o;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const r=await t,n=this.normalizeOptions(typeof e.success=="function"?e.success(r):e.success,"success");return n.duration===void 0&&!n.persistent&&(n.duration=this.config.duration),this.update(s.id,n),(i=e.onSuccess)==null||i.call(e,r),r}catch(r){const n=this.normalizeOptions(typeof e.error=="function"?e.error(r):e.error,"error");throw n.duration===void 0&&!n.persistent&&(n.duration=this.config.duration),this.update(s.id,n),(o=e.onError)==null||o.call(e,r),r}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur,s={...this.config,...t};t.maxVisible!==void 0&&t.visibleToasts===void 0&&delete s.visibleToasts,this.config=this.normalizeConfig(s),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const i=this.queue.updateConfig(this.config);this.hideToasts(i.hide,!0).then(()=>this.showToasts(i.show)).then(()=>this.notify()),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getState(){return{toasts:this.store.getAllToasts(),visible:this.queue.getVisible(),queued:this.queue.getQueued(),groups:this.store.getAllGroups(),config:this.getConfig()}}subscribe(t){return this.subscribers.add(t),t(this.getState()),()=>{this.subscribers.delete(t)}}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"?{message:t,level:e}:{...t,level:t.level||e}}normalizeConfig(t){const e=t.visibleToasts||t.maxVisible||D.maxVisible;return{...t,maxVisible:e,visibleToasts:e}}normalizeToastOptions(t,e=t){var r,n,a,l,d,f;const s=(l=(a=(n=(r=e.closeButton)!=null?r:e.closable)!=null?n:t.closable)!=null?a:t.closeButton)!=null?l:this.config.closeButton,i=t.action?{...t.action,primary:(d=t.action.primary)!=null?d:!0}:void 0,o=[...i?[i]:[],...t.cancel?[t.cancel]:[],...t.actions||[]];return{...t,closable:s,closeButton:s,actions:o.length>0?o:void 0,ariaLive:t.ariaLive||(t.level==="error"||t.important?"assertive":"polite"),role:t.role||(t.level==="error"||t.important?"alert":"status"),preventDuplicate:(f=t.preventDuplicate)!=null?f:this.config.preventDuplicate,dedupeScope:t.dedupeScope||this.config.dedupeScope}}async showToasts(t){for(const e of t)await this.renderer.showToast(e),await this.lifecycle.afterShow(e)}async hideToasts(t,e){for(const s of t)await this.hideOne(s,e)}async hideOne(t,e){await this.lifecycle.beforeHide(t),await this.renderer.hideToast(t),e&&this.store.removeToast(t.id),await this.lifecycle.afterHide(t)}notify(){if(this.subscribers.size===0)return;const t=this.getState();this.subscribers.forEach(e=>e(t))}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||typeof document=="undefined"||!this.config.pauseOnWindowBlur||(this.teardownWindowFocusHandling(),this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),this.visibilityChangeHandler=()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()},window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",this.visibilityChangeHandler))}teardownWindowFocusHandling(){typeof window!="undefined"&&(this.windowBlurHandler&&(window.removeEventListener("blur",this.windowBlurHandler),this.windowBlurHandler=void 0),this.windowFocusHandler&&(window.removeEventListener("focus",this.windowFocusHandler),this.windowFocusHandler=void 0),typeof document!="undefined"&&this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0))}pauseAllToasts(){this.store.getAllToasts().forEach(e=>{e.timeoutId&&!this.pausedToasts.has(e.id)&&(clearTimeout(e.timeoutId),e.timeoutId=void 0,this.pausedToasts.add(e.id))})}resumeAllToasts(){this.store.getAllToasts().forEach(e=>{if(this.pausedToasts.has(e.id)&&!e.options.persistent&&e.options.duration!==0){const s=e.options.duration||this.config.duration;e.timeoutId=window.setTimeout(()=>{this.dismiss(e.id)},s),this.pausedToasts.delete(e.id)}})}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let E=null;function u(){return E||(E=new H),E}function k(c){return typeof document=="undefined"?{dismiss:()=>{}}:u().show(c)}function L(c,t,e,s){let i={};t&&typeof t=="object"?i={...t}:typeof t=="number"&&(i.duration=t),e&&(i.theme=e),s&&(i.position=s);const o={message:c,...i,level:i.level||void 0};return i.duration!==void 0&&(o.duration=i.duration),i.position&&(o.position=i.position),i.theme&&(o.theme=i.theme),o}const M={info:(c,t,e,s)=>k({...L(c,t,e,s),level:"info"}),success:(c,t,e,s)=>k({...L(c,t,e,s),level:"success"}),error:(c,t,e,s)=>k({...L(c,t,e,s),level:"error"}),warning:(c,t,e,s)=>k({...L(c,t,e,s),level:"warning"}),loading:(c,t,e,s)=>k({...L(c,t,e,s),level:"loading"})},C={show:c=>u().show(c),update:(c,t)=>u().update(c,t),dismiss:c=>u().dismiss(c),clear:()=>u().clear(),info:(c,t)=>u().show({message:c,level:"info",...t}),success:(c,t)=>u().show({message:c,level:"success",...t}),error:(c,t)=>u().show({message:c,level:"error",...t}),warning:(c,t)=>u().show({message:c,level:"warning",...t}),loading:(c,t)=>u().show({message:c,level:"loading",...t}),promise:(c,t)=>u().promise(c,t),group:(c,t)=>u().group(c,t),configure:c=>u().configure(c),use:c=>u().use(c),getToasts:()=>u().getToasts(),getGroups:()=>u().getGroups(),getConfig:()=>u().getConfig(),getState:()=>u().getState(),subscribe:c=>u().subscribe(c),onEditorEvent:(c,t)=>u().onEditorEvent(c,t),triggerEditorEvent:(c,t,...e)=>u().triggerEditorEvent(c,t,...e),destroy:()=>{E&&(E.destroy(),E=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const c=window;c.toast=M,c.toastAdvanced=C,c.toastPro=C,c.ToastManager=H,c.__editoraToastReady||(c.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:M,toastAdvanced:C,toastPro:C,ToastManager:H}})))}v.ToastManager=H,v.default=M,v.toast=M,v.toastAdvanced=C,v.toastPro=C,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(T,$){typeof exports=="object"&&typeof module!="undefined"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(T=typeof globalThis!="undefined"?globalThis:T||self,$(T.EditoraToast={}))})(this,(function(T){"use strict";class ${constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(i=>i.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class X{constructor(t){this.queue=[],this.visible=[],this.config=this.normalizeConfig(t)}enqueue(t){var o;const e=this.findDuplicate(t);if(e&&((o=t.options.preventDuplicate)!=null?o:this.config.preventDuplicate))return{show:[],hide:[],rejected:e};const s=[];if(t.options.important&&this.visible.length>=this.maxVisible){const r=this.removeLowestPriorityVisible();return this.visible.push(t),{show:[t],hide:r?[...s,r]:s}}this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.sortQueue();const i=this.processQueue();return{show:i.show,hide:[...s,...i.hide]}}dequeue(t){return this.removeFromCollections(t)?{show:this.processQueue().show,hide:[]}:{show:[],hide:[]}}updateConfig(t){return this.config=this.normalizeConfig({...this.config,...t}),this.sortQueue(),this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}isVisible(t){return this.visible.some(e=>e.id===t)}clear(){const t=[...this.visible,...this.queue];return this.queue=[],this.visible=[],t}processQueue(){const t=[],e=[];for(;this.visible.length>this.maxVisible;){const s=this.visible.pop();s&&e.push(s)}for(;this.visible.length<this.maxVisible&&this.queue.length>0;){const s=this.queue.shift();if(!s)break;this.visible.push(s),t.push(s)}return{show:t,hide:e}}removeLowestPriorityVisible(){if(this.visible.length===0)return;let t=0;for(let e=1;e<this.visible.length;e+=1)(this.visible[e].options.priority||0)<(this.visible[t].options.priority||0)&&(t=e);return this.visible.splice(t,1)[0]}removeFromCollections(t){const e=this.visible.findIndex(i=>i.id===t);if(e!==-1)return this.visible.splice(e,1)[0];const s=this.queue.findIndex(i=>i.id===t);if(s!==-1)return this.queue.splice(s,1)[0]}findDuplicate(t){const e=t.options.dedupeScope||this.config.dedupeScope,s=e==="visible"?this.visible:e==="queue"?this.queue:[...this.visible,...this.queue],i=this.getDedupeKey(t);return s.find(o=>this.getDedupeKey(o)===i)}getDedupeKey(t){return t.options.dedupeKey||`${t.options.level||"info"}:${t.options.title||""}:${t.options.message||""}:${t.options.description||""}`}sortQueue(){this.queue.sort((t,e)=>{const s=(e.options.priority||0)-(t.options.priority||0);return s!==0?s:t.createdAt-e.createdAt})}get maxVisible(){return Math.max(1,this.config.visibleToasts||this.config.maxVisible||1)}normalizeConfig(t){return{...t,maxVisible:t.visibleToasts||t.maxVisible}}}const W=new Set(["a","b","strong","i","em","u","s","del","ins","mark","small","sub","sup","code","kbd","br","span","p","ul","ol","li"]),_=new Set(["script","style","iframe","frame","frameset","object","embed","applet","noscript","template","svg","math","form","input","button","textarea","select","option","head","title","link","meta","base","audio","video","canvas"]),G=/^(?:https?:|mailto:|tel:)/i;function K(n){const t=n.replace(/[\u0000- \u007f-\u009f]/g,"");return t?G.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t):!1}function q(n,t,e){for(const s of Array.from(n.childNodes)){if(s.nodeType===Node.TEXT_NODE){t.appendChild(e.createTextNode(s.textContent||""));continue}if(s.nodeType!==Node.ELEMENT_NODE)continue;const i=s,o=i.localName.toLowerCase();if(_.has(o))continue;if(!W.has(o)){q(i,t,e);continue}const r=e.createElement(o);if(o==="a"){const a=i.getAttribute("href");a&&K(a)&&(r.setAttribute("href",a.trim()),/^(?:https?:)?\/\//i.test(a.trim())&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")));const c=i.getAttribute("title");c&&r.setAttribute("title",c)}q(i,r,e),t.appendChild(r)}}function R(n,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();q(e.content,s,document),n.textContent="",n.appendChild(s)}class U{constructor(t={}){var e,s,i,o;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(o=t.precision)!=null?o:.01}}animate(t,e,s,i,o){const r={...this.config,...o};let a,c=!1;const l=Object.keys(e).reduce((p,v)=>(p[v]=e[v].from,p),{}),h=Object.keys(e).reduce((p,v)=>(p[v]=0,p),{}),y=()=>{if(c)return;let p=!0;Object.keys(e).forEach(d=>{const m=e[d].to,x=l[d],f=h[d],w=-r.stiffness*(x-m),g=-r.damping*f,E=(w+g)/r.mass;h[d]+=E*.016,l[d]+=h[d]*.016,(Math.abs(x-m)>r.precision||Math.abs(f)>r.precision)&&(p=!1)});const v=Object.keys(l).reduce((d,m)=>{const x=e[m].unit||"px";return d[m]=`${l[m]}${x}`,d},{});s(v),p?(c=!0,i==null||i()):a=requestAnimationFrame(y)};return a=requestAnimationFrame(y),()=>{c=!0,a&&cancelAnimationFrame(a)}}}class Q{constructor(){this.springAnimation=new U}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):await this.animateCssShow(t);break;default:await this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):await this.animateCssHide(t);break;default:await this.animateCssHide(t);break}}async updateToast(t,e,s,i){i.type==="custom"&&i.update&&await Promise.resolve(i.update(t,e,s))}animateCssShow(t){return new Promise(e=>{requestAnimationFrame(()=>{t.classList.add("show"),window.setTimeout(e,220)})})}animateCssHide(t){return new Promise(e=>{t.classList.remove("show"),t.classList.add("hiding"),window.setTimeout(e,220)})}async animateSpringShow(t,e){return new Promise(s=>{var r,a,c;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const o=((r=t.parentElement)==null?void 0:r.classList.contains("editora-toast-bottom-right"))||((a=t.parentElement)==null?void 0:a.classList.contains("editora-toast-bottom-left"))||((c=t.parentElement)==null?void 0:c.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${o}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",a=e.duration||800,c=r==="gentle"?.05:r==="strong"?.15:.1,l=o==="up"?30:o==="down"?-30:o==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1-c})`:`translateY(${l}px) scale(${1-c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.05:i==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.distance||100,a=e.easing||"ease-out",c=e.duration||400,l=o==="up"?`translateY(${r}px)`:o==="down"?`translateY(-${r}px)`:o==="left"?`translateX(${r}px)`:`translateX(-${r}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${c}ms ${a}, transform ${c}ms ${a}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},c)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"down",o=e.distance||100,r=e.easing||"ease-in",a=e.duration||300,c=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",c,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-out",a=e.duration||500;t.style.setProperty("transform-origin",o,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-in",a=e.duration||300;t.style.setProperty("transform-origin",o,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"forward",a=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const c=r==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${c}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},a)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"backward",a=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const c=r==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${c}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},a)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||300;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(${o}px)`:i==="down"?`translateY(-${o}px)`:i==="left"?`translateX(${o}px)`:`translateX(-${o}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||200;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",a=e.duration||1e3,c=r==="gentle"?.1:r==="strong"?.3:.2,l=o==="up"?40:o==="down"?-40:o==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1+c})`:`translateY(${l}px) scale(${1+c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.1:i==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||360,o=e.direction||"clockwise",r=e.origin||"center",a=e.duration||500,c=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||180,o=e.direction||"counterclockwise",r=e.origin||"center",a=e.duration||300,c=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}}const z=new Q,N="http://www.w3.org/2000/svg",Z={success:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M6.6 10.3l2.3 2.3 4.5-4.9"}]],error:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M7.6 7.6l4.8 4.8M12.4 7.6l-4.8 4.8"}]],warning:[["path",{d:"M10 2.9L18 16.4H2L10 2.9z"}],["path",{d:"M10 8.3v3.4M10 13.9v.1"}]],info:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M10 9.2v4.4M10 6.5v.1"}]],loading:[["path",{d:"M10 2a8 8 0 1 0 8 8"}]]},J={success:"success",error:"error",warning:"warning",info:"info",loading:"loading",promise:"loading"};function I(n,t){const e=document.createElementNS(N,"svg");return e.setAttribute("viewBox","0 0 20 20"),e.setAttribute("width",String(t)),e.setAttribute("height",String(t)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.7"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("focusable","false"),e.setAttribute("aria-hidden","true"),n.forEach(([s,i])=>{const o=document.createElementNS(N,s);Object.keys(i).forEach(r=>o.setAttribute(r,i[r])),e.appendChild(o)}),e}function tt(n){const t=Z[J[n]||""];return t?I(t,18):null}function et(){const n=I([["path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"}]],14);return n.setAttribute("stroke-width","1.8"),n}const Y=12,st=.05,F=3,H=new WeakMap;function it(n){const t=n.style.height;n.style.height="auto";const e=n.offsetHeight;return n.style.height=t,H.set(n,e),e}function ot(n){H.delete(n)}function rt(n,t){return!t.stack||t.expand||n.dataset.open==="true"}function nt(n,t,e=!1){const i=n.dataset.edge==="bottom"?-1:1,o=Array.from(n.querySelectorAll(".editora-toast")),r=o.filter(d=>!d.classList.contains("hiding")&&d.dataset.leaving!=="true"),a=r.slice().reverse(),c=rt(n,t);a.forEach(d=>{(e||!H.has(d))&&it(d)});const l=a.map(d=>H.get(d)||0),h=l[0]||0;let y=0;a.forEach((d,m)=>{const x=l[m],f=c?1:Math.max(1-m*st,.8),w=c?x:h,g=c?y:m*Y+h*(1-f);d.style.setProperty("--et-y",`${i*g}px`),d.style.setProperty("--et-s",String(f)),d.style.setProperty("--et-index",String(m)),d.style.height=`${w}px`,d.style.zIndex=String(a.length-m),d.dataset.index=String(m),d.dataset.front=String(m===0),d.dataset.collapsed=String(!c&&m>0),d.dataset.hidden=String(!c&&m>=F),y+=x+t.gap}),o.forEach(d=>{r.includes(d)||(d.dataset.front="false")});const p=a.length,v=c?l.reduce((d,m)=>d+m,0)+Math.max(p-1,0)*t.gap:h+(Math.min(p,F)-1>0?(Math.min(p,F)-1)*Y:0);n.style.height=p>0?`${v}px`:"0px",n.dataset.count=String(p),n.dataset.expanded=String(c)}class at{constructor(t){this.containers=new Map,this.cssInjected=!1,this.toastOf=new WeakMap,this.holds=new Map,this.timing=new Map,this.returnFocusTo=null,this.globalListeners=[],this.config=t}updateConfig(t){this.config=t,this.containers.forEach((e,s)=>{this.applyContainerStyles(e,s),this.layout(e,!0)})}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");return e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite"),e.dataset.expand=String(this.config.expand),e.dataset.stack=String(this.config.stack),this.applyContainerStyles(e,t),this.attachContainerListeners(e),document.body.appendChild(e),this.containers.set(t,e),this.attachGlobalListeners(),this.injectCSS(),e}attachContainerListeners(t){t.addEventListener("mouseenter",()=>{t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("pointerdown",e=>{e.pointerType!=="touch"||t.dataset.hover==="true"||(t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t))}),t.addEventListener("mouseleave",()=>{delete t.dataset.hover,this.releaseAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("focusin",e=>{this.isKeyboardFocus(e.target)&&(t.dataset.focus="true",this.holdAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("focusout",e=>{const s=e.relatedTarget;s&&t.contains(s)||(delete t.dataset.focus,this.releaseAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("keydown",e=>this.onContainerKey(t,e))}syncOpen(t){const e=t.dataset.hover==="true"||t.dataset.focus==="true";t.dataset.open=String(e),this.layout(t)}isKeyboardFocus(t){if(!(t instanceof Element))return!1;try{return t.matches(":focus-visible")}catch(e){return!0}}onContainerKey(t,e){if(e.key!=="Escape")return;const s=e.target instanceof Element?e.target.closest(".editora-toast"):null,i=s?this.toastOf.get(s):void 0;if(!s||!i)return;e.preventDefault();const o=Array.from(t.querySelectorAll(".editora-toast:not(.hiding)")),r=o[o.indexOf(s)+1]||o[o.indexOf(s)-1];i.dismiss(),r&&r!==s?r.focus():this.restoreFocus()}restoreFocus(){const t=this.returnFocusTo;this.returnFocusTo=null,t&&t.isConnected&&t.focus()}attachGlobalListeners(){if(this.globalListeners.length>0||typeof window=="undefined")return;const t=(e,s,i)=>{e.addEventListener(s,i),this.globalListeners.push([e,s,i])};t(document,"keydown",(e=>{if(!this.matchesHotkey(e))return;const s=Array.from(this.containers.values()).find(r=>r.querySelector(".editora-toast:not(.hiding)"));if(!s)return;const i=s.querySelector('.editora-toast[data-front="true"]');if(!i)return;e.preventDefault();const o=document.activeElement;o instanceof HTMLElement&&!s.contains(o)&&(this.returnFocusTo=o),i.focus()})),t(document,"pointerdown",(e=>{this.containers.forEach(s=>{s.dataset.hover==="true"&&!s.contains(e.target)&&(delete s.dataset.hover,this.releaseAll(s,"pointer"),this.syncOpen(s))})})),t(window,"resize",(()=>{window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.containers.forEach(e=>this.layout(e,!0)),120)}))}matchesHotkey(t){const e=this.config.hotkey;if(!e)return!1;const s=e.toLowerCase().split("+").map(r=>r.trim()).filter(Boolean),i=s.pop();if(!i)return!1;const o=r=>s.includes(r);return t.altKey!==o("alt")||t.shiftKey!==o("shift")||t.ctrlKey!==o("ctrl")||t.metaKey!==(o("meta")||o("cmd"))?!1:t.code.toLowerCase()===`key${i}`||t.code.toLowerCase()===i||t.key.toLowerCase()===i}layout(t,e=!1){nt(t,{stack:this.config.stack,expand:this.config.expand,gap:this.toPx(this.config.gap)},e)}toPx(t){if(typeof t=="number")return t;const e=parseFloat(t||"");return Number.isFinite(e)?e:8}holdAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);if(!i)return;(e==="focus"?i.options.pauseOnFocus:i.options.pauseOnHover)!==!1&&this.pauseToast(i,e)})}releaseAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);i&&this.resumeToast(i,e)})}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,s.dataset.level=e.level||"info",e.customClass&&e.customClass.split(/\s+/).filter(Boolean).forEach(a=>s.classList.add(a)),s.setAttribute("role",e.role||(e.level==="error"?"alert":"status")),s.setAttribute("aria-atomic","true"),s.tabIndex=0,(e.closable||e.closeButton)&&(s.dataset.closable="true"),this.toastOf.set(s,t),e.ariaLive&&e.ariaLive!=="off"&&s.setAttribute("aria-live",e.ariaLive);const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(this.config.richColors||i==="colored")&&s.setAttribute("data-rich-colors","true"),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const r=this.createContent(t);if(s.appendChild(r),e.actions&&e.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",e.actions.forEach(c=>a.appendChild(this.createActionButton(c,t))),s.appendChild(a)}return(e.closable||e.closeButton)&&s.appendChild(this.createCloseButton(t)),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var o,r;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s),e.dataset.hover==="true"&&t.options.pauseOnHover!==!1&&this.pauseToast(t,"pointer"),e.dataset.focus==="true"&&t.options.pauseOnFocus!==!1&&this.pauseToast(t,"focus"),this.layout(e);const i=t.options.animation||this.config.animation||{type:"css"};await z.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(r=(o=t.options).onShow)==null||r.call(o),this.startTimer(t)}async hideToast(t){var i,o;if(!t.element)return;this.stopTimer(t),this.holds.delete(t.id);const e=t.element;e.dataset.leaving="true",e.parentElement&&this.layout(e.parentElement);const s=t.options.animation||this.config.animation||{type:"css"};if(await z.hideToast(e,t,s),t.element&&t.element.parentNode){const r=t.element.parentElement;t.element.parentNode.removeChild(t.element),t.element=void 0,r&&(r.querySelector(".editora-toast")||(delete r.dataset.hover,delete r.dataset.focus,r.dataset.open="false"),this.layout(r))}(o=(i=t.options).onHide)==null||o.call(i)}async updateToast(t,e){var o,r,a;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await z.updateToast(t.element,t,e,s);return}if(Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g,""),t.element.classList.add(`editora-toast-${e.level}`),t.element.dataset.level=e.level),e.title!==void 0||e.description!==void 0||e.message!==void 0||e.icon!==void 0||e.level!==void 0||e.render){const c=t.element.querySelector(".editora-toast-content"),l=this.createContent(t);c==null||c.replaceWith(l)}const i=(o=e.closeButton)!=null?o:e.closable;if(i!==void 0){t.options.closable=i,t.options.closeButton=i,i?t.element.dataset.closable="true":delete t.element.dataset.closable;const c=t.element.querySelector(".editora-toast-close");i&&!c?t.element.appendChild(this.createCloseButton(t)):!i&&c&&c.remove()}if(e.progress!==void 0){const c=t.element.querySelector(".editora-toast-body"),l=t.element.querySelector(".editora-toast-progress-track");if(e.progress&&c){const h=this.createProgress(e.progress);l?l.replaceWith(h):c.appendChild(h)}else l&&l.remove()}if(e.actions!==void 0||e.action!==void 0||e.cancel!==void 0){let c=t.element.querySelector(".editora-toast-actions");const l=t.options.actions||[];l.length>0?(c?c.innerHTML="":(c=document.createElement("div"),c.className="editora-toast-actions",t.element.appendChild(c)),c&&l.forEach(h=>c.appendChild(this.createActionButton(h,t)))):c&&c.remove()}(e.duration!==void 0||e.persistent!==void 0||e.level!==void 0)&&this.startTimer(t),t.element.style.height="",ot(t.element),t.element.parentElement&&this.layout(t.element.parentElement),(a=(r=t.options).onUpdate)==null||a.call(r,e)}createContent(t){const e=t.options,s=document.createElement("div");s.className="editora-toast-content";const i=this.createIcon(t);i&&s.appendChild(i);const o=document.createElement("div");if(o.className="editora-toast-body",e.render)o.appendChild(e.render(t));else{if(e.title){const r=document.createElement("div");r.className="editora-toast-title",r.textContent=e.title,o.appendChild(r)}if(e.message){const r=document.createElement("div");r.className="editora-toast-message",e.html?R(r,e.message):r.textContent=e.message,o.appendChild(r)}if(e.description){const r=document.createElement("div");r.className="editora-toast-description",r.textContent=e.description,o.appendChild(r)}}return e.progress&&o.appendChild(this.createProgress(e.progress)),s.appendChild(o),s}createProgress(t){const e=Math.min(100,Math.max(0,t.value)),s=document.createElement("div");s.className="editora-toast-progress-track",s.setAttribute("role","progressbar"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuenow",String(e));const i=document.createElement("div");if(i.className="editora-toast-progress-bar",i.style.width=`${e}%`,t.showPercentage){const o=document.createElement("span");o.className="editora-toast-progress-text",o.textContent=`${Math.round(t.value)}%`,s.appendChild(o)}return s.appendChild(i),s}createCloseButton(t){const e=document.createElement("button");return e.className="editora-toast-close",e.setAttribute("type","button"),e.setAttribute("aria-label","Close notification"),e.appendChild(et()),e.onclick=()=>t.dismiss(),e}createIcon(t){const e=t.options;if(e.icon===!1)return null;const s=document.createElement("span");if(s.className="editora-toast-icon",s.setAttribute("aria-hidden","true"),typeof e.icon=="string"&&e.icon)return s.textContent=e.icon,s;if(e.icon&&typeof e.icon=="object")return s.appendChild(e.icon),s;if(this.config.icons===!1)return null;const i=e.level||"info",o=tt(i);return o?((i==="loading"||i==="promise")&&(s.dataset.spin="true"),s.appendChild(o),s):null}createActionButton(t,e){const s=document.createElement("button");return s.className=`editora-toast-action ${t.primary?"primary":""}`,s.textContent=t.label,t.altText&&s.setAttribute("aria-label",t.altText),s.onclick=i=>{i.stopPropagation(),t.onClick(),t.dismissOnClick!==!1&&e.dismiss()},s}applyContainerStyles(t,e){const s=this.toCssLength(this.config.offset),i=this.toCssLength(this.config.mobileOffset),o=this.toCssLength(this.config.gap);t.dataset.position=e,t.dataset.edge=e.startsWith("bottom")?"bottom":"top",t.dataset.expand=String(this.config.expand),t.dataset.stack=String(this.config.stack),t.style.setProperty("--editora-toast-offset",s),t.style.setProperty("--editora-toast-mobile-offset",i),t.style.setProperty("--editora-toast-gap",o),t.style.setProperty("--et-edge",e.startsWith("bottom")?"1":"-1");const r={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"block",width:"var(--et-width, 360px)",maxWidth:`calc(100vw - 2 * ${s})`,boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:""};switch(e){case"top-left":r.top=`max(${s}, env(safe-area-inset-top))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":r.top=`max(${s}, env(safe-area-inset-top))`,r.left="50%",r.transform="translateX(-50%)";break;case"top-right":r.top=`max(${s}, env(safe-area-inset-top))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left="50%",r.transform="translateX(-50%)";break;case"bottom-right":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":r.top="50%",r.left="50%",r.transform="translate(-50%, -50%)";break}Object.assign(t.style,r),t.style.setProperty("--editora-toast-mobile-left",i)}toCssLength(t){return typeof t=="number"?`${t}px`:t||"16px"}startTimer(t){if(this.stopTimer(t),t.options.persistent||t.options.duration===0){this.timing.delete(t.id);return}this.arm(t,t.options.duration||this.config.duration)}arm(t,e){var s;this.timing.set(t.id,{remaining:e,startedAt:Date.now()}),!((((s=this.holds.get(t.id))==null?void 0:s.size)||0)>0)&&(t.timeoutId=window.setTimeout(()=>{t.timeoutId=void 0,t.dismiss()},e))}stopTimer(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}pauseToast(t,e="hover"){const s=this.holds.get(t.id)||new Set;if(this.holds.set(t.id,s),s.size===0&&t.timeoutId){const i=this.timing.get(t.id);this.stopTimer(t),i&&(i.remaining=Math.max(0,i.remaining-(Date.now()-i.startedAt)))}s.add(e)}resumeToast(t,e="hover"){const s=this.holds.get(t.id);if(!s||!s.delete(e)||s.size>0)return;this.holds.delete(t.id);const i=this.timing.get(t.id);i&&!t.timeoutId&&!t.options.persistent&&t.options.duration!==0&&this.arm(t,i.remaining)}addSwipeDismiss(t,e){let s=0,i=0,o=!1;const r=e.options.swipeDirection||this.config.swipeDirection||"any",a=40;let c="",l=!1;const h='button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]',y=()=>{t.style.transform=c,t.style.transition="",t.style.cursor="",t.style.userSelect=""},p=(f,w)=>{if("changedTouches"in f||"touches"in f){const g=w?f.changedTouches:f.touches,b=g&&g[0];return b?{x:b.clientX,y:b.clientY}:null}return{x:f.clientX,y:f.clientY}},v=f=>{const w=f.target;if(w instanceof Element&&t.contains(w)&&w.closest(h)||"button"in f&&f.button!==0)return;const g=p(f,!1);g&&(o=!0,l=!1,s=g.x,i=g.y,c=t.style.transform||"")},d=f=>{var P,D;if(!o)return;const w=p(f,!1);if(!w)return;const g=w.x-s,b=w.y-i,E=5;if(!l&&(Math.abs(g)>E||Math.abs(b)>E)&&(l=!0,t.style.transition="none",t.style.cursor="grabbing",t.style.userSelect="none",(D=(P=window.getSelection)==null?void 0:P.call(window))==null||D.removeAllRanges()),l){const S=Math.abs(b)>Math.abs(g)?25:20,ut=Math.min(Math.max(g*.2,-S),S),pt=Math.min(Math.max(b*.2,-S),S);t.style.transform=`${c} translate(${ut}px, ${pt}px)`,f.cancelable&&f.preventDefault()}},m=f=>{if(!o)return;o=!1;const w=l;if(y(),!w)return;const g=p(f,!0);if(!g)return;const b=g.x-s,E=g.y-i;let P=!1;const S=r==="vertical"||r==="up"||r==="down"?35:a;switch(r){case"any":P=Math.abs(b)>a||Math.abs(E)>a;break;case"horizontal":P=Math.abs(b)>a;break;case"vertical":P=Math.abs(E)>S;break;case"left":P=b<-a;break;case"right":P=b>a;break;case"up":P=E<-S;break;case"down":P=E>S;break}P&&e.dismiss()},x=()=>{o&&(o=!1,l=!1,y())};t.addEventListener("dragstart",f=>f.preventDefault()),t.addEventListener("touchstart",v,{passive:!0}),t.addEventListener("touchmove",d,{passive:!1}),t.addEventListener("touchend",m),t.addEventListener("touchcancel",x),t.addEventListener("mousedown",v),t.addEventListener("mousemove",d),t.addEventListener("mouseup",m),t.addEventListener("mouseleave",m)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){if(t.options.ariaLive==="off")return;const e=document.createElement("div");e.setAttribute("aria-live",t.options.ariaLive||(t.options.level==="error"?"assertive":"polite")),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden";const s=[t.options.title,t.options.message,t.options.description].filter(Boolean).join(". ");e.textContent=`${t.options.level||"info"}: ${s}`,document.body.appendChild(e),setTimeout(()=>{e.remove()},1e3)}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,o,r;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((r=(o=e.ownerNode)==null?void 0:o.textContent)==null?void 0:r.includes("editora-toast"))})){const e=document.createElement("style");e.setAttribute("data-editora-toast-fallback","true"),e.textContent=".editora-toast-container{position:fixed;width:360px;max-width:100vw;box-sizing:border-box}.editora-toast{position:absolute;left:0;width:100%;box-sizing:border-box;padding:12px 14px;background:#fff;color:#111;border:1px solid #ddd;border-radius:12px;font:13px/1.45 system-ui,sans-serif;overflow:hidden;pointer-events:auto;opacity:0;translate:0 var(--et-y,0px);scale:var(--et-s,1);transition:opacity .2s,translate .3s,scale .3s,height .3s}.editora-toast-container[data-edge=bottom] .editora-toast{bottom:0}.editora-toast-container[data-edge=top] .editora-toast{top:0}.editora-toast.show{opacity:1}.editora-toast.hiding,.editora-toast[data-hidden=true]{opacity:0}",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.globalListeners.forEach(([t,e,s])=>t.removeEventListener(e,s)),this.globalListeners=[],window.clearTimeout(this.resizeTimer),this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class ct{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(i=>i.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const i=this.hooks[t];if(!(!i||i.length===0))for(const o of i)try{await o(e,...s)}catch(r){console.error(`Error in ${t} hook:`,r)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const i=`editor:${t}`;this.trigger(i,e,...s)}async handlePromise(t,e,s,i){e();try{const o=await t;return s(o),o}catch(o){throw i(o),o}}async batchShow(t){const e=t.map(i=>this.beforeShow(i));await Promise.all(e);const s=t.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(t){const e=t.map(i=>this.beforeHide(i));await Promise.all(e);const s=t.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const V={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!1,stack:!0,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!0,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,icons:!0,hotkey:"alt+t",preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class O{constructor(t={}){this.idCounter=0,this.pendingShows=new Map,this.subscribers=new Set,this.config=this.normalizeConfig({...V,...t}),this.store=new $(this.config),this.queue=new X(this.config),this.renderer=new at(this.config),this.lifecycle=new ct,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:this.normalizeToastOptions({...this.config,...t},t),createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:r=>this.update(e,r)},i=this.lifecycle.beforeShow(s).then(async()=>{const r=this.queue.enqueue(s);r.rejected||(this.store.addToast(s),await this.hideToasts(r.hide,!0),await this.showToasts(r.show),this.notify())});this.pendingShows.set(e,i);const o=()=>{this.pendingShows.get(e)===i&&this.pendingShows.delete(e)};return i.then(o,o),s}update(t,e){const s=this.pendingShows.get(t);if(s)return s.then(()=>this.update(t,e),()=>{}),!0;const i=this.store.getToast(t);return i?(this.lifecycle.beforeUpdate(i,e).then(async()=>{const o=this.normalizeToastOptions({...i.options,...e},e);this.store.updateToast(t,{options:o}),this.queue.isVisible(t)&&await this.renderer.updateToast(i,e),this.lifecycle.afterUpdate(i,e),this.notify()}),!0):!1}dismiss(t){const e=this.pendingShows.get(t);if(e)return e.then(()=>this.dismiss(t),()=>{}),!0;const s=this.store.getToast(t);return s?(this.lifecycle.beforeHide(s).then(async()=>{const i=this.queue.isVisible(t),o=this.queue.dequeue(t);i&&await this.renderer.hideToast(s),this.store.removeToast(t),this.lifecycle.afterHide(s),await this.showToasts(o.show),this.notify()}),!0):!1}clear(){const t=this.queue.clear();Promise.all(t.map(e=>this.hideOne(e,!1))).then(()=>{this.store.clear(),this.notify()})}async promise(t,e){var i,o;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const r=await t,a=this.normalizeResult(typeof e.success=="function"?e.success(r):e.success,"success");return a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(i=e.onSuccess)==null||i.call(e,r),r}catch(r){const a=this.normalizeResult(typeof e.error=="function"?e.error(r):e.error,"error");throw a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(o=e.onError)==null||o.call(e,r),r}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur,s={...this.config,...t};t.maxVisible!==void 0&&t.visibleToasts===void 0&&delete s.visibleToasts,this.config=this.normalizeConfig(s),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const i=this.queue.updateConfig(this.config);this.hideToasts(i.hide,!0).then(()=>this.showToasts(i.show)).then(()=>this.notify()),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getState(){return{toasts:this.store.getAllToasts(),visible:this.queue.getVisible(),queued:this.queue.getQueued(),groups:this.store.getAllGroups(),config:this.getConfig()}}subscribe(t){return this.subscribers.add(t),t(this.getState()),()=>{this.subscribers.delete(t)}}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"?{message:t,level:e}:{...t,level:t.level||e}}normalizeResult(t,e){const s=this.normalizeOptions(t,e);return"message"in s?s:{...s,message:void 0}}normalizeConfig(t){const e=t.visibleToasts||t.maxVisible||V.maxVisible;return{...t,maxVisible:e,visibleToasts:e}}normalizeToastOptions(t,e=t){var r,a,c,l,h,y;const s=(l=(c=(a=(r=e.closeButton)!=null?r:e.closable)!=null?a:t.closable)!=null?c:t.closeButton)!=null?l:this.config.closeButton,i=t.action?{...t.action,primary:(h=t.action.primary)!=null?h:!0}:void 0,o=[...i?[i]:[],...t.cancel?[t.cancel]:[],...t.actions||[]];return{...t,closable:s,closeButton:s,actions:o.length>0?o:void 0,ariaLive:t.ariaLive||(t.level==="error"||t.important?"assertive":"polite"),role:t.role||(t.level==="error"||t.important?"alert":"status"),preventDuplicate:(y=t.preventDuplicate)!=null?y:this.config.preventDuplicate,dedupeScope:t.dedupeScope||this.config.dedupeScope}}async showToasts(t){for(const e of t)await this.renderer.showToast(e),await this.lifecycle.afterShow(e)}async hideToasts(t,e){for(const s of t)await this.hideOne(s,e)}async hideOne(t,e){await this.lifecycle.beforeHide(t),await this.renderer.hideToast(t),e&&this.store.removeToast(t.id),await this.lifecycle.afterHide(t)}notify(){if(this.subscribers.size===0)return;const t=this.getState();this.subscribers.forEach(e=>e(t))}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||typeof document=="undefined"||!this.config.pauseOnWindowBlur||(this.teardownWindowFocusHandling(),this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),this.visibilityChangeHandler=()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()},window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",this.visibilityChangeHandler))}teardownWindowFocusHandling(){typeof window!="undefined"&&(this.windowBlurHandler&&(window.removeEventListener("blur",this.windowBlurHandler),this.windowBlurHandler=void 0),this.windowFocusHandler&&(window.removeEventListener("focus",this.windowFocusHandler),this.windowFocusHandler=void 0),typeof document!="undefined"&&this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0))}pauseAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.pauseToast(t,"window"))}resumeAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.resumeToast(t,"window"))}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let C=null;function u(){return C||(C=new O),C}const lt=n=>({id:n.id||"",options:n,createdAt:0,dismiss:()=>{},update:()=>{}});function B(n){return typeof document=="undefined"?lt(n):u().show(n)}function j(n,t,e,s){let i={};t&&typeof t=="object"?i={...t}:typeof t=="number"&&(i.duration=t),e&&(i.theme=e),s&&(i.position=s);const o={message:n,...i,level:i.level||void 0};return i.duration!==void 0&&(o.duration=i.duration),i.position&&(o.position=i.position),i.theme&&(o.theme=i.theme),o}function L(n){return(t,e,s,i)=>B({...j(t,e,s,i),level:n})}const k=()=>typeof document!="undefined";function dt(n,t,e,s){const i=j(n,t,e,s);return B({...i,level:i.level||"custom"})}const M=Object.assign(dt,{info:L("info"),success:L("success"),error:L("error"),warning:L("warning"),loading:L("loading"),show:n=>B(n),promise:(n,t)=>k()?u().promise(n,t):n,update:(n,t)=>k()?u().update(n,t):!1,dismiss:n=>k()?n===void 0?(u().clear(),!0):u().dismiss(n):!1,clear:()=>{k()&&u().clear()},configure:n=>{k()&&u().configure(n)}}),A={show:n=>u().show(n),update:(n,t)=>u().update(n,t),dismiss:n=>u().dismiss(n),clear:()=>u().clear(),info:(n,t)=>u().show({message:n,level:"info",...t}),success:(n,t)=>u().show({message:n,level:"success",...t}),error:(n,t)=>u().show({message:n,level:"error",...t}),warning:(n,t)=>u().show({message:n,level:"warning",...t}),loading:(n,t)=>u().show({message:n,level:"loading",...t}),promise:(n,t)=>u().promise(n,t),group:(n,t)=>u().group(n,t),configure:n=>u().configure(n),use:n=>u().use(n),getToasts:()=>u().getToasts(),getGroups:()=>u().getGroups(),getConfig:()=>u().getConfig(),getState:()=>u().getState(),subscribe:n=>u().subscribe(n),onEditorEvent:(n,t)=>u().onEditorEvent(n,t),triggerEditorEvent:(n,t,...e)=>u().triggerEditorEvent(n,t,...e),destroy:()=>{C&&(C.destroy(),C=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const n=window;n.toast=M,n.toastAdvanced=A,n.toastPro=A,n.ToastManager=O,n.__editoraToastReady||(n.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:M,toastAdvanced:A,toastPro:A,ToastManager:O}})))}T.ToastManager=O,T.default=M,T.toast=M,T.toastAdvanced=A,T.toastPro=A,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
2
2
  //# sourceMappingURL=index.umd.js.map