!function(){"use strict";var e="G-TPYJL70Q9M",t=document.createElement("script");function a(){dataLayer.push(arguments)}t.async=!0,t.src="https://www.googletagmanager.com/gtag/js?id="+e,document.head.appendChild(t),window.dataLayer=window.dataLayer||[],window.gtag=a,a("js",new Date);var n={},o=new URLSearchParams(window.location.search);if(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gbraid","wbraid","fbclid"].forEach(function(e){var t=o.get(e);t&&(n[e]=t)}),Object.keys(n).length>0)try{sessionStorage.setItem("atlas_utm",JSON.stringify(n))}catch(e){}else try{var i=sessionStorage.getItem("atlas_utm");i&&(n=JSON.parse(i))}catch(e){}var r=n.utm_source||"direct";if(!n.utm_source&&document.referrer)try{var s=new URL(document.referrer);r=s.hostname.indexOf("google")>=0?"google_organic":s.hostname.indexOf("facebook")>=0||s.hostname.indexOf("fb.")>=0?"facebook_organic":s.hostname.indexOf("instagram")>=0?"instagram":s.hostname.indexOf("tiktok")>=0?"tiktok":s.hostname.indexOf("twitter")>=0||s.hostname.indexOf("x.com")>=0?"twitter":s.hostname}catch(e){}if(a("config",e,{page_title:document.title,page_location:window.location.href,send_page_view:!0,campaign_source:n.utm_source||void 0,campaign_medium:n.utm_medium||void 0,campaign_name:n.utm_campaign||void 0,campaign_content:n.utm_content||void 0,campaign_term:n.utm_term||void 0,traffic_source_detail:r,page_type:c(),cookie_flags:"SameSite=None;Secure",allow_google_signals:!0,allow_ad_personalization_signals:!0}),n.gclid)try{sessionStorage.setItem("atlas_gclid",n.gclid)}catch(e){}function c(){var e=window.location.pathname;return"/"===e||"/index.html"===e?"landing_page":e.indexOf("generate")>=0?"generator":e.indexOf("checkout")>=0?"checkout":e.indexOf("success")>=0?"success":e.indexOf("studio")>=0?"studio":e.indexOf("editor")>=0?"editor":e.indexOf("admin")>=0?"admin":e.indexOf("dashboard")>=0?"dashboard":"other"}window.atlasTrack=function(e,t){(t=t||{}).traffic_source=r,t.page_type=c(),n.utm_campaign&&(t.campaign=n.utm_campaign),n.gclid&&(t.gclid=n.gclid),a("event",e,t),b(e,t),("localhost"===window.location.hostname||t._debug)&&console.log("[ATLAS Analytics]",e,t)};var d={25:!1,50:!1,75:!1,100:!1},l=!1;window.addEventListener("scroll",function(){l||(requestAnimationFrame(function(){var e=window.pageYOffset||document.documentElement.scrollTop,t=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)-window.innerHeight;if(t<=0)l=!1;else{var n=Math.round(e/t*100);[25,50,75,100].forEach(function(e){n>=e&&!d[e]&&(d[e]=!0,a("event","scroll_depth",{percent_scrolled:e,page_type:c()}))}),l=!1}}),l=!0)},{passive:!0});var u=Date.now(),g={10:!1,30:!1,60:!1,120:!1,300:!1};setInterval(function(){var e=Math.floor((Date.now()-u)/1e3);[10,30,60,120,300].forEach(function(t){e>=t&&!g[t]&&(g[t]=!0,a("event","time_on_page",{seconds:t,page_type:c()}))})},5e3);var m=!1;document.addEventListener("input",function(e){"bizName"!==e.target.id||m||e.target.value.trim().length>=3&&(m=!0,window.atlasTrack("atlas_engaged",{engagement_type:"business_name_typed",name_length:e.target.value.trim().length}))},!0),document.addEventListener("click",function(e){var t=e.target.closest("button, .btn, [data-track], a.bb, .exb");if(t){var n=t.dataset.track||t.id||t.textContent.trim().substring(0,40);"buildBtn"===t.id||n.indexOf("Build My Website")>=0?window.atlasTrack("atlas_build_started",{has_place_data:!!document.querySelector('.sel-place[style*="flex"]'),has_ace_data:!!document.querySelector('#aceInfo[style*="block"]'),files_count:document.querySelectorAll(".fc").length}):"chatBtn"===t.id||n.indexOf("Chat")>=0?window.atlasTrack("atlas_chat_opened",{}):"uploadBtn"===t.id?window.atlasTrack("atlas_upload_clicked",{}):a("event","button_click",{button_name:n,page_type:c()})}},!0),document.addEventListener("change",function(e){"fileInput"===e.target.id&&e.target.files&&e.target.files.length>0&&window.atlasTrack("atlas_files_uploaded",{file_count:e.target.files.length,file_types:Array.from(e.target.files).map(function(e){return e.name.split(".").pop().toLowerCase()}).join(",")})},!0);var _=document.getElementById("selPlaceBadge");if(_&&new MutationObserver(function(e){e.forEach(function(e){"selPlaceBadge"===e.target.id&&"none"!==e.target.style.display&&window.atlasTrack("atlas_place_selected",{has_address:e.target.innerHTML.indexOf("sel-place-addr")>-1,has_phone:e.target.innerHTML.indexOf("sel-place-phone")>-1})})}).observe(_,{attributes:!0,attributeFilter:["style"]}),"generator"===c()){window.atlasTrack("atlas_generate_started",{session:o.get("session")||"unknown"});var f=new MutationObserver(function(){document.querySelector('a[href*="checkout"], a[href*="studio"], .progress-complete, [data-status="complete"]')&&(window.atlasTrack("atlas_generate_complete",{}),f.disconnect())});f.observe(document.body,{childList:!0,subtree:!0})}if("checkout"===c()&&(window.atlasTrack("atlas_checkout_started",{session:o.get("session")||"unknown"}),document.addEventListener("click",function(e){if(e.target.closest("[data-domain], .domain-option, .domain-card")){var t=e.target.closest("[data-domain]");window.atlasTrack("atlas_domain_selected",{domain:t?t.dataset.domain:"unknown"})}e.target.closest('[data-track="pay"], .pay-btn, #payBtn, .stripe-button')&&window.atlasTrack("atlas_payment_initiated",{})},!0)),"success"===c()){var p=0;try{var h=o.get("amount");if(h&&(p=parseFloat(h)),p||(p=parseFloat(sessionStorage.getItem("atlas_purchase_value"))||0),!p){var w=o.get("package"),v={starter:99,growth:299,business:599};w&&v[w]&&(p=v[w])}}catch(e){}var y=o.get("stripe_session")||"",k="1"===o.get("free");window.atlasTrack("atlas_purchase_complete",{value:p,currency:"USD",transaction_id:o.get("session")||"unknown"}),a("event","purchase",{value:p,currency:"USD",transaction_id:y||o.get("session")||Date.now().toString()}),console.log("[ATLAS Analytics] Purchase tracked:",{value:p,stripe:y,free:k})}function b(e,t){var a;try{a=sessionStorage.getItem("atlas_session")}catch(e){}if(!a)try{a=o.get("session")}catch(e){}var i={action:"track",session_id:a,event:e,data:Object.assign({},t,{url:window.location.href,referrer:document.referrer,timestamp:(new Date).toISOString(),utm:n,user_agent:navigator.userAgent,screen:window.innerWidth+"x"+window.innerHeight})};navigator.sendBeacon?navigator.sendBeacon("/api/track-events.php",JSON.stringify(i)):fetch("/api/track-events.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0}).catch(function(){})}document.addEventListener("visibilitychange",function(){if("hidden"===document.visibilityState){var e=Math.floor((Date.now()-u)/1e3);navigator.sendBeacon&&navigator.sendBeacon("/api/track-events.php",JSON.stringify({action:"track",event:"page_exit",data:{time_on_page:e,page_type:c(),max_scroll:Math.max.apply(null,Object.keys(d).filter(function(e){return d[e]}).map(Number))||0,traffic_source:r,url:window.location.href}}))}});var O="AW-871359492";a("config",O,{allow_enhanced_conversions:!0});var S=window.atlasTrack;window.atlasTrack=function(e,t){S(e,t),"atlas_build_started"===e&&a("event","conversion",{send_to:O+"/build",value:0,currency:"USD"}),"atlas_purchase_complete"===e&&a("event","conversion",{send_to:O+"/purchase",value:t&&t.value||10,currency:"USD",transaction_id:t&&t.transaction_id||""})},console.log("[ATLAS Analytics] Initialized | GA4: "+e+" | Source: "+r+" | Page: "+c())}();