import"./modulepreload-polyfill-B5Qt9EMX.js";import"./chat-D8AdooBl.js";import"./helper-DXqZhEQG.js";import"./clsx-B-dksMZM.js";import"./ChatBox-TTykackF.js";import"./index-DjzpbRFi.js";import"./this-BsquiCOI.js";import"./axios-B7x57NPv.js";class m{constructor(){this.actions=[],this.startTime=new Date().getTime(),this.setupListeners(),this.fillFormFieldsFromUrl()}setupListeners(){document.addEventListener("click",o=>this.trackClick(o)),document.addEventListener("submit",o=>this.trackFormSubmission(o)),window.addEventListener("beforeunload",()=>this.saveActions())}async sha256Hash(o){const r=new TextEncoder().encode(o),a=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join("")}trackClick(o){var s,c;const n=o.target.closest("a");if(!n)return;const r=n.getAttribute("href");if(!r||r==="#")return;const a={type:"click",timestamp:new Date().getTime(),timeOnPage:new Date().getTime()-this.startTime,element:{tagName:n.tagName,id:n.id||null,className:n.className||null,text:((s=n.textContent)==null?void 0:s.trim().substring(0,50))||null},path:window.location.pathname,position:{x:o.clientX,y:o.clientY}},e=(c=document.head.querySelector('meta[name="click_event"]'))==null?void 0:c.content;if(e&&e!=="undefined"){if(typeof fbq=="function")try{e==="Purchase"?fbq("track",e,{value:0,currency:"IDR"}):e==="StartTrial"?fbq("track",e,{value:"0.00",currency:"IDR",predicted_ltv:"0.00"}):fbq("track",e),console.log(`Meta Pixel click event triggered: ${e}`)}catch(t){console.error(`Error triggering Meta Pixel click event: ${t}`)}if(typeof ttq<"u")try{const d={Purchase:"CompletePayment",AddToCart:"AddToCart",InitiateCheckout:"StartCheckout",AddPaymentInfo:"AddPaymentInfo",CompleteRegistration:"CompleteRegistration",Contact:"Contact",Lead:"SubmitForm",Search:"Search",ViewContent:"ViewContent",Subscribe:"Subscribe"}[e]||e;e==="Purchase"?ttq.track(d,{content_type:"product",content_id:window.location.pathname,currency:"IDR",value:0}):ttq.track(d),console.log(`TikTok Pixel click event triggered: ${d}`)}catch(t){console.error(`Error triggering TikTok Pixel click event: ${t}`)}if(typeof twq<"u")try{const t={Purchase:"tw-o03t1-oer0j",AddToCart:"tw-o03t1-oer0i",InitiateCheckout:"tw-o03t1-oer0h",Lead:"tw-o03t1-oer0e",CompleteRegistration:"tw-o03t1-oer0f",ViewContent:"tw-o03t1-oer0g"};t[e]?(twq("event",t[e],{value:e==="Purchase"?0:void 0,currency:e==="Purchase"?"IDR":void 0,content_ids:[window.location.pathname]}),console.log(`Twitter Pixel click event triggered: ${t[e]}`)):(twq("event",e),console.log(`Twitter Pixel custom click event triggered: ${e}`))}catch(t){console.error(`Error triggering Twitter Pixel click event: ${t}`)}}this.logAction(a)}async trackFormSubmission(o){var c;const n=o.target,r=new FormData(n),a={};for(let[t,d]of r.entries())a[t]=d;const e={type:"form_submit",timestamp:new Date().getTime(),timeOnPage:new Date().getTime()-this.startTime,element:{tagName:"FORM",id:n.id||null,className:n.className||null,action:n.action||null,fields:a},path:window.location.pathname},s=(c=document.head.querySelector('meta[name="submit_event"]'))==null?void 0:c.content;if(s&&s!=="undefined"){if(typeof fbq=="function")try{const t={content_name:document.title||window.location.pathname,content_category:"form_submission"};s==="Purchase"?(t.value=a.value||a.amount||a.price||0,t.currency=a.currency||"IDR"):s==="StartTrial"&&(t.value=a.value||a.amount||a.price||0,t.currency=a.currency||"IDR",t.predicted_ltv=a.predicted_ltv||a.ltv||"0.00"),fbq("track",s,t),console.log(`Meta Pixel form event triggered: ${s}`,t)}catch(t){console.error(`Error triggering Meta Pixel form event: ${t}`)}if(typeof ttq<"u")try{const d={Purchase:"CompletePayment",AddToCart:"AddToCart",InitiateCheckout:"StartCheckout",AddPaymentInfo:"AddPaymentInfo",CompleteRegistration:"CompleteRegistration",Contact:"Contact",Lead:"SubmitForm",Search:"Search",ViewContent:"ViewContent",Subscribe:"Subscribe"}[s]||s,l={content_name:document.title||window.location.pathname};s==="Purchase"&&(l.content_type="product",l.content_id=r.product_id||r.id||window.location.pathname,l.currency=r.currency||"IDR",l.value=r.value||r.amount||r.price||0),ttq.track(d,l),console.log(`TikTok Pixel form event triggered: ${d}`,l)}catch(t){console.error(`Error triggering TikTok Pixel form event: ${t}`)}if(typeof twq<"u")try{const t={Purchase:"tw-o03t1-oer0j",AddToCart:"tw-o03t1-oer0i",InitiateCheckout:"tw-o03t1-oer0h",Lead:"tw-o03t1-oer0e",CompleteRegistration:"tw-o03t1-oer0f",ViewContent:"tw-o03t1-oer0g"},d={content_name:document.title||window.location.pathname};s==="Purchase"?(d.value=r.value||r.amount||r.price||0,d.currency=r.currency||"IDR",d.content_ids=[r.product_id||r.id||window.location.pathname]):d.content_ids=[window.location.pathname],t[s]?(twq("event",t[s],d),console.log(`Twitter Pixel form event triggered: ${t[s]}`,d)):(twq("event",s,d),console.log(`Twitter Pixel custom form event triggered: ${s}`,d))}catch(t){console.error(`Error triggering Twitter Pixel form event: ${t}`)}}this.logAction(e)}trackInputChange(o){const n=o.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"){const r={type:"input_change",timestamp:new Date().getTime(),timeOnPage:new Date().getTime()-this.startTime,element:{tagName:n.tagName,id:n.id||null,className:n.className||null,inputType:n.type||null,name:n.name||null}};this.logAction(r)}}logAction(o){this.actions.push(o),this.sendToServer(o)}async sendToServer(o){var n,r,a;try{o.page_id=(n=document.head.querySelector('meta[name="page_id"]'))==null?void 0:n.content,o.user_id=(r=document.head.querySelector('meta[name="user_id"]'))==null?void 0:r.content,o.slug=(a=document.head.querySelector('meta[name="slug"]'))==null?void 0:a.content;const e=await fetch("/api/log-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});e.ok||console.error("Failed to log action:",e.statusText)}catch(e){console.error("Error logging action:",e)}}saveActions(){localStorage.setItem("pendingActions",JSON.stringify(this.actions))}fillFormFieldsFromUrl(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this._fillFormFields()):this._fillFormFields()}_fillFormFields(){const o=new URLSearchParams(window.location.search);if(o.toString()==="")return;document.querySelectorAll("form").forEach(r=>{for(const[a,e]of o.entries())r.querySelectorAll(`[name="${a}"], #${a}`).forEach(c=>{c.tagName==="INPUT"?c.type==="checkbox"||c.type==="radio"?c.value===e&&(c.checked=!0):c.value=e:(c.tagName==="SELECT"||c.tagName==="TEXTAREA")&&(c.value=e)})})}}new m;if(document.body.getAttribute("status")=="draft"){const i=``;setInterval(()=>{document.querySelector("#banner-draft")?(document.querySelector("#banner-draft").classList.contains("hidden")||document.querySelector("#banner-draft").style.display=="none"||document.querySelector("#banner-draft").style.visibility=="hidden"||document.querySelector("#banner-draft").style.opacity=="0"||document.querySelector("#banner-draft").style.zIndex=="-1")&&document.body.insertAdjacentHTML("beforeend",i):document.body.insertAdjacentHTML("beforeend",i)},3e3)}if(document.querySelector("meta[name='watermark']").getAttribute("content")=="1"){const i=``;setInterval(()=>{document.querySelector("#banner-draft")?(document.querySelector("#banner-draft").classList.contains("hidden")||document.querySelector("#banner-draft").style.display=="none"||document.querySelector("#banner-draft").style.visibility=="hidden"||document.querySelector("#banner-draft").style.opacity=="0"||document.querySelector("#banner-draft").style.zIndex=="-1")&&document.body.insertAdjacentHTML("beforeend",i):document.body.insertAdjacentHTML("beforeend",i)},3e3)}if(document.body.getAttribute("status")=="draft"){const i=``;setInterval(()=>{document.querySelector("#banner-draft")?(document.querySelector("#banner-draft").classList.contains("hidden")||document.querySelector("#banner-draft").style.display=="none"||document.querySelector("#banner-draft").style.visibility=="hidden"||document.querySelector("#banner-draft").style.opacity=="0"||document.querySelector("#banner-draft").style.zIndex=="-1")&&document.body.insertAdjacentHTML("beforeend",i):document.body.insertAdjacentHTML("beforeend",i)},3e3)}