1import{m as J}from"./module.esm-4RGrT4Zt.js";const W="app-toast-root",X=()=>{let t=document.getElementById(W);return t||(t=document.createElement("div"),t.id=W,t.className="pointer-events-none fixed inset-0 z-50 flex flex-col items-center justify-start p-4 lg:p-6 gap-3 pt-6",document.body.appendChild(t),t)},ot=()=>{const t=[],e=document.getElementById("bellBtn");return e&&t.push(e),t},K=t=>{ot().forEach(t)},at=t=>{const e=(t??"").toLowerCase().split(/[-_]/)[0];return["ar","he","fa","ur"].includes(e)},Y=()=>{var e,n;return((n=(e=document.documentElement)==null?void 0:e.getAttribute("lang"))==null?void 0:n.trim())||"en"},it=()=>{const t=document.getElementById("cpiInterstitialContainer");if(!t)return!1;const e=window.getComputedStyle(t);return e.display!=="none"&&e.visibility!=="hidden"&&t.getAttribute("aria-hidden")!=="true"},rt="notification-card-template",st=()=>document.getElementById(rt),lt=()=>{var n,o;const t=st(),e=(o=(n=t==null?void 0:t.content)==null?void 0:n.firstElementChild)==null?void 0:o.cloneNode(!0);return e&&e.removeAttribute("id"),e||null},ct=t=>{if(!t)return;const e=Number(t.dataset.autoHideId??"");Number.isFinite(e)&&(clearTimeout(e),delete t.dataset.autoHideId)},A=t=>{!t||!t.parentElement||(ct(t),dt(t),t.style.opacity="0",t.style.transform="translateY(12px)",t.classList.add("pointer-events-none"),setTimeout(()=>{t.remove()},250))},dt=t=>{const e=t==null?void 0:t.__stpFloatingReposition;e&&(window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0),delete t.__stpFloatingReposition)},ut=t=>{if(!t||!t.isConnected)return;const e=S();if(!e){t.style.top="1rem",t.style.left="50%",t.style.transform="translateX(-50%)";return}const n=e.getBoundingClientRect(),o=window.innerWidth||document.documentElement.clientWidth||0,a=t.getBoundingClientRect(),s=Math.max(0,o-24),i=Math.min(a.width||0,s)||Math.max(280,Math.min(352,s)),y=Math.round(n.left+n.width/2-i/2),d=Math.max(12,Math.min(y,Math.max(12,o-i-12))),m=Math.max(12,Math.round(n.bottom+12)),g=Math.max(18,Math.min(n.left+n.width/2-d,i-18));t.style.top=`${m}px`,t.style.left=`${d}px`,t.style.transform="none",t.style.width=`${i}px`,t.style.maxWidth=`${s}px`;const u=t.querySelector("[data-notif-pointer]");u&&(u.style.left=`${Math.round(g)}px`)},ft=t=>{const e=()=>ut(t);t.__stpFloatingReposition=e,window.addEventListener("resize",e,{passive:!0}),window.addEventListener("scroll",e,{passive:!0,capture:!0}),e()};let v=null;const mt=()=>{if(v)return v;const t=window.AudioContext||window.webkitAudioContext;if(!t)return null;try{return v=new t,v}catch{return null}},pt=t=>{const e=t.createOscillator();e.type="triangle",e.frequency.value=720;const n=t.createGain();n.gain.setValueAtTime(1e-4,t.currentTime),n.gain.linearRampToValueAtTime(.18,t.currentTime+.02),n.gain.exponentialRampToValueAtTime(1e-4,t.currentTime+.3),e.connect(n),n.connect(t.destination),e.start(),e.stop(t.currentTime+.32)},yt=t=>{const e=(t??"").trim();if(!e)return{symbol:"",amount:""};const[,n="",o=""]=e.match(/^([^0-9]*)(.*)$/)??[];return{symbol:n,amount:o.trim()}},gt=(t,e={})=>{if(!t)return null;const{id:n,title:o,body:a,time:s,link:i,language:y,icon:d,type:m,payment_amount:g,new_label:u,is_unread:E,read_url:p,cta_id:_,cta_offer_id:r,cta_label:h}=e,l=t.querySelector("[data-notif-time]"),c=t.querySelector("[data-notif-title]"),q=t.querySelector("[data-notif-body]"),f=t.querySelector("[data-notif-cta]"),w=t.querySelector("[data-notif-new-label]"),k=t.querySelector("[data-notif-icon]"),F=t.querySelector("[data-notif-icon-wrapper]"),U=t.querySelector("[data-notif-fallback]"),$=t.querySelector("[data-notif-survey]"),D=t.querySelector("[data-notif-payment-symbol]"),O=t.querySelector("[data-notif-payment-amount]"),x=t.querySelector("button");l&&(l.textContent=s??""),c&&(c.textContent=o??""),q&&(q.textContent=a??""),f&&(f.href=i??"#",_?f.id=_:f.removeAttribute("id"),r?f.dataset.offerId=r:f.removeAttribute("data-offer-id"),h&&(f.textContent=h)),x&&(p?x.dataset.notificationReadUrl=p:x.removeAttribute("data-notification-read-url")),w&&(E&&u?(w.textContent=u,w.classList.remove("hidden")):(w.textContent="",w.classList.add("hidden")));const T=yt(g),N=(m??"").toLowerCase()==="survey"&&T.amount!=="";$&&$.classList.toggle("hidden",!N),D&&(D.textContent=T.symbol),O&&(O.textContent=T.amount);const P=!N&&!!d;return F&&F.classList.toggle("hidden",!P),k&&(k.src=d??""),U&&U.classList.toggle("hidden",P||N),t.dataset.notificationId=n??"",t.dataset.notificationType=m??"",t.style.direction=at(y)?"rtl":"ltr",t};function M({id:t=null,title:e="Notification",body:n="",time:o="Now",link:a="#",language:s="en",duration:i=-1,icon:y="",type:d="",payment_amount:m="",read_url:g="",is_unread:u=!1,new_label:E="",floating:p=!1}={}){if(!e&&!n)return null;const _=X(),r=lt();if(!r)return null;if(gt(r,{id:t,title:e,body:n,time:o,link:a,language:s,icon:y,type:d,payment_amount:m,new_label:E,is_unread:u,read_url:g}),r.style.opacity="0",r.style.transform="translateY(12px)",r.style.transition="opacity 0.25s ease, transform 0.25s ease",r.dataset.notificationFloating=p?"true":"false",_.appendChild(r),r.classList.add("pointer-events-auto"),p&&ft(r),i!==-1){const c=setTimeout(()=>{A(r)},i);r.dataset.autoHideId=c.toString()}const h=r.querySelector("[data-notif-cta]");h&&h.addEventListener("click",()=>{et(t).catch(()=>{}).finally(()=>{b()})});const l=r.querySelector("button");return l&&p?l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),nt(l)}):l&&!l.dataset.notificationReadUrl&&l.addEventListener("click",c=>{c.preventDefault(),A(r)}),requestAnimationFrame(()=>{r.style.opacity="1",r.style.transform="translateY(0)"}),Z(),vt(),r}const C={Accept:"application/json","X-Requested-With":"XMLHttpRequest"},S=()=>document.getElementById("bellBtn"),G=()=>{const t=S();return(t==null?void 0:t.dataset.countUrl)??(t==null?void 0:t.dataset.unreadUrl)??null},Q=()=>{const t=S();return(t==null?void 0:t.dataset.latestUrl)??null},ht=(t,e)=>{var o;if(!t)return t;const n=typeof e=="string"?e.trim():"";if(!n)return t;try{const a=((o=globalThis==null?void 0:globalThis.location)==null?void 0:o.origin)??"",s=new URL(t,a);return s.searchParams.set("language",n),s.toString()}catch{const s=t.includes("?")?"&":"?";return`${t}${s}language=${encodeURIComponent(n)}`}},wt=t=>{const e=S(),n=e==null?void 0:e.dataset.readUrlBase;return n?n.replace(/\/0(?=\/|$)/,`/${t}`):null},bt=t=>{if(!t)return"Just now";const e=t.replace(" ","T"),n=new Date(e);if(Number.isNaN(n.getTime()))return"Just now";const o=Math.floor((Date.now()-n.getTime())/6e4);if(o<1)return"Just now";if(o<60)return`${o}m ago`;const a=Math.floor(o/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`};let z=0,R=null,H=null;const L=new Map,_t=t=>{const e=Math.max(0,Number.isFinite(+t)?+t:0);K(n=>
1{n.setAttribute("data-count",String(e)),n.dataset.hasUnread=e>0?"true":"false",n.classList.remove("border-main-500/35","bg-[linear-gradient(180deg,#ff8b32,#ff6a0a)]","shadow-[0_14px_30px_rgba(255,106,10,0.35)]","hover:shadow-[0_16px_34px_rgba(255,106,10,0.42)]","bg-main-500"),e>0&&n.classList.add("border-main-500/35","bg-[linear-gradient(180deg,#ff8b32,#ff6a0a)]","shadow-[0_14px_30px_rgba(255,106,10,0.35)]","hover:shadow-[0_16px_34px_rgba(255,106,10,0.42)]")})},Z=()=>{K(t=>{t.classList.add("text-white","bell-pulse","transition","duration-300"),setTimeout(()=>{t.classList.remove("bell-pulse")},2e3)})},tt=async()=>{const t=mt();if(t){if(t.state==="suspended")try{await t.resume()}catch{}pt(t)}},vt=async()=>{await tt()},et=async t=>{var a;if(t==null||t==="")return;const e=wt(t);if(!e)return;if(L.has(t))return L.get(t);const n=((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))??"",o=fetch(e,{method:"POST",credentials:"same-origin",headers:{...C,"X-CSRF-TOKEN":n}}).finally(()=>{L.delete(t)});return L.set(t,o),o},Lt=t=>{const e=X(),n=t.title??e.dataset.title??"Notification",o=t.body_or_subject??e.dataset.body??"",a=t.url??e.dataset.link??"#",s=e.dataset.language??"en",i=e.dataset.newLabel??"";M({id:t.id,title:n,body:o,time:bt(t.created_at),link:a,language:s,duration:-1,icon:t.icon,type:t.type,payment_amount:t.payment_amount,read_url:t.read_url,is_unread:!!t.is_unread,new_label:i,cta_id:t.cta_id,cta_offer_id:t.cta_offer_id,cta_label:t.cta_label,floating:!0})},B=async()=>{const t=Q();if(!t)return;const e=Y(),n=ht(t,e);if(n&&!it())try{const o=await fetch(n,{credentials:"same-origin",headers:C,cache:"no-store"});if(!o.ok)return;const a=await o.json(),s=Array.isArray(a==null?void 0:a.items)?a.items:[];if(!s.length){R=null;return}const i=s[0];if(!i||!i.id||i.id===R||(R=i.id,!i.is_unread)||i.id===H)return;H=i.id,Lt(i)}catch{}},b=async()=>{const t=G();if(t)try{const e=await fetch(t,{credentials:"same-origin",headers:C,cache:"no-store"});if(!e.ok)return;const n=await e.json(),o=Number.isFinite(+n.count)?+n.count:0;o>z&&o>0&&Z(),z=o,_t(o)}catch{}},Ct=async t=>{var n;const e=((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))??"";return fetch(t,{method:"POST",credentials:"same-origin",headers:{...C,"X-CSRF-TOKEN":e}})},nt=async t=>{if(!t)return;const e=t.closest("[data-notification-card]"),n=t.dataset.notificationReadUrl;if(A(e),n)try{await Ct(n)}catch(o){console.error("Failed to mark notification as read",o)}else if(e!=null&&e.dataset.notificationId)try{await et(e.dataset.notificationId)}catch(o){console.error("Failed to mark notification as read",o)}b()};document.addEventListener("click",t=>{const e=t.target.closest("[data-notification-read-url]");if(!e)return;const n=e.closest("[data-notification-card]");(n==null?void 0:n.dataset.notificationFloating)==="true"&&(t.preventDefault(),nt(e))});let V=!1;const j=()=>
1{if(V)return;const t=!!G(),e=!!Q();!t&&!e||(V=!0,t&&(b(),setInterval(b,3e4)),e&&(B(),setInterval(B,3e4)))};window.addEventListener("notifications:refresh",()=>{b(),B()});document.readyState==="loading"?document.addEventListener("DOMContentLoaded",j):j();window.showToast=({message:t="",variant:e="info",duration:n=-1}={})=>t?M({title:"Notification",body:t,time:"Just now",link:"#",language:Y(),duration:n,floating:!1}):null;window.showStpNotification=M;window.playBellSound=tt;window.dispatchEvent(new CustomEvent("toast-helper-ready"));const I=()=>{const t=Array.isArray(window.toastMessages)?window.toastMessages:[];t.length&&(t.forEach(e=>{window.showToast({message:e.message,variant:e.variant,duration:e.duration??-1})}),window.toastMessages=[])};window.addEventListener("toast-messages-ready",I);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",I):I();window.Alpine=J;J.start();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.