@v-tilt/browser 1.10.0 → 1.10.2

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.
@@ -1,2 +1,2 @@
1
- function e(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,n)}function t(t){return function(){var i=this,r=arguments;return new Promise(function(n,s){var o=t.apply(i,r);function a(t){e(o,n,s,a,l,"next",t)}function l(t){e(o,n,s,a,l,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}var r="1.10.0",n="__vt_session",s="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",l="__vt_device_id",d="__vt_anonymous_id",u="__vt_remote_config",h="__vt_distinct_id",c="__vt_user_properties",_="localStorage",v="localStorage+cookie",g="sessionStorage",f="memory",p="$initial_person_info";class m{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,r=i({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.proxy=t.getAttribute("data-proxy")||e.proxy,r.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,r.token=t.getAttribute("data-token")||e.token||"",r.projectId=t.getAttribute("data-project-id")||e.projectId||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var n="true"===t.getAttribute("data-capture-performance");if(r.capture_performance=!!n||e.capture_performance,r.proxy&&r.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var s of(r.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(r.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return r}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}function y(e,t){try{return e()}catch(e){return t}}class b{constructor(){this._events=new Map,this._onceEvents=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>{var i;null===(i=this._events.get(e))||void 0===i||i.delete(t)}}once(e,t){return this._onceEvents.has(e)||this._onceEvents.set(e,new Set),this._onceEvents.get(e).add(t),()=>{var i;null===(i=this._onceEvents.get(e))||void 0===i||i.delete(t)}}emit(e,t){var i,r;null===(i=this._events.get(e))||void 0===i||i.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in event listener for "'+e+'":',t)}});var n=this._onceEvents.get(e);n&&(n.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in once listener for "'+e+'":',t)}}),this._onceEvents.delete(e)),null===(r=this._events.get("*"))||void 0===r||r.forEach(i=>{try{i({event:e,payload:t})}catch(e){console.error("[vTilt] Error in wildcard listener:",e)}})}off(e){e?(this._events.delete(e),this._onceEvents.delete(e)):(this._events.clear(),this._onceEvents.clear())}listenerCount(e){var t,i,r,n;return(null!==(i=null===(t=this._events.get(e))||void 0===t?void 0:t.size)&&void 0!==i?i:0)+(null!==(n=null===(r=this._onceEvents.get(e))||void 0===r?void 0:r.size)&&void 0!==n?n:0)}hasListeners(e){return this.listenerCount(e)>0}}var S="sdk:initialized",w="sdk:config_updated",C="sdk:remote_config_loaded",I="feature:started",E="feature:stopped",M="event:captured",L="recording:started",k="recording:stopped";function T(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function x(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function P(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(i,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(i,e[r],r)}function R(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}function A(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function U(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var n of i)for(var s of n)e.push(s);return e}var O="undefined"!=typeof window?window:void 0,$="undefined"!=typeof globalThis?globalThis:O,z=null==$?void 0:$.navigator,q=null==$?void 0:$.document,D=null==$?void 0:$.location,F=null==$?void 0:$.fetch,N=(null==$?void 0:$.XMLHttpRequest)&&"withCredentials"in new $.XMLHttpRequest?$.XMLHttpRequest:void 0;null==$||$.AbortController;var B=null==z?void 0:z.userAgent,j=null!=O?O:{},V=[d,l,h,a],W=31536e3,H=["herokuapp.com","vercel.app","netlify.app"];function J(e){var t;if(!e||"undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var r=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class Q{constructor(e){var t,i,r;this.memoryStorage=new Map,this._localStorageSupported=null,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");return!H.includes(i)}(),this.sameSite=null!==(i=e.sameSite)&&void 0!==i?i:"Lax",this.secure=null!==(r=e.secure)&&void 0!==r?r:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this._localStorageSupported)return this._localStorageSupported;if(void 0===O||!O.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";O.localStorage.setItem(e,"1");var t="1"===O.localStorage.getItem(e);return O.localStorage.removeItem(e),this._localStorageSupported=t,t||console.warn("[vTilt] localStorage unavailable, using cookies"),t}catch(e){return this._localStorageSupported=!1,console.warn("[vTilt] localStorage unavailable, using cookies"),!1}}isCriticalProperty(e){return V.includes(e)}get(e){var t;try{switch(this.method){case f:return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;case v:return this.getLocalStoragePlusCookie(e);case _:return this.getLocalStorage(e);case g:return this.readFromSessionStorage(e);default:return this.getCookie(e)}}catch(t){return console.warn('[vTilt] Storage get error for "'+e+'":',t),null}}set(e,t,i){try{switch(this.method){case f:this.memoryStorage.set(e,t);break;case v:this.setLocalStoragePlusCookie(e,t,i);break;case _:this.setLocalStorage(e,t);break;case g:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:W)}}catch(t){console.warn('[vTilt] Storage set error for "'+e+'":',t)}}remove(e){try{switch(this.method){case f:this.memoryStorage.delete(e);break;case v:this.removeLocalStoragePlusCookie(e);break;case _:this.removeLocalStorage(e);break;case g:this.removeFromSessionStorage(e);break;default:this.removeCookie(e)}}catch(t){console.warn('[vTilt] Storage remove error for "'+e+'":',t)}}getLocalStoragePlusCookie(e){if(this.isCriticalProperty(e)){var t=this.getCookie(e),i=this.getLocalStorage(e);if(null!==t){if(i!==t&&this.isLocalStorageSupported())try{null==O||O.localStorage.setItem(e,t)}catch(e){}return t}return i}return this.getLocalStorage(e)}setLocalStoragePlusCookie(e,t,i){this.setLocalStorage(e,t),this.isCriticalProperty(e)&&this.setCookie(e,t,null!=i?i:W)}removeLocalStoragePlusCookie(e){this.removeLocalStorage(e),this.isCriticalProperty(e)&&this.removeCookie(e)}getLocalStorage(e){var t;if(!this.isLocalStorageSupported())return null;try{return null!==(t=null==O?void 0:O.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==O||O.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==O||O.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==O?void 0:O.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==O||O.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==O||O.sessionStorage.removeItem(e)}catch(e){}}getCookie(e){if("undefined"==typeof document)return null;var t=e+"=";for(var i of document.cookie.split(";")){var r=i.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var r=J(this.cross_subdomain),n=e+"="+encodeURIComponent(t)+"; Max-Age="+i+"; path=/; SameSite="+this.sameSite;this.secure&&(n+="; Secure"),r&&(n+="; domain="+r),document.cookie=n}}removeCookie(e){if("undefined"!=typeof document){var t=J(this.cross_subdomain);document.cookie=e+"=; Max-Age=0; path=/"+(t?"; domain="+t:""),document.cookie=e+"=; Max-Age=0; path=/"}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,r){var n=i({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(n))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}canUseSessionStorage(){if(void 0===O||!(null==O?void 0:O.sessionStorage))return!1;try{var e="__vt_ss_test__";return O.sessionStorage.setItem(e,"1"),O.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==O?void 0:O.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class G{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=T(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||T();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(T())}_getSessionIdRaw(){return this.storage.get(n)}_storeSessionId(e){this.storage.set(n,e,1800)}_clearSessionId(){this.storage.remove(n)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(s);if(t)return this._windowId=t,t}var i=T();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(s,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(s);i&&!t?this._windowId=i:(i&&e.removeItem(s),this._setWindowId(T())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=T()}_listenToUnload(){var e=this.storage.getSessionStorage();O&&e&&R(O,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"})}}function K(e){if(!q)return null;var t=q.createElement("a");return t.href=e,t}function X(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<i.length;r++){var n=i[r].split("=");if(n[0]===t){if(n.length<2)return"";var s=n[1];try{s=decodeURIComponent(s)}catch(e){}return s.replace(/\+/g," ")}}return""}function Z(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],d=(a||"").split("&"),u=[],h=0;h<d.length;h++){var c=d[h].split("="),_=c[0],v=c.slice(1).join("=");-1!==t.indexOf(_)?u.push(_+"="+i):_&&u.push(_+(v?"="+v:""))}var g=u.join("&");return l+(g?"?"+g:"")+(s?"#"+s:"")}function Y(e){return"function"==typeof e}var ee="Mobile",te="iOS",ie="Android",re="Tablet",ne=ie+" "+re,se="iPad",oe="Apple",ae=oe+" Watch",le="Safari",de="BlackBerry",ue="Samsung",he=ue+"Browser",ce=ue+" Internet",_e="Chrome",ve=_e+" OS",ge=_e+" "+te,fe="Internet Explorer",pe=fe+" "+ee,me="Opera",ye=me+" Mini",be="Edge",Se="Microsoft "+be,we="Firefox",Ce=we+" "+te,Ie="Nintendo",Ee="PlayStation",Me="Xbox",Le=ie+" "+ee,ke=ee+" "+le,Te="Windows",xe=Te+" Phone",Pe="Nokia",Re="Ouya",Ae="Generic",Ue=Ae+" "+ee.toLowerCase(),Oe=Ae+" "+re.toLowerCase(),$e="Konqueror",ze="(\\d+(\\.\\d+)?)",qe=new RegExp("Version/"+ze),De=new RegExp(Me,"i"),Fe=new RegExp(Ee+" \\w+","i"),Ne=new RegExp(Ie+" \\w+","i"),Be=new RegExp(de+"|PlayBook|BB10","i"),je={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Ve(e,t){return e.toLowerCase().includes(t.toLowerCase())}var We=(e,t)=>t&&Ve(t,oe)||function(e){return Ve(e,le)&&!Ve(e,_e)&&!Ve(e,ie)}(e),He=function(e,t){return t=t||"",Ve(e," OPR/")&&Ve(e,"Mini")?ye:Ve(e," OPR/")?me:Be.test(e)?de:Ve(e,"IE"+ee)||Ve(e,"WPDesktop")?pe:Ve(e,he)?ce:Ve(e,be)||Ve(e,"Edg/")?Se:Ve(e,"FBIOS")?"Facebook "+ee:Ve(e,"UCWEB")||Ve(e,"UCBrowser")?"UC Browser":Ve(e,"CriOS")?ge:Ve(e,"CrMo")||Ve(e,_e)?_e:Ve(e,ie)&&Ve(e,le)?Le:Ve(e,"FxiOS")?Ce:Ve(e.toLowerCase(),$e.toLowerCase())?$e:We(e,t)?Ve(e,ee)?ke:le:Ve(e,we)?we:Ve(e,"MSIE")||Ve(e,"Trident/")?fe:Ve(e,"Gecko")?we:""},Je={[pe]:[new RegExp("rv:"+ze)],[Se]:[new RegExp(be+"?\\/"+ze)],[_e]:[new RegExp("("+_e+"|CrMo)\\/"+ze)],[ge]:[new RegExp("CriOS\\/"+ze)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ze)],[le]:[qe],[ke]:[qe],[me]:[new RegExp("(Opera|OPR)\\/"+ze)],[we]:[new RegExp(we+"\\/"+ze)],[Ce]:[new RegExp("FxiOS\\/"+ze)],[$e]:[new RegExp("Konqueror[:/]?"+ze,"i")],[de]:[new RegExp(de+" "+ze),qe],[Le]:[new RegExp("android\\s"+ze,"i")],[ce]:[new RegExp(he+"\\/"+ze)],[fe]:[new RegExp("(rv:|MSIE )"+ze)],Mozilla:[new RegExp("rv:"+ze)]},Qe=function(e,t){var i=He(e,t),r=Je[i];if(void 0===r)return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},Ge=[[new RegExp(Me+"; "+Me+" (.*?)[);]","i"),e=>[Me,e&&e[1]||""]],[new RegExp(Ie,"i"),[Ie,""]],[new RegExp(Ee,"i"),[Ee,""]],[Be,[de,""]],[new RegExp(Te,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[xe,""];if(new RegExp(ee).test(t)&&!/IEMobile\b/.test(t))return[Te+" "+ee,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=je[r]||"";return/arm/i.test(t)&&(n="RT"),[Te,n]}return[Te,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[te,t.join(".")]}return[te,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ie+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ie+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ie,t.join(".")]}return[ie,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ve,""]],[/Linux|debian/i,["Linux",""]]],Ke=function(e){return Ne.test(e)?Ie:Fe.test(e)?Ee:De.test(e)?Me:new RegExp(Re,"i").test(e)?Re:new RegExp("("+xe+"|WPDesktop)","i").test(e)?xe:/iPad/.test(e)?se:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ae:Be.test(e)?de:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Pe,"i").test(e)?Pe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ee).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ie:ne:ie:new RegExp("(pda|"+ee+")","i").test(e)?Ue:new RegExp(re,"i").test(e)&&!new RegExp(re+" pc","i").test(e)?Oe:""},Xe="https?://(.*)",Ze=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ye=U(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ze),et="<masked>";function tt(e){var t=function(e){return e?0===e.search(Xe+"google.([^/?]*)")?"google":0===e.search(Xe+"bing.com")?"bing":0===e.search(Xe+"yahoo.com")?"yahoo":0===e.search(Xe+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=q?X(q.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function it(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function rt(){return(null==q?void 0:q.referrer)||"$direct"}function nt(){var e;return(null==q?void 0:q.referrer)&&(null===(e=K(q.referrer))||void 0===e?void 0:e.host)||"$direct"}function st(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=K(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=K(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Ye.concat([]),i={};return P(t,function(t){var r=X(e,t);i[t]=r||null}),i}(r);A(n,o)}i&&A(n,tt(i));return n}function ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function at(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function lt(e,t){if(!B)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<Ge.length;t++){var[i,r]=Ge[t],n=i.exec(e),s=n&&(Y(r)?r(n,e):r);if(s)return s}return["",""]}(B);return A(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=e[i];null!=r&&""!==r&&(t[i]=r)}return t}({$os:o,$os_version:a,$browser:He(B,navigator.vendor),$device:Ke(B),$device_type:(n=B,s=Ke(n),s===se||s===ne||"Kobo"===s||"Kindle Fire"===s||s===Oe?re:s===Ie||s===Me||s===Ee||s===Re?"Console":s===ae?"Wearable":s?ee:"Desktop"),$timezone:ot(),$timezone_offset:at()}),{$current_url:Z(null==D?void 0:D.href,[],et),$host:null==D?void 0:D.host,$pathname:null==D?void 0:D.pathname,$raw_user_agent:B.length>1e3?B.substring(0,997)+"...":B,$browser_version:Qe(B,navigator.vendor),$browser_language:it(),$browser_language_prefix:(i=it(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==O?void 0:O.screen.height,$screen_width:null==O?void 0:O.screen.width,$viewport_height:null==O?void 0:O.innerHeight,$viewport_width:null==O?void 0:O.innerWidth,$lib:"web",$lib_version:r,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class dt{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(d,this.userIdentity.anonymous_id,W)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,r){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var s=n||this.userIdentity.anonymous_id;this.userIdentity.device_id=s,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:s})}e!==n&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==n&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):t||r?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):e!==n&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var r=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,n=this.getPersonPropertiesHash(r,e,t);return this._cachedPersonProperties===n?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=n,!0)}reset(e){var t=this.generateAnonymousId(),r=this.userIdentity.device_id,n=e?this.generateDeviceId():r;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:n,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[p]){var i=function(e,t){var i=e?U([],Ze,t||[]):[],r=null==D?void 0:D.href.substring(0,1e3);return{r:rt().substring(0,1e3),u:r?Z(r,i,et):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=st(i),t={},P(e,function(e,i){var r;t["$initial_"+(r=String(i),r.startsWith("$")?r.substring(1):r)]=e}),t):{}}update_referrer_info(){var e={$referrer:rt(),$referring_domain:nt()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(d),t=this.storage.get(l),i=this.storage.get(h),r=this.storage.get(a),n=this.getStoredUserProperties(),s=e||this.generateAnonymousId(),o=t||this.generateDeviceId(),u=i||null,c=r||"anonymous",_=s||this.generateAnonymousId();return e||this.storage.set(d,_,W),t||this.storage.set(l,o,W),r||this.storage.set(a,c,W),{distinct_id:u,anonymous_id:_,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,W),this.storage.set(l,this.userIdentity.device_id,W),this.storage.set(a,this.userIdentity.user_state,W),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,W):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,W)}register_once(e,t){var i=this.getStoredUserProperties(),r=!1;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(n in i||(i[n]=e[n],r=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in i||(i[s]=t[s],r=!0));r&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+T()}generateDeviceId(){return"device_"+T()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var ut=["LCP","CLS","FCP","INP","TTFB"],ht=["LCP","CLS","FCP","INP"],ct=9e5,_t="[WebVitals]";class vt{static extractConfig(e){var t=e.capture_performance;return"boolean"==typeof t?{web_vitals:t}:"object"==typeof t&&null!==t?t:{web_vitals:!1}}constructor(e){this.name="WebVitals",this._isStarted=!1,this._instance=e,this._buffer=this._createEmptyBuffer(),this._config=vt.extractConfig(e.getConfig())}get isEnabled(){var e=null==D?void 0:D.protocol;return("http:"===e||"https:"===e)&&!1!==this._config.web_vitals}get isStarted(){return this._isStarted}startIfEnabled(){if(this.isEnabled&&!this._isStarted&&O){var e=this._getWebVitalsCallbacks();e?this._startCapturing(e):this._loadWebVitals()}}stop(){this._isStarted&&(this._flush(),this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),this._isStarted=!1)}onConfigUpdate(e){var t=vt.extractConfig(e),i=this.isEnabled;this._config=t,i||!this.isEnabled||this._isStarted?i&&!this.isEnabled&&this._isStarted&&this.stop():this.startIfEnabled()}get allowedMetrics(){return this._config.web_vitals_allowed_metrics||ht}get flushTimeoutMs(){return this._config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this._config.__web_vitals_max_value;return void 0===e?ct:0===e?0:e<6e4?ct:e}_createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}_getWebVitalsCallbacks(){var e;return null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}_loadWebVitals(){var e,t=null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this._instance,"web-vitals",e=>{if(e)console.error(_t+" Failed to load web-vitals:",e);else{var t=this._getWebVitalsCallbacks();t?this._startCapturing(t):console.error(_t+" web-vitals loaded but callbacks not registered")}}):console.warn(_t+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}_startCapturing(e){if(!this._isStarted){var t=this.allowedMetrics,i=this._addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this._isStarted=!0}}_getCurrentUrl(){var e;return null===(e=null==O?void 0:O.location)||void 0===e?void 0:e.href}_getCurrentPathname(){return null==D?void 0:D.pathname}_addToBuffer(e){try{if(!O||!q||!D)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(_t+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(_t+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this._getCurrentUrl(),r=this._getCurrentPathname();if(!t)return void console.warn(_t+" Could not determine current URL");this._buffer.url&&this._buffer.url!==t&&this._flush(),this._buffer.url||(this._buffer.url=t,this._buffer.pathname=r),this._buffer.firstMetricTimestamp||(this._buffer.firstMetricTimestamp=Date.now());var n=this._cleanAttribution(e.attribution),s=this._instance.getSessionId(),o=this._getWindowId(),a=i({},e,{attribution:n,timestamp:Date.now(),$current_url:t,$session_id:s,$window_id:o}),l=this._buffer.metrics.findIndex(t=>t.name===e.name);l>=0?this._buffer.metrics[l]=a:this._buffer.metrics.push(a),this._scheduleFlush(),this._buffer.metrics.length>=this.allowedMetrics.length&&this._flush()}catch(e){console.error(_t+" Error adding metric to buffer:",e)}}_cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}_getWindowId(){var e;try{return(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}_scheduleFlush(){this._flushTimer&&clearTimeout(this._flushTimer),this._flushTimer=setTimeout(()=>{this._flush()},this.flushTimeoutMs)}_flush(){if(this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),0!==this._buffer.metrics.length){try{var e={$pathname:this._buffer.pathname,$current_url:this._buffer.url};for(var t of this._buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this._instance.capture("$web_vitals",e)}catch(e){console.error(_t+" Error flushing metrics:",e)}this._buffer=this._createEmptyBuffer()}}}function gt(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return Y(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ft{constructor(e,t){var i;this.name="HistoryAutocapture",this._isStarted=!1,this._instance=e,this._config=t||ft.extractConfig(e.getConfig()),this._lastPathname=(null===(i=null==O?void 0:O.location)||void 0===i?void 0:i.pathname)||""}static extractConfig(e){return{enabled:!1!==e.capture_pageview}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().capture_pageview}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._popstateListener&&(this._popstateListener(),this._popstateListener=void 0),this._isStarted=!1)}onConfigUpdate(e){this._config=ft.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}_start(){O&&D&&(this._lastPathname=D.pathname||"",this._patchHistoryMethods(),this._setupPopstateListener(),this._isStarted=!0)}_patchHistoryMethods(){var e,t;if(null==O?void 0:O.history){var i=this;(null===(e=O.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||gt(O.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=O.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||gt(O.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")})}}_setupPopstateListener(){if(!this._popstateListener&&O){var e=()=>{this._capturePageview("popstate")};R(O,"popstate",e),this._popstateListener=()=>{null==O||O.removeEventListener("popstate",e)}}}_capturePageview(e){this.isEnabled&&this._isStarted&&y(()=>{var t,i=null===(t=null==O?void 0:O.location)||void 0===t?void 0:t.pathname;if(i&&D&&q){if(i!==this._lastPathname){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}})}}var pt=["a","button","form","input","select","textarea","label"],mt=["click","change","submit"],yt=["hidden","password"],bt=["button","checkbox","submit","reset","radio"],St=["name","id","class","aria-label","role","type","data-testid"],wt=["_ngcontent","_nghost","_ngcontent-","_nghost-","style"],Ct="data-vt-capture-";function It(e,t){var i,r;if(!e||!e.tagName)return!1;var n=e.tagName.toLowerCase();if((null!==(i=null==t?void 0:t.element_allowlist)&&void 0!==i?i:[...pt]).includes(n))return!0;if(function(e){try{var t=null==O?void 0:O.getComputedStyle(e);return"pointer"===(null==t?void 0:t.cursor)}catch(e){return!1}}(e))return!0;if("true"===e.getAttribute("contenteditable"))return!0;if(null===(r=null==t?void 0:t.css_selector_allowlist)||void 0===r?void 0:r.length)for(var s of t.css_selector_allowlist)try{if(e.matches(s))return!0}catch(e){}return!1}function Et(e){if(!e)return!1;var t=e.tagName.toLowerCase();if(Rt(e,"vt-sensitive"))return!0;if("input"===t){var i=(e.getAttribute("type")||"text").toLowerCase();if(yt.includes(i))return!0;if(!bt.includes(i))return!0}if("select"===t||"textarea"===t)return!0;if("true"===e.getAttribute("contenteditable"))return!0;var r=e.getAttribute("name")||"",n=e.getAttribute("id")||"";return!(!Mt(r)&&!Mt(n))}function Mt(e){if(!e)return!1;return/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(e)}function Lt(e){return!e||"string"!=typeof e||!function(e){var t=e.replace(/[\s-]/g,"");if(!/^\d{13,19}$/.test(t))return!1;return[/^4\d{12}(\d{3})?$/,/^5[1-5]\d{14}$/,/^3[47]\d{13}$/,/^6(?:011|5\d{2})\d{12}$/].some(e=>e.test(t))}(e)&&!function(e){return/^\d{3}-?\d{2}-?\d{4}$/.test(e)}(e)}function kt(e){if(!e)return"";for(var t="",i=e.childNodes,r=0;r<i.length;r++){var n=i[r];n.nodeType===Node.TEXT_NODE&&(t+=n.textContent||"")}return Tt(t)}function Tt(e){if(!e||"string"!=typeof e)return"";var t=e.replace(/\s+/g," ").trim();return t.length>255&&(t=t.substring(0,255)+"..."),Lt(t)?t:""}function xt(e,t){if(!e||!e.tagName)return null;var i=e.tagName.toLowerCase(),r=Et(e),n={tag_name:i};if(!r){var s=function(e){if(!e)return"";var t=kt(e);return e.querySelectorAll(":scope > span").forEach(e=>{t+=" "+kt(e)}),Tt(t)}(e);s&&(n.$el_text=s)}var o=Pt(e);o.length>0&&(n.classes=o);var a=function(e,t,i){var r={},n=(null==i?void 0:i.element_attribute_ignorelist)||[];try{var s=e.attributes;if(!s)return r;for(var o=0;o<s.length;o++){var a=s[o],l=a.name.toLowerCase(),d=a.value;At(l,n)||(t&&!Ut(l)||d&&Lt(d)&&(r["attr__"+l]=d))}}catch(e){}return r}(e,r,t);Object.assign(n,a);var l=function(e){var t=e.parentElement;if(!t)return{};for(var i=t.children,r=e.tagName,n=0,s=0,o=0;o<i.length;o++){var a=i[o];if(n++,a.tagName===r&&s++,a===e)return{nth_child:n,nth_of_type:s}}return{}}(e);return l.nth_child&&(n.nth_child=l.nth_child),l.nth_of_type&&(n.nth_of_type=l.nth_of_type),n}function Pt(e){if(!e)return[];try{var t=e.className;return"string"!=typeof t?t&&"string"==typeof t.baseVal?t.baseVal.split(/\s+/).filter(Boolean):[]:t.split(/\s+/).filter(Boolean)}catch(e){return[]}}function Rt(e,t){var i,r;if(!e)return!1;try{return null!==(r=null===(i=e.classList)||void 0===i?void 0:i.contains(t))&&void 0!==r&&r}catch(i){return Pt(e).includes(t)}}function At(e,t){if(t.includes(e))return!0;for(var i of wt)if(e===i||e.startsWith(i))return!0;return!1}function Ut(e){return St.includes(e)}function Ot(e){return e.replace(/"/g,'\\"').replace(/;/g,"\\;")}function $t(e,t,i){var r;return!!(null!==(r=null==i?void 0:i.dom_event_allowlist)&&void 0!==r?r:mt).includes(e)&&(!function(e){if(!e)return!0;if(Rt(e,"vt-include"))return!1;for(var t=e;t;){if(Rt(t,"vt-no-capture"))return!0;t=t.parentElement}return!1}(t)&&!!function(e){var t,i,r;if(!(null===(t=null==O?void 0:O.location)||void 0===t?void 0:t.href))return!1;var n=O.location.href;if(null===(i=null==e?void 0:e.url_ignorelist)||void 0===i?void 0:i.length)for(var s of e.url_ignorelist)if(zt(n,s))return!1;if(null===(r=null==e?void 0:e.url_allowlist)||void 0===r?void 0:r.length){for(var o of e.url_allowlist)if(zt(n,o))return!0;return!1}return!0}(i))}function zt(e,t){return t instanceof RegExp?t.test(e):e===t||e.includes(t)}class qt{constructor(e,t){this.name="Autocapture",this._isStarted=!1,this._eventHandlers=new Map,this._instance=e,this._config=t||qt.extractConfig(e.getConfig())}static extractConfig(e){var t;return"boolean"==typeof e.autocapture?{enabled:e.autocapture}:"object"==typeof e.autocapture&&null!==e.autocapture?{enabled:null===(t=e.autocapture.enabled)||void 0===t||t,url_allowlist:e.autocapture.url_allowlist,url_ignorelist:e.autocapture.url_ignorelist,dom_event_allowlist:e.autocapture.dom_event_allowlist,element_allowlist:e.autocapture.element_allowlist,css_selector_allowlist:e.autocapture.css_selector_allowlist,element_attribute_ignorelist:e.autocapture.element_attribute_ignorelist,capture_copied_text:e.autocapture.capture_copied_text}:{enabled:!1}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().autocapture}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._removeEventHandlers(),this._isStarted=!1)}onConfigUpdate(e){this._config=qt.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}updateConfig(e){this._config=i({},this._config,e)}_start(){this._isStarted||q&&q.addEventListener&&(this._addEventHandlers(),this._isStarted=!0)}_addEventHandlers(){var e,t=null!==(e=this._config.dom_event_allowlist)&&void 0!==e?e:mt;if(t.includes("submit")){var i=this._createEventHandler("submit");R(q,"submit",i,{capture:!0,passive:!0}),this._eventHandlers.set("submit",i)}if(t.includes("change")){var r=this._createEventHandler("change");R(q,"change",r,{capture:!0,passive:!0}),this._eventHandlers.set("change",r)}if(t.includes("click")){var n=this._createEventHandler("click");R(q,"click",n,{capture:!0,passive:!0}),this._eventHandlers.set("click",n)}}_removeEventHandlers(){var e=q;e&&(this._eventHandlers.forEach((t,i)=>{e.removeEventListener(i,t,{capture:!0})}),this._eventHandlers.clear())}_createEventHandler(e){return t=>{try{this._captureEvent(t,e)}catch(e){"undefined"!=typeof console&&console.error&&console.error("[vTilt] Autocapture error:",e)}}}_captureEvent(e,t){var i=function(e){if(e.composedPath&&"function"==typeof e.composedPath){var t=e.composedPath();if(t.length>0){var i=t[0];if(i instanceof Element)return i;if(i instanceof Node&&i.parentElement)return i.parentElement}}var r=e.target;return r instanceof Element?r:r instanceof Node&&r.parentElement?r.parentElement:null}(e);if(i){var r="click"===t?function(e,t){if(!e)return null;if(It(e,t))return e;for(var i=e.parentElement,r=0;i&&r<10;){if(It(i,t))return i;i=i.parentElement,r++}return null}(i,this._config):i;if(r&&$t(t,r,this._config)){var n=this._buildEventProperties(e,r,t);n&&this._instance.capture("$autocapture",n)}}}_buildEventProperties(e,t,r){var n=function(e,t){var i,r=[];if(!e)return r;for(var n=e,s=0;n&&s<10;){var o=null===(i=n.tagName)||void 0===i?void 0:i.toLowerCase();if("body"===o||"html"===o)break;var a=xt(n,t);a&&r.push(a),n=n.parentElement,s++}return r}(t,this._config);if(0===n.length)return null;var s,o=function(e){var t={};if(!e)return t;for(var i=e,r=0;i&&r<10;){try{var n=i.attributes;if(n)for(var s=0;s<n.length;s++){var o=n[s];if(o.name.startsWith(Ct)){var a=o.name.substring(16);!(a in t)&&o.value&&(t[a]=o.value)}}}catch(e){}i=i.parentElement,r++}return t}(t),a=i({$event_type:r,$elements_chain:(s=n,s.length?s.map(e=>{var t,i=e.tag_name;(null===(t=e.classes)||void 0===t?void 0:t.length)&&(i+="."+e.classes.join("."));var r=[];for(var[n,s]of Object.entries(e))if(n.startsWith("attr__")&&s){var o=n.replace("attr__","");r.push(o+'="'+Ot(String(s))+'"')}return e.nth_child&&r.push('nth-child="'+e.nth_child+'"'),e.nth_of_type&&r.push('nth-of-type="'+e.nth_of_type+'"'),r.length&&(i+=":"+r.join("")),i}).join(";"):""),$elements:n},o);return this._addElementSpecificProps(a,t,r),this._addEventSpecificProps(a,e,r),a}_addElementSpecificProps(e,t,i){var r=t.tagName.toLowerCase();if(e.$tag_name=r,"a"===r){var n=t.getAttribute("href");n&&(e.$href=n)}if(!Et(t)){var s=kt(t);s&&(e.$el_text=s)}if("change"===i&&("input"===r||"select"===r||"textarea"===r)){var o=t.getAttribute("type");o&&(e.$input_type=o)}}_addEventSpecificProps(e,t,i){if("click"===i&&t instanceof MouseEvent&&(e.$click_x=t.clientX,e.$click_y=t.clientY),"submit"===i&&t.target instanceof HTMLFormElement){var r=t.target.action;r&&(e.$form_action=r);var n=t.target.method;n&&(e.$form_method=n.toUpperCase())}}}var Dt="[SessionRecording]";class Ft{constructor(e,t){this._instance=e,this.name="SessionRecording",this._isStarted=!1,this._config=t||Ft.extractConfig(e.getConfig())}static extractConfig(e){var t,i,r,n=e.session_recording||{};return{enabled:null!==(t=n.enabled)&&void 0!==t&&t,sampleRate:n.sampleRate,minimumDurationMs:n.minimumDurationMs,sessionIdleThresholdMs:n.sessionIdleThresholdMs,fullSnapshotIntervalMs:n.fullSnapshotIntervalMs,captureConsole:null!==(i=n.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(r=n.captureNetwork)&&void 0!==r&&r,captureCanvas:n.captureCanvas,blockClass:n.blockClass,blockSelector:n.blockSelector,ignoreClass:n.ignoreClass,maskTextClass:n.maskTextClass,maskTextSelector:n.maskTextSelector,maskAllInputs:n.maskAllInputs,maskInputOptions:n.maskInputOptions,masking:n.masking,recordHeaders:n.recordHeaders,recordBody:n.recordBody,compressEvents:n.compressEvents,__mutationThrottlerRefillRate:n.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:n.__mutationThrottlerBucketSize}}get isEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!O&&i&&r}get isStarted(){var e;return this._isStarted&&!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}startIfEnabled(){this.startIfEnabledOrStop("recording_initialized")}startIfEnabledOrStop(e){var t;if(!this.isEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this.isEnabled&&i?(this._lazyLoadAndStart(e),this._isStarted=!0,console.info(Dt+" starting")):this.stop()}}stop(){y(()=>{var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop(),this._isStarted=!1})}onConfigUpdate(e){var t;this._config=Ft.extractConfig(e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config),this.startIfEnabledOrStop("config_updated")}onRemoteConfig(e){var t,r,n,s,o,a,l;if(e.sessionRecording){var d=e.sessionRecording;this._config=i({},this._config,{enabled:null!==(t=this._config.enabled)&&void 0!==t?t:d.enabled,sampleRate:null!==(r=this._config.sampleRate)&&void 0!==r?r:d.sampleRate,minimumDurationMs:null!==(n=this._config.minimumDurationMs)&&void 0!==n?n:d.minimumDurationMs,fullSnapshotIntervalMs:null!==(s=this._config.fullSnapshotIntervalMs)&&void 0!==s?s:d.fullSnapshotIntervalMs,maskAllInputs:null!==(o=this._config.maskAllInputs)&&void 0!==o?o:d.maskAllInputs,captureConsole:null!==(a=this._config.captureConsole)&&void 0!==a?a:d.captureConsole,captureCanvas:null!==(l=this._config.captureCanvas)&&void 0!==l?l:d.captureCanvas}),this.startIfEnabledOrStop("remote_config")}}get started(){return this.isStarted}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}stopRecording(){this.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(Dt+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this.isEnabled)if((null===(i=null===(t=null==j?void 0:j.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=j.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=j.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(Dt+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(Dt+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=j.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(Dt+" initSessionRecording not available after script load")}}var Nt=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Nt||{}),Bt=Uint8Array,jt=Uint16Array,Vt=Int32Array,Wt=new Bt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ht=new Bt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jt=new Bt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qt=function(e,t){for(var i=new jt(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new Vt(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},Gt=Qt(Wt,2),Kt=Gt.b,Xt=Gt.r;Kt[28]=258,Xt[258]=28;for(var Zt=Qt(Ht,0).r,Yt=new jt(32768),ei=0;ei<32768;++ei){var ti=(43690&ei)>>1|(21845&ei)<<1;ti=(61680&(ti=(52428&ti)>>2|(13107&ti)<<2))>>4|(3855&ti)<<4,Yt[ei]=((65280&ti)>>8|(255&ti)<<8)>>1}var ii=function(e,t,i){for(var r=e.length,n=0,s=new jt(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new jt(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new jt(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var d=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,c=h|(1<<u)-1;h<=c;++h)o[Yt[h]>>l]=d}else for(o=new jt(r),n=0;n<r;++n)e[n]&&(o[n]=Yt[a[e[n]-1]++]>>15-e[n]);return o},ri=new Bt(288);for(ei=0;ei<144;++ei)ri[ei]=8;for(ei=144;ei<256;++ei)ri[ei]=9;for(ei=256;ei<280;++ei)ri[ei]=7;for(ei=280;ei<288;++ei)ri[ei]=8;var ni=new Bt(32);for(ei=0;ei<32;++ei)ni[ei]=5;var si=ii(ri,9,0),oi=ii(ni,5,0),ai=function(e){return(e+7)/8|0},li=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new Bt(e.subarray(t,i))},di=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},ui=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},hi=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return{t:mi,l:0};if(1==n){var o=new Bt(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f<i[h].f?d++:h++],l=i[d!=u&&i[d].f<i[h].f?d++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=s[0].s;for(r=1;r<n;++r)s[r].s>c&&(c=s[r].s);var _=new jt(c+1),v=ci(i[u-1],_,0);if(v>t){r=0;var g=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(_[m]>t))break;g+=p-(1<<v-_[m]),_[m]=t}for(g>>=f;g>0;){var y=s[r].s;_[y]<t?g-=1<<t-_[y]++-1:++r}for(;r>=0&&g;--r){var b=s[r].s;_[b]==t&&(--_[b],++g)}v=t}return{t:new Bt(_),l:v}},ci=function(e,t,i){return-1==e.s?Math.max(ci(e.l,t,i+1),ci(e.r,t,i+1)):t[e.s]=i},_i=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new jt(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return{c:i.subarray(0,r),n:t}},vi=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},gi=function(e,t,i){var r=i.length,n=ai(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},fi=function(e,t,i,r,n,s,o,a,l,d,u){di(t,u++,i),++n[256];for(var h=hi(n,15),c=h.t,_=h.l,v=hi(s,15),g=v.t,f=v.l,p=_i(c),m=p.c,y=p.n,b=_i(g),S=b.c,w=b.n,C=new jt(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<S.length;++I)++C[31&S[I]];for(var E=hi(C,7),M=E.t,L=E.l,k=19;k>4&&!M[Jt[k-1]];--k);var T,x,P,R,A=d+5<<3,U=vi(n,ri)+vi(s,ni)+o,O=vi(n,c)+vi(s,g)+o+14+3*k+vi(C,M)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&A<=U&&A<=O)return gi(t,u,e.subarray(l,l+d));if(di(t,u,1+(O<U)),u+=2,O<U){T=ii(c,_,0),x=c,P=ii(g,f,0),R=g;var $=ii(M,L,0);di(t,u,y-257),di(t,u+5,w-1),di(t,u+10,k-4),u+=14;for(I=0;I<k;++I)di(t,u+3*I,M[Jt[I]]);u+=3*k;for(var z=[m,S],q=0;q<2;++q){var D=z[q];for(I=0;I<D.length;++I){var F=31&D[I];di(t,u,$[F]),u+=M[F],F>15&&(di(t,u,D[I]>>5&127),u+=D[I]>>12)}}}else T=si,x=ri,P=oi,R=ni;for(I=0;I<a;++I){var N=r[I];if(N>255){ui(t,u,T[(F=N>>18&31)+257]),u+=x[F+257],F>7&&(di(t,u,N>>23&31),u+=Wt[F]);var B=31&N;ui(t,u,P[B]),u+=R[B],B>3&&(ui(t,u,N>>5&8191),u+=Ht[B])}else ui(t,u,T[N]),u+=x[N]}return ui(t,u,T[256]),u+x[256]},pi=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mi=new Bt(0),yi=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),bi=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new Bt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,n.w=s.length}return function(e,t,i,r,n,s){var o=s.z||e.length,a=new Bt(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),d=s.l,u=7&(s.r||0);if(t){u&&(l[0]=s.r>>3);for(var h=pi[t-1],c=h>>13,_=8191&h,v=(1<<i)-1,g=s.p||new jt(32768),f=s.h||new jt(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},b=new Vt(25e3),S=new jt(288),w=new jt(32),C=0,I=0,E=s.i||0,M=0,L=s.w||0,k=0;E+2<o;++E){var T=y(E),x=32767&E,P=f[T];if(g[x]=P,f[T]=x,L<=E){var R=o-E;if((C>7e3||M>24576)&&(R>423||!d)){u=fi(e,l,0,b,S,w,I,M,k,E-k,u),M=C=I=0,k=E;for(var A=0;A<286;++A)S[A]=0;for(A=0;A<30;++A)w[A]=0}var U=2,O=0,$=_,z=x-P&32767;if(R>2&&T==y(E-z))for(var q=Math.min(c,R)-1,D=Math.min(32767,E),F=Math.min(258,R);z<=D&&--$&&x!=P;){if(e[E+U]==e[E+U-z]){for(var N=0;N<F&&e[E+N]==e[E+N-z];++N);if(N>U){if(U=N,O=z,N>q)break;var B=Math.min(z,N-2),j=0;for(A=0;A<B;++A){var V=E-z+A&32767,W=V-g[V]&32767;W>j&&(j=W,P=V)}}}z+=(x=P)-(P=g[x])&32767}if(O){b[M++]=268435456|Xt[U]<<18|Zt[O];var H=31&Xt[U],J=31&Zt[O];I+=Wt[H]+Ht[J],++S[257+H],++w[J],L=E+U,++C}else b[M++]=e[E],++S[e[E]]}}for(E=Math.max(E,L);E<o;++E)b[M++]=e[E],++S[e[E]];u=fi(e,l,d,b,S,w,I,M,k,E-k,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=g,s.i=E,s.w=L)}else{for(E=s.w||0;E<o+d;E+=65535){var Q=E+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=gi(l,u+1,e.subarray(E,Q))}s.i=o}return li(a,0,r+ai(u)+n)}(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,r,n)},Si=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function wi(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=yi[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=bi(e,t,10+((n=t).filename?n.filename.length+1:0),8),o=s.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Si(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Si(s,o-8,i.d()),Si(s,o-4,r),s}var Ci="undefined"!=typeof TextEncoder&&new TextEncoder,Ii="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ii.decode(mi,{stream:!0})}catch(e){}Nt.MouseMove,Nt.MouseInteraction,Nt.Scroll,Nt.ViewportResize,Nt.Input,Nt.TouchMove,Nt.MediaInteraction,Nt.Drag;var Ei="[Chat]";class Mi{constructor(e,t){this._instance=e,this.name="Chat",this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._isStarted=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t||Mi.extractConfig(e.getConfig())}static extractConfig(e){var t,i=e.chat||{};return{enabled:i.enabled,autoConfig:null===(t=i.autoConfig)||void 0===t||t,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline}}get isEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!this._instance.getConfig().disable_chat&&!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}get isStarted(){return this._isStarted}startIfEnabled(){this._startAsync().catch(e=>{console.error(Ei+" Error starting:",e)})}stop(){this.destroy(),this._isStarted=!1}onConfigUpdate(e){var t,i;this._config=Mi.extractConfig(e),this._lazyLoadedChat&&(null===(i=(t=this._lazyLoadedChat).updateConfig)||void 0===i||i.call(t,this.getMergedConfig()))}onRemoteConfig(e){var t,r,n,s,o,a,l,d,u;e.chat&&(this._serverConfig=i({},this._serverConfig,{enabled:null!==(n=null!==(t=e.chat.enabled)&&void 0!==t?t:null===(r=this._serverConfig)||void 0===r?void 0:r.enabled)&&void 0!==n&&n,position:null!==(a=null!==(s=e.chat.widgetPosition)&&void 0!==s?s:null===(o=this._serverConfig)||void 0===o?void 0:o.position)&&void 0!==a?a:"bottom-right",color:null!==(u=null!==(l=e.chat.widgetColor)&&void 0!==l?l:null===(d=this._serverConfig)||void 0===d?void 0:d.color)&&void 0!==u?u:"#6366f1"}),this.isEnabled&&!this._isStarted&&this.startIfEnabled())}_startAsync(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Ei+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e.isEnabled?(e._isStarted=!0,null!==(r=null!==(t=e._config.preload)&&void 0!==t?t:null===(i=e._serverConfig)||void 0===i?void 0:i.enabled)&&void 0!==r&&r&&e._schedulePreload(),(null===(n=e._serverConfig)||void 0===n?void 0:n.enabled)&&e._showBubble(),console.info(Ei+" ready (lazy-load on demand)")):console.info(Ei+" not enabled (check dashboard settings)")):console.info(Ei+" disabled by code config")})()}get isOpen(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}get channels(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channels)&&void 0!==t?t:[]}get currentView(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.currentView)&&void 0!==t?t:"list"}open(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.open()})}close(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.close()}toggle(){this._lazyLoadedChat?this._lazyLoadedChat.toggle():this.open()}show(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.show()})}hide(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.hide()}getChannels(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.getChannels()})}selectChannel(e){this._lazyLoadAndThen(()=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.selectChannel(e)})}createChannel(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.createChannel()})}goToChannelList(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.goToChannelList()}sendMessage(e){this._lazyLoadedChat?this._lazyLoadedChat.sendMessage(e):(this._pendingMessages.push(e),this._lazyLoadAndThen(()=>{this._pendingMessages.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.sendMessage(e)}),this._pendingMessages=[]}))}markAsRead(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.markAsRead()}onMessage(e){return this._messageCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,d,u,h,c,_,v,g,f,p,m=this._serverConfig,y=this._config;return{enabled:null!==(t=null!==(e=y.enabled)&&void 0!==e?e:null==m?void 0:m.enabled)&&void 0!==t&&t,autoConfig:null===(i=y.autoConfig)||void 0===i||i,position:null!==(n=null!==(r=y.position)&&void 0!==r?r:null==m?void 0:m.position)&&void 0!==n?n:"bottom-right",greeting:null!==(s=y.greeting)&&void 0!==s?s:null==m?void 0:m.greeting,color:null!==(a=null!==(o=y.color)&&void 0!==o?o:null==m?void 0:m.color)&&void 0!==a?a:"#6366f1",aiMode:null===(d=null!==(l=y.aiMode)&&void 0!==l?l:null==m?void 0:m.ai_enabled)||void 0===d||d,aiGreeting:null!==(u=y.aiGreeting)&&void 0!==u?u:null==m?void 0:m.ai_greeting,preload:null!==(h=y.preload)&&void 0!==h&&h,theme:null!==(c=y.theme)&&void 0!==c?c:{primaryColor:null!==(v=null!==(_=y.color)&&void 0!==_?_:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(g=y.offlineMessage)&&void 0!==g?g:null==m?void 0:m.offline_message,collectEmailOffline:null===(p=null!==(f=y.collectEmailOffline)&&void 0!==f?f:null==m?void 0:m.collect_email_offline)||void 0===p||p}}destroy(){y(()=>{var e,t;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[];var i=null===(t=null==O?void 0:O.document)||void 0===t?void 0:t.getElementById("vtilt-chat-bubble");i&&i.remove()})}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig(),i=t.token,r=t.api_host;if(!i||!r)return console.warn(Ei+" Cannot fetch settings: missing token or api_host"),void(e._configFetched=!0);try{var n=r+"/api/chat/settings?token="+encodeURIComponent(i),s=yield fetch(n);if(!s.ok)return console.warn(Ei+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Ei+" Loaded settings from dashboard")}catch(t){console.warn(Ei+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==O?void 0:O.document)&&!document.getElementById("vtilt-chat-bubble")){var e=this.getMergedConfig(),t=e.position||"bottom-right",i=e.color||"#6366f1",r=document.createElement("div");r.id="vtilt-chat-bubble",r.setAttribute("style",("\n position: fixed;\n bottom: 20px;\n "+("bottom-right"===t?"right: 20px;":"left: 20px;")+"\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+i+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),r.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n ',r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.05)",r.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),r.addEventListener("click",()=>{this.open()}),document.body.appendChild(r)}}get _scriptName(){return"chat"}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._lazyLoad(),{timeout:5e3}):setTimeout(()=>this._lazyLoad(),3e3)}_lazyLoadAndThen(e){this._lazyLoadedChat?e():(this._pendingCallbacks.push(e),this._lazyLoad())}_lazyLoad(){var e,t;if(!(this._isLoading||this._lazyLoadedChat||this._loadError))if(null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=j.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Ei+" loadExternalDependency not available. Chat cannot start."),this._isLoading=!1,void(this._loadError="loadExternalDependency not available");i(this._instance,this._scriptName,e=>{if(this._isLoading=!1,e)return console.error(Ei+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Ei+" initChat not available after script load"),void(this._loadError="initChat not available");if(!this._lazyLoadedChat){var i=this.getMergedConfig();this._lazyLoadedChat=t(this._instance,i),this._messageCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onMessage(e)}),this._typingCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onTyping(e)}),this._connectionCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onConnectionChange(e)});var r=null===document||void 0===document?void 0:document.getElementById("vtilt-chat-bubble");r&&r.remove()}this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],console.info(Ei+" loaded and ready")}}var Li,ki="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Li||(Li={}));var Ti=e=>{var{data:t,compression:i}=e;if(t){var r=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),n=new Blob([r]).size;if(i===Li.GZipJS&&n>=1024)try{var s=wi(function(e,t){if(Ci)return Ci.encode(e);for(var i=e.length,r=new Bt(e.length+(e.length>>1)),n=0,s=function(e){r[n++]=e},o=0;o<i;++o){if(n+5>r.length){var a=new Bt(n+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return li(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:ki});if(o.size<.95*n)return{contentType:ki,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},xi=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Ti(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Li.GZipJS&&n===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,l=i({"Content-Type":n},e.headers||{}),d=new AbortController,u=e.timeout?setTimeout(()=>d.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:l,body:s,keepalive:o<52428.8,signal:d.signal}).then(function(){var i=t(function*(t){var i,r=yield t.text(),n={statusCode:t.status,text:r};if(200===t.status)try{n.json=JSON.parse(r)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,n)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{u&&clearTimeout(u)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Ti(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Li.GZipJS&&i===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,s=new XMLHttpRequest;s.open(e.method||"POST",n,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;s.setRequestHeader(t,i)}),s.setRequestHeader("Content-Type",i),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{var t;if(4===s.readyState){var i={statusCode:s.status,text:s.responseText};if(200===s.status)try{i.json=JSON.parse(s.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},s.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},s.send(r)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Ti(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Li.GZipJS&&i===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Pi=e=>{var t,i=e.transport||"fetch",r=xi.find(e=>e.name===i&&e.available)||xi.find(e=>e.available);if(!r)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));r.method(e)};class Ri{constructor(e,t){var i,r,n,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,n=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,r),n)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(i({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var r=e[i];r.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class Ai{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,O&&void 0!==z&&"onLine"in z&&(this._areWeOnline=z.onLine,R(O,"online",()=>{this._areWeOnline=!0,this._flush()}),R(O,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),n=(Math.random()-.5)*(r-i);return Math.ceil(r+n)}(t),r=Date.now()+i;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var n="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(n+=" (Browser is offline)"),console.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),r=[],n=[];this._queue.forEach(e=>{e.retryAt<i?n.push(e):r.push(e)}),this._queue=r,n.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:r}=t;try{var n=yield e._sendRequest(i);200!==n.statusCode&&(n.statusCode<400||n.statusCode>=500)&&e.enqueue(i,r)}catch(t){e.enqueue(i,r)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var Ui="vt_rate_limit";class Oi{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,r,n;void 0===e&&(e=!1);var s=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(Ui))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(n=this.persistence)||void 0===n||n.set(Ui,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class $i{constructor(e){this._remoteConfig=null,this._host=e}get config(){return this._remoteConfig}onApply(e){this._onApply=e}onLoad(e){this._onLoad=e}load(){var e,t=this._host.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._apply(this._remoteConfig),void this._fetch();var i=y(()=>O.__VTILT_BOOTSTRAP__);if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._apply(this._remoteConfig),void this._fetch();y(()=>{var e=localStorage.getItem(u+"_"+t.projectId);e&&(this._remoteConfig=JSON.parse(e),this._apply(this._remoteConfig))}),this._fetch()}}_fetch(){var e=this._host.getConfig();if(e.projectId&&e.api_host){var t=e.api_host+"/api/projects/"+e.projectId+"/decide",i=new AbortController,r=setTimeout(()=>i.abort(),3e3);(F||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{var i;clearTimeout(r),this._remoteConfig=t,y(()=>{localStorage.setItem(u+"_"+e.projectId,JSON.stringify(t))}),this._apply(t),null===(i=this._onLoad)||void 0===i||i.call(this,t)}).catch(()=>{clearTimeout(r)})}}_apply(e){var t,i,r,n,s,o,a,l,d,u=this._host.getConfig(),h={},c=!1,_=!1,v=!1;e.sessionRecording&&void 0===u.session_recording&&(h.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,fullSnapshotIntervalMs:e.sessionRecording.fullSnapshotIntervalMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(c=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===u.chat&&(h.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},_=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===u.capture_pageview&&(h.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===u.capture_pageleave&&(h.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===u.capture_performance&&(h.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===u.autocapture&&(h.autocapture=e.analytics.autocapture,e.analytics.autocapture&&(v=!0))),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===u.respect_dnt&&(h.respect_dnt=e.privacy.respectDnt),Object.keys(h).length>0&&this._host.updateConfig(h),null===(r=this._onApply)||void 0===r||r.call(this,e),this._host.__loaded&&(c&&(null===(s=(n=this._host).startSessionRecording)||void 0===s||s.call(n)),_&&(null===(a=(o=this._host)._initChat)||void 0===a||a.call(o)),v&&(null===(d=(l=this._host).startAutocapture)||void 0===d||d.call(l)))}}class zi{constructor(e){this._set_once_properties_sent=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this._vt_person_uuid=null,this._host=e}setVtPersonUuid(e){this._vt_person_uuid=e}capture(e,t,r){var n;if(this._host.sessionManager.setSessionId(),(null==z?void 0:z.userAgent)&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(z.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this._host.rateLimiter.shouldAllowEvent())){var s,o=this._host.buildUrl(),a=this._host.getConfig(),l=this._buildEventPayload(e,t);if(!1!==a.stringifyPayload){if(!x(s=JSON.stringify(i({},l,a.globalAttributes))))return}else if(s=i({},l,a.globalAttributes),!x(JSON.stringify(s)))return;var d="$identify"===e?this._host.userManager.getAnonymousId():null!==(n=this._host.userManager.getDistinctId())&&void 0!==n?n:this._host.userManager.getAnonymousId(),u={timestamp:(new Date).toISOString(),event:e,project_id:a.projectId||"",payload:s,distinct_id:d,anonymous_id:this._host.userManager.getAnonymousId()};this._host.sendRequest(o,u,!0)}}captureInternal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}captureInitialPageview(){q&&("visible"===q.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{q&&D&&this.capture("$pageview",{navigation_type:"initial_load"})},300),this._visibility_state_listener&&(q.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>this.captureInitialPageview(),R(q,"visibilitychange",this._visibility_state_listener)))}_buildEventPayload(e,t){var r=lt(),n=this._host.userManager.getUserProperties(),s=this._host.userManager.get_initial_props(),o=this._host.sessionManager.getSessionId(),a=this._host.sessionManager.getWindowId(),l=this._host.userManager.getAnonymousId(),d={};!this._set_once_properties_sent&&Object.keys(s).length>0&&Object.assign(d,s),t.$set_once&&Object.assign(d,t.$set_once);var u=i({},r,n,{$session_id:o,$window_id:a},l?{$anon_distinct_id:l}:{},this._vt_person_uuid?{$vt:this._vt_person_uuid}:{},Object.keys(d).length>0?{$set_once:d}:{},t.$set?{$set:t.$set}:{},t);return!this._set_once_properties_sent&&Object.keys(s).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&q&&(u.title=q.title),u}}class qi{constructor(e){this._host=e}identify(e,t,i){var r;if("number"==typeof e&&(e=String(e),console.warn("identify: first argument should be a string, not a number")),e)if(this._host.userManager.isDistinctIdStringLikePublic(e))console.error('identify: "'+e+'" appears to be a hardcoded string');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this._host.userManager.getDistinctId(),s=this._host.userManager.getAnonymousId(),o=this._host.userManager.getDeviceId(),a="anonymous"===this._host.userManager.getUserState();o||this._host.userManager.ensureDeviceId(n||s),e!==n&&a?(this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$identify",{distinct_id:e,$anon_distinct_id:s,$set:t||{},$set_once:i||{}}),this._host.userManager.setDistinctId(e),null===(r=this._host._emitter)||void 0===r||r.emit("user:identified",{distinctId:e})):t||i?(a&&this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$set",{$set:t||{},$set_once:i||{}})):e!==n&&(this._host.userManager.setUserState("identified"),this._host.userManager.setDistinctId(e))}else console.error("identify: cannot use sentinel value as distinct_id");else console.error("identify: unique user id is required")}setUserProperties(e,t){var i;this._host.userManager.setUserProperties(e,t)&&(this._host.capture("$set",{$set:e||{},$set_once:t||{}}),null===(i=this._host._emitter)||void 0===i||i.emit("user:properties_set",{properties:e}))}resetUser(e){var t;this._host.sessionManager.resetSessionId(),this._host.userManager.reset(e),null===(t=this._host._emitter)||void 0===t||t.emit("user:reset")}createAlias(e,t){var i=this._host.userManager.createAlias(e,t);i?this._host.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this._host.userManager.getDistinctId()||this._host.userManager.getAnonymousId())&&this.identify(e)}getUserIdentity(){return this._host.userManager.getUserIdentity()}getDeviceId(){return this._host.userManager.getDeviceId()}getUserState(){return this._host.userManager.getUserState()}getDistinctId(){var e;return null!==(e=this._host.userManager.getDistinctId())&&void 0!==e?e:this._host.userManager.getAnonymousId()}getAnonymousId(){return this._host.userManager.getAnonymousId()}}class Di{constructor(e){this._features=new Map,this._host=e}onFeatureStarted(e){this._onFeatureStarted=e}onFeatureStopped(e){this._onFeatureStopped=e}register(e){this._features.set(e.name,e)}get(e){var t;return null===(t=this._features.get(e))||void 0===t?void 0:t.instance}initAll(){this._features.forEach(e=>{this._initFeature(e)})}init(e){var t=this._features.get(e);if(t)return this._initFeature(t),t.instance}start(e){var t,i=this._features.get(e);if(i&&(i.instance||this._initFeature(i),i.instance)){if(i.instance.onConfigUpdate){var r=this._host.getConfig();i.instance.onConfigUpdate(r)}i.instance.startIfEnabled(),null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e)}}stop(e){var t,i=this._features.get(e);(null==i?void 0:i.instance)&&(i.instance.stop(),null===(t=this._onFeatureStopped)||void 0===t||t.call(this,e))}isActive(e){var t,i,r;return null!==(r=null===(i=null===(t=this._features.get(e))||void 0===t?void 0:t.instance)||void 0===i?void 0:i.isStarted)&&void 0!==r&&r}notifyConfigUpdate(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onConfigUpdate)&&y(()=>t.instance.onConfigUpdate(e))})}notifyRemoteConfig(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onRemoteConfig)&&y(()=>t.instance.onRemoteConfig(e))})}getAll(){var e=[];return this._features.forEach(t=>{t.instance&&e.push(t.instance)}),e}_initFeature(e){if(!e.instance){var t=this._host.getConfig();e.disableKey&&t[e.disableKey]||e.enableKey&&!1===t[e.enableKey]||y(()=>{var t;e.instance=new e.FeatureClass(this._host),e.instance.startIfEnabled(),e.instance.isStarted&&(null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e.name))})}}}var Fi="vt";class Ni{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this.__request_queue=[],this._has_warned_about_config=!1,this._emitter=new b,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new dt(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.rateLimiter=new Oi({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._captureManager.captureInternal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new Ai({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new Ri(e=>this._send_batched_request(e),{flush_interval_ms:3e3}),this._captureManager=new zi(this),this._identityManager=new qi(this),this._remoteConfigManager=new $i(this),this._featureManager=new Di(this),this._remoteConfigManager.onApply(e=>{this._featureManager.notifyRemoteConfig(e)}),this._remoteConfigManager.onLoad(e=>{this._emitter.emit(C,{config:e})}),this._featureManager.onFeatureStarted(e=>{this._emitter.emit(I,{feature:e})}),this._featureManager.onFeatureStopped(e=>{this._emitter.emit(E,{feature:e})})}init(e,t,i){var r;if(i&&i!==Fi){var n=null!==(r=Bi[i])&&void 0!==r?r:new Ni;return n._init(e,t,i),Bi[i]=n,Bi[Fi][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: Already initialized! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0,this._read_vt_param_from_url(),this._remoteConfigManager.load();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this._initFeatures(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._captureManager.captureInitialPageview(),this._emitter.emit(S,{config:n}),this}_initFeatures(){this._initHistoryAutocapture(),this._initAutocapture(),this._initWebVitals(),this._initSessionRecording(),this._initChat()}_initHistoryAutocapture(){this.historyAutocapture||(this.historyAutocapture=new ft(this),this.historyAutocapture.startIfEnabled())}_initAutocapture(){this.autocapture||!1!==this.configManager.getConfig().autocapture&&(this.autocapture=new qt(this),this.autocapture.startIfEnabled())}_initWebVitals(){this.webVitals||(this.webVitals=new vt(this),this.webVitals.startIfEnabled())}_initSessionRecording(){this.sessionRecording||(this.configManager.getConfig().disable_session_recording||(this.sessionRecording=new Ft(this),this.sessionRecording.isEnabled&&(this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(L))))}_initChat(){this.chat||(this.configManager.getConfig().disable_chat||(this.chat=new Mi(this),this.chat.startIfEnabled()))}startAutocapture(){this.autocapture||(this.autocapture=new qt(this)),this.autocapture.updateConfig({enabled:!0}),this.autocapture.startIfEnabled()}stopAutocapture(){var e;null===(e=this.autocapture)||void 0===e||e.stop()}isAutocaptureActive(){var e,t;return null!==(t=null===(e=this.autocapture)||void 0===e?void 0:e.isStarted)&&void 0!==t&&t}startSessionRecording(){this.sessionRecording||(this.sessionRecording=new Ft(this)),this.sessionRecording.updateConfig({enabled:!0}),this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(L)}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stop(),this._emitter.emit(k)}isRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}capture(e,t,i){this._captureManager.capture(e,t,i),this._emitter.emit(M,{event:e,payload:t})}trackEvent(e,t){void 0===t&&(t={}),this._captureManager.trackEvent(e,t)}identify(e,t,i){this._identityManager.identify(e,t,i)}setUserProperties(e,t){this._identityManager.setUserProperties(e,t)}resetUser(e){this._identityManager.resetUser(e)}createAlias(e,t){this._identityManager.createAlias(e,t)}getUserIdentity(){return this._identityManager.getUserIdentity()}getDeviceId(){return this._identityManager.getDeviceId()}getUserState(){return this._identityManager.getUserState()}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this._identityManager.getDistinctId()}getAnonymousId(){return this._identityManager.getAnonymousId()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:Fi;return t!==Fi&&(t="vt."+t),t}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new dt(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this._notifyFeaturesOfConfigUpdate(t),this._emitter.emit(w,{config:t})}_notifyFeaturesOfConfigUpdate(e){[this.historyAutocapture,this.autocapture,this.webVitals,this.sessionRecording,this.chat].forEach(t=>{(null==t?void 0:t.onConfigUpdate)&&y(()=>t.onConfigUpdate(e))})}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:r,token:n}=e;return t||(i?i+"/api/tracking?token="+n:r?r.replace(/\/+$/gm,"")+"/api/tracking?token="+n:"/api/tracking?token="+n)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==O)if(O.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking"),this._has_warned_about_config=!0),!1)}_send_batched_request(e){"sendBeacon"!==e.transport?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:r}=e,n=1===r.length?r[0]:{events:r},s=this.configManager.getConfig().disable_compression?Li.None:Li.GZipJS;Pi({url:i,data:n,method:"POST",transport:"XHR",compression:s,callback:e=>t({statusCode:e.statusCode})})})}_send_beacon_request(e){var{url:t,events:i}=e,r=1===i.length?i[0]:{events:i},n=this.configManager.getConfig().disable_compression?Li.None:Li.GZipJS;Pi({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}_setup_unload_handler(){if(O){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};R(O,"beforeunload",e),R(O,"pagehide",e)}}_start_queue_if_opted_in(){this.requestQueue.enable()}_read_vt_param_from_url(){y(()=>{var e,t;if(void 0!==D&&D.search){var i=new URL(D.href),r=i.searchParams.get("vt");if(null==r?void 0:r.trim()){this._captureManager.setVtPersonUuid(r.trim()),i.searchParams.delete("vt");var n=i.pathname+(i.search||"")+i.hash;null===(t=null===(e=null==O?void 0:O.history)||void 0===e?void 0:e.replaceState)||void 0===t||t.call(e,{},"",n)}}})}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);"function"==typeof this[t]&&y(()=>this[t](...i))}})}_dom_loaded(){this.__request_queue.forEach(e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}}var Bi={},ji=!(void 0!==N||void 0!==F)&&-1===(null==B?void 0:B.indexOf("MSIE"))&&-1===(null==B?void 0:B.indexOf("Mozilla"));null!=O&&(O.__VTILT_ENQUEUE_REQUESTS=ji);var Vi,Wi=(Vi=Bi[Fi]=new Ni,function(){function e(){e.done||(e.done=!0,ji=!1,null!=O&&(O.__VTILT_ENQUEUE_REQUESTS=!1),P(Bi,e=>e._dom_loaded()))}q&&"function"==typeof q.addEventListener?"complete"===q.readyState?e():R(q,"DOMContentLoaded",e,{capture:!1}):O&&console.error("Browser doesn't support document.addEventListener")}(),Vi);export{ut as ALL_WEB_VITALS_METRICS,ht as DEFAULT_WEB_VITALS_METRICS,Ni as VTilt,Wi as default,Wi as vt};
1
+ function e(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,n)}function t(t){return function(){var i=this,r=arguments;return new Promise(function(n,s){var o=t.apply(i,r);function a(t){e(o,n,s,a,l,"next",t)}function l(t){e(o,n,s,a,l,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}var r="1.10.2",n="__vt_session",s="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",l="__vt_device_id",u="__vt_anonymous_id",d="__vt_remote_config",h="__vt_distinct_id",c="__vt_user_properties",_="localStorage",v="localStorage+cookie",g="sessionStorage",f="memory",p="$initial_person_info";class m{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,r=i({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.proxy=t.getAttribute("data-proxy")||e.proxy,r.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,r.token=t.getAttribute("data-token")||e.token||"",r.projectId=t.getAttribute("data-project-id")||e.projectId||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var n="true"===t.getAttribute("data-capture-performance");if(r.capture_performance=!!n||e.capture_performance,r.proxy&&r.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var s of(r.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(r.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return r}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}function y(e,t){try{return e()}catch(e){return t}}class b{constructor(){this._events=new Map,this._onceEvents=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>{var i;null===(i=this._events.get(e))||void 0===i||i.delete(t)}}once(e,t){return this._onceEvents.has(e)||this._onceEvents.set(e,new Set),this._onceEvents.get(e).add(t),()=>{var i;null===(i=this._onceEvents.get(e))||void 0===i||i.delete(t)}}emit(e,t){var i,r;null===(i=this._events.get(e))||void 0===i||i.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in event listener for "'+e+'":',t)}});var n=this._onceEvents.get(e);n&&(n.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in once listener for "'+e+'":',t)}}),this._onceEvents.delete(e)),null===(r=this._events.get("*"))||void 0===r||r.forEach(i=>{try{i({event:e,payload:t})}catch(e){console.error("[vTilt] Error in wildcard listener:",e)}})}off(e){e?(this._events.delete(e),this._onceEvents.delete(e)):(this._events.clear(),this._onceEvents.clear())}listenerCount(e){var t,i,r,n;return(null!==(i=null===(t=this._events.get(e))||void 0===t?void 0:t.size)&&void 0!==i?i:0)+(null!==(n=null===(r=this._onceEvents.get(e))||void 0===r?void 0:r.size)&&void 0!==n?n:0)}hasListeners(e){return this.listenerCount(e)>0}}var S="sdk:initialized",w="sdk:config_updated",C="sdk:remote_config_loaded",I="feature:started",E="feature:stopped",k="event:captured",M="recording:started",L="recording:stopped";function x(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function T(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function R(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(i,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(i,e[r],r)}function A(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}function P(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function O(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var n of i)for(var s of n)e.push(s);return e}var $="undefined"!=typeof window?window:void 0,U="undefined"!=typeof globalThis?globalThis:$,z=null==U?void 0:U.navigator,N=null==U?void 0:U.document,q=null==U?void 0:U.location,D=null==U?void 0:U.fetch,F=(null==U?void 0:U.XMLHttpRequest)&&"withCredentials"in new U.XMLHttpRequest?U.XMLHttpRequest:void 0;null==U||U.AbortController;var j=null==z?void 0:z.userAgent,B=null!=$?$:{},V=[u,l,h,a],W=31536e3,H=["herokuapp.com","vercel.app","netlify.app"];function J(e){var t;if(!e||"undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var r=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class K{constructor(e){var t,i,r;this.memoryStorage=new Map,this._localStorageSupported=null,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");return!H.includes(i)}(),this.sameSite=null!==(i=e.sameSite)&&void 0!==i?i:"Lax",this.secure=null!==(r=e.secure)&&void 0!==r?r:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this._localStorageSupported)return this._localStorageSupported;if(void 0===$||!$.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";$.localStorage.setItem(e,"1");var t="1"===$.localStorage.getItem(e);return $.localStorage.removeItem(e),this._localStorageSupported=t,t||console.warn("[vTilt] localStorage unavailable, using cookies"),t}catch(e){return this._localStorageSupported=!1,console.warn("[vTilt] localStorage unavailable, using cookies"),!1}}isCriticalProperty(e){return V.includes(e)}get(e){var t;try{switch(this.method){case f:return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;case v:return this.getLocalStoragePlusCookie(e);case _:return this.getLocalStorage(e);case g:return this.readFromSessionStorage(e);default:return this.getCookie(e)}}catch(t){return console.warn('[vTilt] Storage get error for "'+e+'":',t),null}}set(e,t,i){try{switch(this.method){case f:this.memoryStorage.set(e,t);break;case v:this.setLocalStoragePlusCookie(e,t,i);break;case _:this.setLocalStorage(e,t);break;case g:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:W)}}catch(t){console.warn('[vTilt] Storage set error for "'+e+'":',t)}}remove(e){try{switch(this.method){case f:this.memoryStorage.delete(e);break;case v:this.removeLocalStoragePlusCookie(e);break;case _:this.removeLocalStorage(e);break;case g:this.removeFromSessionStorage(e);break;default:this.removeCookie(e)}}catch(t){console.warn('[vTilt] Storage remove error for "'+e+'":',t)}}getLocalStoragePlusCookie(e){if(this.isCriticalProperty(e)){var t=this.getCookie(e),i=this.getLocalStorage(e);if(null!==t){if(i!==t&&this.isLocalStorageSupported())try{null==$||$.localStorage.setItem(e,t)}catch(e){}return t}return i}return this.getLocalStorage(e)}setLocalStoragePlusCookie(e,t,i){this.setLocalStorage(e,t),this.isCriticalProperty(e)&&this.setCookie(e,t,null!=i?i:W)}removeLocalStoragePlusCookie(e){this.removeLocalStorage(e),this.isCriticalProperty(e)&&this.removeCookie(e)}getLocalStorage(e){var t;if(!this.isLocalStorageSupported())return null;try{return null!==(t=null==$?void 0:$.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==$||$.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==$||$.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==$?void 0:$.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==$||$.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==$||$.sessionStorage.removeItem(e)}catch(e){}}getCookie(e){if("undefined"==typeof document)return null;var t=e+"=";for(var i of document.cookie.split(";")){var r=i.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var r=J(this.cross_subdomain),n=e+"="+encodeURIComponent(t)+"; Max-Age="+i+"; path=/; SameSite="+this.sameSite;this.secure&&(n+="; Secure"),r&&(n+="; domain="+r),document.cookie=n}}removeCookie(e){if("undefined"!=typeof document){var t=J(this.cross_subdomain);document.cookie=e+"=; Max-Age=0; path=/"+(t?"; domain="+t:""),document.cookie=e+"=; Max-Age=0; path=/"}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,r){var n=i({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(n))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}canUseSessionStorage(){if(void 0===$||!(null==$?void 0:$.sessionStorage))return!1;try{var e="__vt_ss_test__";return $.sessionStorage.setItem(e,"1"),$.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==$?void 0:$.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class G{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new K({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=x(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||x();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(x())}_getSessionIdRaw(){return this.storage.get(n)}_storeSessionId(e){this.storage.set(n,e,1800)}_clearSessionId(){this.storage.remove(n)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(s);if(t)return this._windowId=t,t}var i=x();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(s,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(s);i&&!t?this._windowId=i:(i&&e.removeItem(s),this._setWindowId(x())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=x()}_listenToUnload(){var e=this.storage.getSessionStorage();$&&e&&A($,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new K({method:e,cross_subdomain:t,sameSite:"Lax"})}}function Q(e){if(!N)return null;var t=N.createElement("a");return t.href=e,t}function X(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<i.length;r++){var n=i[r].split("=");if(n[0]===t){if(n.length<2)return"";var s=n[1];try{s=decodeURIComponent(s)}catch(e){}return s.replace(/\+/g," ")}}return""}function Z(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),d=[],h=0;h<u.length;h++){var c=u[h].split("="),_=c[0],v=c.slice(1).join("=");-1!==t.indexOf(_)?d.push(_+"="+i):_&&d.push(_+(v?"="+v:""))}var g=d.join("&");return l+(g?"?"+g:"")+(s?"#"+s:"")}function Y(e){return"function"==typeof e}var ee="Mobile",te="iOS",ie="Android",re="Tablet",ne=ie+" "+re,se="iPad",oe="Apple",ae=oe+" Watch",le="Safari",ue="BlackBerry",de="Samsung",he=de+"Browser",ce=de+" Internet",_e="Chrome",ve=_e+" OS",ge=_e+" "+te,fe="Internet Explorer",pe=fe+" "+ee,me="Opera",ye=me+" Mini",be="Edge",Se="Microsoft "+be,we="Firefox",Ce=we+" "+te,Ie="Nintendo",Ee="PlayStation",ke="Xbox",Me=ie+" "+ee,Le=ee+" "+le,xe="Windows",Te=xe+" Phone",Re="Nokia",Ae="Ouya",Pe="Generic",Oe=Pe+" "+ee.toLowerCase(),$e=Pe+" "+re.toLowerCase(),Ue="Konqueror",ze="(\\d+(\\.\\d+)?)",Ne=new RegExp("Version/"+ze),qe=new RegExp(ke,"i"),De=new RegExp(Ee+" \\w+","i"),Fe=new RegExp(Ie+" \\w+","i"),je=new RegExp(ue+"|PlayBook|BB10","i"),Be={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Ve(e,t){return e.toLowerCase().includes(t.toLowerCase())}var We=(e,t)=>t&&Ve(t,oe)||function(e){return Ve(e,le)&&!Ve(e,_e)&&!Ve(e,ie)}(e),He=function(e,t){return t=t||"",Ve(e," OPR/")&&Ve(e,"Mini")?ye:Ve(e," OPR/")?me:je.test(e)?ue:Ve(e,"IE"+ee)||Ve(e,"WPDesktop")?pe:Ve(e,he)?ce:Ve(e,be)||Ve(e,"Edg/")?Se:Ve(e,"FBIOS")?"Facebook "+ee:Ve(e,"UCWEB")||Ve(e,"UCBrowser")?"UC Browser":Ve(e,"CriOS")?ge:Ve(e,"CrMo")||Ve(e,_e)?_e:Ve(e,ie)&&Ve(e,le)?Me:Ve(e,"FxiOS")?Ce:Ve(e.toLowerCase(),Ue.toLowerCase())?Ue:We(e,t)?Ve(e,ee)?Le:le:Ve(e,we)?we:Ve(e,"MSIE")||Ve(e,"Trident/")?fe:Ve(e,"Gecko")?we:""},Je={[pe]:[new RegExp("rv:"+ze)],[Se]:[new RegExp(be+"?\\/"+ze)],[_e]:[new RegExp("("+_e+"|CrMo)\\/"+ze)],[ge]:[new RegExp("CriOS\\/"+ze)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ze)],[le]:[Ne],[Le]:[Ne],[me]:[new RegExp("(Opera|OPR)\\/"+ze)],[we]:[new RegExp(we+"\\/"+ze)],[Ce]:[new RegExp("FxiOS\\/"+ze)],[Ue]:[new RegExp("Konqueror[:/]?"+ze,"i")],[ue]:[new RegExp(ue+" "+ze),Ne],[Me]:[new RegExp("android\\s"+ze,"i")],[ce]:[new RegExp(he+"\\/"+ze)],[fe]:[new RegExp("(rv:|MSIE )"+ze)],Mozilla:[new RegExp("rv:"+ze)]},Ke=function(e,t){var i=He(e,t),r=Je[i];if(void 0===r)return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},Ge=[[new RegExp(ke+"; "+ke+" (.*?)[);]","i"),e=>[ke,e&&e[1]||""]],[new RegExp(Ie,"i"),[Ie,""]],[new RegExp(Ee,"i"),[Ee,""]],[je,[ue,""]],[new RegExp(xe,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Te,""];if(new RegExp(ee).test(t)&&!/IEMobile\b/.test(t))return[xe+" "+ee,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Be[r]||"";return/arm/i.test(t)&&(n="RT"),[xe,n]}return[xe,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[te,t.join(".")]}return[te,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ie+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ie+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ie,t.join(".")]}return[ie,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ve,""]],[/Linux|debian/i,["Linux",""]]],Qe=function(e){return Fe.test(e)?Ie:De.test(e)?Ee:qe.test(e)?ke:new RegExp(Ae,"i").test(e)?Ae:new RegExp("("+Te+"|WPDesktop)","i").test(e)?Te:/iPad/.test(e)?se:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ae:je.test(e)?ue:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Re,"i").test(e)?Re:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ee).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ie:ne:ie:new RegExp("(pda|"+ee+")","i").test(e)?Oe:new RegExp(re,"i").test(e)&&!new RegExp(re+" pc","i").test(e)?$e:""},Xe="https?://(.*)",Ze=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ye=O(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ze),et="<masked>";function tt(e){var t=function(e){return e?0===e.search(Xe+"google.([^/?]*)")?"google":0===e.search(Xe+"bing.com")?"bing":0===e.search(Xe+"yahoo.com")?"yahoo":0===e.search(Xe+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=N?X(N.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function it(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function rt(){return(null==N?void 0:N.referrer)||"$direct"}function nt(){var e;return(null==N?void 0:N.referrer)&&(null===(e=Q(N.referrer))||void 0===e?void 0:e.host)||"$direct"}function st(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=Q(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=Q(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Ye.concat([]),i={};return R(t,function(t){var r=X(e,t);i[t]=r||null}),i}(r);P(n,o)}i&&P(n,tt(i));return n}function ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function at(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function lt(e,t){if(!j)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<Ge.length;t++){var[i,r]=Ge[t],n=i.exec(e),s=n&&(Y(r)?r(n,e):r);if(s)return s}return["",""]}(j);return P(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=e[i];null!=r&&""!==r&&(t[i]=r)}return t}({$os:o,$os_version:a,$browser:He(j,navigator.vendor),$device:Qe(j),$device_type:(n=j,s=Qe(n),s===se||s===ne||"Kobo"===s||"Kindle Fire"===s||s===$e?re:s===Ie||s===ke||s===Ee||s===Ae?"Console":s===ae?"Wearable":s?ee:"Desktop"),$timezone:ot(),$timezone_offset:at()}),{$current_url:Z(null==q?void 0:q.href,[],et),$host:null==q?void 0:q.host,$pathname:null==q?void 0:q.pathname,$raw_user_agent:j.length>1e3?j.substring(0,997)+"...":j,$browser_version:Ke(j,navigator.vendor),$browser_language:it(),$browser_language_prefix:(i=it(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==$?void 0:$.screen.height,$screen_width:null==$?void 0:$.screen.width,$viewport_height:null==$?void 0:$.innerHeight,$viewport_width:null==$?void 0:$.innerWidth,$lib:"web",$lib_version:r,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class ut{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new K({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(u,this.userIdentity.anonymous_id,W)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,r){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var s=n||this.userIdentity.anonymous_id;this.userIdentity.device_id=s,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:s})}e!==n&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==n&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):t||r?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):e!==n&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var r=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,n=this.getPersonPropertiesHash(r,e,t);return this._cachedPersonProperties===n?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=n,!0)}reset(e){var t=this.generateAnonymousId(),r=this.userIdentity.device_id,n=e?this.generateDeviceId():r;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:n,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[p]){var i=function(e,t){var i=e?O([],Ze,t||[]):[],r=null==q?void 0:q.href.substring(0,1e3);return{r:rt().substring(0,1e3),u:r?Z(r,i,et):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=st(i),t={},R(e,function(e,i){var r;t["$initial_"+(r=String(i),r.startsWith("$")?r.substring(1):r)]=e}),t):{}}update_referrer_info(){var e={$referrer:rt(),$referring_domain:nt()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(u),t=this.storage.get(l),i=this.storage.get(h),r=this.storage.get(a),n=this.getStoredUserProperties(),s=e||this.generateAnonymousId(),o=t||this.generateDeviceId(),d=i||null,c=r||"anonymous",_=s||this.generateAnonymousId();return e||this.storage.set(u,_,W),t||this.storage.set(l,o,W),r||this.storage.set(a,c,W),{distinct_id:d,anonymous_id:_,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(u,this.userIdentity.anonymous_id,W),this.storage.set(l,this.userIdentity.device_id,W),this.storage.set(a,this.userIdentity.user_state,W),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,W):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,W)}register_once(e,t){var i=this.getStoredUserProperties(),r=!1;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(n in i||(i[n]=e[n],r=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in i||(i[s]=t[s],r=!0));r&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+x()}generateDeviceId(){return"device_"+x()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new K({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var dt=["LCP","CLS","FCP","INP","TTFB"],ht=["LCP","CLS","FCP","INP"],ct=9e5,_t="[WebVitals]";class vt{static extractConfig(e){var t=e.capture_performance;return"boolean"==typeof t?{web_vitals:t}:"object"==typeof t&&null!==t?t:{web_vitals:!1}}constructor(e){this.name="WebVitals",this._isStarted=!1,this._instance=e,this._buffer=this._createEmptyBuffer(),this._config=vt.extractConfig(e.getConfig())}get isEnabled(){var e=null==q?void 0:q.protocol;return("http:"===e||"https:"===e)&&!0===this._config.web_vitals}get isStarted(){return this._isStarted}startIfEnabled(){if(this.isEnabled&&!this._isStarted&&$){var e=this._getWebVitalsCallbacks();e?this._startCapturing(e):this._loadWebVitals()}}stop(){this._isStarted&&(this._flush(),this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),this._isStarted=!1)}onConfigUpdate(e){var t=vt.extractConfig(e),i=this.isEnabled;this._config=t,i||!this.isEnabled||this._isStarted?i&&!this.isEnabled&&this._isStarted&&this.stop():this.startIfEnabled()}get allowedMetrics(){return this._config.web_vitals_allowed_metrics||ht}get flushTimeoutMs(){return this._config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this._config.__web_vitals_max_value;return void 0===e?ct:0===e?0:e<6e4?ct:e}_createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}_getWebVitalsCallbacks(){var e;return null===(e=B.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}_loadWebVitals(){var e,t=null===(e=B.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this._instance,"web-vitals",e=>{if(e)console.error(_t+" Failed to load web-vitals:",e);else{var t=this._getWebVitalsCallbacks();t?this._startCapturing(t):console.error(_t+" web-vitals loaded but callbacks not registered")}}):console.warn(_t+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}_startCapturing(e){if(!this._isStarted){var t=this.allowedMetrics,i=this._addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this._isStarted=!0}}_getCurrentUrl(){var e;return null===(e=null==$?void 0:$.location)||void 0===e?void 0:e.href}_getCurrentPathname(){return null==q?void 0:q.pathname}_addToBuffer(e){try{if(!$||!N||!q)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(_t+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(_t+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this._getCurrentUrl(),r=this._getCurrentPathname();if(!t)return void console.warn(_t+" Could not determine current URL");this._buffer.url&&this._buffer.url!==t&&this._flush(),this._buffer.url||(this._buffer.url=t,this._buffer.pathname=r),this._buffer.firstMetricTimestamp||(this._buffer.firstMetricTimestamp=Date.now());var n=this._cleanAttribution(e.attribution),s=this._instance.getSessionId(),o=this._getWindowId(),a=i({},e,{attribution:n,timestamp:Date.now(),$current_url:t,$session_id:s,$window_id:o}),l=this._buffer.metrics.findIndex(t=>t.name===e.name);l>=0?this._buffer.metrics[l]=a:this._buffer.metrics.push(a),this._scheduleFlush(),this._buffer.metrics.length>=this.allowedMetrics.length&&this._flush()}catch(e){console.error(_t+" Error adding metric to buffer:",e)}}_cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}_getWindowId(){var e;try{return(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}_scheduleFlush(){this._flushTimer&&clearTimeout(this._flushTimer),this._flushTimer=setTimeout(()=>{this._flush()},this.flushTimeoutMs)}_flush(){if(this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),0!==this._buffer.metrics.length){try{var e={$pathname:this._buffer.pathname,$current_url:this._buffer.url};for(var t of this._buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this._instance.capture("$web_vitals",e)}catch(e){console.error(_t+" Error flushing metrics:",e)}this._buffer=this._createEmptyBuffer()}}}function gt(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return Y(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ft{constructor(e,t){var i;this.name="HistoryAutocapture",this._isStarted=!1,this._instance=e,this._config=t||ft.extractConfig(e.getConfig()),this._lastPathname=(null===(i=null==$?void 0:$.location)||void 0===i?void 0:i.pathname)||""}static extractConfig(e){return{enabled:!1!==e.capture_pageview}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().capture_pageview}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._popstateListener&&(this._popstateListener(),this._popstateListener=void 0),this._isStarted=!1)}onConfigUpdate(e){this._config=ft.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}_start(){$&&q&&(this._lastPathname=q.pathname||"",this._patchHistoryMethods(),this._setupPopstateListener(),this._isStarted=!0)}_patchHistoryMethods(){var e,t;if(null==$?void 0:$.history){var i=this;(null===(e=$.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||gt($.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=$.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||gt($.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")})}}_setupPopstateListener(){if(!this._popstateListener&&$){var e=()=>{this._capturePageview("popstate")};A($,"popstate",e),this._popstateListener=()=>{null==$||$.removeEventListener("popstate",e)}}}_capturePageview(e){this.isEnabled&&this._isStarted&&y(()=>{var t,i=null===(t=null==$?void 0:$.location)||void 0===t?void 0:t.pathname;if(i&&q&&N){if(i!==this._lastPathname){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}})}}var pt=["a","button","form","input","select","textarea","label"],mt="$copy_autocapture";function yt(e){return null==e}function bt(e){return"string"==typeof e}function St(e){return void 0===e}function wt(e){return e.replace(/^\s+|\s+$/g,"")}function Ct(e,t){return e.indexOf(t)>-1}function It(e){return 1===(null==e?void 0:e.nodeType)}function Et(e){return 3===(null==e?void 0:e.nodeType)}function kt(e,t){var i;return(null===(i=null==e?void 0:e.tagName)||void 0===i?void 0:i.toLowerCase())===t}function Mt(e){return 11===(null==e?void 0:e.nodeType)}function Lt(e){return e?wt(e).split(/\s+/):[]}function xt(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className&&"string"==typeof e.className.baseVal?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Lt(t)}function Tt(e){return yt(e)?null:wt(e).split(/(\s+)/).filter(e=>Bt(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Rt(e){var t,i="";if(Wt(e)&&!Ht(e)&&e.childNodes&&e.childNodes.length)for(var r=0;r<e.childNodes.length;r++){var n=e.childNodes[r];Et(n)&&n.textContent&&(i+=null!==(t=Tt(n.textContent))&&void 0!==t?t:"")}return wt(i)}function At(e){var t,i="";if(e&&e.childNodes&&e.childNodes.length)for(var r=0;r<e.childNodes.length;r++){var n=e.childNodes[r];if(n&&"span"===(null===(t=n.tagName)||void 0===t?void 0:t.toLowerCase()))try{i=(i+" "+Rt(n)).trim(),n.childNodes&&n.childNodes.length&&(i=(i+" "+At(n)).trim())}catch(e){}}return i}function Pt(e){var t=Rt(e);return Bt(t=(t+" "+At(e)).trim())?t:""}function Ot(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!It(t));return t}function $t(e){var t=e.parentNode;return!(!t||!It(t))&&t}function Ut(e){var t=null==$?void 0:$.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}var zt="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",Nt=new RegExp("^(?:"+zt+")$"),qt=new RegExp(zt),Dt="\\d{3}-?\\d{2}-?\\d{4}",Ft=new RegExp("^("+Dt+")$"),jt=new RegExp("("+Dt+")");function Bt(e,t){if(void 0===t&&(t=!0),yt(e))return!1;if(bt(e)){if(e=wt(e),(t?Nt:qt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Ft:jt).test(e))return!1}return!0}function Vt(e){return!!bt(e)&&("_ngcontent"===e.substring(0,10)||"_nghost"===e.substring(0,7))}function Wt(e){for(var t=e;t&&t.parentNode&&!kt(t,"body");t=t.parentNode){var i=xt(t);if(Ct(i,"vt-sensitive")||Ct(i,"vt-no-capture"))return!1}if(Ct(xt(e),"vt-include"))return!0;var r=e.type||"";if(bt(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=e.name||e.id||"";if(bt(n)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Ht(e){return!!(kt(e,"input")&&!["button","checkbox","submit","reset","radio"].includes(e.type)||kt(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function Jt(e){if(!Wt(e))return null;if(kt(e,"input")){var t=e,i=(t.type||"text").toLowerCase();if("password"===i||"hidden"===i)return null;if("checkbox"===i||"radio"===i){var r={$el_value:t.checked?"true":"false"},n=function(e){var t=e.closest("label");if(t){var i=wt(t.textContent||"");if(i&&Bt(i))return Tt(i)||null}if(e.id)try{var r=null===document||void 0===document?void 0:document.querySelector('label[for="'+e.id+'"]');if(r){var n=wt(r.textContent||"");if(n&&Bt(n))return Tt(n)||null}}catch(e){}return null}(t);return n?r.$selected_text=n:t.value&&Bt(t.value)&&(r.$selected_text=t.value),r}var s=t.value;if(s&&Bt(s)){var o=Tt(s);if(o)return{$el_value:o}}return null}if(kt(e,"select")){var a=e,l=a.selectedIndex;if(l>=0&&a.options[l]){var u=a.options[l],d={};u.value&&Bt(u.value)&&(d.$el_value=u.value);var h=u.text;if(h&&Bt(h)){var c=Tt(h);c&&(d.$selected_text=c)}if(d.$el_value||d.$selected_text)return d}return null}return kt(e,"textarea"),null}function Kt(e,t,i,r,n){if(void 0===i&&(i=void 0),!$||!e||kt(e,"html")||!It(e))return!1;if((null==i?void 0:i.url_allowlist)&&!Ut(i.url_allowlist))return!1;if((null==i?void 0:i.url_ignorelist)&&Ut(i.url_ignorelist))return!1;if(null==i?void 0:i.dom_event_allowlist){var s=i.dom_event_allowlist;if(s&&!s.some(e=>t.type===e))return!1}for(var o=!1,a=[e],l=!0,u=e;u.parentNode&&!kt(u,"body");)if(Mt(u.parentNode))a.push(u.parentNode.host),u=u.parentNode.host;else{if(!(l=$t(u)))break;if(r||pt.indexOf(l.tagName.toLowerCase())>-1)o=!0;else{var d=$.getComputedStyle(l);d&&"pointer"===d.getPropertyValue("cursor")&&(o=!0)}a.push(l),u=l}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(St(i))return!0;var r,n=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var s of e)if(r=n(s))return r.v;return!1}(a,i))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if(St(i))return!0;var r,n=function(e){if(i.some(t=>e.matches(t)))return{v:!0}};for(var s of e)if(r=n(s))return r.v;return!1}(a,i))return!1;var h=$.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return o?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(pt.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}function Gt(e,t){return t.length>e?t.slice(0,e)+"...":t}function Qt(e,t,i,r){var n=e.tagName.toLowerCase(),s={tag_name:n};pt.indexOf(n)>-1&&!i&&(s.$el_text=Gt(1024,"a"===n||"button"===n?Pt(e):Rt(e)));var o=xt(e);o.length>0&&(s.classes=o.filter(e=>""!==e));for(var a=0;a<e.attributes.length;a++){var l=e.attributes[a];if((!Ht(e)||-1!==["name","id","class","aria-label"].indexOf(l.name))&&(!(null==r?void 0:r.includes(l.name))&&!t&&Bt(l.value)&&!Vt(l.name))){var u=l.value;"class"===l.name&&(u=Lt(u).join(" ")),s["attr__"+l.name]=Gt(1024,u)}}for(var d=1,h=1,c=e;c=Ot(c);)d++,c.tagName===e.tagName&&h++;return s.nth_child=d,s.nth_of_type=h,s}function Xt(e){if(!Wt(e))return{};for(var t={},i=0;i<e.attributes.length;i++){var r=e.attributes[i];if(r.name&&0===r.name.indexOf("data-vt-capture-attribute")){var n=r.name.replace("data-vt-capture-attribute-",""),s=r.value;n&&s&&Bt(s)&&(t[n]=s)}}return t}function Zt(e){return e.replace(/"|\\"/g,'\\"')}function Yt(e){var t,i=e.attr__class;return i?(t=i,Array.isArray(t)?i:Lt(i)):void 0}function ei(e){return function(e){var t=e.map(e=>{var t,r,n="";if(e.tag_name&&(n+=e.tag_name),e.attr_class)for(var s of(e.attr_class.sort(),e.attr_class))n+="."+s.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Object.entries(o).sort((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)}).forEach(e=>{var[t,i]=e;return a[Zt(t.toString())]=Zt(String(i))}),(n+=":")+Object.entries(a).map(e=>{var[t,i]=e;return t+'="'+i+'"'}).join("")});return t.join(";")}(function(e){return e.map(e=>{var t,i,r={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:Yt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Object.entries(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,i]=e;return r.attributes[t]=i}),r})}(e))}function ti(e,t){return e.indexOf(t)>-1}class ii{constructor(){this.clicks=[],this.RAGE_CLICK_THRESHOLD_PX=30,this.RAGE_CLICK_TIMEOUT_MS=1e3,this.RAGE_CLICK_CLICK_COUNT=3}isRageClick(e,t,i){if(this.clicks=this.clicks.filter(e=>i-e.timestamp<this.RAGE_CLICK_TIMEOUT_MS),this.clicks.length>0){var r=this.clicks[this.clicks.length-1];Math.sqrt(Math.pow(e-r.x,2)+Math.pow(t-r.y,2))>this.RAGE_CLICK_THRESHOLD_PX&&(this.clicks=[])}return this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length>=this.RAGE_CLICK_CLICK_COUNT}}function ri(e,t){for(var i,r,n,s,{e:o,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:u,elementsChainAsString:d,captureElementValues:h}=t,c=[e],_=e;_.parentNode&&!kt(_,"body");)Mt(_.parentNode)?(c.push(_.parentNode.host),_=_.parentNode.host):(c.push(_.parentNode),_=_.parentNode);var v,g=[],f={},p=!1,m=!1;for(var y of c){var b=Wt(y);if("a"===y.tagName.toLowerCase()){var S=y.getAttribute("href");p=!!(b&&S&&Bt(S))&&S}ti(xt(y),"vt-no-capture")&&(m=!0),g.push(Qt(y,a,l,u));var w=Xt(y);Object.assign(f,w)}if(m)return{props:{},explicitNoCapture:m};if(l||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?g[0].$el_text=Pt(e):g[0].$el_text=Rt(e)),"change"===o.type&&h){var C=Jt(e);C&&(C.$el_value&&(g[0].$el_value=C.$el_value),C.$selected_text&&(g[0].$selected_text=C.$selected_text))}if(p){g[0].attr__href=p;var I=null===(i=Q(p))||void 0===i?void 0:i.host,E=null===(r=null==$?void 0:$.location)||void 0===r?void 0:r.host;I&&E&&I!==E&&(v=p)}var k=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Object.assign({},...t)}({$event_type:o.type,$ce_version:1},d?{}:{$elements:g},{$elements_chain:ei(g)},(null===(n=g[0])||void 0===n?void 0:n.$el_text)?{$el_text:null===(s=g[0])||void 0===s?void 0:s.$el_text}:{},v&&"click"===o.type?{$external_click_url:v}:{},f);return{props:k}}class ni{constructor(e){this.name="Autocapture",this._initialized=!1,this._isDisabledServerSide=null,this._elementSelectors=null,this._rageclicks=new ii,this._elementsChainAsString=!1,this._instance=e}get _config(){var e,t=this._instance.getConfig(),i="object"!=typeof(e=t.autocapture)||null===e||Array.isArray(e)?{}:t.autocapture;return i.url_allowlist&&(i.url_allowlist=i.url_allowlist.map(e=>"string"==typeof e?new RegExp(e):e)),i.url_ignorelist&&(i.url_ignorelist=i.url_ignorelist.map(e=>"string"==typeof e?new RegExp(e):e)),i}get isEnabled(){var e,t=null!==(e=this._isDisabledServerSide)&&void 0!==e&&e;return!!this._instance.getConfig().autocapture&&!t}get isStarted(){return this._initialized}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}stop(){this._initialized=!1}onConfigUpdate(e){this.isEnabled&&!this._initialized&&this.startIfEnabled()}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}updateConfig(e){void 0!==e.enabled&&e.enabled&&(this._isDisabledServerSide=!1)}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach(t=>{var r=null==N?void 0:N.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&i.push(t)})}),i}_addDomEventHandlers(){if(this._isBrowserSupported()&&$&&N){var e=e=>{e=e||(null==$?void 0:$.event);try{this._captureEvent(e)}catch(e){}};if(A(N,"submit",e,{capture:!0}),A(N,"change",e,{capture:!0}),A(N,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==$?void 0:$.event),this._captureEvent(e,mt)};A(N,"copy",t,{capture:!0}),A(N,"cut",t,{capture:!0})}}}_captureEvent(e,t){var i,r,n,s,o;if(void 0===t&&(t="$autocapture"),this.isEnabled){var a=function(e){var t;return St(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}(e);if(Et(a)&&(a=a.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this._instance.getConfig().rageclick&&(null===(i=this._rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&this._captureEvent(e,"$rageclick");var l=t===mt;if(a&&Kt(a,e,this._config,l,l?["copy","cut"]:void 0)){var u=this._instance.getConfig(),{props:d,explicitNoCapture:h}=ri(a,{e:e,maskAllElementAttributes:null!==(r=u.mask_all_element_attributes)&&void 0!==r&&r,maskAllText:null!==(n=u.mask_all_text)&&void 0!==n&&n,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,captureElementValues:null!==(s=this._config.capture_element_values)&&void 0!==s&&s});if(h)return!1;var c=this.getElementSelectors(a);if(c&&c.length>0&&(d.$element_selectors=c),t===mt){var _=Tt(null===(o=null==$?void 0:$.getSelection())||void 0===o?void 0:o.toString()),v=e.type||"clipboard";if(!_)return!1;d.$selected_content=_,d.$copy_type=v}return this._instance.capture(t,d),!0}}}_isBrowserSupported(){return"function"==typeof(null==N?void 0:N.querySelectorAll)}}var si="[SessionRecording]";class oi{constructor(e,t){this._instance=e,this.name="SessionRecording",this._isStarted=!1,this._config=t||oi.extractConfig(e.getConfig())}static extractConfig(e){var t,i,r,n=e.session_recording||{};return{enabled:null!==(t=n.enabled)&&void 0!==t&&t,sampleRate:n.sampleRate,minimumDurationMs:n.minimumDurationMs,sessionIdleThresholdMs:n.sessionIdleThresholdMs,fullSnapshotIntervalMs:n.fullSnapshotIntervalMs,captureConsole:null!==(i=n.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(r=n.captureNetwork)&&void 0!==r&&r,captureCanvas:n.captureCanvas,blockClass:n.blockClass,blockSelector:n.blockSelector,ignoreClass:n.ignoreClass,maskTextClass:n.maskTextClass,maskTextSelector:n.maskTextSelector,maskAllInputs:n.maskAllInputs,maskInputOptions:n.maskInputOptions,masking:n.masking,recordHeaders:n.recordHeaders,recordBody:n.recordBody,compressEvents:n.compressEvents,__mutationThrottlerRefillRate:n.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:n.__mutationThrottlerBucketSize}}get isEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!$&&i&&r}get isStarted(){var e;return this._isStarted&&!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}startIfEnabled(){this.startIfEnabledOrStop("recording_initialized")}startIfEnabledOrStop(e){var t;if(!this.isEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this.isEnabled&&i?(this._lazyLoadAndStart(e),this._isStarted=!0,console.info(si+" starting")):this.stop()}}stop(){y(()=>{var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop(),this._isStarted=!1})}onConfigUpdate(e){var t;this._config=oi.extractConfig(e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config),this.startIfEnabledOrStop("config_updated")}onRemoteConfig(e){var t,r,n,s,o,a,l;if(e.sessionRecording){var u=e.sessionRecording;this._config=i({},this._config,{enabled:null!==(t=this._config.enabled)&&void 0!==t?t:u.enabled,sampleRate:null!==(r=this._config.sampleRate)&&void 0!==r?r:u.sampleRate,minimumDurationMs:null!==(n=this._config.minimumDurationMs)&&void 0!==n?n:u.minimumDurationMs,fullSnapshotIntervalMs:null!==(s=this._config.fullSnapshotIntervalMs)&&void 0!==s?s:u.fullSnapshotIntervalMs,maskAllInputs:null!==(o=this._config.maskAllInputs)&&void 0!==o?o:u.maskAllInputs,captureConsole:null!==(a=this._config.captureConsole)&&void 0!==a?a:u.captureConsole,captureCanvas:null!==(l=this._config.captureCanvas)&&void 0!==l?l:u.captureCanvas}),this.startIfEnabledOrStop("remote_config")}}get started(){return this.isStarted}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}stopRecording(){this.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(si+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this.isEnabled)if((null===(i=null===(t=null==B?void 0:B.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=B.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=B.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(si+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(si+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=B.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(si+" initSessionRecording not available after script load")}}var ai=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ai||{}),li=Uint8Array,ui=Uint16Array,di=Int32Array,hi=new li([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ci=new li([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_i=new li([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vi=function(e,t){for(var i=new ui(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new di(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},gi=vi(hi,2),fi=gi.b,pi=gi.r;fi[28]=258,pi[258]=28;for(var mi=vi(ci,0).r,yi=new ui(32768),bi=0;bi<32768;++bi){var Si=(43690&bi)>>1|(21845&bi)<<1;Si=(61680&(Si=(52428&Si)>>2|(13107&Si)<<2))>>4|(3855&Si)<<4,yi[bi]=((65280&Si)>>8|(255&Si)<<8)>>1}var wi=function(e,t,i){for(var r=e.length,n=0,s=new ui(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new ui(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new ui(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var u=n<<4|e[n],d=t-e[n],h=a[e[n]-1]++<<d,c=h|(1<<d)-1;h<=c;++h)o[yi[h]>>l]=u}else for(o=new ui(r),n=0;n<r;++n)e[n]&&(o[n]=yi[a[e[n]-1]++]>>15-e[n]);return o},Ci=new li(288);for(bi=0;bi<144;++bi)Ci[bi]=8;for(bi=144;bi<256;++bi)Ci[bi]=9;for(bi=256;bi<280;++bi)Ci[bi]=7;for(bi=280;bi<288;++bi)Ci[bi]=8;var Ii=new li(32);for(bi=0;bi<32;++bi)Ii[bi]=5;var Ei=wi(Ci,9,0),ki=wi(Ii,5,0),Mi=function(e){return(e+7)/8|0},Li=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new li(e.subarray(t,i))},xi=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},Ti=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},Ri=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return{t:Ni,l:0};if(1==n){var o=new li(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,d=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};d!=n-1;)a=i[i[u].f<i[h].f?u++:h++],l=i[u!=d&&i[u].f<i[h].f?u++:h++],i[d++]={s:-1,f:a.f+l.f,l:a,r:l};var c=s[0].s;for(r=1;r<n;++r)s[r].s>c&&(c=s[r].s);var _=new ui(c+1),v=Ai(i[d-1],_,0);if(v>t){r=0;var g=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(_[m]>t))break;g+=p-(1<<v-_[m]),_[m]=t}for(g>>=f;g>0;){var y=s[r].s;_[y]<t?g-=1<<t-_[y]++-1:++r}for(;r>=0&&g;--r){var b=s[r].s;_[b]==t&&(--_[b],++g)}v=t}return{t:new li(_),l:v}},Ai=function(e,t,i){return-1==e.s?Math.max(Ai(e.l,t,i+1),Ai(e.r,t,i+1)):t[e.s]=i},Pi=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ui(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return{c:i.subarray(0,r),n:t}},Oi=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},$i=function(e,t,i){var r=i.length,n=Mi(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},Ui=function(e,t,i,r,n,s,o,a,l,u,d){xi(t,d++,i),++n[256];for(var h=Ri(n,15),c=h.t,_=h.l,v=Ri(s,15),g=v.t,f=v.l,p=Pi(c),m=p.c,y=p.n,b=Pi(g),S=b.c,w=b.n,C=new ui(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<S.length;++I)++C[31&S[I]];for(var E=Ri(C,7),k=E.t,M=E.l,L=19;L>4&&!k[_i[L-1]];--L);var x,T,R,A,P=u+5<<3,O=Oi(n,Ci)+Oi(s,Ii)+o,$=Oi(n,c)+Oi(s,g)+o+14+3*L+Oi(C,k)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&P<=O&&P<=$)return $i(t,d,e.subarray(l,l+u));if(xi(t,d,1+($<O)),d+=2,$<O){x=wi(c,_,0),T=c,R=wi(g,f,0),A=g;var U=wi(k,M,0);xi(t,d,y-257),xi(t,d+5,w-1),xi(t,d+10,L-4),d+=14;for(I=0;I<L;++I)xi(t,d+3*I,k[_i[I]]);d+=3*L;for(var z=[m,S],N=0;N<2;++N){var q=z[N];for(I=0;I<q.length;++I){var D=31&q[I];xi(t,d,U[D]),d+=k[D],D>15&&(xi(t,d,q[I]>>5&127),d+=q[I]>>12)}}}else x=Ei,T=Ci,R=ki,A=Ii;for(I=0;I<a;++I){var F=r[I];if(F>255){Ti(t,d,x[(D=F>>18&31)+257]),d+=T[D+257],D>7&&(xi(t,d,F>>23&31),d+=hi[D]);var j=31&F;Ti(t,d,R[j]),d+=A[j],j>3&&(Ti(t,d,F>>5&8191),d+=ci[j])}else Ti(t,d,x[F]),d+=T[F]}return Ti(t,d,x[256]),d+T[256]},zi=new di([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ni=new li(0),qi=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),Di=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new li(s.length+e.length);o.set(s),o.set(e,s.length),e=o,n.w=s.length}return function(e,t,i,r,n,s){var o=s.z||e.length,a=new li(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),u=s.l,d=7&(s.r||0);if(t){d&&(l[0]=s.r>>3);for(var h=zi[t-1],c=h>>13,_=8191&h,v=(1<<i)-1,g=s.p||new ui(32768),f=s.h||new ui(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},b=new di(25e3),S=new ui(288),w=new ui(32),C=0,I=0,E=s.i||0,k=0,M=s.w||0,L=0;E+2<o;++E){var x=y(E),T=32767&E,R=f[x];if(g[T]=R,f[x]=T,M<=E){var A=o-E;if((C>7e3||k>24576)&&(A>423||!u)){d=Ui(e,l,0,b,S,w,I,k,L,E-L,d),k=C=I=0,L=E;for(var P=0;P<286;++P)S[P]=0;for(P=0;P<30;++P)w[P]=0}var O=2,$=0,U=_,z=T-R&32767;if(A>2&&x==y(E-z))for(var N=Math.min(c,A)-1,q=Math.min(32767,E),D=Math.min(258,A);z<=q&&--U&&T!=R;){if(e[E+O]==e[E+O-z]){for(var F=0;F<D&&e[E+F]==e[E+F-z];++F);if(F>O){if(O=F,$=z,F>N)break;var j=Math.min(z,F-2),B=0;for(P=0;P<j;++P){var V=E-z+P&32767,W=V-g[V]&32767;W>B&&(B=W,R=V)}}}z+=(T=R)-(R=g[T])&32767}if($){b[k++]=268435456|pi[O]<<18|mi[$];var H=31&pi[O],J=31&mi[$];I+=hi[H]+ci[J],++S[257+H],++w[J],M=E+O,++C}else b[k++]=e[E],++S[e[E]]}}for(E=Math.max(E,M);E<o;++E)b[k++]=e[E],++S[e[E]];d=Ui(e,l,u,b,S,w,I,k,L,E-L,d),u||(s.r=7&d|l[d/8|0]<<3,d-=7,s.h=f,s.p=g,s.i=E,s.w=M)}else{for(E=s.w||0;E<o+u;E+=65535){var K=E+65535;K>=o&&(l[d/8|0]=u,K=o),d=$i(l,d+1,e.subarray(E,K))}s.i=o}return Li(a,0,r+Mi(d)+n)}(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,r,n)},Fi=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ji(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=qi[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=Di(e,t,10+((n=t).filename?n.filename.length+1:0),8),o=s.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Fi(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Fi(s,o-8,i.d()),Fi(s,o-4,r),s}var Bi="undefined"!=typeof TextEncoder&&new TextEncoder,Vi="undefined"!=typeof TextDecoder&&new TextDecoder;try{Vi.decode(Ni,{stream:!0})}catch(e){}ai.MouseMove,ai.MouseInteraction,ai.Scroll,ai.ViewportResize,ai.Input,ai.TouchMove,ai.MediaInteraction,ai.Drag;var Wi="[Chat]";class Hi{constructor(e,t){this._instance=e,this.name="Chat",this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._isStarted=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t||Hi.extractConfig(e.getConfig())}static extractConfig(e){var t,i=e.chat||{};return{enabled:i.enabled,autoConfig:null===(t=i.autoConfig)||void 0===t||t,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline}}get isEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!this._instance.getConfig().disable_chat&&!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}get isStarted(){return this._isStarted}startIfEnabled(){this._startAsync().catch(e=>{console.error(Wi+" Error starting:",e)})}stop(){this.destroy(),this._isStarted=!1}onConfigUpdate(e){var t,i;this._config=Hi.extractConfig(e),this._lazyLoadedChat&&(null===(i=(t=this._lazyLoadedChat).updateConfig)||void 0===i||i.call(t,this.getMergedConfig()))}onRemoteConfig(e){var t,r,n,s,o,a,l,u,d;e.chat&&(this._serverConfig=i({},this._serverConfig,{enabled:null!==(n=null!==(t=e.chat.enabled)&&void 0!==t?t:null===(r=this._serverConfig)||void 0===r?void 0:r.enabled)&&void 0!==n&&n,position:null!==(a=null!==(s=e.chat.widgetPosition)&&void 0!==s?s:null===(o=this._serverConfig)||void 0===o?void 0:o.position)&&void 0!==a?a:"bottom-right",color:null!==(d=null!==(l=e.chat.widgetColor)&&void 0!==l?l:null===(u=this._serverConfig)||void 0===u?void 0:u.color)&&void 0!==d?d:"#6366f1"}),this.isEnabled&&!this._isStarted&&this.startIfEnabled())}_startAsync(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Wi+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e.isEnabled?(e._isStarted=!0,null!==(r=null!==(t=e._config.preload)&&void 0!==t?t:null===(i=e._serverConfig)||void 0===i?void 0:i.enabled)&&void 0!==r&&r&&e._schedulePreload(),(null===(n=e._serverConfig)||void 0===n?void 0:n.enabled)&&e._showBubble(),console.info(Wi+" ready (lazy-load on demand)")):console.info(Wi+" not enabled (check dashboard settings)")):console.info(Wi+" disabled by code config")})()}get isOpen(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}get channels(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channels)&&void 0!==t?t:[]}get currentView(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.currentView)&&void 0!==t?t:"list"}open(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.open()})}close(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.close()}toggle(){this._lazyLoadedChat?this._lazyLoadedChat.toggle():this.open()}show(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.show()})}hide(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.hide()}getChannels(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.getChannels()})}selectChannel(e){this._lazyLoadAndThen(()=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.selectChannel(e)})}createChannel(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.createChannel()})}goToChannelList(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.goToChannelList()}sendMessage(e){this._lazyLoadedChat?this._lazyLoadedChat.sendMessage(e):(this._pendingMessages.push(e),this._lazyLoadAndThen(()=>{this._pendingMessages.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.sendMessage(e)}),this._pendingMessages=[]}))}markAsRead(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.markAsRead()}onMessage(e){return this._messageCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,u,d,h,c,_,v,g,f,p,m=this._serverConfig,y=this._config;return{enabled:null!==(t=null!==(e=y.enabled)&&void 0!==e?e:null==m?void 0:m.enabled)&&void 0!==t&&t,autoConfig:null===(i=y.autoConfig)||void 0===i||i,position:null!==(n=null!==(r=y.position)&&void 0!==r?r:null==m?void 0:m.position)&&void 0!==n?n:"bottom-right",greeting:null!==(s=y.greeting)&&void 0!==s?s:null==m?void 0:m.greeting,color:null!==(a=null!==(o=y.color)&&void 0!==o?o:null==m?void 0:m.color)&&void 0!==a?a:"#6366f1",aiMode:null===(u=null!==(l=y.aiMode)&&void 0!==l?l:null==m?void 0:m.ai_enabled)||void 0===u||u,aiGreeting:null!==(d=y.aiGreeting)&&void 0!==d?d:null==m?void 0:m.ai_greeting,preload:null!==(h=y.preload)&&void 0!==h&&h,theme:null!==(c=y.theme)&&void 0!==c?c:{primaryColor:null!==(v=null!==(_=y.color)&&void 0!==_?_:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(g=y.offlineMessage)&&void 0!==g?g:null==m?void 0:m.offline_message,collectEmailOffline:null===(p=null!==(f=y.collectEmailOffline)&&void 0!==f?f:null==m?void 0:m.collect_email_offline)||void 0===p||p}}destroy(){y(()=>{var e,t;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[];var i=null===(t=null==$?void 0:$.document)||void 0===t?void 0:t.getElementById("vtilt-chat-bubble");i&&i.remove()})}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig(),i=t.token,r=t.api_host;if(!i||!r)return console.warn(Wi+" Cannot fetch settings: missing token or api_host"),void(e._configFetched=!0);try{var n=r+"/api/chat/settings?token="+encodeURIComponent(i),s=yield fetch(n);if(!s.ok)return console.warn(Wi+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Wi+" Loaded settings from dashboard")}catch(t){console.warn(Wi+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==$?void 0:$.document)&&!document.getElementById("vtilt-chat-bubble")){var e=this.getMergedConfig(),t=e.position||"bottom-right",i=e.color||"#6366f1",r=document.createElement("div");r.id="vtilt-chat-bubble",r.setAttribute("style",("\n position: fixed;\n bottom: 20px;\n "+("bottom-right"===t?"right: 20px;":"left: 20px;")+"\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+i+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),r.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n ',r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.05)",r.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),r.addEventListener("click",()=>{this.open()}),document.body.appendChild(r)}}get _scriptName(){return"chat"}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._lazyLoad(),{timeout:5e3}):setTimeout(()=>this._lazyLoad(),3e3)}_lazyLoadAndThen(e){this._lazyLoadedChat?e():(this._pendingCallbacks.push(e),this._lazyLoad())}_lazyLoad(){var e,t;if(!(this._isLoading||this._lazyLoadedChat||this._loadError))if(null===(e=B.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=B.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Wi+" loadExternalDependency not available. Chat cannot start."),this._isLoading=!1,void(this._loadError="loadExternalDependency not available");i(this._instance,this._scriptName,e=>{if(this._isLoading=!1,e)return console.error(Wi+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=B.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Wi+" initChat not available after script load"),void(this._loadError="initChat not available");if(!this._lazyLoadedChat){var i=this.getMergedConfig();this._lazyLoadedChat=t(this._instance,i),this._messageCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onMessage(e)}),this._typingCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onTyping(e)}),this._connectionCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onConnectionChange(e)});var r=null===document||void 0===document?void 0:document.getElementById("vtilt-chat-bubble");r&&r.remove()}this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],console.info(Wi+" loaded and ready")}}var Ji,Ki="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Ji||(Ji={}));var Gi=e=>{var{data:t,compression:i}=e;if(t){var r=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),n=new Blob([r]).size;if(i===Ji.GZipJS&&n>=1024)try{var s=ji(function(e,t){if(Bi)return Bi.encode(e);for(var i=e.length,r=new li(e.length+(e.length>>1)),n=0,s=function(e){r[n++]=e},o=0;o<i;++o){if(n+5>r.length){var a=new li(n+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return Li(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:Ki});if(o.size<.95*n)return{contentType:Ki,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},Qi=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Gi(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Ji.GZipJS&&n===Ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,l=i({"Content-Type":n},e.headers||{}),u=new AbortController,d=e.timeout?setTimeout(()=>u.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:l,body:s,keepalive:o<52428.8,signal:u.signal}).then(function(){var i=t(function*(t){var i,r=yield t.text(),n={statusCode:t.status,text:r};if(200===t.status)try{n.json=JSON.parse(r)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,n)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{d&&clearTimeout(d)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Gi(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Ji.GZipJS&&i===Ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,s=new XMLHttpRequest;s.open(e.method||"POST",n,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;s.setRequestHeader(t,i)}),s.setRequestHeader("Content-Type",i),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{var t;if(4===s.readyState){var i={statusCode:s.status,text:s.responseText};if(200===s.status)try{i.json=JSON.parse(s.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},s.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},s.send(r)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Gi(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Ji.GZipJS&&i===Ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Xi=e=>{var t,i=e.transport||"fetch",r=Qi.find(e=>e.name===i&&e.available)||Qi.find(e=>e.available);if(!r)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));r.method(e)};class Zi{constructor(e,t){var i,r,n,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,n=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,r),n)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(i({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var r=e[i];r.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class Yi{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,$&&void 0!==z&&"onLine"in z&&(this._areWeOnline=z.onLine,A($,"online",()=>{this._areWeOnline=!0,this._flush()}),A($,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),n=(Math.random()-.5)*(r-i);return Math.ceil(r+n)}(t),r=Date.now()+i;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var n="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(n+=" (Browser is offline)"),console.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),r=[],n=[];this._queue.forEach(e=>{e.retryAt<i?n.push(e):r.push(e)}),this._queue=r,n.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:r}=t;try{var n=yield e._sendRequest(i);200!==n.statusCode&&(n.statusCode<400||n.statusCode>=500)&&e.enqueue(i,r)}catch(t){e.enqueue(i,r)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var er="vt_rate_limit";class tr{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,r,n;void 0===e&&(e=!1);var s=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(er))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(n=this.persistence)||void 0===n||n.set(er,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class ir{constructor(e){this._remoteConfig=null,this._host=e}get config(){return this._remoteConfig}onApply(e){this._onApply=e}onLoad(e){this._onLoad=e}load(){var e,t=this._host.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._apply(this._remoteConfig),void this._fetch();var i=y(()=>$.__VTILT_BOOTSTRAP__);if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._apply(this._remoteConfig),void this._fetch();y(()=>{var e=localStorage.getItem(d+"_"+t.projectId);e&&(this._remoteConfig=JSON.parse(e),this._apply(this._remoteConfig))}),this._fetch()}}_fetch(){var e=this._host.getConfig();if(e.projectId&&e.api_host){var t=e.api_host+"/api/projects/"+e.projectId+"/decide",i=new AbortController,r=setTimeout(()=>i.abort(),3e3);(D||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{var i;clearTimeout(r),this._remoteConfig=t,y(()=>{localStorage.setItem(d+"_"+e.projectId,JSON.stringify(t))}),this._apply(t),null===(i=this._onLoad)||void 0===i||i.call(this,t)}).catch(()=>{clearTimeout(r)})}}_apply(e){var t,i,r,n,s,o,a,l,u,d=this._host.getConfig(),h={},c=!1,_=!1,v=!1;e.sessionRecording&&void 0===d.session_recording&&(h.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,fullSnapshotIntervalMs:e.sessionRecording.fullSnapshotIntervalMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(c=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===d.chat&&(h.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},_=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===d.capture_pageview&&(h.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===d.capture_pageleave&&(h.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===d.capture_performance&&(h.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===d.autocapture&&(h.autocapture=e.analytics.autocapture,e.analytics.autocapture&&(v=!0))),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===d.respect_dnt&&(h.respect_dnt=e.privacy.respectDnt),Object.keys(h).length>0&&this._host.updateConfig(h),null===(r=this._onApply)||void 0===r||r.call(this,e),this._host.__loaded&&(c&&(null===(s=(n=this._host).startSessionRecording)||void 0===s||s.call(n)),_&&(null===(a=(o=this._host)._initChat)||void 0===a||a.call(o)),v&&(null===(u=(l=this._host).startAutocapture)||void 0===u||u.call(l)))}}class rr{constructor(e){this._set_once_properties_sent=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this._vt_person_uuid=null,this._host=e}setVtPersonUuid(e){this._vt_person_uuid=e}capture(e,t,r){var n;if(this._host.sessionManager.setSessionId(),(null==z?void 0:z.userAgent)&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(z.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this._host.rateLimiter.shouldAllowEvent())){var s,o=this._host.buildUrl(),a=this._host.getConfig(),l=this._buildEventPayload(e,t);if(!1!==a.stringifyPayload){if(!T(s=JSON.stringify(i({},l,a.globalAttributes))))return}else if(s=i({},l,a.globalAttributes),!T(JSON.stringify(s)))return;var u="$identify"===e?this._host.userManager.getAnonymousId():null!==(n=this._host.userManager.getDistinctId())&&void 0!==n?n:this._host.userManager.getAnonymousId(),d={timestamp:(new Date).toISOString(),event:e,project_id:a.projectId||"",payload:s,distinct_id:u,anonymous_id:this._host.userManager.getAnonymousId()};this._host.sendRequest(o,d,!0)}}captureInternal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}captureInitialPageview(){N&&("visible"===N.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{N&&q&&this.capture("$pageview",{navigation_type:"initial_load"})},300),this._visibility_state_listener&&(N.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>this.captureInitialPageview(),A(N,"visibilitychange",this._visibility_state_listener)))}_buildEventPayload(e,t){var r=lt(),n=this._host.userManager.getUserProperties(),s=this._host.userManager.get_initial_props(),o=this._host.sessionManager.getSessionId(),a=this._host.sessionManager.getWindowId(),l=this._host.userManager.getAnonymousId(),u={};!this._set_once_properties_sent&&Object.keys(s).length>0&&Object.assign(u,s),t.$set_once&&Object.assign(u,t.$set_once);var d=i({},r,n,{$session_id:o,$window_id:a},l?{$anon_distinct_id:l}:{},this._vt_person_uuid?{$vt:this._vt_person_uuid}:{},Object.keys(u).length>0?{$set_once:u}:{},t.$set?{$set:t.$set}:{},t);return!this._set_once_properties_sent&&Object.keys(s).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&N&&(d.title=N.title),d}}class nr{constructor(e){this._host=e}identify(e,t,i){var r;if("number"==typeof e&&(e=String(e),console.warn("identify: first argument should be a string, not a number")),e)if(this._host.userManager.isDistinctIdStringLikePublic(e))console.error('identify: "'+e+'" appears to be a hardcoded string');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this._host.userManager.getDistinctId(),s=this._host.userManager.getAnonymousId(),o=this._host.userManager.getDeviceId(),a="anonymous"===this._host.userManager.getUserState();o||this._host.userManager.ensureDeviceId(n||s),e!==n&&a?(this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$identify",{distinct_id:e,$anon_distinct_id:s,$set:t||{},$set_once:i||{}}),this._host.userManager.setDistinctId(e),null===(r=this._host._emitter)||void 0===r||r.emit("user:identified",{distinctId:e})):t||i?(a&&this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$set",{$set:t||{},$set_once:i||{}})):e!==n&&(this._host.userManager.setUserState("identified"),this._host.userManager.setDistinctId(e))}else console.error("identify: cannot use sentinel value as distinct_id");else console.error("identify: unique user id is required")}setUserProperties(e,t){var i;this._host.userManager.setUserProperties(e,t)&&(this._host.capture("$set",{$set:e||{},$set_once:t||{}}),null===(i=this._host._emitter)||void 0===i||i.emit("user:properties_set",{properties:e}))}resetUser(e){var t;this._host.sessionManager.resetSessionId(),this._host.userManager.reset(e),null===(t=this._host._emitter)||void 0===t||t.emit("user:reset")}createAlias(e,t){var i=this._host.userManager.createAlias(e,t);i?this._host.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this._host.userManager.getDistinctId()||this._host.userManager.getAnonymousId())&&this.identify(e)}getUserIdentity(){return this._host.userManager.getUserIdentity()}getDeviceId(){return this._host.userManager.getDeviceId()}getUserState(){return this._host.userManager.getUserState()}getDistinctId(){var e;return null!==(e=this._host.userManager.getDistinctId())&&void 0!==e?e:this._host.userManager.getAnonymousId()}getAnonymousId(){return this._host.userManager.getAnonymousId()}}class sr{constructor(e){this._features=new Map,this._host=e}onFeatureStarted(e){this._onFeatureStarted=e}onFeatureStopped(e){this._onFeatureStopped=e}register(e){this._features.set(e.name,e)}get(e){var t;return null===(t=this._features.get(e))||void 0===t?void 0:t.instance}initAll(){this._features.forEach(e=>{this._initFeature(e)})}init(e){var t=this._features.get(e);if(t)return this._initFeature(t),t.instance}start(e){var t,i=this._features.get(e);if(i&&(i.instance||this._initFeature(i),i.instance)){if(i.instance.onConfigUpdate){var r=this._host.getConfig();i.instance.onConfigUpdate(r)}i.instance.startIfEnabled(),null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e)}}stop(e){var t,i=this._features.get(e);(null==i?void 0:i.instance)&&(i.instance.stop(),null===(t=this._onFeatureStopped)||void 0===t||t.call(this,e))}isActive(e){var t,i,r;return null!==(r=null===(i=null===(t=this._features.get(e))||void 0===t?void 0:t.instance)||void 0===i?void 0:i.isStarted)&&void 0!==r&&r}notifyConfigUpdate(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onConfigUpdate)&&y(()=>t.instance.onConfigUpdate(e))})}notifyRemoteConfig(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onRemoteConfig)&&y(()=>t.instance.onRemoteConfig(e))})}getAll(){var e=[];return this._features.forEach(t=>{t.instance&&e.push(t.instance)}),e}_initFeature(e){if(!e.instance){var t=this._host.getConfig();e.disableKey&&t[e.disableKey]||e.enableKey&&!1===t[e.enableKey]||y(()=>{var t;e.instance=new e.FeatureClass(this._host),e.instance.startIfEnabled(),e.instance.isStarted&&(null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e.name))})}}}var or="vt";class ar{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this.__request_queue=[],this._has_warned_about_config=!1,this._emitter=new b,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new ut(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.rateLimiter=new tr({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._captureManager.captureInternal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new Yi({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new Zi(e=>this._send_batched_request(e),{flush_interval_ms:3e3}),this._captureManager=new rr(this),this._identityManager=new nr(this),this._remoteConfigManager=new ir(this),this._featureManager=new sr(this),this._remoteConfigManager.onApply(e=>{this._featureManager.notifyRemoteConfig(e)}),this._remoteConfigManager.onLoad(e=>{this._emitter.emit(C,{config:e})}),this._featureManager.onFeatureStarted(e=>{this._emitter.emit(I,{feature:e})}),this._featureManager.onFeatureStopped(e=>{this._emitter.emit(E,{feature:e})})}init(e,t,i){var r;if(i&&i!==or){var n=null!==(r=lr[i])&&void 0!==r?r:new ar;return n._init(e,t,i),lr[i]=n,lr[or][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: Already initialized! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0,this._read_vt_param_from_url(),this._remoteConfigManager.load();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this._initFeatures(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._captureManager.captureInitialPageview(),this._emitter.emit(S,{config:n}),this}_initFeatures(){this._initHistoryAutocapture(),this._initAutocapture(),this._initWebVitals(),this._initSessionRecording(),this._initChat()}_initHistoryAutocapture(){this.historyAutocapture||(this.historyAutocapture=new ft(this),this.historyAutocapture.startIfEnabled())}_initAutocapture(){this.autocapture||!1!==this.configManager.getConfig().autocapture&&(this.autocapture=new ni(this),this.autocapture.startIfEnabled())}_initWebVitals(){this.webVitals||(this.webVitals=new vt(this),this.webVitals.startIfEnabled())}_initSessionRecording(){this.sessionRecording||(this.configManager.getConfig().disable_session_recording||(this.sessionRecording=new oi(this),this.sessionRecording.isEnabled&&(this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(M))))}_initChat(){this.chat||(this.configManager.getConfig().disable_chat||(this.chat=new Hi(this),this.chat.startIfEnabled()))}startAutocapture(){this.autocapture||(this.autocapture=new ni(this)),this.autocapture.updateConfig({enabled:!0}),this.autocapture.startIfEnabled()}stopAutocapture(){var e;null===(e=this.autocapture)||void 0===e||e.stop()}isAutocaptureActive(){var e,t;return null!==(t=null===(e=this.autocapture)||void 0===e?void 0:e.isStarted)&&void 0!==t&&t}startSessionRecording(){this.sessionRecording||(this.sessionRecording=new oi(this)),this.sessionRecording.updateConfig({enabled:!0}),this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(M)}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stop(),this._emitter.emit(L)}isRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}capture(e,t,i){this._captureManager.capture(e,t,i),this._emitter.emit(k,{event:e,payload:t})}trackEvent(e,t){void 0===t&&(t={}),this._captureManager.trackEvent(e,t)}identify(e,t,i){this._identityManager.identify(e,t,i)}setUserProperties(e,t){this._identityManager.setUserProperties(e,t)}resetUser(e){this._identityManager.resetUser(e)}createAlias(e,t){this._identityManager.createAlias(e,t)}getUserIdentity(){return this._identityManager.getUserIdentity()}getDeviceId(){return this._identityManager.getDeviceId()}getUserState(){return this._identityManager.getUserState()}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this._identityManager.getDistinctId()}getAnonymousId(){return this._identityManager.getAnonymousId()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:or;return t!==or&&(t="vt."+t),t}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new ut(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this._notifyFeaturesOfConfigUpdate(t),this._emitter.emit(w,{config:t})}_notifyFeaturesOfConfigUpdate(e){[this.historyAutocapture,this.autocapture,this.webVitals,this.sessionRecording,this.chat].forEach(t=>{(null==t?void 0:t.onConfigUpdate)&&y(()=>t.onConfigUpdate(e))})}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:r,token:n}=e;return t||(i?i+"/api/tracking?token="+n:r?r.replace(/\/+$/gm,"")+"/api/tracking?token="+n:"/api/tracking?token="+n)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==$)if($.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking"),this._has_warned_about_config=!0),!1)}_send_batched_request(e){"sendBeacon"!==e.transport?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:r}=e,n=1===r.length?r[0]:{events:r},s=this.configManager.getConfig().disable_compression?Ji.None:Ji.GZipJS;Xi({url:i,data:n,method:"POST",transport:"XHR",compression:s,callback:e=>t({statusCode:e.statusCode})})})}_send_beacon_request(e){var{url:t,events:i}=e,r=1===i.length?i[0]:{events:i},n=this.configManager.getConfig().disable_compression?Ji.None:Ji.GZipJS;Xi({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}_setup_unload_handler(){if($){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};A($,"beforeunload",e),A($,"pagehide",e)}}_start_queue_if_opted_in(){this.requestQueue.enable()}_read_vt_param_from_url(){y(()=>{var e,t;if(void 0!==q&&q.search){var i=new URL(q.href),r=i.searchParams.get("vt");if(null==r?void 0:r.trim()){this._captureManager.setVtPersonUuid(r.trim()),i.searchParams.delete("vt");var n=i.pathname+(i.search||"")+i.hash;null===(t=null===(e=null==$?void 0:$.history)||void 0===e?void 0:e.replaceState)||void 0===t||t.call(e,{},"",n)}}})}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);"function"==typeof this[t]&&y(()=>this[t](...i))}})}_dom_loaded(){this.__request_queue.forEach(e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}}var lr={},ur=!(void 0!==F||void 0!==D)&&-1===(null==j?void 0:j.indexOf("MSIE"))&&-1===(null==j?void 0:j.indexOf("Mozilla"));null!=$&&($.__VTILT_ENQUEUE_REQUESTS=ur);var dr,hr=(dr=lr[or]=new ar,function(){function e(){e.done||(e.done=!0,ur=!1,null!=$&&($.__VTILT_ENQUEUE_REQUESTS=!1),R(lr,e=>e._dom_loaded()))}N&&"function"==typeof N.addEventListener?"complete"===N.readyState?e():A(N,"DOMContentLoaded",e,{capture:!1}):$&&console.error("Browser doesn't support document.addEventListener")}(),dr);export{dt as ALL_WEB_VITALS_METRICS,ht as DEFAULT_WEB_VITALS_METRICS,ar as VTilt,hr as default,hr as vt};
2
2
  //# sourceMappingURL=module.no-external.js.map