customizable-toast-notification 3.7.1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.7.1
3
- * Build: 2025-09-13 10:09:28
4
- * Cache-Buster: 1757758168805
2
+ * Customizable Toast Notifications 3.8.0
3
+ * Build: 2025-09-14 10:34:50
4
+ * Cache-Buster: 1757846090138
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
@@ -12,7 +12,7 @@
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
13
  * out of the box — with zero dependencies.
14
14
  */
15
- "use strict";async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const o=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,o){if(!o.hasFullWidth)return!1;if(e.maxWidth="100vw",o.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(o.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,o)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,o)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,o)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function o(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(o){try{return t.insertAdjacentElement("beforeend",e),!0}catch(o){try{if(t===document.body){const o=e.cloneNode(!0);return t.appendChild(o),!0}}catch(t){return!1}}}return!1}async function n(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,o,n;if(t.startsWith("#")){const r=t.substring(1);if(3===r.length)e=parseInt(r[0]+r[0],16),o=parseInt(r[1]+r[1],16),n=parseInt(r[2]+r[2],16);else{if(6!==r.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const r=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!r)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(r[1]),o=parseInt(r[2]),n=parseInt(r[3])}else{const r={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!r)throw new Error(`Unsupported color format: ${t}`);e=r[0],o=r[1],n=r[2]}if(isNaN(e)||isNaN(o)||isNaN(n))throw new Error(`Invalid color value: ${t}`);const r=(.2126*e+.7152*o+.0722*n)/255,a=.05;return(Math.max(r,a)+.05)/Math.min(r,a)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function r(t,e,o){const n=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=n;const r=document.createElement("span");r.style.position=e.fontPosition,r.style.display="inline-block",r.style.flex="1",r.style.padding=e.fontPadding,r.style.borderRadius=e.fontBorderRadius,r.style.background=e.fontBackgroundColor,r.style.fontFamily=e.fontFamily,r.style.fontSize=e.fontSize,r.style.fontWeight=e.fontWeight,r.style.lineHeight=e.fontLineHeight,r.style.color=e.textColor,r.style.userSelect="text",r.style.wordBreak="break-word",r.style.direction=e.fontDirection,r.style.webkitLineClamp="3",r.style.webkitBoxOrient="vertical",r.style.whiteSpace=e.wrapText?"normal":"nowrap",r.style.display="block",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.lineClamp="3",r.style.boxOrient="vertical",r.style.display="-webkit-box",r.textContent=e.message,r.setAttribute("aria-label","Toast Notification Center"),r.setAttribute("title",e.message),t.appendChild(r),e.showCloseButton&&await async function(t,e,o){const n=document.createElement("button");n.setAttribute("aria-label","Close notification"),n.setAttribute("title","Close"),n.textContent="×",Object.assign(n.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),n.onclick=()=>o(t),t.appendChild(n),t._cleanupCloseButton=()=>{n.onclick=null}}(t,e,o),e.showProgressBar&&await async function(t,e){const o=document.createElement("div");Object.assign(o.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(o),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(o),o.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function a(t,e){try{const o=document.createElement("div");return o.id=`emergency-${Date.now()}`,o.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,o._animationDuration=500,o._isEmergencyToast=!0,setTimeout(()=>{try{o.parentNode&&o.parentNode.removeChild(o),e(o)}catch(t){}},t.duration||1800),o}catch(o){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,o){let n;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return n=await async function(t,o){try{const n=document.createElement(t);return n.id=await e(o),n}catch(t){try{const t="div",o="fallback",n=document.createElement(t);return n.id=await e(o),n.setAttribute("data-original-tag",t),n}catch(t){}}}("div","toast"),await r(n,t,o),n}catch(e){return await a(t,o),n}}let s=[],l=[];async function c(e){try{const n=await async function(e){try{let n=document.getElementById(`toast-container-${e.position}`);return n||(n=document.createElement("div"),n.id=`toast-container-${e.position}`,n.style.position="fixed",n.style.zIndex="9999",await t(n,e),await o(document.body,n)),n}catch(t){return document.body}}(e),r=await i(e,d);if(!r)throw new Error("Toast element creation failed!");s.push(r),n.id.includes("toast-container-")&&n.appendChild(r);const a="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,c=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(r),a);return void l.push(c)}catch(t){const o=document.querySelector('[id^="toast-container-"]'),n=a(e,d);return void(o&&o?.id?.includes("toast-container-")?o.appendChild(n):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
15
+ "use strict";async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const o=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,o){if(!o.hasFullWidth)return!1;if(e.maxWidth="100vw",o.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(o.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,o)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,o)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,o)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function o(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,o,n;if(t.startsWith("#")){const i=t.substring(1);if(3===i.length)e=parseInt(i[0]+i[0],16),o=parseInt(i[1]+i[1],16),n=parseInt(i[2]+i[2],16);else{if(6!==i.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(i.substring(0,2),16),o=parseInt(i.substring(2,4),16),n=parseInt(i.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const i=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!i)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(i[1]),o=parseInt(i[2]),n=parseInt(i[3])}else{const i={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!i)throw new Error(`Unsupported color format: ${t}`);e=i[0],o=i[1],n=i[2]}if(isNaN(e)||isNaN(o)||isNaN(n))throw new Error(`Invalid color value: ${t}`);const i=(.2126*e+.7152*o+.0722*n)/255,r=.05;return(Math.max(i,r)+.05)/Math.min(i,r)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function n(t,e,o){const n=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=n;const i=document.createElement("span");i.style.position=e.fontPosition,i.style.display="inline-block",i.style.flex="1",i.style.padding=e.fontPadding,i.style.borderRadius=e.fontBorderRadius,i.style.background=e.fontBackgroundColor,i.style.fontFamily=e.fontFamily,i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.lineHeight=e.fontLineHeight,i.style.color=e.textColor,i.style.userSelect="text",i.style.wordBreak="break-word",i.style.direction=e.fontDirection,i.style.webkitLineClamp="3",i.style.webkitBoxOrient="vertical",i.style.whiteSpace=e.wrapText?"normal":"nowrap",i.style.display="block",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.lineClamp="3",i.style.boxOrient="vertical",i.style.display="-webkit-box",i.textContent=e.message,i.setAttribute("aria-label","Toast Notification Center"),i.setAttribute("title",e.message),t.appendChild(i),e.showCloseButton&&await async function(t,e,o){const n=document.createElement("button");n.setAttribute("aria-label","Close notification"),n.setAttribute("title","Close"),n.textContent="×",Object.assign(n.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),n.onclick=()=>o(t),t.appendChild(n),t._cleanupCloseButton=()=>{n.onclick=null}}(t,e,o),e.showProgressBar&&await async function(t,e){const o=document.createElement("div");Object.assign(o.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(o),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(o),o.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function i(t,e){try{const o=document.createElement("div");return o.id=`emergency-${Date.now()}`,o.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,o._animationDuration=500,o._isEmergencyToast=!0,setTimeout(()=>{try{o.parentNode&&o.parentNode.removeChild(o),e(o)}catch(t){}},t.duration||1800),o}catch(o){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function r(t,e){return setTimeout(()=>{t()},e)}async function a(t,o){let r;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return r=await async function(t,o){try{const n=document.createElement(t);return n.id=await e(o),n}catch(t){try{const t="div",o="fallback",n=document.createElement(t);return n.id=await e(o),n.setAttribute("data-original-tag",t),n}catch(t){}}}("div","toast"),await n(r,t,o),r}catch(e){return await i(t,o),r}}const s=new Map,l=new Map;function c(t="bottom-right"){return`toast-container-${function(t="bottom-right"){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"-").replace(/\-+/g,"-")}(t)}`}async function u(t={},e){const o=c(t.position);if(l.has(o))return l.get(o);const n=(async()=>{const n=s.get(o);if(n&&n.isConnected)return n;let i=document.getElementById(o);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=o,i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const r=document.querySelectorAll(`#${o}`);if(r.length>1)for(let t=1;t<r.length;t++)try{r[t].remove()}catch{}return s.set(o,i),i})();l.set(o,n);try{return await n}finally{l.delete(c(t.position))}}const d=new Map,p=new Map,f=[];let m=0;function y(t){let e=5381;for(let o=0;o<t.length;o++)e=(e<<5)+e+t.charCodeAt(o);return e>>>0}async function h(t={}){const e=function({type:t="info",message:e="",position:o="bottom-right"}){return[String(t).trim().toLowerCase(),y(String(e)).toString(16),String(o).trim().toLowerCase()].join("|")}(t);if(d.has(e)){const o=d.get(e);return o.count++,clearTimeout(o.timeout),o.timeout=await r(()=>w(o.toast),(t.duration||1800)+10),void x(o)}if(p.has(e))return void p.get(e).count++;const o={options:t,count:1,rafId:0};p.set(e,o),o.rafId=requestAnimationFrame(async()=>{const t=p.get(e);if(t){if(p.delete(e),m>=3)return f.push({options:t.options,key:e,count:t.count}),void b();await g(t.options,e,t.count)}})}async function g(e,o,n){try{m++;const i=await u(e,t),s=await a(e,w);if(!s)throw new Error("Toast element creation failed");const l=document.createElement("div");Object.assign(l.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const c=document.createElement("div");Object.assign(c.style,{position:"relative",overflow:"hidden",borderRadius:e.borderRadius||"8px",zIndex:"1"}),c.appendChild(s),l.appendChild(c),i.id.includes("toast-container-")&&i.appendChild(l);const p={outer:l,toast:s,count:Math.max(1,0|n),timeout:null};d.set(o,p),s._key=o,p.count>1&&x(p),p.timeout=await r(()=>w(s),(e.duration||1800)+10)}catch(t){m=Math.max(0,m-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(i(e,w))}}async function w(t){if(!t||!t._key)return;const e=d.get(t._key);var o;e&&(clearTimeout(e.timeout),d.delete(t._key),m=Math.max(0,m-1),e.outer.querySelector(".toast-count-badge")?.remove(),await(o=e.outer,new Promise(t=>{let e=!1;const n=()=>{e||(e=!0,async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}}(o),t())},i=o.firstElementChild||o,r=t=>{t.target===i&&(i.removeEventListener("transitionend",r,!0),n())};i.addEventListener("transitionend",r,!0),setTimeout(()=>{i.removeEventListener("transitionend",r,!0),n()},700)})),b())}function b(){for(;m<3&&f.length;){const t=f.shift();if(d.has(t.key)){const e=d.get(t.key);e.count+=t.count,x(e);continue}g(t.options,t.key,t.count)}}function x({outer:t,count:e}){if(e<2)return void t.querySelector(".toast-count-badge")?.remove();let o=t.querySelector(".toast-count-badge");o||(o=document.createElement("span"),o.className="toast-count-badge",o.setAttribute("aria-label",`${e} identical notifications`),Object.assign(o.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),t.appendChild(o)),o.textContent=e>99?"99+":String(e),o.style.transform="scale(1.2)",setTimeout(()=>o.style.transform="scale(1)",150)}
16
16
  // * @license Apache-2.0
17
- let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const f=[];let y=!1;async function m(e={}){try{const r=await async function(t){const e=t?.position?.toLowerCase()?.trim(),o=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",r={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:o,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=t?.message??r.message;try{r.backgroundColor||(r.backgroundColor=u?.[r.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),r.message=r.message||p?.[r.type]||"No Message Provided!",!r.textColor&&r.backgroundColor&&(r.textColor=await n(r.backgroundColor)),!r.progressColor&&r.backgroundColor&&(r.progressColor=await n(r.backgroundColor))}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(e);await async function(e){try{let n=document.getElementById(`toast-container-${e.position}`);return n||(n=document.createElement("div"),n.id=`toast-container-${e.position}`,n.style.position="fixed",n.style.zIndex="9999",await t(n,e),await o(document.body,n)),n}catch(t){return document.body}}(r),await c(r)}catch(t){const o="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(o)}}let h=!1;async function g(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){y||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0):document.addEventListener("DOMContentLoaded",()=>{y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0},{once:!0}))}(),y?h?await m(t):(h=!0,setTimeout(await m(t),2e3)):f.push(t))}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:g,setDefaultColors:w,setDefaultMessages:b})}catch(t){}exports.createToast=g,exports.noop=function(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=w,exports.setDefaultMessages=b;
17
+ let C={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},v={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const k=[];let E=!1;async function T(e={}){try{const n=await async function(t){const e=t?.position?.toLowerCase()?.trim(),n=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",i={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:n,..."object"!=typeof t||Array.isArray(t)?{}:t};i.message=t?.message??i.message;try{i.backgroundColor||(i.backgroundColor=C?.[i.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),i.message=i.message||v?.[i.type]||"No Message Provided!",!i.textColor&&i.backgroundColor&&(i.textColor=await o(i.backgroundColor)),!i.progressColor&&i.backgroundColor&&(i.progressColor=await o(i.backgroundColor))}catch(t){}"string"!=typeof i.message&&(i.message="No Message Provided!");return i}(e);await async function(e){try{return await u(e,t)}catch(t){return document.body}}(n),await h(n)}catch(t){const o="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(o)}}let S=!1;async function I(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){E||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(E=!0,k.forEach(t=>setTimeout(()=>T(t),2e3)),k.length=0):document.addEventListener("DOMContentLoaded",()=>{E=!0,k.forEach(t=>setTimeout(()=>T(t),2e3)),k.length=0},{once:!0}))}(),E?S?await T(t):(S=!0,setTimeout(await T(t),2e3)):k.push(t))}function B(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(C={...C,...t})}catch(t){}}function L(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(v={...v,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:I,setDefaultColors:B,setDefaultMessages:L})}catch(t){}exports.createToast=I,exports.noop=function(){w(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=B,exports.setDefaultMessages=L;
18
18
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/utils/position.js","../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/components/ToastContainer.js","../src/index.js"],"sourcesContent":["// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {Object} options - Options object containing position\r\n * @returns {Promise<void>}\r\n */\r\nexport async function setPosition(container, options) {\r\n if (!container || !options.position) {\r\n throw new Error(\"Invalid container or position!\");\r\n }\r\n\r\n resetContainerStyles(container);\r\n const positionFlags = parsePosition(options.position);\r\n\r\n if (handleFullWidthPositions(container, options, positionFlags)) return;\r\n if (handleCenterPositions(container, positionFlags)) return;\r\n\r\n applyStandardPositioning(container, positionFlags);\r\n}\r\n\r\n/**\r\n * Reset all position-related styles\r\n * @param {HTMLElement} container\r\n */\r\nfunction resetContainerStyles(container) {\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n}\r\n\r\n/**\r\n * Parse position string into boolean flags\r\n * @param {string} position\r\n * @returns {Object} Position flags\r\n */\r\nfunction parsePosition(position) {\r\n const pos = position.toLowerCase().trim();\r\n return {\r\n hasTop: pos.includes(\"top\"),\r\n hasBottom: pos.includes(\"bottom\") || pos.includes(\"below\"),\r\n hasLeft: pos.includes(\"left\"),\r\n hasRight: pos.includes(\"right\"),\r\n hasCenter: pos.includes(\"center\"),\r\n hasFullWidth:\r\n pos.includes(\"top-full-width\") ||\r\n pos.includes(\"bottom-full-width\") ||\r\n pos.includes(\"fullwidth\"),\r\n };\r\n}\r\n\r\n/**\r\n * Handle full-width positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} options\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleFullWidthPositions(container, options, flags) {\r\n if (!flags.hasFullWidth) return false;\r\n\r\n options.maxWidth = \"100vw\";\r\n\r\n if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Handle center positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleCenterPositions(container, flags) {\r\n if (!flags.hasCenter) return false;\r\n\r\n // top-center\r\n if (flags.hasTop && !flags.hasLeft && !flags.hasRight) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // bottom-center\r\n if (flags.hasBottom && !flags.hasLeft && !flags.hasRight) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // left-center\r\n if (flags.hasLeft && !flags.hasTop && !flags.hasBottom) {\r\n container.style.left = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // right-center\r\n if (flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.right = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // full center (no sides specified)\r\n if (!flags.hasLeft && !flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Apply standard positioning (corners and edges)\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n */\r\nfunction applyStandardPositioning(container, flags) {\r\n // Set vertical position\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n } else if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n // Set horizontal position\r\n if (flags.hasRight) {\r\n container.style.right = \"10px\";\r\n } else if (flags.hasLeft) {\r\n container.style.left = \"10px\";\r\n } else {\r\n // Default: bottom-center\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n }\r\n}\r\n","// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = await generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = await generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n // Emergency fallback removed: avoid using outerHTML (drops listeners & risks XSS).\r\n // Final attempt: clone and append using standard APIs.\r\n try {\r\n if (parent === document.body) {\r\n const clone = child.cloneNode(true);\r\n parent.appendChild(clone);\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport async function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n\r\n/**\r\n * Determine text color based on background color.\r\n * @param {string} toastBg Toast background color in hex, rgb, or rgba format.\r\n * @returns {Promise<string>} Text color, either `\"black\"` or `\"white\"`.\r\n */\r\nexport async function getTextColor(toastBg) {\r\n if (!toastBg) return \"black\";\r\n try {\r\n return (await contrast(toastBg)) > 3.5 ? \"black\" : \"white\";\r\n } catch (error) {\r\n console.warn(\"TextColor calculation failed:\", error);\r\n return \"black\";\r\n }\r\n}\r\n\r\n/**\r\n * Calculates the contrast ratio between the given color and black or white.\r\n * @param {string} color A color in hex, rgb, rgba, or color name format.\r\n * @returns {Promise<number>} The contrast ratio between the given color and black or white.\r\n * @throws {Error} If the given color is not supported.\r\n */\r\nasync function contrast(color) {\r\n if (!color) {\r\n throw new Error(\"Color is required\");\r\n }\r\n\r\n let r, g, b;\r\n\r\n // If color is in hex format\r\n if (color.startsWith(\"#\")) {\r\n const hex = color.substring(1);\r\n if (hex.length === 3) {\r\n r = parseInt(hex[0] + hex[0], 16);\r\n g = parseInt(hex[1] + hex[1], 16);\r\n b = parseInt(hex[2] + hex[2], 16);\r\n } else if (hex.length === 6) {\r\n r = parseInt(hex.substring(0, 2), 16);\r\n g = parseInt(hex.substring(2, 4), 16);\r\n b = parseInt(hex.substring(4, 6), 16);\r\n } else {\r\n throw new Error(`Invalid hex color format: ${color}`);\r\n }\r\n }\r\n // If color is in rgb/rgba format\r\n else if (color.startsWith(\"rgb\") || color.startsWith(\"rgba\")) {\r\n const match = color.match(\r\n /^rgba?\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/\r\n );\r\n if (match) {\r\n r = parseInt(match[1]);\r\n g = parseInt(match[2]);\r\n b = parseInt(match[3]);\r\n } else {\r\n throw new Error(`Invalid rgb/rgba color format: ${color}`);\r\n }\r\n }\r\n // If color is a color name\r\n else {\r\n const colorMap = {\r\n black: [0, 0, 0],\r\n white: [255, 255, 255],\r\n // Add more color names as needed\r\n };\r\n const colorArray = colorMap[color.toLowerCase()];\r\n if (colorArray) {\r\n r = colorArray[0];\r\n g = colorArray[1];\r\n b = colorArray[2];\r\n } else {\r\n throw new Error(`Unsupported color format: ${color}`);\r\n }\r\n }\r\n\r\n if (isNaN(r) || isNaN(g) || isNaN(b)) {\r\n throw new Error(`Invalid color value: ${color}`);\r\n }\r\n\r\n const l1 = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 255;\r\n const l2 = 0.05;\r\n return (Math.max(l1, l2) + 0.05) / Math.min(l1, l2);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n // Accessibility + avoid innerHTML (XSS surface)\r\n closeButton.setAttribute(\"aria-label\", \"Close notification\");\r\n closeButton.setAttribute(\"title\", \"Close\");\r\n closeButton.textContent = \"×\"; // U+00D7 multiplication sign\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor,\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport async function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport async function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n requestAnimationFrame(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n });\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = await parseAnimationDuration(\r\n options.animationDuration\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor,\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: options.borderRadius,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: options.maxWidth,\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration} ${options.animationEasing}, transform ${options.animationDuration} ${options.animationEasing}`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n // willChange: \"opacity, transform\",\r\n });\r\n\r\n // TODO! Later\r\n // await animateElement(toast, {\r\n // animationType: options.animationType,\r\n // duration: animDurationMs,\r\n // easing: options.animationEasing,\r\n // });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n\r\n // Layout & positioning\r\n messageSpan.style.position = options.fontPosition;\r\n messageSpan.style.display = \"inline-block\"; // ensure consistent layout\r\n messageSpan.style.flex = \"1\";\r\n\r\n // Spacing & container styling\r\n messageSpan.style.padding = options.fontPadding;\r\n messageSpan.style.borderRadius = options.fontBorderRadius;\r\n messageSpan.style.background = options.fontBackgroundColor;\r\n\r\n // Font stack (system + emoji + fallback)\r\n messageSpan.style.fontFamily = options.fontFamily;\r\n\r\n // Font size & readability\r\n messageSpan.style.fontSize = options.fontSize; // minimum for readability\r\n messageSpan.style.fontWeight = options.fontWeight;\r\n messageSpan.style.lineHeight = options.fontLineHeight; // balance readability\r\n\r\n //TODO LATER Icons (auto dark/light fallback)\r\n // messageSpan.style.color =\r\n // options.iconColor ||\r\n // (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n // ? \"#f5f5f5\"\r\n // : \"#111111\");\r\n\r\n // Colors (auto dark/light fallback)\r\n messageSpan.style.color = options.textColor;\r\n\r\n // Accessibility\r\n messageSpan.style.userSelect = \"text\"; // allow copy/paste if needed\r\n messageSpan.style.wordBreak = \"break-word\"; // avoid layout breaking on long strings\r\n messageSpan.style.direction = options.fontDirection; // RTL/LTR auto-detect\r\n // ✅ Multi-line ellipsis (max 3 lines)\r\n messageSpan.style.webkitLineClamp = \"3\"; // maximum 3 lines\r\n messageSpan.style.webkitBoxOrient = \"vertical\";\r\n messageSpan.style.whiteSpace = options.wrapText ? \"normal\" : \"nowrap\"; // allow wrapping if wanted\r\n messageSpan.style.display = \"block\";\r\n messageSpan.style.overflow = \"hidden\";\r\n messageSpan.style.textOverflow = \"ellipsis\";\r\n messageSpan.style.lineClamp = \"3\"; // modern property\r\n messageSpan.style.boxOrient = \"vertical\"; // non-prefixed\r\n messageSpan.style.display = \"-webkit-box\";\r\n // messageSpan.style.mixBlendMode = \"difference\";\r\n // Assign message\r\n messageSpan.textContent = options.message;\r\n messageSpan.setAttribute(\"aria-label\", \"Toast Notification Center\");\r\n messageSpan.setAttribute(\"title\", options.message);\r\n // Add to toast\r\n toast.appendChild(messageSpan);\r\n\r\n // TODO Icon Later\r\n // if (options.icon) {\r\n // createIcon(toast, options);\r\n // }\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n await createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n await createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n await runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message;\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n// CSS injection function\r\nasync function injectToastStyles() {\r\n if (document.getElementById(\"ctoast-styles\")) return; // Already injected\r\n\r\n const style = document.createElement(\"style\");\r\n style.id = \"ctoast-styles\";\r\n style.textContent = `\r\n .ctoast-toast {\r\n padding: 12px 20px;\r\n margin-bottom: 10px;\r\n border-radius: 5px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\r\n min-width: 250px;\r\n max-width: 400px;\r\n opacity: 0;\r\n position: relative;\r\n transform: translateY(20px);\r\n z-index: 9999;\r\n }\r\n\r\n .ctoast-message {\r\n flex: 1;\r\n }\r\n\r\n .ctoast-close {\r\n cursor: pointer;\r\n margin-left: 10px;\r\n font-weight: bold;\r\n background: transparent;\r\n border: none;\r\n }\r\n\r\n .ctoast-progress {\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n height: 4px;\r\n background: rgba(255,255,255,0.7);\r\n width: 100%;\r\n transform-origin: left;\r\n }\r\n\r\n .ctoast-show {\r\n opacity: 1 !important;\r\n transform: translateY(0) !important;\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n await applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n await createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(options) {\r\n try {\r\n let toastContainer = document.getElementById(\r\n `toast-container-${options.position}`\r\n );\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${options.position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, options);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// // src/index.js\r\n// /**\r\n// * @fileoverview A simple toast notification library for any JavaScript framework.\r\n// * @name Customizable Toast Notifications\r\n// * @author Priyanshu Patel\r\n// * @version __VERSION__\r\n// * @build Production\r\n// * @license Apache-2.0\r\n// * @depends None\r\n// * @description A lightweight and fully customizable toast notification library\r\n// * designed for seamless integration with any JavaScript or framework-based UI.\r\n// * Supports flexible positioning, theming, icons, animations, and timing options\r\n// * out of the box — with zero dependencies.\r\n// * Author: Priyanshu Patel\r\n// * Email: priyanshu.alt191@gmail.com\r\n// * Created: July 31, 2024\r\n// * License: Apache-2.0\r\n// * Dependencies: None\r\n// */\r\n//\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\nimport { appendChild, getTextColor } from \"./utils/dom.js\";\r\nimport { setPosition } from \"./utils/position.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\n// Toast queue for calls before DOM ready\r\nconst pendingToasts = [];\r\n\r\n// Flag to indicate DOM ready for toast execution\r\nlet domReady = false;\r\n\r\n// DOM ready check\r\nasync function checkDOMReady() {\r\n if (domReady) return;\r\n\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n if (\r\n document.readyState === \"complete\" ||\r\n document.readyState === \"interactive\"\r\n ) {\r\n domReady = true;\r\n // Flush queued toasts after 2s delay\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n } else {\r\n // Wait for DOMContentLoaded\r\n document.addEventListener(\r\n \"DOMContentLoaded\",\r\n () => {\r\n domReady = true;\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n },\r\n { once: true }\r\n );\r\n }\r\n }\r\n}\r\n\r\n// Core toast creation logic\r\nasync function createToastNow(options = {}) {\r\n try {\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n await createFirstToastContainer(sanitizedOptions);\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n const safeMessage =\r\n typeof options?.message === \"string\" && options?.message !== null\r\n ? `${options?.message?.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\nlet initialDelayDone = false; // flag to ensure single execution\r\n\r\n// Public API\r\nasync function createToast(options = {}) {\r\n // Check browser environment\r\n const isBrowser =\r\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\r\n\r\n if (!isBrowser) {\r\n console.warn(\r\n \"ToastNotification: running in non-browser environment, no DOM available.\"\r\n );\r\n return;\r\n }\r\n\r\n // Check if DOM ready\r\n await checkDOMReady();\r\n\r\n if (!domReady) {\r\n // Queue for later execution\r\n pendingToasts.push(options);\r\n return;\r\n }\r\n\r\n // If DOM ready → execute after 2s delay\r\n if (!initialDelayDone) {\r\n // First call → wait 2 seconds\r\n initialDelayDone = true;\r\n setTimeout(await createToastNow(options), 2000);\r\n } else {\r\n // Subsequent calls → run immediately\r\n await createToastNow(options);\r\n }\r\n}\r\n\r\nasync function createFirstToastContainer(options) {\r\n try {\r\n let toastContainer = document.getElementById(\r\n `toast-container-${options.position}`\r\n );\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${options.position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, options);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n\r\n/**\r\n * Sanitizes and normalizes toast options.\r\n * Fills in defaults, validates input, and ensures colors & messages are set.\r\n * @param {Object} options - User-provided toast options\r\n * @returns {Promise<Object>} final sanitized toast options\r\n */\r\nasync function sanitizeToastOptions(options) {\r\n const contPosition = options?.position?.toLowerCase()?.trim();\r\n const contMaxWidth =\r\n contPosition?.includes(\"top-full-width\") ||\r\n contPosition?.includes(\"bottom-full-width\")\r\n ? \"100vw\"\r\n : \"400px\";\r\n\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n borderRadius: \"50px\",\r\n backgroundColor: undefined,\r\n textColor: undefined,\r\n showCloseButton: true,\r\n animationDuration: \"0.4s\",\r\n animationType: \"fade\",\r\n animationEasing: \"ease\",\r\n showProgressBar: true,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n fontPosition: \"relative\",\r\n fontPadding: undefined,\r\n fontBorderRadius: undefined,\r\n fontBackgroundColor: undefined,\r\n fontFamily:\r\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\r\n fontSize: \"14px\",\r\n fontWeight: \"400\",\r\n fontLineHeight: \"1.4\",\r\n fontDirection: \"auto\",\r\n wrapText: \"normal\",\r\n maxWidth: contMaxWidth,\r\n };\r\n\r\n // Merge defaults with user options\r\n const final = {\r\n ...defaults,\r\n ...(typeof options === \"object\" && !Array.isArray(options) ? options : {}),\r\n };\r\n\r\n // Ensure message property separately\r\n final.message = options?.message ?? final.message;\r\n\r\n try {\r\n // Background color fallback based on type or system preference\r\n if (!final.backgroundColor) {\r\n final.backgroundColor =\r\n defaultColors?.[final.type] ??\r\n (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n ? \"#f5f5f5\"\r\n : \"#111111\");\r\n }\r\n\r\n // Default message if not provided\r\n final.message =\r\n final.message || defaultMessages?.[final.type] || \"No Message Provided!\";\r\n\r\n // Ensure textColor is set\r\n if (!final.textColor && final.backgroundColor) {\r\n final.textColor = await getTextColor(final.backgroundColor);\r\n }\r\n\r\n // Ensure progressColor is set\r\n if (!final.progressColor && final.backgroundColor) {\r\n final.progressColor = await getTextColor(final.backgroundColor);\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Safety check for message type\r\n if (typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","setPosition","container","options","position","Error","style","top","bottom","left","right","transform","resetContainerStyles","positionFlags","pos","toLowerCase","trim","hasTop","includes","hasBottom","hasLeft","hasRight","hasCenter","hasFullWidth","parsePosition","flags","maxWidth","handleFullWidthPositions","handleCenterPositions","applyStandardPositioning","generateUniqueId","prefix","Date","now","Math","floor","random","appendChild","parent","child","contains","error","insertAdjacentElement","fallbackError","document","body","clone","cloneNode","emergencyError","getTextColor","toastBg","color","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","isNaN","l1","l2","max","min","contrast","applyRichStyling","toast","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","opacity","transition","animationEasing","zIndex","_animationDuration","messageSpan","createElement","fontPosition","flex","fontPadding","fontBorderRadius","fontBackgroundColor","fontFamily","fontSize","fontWeight","lineHeight","fontLineHeight","textColor","userSelect","wordBreak","direction","fontDirection","webkitLineClamp","webkitBoxOrient","whiteSpace","wrapText","textOverflow","lineClamp","boxOrient","textContent","message","setAttribute","showCloseButton","closeButton","border","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","createElementWithId","currentToast","emergencyTimeouts","showToast","toastContainer","getElementById","createToastContainer","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","contPosition","contMaxWidth","final","type","undefined","animationType","Array","isArray","window","matchMedia","matches","sanitizeToastOptions","createFirstToastContainer","safeMessage","initialDelayDone","createToast","readyState","forEach","addEventListener","once","checkDOMReady","setDefaultColors","colors","setDefaultMessages","messages","customizableToast"],"mappings":";;;;;;;;;;;;;;aASOA,eAAeC,EAAYC,EAAWC,GAC3C,IAAKD,IAAcC,EAAQC,SACzB,MAAM,IAAIC,MAAM,mCAgBpB,SAA8BH,GAC5BA,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAME,OAAS,OACzBN,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,OACxBR,EAAUI,MAAMK,UAAY,MAC9B,CAnBEC,CAAqBV,GACrB,MAAMW,EAyBR,SAAuBT,GACrB,MAAMU,EAAMV,EAASW,cAAcC,OACnC,MAAO,CACLC,OAAQH,EAAII,SAAS,OACrBC,UAAWL,EAAII,SAAS,WAAaJ,EAAII,SAAS,SAClDE,QAASN,EAAII,SAAS,QACtBG,SAAUP,EAAII,SAAS,SACvBI,UAAWR,EAAII,SAAS,UACxBK,aACET,EAAII,SAAS,mBACbJ,EAAII,SAAS,sBACbJ,EAAII,SAAS,aAEnB,CAtCwBM,CAAcrB,EAAQC,WA+C9C,SAAkCF,EAAWC,EAASsB,GACpD,IAAKA,EAAMF,aAAc,OAAO,EAIhC,GAFApB,EAAQuB,SAAW,QAEfD,EAAMR,OAIR,OAHAf,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,QACjB,EAGT,GAAIe,EAAMN,UAIR,OAHAjB,EA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qD,EAAe9L,GAAU,MAE5C4L,EAAcrI,OAAS,GAEzB,CAAE4J,MAAM,IAIhB,CAoCQC,GAEDvB,EAOAiB,QAMGhB,EAAe9L,IAJrB8M,GAAmB,EACnBrE,iBAAiBqD,EAAe9L,GAAU,MAR1C4L,EAAcrB,KAAKvK,GAavB,CAmHA,SAASqN,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBhB,MAAMC,QAAQe,KACzD/B,EAAgB,IAAKA,KAAkB+B,GAE3C,CAAE,MAAOhL,GAET,CACF,CAKA,SAASiL,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BlB,MAAMC,QAAQiB,KAC7D7B,EAAkB,IAAKA,KAAoB6B,GAE/C,CAAE,MAAOlL,GAET,CACF,CAWA,IAEwB,oBAAXkK,SACTA,OAAOiB,kBAAoB,CACzBV,cACAM,mBACAE,sBAGN,CAAE,MAAOjL,GAET,oCApBA,WAEEgI,EADc7H,SAASiH,cAAc,yCAEvC"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/position.js","../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/utils/containerRegistry.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {Object} options - Options object containing position\r\n * @returns {Promise<void>}\r\n */\r\nexport async function setPosition(container, options) {\r\n if (!container || !options.position) {\r\n throw new Error(\"Invalid container or position!\");\r\n }\r\n\r\n resetContainerStyles(container);\r\n const positionFlags = parsePosition(options.position);\r\n\r\n if (handleFullWidthPositions(container, options, positionFlags)) return;\r\n if (handleCenterPositions(container, positionFlags)) return;\r\n\r\n applyStandardPositioning(container, positionFlags);\r\n}\r\n\r\n/**\r\n * Reset all position-related styles\r\n * @param {HTMLElement} container\r\n */\r\nfunction resetContainerStyles(container) {\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n}\r\n\r\n/**\r\n * Parse position string into boolean flags\r\n * @param {string} position\r\n * @returns {Object} Position flags\r\n */\r\nfunction parsePosition(position) {\r\n const pos = position.toLowerCase().trim();\r\n return {\r\n hasTop: pos.includes(\"top\"),\r\n hasBottom: pos.includes(\"bottom\") || pos.includes(\"below\"),\r\n hasLeft: pos.includes(\"left\"),\r\n hasRight: pos.includes(\"right\"),\r\n hasCenter: pos.includes(\"center\"),\r\n hasFullWidth:\r\n pos.includes(\"top-full-width\") ||\r\n pos.includes(\"bottom-full-width\") ||\r\n pos.includes(\"fullwidth\"),\r\n };\r\n}\r\n\r\n/**\r\n * Handle full-width positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} options\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleFullWidthPositions(container, options, flags) {\r\n if (!flags.hasFullWidth) return false;\r\n\r\n options.maxWidth = \"100vw\";\r\n\r\n if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Handle center positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleCenterPositions(container, flags) {\r\n if (!flags.hasCenter) return false;\r\n\r\n // top-center\r\n if (flags.hasTop && !flags.hasLeft && !flags.hasRight) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // bottom-center\r\n if (flags.hasBottom && !flags.hasLeft && !flags.hasRight) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // left-center\r\n if (flags.hasLeft && !flags.hasTop && !flags.hasBottom) {\r\n container.style.left = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // right-center\r\n if (flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.right = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // full center (no sides specified)\r\n if (!flags.hasLeft && !flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Apply standard positioning (corners and edges)\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n */\r\nfunction applyStandardPositioning(container, flags) {\r\n // Set vertical position\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n } else if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n // Set horizontal position\r\n if (flags.hasRight) {\r\n container.style.right = \"10px\";\r\n } else if (flags.hasLeft) {\r\n container.style.left = \"10px\";\r\n } else {\r\n // Default: bottom-center\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n }\r\n}\r\n","// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = await generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = await generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n // Emergency fallback removed: avoid using outerHTML (drops listeners & risks XSS).\r\n // Final attempt: clone and append using standard APIs.\r\n try {\r\n if (parent === document.body) {\r\n const clone = child.cloneNode(true);\r\n parent.appendChild(clone);\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport async function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n\r\n/**\r\n * Determine text color based on background color.\r\n * @param {string} toastBg Toast background color in hex, rgb, or rgba format.\r\n * @returns {Promise<string>} Text color, either `\"black\"` or `\"white\"`.\r\n */\r\nexport async function getTextColor(toastBg) {\r\n if (!toastBg) return \"black\";\r\n try {\r\n return (await contrast(toastBg)) > 3.5 ? \"black\" : \"white\";\r\n } catch (error) {\r\n console.warn(\"TextColor calculation failed:\", error);\r\n return \"black\";\r\n }\r\n}\r\n\r\n/**\r\n * Calculates the contrast ratio between the given color and black or white.\r\n * @param {string} color A color in hex, rgb, rgba, or color name format.\r\n * @returns {Promise<number>} The contrast ratio between the given color and black or white.\r\n * @throws {Error} If the given color is not supported.\r\n */\r\nasync function contrast(color) {\r\n if (!color) {\r\n throw new Error(\"Color is required\");\r\n }\r\n\r\n let r, g, b;\r\n\r\n // If color is in hex format\r\n if (color.startsWith(\"#\")) {\r\n const hex = color.substring(1);\r\n if (hex.length === 3) {\r\n r = parseInt(hex[0] + hex[0], 16);\r\n g = parseInt(hex[1] + hex[1], 16);\r\n b = parseInt(hex[2] + hex[2], 16);\r\n } else if (hex.length === 6) {\r\n r = parseInt(hex.substring(0, 2), 16);\r\n g = parseInt(hex.substring(2, 4), 16);\r\n b = parseInt(hex.substring(4, 6), 16);\r\n } else {\r\n throw new Error(`Invalid hex color format: ${color}`);\r\n }\r\n }\r\n // If color is in rgb/rgba format\r\n else if (color.startsWith(\"rgb\") || color.startsWith(\"rgba\")) {\r\n const match = color.match(\r\n /^rgba?\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/\r\n );\r\n if (match) {\r\n r = parseInt(match[1]);\r\n g = parseInt(match[2]);\r\n b = parseInt(match[3]);\r\n } else {\r\n throw new Error(`Invalid rgb/rgba color format: ${color}`);\r\n }\r\n }\r\n // If color is a color name\r\n else {\r\n const colorMap = {\r\n black: [0, 0, 0],\r\n white: [255, 255, 255],\r\n // Add more color names as needed\r\n };\r\n const colorArray = colorMap[color.toLowerCase()];\r\n if (colorArray) {\r\n r = colorArray[0];\r\n g = colorArray[1];\r\n b = colorArray[2];\r\n } else {\r\n throw new Error(`Unsupported color format: ${color}`);\r\n }\r\n }\r\n\r\n if (isNaN(r) || isNaN(g) || isNaN(b)) {\r\n throw new Error(`Invalid color value: ${color}`);\r\n }\r\n\r\n const l1 = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 255;\r\n const l2 = 0.05;\r\n return (Math.max(l1, l2) + 0.05) / Math.min(l1, l2);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n // Accessibility + avoid innerHTML (XSS surface)\r\n closeButton.setAttribute(\"aria-label\", \"Close notification\");\r\n closeButton.setAttribute(\"title\", \"Close\");\r\n closeButton.textContent = \"×\"; // U+00D7 multiplication sign\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor,\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport async function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport async function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n requestAnimationFrame(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n });\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = await parseAnimationDuration(\r\n options.animationDuration\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor,\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: options.borderRadius,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: options.maxWidth,\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration} ${options.animationEasing}, transform ${options.animationDuration} ${options.animationEasing}`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n // willChange: \"opacity, transform\",\r\n });\r\n\r\n // TODO! Later\r\n // await animateElement(toast, {\r\n // animationType: options.animationType,\r\n // duration: animDurationMs,\r\n // easing: options.animationEasing,\r\n // });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n\r\n // Layout & positioning\r\n messageSpan.style.position = options.fontPosition;\r\n messageSpan.style.display = \"inline-block\"; // ensure consistent layout\r\n messageSpan.style.flex = \"1\";\r\n\r\n // Spacing & container styling\r\n messageSpan.style.padding = options.fontPadding;\r\n messageSpan.style.borderRadius = options.fontBorderRadius;\r\n messageSpan.style.background = options.fontBackgroundColor;\r\n\r\n // Font stack (system + emoji + fallback)\r\n messageSpan.style.fontFamily = options.fontFamily;\r\n\r\n // Font size & readability\r\n messageSpan.style.fontSize = options.fontSize; // minimum for readability\r\n messageSpan.style.fontWeight = options.fontWeight;\r\n messageSpan.style.lineHeight = options.fontLineHeight; // balance readability\r\n\r\n //TODO LATER Icons (auto dark/light fallback)\r\n // messageSpan.style.color =\r\n // options.iconColor ||\r\n // (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n // ? \"#f5f5f5\"\r\n // : \"#111111\");\r\n\r\n // Colors (auto dark/light fallback)\r\n messageSpan.style.color = options.textColor;\r\n\r\n // Accessibility\r\n messageSpan.style.userSelect = \"text\"; // allow copy/paste if needed\r\n messageSpan.style.wordBreak = \"break-word\"; // avoid layout breaking on long strings\r\n messageSpan.style.direction = options.fontDirection; // RTL/LTR auto-detect\r\n // ✅ Multi-line ellipsis (max 3 lines)\r\n messageSpan.style.webkitLineClamp = \"3\"; // maximum 3 lines\r\n messageSpan.style.webkitBoxOrient = \"vertical\";\r\n messageSpan.style.whiteSpace = options.wrapText ? \"normal\" : \"nowrap\"; // allow wrapping if wanted\r\n messageSpan.style.display = \"block\";\r\n messageSpan.style.overflow = \"hidden\";\r\n messageSpan.style.textOverflow = \"ellipsis\";\r\n messageSpan.style.lineClamp = \"3\"; // modern property\r\n messageSpan.style.boxOrient = \"vertical\"; // non-prefixed\r\n messageSpan.style.display = \"-webkit-box\";\r\n // messageSpan.style.mixBlendMode = \"difference\";\r\n // Assign message\r\n messageSpan.textContent = options.message;\r\n messageSpan.setAttribute(\"aria-label\", \"Toast Notification Center\");\r\n messageSpan.setAttribute(\"title\", options.message);\r\n // Add to toast\r\n toast.appendChild(messageSpan);\r\n\r\n // TODO Icon Later\r\n // if (options.icon) {\r\n // createIcon(toast, options);\r\n // }\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n await createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n await createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n await runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message;\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n// CSS injection function\r\nasync function injectToastStyles() {\r\n if (document.getElementById(\"ctoast-styles\")) return; // Already injected\r\n\r\n const style = document.createElement(\"style\");\r\n style.id = \"ctoast-styles\";\r\n style.textContent = `\r\n .ctoast-toast {\r\n padding: 12px 20px;\r\n margin-bottom: 10px;\r\n border-radius: 5px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\r\n min-width: 250px;\r\n max-width: 400px;\r\n opacity: 0;\r\n position: relative;\r\n transform: translateY(20px);\r\n z-index: 9999;\r\n }\r\n\r\n .ctoast-message {\r\n flex: 1;\r\n }\r\n\r\n .ctoast-close {\r\n cursor: pointer;\r\n margin-left: 10px;\r\n font-weight: bold;\r\n background: transparent;\r\n border: none;\r\n }\r\n\r\n .ctoast-progress {\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n height: 4px;\r\n background: rgba(255,255,255,0.7);\r\n width: 100%;\r\n transform-origin: left;\r\n }\r\n\r\n .ctoast-show {\r\n opacity: 1 !important;\r\n transform: translateY(0) !important;\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n await applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n await createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/utils/containerRegistry.js\r\n\"use strict\";\r\n\r\nconst containerRegistry = new Map(); // id -> HTMLElement\r\nconst containerLocks = new Map(); // id -> Promise<HTMLElement>\r\n\r\n/**\r\n * Normalize a position string to a canonical key (id-safe, stable).\r\n */\r\nexport function normalizePositionKey(position = \"bottom-right\") {\r\n // lower-case, trim, unify separators, alias \"below\" -> \"bottom\"\r\n const raw = String(position).toLowerCase().trim();\r\n const aliased = raw.replace(/\\bbelow\\b/g, \"bottom\");\r\n return aliased\r\n .replace(/\\s+/g, \"-\")\r\n .replace(/[^a-z0-9\\-]/g, \"-\")\r\n .replace(/\\-+/g, \"-\");\r\n}\r\n\r\n/**\r\n * Canonical container id\r\n */\r\nexport function getContainerId(position = \"bottom-right\") {\r\n return `toast-container-${normalizePositionKey(position)}`;\r\n}\r\n\r\n/**\r\n * Atomically get or create a single container per canonical id.\r\n */\r\nexport async function getOrCreateToastContainer(options = {}, setPosition) {\r\n const id = getContainerId(options.position);\r\n // If a creation is in-flight, await it\r\n if (containerLocks.has(id)) {\r\n return containerLocks.get(id);\r\n }\r\n\r\n const p = (async () => {\r\n // 1) Prefer registry cache if still connected\r\n const cached = containerRegistry.get(id);\r\n if (cached && cached.isConnected) {\r\n return cached;\r\n }\r\n\r\n // 2) Find existing in DOM\r\n let el = document.getElementById(id); // unique by spec, but may return first if duplicates exist\r\n if (el && !el.isConnected) {\r\n // re-attach if detached\r\n document.body.appendChild(el);\r\n }\r\n\r\n // 3) If not found, create\r\n if (!el) {\r\n el = document.createElement(\"div\");\r\n el.id = id;\r\n el.style.position = \"fixed\";\r\n el.style.zIndex = \"9999\";\r\n el.style.inset = \"auto 10px 10px auto\";\r\n el.style.display = \"flex\";\r\n el.style.justifyContent = \"space-between\";\r\n el.style.alignItems = \"center\";\r\n el.style.flexDirection = \"column\";\r\n el.style.overflow = \"hidden\";\r\n // Position with provided helper\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n document.body.appendChild(el);\r\n } else {\r\n // Ensure base styles and (re)apply position in case options changed\r\n el.style.position = el.style.position || \"fixed\";\r\n el.style.zIndex = el.style.zIndex || \"9999\";\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n }\r\n\r\n // 4) If somehow duplicates exist, keep the first and remove the rest\r\n // getElementById would have returned the first; clean up others proactively\r\n const all = document.querySelectorAll(`#${id}`);\r\n if (all.length > 1) {\r\n for (let i = 1; i < all.length; i++) {\r\n try {\r\n all[i].remove();\r\n } catch {}\r\n }\r\n }\r\n\r\n containerRegistry.set(id, el);\r\n return el;\r\n })();\r\n\r\n containerLocks.set(id, p);\r\n try {\r\n const out = await p;\r\n return out;\r\n } finally {\r\n // Clear the lock so future calls can re-enter if needed\r\n containerLocks.delete(getContainerId(options.position));\r\n }\r\n}\r\n","// src/components/ToastManager.js\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\nimport { getOrCreateToastContainer } from \"../utils/containerRegistry.js\";\r\nimport { setPosition } from \"../utils/position.js\";\r\n\r\n// Config\r\nconst MAX_VISIBLE = 3;\r\n\r\n// State\r\nconst active = new Map(); // key -> { outer, toast, count, timeout }\r\nconst pending = new Map(); // key -> { options, count, rafId }\r\nconst queue = []; // [{ options, key, count }]\r\nlet visibleCount = 0;\r\n\r\n// djb2 hash for full-message dedupe\r\nfunction hashString(str) {\r\n let h = 5381;\r\n for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i);\r\n return h >>> 0;\r\n}\r\n\r\nfunction makeKey({ type = \"info\", message = \"\", position = \"bottom-right\" }) {\r\n return [\r\n String(type).trim().toLowerCase(),\r\n hashString(String(message)).toString(16),\r\n String(position).trim().toLowerCase(),\r\n ].join(\"|\");\r\n}\r\n\r\nexport async function showToast(options = {}) {\r\n const key = makeKey(options);\r\n\r\n // If already active: group immediately\r\n if (active.has(key)) {\r\n const data = active.get(key);\r\n data.count++;\r\n clearTimeout(data.timeout);\r\n data.timeout = await safeSetTimeout(\r\n () => closeToast(data.toast),\r\n (options.duration || 1800) + 10\r\n );\r\n updateBadge(data);\r\n return;\r\n }\r\n\r\n // If coalescing is already scheduled for this key, just increment the pending count\r\n if (pending.has(key)) {\r\n pending.get(key).count++;\r\n return;\r\n }\r\n\r\n // Start coalescing identical calls in the same frame\r\n const entry = { options, count: 1, rafId: 0 };\r\n pending.set(key, entry);\r\n\r\n entry.rafId = requestAnimationFrame(async () => {\r\n // finalize batch for this key\r\n const current = pending.get(key);\r\n if (!current) return;\r\n pending.delete(key);\r\n\r\n // If capacity full, enqueue the grouped request\r\n if (visibleCount >= MAX_VISIBLE) {\r\n queue.push({ options: current.options, key, count: current.count });\r\n drainQueue();\r\n return;\r\n }\r\n\r\n // Otherwise create immediately with the grouped count\r\n await createOne(current.options, key, current.count);\r\n });\r\n}\r\n\r\nasync function createOne(options, key, initialCount) {\r\n try {\r\n visibleCount++;\r\n\r\n const container = await getOrCreateToastContainer(options, setPosition);\r\n\r\n // Build the toast element\r\n const toast = await createToastElement(options, closeToast);\r\n if (!toast) throw new Error(\"Toast element creation failed\");\r\n\r\n // Outer wrapper (badge surface; visible overflow)\r\n const outer = document.createElement(\"div\");\r\n Object.assign(outer.style, {\r\n position: \"relative\",\r\n display: \"inline-block\",\r\n overflow: \"visible\",\r\n marginBottom: \"10px\",\r\n zIndex: \"0\",\r\n width: \"100%\",\r\n });\r\n\r\n // Inner wrapper (clip progress bar & rounded corners)\r\n const inner = document.createElement(\"div\");\r\n Object.assign(inner.style, {\r\n position: \"relative\",\r\n overflow: \"hidden\",\r\n borderRadius: options.borderRadius || \"8px\",\r\n zIndex: \"1\",\r\n });\r\n\r\n inner.appendChild(toast);\r\n outer.appendChild(inner);\r\n\r\n // Mount\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(outer);\r\n }\r\n\r\n // Track\r\n const data = {\r\n outer,\r\n toast,\r\n count: Math.max(1, initialCount | 0),\r\n timeout: null,\r\n };\r\n active.set(key, data);\r\n toast._key = key;\r\n\r\n if (data.count > 1) updateBadge(data);\r\n\r\n // Auto-dismiss timer\r\n data.timeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n (options.duration || 1800) + 10\r\n );\r\n } catch (err) {\r\n // Rollback slot and fall back\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n console.warn(\"Toast creation failed:\", err);\r\n const el =\r\n document.querySelector('[id^=\"toast-container-\"]') || document.body;\r\n el.appendChild(createEmergencyToast(options, closeToast));\r\n }\r\n}\r\n\r\nexport async function closeToast(toast) {\r\n if (!toast || !toast._key) return;\r\n const data = active.get(toast._key);\r\n if (!data) return;\r\n\r\n clearTimeout(data.timeout);\r\n active.delete(toast._key);\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n\r\n // Remove badge if present\r\n data.outer.querySelector(\".toast-count-badge\")?.remove();\r\n\r\n // Remove wrapper after transition ends (or fallback)\r\n await removeWithTransition(data.outer);\r\n\r\n // Drain queue after a slot frees\r\n drainQueue();\r\n}\r\n\r\nfunction drainQueue() {\r\n // Fill available slots; coalesce queued entries against active if they became active meanwhile\r\n while (visibleCount < MAX_VISIBLE && queue.length) {\r\n const item = queue.shift();\r\n if (active.has(item.key)) {\r\n const data = active.get(item.key);\r\n data.count += item.count;\r\n updateBadge(data);\r\n continue;\r\n }\r\n // Create without awaiting to keep loop responsive; visibleCount is incremented inside createOne\r\n void createOne(item.options, item.key, item.count);\r\n }\r\n}\r\n\r\nfunction removeWithTransition(el) {\r\n return new Promise((resolve) => {\r\n let done = false;\r\n const finish = () => {\r\n if (done) return;\r\n done = true;\r\n removeElement(el);\r\n resolve();\r\n };\r\n\r\n // Listen on the immediate child (inner wrapper) if possible\r\n const child = el.firstElementChild || el;\r\n const onEnd = (e) => {\r\n if (e.target !== child) return;\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n };\r\n\r\n child.addEventListener(\"transitionend\", onEnd, true);\r\n // Hard fallback if no transition fires\r\n setTimeout(() => {\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n }, 700);\r\n });\r\n}\r\n\r\nfunction updateBadge({ outer, count }) {\r\n if (count < 2) {\r\n outer.querySelector(\".toast-count-badge\")?.remove();\r\n return;\r\n }\r\n let badge = outer.querySelector(\".toast-count-badge\");\r\n if (!badge) {\r\n badge = document.createElement(\"span\");\r\n badge.className = \"toast-count-badge\";\r\n badge.setAttribute(\"aria-label\", `${count} identical notifications`);\r\n Object.assign(badge.style, {\r\n position: \"absolute\",\r\n top: \"6px\",\r\n right: \"6px\",\r\n backgroundColor: \"#f44336\",\r\n color: \"#fff\",\r\n borderRadius: \"50%\",\r\n minWidth: \"20px\",\r\n height: \"20px\",\r\n fontSize: \"12px\",\r\n fontWeight: \"600\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n border: \"2px solid #fff\",\r\n boxShadow: \"0 2px 6px rgba(0,0,0,0.3)\",\r\n zIndex: \"2\",\r\n pointerEvents: \"none\",\r\n transition: \"transform 150ms ease\",\r\n });\r\n outer.appendChild(badge);\r\n }\r\n badge.textContent = count > 99 ? \"99+\" : String(count);\r\n badge.style.transform = \"scale(1.2)\";\r\n setTimeout(() => (badge.style.transform = \"scale(1)\"), 150);\r\n}\r\n","// // src/index.js\r\n// /**\r\n// * @fileoverview A simple toast notification library for any JavaScript framework.\r\n// * @name Customizable Toast Notifications\r\n// * @author Priyanshu Patel\r\n// * @version __VERSION__\r\n// * @build Production\r\n// * @license Apache-2.0\r\n// * @depends None\r\n// * @description A lightweight and fully customizable toast notification library\r\n// * designed for seamless integration with any JavaScript or framework-based UI.\r\n// * Supports flexible positioning, theming, icons, animations, and timing options\r\n// * out of the box — with zero dependencies.\r\n// * Author: Priyanshu Patel\r\n// * Email: priyanshu.alt191@gmail.com\r\n// * Created: July 31, 2024\r\n// * License: Apache-2.0\r\n// * Dependencies: None\r\n// */\r\n//\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\nimport { getOrCreateToastContainer } from \"./utils/containerRegistry.js\";\r\nimport { appendChild, getTextColor } from \"./utils/dom.js\";\r\nimport { setPosition } from \"./utils/position.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\n// Toast queue for calls before DOM ready\r\nconst pendingToasts = [];\r\n\r\n// Flag to indicate DOM ready for toast execution\r\nlet domReady = false;\r\n\r\n// DOM ready check\r\nasync function checkDOMReady() {\r\n if (domReady) return;\r\n\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n if (\r\n document.readyState === \"complete\" ||\r\n document.readyState === \"interactive\"\r\n ) {\r\n domReady = true;\r\n // Flush queued toasts after 2s delay\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n } else {\r\n // Wait for DOMContentLoaded\r\n document.addEventListener(\r\n \"DOMContentLoaded\",\r\n () => {\r\n domReady = true;\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n },\r\n { once: true }\r\n );\r\n }\r\n }\r\n}\r\n\r\n// Core toast creation logic\r\nasync function createToastNow(options = {}) {\r\n try {\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n await createFirstToastContainer(sanitizedOptions);\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n const safeMessage =\r\n typeof options?.message === \"string\" && options?.message !== null\r\n ? `${options?.message?.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\nlet initialDelayDone = false; // flag to ensure single execution\r\n\r\n// Public API\r\nasync function createToast(options = {}) {\r\n // Check browser environment\r\n const isBrowser =\r\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\r\n\r\n if (!isBrowser) {\r\n console.warn(\r\n \"ToastNotification: running in non-browser environment, no DOM available.\"\r\n );\r\n return;\r\n }\r\n\r\n // Check if DOM ready\r\n await checkDOMReady();\r\n\r\n if (!domReady) {\r\n // Queue for later execution\r\n pendingToasts.push(options);\r\n return;\r\n }\r\n\r\n // If DOM ready → execute after 2s delay\r\n if (!initialDelayDone) {\r\n // First call → wait 2 seconds\r\n initialDelayDone = true;\r\n setTimeout(await createToastNow(options), 2000);\r\n } else {\r\n // Subsequent calls → run immediately\r\n await createToastNow(options);\r\n }\r\n}\r\n\r\nasync function createFirstToastContainer(options) {\r\n try {\r\n // Single source of truth for containers; prevents same-id duplicates\r\n const toastContainer = await getOrCreateToastContainer(\r\n options,\r\n setPosition\r\n );\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n\r\n/**\r\n * Sanitizes and normalizes toast options.\r\n * Fills in defaults, validates input, and ensures colors & messages are set.\r\n * @param {Object} options - User-provided toast options\r\n * @returns {Promise<Object>} final sanitized toast options\r\n */\r\nasync function sanitizeToastOptions(options) {\r\n const contPosition = options?.position?.toLowerCase()?.trim();\r\n const contMaxWidth =\r\n contPosition?.includes(\"top-full-width\") ||\r\n contPosition?.includes(\"bottom-full-width\")\r\n ? \"100vw\"\r\n : \"400px\";\r\n\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n borderRadius: \"50px\",\r\n backgroundColor: undefined,\r\n textColor: undefined,\r\n showCloseButton: true,\r\n animationDuration: \"0.4s\",\r\n animationType: \"fade\",\r\n animationEasing: \"ease\",\r\n showProgressBar: true,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n fontPosition: \"relative\",\r\n fontPadding: undefined,\r\n fontBorderRadius: undefined,\r\n fontBackgroundColor: undefined,\r\n fontFamily:\r\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\r\n fontSize: \"14px\",\r\n fontWeight: \"400\",\r\n fontLineHeight: \"1.4\",\r\n fontDirection: \"auto\",\r\n wrapText: \"normal\",\r\n maxWidth: contMaxWidth,\r\n };\r\n\r\n // Merge defaults with user options\r\n const final = {\r\n ...defaults,\r\n ...(typeof options === \"object\" && !Array.isArray(options) ? options : {}),\r\n };\r\n\r\n // Ensure message property separately\r\n final.message = options?.message ?? final.message;\r\n\r\n try {\r\n // Background color fallback based on type or system preference\r\n if (!final.backgroundColor) {\r\n final.backgroundColor =\r\n defaultColors?.[final.type] ??\r\n (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n ? \"#f5f5f5\"\r\n : \"#111111\");\r\n }\r\n\r\n // Default message if not provided\r\n final.message =\r\n final.message || defaultMessages?.[final.type] || \"No Message Provided!\";\r\n\r\n // Ensure textColor is set\r\n if (!final.textColor && final.backgroundColor) {\r\n final.textColor = await getTextColor(final.backgroundColor);\r\n }\r\n\r\n // Ensure progressColor is set\r\n if (!final.progressColor && final.backgroundColor) {\r\n final.progressColor = await getTextColor(final.backgroundColor);\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Safety check for message type\r\n if (typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","setPosition","container","options","position","Error","style","top","bottom","left","right","transform","resetContainerStyles","positionFlags","pos","toLowerCase","trim","hasTop","includes","hasBottom","hasLeft","hasRight","hasCenter","hasFullWidth","parsePosition","flags","maxWidth","handleFullWidthPositions","handleCenterPositions","applyStandardPositioning","generateUniqueId","prefix","Date","now","Math","floor","random","getTextColor","toastBg","color","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","isNaN","l1","l2","max","min","contrast","error","applyRichStyling","toast","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","opacity","transition","animationEasing","zIndex","_animationDuration","messageSpan","document","createElement","fontPosition","flex","fontPadding","fontBorderRadius","fontBackgroundColor","fontFamily","fontSize","fontWeight","lineHeight","fontLineHeight","textColor","userSelect","wordBreak","direction","fontDirection","webkitLineClamp","webkitBoxOrient","whiteSpace","wrapText","textOverflow","lineClamp","boxOrient","textContent","message","setAttribute","appendChild","showCloseButton","closeButton","border","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","emergencyError","alert","alertError","safeSetTimeout","fn","delay","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","fallbackError","createElementWithId","containerRegistry","Map","containerLocks","getContainerId","String","replace","normalizePositionKey","getOrCreateToastContainer","has","get","p","cached","isConnected","getElementById","body","inset","flexDirection","all","querySelectorAll","i","remove","set","delete","active","pending","queue","visibleCount","hashString","str","h","charCodeAt","showToast","key","type","toString","join","makeKey","data","count","clearTimeout","timeout","closeToast","updateBadge","entry","rafId","current","push","drainQueue","createOne","initialCount","outer","inner","_key","err","Promise","resolve","done","finish","pointerEvents","hideError","removeElement","child","firstElementChild","onEnd","e","target","removeEventListener","addEventListener","item","shift","badge","className","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","contPosition","contMaxWidth","final","undefined","animationType","Array","isArray","window","matchMedia","matches","sanitizeToastOptions","createFirstToastContainer","safeMessage","initialDelayDone","createToast","readyState","forEach","once","checkDOMReady","setDefaultColors","colors","setDefaultMessages","messages","customizableToast"],"mappings":";;;;;;;;;;;;;;aASOA,eAAeC,EAAYC,EAAWC,GAC3C,IAAKD,IAAcC,EAAQC,SACzB,MAAM,IAAIC,MAAM,mCAgBpB,SAA8BH,GAC5BA,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAME,OAAS,OACzBN,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,OACxBR,EAAUI,MAAMK,UAAY,MAC9B,CAnBEC,CAAqBV,GACrB,MAAMW,EAyBR,SAAuBT,GACrB,MAAMU,EAAMV,EAASW,cAAcC,OACnC,MAAO,CACLC,OAAQH,EAAII,SAAS,OACrBC,UAAWL,EAAII,SAAS,WAAaJ,EAAII,SAAS,SAClDE,QAASN,EAAII,SAAS,QACtBG,SAAUP,EAAII,SAAS,SACvBI,UAAWR,EAAII,SAAS,UACxBK,aACET,EAAII,SAAS,mBACbJ,EAAII,SAAS,sBACbJ,EAAII,SAAS,aAEnB,CAtCwBM,CAAcrB,EAAQC,WA+C9C,SAAkCF,EAAWC,EAASsB,GACpD,IAAKA,EAAMF,aAAc,OAAO,EAIhC,GAFApB,EAAQuB,SAAW,QAEfD,EAAMR,OAIR,OAHAf,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,QACjB,EAGT,GAAIe,EAAMN,UAIR,OAHAjB,EAAUI,MAAME,OAAS,OACzBN,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAM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AavB,CA2GA,SAASgQ,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBf,MAAMC,QAAQc,KACzD7B,EAAgB,IAAKA,KAAkB6B,GAE3C,CAAE,MAAO1M,GAET,CACF,CAKA,SAAS2M,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BjB,MAAMC,QAAQgB,KAC7D3B,EAAkB,IAAKA,KAAoB2B,GAE/C,CAAE,MAAO5M,GAET,CACF,CAWA,IAEwB,oBAAX6L,SACTA,OAAOgB,kBAAoB,CACzBT,cACAK,mBACAE,sBAGN,CAAE,MAAO3M,GAET,oCApBA,WAEE8I,EADchH,SAASgE,cAAc,yCAEvC"}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.7.1
3
- * Build: 2025-09-13 10:09:28
4
- * Cache-Buster: 1757758168805
2
+ * Customizable Toast Notifications 3.8.0
3
+ * Build: 2025-09-14 10:34:50
4
+ * Cache-Buster: 1757846090138
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
@@ -12,7 +12,7 @@
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
13
  * out of the box — with zero dependencies.
14
14
  */
15
- async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function n(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body){const n=e.cloneNode(!0);return t.appendChild(n),!0}}catch(t){return!1}}}return!1}async function o(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,n,o;if(t.startsWith("#")){const r=t.substring(1);if(3===r.length)e=parseInt(r[0]+r[0],16),n=parseInt(r[1]+r[1],16),o=parseInt(r[2]+r[2],16);else{if(6!==r.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(r.substring(0,2),16),n=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const r=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!r)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(r[1]),n=parseInt(r[2]),o=parseInt(r[3])}else{const r={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!r)throw new Error(`Unsupported color format: ${t}`);e=r[0],n=r[1],o=r[2]}if(isNaN(e)||isNaN(n)||isNaN(o))throw new Error(`Invalid color value: ${t}`);const r=(.2126*e+.7152*n+.0722*o)/255,a=.05;return(Math.max(r,a)+.05)/Math.min(r,a)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function r(t,e,n){const o=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.style.position=e.fontPosition,r.style.display="inline-block",r.style.flex="1",r.style.padding=e.fontPadding,r.style.borderRadius=e.fontBorderRadius,r.style.background=e.fontBackgroundColor,r.style.fontFamily=e.fontFamily,r.style.fontSize=e.fontSize,r.style.fontWeight=e.fontWeight,r.style.lineHeight=e.fontLineHeight,r.style.color=e.textColor,r.style.userSelect="text",r.style.wordBreak="break-word",r.style.direction=e.fontDirection,r.style.webkitLineClamp="3",r.style.webkitBoxOrient="vertical",r.style.whiteSpace=e.wrapText?"normal":"nowrap",r.style.display="block",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.lineClamp="3",r.style.boxOrient="vertical",r.style.display="-webkit-box",r.textContent=e.message,r.setAttribute("aria-label","Toast Notification Center"),r.setAttribute("title",e.message),t.appendChild(r),e.showCloseButton&&await async function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&await async function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function a(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,n){let o;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return o=await async function(t,n){try{const o=document.createElement(t);return o.id=await e(n),o}catch(t){try{const t="div",n="fallback",o=document.createElement(t);return o.id=await e(n),o.setAttribute("data-original-tag",t),o}catch(t){}}}("div","toast"),await r(o,t,n),o}catch(e){return await a(t,n),o}}let s=[],l=[];async function c(e){try{const o=await async function(e){try{let o=document.getElementById(`toast-container-${e.position}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e.position}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(e),r=await i(e,d);if(!r)throw new Error("Toast element creation failed!");s.push(r),o.id.includes("toast-container-")&&o.appendChild(r);const a="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,c=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(r),a);return void l.push(c)}catch(t){const n=document.querySelector('[id^="toast-container-"]'),o=a(e,d);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(o):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
15
+ async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const o=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,o){if(!o.hasFullWidth)return!1;if(e.maxWidth="100vw",o.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(o.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,o)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,o)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,o)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function o(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,o,n;if(t.startsWith("#")){const i=t.substring(1);if(3===i.length)e=parseInt(i[0]+i[0],16),o=parseInt(i[1]+i[1],16),n=parseInt(i[2]+i[2],16);else{if(6!==i.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(i.substring(0,2),16),o=parseInt(i.substring(2,4),16),n=parseInt(i.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const i=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!i)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(i[1]),o=parseInt(i[2]),n=parseInt(i[3])}else{const i={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!i)throw new Error(`Unsupported color format: ${t}`);e=i[0],o=i[1],n=i[2]}if(isNaN(e)||isNaN(o)||isNaN(n))throw new Error(`Invalid color value: ${t}`);const i=(.2126*e+.7152*o+.0722*n)/255,r=.05;return(Math.max(i,r)+.05)/Math.min(i,r)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function n(t,e,o){const n=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=n;const i=document.createElement("span");i.style.position=e.fontPosition,i.style.display="inline-block",i.style.flex="1",i.style.padding=e.fontPadding,i.style.borderRadius=e.fontBorderRadius,i.style.background=e.fontBackgroundColor,i.style.fontFamily=e.fontFamily,i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.lineHeight=e.fontLineHeight,i.style.color=e.textColor,i.style.userSelect="text",i.style.wordBreak="break-word",i.style.direction=e.fontDirection,i.style.webkitLineClamp="3",i.style.webkitBoxOrient="vertical",i.style.whiteSpace=e.wrapText?"normal":"nowrap",i.style.display="block",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.lineClamp="3",i.style.boxOrient="vertical",i.style.display="-webkit-box",i.textContent=e.message,i.setAttribute("aria-label","Toast Notification Center"),i.setAttribute("title",e.message),t.appendChild(i),e.showCloseButton&&await async function(t,e,o){const n=document.createElement("button");n.setAttribute("aria-label","Close notification"),n.setAttribute("title","Close"),n.textContent="×",Object.assign(n.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),n.onclick=()=>o(t),t.appendChild(n),t._cleanupCloseButton=()=>{n.onclick=null}}(t,e,o),e.showProgressBar&&await async function(t,e){const o=document.createElement("div");Object.assign(o.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(o),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(o),o.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function i(t,e){try{const o=document.createElement("div");return o.id=`emergency-${Date.now()}`,o.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,o._animationDuration=500,o._isEmergencyToast=!0,setTimeout(()=>{try{o.parentNode&&o.parentNode.removeChild(o),e(o)}catch(t){}},t.duration||1800),o}catch(o){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function r(t,e){return setTimeout(()=>{t()},e)}async function a(t,o){let r;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return r=await async function(t,o){try{const n=document.createElement(t);return n.id=await e(o),n}catch(t){try{const t="div",o="fallback",n=document.createElement(t);return n.id=await e(o),n.setAttribute("data-original-tag",t),n}catch(t){}}}("div","toast"),await n(r,t,o),r}catch(e){return await i(t,o),r}}const s=new Map,l=new Map;function c(t="bottom-right"){return`toast-container-${function(t="bottom-right"){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"-").replace(/\-+/g,"-")}(t)}`}async function u(t={},e){const o=c(t.position);if(l.has(o))return l.get(o);const n=(async()=>{const n=s.get(o);if(n&&n.isConnected)return n;let i=document.getElementById(o);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=o,i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const r=document.querySelectorAll(`#${o}`);if(r.length>1)for(let t=1;t<r.length;t++)try{r[t].remove()}catch{}return s.set(o,i),i})();l.set(o,n);try{return await n}finally{l.delete(c(t.position))}}const d=new Map,p=new Map,f=[];let m=0;function y(t){let e=5381;for(let o=0;o<t.length;o++)e=(e<<5)+e+t.charCodeAt(o);return e>>>0}async function h(t={}){const e=function({type:t="info",message:e="",position:o="bottom-right"}){return[String(t).trim().toLowerCase(),y(String(e)).toString(16),String(o).trim().toLowerCase()].join("|")}(t);if(d.has(e)){const o=d.get(e);return o.count++,clearTimeout(o.timeout),o.timeout=await r(()=>w(o.toast),(t.duration||1800)+10),void x(o)}if(p.has(e))return void p.get(e).count++;const o={options:t,count:1,rafId:0};p.set(e,o),o.rafId=requestAnimationFrame(async()=>{const t=p.get(e);if(t){if(p.delete(e),m>=3)return f.push({options:t.options,key:e,count:t.count}),void b();await g(t.options,e,t.count)}})}async function g(e,o,n){try{m++;const i=await u(e,t),s=await a(e,w);if(!s)throw new Error("Toast element creation failed");const l=document.createElement("div");Object.assign(l.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const c=document.createElement("div");Object.assign(c.style,{position:"relative",overflow:"hidden",borderRadius:e.borderRadius||"8px",zIndex:"1"}),c.appendChild(s),l.appendChild(c),i.id.includes("toast-container-")&&i.appendChild(l);const p={outer:l,toast:s,count:Math.max(1,0|n),timeout:null};d.set(o,p),s._key=o,p.count>1&&x(p),p.timeout=await r(()=>w(s),(e.duration||1800)+10)}catch(t){m=Math.max(0,m-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(i(e,w))}}async function w(t){if(!t||!t._key)return;const e=d.get(t._key);var o;e&&(clearTimeout(e.timeout),d.delete(t._key),m=Math.max(0,m-1),e.outer.querySelector(".toast-count-badge")?.remove(),await(o=e.outer,new Promise(t=>{let e=!1;const n=()=>{e||(e=!0,async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}}(o),t())},i=o.firstElementChild||o,r=t=>{t.target===i&&(i.removeEventListener("transitionend",r,!0),n())};i.addEventListener("transitionend",r,!0),setTimeout(()=>{i.removeEventListener("transitionend",r,!0),n()},700)})),b())}function b(){for(;m<3&&f.length;){const t=f.shift();if(d.has(t.key)){const e=d.get(t.key);e.count+=t.count,x(e);continue}g(t.options,t.key,t.count)}}function x({outer:t,count:e}){if(e<2)return void t.querySelector(".toast-count-badge")?.remove();let o=t.querySelector(".toast-count-badge");o||(o=document.createElement("span"),o.className="toast-count-badge",o.setAttribute("aria-label",`${e} identical notifications`),Object.assign(o.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),t.appendChild(o)),o.textContent=e>99?"99+":String(e),o.style.transform="scale(1.2)",setTimeout(()=>o.style.transform="scale(1)",150)}
16
16
  // * @license Apache-2.0
17
- let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const f=[];let y=!1;async function m(e={}){try{const r=await async function(t){const e=t?.position?.toLowerCase()?.trim(),n=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",r={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:n,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=t?.message??r.message;try{r.backgroundColor||(r.backgroundColor=u?.[r.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),r.message=r.message||p?.[r.type]||"No Message Provided!",!r.textColor&&r.backgroundColor&&(r.textColor=await o(r.backgroundColor)),!r.progressColor&&r.backgroundColor&&(r.progressColor=await o(r.backgroundColor))}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(e);await async function(e){try{let o=document.getElementById(`toast-container-${e.position}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e.position}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(r),await c(r)}catch(t){const n="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}let h=!1;async function g(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){y||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0):document.addEventListener("DOMContentLoaded",()=>{y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0},{once:!0}))}(),y?h?await m(t):(h=!0,setTimeout(await m(t),2e3)):f.push(t))}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}function x(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))}try{"undefined"!=typeof window&&(window.customizableToast={createToast:g,setDefaultColors:w,setDefaultMessages:b})}catch(t){}export{g as createToast,x as noop,w as setDefaultColors,b as setDefaultMessages};
17
+ let C={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},v={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const k=[];let E=!1;async function S(e={}){try{const n=await async function(t){const e=t?.position?.toLowerCase()?.trim(),n=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",i={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:n,..."object"!=typeof t||Array.isArray(t)?{}:t};i.message=t?.message??i.message;try{i.backgroundColor||(i.backgroundColor=C?.[i.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),i.message=i.message||v?.[i.type]||"No Message Provided!",!i.textColor&&i.backgroundColor&&(i.textColor=await o(i.backgroundColor)),!i.progressColor&&i.backgroundColor&&(i.progressColor=await o(i.backgroundColor))}catch(t){}"string"!=typeof i.message&&(i.message="No Message Provided!");return i}(e);await async function(e){try{return await u(e,t)}catch(t){return document.body}}(n),await h(n)}catch(t){const o="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(o)}}let T=!1;async function I(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){E||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(E=!0,k.forEach(t=>setTimeout(()=>S(t),2e3)),k.length=0):document.addEventListener("DOMContentLoaded",()=>{E=!0,k.forEach(t=>setTimeout(()=>S(t),2e3)),k.length=0},{once:!0}))}(),E?T?await S(t):(T=!0,setTimeout(await S(t),2e3)):k.push(t))}function B(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(C={...C,...t})}catch(t){}}function L(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(v={...v,...t})}catch(t){}}function A(){w(document.querySelector('[id^="toast-"]:not([id*="container"])'))}try{"undefined"!=typeof window&&(window.customizableToast={createToast:I,setDefaultColors:B,setDefaultMessages:L})}catch(t){}export{I as createToast,A as noop,B as setDefaultColors,L as setDefaultMessages};
18
18
  //# sourceMappingURL=index.esm.mjs.map