"use strict";(()=>{var le=Object.create;var C=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var me=(e,t,r)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ge=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fe(t))!pe.call(e,o)&&o!==r&&C(e,o,{get:()=>t[o],enumerable:!(n=de(t,o))||n.enumerable});return e};var ye=(e,t,r)=>(r=e!=null?le(he(e)):{},ge(t||!e||!e.__esModule?C(r,"default",{value:e,enumerable:!0}):r,e));var h=(e,t,r)=>me(e,typeof t!="symbol"?t+"":t,r);var S=(e,t,r)=>new Promise((n,o)=>{var a=d=>{try{l(r.next(d))}catch(p){o(p)}},i=d=>{try{l(r.throw(d))}catch(p){o(p)}},l=d=>d.done?n(d.value):Promise.resolve(d.value).then(a,i);l((r=r.apply(e,t)).next())});var ne=H(u=>{"use strict";var x=Symbol.for("react.element"),Se=Symbol.for("react.portal"),be=Symbol.for("react.fragment"),xe=Symbol.for("react.strict_mode"),ve=Symbol.for("react.profiler"),ke=Symbol.for("react.provider"),_e=Symbol.for("react.context"),Ee=Symbol.for("react.forward_ref"),Ce=Symbol.for("react.suspense"),Re=Symbol.for("react.memo"),$e=Symbol.for("react.lazy"),W=Symbol.iterator;function Pe(e){return e===null||typeof e!="object"?null:(e=W&&e[W]||e["@@iterator"],typeof e=="function"?e:null)}var K={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Q=Object.assign,Y={};function b(e,t,r){this.props=e,this.context=t,this.refs=Y,this.updater=r||K}b.prototype.isReactComponent={};b.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function X(){}X.prototype=b.prototype;function A(e,t,r){this.props=e,this.context=t,this.refs=Y,this.updater=r||K}var D=A.prototype=new X;D.constructor=A;Q(D,b.prototype);D.isPureReactComponent=!0;var G=Array.isArray,ee=Object.prototype.hasOwnProperty,I={current:null},te={key:!0,ref:!0,__self:!0,__source:!0};function re(e,t,r){var n,o={},a=null,i=null;if(t!=null)for(n in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(a=""+t.key),t)ee.call(t,n)&&!te.hasOwnProperty(n)&&(o[n]=t[n]);var l=arguments.length-2;if(l===1)o.children=r;else if(1{"use strict";oe.exports=ne()});var R=class{constructor(t=!0){h(this,"isEnabled");this.isEnabled=t}store(t,r){if(!t||!this.isEnabled)return;let n="swan_";try{return window.localStorage.setItem(n+t,r),r}catch(o){return console.log("store error ",o),r}}get(t,r=!1,n=!1){var i;if(!t||!this.isEnabled)return;t=r?t:"swan_"+t;let a;try{return a=window[n?"sessionStorage":"localStorage"].getItem(t),a||(a=(i=document.cookie.split(";").map(l=>l.trim()).find(l=>l.startsWith(t+"=")))==null?void 0:i.split("=")[1]),a}catch(l){console.log("get error",l),this.isEnabled=!1}}},J=R;var M=()=>{let t=(navigator.userAgent||navigator.vendor||window.opera||"").toLowerCase();return we.some(r=>t.includes(r.toLowerCase()))},we=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","deepscan","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","headlesschrome","cypress","Google-HotelAdsVerifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","Bytespider;"];var $=class{constructor(t,r){this.conf=t;this.logger=r;h(this,"externalScripts",[]);h(this,"domains",[]);h(this,"isDisabled",!1);h(this,"excludedPaths",[]);h(this,"allowedCountryCodes",[]);h(this,"minimumSessionTimeSec",10);h(this,"externalScriptsAreRendered",!1)}load(){return S(this,null,function*(){var n;let r=yield(yield fetch(this.conf.url+"/scripts?pk="+this.conf.pk)).json();if((r==null?void 0:r.success)===!1){this.isDisabled=!0;return}this.externalScripts=r.scripts||[],this.isDisabled=r.trackingScript.isEnabled===!1,this.excludedPaths=r.trackingScript.excludedPaths||[],this.domains=r.domains,this.minimumSessionTimeSec=(n=r.trackingScript.minimumSessionTimeSec)!=null?n:10,this.allowedCountryCodes=r.trackingScript.allowedCountryCodes||[]})}renderExternalScripts(){var t;this.externalScriptsAreRendered||((t=this.externalScripts)==null||t.filter(r=>!!r.html).forEach(r=>{let n=document.createElement("script");n.type="text/javascript",n.text=r.html,document.head.appendChild(n)}),this.externalScriptsAreRendered=!0)}},z=$;var P=class{constructor(t){h(this,"enabled");this.enabled=t&&!!window.console&&!!console.log}log(...t){this.enabled&&console.log("[swan]",...t)}error(...t){console.error("[swan]",...t)}},B=P;var Le=ye(se());var ie,U=class{constructor(){h(this,"beUrl");h(this,"debug");h(this,"pk","");h(this,"canRun",!0);h(this,"isEnded",!1);h(this,"scriptUrl",(ie=document.currentScript)==null?void 0:ie.src);h(this,"logger");h(this,"memory");h(this,"settings");h(this,"sid","");h(this,"isCollecting",!1);let t=window.swan;this.pk=t.pk,this.debug=t.debug,this.beUrl=this.debug?"http://localhost:4001":"https://ppt2emy7nkbhu3nf4fatqm5rpe0ymllj.lambda-url.us-east-1.on.aws",this.memory=new J(this.canRun);let r=new URLSearchParams(window.location.search);this.logger=new B(this.debug||r.get("swnlogz")==="true"),this.validateCanRun(),this.settings=new z({url:this.beUrl,pk:this.pk},this.logger)}validateCanRun(){if(!this.pk||this.pk==="undefined"){this.logger.error("no key provided - Swan not running"),this.canRun=!1;return}if(!navigator.cookieEnabled||!window.localStorage){this.logger.log("no storage"),this.canRun=!1;return}if(!this.scriptUrl&&!this.debug){this.logger.log("no script url"),this.canRun=!1;return}if(M()){this.logger.log("bot"),this.canRun=!1;return}["","localhost","127.0.0.1"].includes(location.hostname)&&!this.debug&&(this.canRun=!1,this.logger.error("localhost - not running"))}checkCollected(){let t=this.memory.get("session_ended");if(!t){this.isEnded=!1;return}let r=30*24*60*60*1e3,n=Date.now()-Number(t),o=n>r;this.logger.log("hours passed: ",n/1e3/60/60,"more than 30d: ",o),(o||this.debug)&&this.memory.store("session_ended",""),this.isEnded=!o}checkDoubleLoad(){if(window.location!==window.parent.location){this.logger.error("double load"),this.canRun=!1;return}if(this.memory.get("loaded")==="true"){this.logger.log("double load cookie"),this.canRun=!1;return}document.cookie="swan_loaded=true;max-age=1;secure;samesite=strict;path=/"}loadScriptSettings(){return S(this,null,function*(){if(!this.canRun){this.logger.log("cant run, not loading settings");return}yield this.settings.load(),this.settings.isDisabled&&(this.logger.log("disabled, not running"),this.canRun=!1)})}renderScripts(){if(this.canRun)return this.settings.renderExternalScripts()}checkGeo(){return S(this,null,function*(){let r=yield(yield fetch("https://pro.ip-api.com/json/?fields=61439&key=FF31FlkFbJqhRGy")).json(),n=this.settings.allowedCountryCodes;r.countryCode&&n.length&&!n.includes(r.countryCode)&&(this.logger.error("country not whitelisted",r.countryCode),this.canRun=!1),this.memory.store("location",JSON.stringify({country:r.country,countryCode:r.countryCode,city:r.city,region:r.region}))})}checkExcludedDomains(){this.settings.domains.some(t=>{let r=window.location.host;return r===t.domain||r===`www.${t.domain}`})||(this.logger.error("domain not whitelisted"),this.canRun=!1)}storeReqDetails(){document.referrer&&!document.referrer.includes(location.hostname)&&this.memory.store("referrer",document.referrer);let t=new URL(window.location.href),r={};["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].forEach(n=>{let o=t.searchParams.get(n);o&&(r[n]=o)}),Object.keys(r).length>0&&this.memory.store("utms",JSON.stringify(r))}setupPageTracking(){document.readyState==="complete"?this.trackPageView():window.addEventListener("load",()=>this.trackPageView()),window.addEventListener("popstate",()=>this.trackPageView());let t=history.pushState;history.pushState=(...n)=>{t.apply(history,n),this.trackPageView()};let r=history.replaceState;history.replaceState=(...n)=>{r.apply(history,n),this.trackPageView()}}trackPageView(){var l,d;if(this.isCurrentPathExcluded()){this.logger.log("current path is excluded, skipping tracking");return}let t="page_views",r=JSON.parse(this.memory.get(t,!1)||"[]"),n=window.location.href,o={type:"PAGE",timestamp:new Date().toISOString(),data:{url:n,title:document.title}};if(this.logger.log("page: ",o),!(((d=(l=r[r.length-1])==null?void 0:l.data)==null?void 0:d.url)!==n))return;let i=[...r,o];this.memory.store(t,JSON.stringify(i)),i.length>40&&this.collect()}isCurrentPathExcluded(){return this.settings.excludedPaths.some(r=>{let n=r.path;try{(r.path.startsWith("http://")||r.path.startsWith("https://"))&&(n=new URL(r.path).pathname)}catch(o){n=r.path}return n==="/"?window.location.pathname==="/":window.location.pathname.includes(n)})}createId(){let t=this.memory.get("id");if(t)return this.sid=t,t;let r=(crypto==null?void 0:crypto.randomUUID())||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let o=Math.random()*16|0;return(n=="x"?o:o&3|8).toString(16)});return this.memory.store("id",r),this.sid=r,r}collect(){var a;if(this.isEnded||!this.canRun||this.isCollecting)return;let t=this.memory.get("page_views",!1)||"[]",r=JSON.parse(t);if(r.length===0){this.logger.log("no events");return}this.isCollecting=!0;let n=[];try{n=this.captureHems()}catch(i){this.logger.error("error capturing hems",i)}let o={sid:this.sid,events:r,meta:{ref:this.memory.get("referrer")||"",utms:JSON.parse(this.memory.get("utms")||"{}"),fbc:this.memory.get("_fbc")||"",fbp:this.memory.get("_fbp")||"",location:JSON.parse(this.memory.get("location")||"{}"),userAgent:navigator.userAgent,hems:n},vectorVisitorId:(a=window.vector)==null?void 0:a.visitorId};this.logger.log("collect",o),this.memory.store("page_views",""),fetch(this.beUrl+"/track?pk="+this.pk,{method:"POST",body:JSON.stringify(o),keepalive:!0,headers:{"Content-Type":"application/json"}}).then(i=>i.json()).then(i=>{this.isCollecting=!1,i.code==="SESSION_ENDED"?this.endSession():setTimeout(()=>this.collect(),15e3)}).catch(i=>{this.isCollecting=!1,this.logger.error("track error",i)})}captureHems(){var q,F;let t=JSON.parse(this.memory.get("location")||"{}");if(!["us","ca","united states"].includes((q=t.countryCode)==null?void 0:q.toLowerCase()))return this.logger.log("skipping HEM capture for non-US traffic:",t.countryCode),[];let r=[],n=new Set,o=/^[a-f0-9]{32}$/i,a=/^[a-f0-9]{64}$/i,i=/^[A-Za-z0-9+/]{43}=$/,l=/^[A-Za-z0-9\-_]{43}=?$/,d=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,p=/email|^em$|hem|hashed|sha256|md5|user_id|customer|subscriber|token|hash/i,ae=s=>o.test(s)||a.test(s)||i.test(s)||l.test(s),ce=s=>d.test(s),E=(s,c="")=>{let f=s.trim();if(!(!f||n.has(f))){if(ce(f)){r.push(f),n.add(f);return}ae(f)&&p.test(c)&&(r.push(f),n.add(f))}},g=(s,c,f=0)=>{if(!(f>5||s==null)){if(typeof s=="string"){if(E(s,c),s.trim().startsWith("{")||s.trim().startsWith("["))try{g(JSON.parse(s),c,f+1)}catch(y){}}else if(Array.isArray(s))s.forEach((y,w)=>g(y,`${c}[${w}]`,f+1));else if(typeof s=="object")for(let[y,w]of Object.entries(s))g(w,c?`${c}.${y}`:y,f+1)}};document.cookie.split(";").forEach(s=>{let c=s.trim(),f=c.indexOf("=");if(f>0){let y=c.substring(0,f),w=c.substring(f+1);try{g(decodeURIComponent(w),`cookie.${y}`)}catch(Ue){g(w,`cookie.${y}`)}}});for(let s=0;s{try{g(decodeURIComponent(s),`urlParam.${c}`)}catch(f){g(s,`urlParam.${c}`)}}),document.querySelectorAll("meta[name], meta[property]").forEach(s=>{let c=s.getAttribute("name")||s.getAttribute("property")||"",f=s.getAttribute("content");f&&E(f,`meta.${c}`)}),document.querySelectorAll('input[type="hidden"], input[type="email"]').forEach(s=>{let c=s,f=c.name||c.id||"input";c.value&&E(c.value,`input.${f}`)});let j=(F=document.body)==null?void 0:F.dataset;if(j)for(let[s,c]of Object.entries(j))c&&g(c,`body.data-${s}`);return r}endSession(){this.logger.log("cleanup"),this.isEnded=!0,this.memory.store("page_views",""),this.memory.store("session_start",""),this.memory.store("utms",""),this.memory.store("referrer",""),this.memory.store("id",""),this.memory.store("session_ended",Date.now().toString())}setup(){return S(this,null,function*(){this.checkDoubleLoad(),this.checkCollected(),yield this.loadScriptSettings(),yield this.checkGeo(),this.checkExcludedDomains(),this.storeReqDetails(),this.createId(),this.setupPageTracking()})}run(){this.logger.log(this);let t="session_start";if(!this.canRun)return;let r=Date.now(),n=parseInt(this.memory.get(t)||r.toString());this.memory.get(t)||this.memory.store(t,n.toString());let o=(r-n)/1e3,a=()=>{this.renderScripts(),setTimeout(()=>this.collect(),1e3)};if(o>=this.settings.minimumSessionTimeSec){this.logger.log("duration: ",o),a();return}let i=this.settings.minimumSessionTimeSec-o;this.logger.log("colecting in ",i*1e3),setTimeout(()=>a(),i*1e3)}},T=U;var N=new T;N.setup().then(()=>N.run());window.swan=N;})(); /*! Bundled license information: react/cjs/react.production.min.js: (** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) */