@enjoys/pinglet 1.1.5 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pinglet-sse.js +1 -1
- package/pinglet-sse.min.js +555 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enjoys/pinglet",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Lightweight Customizable Web & CustomPush Notification SDK for modern web apps. Supports customizable layouts, secure delivery, and real-time updates via SSE.",
|
|
5
5
|
"main": "./pinglet-sse.js",
|
|
6
6
|
"types": "./pinglet-sse.d.ts",
|
package/pinglet-sse.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e){switch(t.action){case"redirect":case"open":return window.open(t.src,"_blank");case"link":return window.open(t.src);case"alert":return alert(t.src);case"reload":return window.location.reload();case"event":return window.addEventListener(t.src,(()=>{}));case"close":case"dismiss":return window.dispatchEvent(new CustomEvent("pinglet:notificationClosed",{detail:{contentEl:e,reason:"user-dismiss"}}))}return window.open("https://pinglet.enjoys.in/docs","_blank")}function e(e,n,i=[{text:"See Docs",onClick:()=>window.open("https://pinglet.enjoys.in/docs","_blank")}],o="⚠️",s={duration:5e3,auto_dismiss:!0}){const a="toastContainer";let l=document.getElementById(a);l||(l=document.createElement("div"),l.id=a,Object.assign(l.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"9999",display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end",fontFamily:"Manrope, sans-serif"}),document.body.appendChild(l));const r=document.createElement("div");Object.assign(r.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",fontFamily:"'Inter', sans-serif",minWidth:"260px",maxWidth:"340px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"10px",fontFamily:"Manrope, sans-serif"});const c=document.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600",fontFamily:"Manrope, sans-serif"});const d=document.createElement("div");d.textContent=o;const p=document.createElement("div");if(p.textContent=e,c.appendChild(d),c.appendChild(p),r.appendChild(c),n){const t=document.createElement("div");t.textContent=n,Object.assign(t.style,{fontSize:"13.5px",fontWeight:"400",color:"#ddd",lineHeight:"1.5"}),r.appendChild(t)}if(Array.isArray(i)&&i.length){const e=document.createElement("div");Object.assign(e.style,{marginTop:"8px",display:"flex",gap:"10px",justifyContent:"flex-start"});for(const n of i){const i=document.createElement("button");if(i.textContent=n.text||"Click Here",Object.assign(i.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s",fontFamily:"Manrope, sans-serif"}),i.onmouseover=()=>i.style.background="#444",i.onmouseout=()=>i.style.background="#333",n?.onClick){const t=new Function(`return ${n.onClick}`)();"function"==typeof t&&i.addEventListener("click",t)}else i.addEventListener("click",(e=>(e.stopPropagation(),t(n,i))));e.appendChild(i)}r.appendChild(e)}const m=document.createElement("div");return m.innerHTML='Notifications by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys',Object.assign(m.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"Manrope, sans-serif"}),l.appendChild(r),l.appendChild(m),requestAnimationFrame((()=>{r.style.opacity="1",r.style.transform="translateX(0)"})),s.auto_dismiss||setTimeout((()=>{r.style.opacity="0",r.style.transform="translateX(100%)",setTimeout((()=>{r.remove(),m.remove()}),500)}),s.duration||5e3),l}const n={duration:3e3,btn1:{color:"#ffffff",backgroundColor:"#007bff",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"none",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},btn2:{color:"#333333",backgroundColor:"#f0f0f0",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"1px solid #ccc"},title:{color:"#111111",fontSize:"14px",fontWeight:"500",lineHeight:"1.4",margin:"0 0 0 0",textAlign:"left"},description:{color:"#444444",fontSize:"13px",fontWeight:"400",lineHeight:"1.5",margin:"0 0 10px 0",textAlign:"left"},controls:{video:{autoplay:!1,muted:!1,loop:!1,controls:!1},audio:{autoplay:!1,muted:!1,loop:!1,controls:!1}},media:{image:{width:"100%",height:"200px",borderRadius:"6px",objectFit:"cover",margin:"0 0 8px 0"},icon:{width:"24px",height:"24px",margin:"0 8px 0 0",objectFit:"contain"},logo:{width:"50px",height:"50px",margin:"0 8px 0 0",objectFit:"contain"},video:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},iframe:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},audio:{width:"100%",margin:"8px 0"}}},i={position:"bottom-left",transition:"fade",branding:{show:!0,once:!0,html:'Notifications by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'},sound:{play:!1,src:"https://pinglet.enjoys.in/api/v1/pinglet-sound.mp3?v=1&ext=mp3",volume:.6},duration:2e3,maxVisible:3,stacking:!0,auto_dismiss:!0,dismissible:!0,website:"https://pinglet.enjoys.in",time:!0,favicon:!0,pauseOnHover:!0,theme:{mode:"light",customClass:"",rounded:!0,shadow:!0,border:!1},iconDefaults:{show:!0,size:20,position:"left"},progressBar:{show:!0,color:"#4da6ff",height:3}};let o,s,a=null,l=null,r=null;function c(){o&&(o.currentTime=0,o.play())}function d(t){return l||(l=document.createElement("div"),l.className="pinglet-branding",l.innerHTML=t?.html||'Notifications by <a href="https://pinglet.enjoys.in" class="pinglet-link" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a>',l.style="\n font-size: 11px;\n color: #808080;\n text-align: right;\n width: 100%;\n pointer-events: auto;\n ",l)}function p(t){if(s&&a)return{toastContainer:s,toastStack:a};const e=document.getElementById("pinglet-widget-container");return e?(s=e,a=s.querySelector(".pinglet-widget-stack"),{toastContainer:s,toastStack:a}):(s=document.createElement("div"),s.id="pinglet-widget-container",s.style.position="fixed",s.style.bottom="20px",s.style.left="20px",s.style.zIndex="9999",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="flex-start",s.style.gap="8px",s.style.maxWidth="360px",s.style.width="360px",s.style.boxSizing="border-box",s.style.pointerEvents="none",s.style.padding="4px",s.style.borderRadius="8px",a=document.createElement("div"),a.className="pinglet-widget-stack",a.style.display="flex",a.style.flexDirection="column",a.style.gap="12px",a.style.pointerEvents="none",a.style.overflow="visible",a.style.flexShrink="0",s.appendChild(a),t?.show&&t?.once&&s.appendChild(d(t)),document.body.appendChild(s),{toastContainer:s,toastStack:a})}function m(t,e){const n=e.config,{toastContainer:i,toastStack:o}=p(n.branding);var s,a;let r;function c(){n?.auto_dismiss&&(r=setTimeout((()=>{o.contains(t)&&(g("dropped",t,"user doesn't engaged"),f(t,n?.transition||"fade"))}),n.duration||5e3))}return n?.branding?.show&&n?.branding?.once&&i.appendChild(l),s=t,a=n.transition,s.style.opacity="0",s.style.transition="all 0.4s ease","fade"===a?(s.style.transform="translateX(20px)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="translateX(0)"}))):"slide"===a?(s.style.transform="translateX(100%)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="translateX(0)"}))):"zoom"===a?(s.style.transform="scale(0.8)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="scale(1)"}))):s.style.opacity="1",t.style.pointerEvents="auto",o.appendChild(t),i.addEventListener("mouseenter",(function(){clearTimeout(r)})),i.addEventListener("mouseleave",c),c(),{toastContainer:i,toastStack:o}}function f(t,e){t&&(t.style.transition="all 0.4s ease","fade"===e?(t.style.opacity="0",t.style.transform="translateX(-40px)"):"slide"===e?(t.style.transform="translateX(-100%)",t.style.opacity="0"):"zoom"===e?(t.style.transform="scale(0.8)",t.style.opacity="0"):t.style.opacity="0",t.addEventListener("transitionend",(()=>{t.remove(),a&&0===a.children.length&&l?.remove()}),{once:!0}))}async function g(t,e,n="user-dismiss"){const i=e.getAttribute("data-notification-id"),o=e.getAttribute("data-notification-type")||"0",[s,a]=i.split("-");window.sendNotificationEvent(t,{project_id:s,notification_id:i,timestamp:a,reason:n,type:o})}function u(t=i,e=window.location.hostname,n="just now",o=!1){const s=document.createElement("div");s.className="pinglet-row",Object.assign(s.style,{display:"flex",justifyContent:"space-between",alignItems:"center",background:o?"#1a1a1a":"transparent",fontFamily:"system-ui, sans-serif",fontSize:"10px",padding:"6px 10px",borderBottom:o?"1px solid rgba(255, 255, 255, 0.1)":"1px solid rgba(0, 0, 0, 0.05)",color:o?"#f0f0f0":"#000"});const r=document.createElement("div");r.className="pinglet-left",Object.assign(r.style,{display:"flex",alignItems:"center",gap:"6px",flexGrow:"1"});const c=document.createElement("span");c.className="pinglet-icon",c.textContent="- Pinglet",c.onclick=()=>{window.open("https://pinglet.enjoys.in","_blank")},Object.assign(c.style,{alignItems:"center",color:"dodgerblue",flexShrink:"0",fontWeight:"bold",cursor:"pointer"});const d=document.createElement("span");d.className="pinglet-domain",d.textContent=e,d.style.color=o?"#bbb":"#808080";const p=document.createElement("span");p.className="pinglet-time",p.textContent=`- ${n}`,p.style.color=o?"#ccc":"#aaa";const m=document.createElement("button");return m.className="pinglet-close",m.textContent="✕",Object.assign(m.style,{background:"none",border:"none",fontSize:"12px",cursor:"pointer",color:o?"#aaa":"#888",padding:"0 4px"}),m.addEventListener("mouseenter",(()=>{m.style.color="#f44"})),m.addEventListener("mouseleave",(()=>{m.style.color=o?"#aaa":"#888"})),t?.website&&r.appendChild(d),t?.time&&r.appendChild(p),t?.favicon&&r.appendChild(c),s.appendChild(r),t?.dismissible&&s.appendChild(m),m.addEventListener("click",(t=>{t.stopPropagation(),function(t="pinglet:notificationClosed",e){window.dispatchEvent(new CustomEvent(t,{detail:e}))}("pinglet:notificationClosed",{contentEl:m.parentElement?.parentElement,reason:"user-dismiss"}),a&&0===a.children.length&&l?.remove()})),s}function y(e,i){const o=i.style,s=i.config,a=(s.theme.mode||{})&&window.matchMedia("(prefers-color-scheme: dark)").matches,r=document.createElement("div");r.id="pinglet-variant",r.setAttribute("data-key",`${Date.now()}-${Math.random().toString(36).slice(2,8)}`),r.className=`pinglet-variant pinglet-${e.variant||"default"}`,Object.assign(r.style,{display:"flex",flexDirection:"column",alignItems:"stretch",width:"320px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",overflowY:"auto",padding:"4px",gap:"4px",pointerEvents:"none",overflow:"visible",flexShrink:"0",boxShadow:a?"0 2px 8px rgba(0,0,0,0.6)":"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:a?"#1e1e1e":"whitesmoke",color:a?"#f0f0f0":"#000"}),r.appendChild(u(s,window.location.hostname,"just now",a));let d=null;const p="icon"in e||"logo"in e;if(e.media?.type&&(d=function(t,e,i){switch(t.type){case"image":{const i=document.createElement("img");return i.src=t.src,Object.assign(i.style,e?.image||n.media.image),i}case"video":{const o=document.createElement("video");return o.src=t.src,o.autoplay=i?.video?.autoplay||n.controls.video.autoplay||!1,o.muted=i?.video?.muted||n.controls.video.muted||!1,o.loop=i?.video?.loop||n.controls.video.loop||!1,o.controls=i?.video?.controls||n.controls.video.controls||!1,o.style=e?.video||n.media.video,Object.assign(o.style,e?.video||n.media.video),o}case"audio":return function(t,e,n,i){const o=document.createElement("div");Object.assign(o.style,{maxWidth:"auto",padding:"16px",borderRadius:"20px 20px 6px 20px",background:"#fff",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",position:"relative",fontFamily:"Segoe UI, sans-serif"});const s=document.createElement("div");Object.assign(s.style,{position:"absolute",bottom:"6px",right:"-6px",width:"0",height:"0",borderLeft:"8px solid #ffffff",borderBottom:"8px solid transparent"}),o.appendChild(s);const a=document.createElement("audio");a.src=t,a.autoplay=!0,a.muted=e,a.loop=n,a.controls=i,o.appendChild(a);const l=document.createElement("div");Object.assign(l.style,{display:"flex",alignItems:"center",gap:"14px"});const r=document.createElement("button");r.textContent="▶",Object.assign(r.style,{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"50%",color:"white",width:"44px",height:"44px",fontSize:"18px",cursor:"pointer",flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(102, 126, 234, 0.4)",transition:"transform 0.3s ease"}),l.appendChild(r);const c=document.createElement("div");Object.assign(c.style,{flex:"1",display:"flex",flexDirection:"column",gap:"8px"});const d=document.createElement("div");Object.assign(d.style,{display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 4px"});const p=[];for(let t=0;t<20;t++){const e=document.createElement("div");Object.assign(e.style,{width:"4px",background:"linear-gradient(to top, #667eea, #764ba2)",borderRadius:"2px",transition:"all 0.3s ease",height:8+t%5*4+"px",animation:"wave 1.5s infinite ease-in-out",animationDelay:t%5*.15+"s",animationPlayState:"paused"}),p.push(e),d.appendChild(e)}c.appendChild(d);const m=document.createElement("div");Object.assign(m.style,{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"13px",color:"#666"});const f=document.createElement("div");f.textContent="Voice message",f.style.fontSize="12px",f.style.color="#888";const g=document.createElement("div");g.textContent="0:00",Object.assign(g.style,{fontWeight:"500",color:"#667eea"}),m.appendChild(f),m.appendChild(g),c.appendChild(m),l.appendChild(c),o.appendChild(l);const u=document.createElement("style");function y(t){return`${Math.floor(t/60)}:${Math.floor(t%60).toString().padStart(2,"0")}`}return u.textContent="\n @keyframes wave {\n 0%, 100% { opacity: 0.3; transform: scaleY(0.5); }\n 50% { opacity: 1; transform: scaleY(1); }\n }\n ",document.head.appendChild(u),a.addEventListener("loadedmetadata",(()=>{g.textContent=y(a.duration)})),a.addEventListener("timeupdate",(()=>{g.textContent=y(a.currentTime)})),r.addEventListener("click",(()=>{a.paused?(a.play(),r.textContent="⏸",p.forEach((t=>t.style.animationPlayState="running"))):(a.pause(),r.textContent="▶",p.forEach((t=>t.style.animationPlayState="paused")))})),a.addEventListener("ended",(()=>{r.textContent="▶",p.forEach((t=>t.style.animationPlayState="paused")),a.currentTime=0})),o}(t.src,i?.audio?.muted||n.controls?.audio.muted||!1,i?.audio?.loop||n.controls?.audio?.loop||!1,i?.audio?.controls||n.controls?.audio?.controls||!1);default:return null}}(e.media,o.media,o.controls),d.style.marginBottom="12px"),d&&r.appendChild(d),p){const t=document.createElement("div");Object.assign(t.style,{display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"6px"});const s=document.createElement("div");Object.assign(s.style,{flex:"0 0 auto"});const l=function(t,e,i){if("logo"===t){const t=document.createElement("img");return t.src=e,Object.assign(t.style,i?.logo||n.media.logo),t}if("icon"===t){const t=document.createElement("span");if("string"==typeof e){const n=/^data:image\/(png|jpeg|gif|webp);base64,/.test(e),i=/^<svg[\s\S]*<\/svg>$/.test(e.trim());n?(t.style.backgroundImage=`url('${e}')`,t.style.backgroundSize="cover",t.textContent=""):i?t.innerHTML=e:t.textContent=e}return t.className="pinglet-icon",Object.assign(t.style,{width:"40px",height:"40px",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundPosition:"center",borderRadius:"8px",fontSize:"24px",overflow:"hidden"}),t}return null}("icon"in e?"icon":"logo",e?.icon||e?.logo,i.style.media);l&&s.appendChild(l),t.appendChild(s);const c=document.createElement("div");if(Object.assign(c.style,{display:"flex",flexDirection:"column",flex:"1"}),e.title){const t=document.createElement("div");t.className="pinglet-title",t.innerText=e.title,Object.assign(t.style,{...o.title||n.title,color:a?"#ffffff":"#000000"}),c.appendChild(t)}if(e.description){const t=document.createElement("p");t.className="pinglet-desc",t.innerText=e.description,Object.assign(t.style,{...o.description||n.description,color:a?"#dddddd":"#333333"}),c.appendChild(t)}t.appendChild(c),r.appendChild(t)}else{if(e.title){const t=document.createElement("div");t.className="pinglet-title",t.innerText=e.title,Object.assign(t.style,{...o.title||n.title,color:a?"#ffffff":"#000000"}),r.appendChild(t)}if(e.description){const t=document.createElement("p");t.className="pinglet-desc",t.innerText=e.description,Object.assign(t.style,{...o.description||n.description,color:a?"#dddddd":"#333333"}),r.appendChild(t)}}if(e.buttons){const n=document.createElement("div");n.className="pinglet-buttons",n.style.fontFamily="Manrope",e.buttons.forEach(((e,i)=>{const s=document.createElement("button");if(s.innerText=e.text,s.className="pinglet-btn",Object.assign(s.style,{cursor:"pointer",padding:"6px 10px",fontFamily:"Manrope, sans-serif",margin:"1px 4px",color:a?"#f0f0f0":"#000",backgroundColor:a?"#333":"#f0f0f0",border:"none",borderRadius:"4px"}),Object.assign(s.style,0===i?o.btn1:o.btn2),e?.onClick){const t=new Function(`return ${e.onClick}`)();"function"==typeof t&&s.addEventListener("click",t)}else s.addEventListener("click",(n=>(n.stopPropagation(),t(e,r))));n.appendChild(s)})),r.appendChild(n)}return s.sound?.play&&c(),!l||r.contains(l)||s.branding?.once||r.appendChild(l),r}function x(t){const e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=window.atob(e);return Uint8Array.from([...n].map((t=>t.charCodeAt(0))))}function h(t,n,i){"Notification"in window?"granted"===Notification.permission||function(t={}){const{title:e="Stay updated with notifications",description:n="Get notified about important updates, new features, and exclusive content. We'll only send you valuable notifications.",site:i=window.location.hostname,onAllow:o=()=>{},onDeny:s=()=>{}}=t,a=document.createElement("div");a.className="notification-dialog",Object.assign(a.style,{position:"fixed",bottom:"24px",right:"24px",width:"380px",background:"#fff",borderRadius:"16px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255,255,255,0.1)",zIndex:"1000",overflow:"hidden",transform:"translateX(420px)",animation:"slideIn 0.6s ease-out 1s forwards",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const l=document.createElement("style");l.textContent="\n @keyframes slideIn { to { transform: translateX(0); } }\n @keyframes pulse {\n 0%, 100% { box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); }\n 50% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5); }\n }\n @media (max-width: 480px) {\n .notification-dialog {\n width: calc(100vw - 32px) !important;\n right: 16px !important;\n bottom: 16px !important;\n transform: translateY(420px) !important;\n }\n @keyframes slideIn { to { transform: translateY(0); } }\n }\n ",document.head.appendChild(l);const r=document.createElement("div");r.style.display="flex",r.style.justifyContent="space-between",r.style.padding="20px 20px 0 20px";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.gap="8px",c.style.color="#6b7280",c.style.fontSize="14px",c.style.fontWeight="500";const d=document.createElement("div");d.style.width="16px",d.style.height="16px",d.style.borderRadius="4px",d.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.innerHTML='<svg viewBox="0 0 16 16" fill="white" width="10" height="10"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8z"/></svg>';const p=document.createElement("span");p.textContent=i,c.append(d,p);const m=document.createElement("button");m.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12">\n <path d="M12.854 4.854a.5.5 0 0 0-.708-.708L8 8.293 3.854 4.146a.5.5 0 1 0-.708.708L7.293 9l-4.147 4.146a.5.5 0 0 0 .708.708L8 9.707l4.146 4.147a.5.5 0 0 0 .708-.708L8.707 9l4.147-4.146z"/>\n </svg>',Object.assign(m.style,{width:"24px",height:"24px",background:"#f3f4f6",border:"none",borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"}),m.onclick=()=>a.remove(),r.append(c,m);const f=document.createElement("div");f.style.padding="16px 24px 24px 24px";const g=document.createElement("div");g.style.width="48px",g.style.height="48px",g.style.borderRadius="12px",g.style.marginBottom="16px",g.style.animation="pulse 2s infinite",g.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",g.style.display="flex",g.style.alignItems="center",g.style.justifyContent="center",g.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" width="24" height="24">\n <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>\n </svg>';const u=document.createElement("h3");u.textContent=e,Object.assign(u.style,{fontSize:"18px",fontWeight:"600",color:"#111827",marginBottom:"8px"});const y=document.createElement("p");y.textContent=n,Object.assign(y.style,{fontSize:"14px",color:"#6b7280",lineHeight:"1.5",marginBottom:"20px"});const x=document.createElement("div");x.style.display="flex",x.style.gap="8px";const h=document.createElement("button");h.textContent="Not now",Object.assign(h.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"1px solid #e5e7eb",background:"#f9fafb",color:"#6b7280",cursor:"pointer"}),h.onclick=()=>{s(),a.remove()};const b=document.createElement("button");b.textContent="Allow notifications",Object.assign(b.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"none",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",cursor:"pointer"}),b.onclick=()=>{o(),a.remove()},x.append(h,b);const w=document.createElement("div");w.style.marginTop="12px",w.style.display="flex",w.style.alignItems="center",w.style.justifyContent="center",w.style.gap="6px",w.style.color="#9ca3af",w.style.fontSize="12px",w.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12"><path d="M8 0c-.69 0-1.843.265-2.928.56-1.11.3-2.229.655-2.887.87a1.54 1.54 0 0 0-1.044 1.262c-.596 4.477.787 7.795 2.465 9.99a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.775 11.775 0 0 0 2.517-2.453c1.678-2.195 3.061-5.513 2.465-9.99a1.541 1.541 0 0 0-1.044-1.263 62.467 62.467 0 0 0-2.887-.87C9.843.266 8.69 0 8 0z"/></svg><span>Secure & private • Unsubscribe anytime</span>',f.append(g,u,y,x,w),a.append(r,f),document.body.appendChild(a)}({site:window.location.hostname,onAllow:()=>{Notification.requestPermission().then((async o=>"granted"===o?async function(t,n,i){try{const o=await navigator.serviceWorker.register(t+"/sw.js");if(await o.pushManager.getSubscription())return;const s=await o.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:x(i)}),a=await fetch(`${t}/subscribe?projectId=${n}`,{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"},credentials:"omit"}),l=await a.json();if(l.success)return localStorage.getItem("subscription")?void 0:(localStorage.setItem("subscription","true"),e("Notifications Enabled","You can now receive notifications from this site.",[{text:"See Demo",onClick:'()=>{\n new Notification("Pinglet", {\n body: "This is a demo notification",\n icon: "https://pinglet.enjoys.in/favicon.ico"\n }).onclick = () => {\n window.open("https://pinglet.enjoys.in", "_blank");\n }) \n }'}],"🎉"));e("Something Went Wrong",l.message,[],"❌")}catch(t){}}(t,n,i):e("Permission Denied","You blocked notifications!",[],"😭"))).catch((t=>e("Permission Error","Error requesting notification permission:",[],"😭")))},onDeny:()=>e("Permission Denied","You blocked notifications!",[],"❌")}):e("Unsupported Browser","Notifications not supported.",[],"🚫")}window.addEventListener("pinglet:notificationClosed",(t=>{g("closed",t.detail.contentEl,t.detail.reason),f(t.detail.contentEl,"fade")}));let b=!1;async function w(t,e){(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).forEach((n=>{n.postMessage({type:"CUSTOM_NOTIFICATION_EVENT",eventName:t,payload:e})}))}async function v(t,e){"project_id"in e&&await fetch("https://pinglet.enjoys.in/api/v1/log/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,event:t})})}function E(t,e){const n=new CustomEvent(`notification:${t}`,{detail:e});document.dispatchEvent(n)}function C(t,e){document.addEventListener(`notification:${t}`,(t=>{e(t.detail)}))}async function k(t,e){"project_id"in e&&await fetch("https://pinglet.enjoys.in/api/v1/log/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,event:t}),credentials:"omit"})}self.addEventListener("install",(t=>{self.skipWaiting()})),self.addEventListener("activate",(t=>{clients.claim()})),self.addEventListener("push",(async t=>{if(console.log("[Service Worker] Push Received."),!t.data)return;const e=t.data?.json?.()||{},n={body:e?.body,icon:e?.icon,badge:e?.badge,tag:e?.tag,requireInteraction:e?.requireInteraction||!0,silent:e?.silent||!1,data:e?.data,actions:e?.actions,image:e?.image,timestamp:Date.now(),vibrate:[200,100,200]};e.data&&e.data.duration&&setTimeout((()=>{self.registration.getNotifications({tag:e.tag}).then((async t=>{const n=await self.clients.matchAll({type:"window",includeUncontrolled:!0});t.forEach((t=>{n.length>0?w("dropped",{...e?.data,notificationTag:t.tag,timestamp:Date.now()}):v("dropped",{...e?.data,notificationTag:t.tag,timestamp:Date.now()}),t.close()}))}))}),e.data?.duration||5e3);const i=await self.clients.matchAll({type:"window",includeUncontrolled:!0});b=i.length>0,t.waitUntil(self.registration.showNotification(e.title,n))})),self.addEventListener("notificationclick",(t=>{t.notification.close();const e=t.notification.data||{},n=t.action;if(n&&e.actionEvents&&e.actionEvents[n]){const i=e.actionEvents[n];async function o(t,e,n){const{eventName:i,eventData:o,url:s,windowAction:a}=t;try{if(b?n.waitUntil(w(i,{...o,notificationTag:n.notification.tag,timestamp:Date.now()})):n.waitUntil(v("clicked",{...e,notificationTag:n.notification.tag,timestamp:Date.now()})),"open"===a&&s)await clients.openWindow(s);else if("focus"===a){const t=await clients.matchAll({type:"window"});t.length>0?await t[0].focus():s&&await clients.openWindow(s)}}catch(t){}}t.waitUntil(o(i,e,t))}else{if("dismiss"===t.action)return b?t.waitUntil(w("closed",{...e,notificationTag:t.notification.tag,timestamp:Date.now()})):t.waitUntil(v("closed",{...eventData,notificationTag:t.notification.tag,timestamp:Date.now()})),t.notification.close();if("url"in e){const s=e.url;t.waitUntil(clients.openWindow(s))}b?t.waitUntil(w("clicked",{...e,notificationTag:t.notification.tag,timestamp:Date.now()})):t.waitUntil(v("clicked",{...eventData,notificationTag:t.notification.tag,timestamp:Date.now()}))}})),self.addEventListener("notificationclose",(t=>{console.log("Notification closed:",t.notification.tag)})),window.notificationEventHandlers={},"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",(t=>{const{type:e,eventName:n,payload:i}=t.data;"CUSTOM_NOTIFICATION_EVENT"===e&&E(n,i)})),window.sendNotificationEvent=E,C("clicked",(t=>k("clicked",t))),C("dropped",(t=>k("dropped",t))),C("closed",(t=>k("closed",t)));const j={autoCloseDelay:1e4,brandingText:"Powered by Enjoys",brandingPosition:"right",defaultClass:"pinglet-wigdet-wrapper",spacing:2,maxVisible:3,side:"right"},S=document.createElement("style");function I(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.position="fixed",n.style.zIndex="9999",n.style.display="flex",n.style.flexDirection="column-reverse",n.style.gap=j.spacing+"px",n.style.pointerEvents="none",n.style.bottom="20px",n.classList.add(j.defaultClass),"left"===e?n.style.left="20px":n.style.right="20px",document.body.appendChild(n)),n}S.innerHTML="\n@keyframes slideIn {\n from { opacity: 0; transform: translateY(40px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes slideOut {\n from { opacity: 1; transform: translateY(0); }\n to { opacity: 0; transform: translateY(40px); }\n}",document.head.appendChild(S);const O=I("container-right","right"),T=I("container-left","left"),L={left:[],right:[]},N={left:[],right:[]};function z(t=[],e={}){const n={...j,...e},i=document.createElement("div");i.style.position="relative",i.style.width="300px",i.style.borderRadius="10px",i.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)",i.style.backgroundColor="#fff",i.style.transition="transform 0.3s ease, opacity 0.3s ease",i.style.animation="slideIn 0.4s forwards",i.style.pointerEvents="all",i.id="pinglet-custom-wrapper",t.forEach((t=>i.appendChild(t)));const o=document.createElement("button");o.innerText="×",Object.assign(o.style,{position:"absolute",top:"-10px",right:"-10px",width:"25px",height:"25px",borderRadius:"50%",border:"none",backgroundColor:"#f00",color:"#fff",fontSize:"16px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 4px rgba(0,0,0,0.2)"}),o.addEventListener("click",(async t=>{t.stopPropagation(),r(),g("closed",i),P(i,n.side)})),i.appendChild(o);const s=document.createElement("div");let a;function l(){a=setTimeout((()=>{(T.contains(i)||O.contains(i))&&g("dropped",i,"user doesn't interact"),P(i,n.side)}),n.autoCloseDelay)}function r(){clearTimeout(a)}return s.innerText=n.brandingText,Object.assign(s.style,{position:"absolute",bottom:"5px",fontSize:"12px",color:"#666"}),s.style[n.brandingPosition]="10px",i.appendChild(s),i.addEventListener("mouseenter",r),i.addEventListener("mouseleave",l),l(),L[n.side].push(i),D(n.side),i}function D(t){const e="left"===t?T:O;for(;N[t].length<j.maxVisible&&L[t].length>0;){const n=L[t].shift();e.appendChild(n),N[t].push(n)}}function P(t,e){t.style.animation="slideOut 0.4s forwards",t.addEventListener("animationend",(()=>{t.remove();const n=N[e].indexOf(t);-1!==n&&N[e].splice(n,1),D(e)}))}const M=Array.from(document.scripts).find((t=>t.src.includes("pinglet-sse")&&t.dataset.endpoint))||document.currentScript,_=M?.dataset.endpoint,W=M?.dataset.configuredDomain,A=M?.dataset.projectId,R=M?.dataset.pingletId,F=M?.dataset.checksum,$=M?.dataset.testimonials,X=M?.dataset.templates;(async t=>{if(t.projectId=A,t.PingletWidget)return void console.warn("PingletNotification is already initialized.");!function(){const t=document.createElement("link");t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap",document.head.appendChild(t);const e=document.createElement("style");e.innerHTML='\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Manrope\', sans-serif !important;\n font-weight: 400 !important;\n }\n ',document.head.appendChild(e)}(),h(_,A,R),$&&function(){const t=document.getElementById("pinglet-testimonials");if(t)return t;const n=document.createElement("div");n.className="pinglet-floating-btn",n.style.position="fixed",n.style.bottom="30px",n.style.right="30px",n.style.display="flex",n.style.alignItems="center",n.style.background="#667EEA",n.style.borderRadius="50px",n.style.padding="0",n.style.cursor="pointer",n.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",n.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",n.style.overflow="hidden",n.style.width="24px",n.style.height="24px",n.style.zIndex="1000",n.style.backdropFilter="blur(10px)",n.style.border="1px solid rgba(255, 255, 255, 0.1)";const i=document.createElement("div");i.textContent="❔",i.className="icon",i.style.fontSize="20px",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",i.style.width="24px",i.style.height="24px",i.style.flexShrink="0",i.style.color="white";const o=document.createElement("span");o.textContent="View",o.className="label",o.style.color="white",o.style.fontWeight="500",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px",o.style.opacity="0",o.style.transform="translateX(-8px)",o.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",o.style.whiteSpace="nowrap",o.style.letterSpacing="0.025em",n.appendChild(i),n.appendChild(o),document.body.appendChild(n),n.addEventListener("mouseenter",(()=>{n.style.width="100px",n.style.borderRadius="28px",n.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)",n.style.transform="translateY(-2px)",o.style.opacity="1",o.style.transform="translateX(0)",i.style.transform="scale(1.05)"})),n.addEventListener("mouseleave",(()=>{n.style.width="40px",n.style.height="40px",n.style.borderRadius="50px",n.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",n.style.transform="translateY(0)",o.style.opacity="0",o.style.transform="translateX(-8px)",i.style.transform="scale(1)"})),n.addEventListener("mousedown",(()=>{n.style.transform="translateY(0) scale(0.98)",n.style.boxShadow="0 2px 8px 0 rgba(102, 126, 234, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05)"})),n.addEventListener("mouseup",(()=>{n.style.transform="translateY(-2px)",n.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)"})),o.addEventListener("click",(()=>{e("Testimonials Error","There was an error loading testimonials. Please try again later. If the issue persists, please contact support.",[],"❌")}));const s=()=>{window.innerWidth<=768?(n.style.bottom="16px",n.style.right="16px",n.style.width="48px",n.style.height="48px",i.style.width="48px",i.style.height="48px",i.style.fontSize="18px",o.style.fontSize="13px",o.style.marginLeft="6px",o.style.marginRight="12px"):(n.style.bottom="30px",n.style.right="30px",n.style.width="40px",n.style.height="40px",i.style.width="40px",i.style.height="40px",i.style.fontSize="20px",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px")};s(),window.addEventListener("resize",s)}();const s={version:"1.1.4",checksum:F.replace("sha384-",""),async init({endpoint:t,configuredDomain:s,projectId:a,pingletId:l}){if(console.log("%cPingletWidget initialized successfully.","color: #1e90ff; font-weight: bold;",this.version),!X)return e("Configuration Error","Missing templatesIds.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing templatesIds.");if(!l)return e("Configuration Error","Missing Pinglet ID.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing pingletId.");if(!t)return e("Configuration Error","Missing Endpoint.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing pingletId.");if("1.1.3"!==this.version)return e("Pinglet Unsupported Version",`PingletWidget version ${this.version} is not supported. Please update to the latest version.`,[{text:"See Docs",actions:"redirect",src:"https://pinglet.enjoys.in/docs"}],"⚠️"),void console.warn("Unsupported version detected.");if(!this.checksum||!F)return e("Configuration Error","Missing checksum.");const p=await fetch(`${t}/load/projects?projectId=${a}&domain=${s}`,{headers:{"X-Project-ID":a,"X-Timestamp":Date.now(),"X-Pinglet-Signature":l,"X-Pinglet-Checksum":this.checksum,"X-Pinglet-Version":this.version,"X-Configured-Domain":s,"X-Pinglet-Id":l},credentials:"omit"}),f=await p.json();if(!f||!f.success)return e("Configuration Error",`Failed to load configuration for PingletWidget. ${f.message||"Unknown error"}`,[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Failed to load configuration for PingletWidget.");d(f.result.config.branding);let u=await async function(t,e,n,i,o,s){const a=await fetch(`${t}/load/templates?projectId=${e}&templatesIds=${s}`,{headers:{"X-Project-ID":e,"X-Timestamp":Date.now(),"X-Pinglet-Signature":n,"X-Pinglet-Checksum":i,"X-Pinglet-Version":o},credentials:"omit"}),l=await a.json();return l&&l.success?l.result:null}(t,a,l,this.checksum,this.version,X);u||e("Configuration Error","Failed to load templates for PingletWidget.");const x={is_tff:f.result?.is_premium??!1,templates:Object.assign({},{default:{compiled_text:e.toString(),config:i,is_active:!0,is_default:!0}},u),style:Object.assign({},n,f.result.template?.config),config:Object.assign({},i,f.result.config)};!function(t){if(o)return o;t.config.sound?.play&&t.config.sound.src&&(r=t.config.sound.src,o=new Audio(r||t.config.sound.src),o.volume=t.config.sound.volume??.5)}(x);new EventSource(`${t}/sse?projectId=${a}&pingletId=${l}`,{withCredentials:!1}).onmessage=t=>{const e=JSON.parse(t.data),n=e.data;if(x?.is_tff&&Object.assign(x.config,x.config,n?.overrides??{}),"1"===e?.type&&e?.template_id&&e?.custom_template){const t=x.templates[e.template_id];if(!t||0===t.compiled_text.length)return console.log("Template not found");const n=new Function("return "+t.compiled_text?.trim())()(e?.custom_template);let i;return x.config.sound&&c(),i=Array.isArray(n)?z(n,{side:"left"}):z([n],{side:"left"}),i.setAttribute("data-notification-id",`${e?.project_id||a}-${Date.now()}`),i.setAttribute("data-notification-type",e?.type||"1"),void i.addEventListener("click",(()=>{g("clicked",i,"user clicked"),e.custom_template.url&&window.open(e.custom_template.url,"_blank")}))}if("0"===e?.type&&e?.body){const t=y(e.body,x);t.setAttribute("data-notification-id",`${e?.project_id||a}-${Date.now()}`),t.setAttribute("data-notification-type",e?.type||"0");const{toastContainer:n}=m(t,x);"url"in e.body&&n.addEventListener("click",(()=>{g("clicked",t,"user clicked"),t.remove(),window.open(e.body.url,"_blank")}))}else e&&"-1"===e?.type&&function(t,e,n){new Notification(t,{badge:"🎉",body:e,actions:[{action:"pinglet",title:"Pinglet"}],icon:n,dir:"rtl",lang:"en",silent:!1,tag:"pinglet",vibrate:[100,50,100],requireInteraction:!0}).onclick=()=>{}}(body.title,body.description,body.type?.icon?.src||"")}}};t.PingletWidget=s,s.init({endpoint:_,configuredDomain:W,projectId:A,pingletId:R})})(window)}();
|
|
1
|
+
!function(){"use strict";function t(t,e){switch(t.action){case"redirect":case"open":return window.open(t.src,"_blank");case"link":return window.open(t.src);case"alert":return alert(t.src);case"reload":return window.location.reload();case"event":return window.addEventListener(t.src,(()=>{}));case"close":case"dismiss":return window.dispatchEvent(new CustomEvent("pinglet:notificationClosed",{detail:{contentEl:e,reason:"user-dismiss"}}))}return window.open("https://pinglet.enjoys.in/docs","_blank")}function e(e,n,i=[{text:"See Docs",onClick:()=>window.open("https://pinglet.enjoys.in/docs","_blank")}],o="⚠️",s={duration:5e3,auto_dismiss:!0}){const a="toastContainer";let l=document.getElementById(a);l||(l=document.createElement("div"),l.id=a,Object.assign(l.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"9999",display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end",fontFamily:"Manrope, sans-serif"}),document.body.appendChild(l));const r=document.createElement("div");Object.assign(r.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",minWidth:"260px",maxWidth:"340px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"10px",fontFamily:"Manrope, sans-serif"});const c=document.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600",fontFamily:"Manrope, sans-serif"});const d=document.createElement("div");d.textContent=o;const p=document.createElement("div");if(p.textContent=e,c.appendChild(d),c.appendChild(p),r.appendChild(c),n){const t=document.createElement("div");t.textContent=n,Object.assign(t.style,{fontSize:"13.5px",fontWeight:"400",color:"#ddd",lineHeight:"1.5"}),r.appendChild(t)}if(Array.isArray(i)&&i.length){const e=document.createElement("div");Object.assign(e.style,{marginTop:"8px",display:"flex",gap:"10px",justifyContent:"flex-start"});for(const n of i){const i=document.createElement("button");if(i.textContent=n.text||"Click Here",Object.assign(i.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s",fontFamily:"Manrope, sans-serif"}),i.onmouseover=()=>i.style.background="#444",i.onmouseout=()=>i.style.background="#333",n?.onClick){const t=new Function(`return ${n.onClick}`)();"function"==typeof t&&i.addEventListener("click",t)}else i.addEventListener("click",(e=>(e.stopPropagation(),t(n,i))));e.appendChild(i)}r.appendChild(e)}const m=document.createElement("div");return m.innerHTML='Notifications by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys',Object.assign(m.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"Manrope, sans-serif"}),l.appendChild(r),l.appendChild(m),requestAnimationFrame((()=>{r.style.opacity="1",r.style.transform="translateX(0)"})),s.auto_dismiss||setTimeout((()=>{r.style.opacity="0",r.style.transform="translateX(100%)",setTimeout((()=>{r.remove(),m.remove()}),500)}),s.duration||5e3),l}const n={duration:3e3,btn1:{color:"#ffffff",backgroundColor:"#007bff",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"none",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},btn2:{color:"#333333",backgroundColor:"#f0f0f0",padding:"6px 10px",borderRadius:"6px",fontSize:"14px",fontWeight:"600",border:"1px solid #ccc"},title:{color:"#111111",fontSize:"14px",fontWeight:"500",lineHeight:"1.4",margin:"0 0 0 0",textAlign:"left"},description:{color:"#444444",fontSize:"13px",fontWeight:"400",lineHeight:"1.5",margin:"0 0 10px 0",textAlign:"left"},controls:{video:{autoplay:!1,muted:!1,loop:!1,controls:!1},audio:{autoplay:!1,muted:!1,loop:!1,controls:!1}},media:{image:{width:"100%",height:"200px",borderRadius:"6px",objectFit:"cover",margin:"0 0 8px 0"},icon:{width:"24px",height:"24px",margin:"0 8px 0 0",objectFit:"contain"},logo:{width:"50px",height:"50px",margin:"0 8px 0 0",objectFit:"contain"},video:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},iframe:{width:"100%",height:"140px",borderRadius:"6px",objectFit:"cover",margin:"0 0 10px 0"},audio:{width:"100%",margin:"8px 0"}}},i={position:"bottom-left",transition:"fade",branding:{show:!0,once:!0,html:'Notifications by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'},sound:{play:!1,src:"https://pinglet.enjoys.in/api/v1/pinglet-sound.mp3?v=1&ext=mp3",volume:.6},duration:2e3,maxVisible:3,stacking:!0,auto_dismiss:!0,dismissible:!0,website:"https://pinglet.enjoys.in",time:!0,favicon:!0,pauseOnHover:!0,theme:{mode:"light",customClass:"",rounded:!0,shadow:!0,border:!1},iconDefaults:{show:!0,size:20,position:"left"},progressBar:{show:!0,color:"#4da6ff",height:3}};function o(t){const e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=window.atob(e);return Uint8Array.from([...n].map((t=>t.charCodeAt(0))))}function s(t,n,i){"Notification"in window?"granted"===Notification.permission||function(t={}){const{title:e="Stay updated with notifications",description:n="Get notified about important updates, new features, and exclusive content. We'll only send you valuable notifications.",site:i=window.location.hostname,onAllow:o=()=>{},onDeny:s=()=>{}}=t,a=document.createElement("div");a.className="notification-dialog",Object.assign(a.style,{position:"fixed",bottom:"24px",right:"24px",width:"380px",background:"#fff",borderRadius:"16px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255,255,255,0.1)",zIndex:"1000",overflow:"hidden",transform:"translateX(420px)",animation:"slideIn 0.6s ease-out 1s forwards",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const l=document.createElement("style");l.textContent="\n @keyframes slideIn { to { transform: translateX(0); } }\n @keyframes pulse {\n 0%, 100% { box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); }\n 50% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5); }\n }\n @media (max-width: 480px) {\n .notification-dialog {\n width: calc(100vw - 32px) !important;\n right: 16px !important;\n bottom: 16px !important;\n transform: translateY(420px) !important;\n }\n @keyframes slideIn { to { transform: translateY(0); } }\n }\n ",document.head.appendChild(l);const r=document.createElement("div");r.style.display="flex",r.style.justifyContent="space-between",r.style.padding="20px 20px 0 20px";const c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.gap="8px",c.style.color="#6b7280",c.style.fontSize="14px",c.style.fontWeight="500";const d=document.createElement("div");d.style.width="16px",d.style.height="16px",d.style.borderRadius="4px",d.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.innerHTML='<svg viewBox="0 0 16 16" fill="white" width="10" height="10"><path d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8z"/></svg>';const p=document.createElement("span");p.textContent=i,c.append(d,p);const m=document.createElement("button");m.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12">\n <path d="M12.854 4.854a.5.5 0 0 0-.708-.708L8 8.293 3.854 4.146a.5.5 0 1 0-.708.708L7.293 9l-4.147 4.146a.5.5 0 0 0 .708.708L8 9.707l4.146 4.147a.5.5 0 0 0 .708-.708L8.707 9l4.147-4.146z"/>\n </svg>',Object.assign(m.style,{width:"24px",height:"24px",background:"#f3f4f6",border:"none",borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"}),m.onclick=()=>a.remove(),r.append(c,m);const f=document.createElement("div");f.style.padding="16px 24px 24px 24px";const g=document.createElement("div");g.style.width="48px",g.style.height="48px",g.style.borderRadius="12px",g.style.marginBottom="16px",g.style.animation="pulse 2s infinite",g.style.background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",g.style.display="flex",g.style.alignItems="center",g.style.justifyContent="center",g.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" width="24" height="24">\n <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>\n </svg>';const u=document.createElement("h3");u.textContent=e,Object.assign(u.style,{fontSize:"18px",fontWeight:"600",color:"#111827",marginBottom:"8px"});const y=document.createElement("p");y.textContent=n,Object.assign(y.style,{fontSize:"14px",color:"#6b7280",lineHeight:"1.5",marginBottom:"20px"});const x=document.createElement("div");x.style.display="flex",x.style.gap="8px";const h=document.createElement("button");h.textContent="Not now",Object.assign(h.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"1px solid #e5e7eb",background:"#f9fafb",color:"#6b7280",cursor:"pointer"}),h.onclick=()=>{s(),a.remove()};const b=document.createElement("button");b.textContent="Allow notifications",Object.assign(b.style,{flex:1,padding:"10px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",border:"none",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",cursor:"pointer"}),b.onclick=()=>{o(),a.remove()},x.append(h,b);const w=document.createElement("div");w.style.marginTop="12px",w.style.display="flex",w.style.alignItems="center",w.style.justifyContent="center",w.style.gap="6px",w.style.color="#9ca3af",w.style.fontSize="12px",w.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" width="12" height="12"><path d="M8 0c-.69 0-1.843.265-2.928.56-1.11.3-2.229.655-2.887.87a1.54 1.54 0 0 0-1.044 1.262c-.596 4.477.787 7.795 2.465 9.99a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.775 11.775 0 0 0 2.517-2.453c1.678-2.195 3.061-5.513 2.465-9.99a1.541 1.541 0 0 0-1.044-1.263 62.467 62.467 0 0 0-2.887-.87C9.843.266 8.69 0 8 0z"/></svg><span>Secure & private • Unsubscribe anytime</span>',f.append(g,u,y,x,w),a.append(r,f),document.body.appendChild(a)}({site:window.location.hostname,onAllow:()=>{Notification.requestPermission().then((async s=>"granted"===s?async function(t,n,i){try{const s=await navigator.serviceWorker.register(`${t}/sw.js`);if(await s.pushManager.getSubscription())return;const a=await s.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:o(i)}),l=await fetch(`${t}/subscribe?projectId=${n}`,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},credentials:"omit"}),r=await l.json();if(r.success)return localStorage.getItem("subscription")?void 0:(localStorage.setItem("subscription","true"),e("Notifications Enabled","You can now receive notifications from this site.",[{text:"See Demo",onClick:'()=>{\n new Notification("Pinglet", {\n body: "This is a demo notification",\n icon: "https://pinglet.enjoys.in/favicon.ico"\n }).onclick = () => {\n window.open("https://pinglet.enjoys.in", "_blank");\n }) \n }'}],"🎉"));e("Something Went Wrong",r.message,[],"❌")}catch(t){}}(t,n,i):e("Permission Denied","You blocked notifications!",[],"😭"))).catch((t=>e("Permission Error","Error requesting notification permission:",[],"😭")))},onDeny:()=>e("Permission Denied","You blocked notifications!",[],"❌")}):e("Unsupported Browser","Notifications not supported.",[],"🚫")}let a,l,r=null,c=null,d=null;function p(){a&&(a.currentTime=0,a.play())}function m(t){return c||(c=document.createElement("div"),c.className="pinglet-branding",c.innerHTML=t?.html||'Notifications by <a href="https://pinglet.enjoys.in" class="pinglet-link" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a>',c.style="\n font-size: 11px;\n color: #808080;\n text-align: right;\n width: 100%;\n pointer-events: auto;\n ",c)}function f(t){if(l&&r)return{toastContainer:l,toastStack:r};const e=document.getElementById("pinglet-widget-container");return e?(l=e,r=l.querySelector(".pinglet-widget-stack"),{toastContainer:l,toastStack:r}):(l=document.createElement("div"),l.id="pinglet-widget-container",l.style.position="fixed",l.style.bottom="20px",l.style.left="20px",l.style.zIndex="9999",l.style.display="flex",l.style.flexDirection="column",l.style.alignItems="flex-start",l.style.gap="8px",l.style.maxWidth="360px",l.style.width="360px",l.style.boxSizing="border-box",l.style.pointerEvents="none",l.style.padding="4px",l.style.borderRadius="8px",r=document.createElement("div"),r.className="pinglet-widget-stack",r.style.display="flex",r.style.flexDirection="column",r.style.gap="12px",r.style.pointerEvents="none",r.style.overflow="visible",r.style.flexShrink="0",l.appendChild(r),t?.show&&t?.once&&l.appendChild(m(t)),document.body.appendChild(l),{toastContainer:l,toastStack:r})}function g(t,e){const n=e.config,{toastContainer:i,toastStack:o}=f(n.branding);var s,a;let l;function r(){n?.auto_dismiss&&(l=setTimeout((()=>{o.contains(t)&&(y("dropped",t,"user doesn't engaged"),u(t,n?.transition||"fade"))}),n.duration||5e3))}return n?.branding?.show&&n?.branding?.once&&i.appendChild(c),s=t,a=n.transition,s.style.opacity="0",s.style.transition="all 0.4s ease","fade"===a?(s.style.transform="translateX(20px)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="translateX(0)"}))):"slide"===a?(s.style.transform="translateX(100%)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="translateX(0)"}))):"zoom"===a?(s.style.transform="scale(0.8)",requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="scale(1)"}))):s.style.opacity="1",t.style.pointerEvents="auto",o.appendChild(t),i.addEventListener("mouseenter",(function(){clearTimeout(l)})),i.addEventListener("mouseleave",r),r(),{toastContainer:i,toastStack:o}}function u(t,e){t&&(t.style.transition="all 0.4s ease","fade"===e?(t.style.opacity="0",t.style.transform="translateX(-40px)"):"slide"===e?(t.style.transform="translateX(-100%)",t.style.opacity="0"):"zoom"===e?(t.style.transform="scale(0.8)",t.style.opacity="0"):t.style.opacity="0",t.addEventListener("transitionend",(()=>{t.remove(),r&&0===r.children.length&&c?.remove()}),{once:!0}))}async function y(t,e,n="user-dismiss"){const i=e.getAttribute("data-notification-id"),o=e.getAttribute("data-notification-type")||"0",[s,a]=i.split("-");window.sendNotificationEvent(t,{project_id:s,notification_id:i,timestamp:a,reason:n,type:o})}function x(t=i,e=window.location.hostname,n="just now",o=!1){const s=document.createElement("div");s.className="pinglet-row",Object.assign(s.style,{display:"flex",justifyContent:"space-between",alignItems:"center",background:o?"#1a1a1a":"transparent",fontFamily:"system-ui, sans-serif",fontSize:"10px",padding:"6px 10px",borderBottom:o?"1px solid rgba(255, 255, 255, 0.1)":"1px solid rgba(0, 0, 0, 0.05)",color:o?"#f0f0f0":"#000"});const a=document.createElement("div");a.className="pinglet-left",Object.assign(a.style,{display:"flex",alignItems:"center",gap:"6px",flexGrow:"1"});const l=document.createElement("span");l.className="pinglet-icon",l.textContent="- Pinglet",l.onclick=()=>{window.open("https://pinglet.enjoys.in","_blank")},Object.assign(l.style,{alignItems:"center",color:"dodgerblue",flexShrink:"0",fontWeight:"bold",cursor:"pointer"});const d=document.createElement("span");d.className="pinglet-domain",d.textContent=e,d.style.color=o?"#bbb":"#808080";const p=document.createElement("span");p.className="pinglet-time",p.textContent=`- ${n}`,p.style.color=o?"#ccc":"#aaa";const m=document.createElement("button");return m.className="pinglet-close",m.textContent="✕",Object.assign(m.style,{background:"none",border:"none",fontSize:"12px",cursor:"pointer",color:o?"#aaa":"#888",padding:"0 4px"}),m.addEventListener("mouseenter",(()=>{m.style.color="#f44"})),m.addEventListener("mouseleave",(()=>{m.style.color=o?"#aaa":"#888"})),t?.website&&a.appendChild(d),t?.time&&a.appendChild(p),t?.favicon&&a.appendChild(l),s.appendChild(a),t?.dismissible&&s.appendChild(m),m.addEventListener("click",(t=>{var e,n;t.stopPropagation(),e="pinglet:notificationClosed",n={contentEl:m.parentElement?.parentElement,reason:"user-dismiss"},window.dispatchEvent(new CustomEvent(e,{detail:n})),r&&0===r.children.length&&c?.remove()})),s}function h(e,i){const o=i.style,s=i.config,a=(s.theme.mode||{})&&window.matchMedia("(prefers-color-scheme: dark)").matches,l=document.createElement("div");l.id="pinglet-variant",l.setAttribute("data-key",`${Date.now()}-${Math.random().toString(36).slice(2,8)}`),l.className=`pinglet-variant pinglet-${e.variant||"default"}`,Object.assign(l.style,{display:"flex",flexDirection:"column",alignItems:"stretch",width:"320px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",overflowY:"auto",padding:"4px",gap:"4px",pointerEvents:"none",overflow:"visible",flexShrink:"0",boxShadow:a?"0 2px 8px rgba(0,0,0,0.6)":"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:a?"#1e1e1e":"whitesmoke",color:a?"#f0f0f0":"#000"}),l.appendChild(x(s,window.location.hostname,"just now",a));let r=null;const d="icon"in e||"logo"in e;if(e.media?.type&&(r=function(t,e,i){switch(t.type){case"image":{const i=document.createElement("img");return i.src=t.src,Object.assign(i.style,e?.image||n.media.image),i}case"video":{const o=document.createElement("video");return o.src=t.src,o.autoplay=i?.video?.autoplay||n.controls.video.autoplay||!1,o.muted=i?.video?.muted||n.controls.video.muted||!1,o.loop=i?.video?.loop||n.controls.video.loop||!1,o.controls=i?.video?.controls||n.controls.video.controls||!1,o.style=e?.video||n.media.video,Object.assign(o.style,e?.video||n.media.video),o}case"audio":return function(t,e,n,i){const o=document.createElement("div");Object.assign(o.style,{maxWidth:"auto",padding:"16px",borderRadius:"20px 20px 6px 20px",background:"#fff",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",position:"relative",fontFamily:"Segoe UI, sans-serif"});const s=document.createElement("div");Object.assign(s.style,{position:"absolute",bottom:"6px",right:"-6px",width:"0",height:"0",borderLeft:"8px solid #ffffff",borderBottom:"8px solid transparent"}),o.appendChild(s);const a=document.createElement("audio");a.src=t,a.autoplay=!0,a.muted=e,a.loop=n,a.controls=i,o.appendChild(a);const l=document.createElement("div");Object.assign(l.style,{display:"flex",alignItems:"center",gap:"14px"});const r=document.createElement("button");r.textContent="▶",Object.assign(r.style,{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"50%",color:"white",width:"44px",height:"44px",fontSize:"18px",cursor:"pointer",flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(102, 126, 234, 0.4)",transition:"transform 0.3s ease"}),l.appendChild(r);const c=document.createElement("div");Object.assign(c.style,{flex:"1",display:"flex",flexDirection:"column",gap:"8px"});const d=document.createElement("div");Object.assign(d.style,{display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 4px"});const p=[];for(let t=0;t<20;t++){const e=document.createElement("div");Object.assign(e.style,{width:"4px",background:"linear-gradient(to top, #667eea, #764ba2)",borderRadius:"2px",transition:"all 0.3s ease",height:8+t%5*4+"px",animation:"wave 1.5s infinite ease-in-out",animationDelay:t%5*.15+"s",animationPlayState:"paused"}),p.push(e),d.appendChild(e)}c.appendChild(d);const m=document.createElement("div");Object.assign(m.style,{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"13px",color:"#666"});const f=document.createElement("div");f.textContent="Voice message",f.style.fontSize="12px",f.style.color="#888";const g=document.createElement("div");g.textContent="0:00",Object.assign(g.style,{fontWeight:"500",color:"#667eea"}),m.appendChild(f),m.appendChild(g),c.appendChild(m),l.appendChild(c),o.appendChild(l);const u=document.createElement("style");function y(t){return`${Math.floor(t/60)}:${Math.floor(t%60).toString().padStart(2,"0")}`}return u.textContent="\n @keyframes wave {\n 0%, 100% { opacity: 0.3; transform: scaleY(0.5); }\n 50% { opacity: 1; transform: scaleY(1); }\n }\n ",document.head.appendChild(u),a.addEventListener("loadedmetadata",(()=>{g.textContent=y(a.duration)})),a.addEventListener("timeupdate",(()=>{g.textContent=y(a.currentTime)})),r.addEventListener("click",(()=>{a.paused?(a.play(),r.textContent="⏸",p.forEach((t=>t.style.animationPlayState="running"))):(a.pause(),r.textContent="▶",p.forEach((t=>t.style.animationPlayState="paused")))})),a.addEventListener("ended",(()=>{r.textContent="▶",p.forEach((t=>t.style.animationPlayState="paused")),a.currentTime=0})),o}(t.src,i?.audio?.muted||n.controls?.audio.muted||!1,i?.audio?.loop||n.controls?.audio?.loop||!1,i?.audio?.controls||n.controls?.audio?.controls||!1);default:return null}}(e.media,o.media,o.controls),r.style.marginBottom="12px"),r&&l.appendChild(r),d){const t=document.createElement("div");Object.assign(t.style,{display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"6px"});const s=document.createElement("div");Object.assign(s.style,{flex:"0 0 auto"});const r=function(t,e,i){if("logo"===t){const t=document.createElement("img");return t.src=e,Object.assign(t.style,i?.logo||n.media.logo),t}if("icon"===t){const t=document.createElement("span");if("string"==typeof e){const n=/^data:image\/(png|jpeg|gif|webp);base64,/.test(e),i=/^<svg[\s\S]*<\/svg>$/.test(e.trim());n?(t.style.backgroundImage=`url('${e}')`,t.style.backgroundSize="cover",t.textContent=""):i?t.innerHTML=e:t.textContent=e}return t.className="pinglet-icon",Object.assign(t.style,{width:"40px",height:"40px",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundPosition:"center",borderRadius:"8px",fontSize:"24px",overflow:"hidden"}),t}return null}("icon"in e?"icon":"logo",e?.icon||e?.logo,i.style.media);r&&s.appendChild(r),t.appendChild(s);const c=document.createElement("div");if(Object.assign(c.style,{display:"flex",flexDirection:"column",flex:"1"}),e.title){const t=document.createElement("div");t.className="pinglet-title",t.innerText=e.title,Object.assign(t.style,{...o.title||n.title,color:a?"#ffffff":"#000000"}),c.appendChild(t)}if(e.description){const t=document.createElement("p");t.className="pinglet-desc",t.innerText=e.description,Object.assign(t.style,{...o.description||n.description,color:a?"#dddddd":"#333333"}),c.appendChild(t)}t.appendChild(c),l.appendChild(t)}else{if(e.title){const t=document.createElement("div");t.className="pinglet-title",t.innerText=e.title,Object.assign(t.style,{...o.title||n.title,color:a?"#ffffff":"#000000"}),l.appendChild(t)}if(e.description){const t=document.createElement("p");t.className="pinglet-desc",t.innerText=e.description,Object.assign(t.style,{...o.description||n.description,color:a?"#dddddd":"#333333"}),l.appendChild(t)}}if(e.buttons){const n=document.createElement("div");n.className="pinglet-buttons",n.style.fontFamily="Manrope",e.buttons.forEach(((e,i)=>{const s=document.createElement("button");if(s.innerText=e.text,s.className="pinglet-btn",Object.assign(s.style,{cursor:"pointer",padding:"6px 10px",fontFamily:"Manrope, sans-serif",margin:"1px 4px",color:a?"#f0f0f0":"#000",backgroundColor:a?"#333":"#f0f0f0",border:"none",borderRadius:"4px"}),Object.assign(s.style,0===i?o.btn1:o.btn2),e?.onClick){const t=new Function(`return ${e.onClick}`)();"function"==typeof t&&s.addEventListener("click",t)}else s.addEventListener("click",(n=>(n.stopPropagation(),t(e,l))));n.appendChild(s)})),l.appendChild(n)}return s.sound?.play&&p(),!c||l.contains(c)||s.branding?.once||l.appendChild(c),l}window.addEventListener("pinglet:notificationClosed",(t=>{y("closed",t.detail.contentEl,t.detail.reason),u(t.detail.contentEl,"fade")}));let b=!1;async function w(t,e){(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).forEach((n=>{n.postMessage({type:"CUSTOM_NOTIFICATION_EVENT",eventName:t,payload:e})}))}async function v(t,e){"project_id"in e&&await fetch("https://pinglet.enjoys.in/api/v1/log/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,event:t})})}function E(t,e){const n=new CustomEvent(`notification:${t}`,{detail:e});document.dispatchEvent(n)}function C(t,e){document.addEventListener(`notification:${t}`,(t=>{e(t.detail)}))}async function k(t,e){"project_id"in e&&await fetch("https://pinglet.enjoys.in/api/v1/log/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,event:t}),credentials:"omit"})}self.addEventListener("install",(t=>{self.skipWaiting()})),self.addEventListener("activate",(t=>{clients.claim()})),self.addEventListener("push",(async t=>{if(console.log("[Service Worker] Push Received."),!t.data)return;const e=t.data?.json?.()||{},n={body:e?.body,icon:e?.icon,badge:e?.badge,tag:e?.tag,requireInteraction:e?.requireInteraction||!0,silent:e?.silent||!1,data:e?.data,actions:e?.actions,image:e?.image,timestamp:Date.now(),vibrate:[200,100,200]};e.data?.duration&&setTimeout((()=>{self.registration.getNotifications({tag:e.tag}).then((async t=>{const n=await self.clients.matchAll({type:"window",includeUncontrolled:!0});t.forEach((t=>{n.length>0?w("dropped",{...e?.data,notificationTag:t.tag,timestamp:Date.now()}):v("dropped",{...e?.data,notificationTag:t.tag,timestamp:Date.now()}),t.close()}))}))}),e.data?.duration||5e3);const i=await self.clients.matchAll({type:"window",includeUncontrolled:!0});b=i.length>0,t.waitUntil(self.registration.showNotification(e.title,n))})),self.addEventListener("notificationclick",(t=>{t.notification.close();const e=t.notification.data||{},n=t.action;if(n&&e.actionEvents&&e.actionEvents[n]){const i=e.actionEvents[n];async function o(t,e,n){const{eventName:i,eventData:o,url:s,windowAction:a}=t;try{if(b?n.waitUntil(w(i,{...o,notificationTag:n.notification.tag,timestamp:Date.now()})):n.waitUntil(v("clicked",{...e,notificationTag:n.notification.tag,timestamp:Date.now()})),"open"===a&&s)await clients.openWindow(s);else if("focus"===a){const t=await clients.matchAll({type:"window"});t.length>0?await t[0].focus():s&&await clients.openWindow(s)}}catch(t){}}t.waitUntil(o(i,e,t))}else{if("dismiss"===t.action)return b?t.waitUntil(w("closed",{...e,notificationTag:t.notification.tag,timestamp:Date.now()})):t.waitUntil(v("closed",{...eventData,notificationTag:t.notification.tag,timestamp:Date.now()})),t.notification.close();if("url"in e){const s=e.url;t.waitUntil(clients.openWindow(s))}b?t.waitUntil(w("clicked",{...e,notificationTag:t.notification.tag,timestamp:Date.now()})):t.waitUntil(v("clicked",{...eventData,notificationTag:t.notification.tag,timestamp:Date.now()}))}})),self.addEventListener("notificationclose",(t=>{console.log("Notification closed:",t.notification.tag)})),window.notificationEventHandlers={},"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",(t=>{const{type:e,eventName:n,payload:i}=t.data;"CUSTOM_NOTIFICATION_EVENT"===e&&E(n,i)})),window.sendNotificationEvent=E,C("clicked",(t=>k("clicked",t))),C("dropped",(t=>k("dropped",t))),C("closed",(t=>k("closed",t)));const j={autoCloseDelay:1e4,brandingText:"Powered by Enjoys",brandingPosition:"right",defaultClass:"pinglet-wigdet-wrapper",spacing:2,maxVisible:3,side:"right"},S=document.createElement("style");function I(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.position="fixed",n.style.zIndex="9999",n.style.display="flex",n.style.flexDirection="column-reverse",n.style.gap=`${j.spacing}px`,n.style.pointerEvents="none",n.style.bottom="20px",n.classList.add(j.defaultClass),"left"===e?n.style.left="20px":n.style.right="20px",document.body.appendChild(n)),n}S.innerHTML="\n@keyframes slideIn {\n from { opacity: 0; transform: translateY(40px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes slideOut {\n from { opacity: 1; transform: translateY(0); }\n to { opacity: 0; transform: translateY(40px); }\n}",document.head.appendChild(S);const O=I("container-right","right"),T=I("container-left","left"),L={left:[],right:[]},N={left:[],right:[]};function z(t=[],e={}){const n={...j,...e},i=document.createElement("div");i.style.position="relative",i.style.width="300px",i.style.borderRadius="10px",i.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)",i.style.backgroundColor="#fff",i.style.transition="transform 0.3s ease, opacity 0.3s ease",i.style.animation="slideIn 0.4s forwards",i.style.pointerEvents="all",i.id="pinglet-custom-wrapper",t.forEach((t=>i.appendChild(t)));const o=document.createElement("button");o.innerText="×",Object.assign(o.style,{position:"absolute",top:"-10px",right:"-10px",width:"25px",height:"25px",borderRadius:"50%",border:"none",backgroundColor:"#f00",color:"#fff",fontSize:"16px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 4px rgba(0,0,0,0.2)"}),o.addEventListener("click",(async t=>{t.stopPropagation(),r(),y("closed",i),P(i,n.side)})),i.appendChild(o);const s=document.createElement("div");let a;function l(){a=setTimeout((()=>{(T.contains(i)||O.contains(i))&&y("dropped",i,"user doesn't interact"),P(i,n.side)}),n.autoCloseDelay)}function r(){clearTimeout(a)}return s.innerText=n.brandingText,Object.assign(s.style,{position:"absolute",bottom:"5px",fontSize:"12px",color:"#666"}),s.style[n.brandingPosition]="10px",i.appendChild(s),i.addEventListener("mouseenter",r),i.addEventListener("mouseleave",l),l(),L[n.side].push(i),D(n.side),i}function D(t){const e="left"===t?T:O;for(;N[t].length<j.maxVisible&&L[t].length>0;){const n=L[t].shift();e.appendChild(n),N[t].push(n)}}function P(t,e){t.style.animation="slideOut 0.4s forwards",t.addEventListener("animationend",(()=>{t.remove();const n=N[e].indexOf(t);-1!==n&&N[e].splice(n,1),D(e)}))}const M=Array.from(document.scripts).find((t=>t.src.includes("pinglet-sse")&&t.dataset.endpoint))||document.currentScript,_=M?.dataset.endpoint,W=M?.dataset.configuredDomain,A=M?.dataset.projectId,R=M?.dataset.pingletId,$=M?.dataset.checksum,F=M?.dataset.testimonials,X=M?.dataset.templates;(async t=>{if(t.projectId=A,t.PingletWidget)return void console.warn("PingletNotification is already initialized.");!function(){const t=document.createElement("link");t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap",document.head.appendChild(t);const e=document.createElement("style");e.innerHTML='\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Manrope\', sans-serif !important;\n font-weight: 400 !important;\n }\n ',document.head.appendChild(e)}(),s(_,A,R),F&&function(){const t=document.getElementById("pinglet-testimonials");if(t)return t;const n=document.createElement("div");n.className="pinglet-floating-btn",n.style.position="fixed",n.style.bottom="30px",n.style.right="30px",n.style.display="flex",n.style.alignItems="center",n.style.background="#667EEA",n.style.borderRadius="50px",n.style.padding="0",n.style.cursor="pointer",n.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",n.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",n.style.overflow="hidden",n.style.width="24px",n.style.height="24px",n.style.zIndex="1000",n.style.backdropFilter="blur(10px)",n.style.border="1px solid rgba(255, 255, 255, 0.1)";const i=document.createElement("div");i.textContent="❔",i.className="icon",i.style.fontSize="20px",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",i.style.width="24px",i.style.height="24px",i.style.flexShrink="0",i.style.color="white";const o=document.createElement("span");o.textContent="View",o.className="label",o.style.color="white",o.style.fontWeight="500",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px",o.style.opacity="0",o.style.transform="translateX(-8px)",o.style.transition="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",o.style.whiteSpace="nowrap",o.style.letterSpacing="0.025em",n.appendChild(i),n.appendChild(o),document.body.appendChild(n),n.addEventListener("mouseenter",(()=>{n.style.width="100px",n.style.borderRadius="28px",n.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)",n.style.transform="translateY(-2px)",o.style.opacity="1",o.style.transform="translateX(0)",i.style.transform="scale(1.05)"})),n.addEventListener("mouseleave",(()=>{n.style.width="40px",n.style.height="40px",n.style.borderRadius="50px",n.style.boxShadow="0 4px 14px 0 rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",n.style.transform="translateY(0)",o.style.opacity="0",o.style.transform="translateX(-8px)",i.style.transform="scale(1)"})),n.addEventListener("mousedown",(()=>{n.style.transform="translateY(0) scale(0.98)",n.style.boxShadow="0 2px 8px 0 rgba(102, 126, 234, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05)"})),n.addEventListener("mouseup",(()=>{n.style.transform="translateY(-2px)",n.style.boxShadow="0 8px 25px 0 rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1)"})),o.addEventListener("click",(()=>{e("Testimonials Error","There was an error loading testimonials. Please try again later. If the issue persists, please contact support.",[],"❌")}));const s=()=>{window.innerWidth<=768?(n.style.bottom="16px",n.style.right="16px",n.style.width="48px",n.style.height="48px",i.style.width="48px",i.style.height="48px",i.style.fontSize="18px",o.style.fontSize="13px",o.style.marginLeft="6px",o.style.marginRight="12px"):(n.style.bottom="30px",n.style.right="30px",n.style.width="40px",n.style.height="40px",i.style.width="40px",i.style.height="40px",i.style.fontSize="20px",o.style.fontSize="14px",o.style.marginLeft="8px",o.style.marginRight="16px")};s(),window.addEventListener("resize",s)}();const o={version:"1.2.0",checksum:$.replace("sha384-",""),async init({endpoint:t,configuredDomain:o,projectId:s,pingletId:l}){if(console.log("%cPingletWidget initialized successfully.","color: #1e90ff; font-weight: bold;",this.version),!X)return e("Configuration Error","Missing templatesIds.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing templatesIds.");if(!l)return e("Configuration Error","Missing Pinglet ID.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing pingletId.");if(!t)return e("Configuration Error","Missing Endpoint.",[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Missing pingletId.");if("1.2.0"!==this.version)return e("Pinglet Unsupported Version",`PingletWidget version ${this.version} is not supported. Please update to the latest version.`,[{text:"See Docs",actions:"redirect",src:"https://pinglet.enjoys.in/docs"}],"⚠️"),void console.warn("Unsupported version detected.");if(!this.checksum||!$)return e("Configuration Error","Missing checksum.");const r=await fetch(`${t}/load/projects?projectId=${s}&domain=${o}`,{headers:{"X-Project-ID":s,"X-Timestamp":Date.now(),"X-Pinglet-Signature":l,"X-Pinglet-Checksum":this.checksum,"X-Pinglet-Version":this.version,"X-Configured-Domain":o,"X-Pinglet-Id":l},credentials:"omit"}),c=await r.json();if(!c||!c.success)return e("Configuration Error",`Failed to load configuration for PingletWidget. ${c.message||"Unknown error"}`,[{text:"Retry",action:"reload"},{text:"See Docs",action:"redirect",src:"https://pinglet.enjoys.in/docs"}],"❌"),console.error("Failed to load configuration for PingletWidget.");m(c.result.config.branding);const f=await async function(t,e,n,i,o,s){const a=await fetch(`${t}/load/templates?projectId=${e}&templatesIds=${s}`,{headers:{"X-Project-ID":e,"X-Timestamp":Date.now(),"X-Pinglet-Signature":n,"X-Pinglet-Checksum":i,"X-Pinglet-Version":o},credentials:"omit"}),l=await a.json();return l&&l.success?l.result:null}(t,s,l,this.checksum,this.version,X);f||e("Configuration Error","Failed to load templates for PingletWidget.");const u={is_tff:c.result?.is_premium??!1,templates:Object.assign({},{default:{compiled_text:e.toString(),config:i,is_active:!0,is_default:!0}},f),style:Object.assign({},n,c.result.template?.config),config:Object.assign({},i,c.result.config)};!function(t){if(a)return a;t.config.sound?.play&&t.config.sound.src&&(d=t.config.sound.src,a=new Audio(d||t.config.sound.src),a.volume=t.config.sound.volume??.5)}(u);new EventSource(`${t}/sse?projectId=${s}&pingletId=${l}`,{withCredentials:!1}).onmessage=t=>{const e=JSON.parse(t.data),n=e.data;if(u?.is_tff&&Object.assign(u.config,u.config,n?.overrides??{}),"1"===e?.type&&e?.template_id&&e?.custom_template){const t=u.templates[e.template_id];if(!t||0===t.compiled_text.length)return console.log("Template not found");const n=new Function(`return ${t.compiled_text?.trim()}`)()(e?.custom_template);let i;return u.config.sound&&p(),i=Array.isArray(n)?z(n,{side:"left"}):z([n],{side:"left"}),i.setAttribute("data-notification-id",`${e?.project_id||s}-${Date.now()}`),i.setAttribute("data-notification-type",e?.type||"1"),void i.addEventListener("click",(()=>{y("clicked",i,"user clicked"),e.custom_template.url&&window.open(e.custom_template.url,"_blank")}))}if("0"===e?.type&&e?.body){const t=h(e.body,u);t.setAttribute("data-notification-id",`${e?.project_id||s}-${Date.now()}`),t.setAttribute("data-notification-type",e?.type||"0");const{toastContainer:n}=g(t,u);"url"in e.body&&n.addEventListener("click",(()=>{y("clicked",t,"user clicked"),t.remove(),window.open(e.body.url,"_blank")}))}else e&&"-1"===e?.type&&function(t,e,n){new Notification(t,{badge:"🎉",body:e,actions:[{action:"pinglet",title:"Pinglet"}],icon:n,dir:"rtl",lang:"en",silent:!1,tag:"pinglet",vibrate:[100,50,100],requireInteraction:!0}).onclick=()=>{}}(body.title,body.description,body.type?.icon?.src||"")}}};t.PingletWidget=o,o.init({endpoint:_,configuredDomain:W,projectId:A,pingletId:R})})(window)}();
|
package/pinglet-sse.min.js
CHANGED
|
@@ -1 +1,555 @@
|
|
|
1
|
-
!function(){"use strict";(e=>{!function(){const e=document.createElement("link");e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML='\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Inter\', sans-serif !important;\n }\n ',document.head.appendChild(t)}();const t={style:{color:"#fff",backgroundColor:"#000"},position:"bottom-left",branding:{html:'Powered by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'},duration:2e3},n="pinglet-wrapper";let o=0,i=null;const a={createMediaElement(e,t="Pinglet Notification"){let n;switch(e.type){case"image":default:n=document.createElement("img"),n.src=e.src,n.alt=t;break;case"video":n=document.createElement("video"),n.src=e.src,n.controls=!0,n.setAttribute("playsinline",""),n.setAttribute("muted","");break;case"audio":n=document.createElement("audio"),n.src=e.src,n.controls=!0;break;case"icon":n=document.createElement("span"),n.className=`icon-${e.src}`,n.setAttribute("aria-label",t)}return["image","video","audio"].includes(e.type)&&(Object.assign(n.style,{width:"100%",maxWidth:"320px",height:"auto",borderRadius:"10px",marginBottom:"8px",display:"block"}),"audio"===e.type&&(n.style.height="40px"),"video"!==e.type&&"image"!==e.type||(n.style.height="180px",n.style.objectFit="cover")),n},createWrapper(e="bottom-right"){let t=document.getElementById(n);if(!t){t=document.createElement("div"),t.id=n,Object.assign(t.style,{position:"fixed",zIndex:99999,display:"flex",flexDirection:"column",gap:"10px",maxWidth:"calc(100vw - 20px)",padding:"12px",pointerEvents:"none"});const o={"top-left":{top:"0",left:"0",alignItems:"flex-start"},"top-right":{top:"0",right:"0",alignItems:"flex-end"},"bottom-left":{bottom:"0",left:"0",alignItems:"flex-start"},"bottom-right":{bottom:"0",right:"0",alignItems:"flex-end"},"top-center":{top:"0",left:"50%",transform:"translateX(-50%)",alignItems:"center"},"bottom-center":{bottom:"0",left:"50%",transform:"translateX(-50%)",alignItems:"center"}};Object.assign(t.style,o[e]||o["bottom-right"]),document.body.appendChild(t)}return t},playNotificationSound({play:e,src:t}){if(!e||!t)return;new Audio(t).play().catch((e=>{}))},showToast(e){const{title:n="",description:a="",media:s,buttons:r=[]}=e,{style:l={},position:c,duration:d,branding:p}=t,m=this.createWrapper(c),f=document.createElement("div");f.className="pinglet-toast",o++,Object.assign(f.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0,0,0,0.25)",fontFamily:"'Inter', sans-serif",fontSize:"14px",lineHeight:"1.5",maxWidth:"360px",minWidth:"280px",pointerEvents:"auto",position:"relative",opacity:"0",transform:"none",transition:"all 0.4s ease",...o>=4?{opacity:.8,scale:.95}:{},...l});const g=document.createElement("span");if(g.innerHTML="×",Object.assign(g.style,{position:"absolute",top:"6px",right:"10px",cursor:"pointer",fontSize:"18px",color:"#aaa"}),g.onclick=()=>this.removeToast(f),f.appendChild(g),s){if("icon"===s.type){const e=document.createElement("div");e.innerHTML=`<span style="font-size:14px;margin-right:8px;">${s.src}</span><strong>${n}</strong>`,f.appendChild(e)}else if("image"===s.type||"video"===s.type){const e=this.createMediaElement(s);f.appendChild(e);const t=document.createElement("div");t.innerHTML=`<strong>${n}</strong>`,f.appendChild(t)}}else{const e=document.createElement("div");e.innerHTML=`<strong>${n}</strong>`,f.appendChild(e)}if(a){const e=document.createElement("div");e.textContent=a,e.style.color="#ccc",f.appendChild(e)}if(r.length){const e=document.createElement("div");Object.assign(e.style,{display:"flex",gap:"10px",marginTop:"8px",flexWrap:"wrap"}),r.forEach((t=>{const n=document.createElement("button");if(n.type="button",n.className=`pinglet-toast-btn-${o}`,n.textContent=t.text,Object.assign(n.style,{padding:"6px 12px",background:"#333",border:"1px solid #555",color:"#fff",borderRadius:"6px",cursor:"pointer",fontSize:"13px"}),t.onClick){if("string"==typeof t.onClick)try{t.onClick=new Function(`return (${t.onClick})`)()}catch(e){t.onClick=null}"function"==typeof t.onClick&&n.addEventListener("click",t.onClick)}e.appendChild(n)})),f.appendChild(e)}i||(i=document.createElement("div"),i.innerHTML=p.html,Object.assign(i.style,{fontSize:"11px",color:"#888",textAlign:"right",fontFamily:"'Inter', sans-serif",marginTop:"8px"})),m.appendChild(f),i&&m.appendChild(i),setTimeout((()=>{f.style.opacity="1",f.style.transform="translateX(0)"}),10);let u=setTimeout((()=>this.removeToast(f)),d);f.addEventListener("mouseenter",(()=>clearTimeout(u))),f.addEventListener("mouseleave",(()=>{u=setTimeout((()=>removeToast(f)),2e3)}))},removeToast(e){e&&(e.style.opacity="0",e.style.transform="translateX(100%)",setTimeout((()=>{e.remove(),o--,0===o&&i&&(i.remove(),i=null)}),400))}},s={init({endpoint:e,configuredDomain:t,projectIds:n=[]}){const o=location.hostname.replace(/^www\./,"");if(0===t.length)return void this._showPopup("Domain Configuration Error ","Please ensure you are running Pinglet on a valid domain.");if(0===n.length)return void this._showPopup("Project Configuration Error ","Please add at least one project to your Pinglet configuration.");t==o?n.forEach((t=>{new EventSource(`${e}/sse?projectId=${encodeURIComponent(t)}`).onmessage=e=>{try{const t=JSON.parse(e.data);a.showToast({title:t.title,description:t.description,media:t.media,buttons:t.buttons})}catch(e){}}})):this._showPopup("Domain Configuration Error ",`Your current domain is not allowed. Please ensure it matches one of the following:\n ${t}`)},_showNotification(e){const{title:t="",description:n="",buttons:o=[],media:i=null,style:a={},branding:s={show:!0,html:'Powered by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys'}}=e,r=this._getWrapper(),l=document.createElement("div");if(l.className="pinglet-toast",Object.assign(l.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",fontFamily:"'Inter', sans-serif",minWidth:"260px",maxWidth:"360px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"12px",...a}),i){if("icon"===i.type){const e=document.createElement("div");Object.assign(e.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600"});const n=document.createElement("span");n.textContent=i.src;const o=document.createElement("span");o.textContent=t,e.appendChild(n),e.appendChild(o),l.appendChild(e)}else if("image"===i.type||"video"===i.type){const e=document.createElement(i.type);Object.assign(e.style,{maxWidth:"100%",borderRadius:"8px"}),e.src=i.src,"video"===i.type&&(e.controls=!0),l.appendChild(e);const n=document.createElement("div");n.textContent=t,Object.assign(n.style,{fontSize:"16px",fontWeight:"600"}),l.appendChild(n)}}else{const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{fontSize:"16px",fontWeight:"600"}),l.appendChild(e)}if(n){const e=document.createElement("div");e.textContent=n,Object.assign(e.style,{fontSize:"13.5px",color:"#ccc",lineHeight:"1.5"}),l.appendChild(e)}if(Array.isArray(o)&&o.length){const e=document.createElement("div");Object.assign(e.style,{display:"flex",gap:"10px",marginTop:"6px"});for(const t of o){const n=document.createElement("button");n.textContent=t.text||"Click",Object.assign(n.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s"}),n.onmouseover=()=>n.style.background="#444",n.onmouseout=()=>n.style.background="#333","function"==typeof t.onClick&&(n.onclick=t.onClick),e.appendChild(n)}l.appendChild(e)}if(r.appendChild(l),!1!==s?.show){const e=document.createElement("div");e.innerHTML=s?.html||"",Object.assign(e.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"'Inter', sans-serif"}),r.appendChild(e),setTimeout((()=>{l.remove(),e.remove()}),5e3)}else setTimeout((()=>l.remove()),5e3);requestAnimationFrame((()=>{l.style.opacity="1",l.style.transform="translateX(0)"}))},_showPopup(e,t,n=[{text:"See Docs",onClick:()=>window.open("https://pinglet.enjoys.in/docs","_blank")}],o="⚠️"){const i="toastContainer";let a=document.getElementById(i);a||(a=document.createElement("div"),a.id=i,Object.assign(a.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"9999",display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end"}),document.body.appendChild(a));const s=document.createElement("div");Object.assign(s.style,{background:"#1f1f1f",color:"#fff",padding:"16px 20px",borderRadius:"12px",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.25)",fontFamily:"'Inter', sans-serif",minWidth:"260px",maxWidth:"340px",opacity:"0",transform:"translateX(100%)",transition:"opacity 0.3s ease, transform 0.3s ease",display:"flex",flexDirection:"column",gap:"10px"});const r=document.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",fontWeight:"600"});const l=document.createElement("div");l.textContent=o;const c=document.createElement("div");if(c.textContent=e,r.appendChild(l),r.appendChild(c),s.appendChild(r),t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{fontSize:"13.5px",fontWeight:"400",color:"#ddd",lineHeight:"1.5"}),s.appendChild(e)}if(Array.isArray(n)&&n.length){const e=document.createElement("div");Object.assign(e.style,{marginTop:"8px",display:"flex",gap:"10px",justifyContent:"flex-start"});for(const t of n){const n=document.createElement("button");n.textContent=t.text||"Click",Object.assign(n.style,{padding:"8px 14px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"6px",fontSize:"13px",cursor:"pointer",transition:"background 0.3s"}),n.onmouseover=()=>n.style.background="#444",n.onmouseout=()=>n.style.background="#333","function"==typeof t.onClick&&n.addEventListener("click",t.onClick),e.appendChild(n)}s.appendChild(e)}a.appendChild(s);const d=document.createElement("div");d.innerHTML='Powered by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys',Object.assign(d.style,{fontSize:"11px",color:"#999",marginTop:"4px",textAlign:"right",fontFamily:"'Inter', sans-serif"}),a.appendChild(d),requestAnimationFrame((()=>{s.style.opacity="1",s.style.transform="translateX(0)"})),setTimeout((()=>{s.style.opacity="0",s.style.transform="translateX(100%)",setTimeout((()=>{s.remove(),d.remove()}),500)}),5e3)},_getWrapper(){let e=document.getElementById("pinglet-wrapper");return e||(e=document.createElement("div"),e.id="pinglet-wrapper",e.style="position:fixed;bottom:20px;right:20px;z-index:99999;display:flex;flex-direction:column;gap:10px;max-width:300px;font-family:sans-serif",document.body.appendChild(e)),e},_addBranding(e){if(!document.getElementById("pinglet-brand")){const t=document.createElement("div");t.id="pinglet-brand",t.style="font-size:10px;text-align:right;color:#aaa;margin-top:8px",t.innerHTML="Powered by <strong>Pinglet</strong> – Enjoys",e.appendChild(t)}}};e.PingletWidget=s})(window)}();
|
|
1
|
+
!(() => {
|
|
2
|
+
((e) => {
|
|
3
|
+
!(() => {
|
|
4
|
+
const e = document.createElement("link");
|
|
5
|
+
(e.rel = "stylesheet"),
|
|
6
|
+
(e.href =
|
|
7
|
+
"https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"),
|
|
8
|
+
document.head.appendChild(e);
|
|
9
|
+
const t = document.createElement("style");
|
|
10
|
+
(t.innerHTML =
|
|
11
|
+
'\n [class^="pinglet-"],\n [class*=" pinglet-"] {\n font-family: \'Inter\', sans-serif !important;\n }\n '),
|
|
12
|
+
document.head.appendChild(t);
|
|
13
|
+
})();
|
|
14
|
+
const t = {
|
|
15
|
+
style: { color: "#fff", backgroundColor: "#000" },
|
|
16
|
+
position: "bottom-left",
|
|
17
|
+
branding: {
|
|
18
|
+
html: 'Powered by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys',
|
|
19
|
+
},
|
|
20
|
+
duration: 2e3,
|
|
21
|
+
};
|
|
22
|
+
const n = "pinglet-wrapper";
|
|
23
|
+
let o = 0;
|
|
24
|
+
let i = null;
|
|
25
|
+
const a = {
|
|
26
|
+
createMediaElement(e, t = "Pinglet Notification") {
|
|
27
|
+
let n;
|
|
28
|
+
switch (e.type) {
|
|
29
|
+
default:
|
|
30
|
+
(n = document.createElement("img")), (n.src = e.src), (n.alt = t);
|
|
31
|
+
break;
|
|
32
|
+
case "video":
|
|
33
|
+
(n = document.createElement("video")),
|
|
34
|
+
(n.src = e.src),
|
|
35
|
+
(n.controls = !0),
|
|
36
|
+
n.setAttribute("playsinline", ""),
|
|
37
|
+
n.setAttribute("muted", "");
|
|
38
|
+
break;
|
|
39
|
+
case "audio":
|
|
40
|
+
(n = document.createElement("audio")),
|
|
41
|
+
(n.src = e.src),
|
|
42
|
+
(n.controls = !0);
|
|
43
|
+
break;
|
|
44
|
+
case "icon":
|
|
45
|
+
(n = document.createElement("span")),
|
|
46
|
+
(n.className = `icon-${e.src}`),
|
|
47
|
+
n.setAttribute("aria-label", t);
|
|
48
|
+
}
|
|
49
|
+
return (
|
|
50
|
+
["image", "video", "audio"].includes(e.type) &&
|
|
51
|
+
(Object.assign(n.style, {
|
|
52
|
+
width: "100%",
|
|
53
|
+
maxWidth: "320px",
|
|
54
|
+
height: "auto",
|
|
55
|
+
borderRadius: "10px",
|
|
56
|
+
marginBottom: "8px",
|
|
57
|
+
display: "block",
|
|
58
|
+
}),
|
|
59
|
+
"audio" === e.type && (n.style.height = "40px"),
|
|
60
|
+
("video" !== e.type && "image" !== e.type) ||
|
|
61
|
+
((n.style.height = "180px"), (n.style.objectFit = "cover"))),
|
|
62
|
+
n
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
createWrapper(e = "bottom-right") {
|
|
66
|
+
let t = document.getElementById(n);
|
|
67
|
+
if (!t) {
|
|
68
|
+
(t = document.createElement("div")),
|
|
69
|
+
(t.id = n),
|
|
70
|
+
Object.assign(t.style, {
|
|
71
|
+
position: "fixed",
|
|
72
|
+
zIndex: 99999,
|
|
73
|
+
display: "flex",
|
|
74
|
+
flexDirection: "column",
|
|
75
|
+
gap: "10px",
|
|
76
|
+
maxWidth: "calc(100vw - 20px)",
|
|
77
|
+
padding: "12px",
|
|
78
|
+
pointerEvents: "none",
|
|
79
|
+
});
|
|
80
|
+
const o = {
|
|
81
|
+
"top-left": { top: "0", left: "0", alignItems: "flex-start" },
|
|
82
|
+
"top-right": { top: "0", right: "0", alignItems: "flex-end" },
|
|
83
|
+
"bottom-left": {
|
|
84
|
+
bottom: "0",
|
|
85
|
+
left: "0",
|
|
86
|
+
alignItems: "flex-start",
|
|
87
|
+
},
|
|
88
|
+
"bottom-right": {
|
|
89
|
+
bottom: "0",
|
|
90
|
+
right: "0",
|
|
91
|
+
alignItems: "flex-end",
|
|
92
|
+
},
|
|
93
|
+
"top-center": {
|
|
94
|
+
top: "0",
|
|
95
|
+
left: "50%",
|
|
96
|
+
transform: "translateX(-50%)",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
},
|
|
99
|
+
"bottom-center": {
|
|
100
|
+
bottom: "0",
|
|
101
|
+
left: "50%",
|
|
102
|
+
transform: "translateX(-50%)",
|
|
103
|
+
alignItems: "center",
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
Object.assign(t.style, o[e] || o["bottom-right"]),
|
|
107
|
+
document.body.appendChild(t);
|
|
108
|
+
}
|
|
109
|
+
return t;
|
|
110
|
+
},
|
|
111
|
+
playNotificationSound({ play: e, src: t }) {
|
|
112
|
+
if (!e || !t) return;
|
|
113
|
+
new Audio(t).play().catch((e) => {});
|
|
114
|
+
},
|
|
115
|
+
showToast(e) {
|
|
116
|
+
const {
|
|
117
|
+
title: n = "",
|
|
118
|
+
description: a = "",
|
|
119
|
+
media: s,
|
|
120
|
+
buttons: r = [],
|
|
121
|
+
} = e;
|
|
122
|
+
const { style: l = {}, position: c, duration: d, branding: p } = t;
|
|
123
|
+
const m = this.createWrapper(c);
|
|
124
|
+
const f = document.createElement("div");
|
|
125
|
+
(f.className = "pinglet-toast"),
|
|
126
|
+
o++,
|
|
127
|
+
Object.assign(f.style, {
|
|
128
|
+
background: "#1f1f1f",
|
|
129
|
+
color: "#fff",
|
|
130
|
+
padding: "16px 20px",
|
|
131
|
+
borderRadius: "12px",
|
|
132
|
+
boxShadow: "0 6px 18px rgba(0,0,0,0.25)",
|
|
133
|
+
fontFamily: "'Inter', sans-serif",
|
|
134
|
+
fontSize: "14px",
|
|
135
|
+
lineHeight: "1.5",
|
|
136
|
+
maxWidth: "360px",
|
|
137
|
+
minWidth: "280px",
|
|
138
|
+
pointerEvents: "auto",
|
|
139
|
+
position: "relative",
|
|
140
|
+
opacity: "0",
|
|
141
|
+
transform: "none",
|
|
142
|
+
transition: "all 0.4s ease",
|
|
143
|
+
...(o >= 4 ? { opacity: 0.8, scale: 0.95 } : {}),
|
|
144
|
+
...l,
|
|
145
|
+
});
|
|
146
|
+
const g = document.createElement("span");
|
|
147
|
+
if (
|
|
148
|
+
((g.innerHTML = "×"),
|
|
149
|
+
Object.assign(g.style, {
|
|
150
|
+
position: "absolute",
|
|
151
|
+
top: "6px",
|
|
152
|
+
right: "10px",
|
|
153
|
+
cursor: "pointer",
|
|
154
|
+
fontSize: "18px",
|
|
155
|
+
color: "#aaa",
|
|
156
|
+
}),
|
|
157
|
+
(g.onclick = () => this.removeToast(f)),
|
|
158
|
+
f.appendChild(g),
|
|
159
|
+
s)
|
|
160
|
+
) {
|
|
161
|
+
if ("icon" === s.type) {
|
|
162
|
+
const e = document.createElement("div");
|
|
163
|
+
(e.innerHTML = `<span style="font-size:14px;margin-right:8px;">${s.src}</span><strong>${n}</strong>`),
|
|
164
|
+
f.appendChild(e);
|
|
165
|
+
} else if ("image" === s.type || "video" === s.type) {
|
|
166
|
+
const e = this.createMediaElement(s);
|
|
167
|
+
f.appendChild(e);
|
|
168
|
+
const t = document.createElement("div");
|
|
169
|
+
(t.innerHTML = `<strong>${n}</strong>`), f.appendChild(t);
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
const e = document.createElement("div");
|
|
173
|
+
(e.innerHTML = `<strong>${n}</strong>`), f.appendChild(e);
|
|
174
|
+
}
|
|
175
|
+
if (a) {
|
|
176
|
+
const e = document.createElement("div");
|
|
177
|
+
(e.textContent = a), (e.style.color = "#ccc"), f.appendChild(e);
|
|
178
|
+
}
|
|
179
|
+
if (r.length) {
|
|
180
|
+
const e = document.createElement("div");
|
|
181
|
+
Object.assign(e.style, {
|
|
182
|
+
display: "flex",
|
|
183
|
+
gap: "10px",
|
|
184
|
+
marginTop: "8px",
|
|
185
|
+
flexWrap: "wrap",
|
|
186
|
+
}),
|
|
187
|
+
r.forEach((t) => {
|
|
188
|
+
const n = document.createElement("button");
|
|
189
|
+
if (
|
|
190
|
+
((n.type = "button"),
|
|
191
|
+
(n.className = `pinglet-toast-btn-${o}`),
|
|
192
|
+
(n.textContent = t.text),
|
|
193
|
+
Object.assign(n.style, {
|
|
194
|
+
padding: "6px 12px",
|
|
195
|
+
background: "#333",
|
|
196
|
+
border: "1px solid #555",
|
|
197
|
+
color: "#fff",
|
|
198
|
+
borderRadius: "6px",
|
|
199
|
+
cursor: "pointer",
|
|
200
|
+
fontSize: "13px",
|
|
201
|
+
}),
|
|
202
|
+
t.onClick)
|
|
203
|
+
) {
|
|
204
|
+
if ("string" === typeof t.onClick)
|
|
205
|
+
try {
|
|
206
|
+
t.onClick = new Function(`return (${t.onClick})`)();
|
|
207
|
+
} catch (e) {
|
|
208
|
+
t.onClick = null;
|
|
209
|
+
}
|
|
210
|
+
"function" === typeof t.onClick &&
|
|
211
|
+
n.addEventListener("click", t.onClick);
|
|
212
|
+
}
|
|
213
|
+
e.appendChild(n);
|
|
214
|
+
}),
|
|
215
|
+
f.appendChild(e);
|
|
216
|
+
}
|
|
217
|
+
i ||
|
|
218
|
+
((i = document.createElement("div")),
|
|
219
|
+
(i.innerHTML = p.html),
|
|
220
|
+
Object.assign(i.style, {
|
|
221
|
+
fontSize: "11px",
|
|
222
|
+
color: "#888",
|
|
223
|
+
textAlign: "right",
|
|
224
|
+
fontFamily: "'Inter', sans-serif",
|
|
225
|
+
marginTop: "8px",
|
|
226
|
+
})),
|
|
227
|
+
m.appendChild(f),
|
|
228
|
+
i && m.appendChild(i),
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
(f.style.opacity = "1"), (f.style.transform = "translateX(0)");
|
|
231
|
+
}, 10);
|
|
232
|
+
let u = setTimeout(() => this.removeToast(f), d);
|
|
233
|
+
f.addEventListener("mouseenter", () => clearTimeout(u)),
|
|
234
|
+
f.addEventListener("mouseleave", () => {
|
|
235
|
+
u = setTimeout(() => removeToast(f), 2e3);
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
removeToast(e) {
|
|
239
|
+
e &&
|
|
240
|
+
((e.style.opacity = "0"),
|
|
241
|
+
(e.style.transform = "translateX(100%)"),
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
e.remove(), o--, 0 === o && i && (i.remove(), (i = null));
|
|
244
|
+
}, 400));
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
const s = {
|
|
248
|
+
init({ endpoint: e, configuredDomain: t, projectIds: n = [] }) {
|
|
249
|
+
const o = location.hostname.replace(/^www\./, "");
|
|
250
|
+
if (0 === t.length)
|
|
251
|
+
return void this._showPopup(
|
|
252
|
+
"Domain Configuration Error ",
|
|
253
|
+
"Please ensure you are running Pinglet on a valid domain.",
|
|
254
|
+
);
|
|
255
|
+
if (0 === n.length)
|
|
256
|
+
return void this._showPopup(
|
|
257
|
+
"Project Configuration Error ",
|
|
258
|
+
"Please add at least one project to your Pinglet configuration.",
|
|
259
|
+
);
|
|
260
|
+
t === o
|
|
261
|
+
? n.forEach((t) => {
|
|
262
|
+
new EventSource(
|
|
263
|
+
`${e}/sse?projectId=${encodeURIComponent(t)}`,
|
|
264
|
+
).onmessage = (e) => {
|
|
265
|
+
try {
|
|
266
|
+
const t = JSON.parse(e.data);
|
|
267
|
+
a.showToast({
|
|
268
|
+
title: t.title,
|
|
269
|
+
description: t.description,
|
|
270
|
+
media: t.media,
|
|
271
|
+
buttons: t.buttons,
|
|
272
|
+
});
|
|
273
|
+
} catch (e) {}
|
|
274
|
+
};
|
|
275
|
+
})
|
|
276
|
+
: this._showPopup(
|
|
277
|
+
"Domain Configuration Error ",
|
|
278
|
+
`Your current domain is not allowed. Please ensure it matches one of the following:\n ${t}`,
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
_showNotification(e) {
|
|
282
|
+
const {
|
|
283
|
+
title: t = "",
|
|
284
|
+
description: n = "",
|
|
285
|
+
buttons: o = [],
|
|
286
|
+
media: i = null,
|
|
287
|
+
style: a = {},
|
|
288
|
+
branding: s = {
|
|
289
|
+
show: !0,
|
|
290
|
+
html: 'Powered by <a href="https://pinglet.enjoys.in" style="color:#4da6ff;text-decoration:none;" target="_blank">Pinglet</a> - Enjoys',
|
|
291
|
+
},
|
|
292
|
+
} = e;
|
|
293
|
+
const r = this._getWrapper();
|
|
294
|
+
const l = document.createElement("div");
|
|
295
|
+
if (
|
|
296
|
+
((l.className = "pinglet-toast"),
|
|
297
|
+
Object.assign(l.style, {
|
|
298
|
+
background: "#1f1f1f",
|
|
299
|
+
color: "#fff",
|
|
300
|
+
padding: "16px 20px",
|
|
301
|
+
borderRadius: "12px",
|
|
302
|
+
boxShadow: "0 6px 18px rgba(0, 0, 0, 0.25)",
|
|
303
|
+
fontFamily: "'Inter', sans-serif",
|
|
304
|
+
minWidth: "260px",
|
|
305
|
+
maxWidth: "360px",
|
|
306
|
+
opacity: "0",
|
|
307
|
+
transform: "translateX(100%)",
|
|
308
|
+
transition: "opacity 0.3s ease, transform 0.3s ease",
|
|
309
|
+
display: "flex",
|
|
310
|
+
flexDirection: "column",
|
|
311
|
+
gap: "12px",
|
|
312
|
+
...a,
|
|
313
|
+
}),
|
|
314
|
+
i)
|
|
315
|
+
) {
|
|
316
|
+
if ("icon" === i.type) {
|
|
317
|
+
const e = document.createElement("div");
|
|
318
|
+
Object.assign(e.style, {
|
|
319
|
+
display: "flex",
|
|
320
|
+
alignItems: "center",
|
|
321
|
+
gap: "10px",
|
|
322
|
+
fontSize: "16px",
|
|
323
|
+
fontWeight: "600",
|
|
324
|
+
});
|
|
325
|
+
const n = document.createElement("span");
|
|
326
|
+
n.textContent = i.src;
|
|
327
|
+
const o = document.createElement("span");
|
|
328
|
+
(o.textContent = t),
|
|
329
|
+
e.appendChild(n),
|
|
330
|
+
e.appendChild(o),
|
|
331
|
+
l.appendChild(e);
|
|
332
|
+
} else if ("image" === i.type || "video" === i.type) {
|
|
333
|
+
const e = document.createElement(i.type);
|
|
334
|
+
Object.assign(e.style, { maxWidth: "100%", borderRadius: "8px" }),
|
|
335
|
+
(e.src = i.src),
|
|
336
|
+
"video" === i.type && (e.controls = !0),
|
|
337
|
+
l.appendChild(e);
|
|
338
|
+
const n = document.createElement("div");
|
|
339
|
+
(n.textContent = t),
|
|
340
|
+
Object.assign(n.style, { fontSize: "16px", fontWeight: "600" }),
|
|
341
|
+
l.appendChild(n);
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
const e = document.createElement("div");
|
|
345
|
+
(e.textContent = t),
|
|
346
|
+
Object.assign(e.style, { fontSize: "16px", fontWeight: "600" }),
|
|
347
|
+
l.appendChild(e);
|
|
348
|
+
}
|
|
349
|
+
if (n) {
|
|
350
|
+
const e = document.createElement("div");
|
|
351
|
+
(e.textContent = n),
|
|
352
|
+
Object.assign(e.style, {
|
|
353
|
+
fontSize: "13.5px",
|
|
354
|
+
color: "#ccc",
|
|
355
|
+
lineHeight: "1.5",
|
|
356
|
+
}),
|
|
357
|
+
l.appendChild(e);
|
|
358
|
+
}
|
|
359
|
+
if (Array.isArray(o) && o.length) {
|
|
360
|
+
const e = document.createElement("div");
|
|
361
|
+
Object.assign(e.style, {
|
|
362
|
+
display: "flex",
|
|
363
|
+
gap: "10px",
|
|
364
|
+
marginTop: "6px",
|
|
365
|
+
});
|
|
366
|
+
for (const t of o) {
|
|
367
|
+
const n = document.createElement("button");
|
|
368
|
+
(n.textContent = t.text || "Click"),
|
|
369
|
+
Object.assign(n.style, {
|
|
370
|
+
padding: "8px 14px",
|
|
371
|
+
background: "#333",
|
|
372
|
+
color: "#fff",
|
|
373
|
+
border: "1px solid #444",
|
|
374
|
+
borderRadius: "6px",
|
|
375
|
+
fontSize: "13px",
|
|
376
|
+
cursor: "pointer",
|
|
377
|
+
transition: "background 0.3s",
|
|
378
|
+
}),
|
|
379
|
+
(n.onmouseover = () => (n.style.background = "#444")),
|
|
380
|
+
(n.onmouseout = () => (n.style.background = "#333")),
|
|
381
|
+
"function" === typeof t.onClick && (n.onclick = t.onClick),
|
|
382
|
+
e.appendChild(n);
|
|
383
|
+
}
|
|
384
|
+
l.appendChild(e);
|
|
385
|
+
}
|
|
386
|
+
if ((r.appendChild(l), !1 !== s?.show)) {
|
|
387
|
+
const e = document.createElement("div");
|
|
388
|
+
(e.innerHTML = s?.html || ""),
|
|
389
|
+
Object.assign(e.style, {
|
|
390
|
+
fontSize: "11px",
|
|
391
|
+
color: "#999",
|
|
392
|
+
marginTop: "4px",
|
|
393
|
+
textAlign: "right",
|
|
394
|
+
fontFamily: "'Inter', sans-serif",
|
|
395
|
+
}),
|
|
396
|
+
r.appendChild(e),
|
|
397
|
+
setTimeout(() => {
|
|
398
|
+
l.remove(), e.remove();
|
|
399
|
+
}, 5e3);
|
|
400
|
+
} else setTimeout(() => l.remove(), 5e3);
|
|
401
|
+
requestAnimationFrame(() => {
|
|
402
|
+
(l.style.opacity = "1"), (l.style.transform = "translateX(0)");
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
_showPopup(
|
|
406
|
+
e,
|
|
407
|
+
t,
|
|
408
|
+
n = [
|
|
409
|
+
{
|
|
410
|
+
text: "See Docs",
|
|
411
|
+
onClick: () =>
|
|
412
|
+
window.open("https://pinglet.enjoys.in/docs", "_blank"),
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
o = "⚠️",
|
|
416
|
+
) {
|
|
417
|
+
const i = "toastContainer";
|
|
418
|
+
let a = document.getElementById(i);
|
|
419
|
+
a ||
|
|
420
|
+
((a = document.createElement("div")),
|
|
421
|
+
(a.id = i),
|
|
422
|
+
Object.assign(a.style, {
|
|
423
|
+
position: "fixed",
|
|
424
|
+
bottom: "24px",
|
|
425
|
+
right: "24px",
|
|
426
|
+
zIndex: "9999",
|
|
427
|
+
display: "flex",
|
|
428
|
+
flexDirection: "column",
|
|
429
|
+
gap: "4px",
|
|
430
|
+
alignItems: "flex-end",
|
|
431
|
+
}),
|
|
432
|
+
document.body.appendChild(a));
|
|
433
|
+
const s = document.createElement("div");
|
|
434
|
+
Object.assign(s.style, {
|
|
435
|
+
background: "#1f1f1f",
|
|
436
|
+
color: "#fff",
|
|
437
|
+
padding: "16px 20px",
|
|
438
|
+
borderRadius: "12px",
|
|
439
|
+
boxShadow: "0 6px 18px rgba(0, 0, 0, 0.25)",
|
|
440
|
+
fontFamily: "'Inter', sans-serif",
|
|
441
|
+
minWidth: "260px",
|
|
442
|
+
maxWidth: "340px",
|
|
443
|
+
opacity: "0",
|
|
444
|
+
transform: "translateX(100%)",
|
|
445
|
+
transition: "opacity 0.3s ease, transform 0.3s ease",
|
|
446
|
+
display: "flex",
|
|
447
|
+
flexDirection: "column",
|
|
448
|
+
gap: "10px",
|
|
449
|
+
});
|
|
450
|
+
const r = document.createElement("div");
|
|
451
|
+
Object.assign(r.style, {
|
|
452
|
+
display: "flex",
|
|
453
|
+
alignItems: "center",
|
|
454
|
+
gap: "10px",
|
|
455
|
+
fontSize: "16px",
|
|
456
|
+
fontWeight: "600",
|
|
457
|
+
});
|
|
458
|
+
const l = document.createElement("div");
|
|
459
|
+
l.textContent = o;
|
|
460
|
+
const c = document.createElement("div");
|
|
461
|
+
if (
|
|
462
|
+
((c.textContent = e),
|
|
463
|
+
r.appendChild(l),
|
|
464
|
+
r.appendChild(c),
|
|
465
|
+
s.appendChild(r),
|
|
466
|
+
t)
|
|
467
|
+
) {
|
|
468
|
+
const e = document.createElement("div");
|
|
469
|
+
(e.textContent = t),
|
|
470
|
+
Object.assign(e.style, {
|
|
471
|
+
fontSize: "13.5px",
|
|
472
|
+
fontWeight: "400",
|
|
473
|
+
color: "#ddd",
|
|
474
|
+
lineHeight: "1.5",
|
|
475
|
+
}),
|
|
476
|
+
s.appendChild(e);
|
|
477
|
+
}
|
|
478
|
+
if (Array.isArray(n) && n.length) {
|
|
479
|
+
const e = document.createElement("div");
|
|
480
|
+
Object.assign(e.style, {
|
|
481
|
+
marginTop: "8px",
|
|
482
|
+
display: "flex",
|
|
483
|
+
gap: "10px",
|
|
484
|
+
justifyContent: "flex-start",
|
|
485
|
+
});
|
|
486
|
+
for (const t of n) {
|
|
487
|
+
const n = document.createElement("button");
|
|
488
|
+
(n.textContent = t.text || "Click"),
|
|
489
|
+
Object.assign(n.style, {
|
|
490
|
+
padding: "8px 14px",
|
|
491
|
+
background: "#333",
|
|
492
|
+
color: "#fff",
|
|
493
|
+
border: "1px solid #444",
|
|
494
|
+
borderRadius: "6px",
|
|
495
|
+
fontSize: "13px",
|
|
496
|
+
cursor: "pointer",
|
|
497
|
+
transition: "background 0.3s",
|
|
498
|
+
}),
|
|
499
|
+
(n.onmouseover = () => (n.style.background = "#444")),
|
|
500
|
+
(n.onmouseout = () => (n.style.background = "#333")),
|
|
501
|
+
"function" === typeof t.onClick &&
|
|
502
|
+
n.addEventListener("click", t.onClick),
|
|
503
|
+
e.appendChild(n);
|
|
504
|
+
}
|
|
505
|
+
s.appendChild(e);
|
|
506
|
+
}
|
|
507
|
+
a.appendChild(s);
|
|
508
|
+
const d = document.createElement("div");
|
|
509
|
+
(d.innerHTML =
|
|
510
|
+
'Powered by <a href="https://pinglet.enjoys.in" target="_blank" style="color:#4da6ff;text-decoration:none;">Pinglet</a> - Enjoys'),
|
|
511
|
+
Object.assign(d.style, {
|
|
512
|
+
fontSize: "11px",
|
|
513
|
+
color: "#999",
|
|
514
|
+
marginTop: "4px",
|
|
515
|
+
textAlign: "right",
|
|
516
|
+
fontFamily: "'Inter', sans-serif",
|
|
517
|
+
}),
|
|
518
|
+
a.appendChild(d),
|
|
519
|
+
requestAnimationFrame(() => {
|
|
520
|
+
(s.style.opacity = "1"), (s.style.transform = "translateX(0)");
|
|
521
|
+
}),
|
|
522
|
+
setTimeout(() => {
|
|
523
|
+
(s.style.opacity = "0"),
|
|
524
|
+
(s.style.transform = "translateX(100%)"),
|
|
525
|
+
setTimeout(() => {
|
|
526
|
+
s.remove(), d.remove();
|
|
527
|
+
}, 500);
|
|
528
|
+
}, 5e3);
|
|
529
|
+
},
|
|
530
|
+
_getWrapper() {
|
|
531
|
+
let e = document.getElementById("pinglet-wrapper");
|
|
532
|
+
return (
|
|
533
|
+
e ||
|
|
534
|
+
((e = document.createElement("div")),
|
|
535
|
+
(e.id = "pinglet-wrapper"),
|
|
536
|
+
(e.style =
|
|
537
|
+
"position:fixed;bottom:20px;right:20px;z-index:99999;display:flex;flex-direction:column;gap:10px;max-width:300px;font-family:sans-serif"),
|
|
538
|
+
document.body.appendChild(e)),
|
|
539
|
+
e
|
|
540
|
+
);
|
|
541
|
+
},
|
|
542
|
+
_addBranding(e) {
|
|
543
|
+
if (!document.getElementById("pinglet-brand")) {
|
|
544
|
+
const t = document.createElement("div");
|
|
545
|
+
(t.id = "pinglet-brand"),
|
|
546
|
+
(t.style =
|
|
547
|
+
"font-size:10px;text-align:right;color:#aaa;margin-top:8px"),
|
|
548
|
+
(t.innerHTML = "Powered by <strong>Pinglet</strong> – Enjoys"),
|
|
549
|
+
e.appendChild(t);
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
};
|
|
553
|
+
e.PingletWidget = s;
|
|
554
|
+
})(window);
|
|
555
|
+
})();
|