@v-tilt/browser 1.7.2 → 1.9.0

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.
@@ -21,10 +21,9 @@ interface VTiltConfig {
21
21
  /** UI host for dashboard links */
22
22
  ui_host?: string | null;
23
23
  /**
24
- * Host for loading extension scripts (recorder.js, etc.)
25
- * Defaults to unpkg CDN: https://unpkg.com/@v-tilt/browser@{version}/dist
26
- * Can also use jsdelivr: https://cdn.jsdelivr.net/npm/@v-tilt/browser@{version}/dist
27
- * Or self-hosted: https://your-domain.com/static
24
+ * CDN host for loading extension scripts (recorder.js, etc.)
25
+ * If set, scripts load from {script_host}/{script}.js (no /dist/)
26
+ * If not set, falls back to {api_host}/dist/{script}.js
28
27
  */
29
28
  script_host?: string;
30
29
  /** Proxy domain for tracking requests */
@@ -554,6 +553,29 @@ interface ChatConfig {
554
553
  offlineMessage?: string;
555
554
  /** Collect email when offline */
556
555
  collectEmailOffline?: boolean;
556
+ /** Called when widget is opened */
557
+ onWidgetOpen?: () => void;
558
+ /** Called when widget is closed */
559
+ onWidgetClose?: (data: {
560
+ timeOpenSeconds: number;
561
+ messagesSent: number;
562
+ }) => void;
563
+ /** Called when a new conversation is started */
564
+ onConversationStart?: (data: {
565
+ channelId: string;
566
+ aiMode: boolean;
567
+ }) => void;
568
+ /** Called when user sends a message */
569
+ onMessageSent?: (data: {
570
+ channelId: string;
571
+ messageId: string;
572
+ }) => void;
573
+ /** Called when a message is received (from AI or agent) */
574
+ onMessageReceived?: (data: {
575
+ channelId: string;
576
+ messageId: string;
577
+ senderType: "ai" | "agent";
578
+ }) => void;
557
579
  }
558
580
  /**
559
581
  * Chat theme customization
@@ -825,7 +847,7 @@ interface QueuedRequest {
825
847
  }
826
848
 
827
849
  declare class VTilt {
828
- readonly version = "1.7.2";
850
+ readonly version = "1.9.0";
829
851
  private configManager;
830
852
  private sessionManager;
831
853
  private userManager;
@@ -843,6 +865,8 @@ declare class VTilt {
843
865
  private _has_warned_about_config;
844
866
  private _set_once_properties_sent;
845
867
  private _remoteConfig;
868
+ /** Person UUID from vt= URL param (manual person tracking link); sent as $vt until backend links distinct_id */
869
+ private _vt_person_uuid;
846
870
  constructor(config?: Partial<VTiltConfig>);
847
871
  /**
848
872
  * Initializes a new instance of the VTilt tracking object.
@@ -891,6 +915,11 @@ declare class VTilt {
891
915
  * Uses both beforeunload and pagehide for maximum compatibility
892
916
  */
893
917
  private _setup_unload_handler;
918
+ /**
919
+ * Read vt=person_uuid from current URL (tracking link for manually created persons).
920
+ * Stores the value for inclusion in event payload as $vt; removes param from URL via replaceState.
921
+ */
922
+ private _read_vt_param_from_url;
894
923
  /**
895
924
  * Load remote config from cache and fetch fresh in background.
896
925
  * Uses sessionStorage for per-session caching.
@@ -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.7.2",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",g="localStorage",v="localStorage+cookie",_="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(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function b(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function w(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 S(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 C(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function I(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 T="undefined"!=typeof window?window:void 0,L="undefined"!=typeof globalThis?globalThis:T,k=null==L?void 0:L.navigator,M=null==L?void 0:L.document,E=null==L?void 0:L.location,R=null==L?void 0:L.fetch,x=(null==L?void 0:L.XMLHttpRequest)&&"withCredentials"in new L.XMLHttpRequest?L.XMLHttpRequest:void 0;null==L||L.AbortController;var P=null==k?void 0:k.userAgent,A=null!=T?T:{},z=[d,l,h,a],O=31536e3,$=["herokuapp.com","vercel.app","netlify.app"];function q(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 U{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!$.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===T||!T.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";T.localStorage.setItem(e,"1");var t="1"===T.localStorage.getItem(e);return T.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 z.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 g:return this.getLocalStorage(e);case _: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 g:this.setLocalStorage(e,t);break;case _:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:O)}}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 g:this.removeLocalStorage(e);break;case _: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==T||T.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:O)}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==T?void 0:T.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==T||T.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==T||T.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==T?void 0:T.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==T||T.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==T||T.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=q(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=q(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===T||!(null==T?void 0:T.sessionStorage))return!1;try{var e="__vt_ss_test__";return T.sessionStorage.setItem(e,"1"),T.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==T?void 0:T.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class D{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=y(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||y();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(y())}_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=y();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(y())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=y()}_listenToUnload(){var e=this.storage.getSessionStorage();T&&e&&S(T,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"})}}function B(e){if(!M)return null;var t=M.createElement("a");return t.href=e,t}function j(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 N(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("="),g=c[0],v=c.slice(1).join("=");-1!==t.indexOf(g)?u.push(g+"="+i):g&&u.push(g+(v?"="+v:""))}var _=u.join("&");return l+(_?"?"+_:"")+(s?"#"+s:"")}function F(e){return"function"==typeof e}var V="Mobile",W="iOS",J="Android",H="Tablet",Q=J+" "+H,G="iPad",X="Apple",K=X+" Watch",Z="Safari",Y="BlackBerry",ee="Samsung",te=ee+"Browser",ie=ee+" Internet",re="Chrome",ne=re+" OS",se=re+" "+W,oe="Internet Explorer",ae=oe+" "+V,le="Opera",de=le+" Mini",ue="Edge",he="Microsoft "+ue,ce="Firefox",ge=ce+" "+W,ve="Nintendo",_e="PlayStation",fe="Xbox",pe=J+" "+V,me=V+" "+Z,ye="Windows",be=ye+" Phone",we="Nokia",Se="Ouya",Ce="Generic",Ie=Ce+" "+V.toLowerCase(),Te=Ce+" "+H.toLowerCase(),Le="Konqueror",ke="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+ke),Ee=new RegExp(fe,"i"),Re=new RegExp(_e+" \\w+","i"),xe=new RegExp(ve+" \\w+","i"),Pe=new RegExp(Y+"|PlayBook|BB10","i"),Ae={"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 ze(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Oe=(e,t)=>t&&ze(t,X)||function(e){return ze(e,Z)&&!ze(e,re)&&!ze(e,J)}(e),$e=function(e,t){return t=t||"",ze(e," OPR/")&&ze(e,"Mini")?de:ze(e," OPR/")?le:Pe.test(e)?Y:ze(e,"IE"+V)||ze(e,"WPDesktop")?ae:ze(e,te)?ie:ze(e,ue)||ze(e,"Edg/")?he:ze(e,"FBIOS")?"Facebook "+V:ze(e,"UCWEB")||ze(e,"UCBrowser")?"UC Browser":ze(e,"CriOS")?se:ze(e,"CrMo")||ze(e,re)?re:ze(e,J)&&ze(e,Z)?pe:ze(e,"FxiOS")?ge:ze(e.toLowerCase(),Le.toLowerCase())?Le:Oe(e,t)?ze(e,V)?me:Z:ze(e,ce)?ce:ze(e,"MSIE")||ze(e,"Trident/")?oe:ze(e,"Gecko")?ce:""},qe={[ae]:[new RegExp("rv:"+ke)],[he]:[new RegExp(ue+"?\\/"+ke)],[re]:[new RegExp("("+re+"|CrMo)\\/"+ke)],[se]:[new RegExp("CriOS\\/"+ke)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ke)],[Z]:[Me],[me]:[Me],[le]:[new RegExp("(Opera|OPR)\\/"+ke)],[ce]:[new RegExp(ce+"\\/"+ke)],[ge]:[new RegExp("FxiOS\\/"+ke)],[Le]:[new RegExp("Konqueror[:/]?"+ke,"i")],[Y]:[new RegExp(Y+" "+ke),Me],[pe]:[new RegExp("android\\s"+ke,"i")],[ie]:[new RegExp(te+"\\/"+ke)],[oe]:[new RegExp("(rv:|MSIE )"+ke)],Mozilla:[new RegExp("rv:"+ke)]},Ue=function(e,t){var i=$e(e,t),r=qe[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},De=[[new RegExp(fe+"; "+fe+" (.*?)[);]","i"),e=>[fe,e&&e[1]||""]],[new RegExp(ve,"i"),[ve,""]],[new RegExp(_e,"i"),[_e,""]],[Pe,[Y,""]],[new RegExp(ye,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[be,""];if(new RegExp(V).test(t)&&!/IEMobile\b/.test(t))return[ye+" "+V,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Ae[r]||"";return/arm/i.test(t)&&(n="RT"),[ye,n]}return[ye,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[W,t.join(".")]}return[W,""]}],[/(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("("+J+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+J+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[J,t.join(".")]}return[J,""]}],[/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/,[ne,""]],[/Linux|debian/i,["Linux",""]]],Be=function(e){return xe.test(e)?ve:Re.test(e)?_e:Ee.test(e)?fe:new RegExp(Se,"i").test(e)?Se:new RegExp("("+be+"|WPDesktop)","i").test(e)?be:/iPad/.test(e)?G:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?K:Pe.test(e)?Y:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(we,"i").test(e)?we:/(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(V).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)?J:Q:J:new RegExp("(pda|"+V+")","i").test(e)?Ie:new RegExp(H,"i").test(e)&&!new RegExp(H+" pc","i").test(e)?Te:""},je="https?://(.*)",Ne=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Fe=I(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ne),Ve="<masked>";function We(e){var t=function(e){return e?0===e.search(je+"google.([^/?]*)")?"google":0===e.search(je+"bing.com")?"bing":0===e.search(je+"yahoo.com")?"yahoo":0===e.search(je+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=M?j(M.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function Je(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function He(){return(null==M?void 0:M.referrer)||"$direct"}function Qe(){var e;return(null==M?void 0:M.referrer)&&(null===(e=B(M.referrer))||void 0===e?void 0:e.host)||"$direct"}function Ge(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=B(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=B(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Fe.concat([]),i={};return w(t,function(t){var r=j(e,t);i[t]=r||null}),i}(r);C(n,o)}i&&C(n,We(i));return n}function Xe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ke(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Ze(e,t){if(!P)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<De.length;t++){var[i,r]=De[t],n=i.exec(e),s=n&&(F(r)?r(n,e):r);if(s)return s}return["",""]}(P);return C(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:$e(P,navigator.vendor),$device:Be(P),$device_type:(n=P,s=Be(n),s===G||s===Q||"Kobo"===s||"Kindle Fire"===s||s===Te?H:s===ve||s===fe||s===_e||s===Se?"Console":s===K?"Wearable":s?V:"Desktop"),$timezone:Xe(),$timezone_offset:Ke()}),{$current_url:N(null==E?void 0:E.href,[],Ve),$host:null==E?void 0:E.host,$pathname:null==E?void 0:E.pathname,$raw_user_agent:P.length>1e3?P.substring(0,997)+"...":P,$browser_version:Ue(P,navigator.vendor),$browser_language:Je(),$browser_language_prefix:(i=Je(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==T?void 0:T.screen.height,$screen_width:null==T?void 0:T.screen.width,$viewport_height:null==T?void 0:T.innerHeight,$viewport_width:null==T?void 0:T.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 Ye{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new U({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,O)),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?I([],Ne,t||[]):[],r=null==E?void 0:E.href.substring(0,1e3);return{r:He().substring(0,1e3),u:r?N(r,i,Ve):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=Ge(i),t={},w(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:He(),$referring_domain:Qe()};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",g=s||this.generateAnonymousId();return e||this.storage.set(d,g,O),t||this.storage.set(l,o,O),r||this.storage.set(a,c,O),{distinct_id:u,anonymous_id:g,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,O),this.storage.set(l,this.userIdentity.device_id,O),this.storage.set(a,this.userIdentity.user_state,O),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,O):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,O)}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_"+y()}generateDeviceId(){return"device_"+y()}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 U({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var et=["LCP","CLS","FCP","INP","TTFB"],tt=["LCP","CLS","FCP","INP"],it=9e5,rt="[WebVitals]";class nt{constructor(e,t){this.initialized=!1,this.instance=t,this.buffer=this.createEmptyBuffer(),this.config=this.parseConfig(e.capture_performance),this.isEnabled&&T&&this.startIfEnabled()}parseConfig(e){return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}get isEnabled(){var e=null==E?void 0:E.protocol;return("http:"===e||"https:"===e)&&!1!==this.config.web_vitals}get allowedMetrics(){return this.config.web_vitals_allowed_metrics||tt}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?it:0===e?0:e<6e4?it:e}createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}getWebVitalsCallbacks(){var e;return null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}startIfEnabled(){if(this.isEnabled&&!this.initialized){var e=this.getWebVitalsCallbacks();e?this.startCapturing(e):this.loadWebVitals()}}loadWebVitals(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this.instance,"web-vitals",e=>{if(e)console.error(rt+" Failed to load web-vitals:",e);else{var t=this.getWebVitalsCallbacks();t?this.startCapturing(t):console.error(rt+" web-vitals loaded but callbacks not registered")}}):console.warn(rt+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}startCapturing(e){if(!this.initialized){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.initialized=!0}}getCurrentUrl(){var e;return null===(e=null==T?void 0:T.location)||void 0===e?void 0:e.href}getCurrentPathname(){return null==E?void 0:E.pathname}addToBuffer(e){try{if(!T||!M||!E)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(rt+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(rt+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this.getCurrentUrl(),r=this.getCurrentPathname();if(!t)return void console.warn(rt+" 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(rt+" 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(rt+" Error flushing metrics:",e)}this.buffer=this.createEmptyBuffer()}}}function st(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return F(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ot{constructor(e){var t;this._instance=e,this._lastPathname=(null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname)||""}get isEnabled(){return!0}startIfEnabled(){this.isEnabled&&this.monitorHistoryChanges()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0}monitorHistoryChanges(){var e,t;if(T&&E&&(this._lastPathname=E.pathname||"",T.history)){var i=this;(null===(e=T.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||st(T.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=T.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||st(T.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")}),this._setupPopstateListener()}}_capturePageview(e){var t;try{var i=null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname;if(!i||!E||!M)return;if(i!==this._lastPathname&&this.isEnabled){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}catch(t){console.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener&&T){var e=()=>{this._capturePageview("popstate")};S(T,"popstate",e),this._popstateListener=()=>{T&&T.removeEventListener("popstate",e)}}}}var at="[SessionRecording]";class lt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._config=t}get started(){var e;return!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.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)||""}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),console.info(at+" starting")):this.stopRecording()}}stopRecording(){var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.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(at+" 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 _isRecordingEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!T&&i&&r}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this._isRecordingEnabled)if((null===(i=null===(t=null==A?void 0:A.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=A.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=A.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(at+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(at+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(at+" initSessionRecording not available after script load")}}var dt=(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))(dt||{}),ut=Uint8Array,ht=Uint16Array,ct=Int32Array,gt=new ut([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]),vt=new ut([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]),_t=new ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var i=new ht(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new ct(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}},pt=ft(gt,2),mt=pt.b,yt=pt.r;mt[28]=258,yt[258]=28;for(var bt=ft(vt,0).r,wt=new ht(32768),St=0;St<32768;++St){var Ct=(43690&St)>>1|(21845&St)<<1;Ct=(61680&(Ct=(52428&Ct)>>2|(13107&Ct)<<2))>>4|(3855&Ct)<<4,wt[St]=((65280&Ct)>>8|(255&Ct)<<8)>>1}var It=function(e,t,i){for(var r=e.length,n=0,s=new ht(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new ht(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new ht(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[wt[h]>>l]=d}else for(o=new ht(r),n=0;n<r;++n)e[n]&&(o[n]=wt[a[e[n]-1]++]>>15-e[n]);return o},Tt=new ut(288);for(St=0;St<144;++St)Tt[St]=8;for(St=144;St<256;++St)Tt[St]=9;for(St=256;St<280;++St)Tt[St]=7;for(St=280;St<288;++St)Tt[St]=8;var Lt=new ut(32);for(St=0;St<32;++St)Lt[St]=5;var kt=It(Tt,9,0),Mt=It(Lt,5,0),Et=function(e){return(e+7)/8|0},Rt=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new ut(e.subarray(t,i))},xt=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},Pt=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},At=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:Bt,l:0};if(1==n){var o=new ut(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 g=new ht(c+1),v=zt(i[u-1],g,0);if(v>t){r=0;var _=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(g[m]>t))break;_+=p-(1<<v-g[m]),g[m]=t}for(_>>=f;_>0;){var y=s[r].s;g[y]<t?_-=1<<t-g[y]++-1:++r}for(;r>=0&&_;--r){var b=s[r].s;g[b]==t&&(--g[b],++_)}v=t}return{t:new ut(g),l:v}},zt=function(e,t,i){return-1==e.s?Math.max(zt(e.l,t,i+1),zt(e.r,t,i+1)):t[e.s]=i},Ot=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ht(++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}},$t=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},qt=function(e,t,i){var r=i.length,n=Et(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)},Ut=function(e,t,i,r,n,s,o,a,l,d,u){xt(t,u++,i),++n[256];for(var h=At(n,15),c=h.t,g=h.l,v=At(s,15),_=v.t,f=v.l,p=Ot(c),m=p.c,y=p.n,b=Ot(_),w=b.c,S=b.n,C=new ht(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<w.length;++I)++C[31&w[I]];for(var T=At(C,7),L=T.t,k=T.l,M=19;M>4&&!L[_t[M-1]];--M);var E,R,x,P,A=d+5<<3,z=$t(n,Tt)+$t(s,Lt)+o,O=$t(n,c)+$t(s,_)+o+14+3*M+$t(C,L)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&A<=z&&A<=O)return qt(t,u,e.subarray(l,l+d));if(xt(t,u,1+(O<z)),u+=2,O<z){E=It(c,g,0),R=c,x=It(_,f,0),P=_;var $=It(L,k,0);xt(t,u,y-257),xt(t,u+5,S-1),xt(t,u+10,M-4),u+=14;for(I=0;I<M;++I)xt(t,u+3*I,L[_t[I]]);u+=3*M;for(var q=[m,w],U=0;U<2;++U){var D=q[U];for(I=0;I<D.length;++I){var B=31&D[I];xt(t,u,$[B]),u+=L[B],B>15&&(xt(t,u,D[I]>>5&127),u+=D[I]>>12)}}}else E=kt,R=Tt,x=Mt,P=Lt;for(I=0;I<a;++I){var j=r[I];if(j>255){Pt(t,u,E[(B=j>>18&31)+257]),u+=R[B+257],B>7&&(xt(t,u,j>>23&31),u+=gt[B]);var N=31&j;Pt(t,u,x[N]),u+=P[N],N>3&&(Pt(t,u,j>>5&8191),u+=vt[N])}else Pt(t,u,E[j]),u+=R[j]}return Pt(t,u,E[256]),u+R[256]},Dt=new ct([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bt=new ut(0),jt=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}(),Nt=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new ut(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 ut(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=Dt[t-1],c=h>>13,g=8191&h,v=(1<<i)-1,_=s.p||new ht(32768),f=s.h||new ht(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 ct(25e3),w=new ht(288),S=new ht(32),C=0,I=0,T=s.i||0,L=0,k=s.w||0,M=0;T+2<o;++T){var E=y(T),R=32767&T,x=f[E];if(_[R]=x,f[E]=R,k<=T){var P=o-T;if((C>7e3||L>24576)&&(P>423||!d)){u=Ut(e,l,0,b,w,S,I,L,M,T-M,u),L=C=I=0,M=T;for(var A=0;A<286;++A)w[A]=0;for(A=0;A<30;++A)S[A]=0}var z=2,O=0,$=g,q=R-x&32767;if(P>2&&E==y(T-q))for(var U=Math.min(c,P)-1,D=Math.min(32767,T),B=Math.min(258,P);q<=D&&--$&&R!=x;){if(e[T+z]==e[T+z-q]){for(var j=0;j<B&&e[T+j]==e[T+j-q];++j);if(j>z){if(z=j,O=q,j>U)break;var N=Math.min(q,j-2),F=0;for(A=0;A<N;++A){var V=T-q+A&32767,W=V-_[V]&32767;W>F&&(F=W,x=V)}}}q+=(R=x)-(x=_[R])&32767}if(O){b[L++]=268435456|yt[z]<<18|bt[O];var J=31&yt[z],H=31&bt[O];I+=gt[J]+vt[H],++w[257+J],++S[H],k=T+z,++C}else b[L++]=e[T],++w[e[T]]}}for(T=Math.max(T,k);T<o;++T)b[L++]=e[T],++w[e[T]];u=Ut(e,l,d,b,w,S,I,L,M,T-M,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=_,s.i=T,s.w=k)}else{for(T=s.w||0;T<o+d;T+=65535){var Q=T+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=qt(l,u+1,e.subarray(T,Q))}s.i=o}return Rt(a,0,r+Et(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)},Ft=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Vt(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=jt[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=Nt(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&&Ft(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),Ft(s,o-8,i.d()),Ft(s,o-4,r),s}var Wt="undefined"!=typeof TextEncoder&&new TextEncoder,Jt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Jt.decode(Bt,{stream:!0})}catch(e){}dt.MouseMove,dt.MouseInteraction,dt.Scroll,dt.ViewportResize,dt.Input,dt.TouchMove,dt.MediaInteraction,dt.Drag;var Ht="[Chat]";class Qt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t}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)}}startIfEnabled(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Ht+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e._isChatEnabled?(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(Ht+" ready (lazy-load on demand)")):console.info(Ht+" not enabled (check dashboard settings)")):console.info(Ht+" disabled by code config")})()}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,d,u,h,c,g,v,_,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!==(g=y.color)&&void 0!==g?g:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(_=y.offlineMessage)&&void 0!==_?_: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(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[]}get _isChatEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}_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(Ht+" 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(Ht+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Ht+" Loaded settings from dashboard")}catch(t){console.warn(Ht+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==T?void 0:T.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=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Ht+" 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(Ht+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Ht+" 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(Ht+" loaded and ready")}}var Gt,Xt="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Gt||(Gt={}));var Kt=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===Gt.GZipJS&&n>=1024)try{var s=Vt(function(e,t){if(Wt)return Wt.encode(e);for(var i=e.length,r=new ut(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 ut(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 Rt(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:Xt});if(o.size<.95*n)return{contentType:Xt,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},Zt=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Kt(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Gt.GZipJS&&n===Xt?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=Kt(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Gt.GZipJS&&i===Xt?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=Kt(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Gt.GZipJS&&i===Xt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Yt=e=>{var t,i=e.transport||"fetch",r=Zt.find(e=>e.name===i&&e.available)||Zt.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 ei{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 ti{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,T&&void 0!==k&&"onLine"in k&&(this._areWeOnline=k.onLine,S(T,"online",()=>{this._areWeOnline=!0,this._flush()}),S(T,"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 ii="vt_rate_limit";class ri{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(ii))&&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(ii,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class ni{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this.__request_queue=[],this._has_warned_about_config=!1,this._set_once_properties_sent=!1,this._remoteConfig=null,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.rateLimiter=new ri({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._capture_internal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new ti({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new ei(e=>this._send_batched_request(e),{flush_interval_ms:3e3})}init(e,t,i){var r;if(i&&i!==oi){var n=null!==(r=si[i])&&void 0!==r?r:new ni;return n._init(e,t,i),si[i]=n,si[oi][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: You have already initialized vTilt! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0,this._loadRemoteConfig();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this.historyAutocapture=new ot(this),this.historyAutocapture.startIfEnabled(),this._initSessionRecording(),this._initChat(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._capture_initial_pageview(),this}_start_queue_if_opted_in(){this.requestQueue.enable()}_setup_unload_handler(){if(T){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};S(T,"beforeunload",e),S(T,"pagehide",e)}}_loadRemoteConfig(){var e,t=this.configManager.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig();try{var i=T.__VTILT_BOOTSTRAP__;if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig()}catch(e){}try{var r=localStorage.getItem(u+"_"+t.projectId);r&&(this._remoteConfig=JSON.parse(r),this._applyRemoteConfig(this._remoteConfig))}catch(e){}this._fetchRemoteConfig()}}_fetchRemoteConfig(){var e=this.configManager.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);(R||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{clearTimeout(r),this._remoteConfig=t;try{localStorage.setItem(u+"_"+e.projectId,JSON.stringify(t))}catch(e){}this._applyRemoteConfig(t)}).catch(()=>{clearTimeout(r)})}}_applyRemoteConfig(e){var t,i,r=this.configManager.getConfig(),n={},s=!1,o=!1;if(e.sessionRecording&&void 0===r.session_recording&&(n.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(s=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===r.chat&&(n.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},o=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===r.capture_pageview&&(n.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===r.capture_pageleave&&(n.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===r.capture_performance&&(n.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===r.autocapture&&(n.autocapture=e.analytics.autocapture)),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===r.respect_dnt&&(n.respect_dnt=e.privacy.respectDnt),Object.keys(n).length>0&&this.updateConfig(n),s&&this.__loaded&&this.startSessionRecording(),o&&this.__loaded)if(this.chat){var a=this._buildChatConfig(this.configManager.getConfig());this.chat.updateConfig(a),this.chat.startIfEnabled()}else this._initChat()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:oi;return t!==oi&&(t=oi+"."+t),t}getCurrentDomain(){if(!E)return"";var e=E.protocol,t=E.hostname,i=E.port;return e+"//"+t+(i?":"+i:"")}_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. Events will be skipped until init() or updateConfig() is called with these fields."),this._has_warned_about_config=!0),!1)}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!==T)if(T.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_send_batched_request(e){var{transport:t}=e;"sendBeacon"!==t?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?Gt.None:Gt.GZipJS;Yt({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?Gt.None:Gt.GZipJS;Yt({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}capture(e,t,r){if(this.sessionManager.setSessionId(),k&&k.userAgent&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(k.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this.rateLimiter.shouldAllowEvent())){var n=this.buildUrl(),s=Ze(),o=this.userManager.getUserProperties(),a=this.userManager.get_initial_props(),l=this.sessionManager.getSessionId(),d=this.sessionManager.getWindowId(),u=this.userManager.getAnonymousId(),h={};!this._set_once_properties_sent&&Object.keys(a).length>0&&Object.assign(h,a),t.$set_once&&Object.assign(h,t.$set_once);var c=i({},s,o,{$session_id:l,$window_id:d},u?{$anon_distinct_id:u}:{},Object.keys(h).length>0?{$set_once:h}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(a).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&M&&(c.title=M.title);var g,v,_=this.configManager.getConfig();if(!1!==_.stringifyPayload){if(g=Object.assign({},c,_.globalAttributes),!b(g=JSON.stringify(g)))return}else if(g=Object.assign({},c,_.globalAttributes),!b(JSON.stringify(g)))return;v="$identify"===e?this.userManager.getAnonymousId():this.userManager.getDistinctId()||this.userManager.getAnonymousId();var f={timestamp:(new Date).toISOString(),event:e,project_id:_.projectId||"",payload:g,distinct_id:v,anonymous_id:u};this.sendRequest(n,f,!0)}}_capture_internal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}identify(e,t,i){if("number"==typeof e&&(e=String(e),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.userManager.isDistinctIdStringLikePublic(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 r=this.userManager.getDistinctId(),n=this.userManager.getAnonymousId(),s=this.userManager.getDeviceId(),o="anonymous"===this.userManager.getUserState();if(!s){var a=r||n;this.userManager.ensureDeviceId(a)}e!==r&&o?(this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n,$set:t||{},$set_once:i||{}}),this.userManager.setDistinctId(e)):t||i?(o&&this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$set",{$set:t||{},$set_once:i||{}})):e!==r&&(this.userManager.setUserState("identified"),this.userManager.setDistinctId(e))}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){this.userManager.setUserProperties(e,t)&&this.capture("$set",{$set:e||{},$set_once:t||{}})}resetUser(e){this.sessionManager.resetSessionId(),this.userManager.reset(e)}getUserIdentity(){return this.userManager.getUserIdentity()}getDeviceId(){return this.userManager.getDeviceId()}getUserState(){return this.userManager.getUserState()}createAlias(e,t){var i=this.userManager.createAlias(e,t);i?this.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this.userManager.getDistinctId()||this.userManager.getAnonymousId())&&this.identify(e)}_capture_initial_pageview(){M&&("visible"===M.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{if(M&&E){this.capture("$pageview",{navigation_type:"initial_load"})}},300),this._visibility_state_listener&&(M.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>{this._capture_initial_pageview()},S(M,"visibilitychange",this._visibility_state_listener)))}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this.userManager.getDistinctId()||this.userManager.getAnonymousId()}getAnonymousId(){return this.userManager.getAnonymousId()}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.sessionRecording&&t.session_recording&&this.sessionRecording.updateConfig(this._buildSessionRecordingConfig(t))}_initSessionRecording(){if(!this.sessionRecording){var e=this.configManager.getConfig();if(!e.disable_session_recording){var t=this._buildSessionRecordingConfig(e);this.sessionRecording=new lt(this,t),t.enabled&&this.sessionRecording.startIfEnabledOrStop("recording_initialized")}}}_buildSessionRecordingConfig(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}}startSessionRecording(){var e=this.configManager.getConfig(),t=this._buildSessionRecordingConfig(e);t.enabled=!0,this.sessionRecording?this.sessionRecording.updateConfig(t):this.sessionRecording=new lt(this,t),this.sessionRecording.startIfEnabledOrStop("recording_initialized")}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stopRecording()}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}_initChat(){if(!this.chat){var e=this.configManager.getConfig();if(!e.disable_chat){var t=this._buildChatConfig(e);this.chat=new Qt(this,t),this.chat.startIfEnabled()}}}_buildChatConfig(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}}_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);if("function"==typeof this[t])try{this[t](...i)}catch(e){console.error("vTilt: Error executing queued call "+t+":",e)}}})}_dom_loaded(){this.__request_queue.forEach(e=>{this._send_retriable_request(e)}),this.__request_queue=[],this._start_queue_if_opted_in()}}var si={},oi="vt",ai=!(void 0!==x||void 0!==R)&&-1===(null==P?void 0:P.indexOf("MSIE"))&&-1===(null==P?void 0:P.indexOf("Mozilla"));null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=ai);var li,di=(li=si[oi]=new ni,function(){function e(){e.done||(e.done=!0,ai=!1,null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=!1),w(si,function(e){e._dom_loaded()}))}M&&"function"==typeof M.addEventListener?"complete"===M.readyState?e():S(M,"DOMContentLoaded",e,{capture:!1}):T&&console.error("Browser doesn't support `document.addEventListener` so vTilt couldn't be initialized")}(),li);export{et as ALL_WEB_VITALS_METRICS,tt as DEFAULT_WEB_VITALS_METRICS,ni as VTilt,di as default,di 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.9.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",g="localStorage",v="localStorage+cookie",_="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(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function b(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function w(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 S(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 C(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function I(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 T="undefined"!=typeof window?window:void 0,L="undefined"!=typeof globalThis?globalThis:T,k=null==L?void 0:L.navigator,M=null==L?void 0:L.document,E=null==L?void 0:L.location,R=null==L?void 0:L.fetch,x=(null==L?void 0:L.XMLHttpRequest)&&"withCredentials"in new L.XMLHttpRequest?L.XMLHttpRequest:void 0;null==L||L.AbortController;var P=null==k?void 0:k.userAgent,A=null!=T?T:{},z=[d,l,h,a],O=31536e3,$=["herokuapp.com","vercel.app","netlify.app"];function q(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 U{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!$.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===T||!T.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";T.localStorage.setItem(e,"1");var t="1"===T.localStorage.getItem(e);return T.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 z.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 g:return this.getLocalStorage(e);case _: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 g:this.setLocalStorage(e,t);break;case _:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:O)}}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 g:this.removeLocalStorage(e);break;case _: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==T||T.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:O)}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==T?void 0:T.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==T||T.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==T||T.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==T?void 0:T.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==T||T.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==T||T.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=q(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=q(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===T||!(null==T?void 0:T.sessionStorage))return!1;try{var e="__vt_ss_test__";return T.sessionStorage.setItem(e,"1"),T.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==T?void 0:T.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class D{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=y(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||y();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(y())}_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=y();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(y())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=y()}_listenToUnload(){var e=this.storage.getSessionStorage();T&&e&&S(T,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"})}}function B(e){if(!M)return null;var t=M.createElement("a");return t.href=e,t}function j(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 N(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("="),g=c[0],v=c.slice(1).join("=");-1!==t.indexOf(g)?u.push(g+"="+i):g&&u.push(g+(v?"="+v:""))}var _=u.join("&");return l+(_?"?"+_:"")+(s?"#"+s:"")}function F(e){return"function"==typeof e}var V="Mobile",W="iOS",J="Android",H="Tablet",Q=J+" "+H,G="iPad",X="Apple",K=X+" Watch",Z="Safari",Y="BlackBerry",ee="Samsung",te=ee+"Browser",ie=ee+" Internet",re="Chrome",ne=re+" OS",se=re+" "+W,oe="Internet Explorer",ae=oe+" "+V,le="Opera",de=le+" Mini",ue="Edge",he="Microsoft "+ue,ce="Firefox",ge=ce+" "+W,ve="Nintendo",_e="PlayStation",fe="Xbox",pe=J+" "+V,me=V+" "+Z,ye="Windows",be=ye+" Phone",we="Nokia",Se="Ouya",Ce="Generic",Ie=Ce+" "+V.toLowerCase(),Te=Ce+" "+H.toLowerCase(),Le="Konqueror",ke="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+ke),Ee=new RegExp(fe,"i"),Re=new RegExp(_e+" \\w+","i"),xe=new RegExp(ve+" \\w+","i"),Pe=new RegExp(Y+"|PlayBook|BB10","i"),Ae={"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 ze(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Oe=(e,t)=>t&&ze(t,X)||function(e){return ze(e,Z)&&!ze(e,re)&&!ze(e,J)}(e),$e=function(e,t){return t=t||"",ze(e," OPR/")&&ze(e,"Mini")?de:ze(e," OPR/")?le:Pe.test(e)?Y:ze(e,"IE"+V)||ze(e,"WPDesktop")?ae:ze(e,te)?ie:ze(e,ue)||ze(e,"Edg/")?he:ze(e,"FBIOS")?"Facebook "+V:ze(e,"UCWEB")||ze(e,"UCBrowser")?"UC Browser":ze(e,"CriOS")?se:ze(e,"CrMo")||ze(e,re)?re:ze(e,J)&&ze(e,Z)?pe:ze(e,"FxiOS")?ge:ze(e.toLowerCase(),Le.toLowerCase())?Le:Oe(e,t)?ze(e,V)?me:Z:ze(e,ce)?ce:ze(e,"MSIE")||ze(e,"Trident/")?oe:ze(e,"Gecko")?ce:""},qe={[ae]:[new RegExp("rv:"+ke)],[he]:[new RegExp(ue+"?\\/"+ke)],[re]:[new RegExp("("+re+"|CrMo)\\/"+ke)],[se]:[new RegExp("CriOS\\/"+ke)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ke)],[Z]:[Me],[me]:[Me],[le]:[new RegExp("(Opera|OPR)\\/"+ke)],[ce]:[new RegExp(ce+"\\/"+ke)],[ge]:[new RegExp("FxiOS\\/"+ke)],[Le]:[new RegExp("Konqueror[:/]?"+ke,"i")],[Y]:[new RegExp(Y+" "+ke),Me],[pe]:[new RegExp("android\\s"+ke,"i")],[ie]:[new RegExp(te+"\\/"+ke)],[oe]:[new RegExp("(rv:|MSIE )"+ke)],Mozilla:[new RegExp("rv:"+ke)]},Ue=function(e,t){var i=$e(e,t),r=qe[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},De=[[new RegExp(fe+"; "+fe+" (.*?)[);]","i"),e=>[fe,e&&e[1]||""]],[new RegExp(ve,"i"),[ve,""]],[new RegExp(_e,"i"),[_e,""]],[Pe,[Y,""]],[new RegExp(ye,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[be,""];if(new RegExp(V).test(t)&&!/IEMobile\b/.test(t))return[ye+" "+V,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Ae[r]||"";return/arm/i.test(t)&&(n="RT"),[ye,n]}return[ye,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[W,t.join(".")]}return[W,""]}],[/(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("("+J+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+J+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[J,t.join(".")]}return[J,""]}],[/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/,[ne,""]],[/Linux|debian/i,["Linux",""]]],Be=function(e){return xe.test(e)?ve:Re.test(e)?_e:Ee.test(e)?fe:new RegExp(Se,"i").test(e)?Se:new RegExp("("+be+"|WPDesktop)","i").test(e)?be:/iPad/.test(e)?G:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?K:Pe.test(e)?Y:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(we,"i").test(e)?we:/(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(V).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)?J:Q:J:new RegExp("(pda|"+V+")","i").test(e)?Ie:new RegExp(H,"i").test(e)&&!new RegExp(H+" pc","i").test(e)?Te:""},je="https?://(.*)",Ne=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Fe=I(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ne),Ve="<masked>";function We(e){var t=function(e){return e?0===e.search(je+"google.([^/?]*)")?"google":0===e.search(je+"bing.com")?"bing":0===e.search(je+"yahoo.com")?"yahoo":0===e.search(je+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=M?j(M.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function Je(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function He(){return(null==M?void 0:M.referrer)||"$direct"}function Qe(){var e;return(null==M?void 0:M.referrer)&&(null===(e=B(M.referrer))||void 0===e?void 0:e.host)||"$direct"}function Ge(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=B(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=B(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Fe.concat([]),i={};return w(t,function(t){var r=j(e,t);i[t]=r||null}),i}(r);C(n,o)}i&&C(n,We(i));return n}function Xe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ke(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Ze(e,t){if(!P)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<De.length;t++){var[i,r]=De[t],n=i.exec(e),s=n&&(F(r)?r(n,e):r);if(s)return s}return["",""]}(P);return C(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:$e(P,navigator.vendor),$device:Be(P),$device_type:(n=P,s=Be(n),s===G||s===Q||"Kobo"===s||"Kindle Fire"===s||s===Te?H:s===ve||s===fe||s===_e||s===Se?"Console":s===K?"Wearable":s?V:"Desktop"),$timezone:Xe(),$timezone_offset:Ke()}),{$current_url:N(null==E?void 0:E.href,[],Ve),$host:null==E?void 0:E.host,$pathname:null==E?void 0:E.pathname,$raw_user_agent:P.length>1e3?P.substring(0,997)+"...":P,$browser_version:Ue(P,navigator.vendor),$browser_language:Je(),$browser_language_prefix:(i=Je(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==T?void 0:T.screen.height,$screen_width:null==T?void 0:T.screen.width,$viewport_height:null==T?void 0:T.innerHeight,$viewport_width:null==T?void 0:T.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 Ye{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new U({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,O)),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?I([],Ne,t||[]):[],r=null==E?void 0:E.href.substring(0,1e3);return{r:He().substring(0,1e3),u:r?N(r,i,Ve):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=Ge(i),t={},w(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:He(),$referring_domain:Qe()};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",g=s||this.generateAnonymousId();return e||this.storage.set(d,g,O),t||this.storage.set(l,o,O),r||this.storage.set(a,c,O),{distinct_id:u,anonymous_id:g,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,O),this.storage.set(l,this.userIdentity.device_id,O),this.storage.set(a,this.userIdentity.user_state,O),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,O):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,O)}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_"+y()}generateDeviceId(){return"device_"+y()}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 U({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var et=["LCP","CLS","FCP","INP","TTFB"],tt=["LCP","CLS","FCP","INP"],it=9e5,rt="[WebVitals]";class nt{constructor(e,t){this.initialized=!1,this.instance=t,this.buffer=this.createEmptyBuffer(),this.config=this.parseConfig(e.capture_performance),this.isEnabled&&T&&this.startIfEnabled()}parseConfig(e){return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}get isEnabled(){var e=null==E?void 0:E.protocol;return("http:"===e||"https:"===e)&&!1!==this.config.web_vitals}get allowedMetrics(){return this.config.web_vitals_allowed_metrics||tt}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?it:0===e?0:e<6e4?it:e}createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}getWebVitalsCallbacks(){var e;return null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}startIfEnabled(){if(this.isEnabled&&!this.initialized){var e=this.getWebVitalsCallbacks();e?this.startCapturing(e):this.loadWebVitals()}}loadWebVitals(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this.instance,"web-vitals",e=>{if(e)console.error(rt+" Failed to load web-vitals:",e);else{var t=this.getWebVitalsCallbacks();t?this.startCapturing(t):console.error(rt+" web-vitals loaded but callbacks not registered")}}):console.warn(rt+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}startCapturing(e){if(!this.initialized){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.initialized=!0}}getCurrentUrl(){var e;return null===(e=null==T?void 0:T.location)||void 0===e?void 0:e.href}getCurrentPathname(){return null==E?void 0:E.pathname}addToBuffer(e){try{if(!T||!M||!E)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(rt+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(rt+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this.getCurrentUrl(),r=this.getCurrentPathname();if(!t)return void console.warn(rt+" 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(rt+" 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(rt+" Error flushing metrics:",e)}this.buffer=this.createEmptyBuffer()}}}function st(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return F(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ot{constructor(e){var t;this._instance=e,this._lastPathname=(null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname)||""}get isEnabled(){return!0}startIfEnabled(){this.isEnabled&&this.monitorHistoryChanges()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0}monitorHistoryChanges(){var e,t;if(T&&E&&(this._lastPathname=E.pathname||"",T.history)){var i=this;(null===(e=T.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||st(T.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=T.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||st(T.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")}),this._setupPopstateListener()}}_capturePageview(e){var t;try{var i=null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname;if(!i||!E||!M)return;if(i!==this._lastPathname&&this.isEnabled){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}catch(t){console.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener&&T){var e=()=>{this._capturePageview("popstate")};S(T,"popstate",e),this._popstateListener=()=>{T&&T.removeEventListener("popstate",e)}}}}var at="[SessionRecording]";class lt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._config=t}get started(){var e;return!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.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)||""}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),console.info(at+" starting")):this.stopRecording()}}stopRecording(){var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.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(at+" 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 _isRecordingEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!T&&i&&r}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this._isRecordingEnabled)if((null===(i=null===(t=null==A?void 0:A.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=A.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=A.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(at+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(at+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(at+" initSessionRecording not available after script load")}}var dt=(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))(dt||{}),ut=Uint8Array,ht=Uint16Array,ct=Int32Array,gt=new ut([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]),vt=new ut([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]),_t=new ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var i=new ht(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new ct(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}},pt=ft(gt,2),mt=pt.b,yt=pt.r;mt[28]=258,yt[258]=28;for(var bt=ft(vt,0).r,wt=new ht(32768),St=0;St<32768;++St){var Ct=(43690&St)>>1|(21845&St)<<1;Ct=(61680&(Ct=(52428&Ct)>>2|(13107&Ct)<<2))>>4|(3855&Ct)<<4,wt[St]=((65280&Ct)>>8|(255&Ct)<<8)>>1}var It=function(e,t,i){for(var r=e.length,n=0,s=new ht(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new ht(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new ht(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[wt[h]>>l]=d}else for(o=new ht(r),n=0;n<r;++n)e[n]&&(o[n]=wt[a[e[n]-1]++]>>15-e[n]);return o},Tt=new ut(288);for(St=0;St<144;++St)Tt[St]=8;for(St=144;St<256;++St)Tt[St]=9;for(St=256;St<280;++St)Tt[St]=7;for(St=280;St<288;++St)Tt[St]=8;var Lt=new ut(32);for(St=0;St<32;++St)Lt[St]=5;var kt=It(Tt,9,0),Mt=It(Lt,5,0),Et=function(e){return(e+7)/8|0},Rt=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new ut(e.subarray(t,i))},xt=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},Pt=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},At=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:Bt,l:0};if(1==n){var o=new ut(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 g=new ht(c+1),v=zt(i[u-1],g,0);if(v>t){r=0;var _=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(g[m]>t))break;_+=p-(1<<v-g[m]),g[m]=t}for(_>>=f;_>0;){var y=s[r].s;g[y]<t?_-=1<<t-g[y]++-1:++r}for(;r>=0&&_;--r){var b=s[r].s;g[b]==t&&(--g[b],++_)}v=t}return{t:new ut(g),l:v}},zt=function(e,t,i){return-1==e.s?Math.max(zt(e.l,t,i+1),zt(e.r,t,i+1)):t[e.s]=i},Ot=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ht(++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}},$t=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},qt=function(e,t,i){var r=i.length,n=Et(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)},Ut=function(e,t,i,r,n,s,o,a,l,d,u){xt(t,u++,i),++n[256];for(var h=At(n,15),c=h.t,g=h.l,v=At(s,15),_=v.t,f=v.l,p=Ot(c),m=p.c,y=p.n,b=Ot(_),w=b.c,S=b.n,C=new ht(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<w.length;++I)++C[31&w[I]];for(var T=At(C,7),L=T.t,k=T.l,M=19;M>4&&!L[_t[M-1]];--M);var E,R,x,P,A=d+5<<3,z=$t(n,Tt)+$t(s,Lt)+o,O=$t(n,c)+$t(s,_)+o+14+3*M+$t(C,L)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&A<=z&&A<=O)return qt(t,u,e.subarray(l,l+d));if(xt(t,u,1+(O<z)),u+=2,O<z){E=It(c,g,0),R=c,x=It(_,f,0),P=_;var $=It(L,k,0);xt(t,u,y-257),xt(t,u+5,S-1),xt(t,u+10,M-4),u+=14;for(I=0;I<M;++I)xt(t,u+3*I,L[_t[I]]);u+=3*M;for(var q=[m,w],U=0;U<2;++U){var D=q[U];for(I=0;I<D.length;++I){var B=31&D[I];xt(t,u,$[B]),u+=L[B],B>15&&(xt(t,u,D[I]>>5&127),u+=D[I]>>12)}}}else E=kt,R=Tt,x=Mt,P=Lt;for(I=0;I<a;++I){var j=r[I];if(j>255){Pt(t,u,E[(B=j>>18&31)+257]),u+=R[B+257],B>7&&(xt(t,u,j>>23&31),u+=gt[B]);var N=31&j;Pt(t,u,x[N]),u+=P[N],N>3&&(Pt(t,u,j>>5&8191),u+=vt[N])}else Pt(t,u,E[j]),u+=R[j]}return Pt(t,u,E[256]),u+R[256]},Dt=new ct([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bt=new ut(0),jt=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}(),Nt=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new ut(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 ut(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=Dt[t-1],c=h>>13,g=8191&h,v=(1<<i)-1,_=s.p||new ht(32768),f=s.h||new ht(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 ct(25e3),w=new ht(288),S=new ht(32),C=0,I=0,T=s.i||0,L=0,k=s.w||0,M=0;T+2<o;++T){var E=y(T),R=32767&T,x=f[E];if(_[R]=x,f[E]=R,k<=T){var P=o-T;if((C>7e3||L>24576)&&(P>423||!d)){u=Ut(e,l,0,b,w,S,I,L,M,T-M,u),L=C=I=0,M=T;for(var A=0;A<286;++A)w[A]=0;for(A=0;A<30;++A)S[A]=0}var z=2,O=0,$=g,q=R-x&32767;if(P>2&&E==y(T-q))for(var U=Math.min(c,P)-1,D=Math.min(32767,T),B=Math.min(258,P);q<=D&&--$&&R!=x;){if(e[T+z]==e[T+z-q]){for(var j=0;j<B&&e[T+j]==e[T+j-q];++j);if(j>z){if(z=j,O=q,j>U)break;var N=Math.min(q,j-2),F=0;for(A=0;A<N;++A){var V=T-q+A&32767,W=V-_[V]&32767;W>F&&(F=W,x=V)}}}q+=(R=x)-(x=_[R])&32767}if(O){b[L++]=268435456|yt[z]<<18|bt[O];var J=31&yt[z],H=31&bt[O];I+=gt[J]+vt[H],++w[257+J],++S[H],k=T+z,++C}else b[L++]=e[T],++w[e[T]]}}for(T=Math.max(T,k);T<o;++T)b[L++]=e[T],++w[e[T]];u=Ut(e,l,d,b,w,S,I,L,M,T-M,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=_,s.i=T,s.w=k)}else{for(T=s.w||0;T<o+d;T+=65535){var Q=T+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=qt(l,u+1,e.subarray(T,Q))}s.i=o}return Rt(a,0,r+Et(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)},Ft=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Vt(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=jt[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=Nt(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&&Ft(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),Ft(s,o-8,i.d()),Ft(s,o-4,r),s}var Wt="undefined"!=typeof TextEncoder&&new TextEncoder,Jt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Jt.decode(Bt,{stream:!0})}catch(e){}dt.MouseMove,dt.MouseInteraction,dt.Scroll,dt.ViewportResize,dt.Input,dt.TouchMove,dt.MediaInteraction,dt.Drag;var Ht="[Chat]";class Qt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t}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)}}startIfEnabled(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Ht+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e._isChatEnabled?(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(Ht+" ready (lazy-load on demand)")):console.info(Ht+" not enabled (check dashboard settings)")):console.info(Ht+" disabled by code config")})()}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,d,u,h,c,g,v,_,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!==(g=y.color)&&void 0!==g?g:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(_=y.offlineMessage)&&void 0!==_?_: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(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[]}get _isChatEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}_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(Ht+" 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(Ht+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Ht+" Loaded settings from dashboard")}catch(t){console.warn(Ht+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==T?void 0:T.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=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Ht+" 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(Ht+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Ht+" 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(Ht+" loaded and ready")}}var Gt,Xt="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Gt||(Gt={}));var Kt=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===Gt.GZipJS&&n>=1024)try{var s=Vt(function(e,t){if(Wt)return Wt.encode(e);for(var i=e.length,r=new ut(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 ut(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 Rt(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:Xt});if(o.size<.95*n)return{contentType:Xt,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},Zt=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Kt(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Gt.GZipJS&&n===Xt?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=Kt(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Gt.GZipJS&&i===Xt?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=Kt(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Gt.GZipJS&&i===Xt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Yt=e=>{var t,i=e.transport||"fetch",r=Zt.find(e=>e.name===i&&e.available)||Zt.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 ei{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 ti{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,T&&void 0!==k&&"onLine"in k&&(this._areWeOnline=k.onLine,S(T,"online",()=>{this._areWeOnline=!0,this._flush()}),S(T,"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 ii="vt_rate_limit";class ri{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(ii))&&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(ii,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class ni{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this.__request_queue=[],this._has_warned_about_config=!1,this._set_once_properties_sent=!1,this._remoteConfig=null,this._vt_person_uuid=null,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.rateLimiter=new ri({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._capture_internal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new ti({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new ei(e=>this._send_batched_request(e),{flush_interval_ms:3e3})}init(e,t,i){var r;if(i&&i!==oi){var n=null!==(r=si[i])&&void 0!==r?r:new ni;return n._init(e,t,i),si[i]=n,si[oi][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: You have already initialized vTilt! 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._loadRemoteConfig();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this.historyAutocapture=new ot(this),this.historyAutocapture.startIfEnabled(),this._initSessionRecording(),this._initChat(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._capture_initial_pageview(),this}_start_queue_if_opted_in(){this.requestQueue.enable()}_setup_unload_handler(){if(T){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};S(T,"beforeunload",e),S(T,"pagehide",e)}}_read_vt_param_from_url(){var e;try{if(void 0===E||!E.search)return;var t=new URL(E.href),i=t.searchParams.get("vt");if(i&&i.trim()){this._vt_person_uuid=i.trim(),t.searchParams.delete("vt");var r=t.pathname+(t.search||"")+t.hash;void 0!==T&&(null===(e=T.history)||void 0===e?void 0:e.replaceState)&&T.history.replaceState({},"",r)}}catch(e){}}_loadRemoteConfig(){var e,t=this.configManager.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig();try{var i=T.__VTILT_BOOTSTRAP__;if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig()}catch(e){}try{var r=localStorage.getItem(u+"_"+t.projectId);r&&(this._remoteConfig=JSON.parse(r),this._applyRemoteConfig(this._remoteConfig))}catch(e){}this._fetchRemoteConfig()}}_fetchRemoteConfig(){var e=this.configManager.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);(R||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{clearTimeout(r),this._remoteConfig=t;try{localStorage.setItem(u+"_"+e.projectId,JSON.stringify(t))}catch(e){}this._applyRemoteConfig(t)}).catch(()=>{clearTimeout(r)})}}_applyRemoteConfig(e){var t,i,r=this.configManager.getConfig(),n={},s=!1,o=!1;if(e.sessionRecording&&void 0===r.session_recording&&(n.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(s=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===r.chat&&(n.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},o=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===r.capture_pageview&&(n.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===r.capture_pageleave&&(n.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===r.capture_performance&&(n.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===r.autocapture&&(n.autocapture=e.analytics.autocapture)),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===r.respect_dnt&&(n.respect_dnt=e.privacy.respectDnt),Object.keys(n).length>0&&this.updateConfig(n),s&&this.__loaded&&this.startSessionRecording(),o&&this.__loaded)if(this.chat){var a=this._buildChatConfig(this.configManager.getConfig());this.chat.updateConfig(a),this.chat.startIfEnabled()}else this._initChat()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:oi;return t!==oi&&(t=oi+"."+t),t}getCurrentDomain(){if(!E)return"";var e=E.protocol,t=E.hostname,i=E.port;return e+"//"+t+(i?":"+i:"")}_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. Events will be skipped until init() or updateConfig() is called with these fields."),this._has_warned_about_config=!0),!1)}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!==T)if(T.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_send_batched_request(e){var{transport:t}=e;"sendBeacon"!==t?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?Gt.None:Gt.GZipJS;Yt({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?Gt.None:Gt.GZipJS;Yt({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}capture(e,t,r){if(this.sessionManager.setSessionId(),k&&k.userAgent&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(k.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this.rateLimiter.shouldAllowEvent())){var n=this.buildUrl(),s=Ze(),o=this.userManager.getUserProperties(),a=this.userManager.get_initial_props(),l=this.sessionManager.getSessionId(),d=this.sessionManager.getWindowId(),u=this.userManager.getAnonymousId(),h={};!this._set_once_properties_sent&&Object.keys(a).length>0&&Object.assign(h,a),t.$set_once&&Object.assign(h,t.$set_once);var c=i({},s,o,{$session_id:l,$window_id:d},u?{$anon_distinct_id:u}:{},this._vt_person_uuid?{$vt:this._vt_person_uuid}:{},Object.keys(h).length>0?{$set_once:h}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(a).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&M&&(c.title=M.title);var g,v,_=this.configManager.getConfig();if(!1!==_.stringifyPayload){if(g=Object.assign({},c,_.globalAttributes),!b(g=JSON.stringify(g)))return}else if(g=Object.assign({},c,_.globalAttributes),!b(JSON.stringify(g)))return;v="$identify"===e?this.userManager.getAnonymousId():this.userManager.getDistinctId()||this.userManager.getAnonymousId();var f={timestamp:(new Date).toISOString(),event:e,project_id:_.projectId||"",payload:g,distinct_id:v,anonymous_id:u};this.sendRequest(n,f,!0)}}_capture_internal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}identify(e,t,i){if("number"==typeof e&&(e=String(e),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.userManager.isDistinctIdStringLikePublic(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 r=this.userManager.getDistinctId(),n=this.userManager.getAnonymousId(),s=this.userManager.getDeviceId(),o="anonymous"===this.userManager.getUserState();if(!s){var a=r||n;this.userManager.ensureDeviceId(a)}e!==r&&o?(this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n,$set:t||{},$set_once:i||{}}),this.userManager.setDistinctId(e)):t||i?(o&&this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$set",{$set:t||{},$set_once:i||{}})):e!==r&&(this.userManager.setUserState("identified"),this.userManager.setDistinctId(e))}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){this.userManager.setUserProperties(e,t)&&this.capture("$set",{$set:e||{},$set_once:t||{}})}resetUser(e){this.sessionManager.resetSessionId(),this.userManager.reset(e)}getUserIdentity(){return this.userManager.getUserIdentity()}getDeviceId(){return this.userManager.getDeviceId()}getUserState(){return this.userManager.getUserState()}createAlias(e,t){var i=this.userManager.createAlias(e,t);i?this.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this.userManager.getDistinctId()||this.userManager.getAnonymousId())&&this.identify(e)}_capture_initial_pageview(){M&&("visible"===M.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{if(M&&E){this.capture("$pageview",{navigation_type:"initial_load"})}},300),this._visibility_state_listener&&(M.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>{this._capture_initial_pageview()},S(M,"visibilitychange",this._visibility_state_listener)))}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this.userManager.getDistinctId()||this.userManager.getAnonymousId()}getAnonymousId(){return this.userManager.getAnonymousId()}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.sessionRecording&&t.session_recording&&this.sessionRecording.updateConfig(this._buildSessionRecordingConfig(t))}_initSessionRecording(){if(!this.sessionRecording){var e=this.configManager.getConfig();if(!e.disable_session_recording){var t=this._buildSessionRecordingConfig(e);this.sessionRecording=new lt(this,t),t.enabled&&this.sessionRecording.startIfEnabledOrStop("recording_initialized")}}}_buildSessionRecordingConfig(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}}startSessionRecording(){var e=this.configManager.getConfig(),t=this._buildSessionRecordingConfig(e);t.enabled=!0,this.sessionRecording?this.sessionRecording.updateConfig(t):this.sessionRecording=new lt(this,t),this.sessionRecording.startIfEnabledOrStop("recording_initialized")}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stopRecording()}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}_initChat(){if(!this.chat){var e=this.configManager.getConfig();if(!e.disable_chat){var t=this._buildChatConfig(e);this.chat=new Qt(this,t),this.chat.startIfEnabled()}}}_buildChatConfig(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}}_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);if("function"==typeof this[t])try{this[t](...i)}catch(e){console.error("vTilt: Error executing queued call "+t+":",e)}}})}_dom_loaded(){this.__request_queue.forEach(e=>{this._send_retriable_request(e)}),this.__request_queue=[],this._start_queue_if_opted_in()}}var si={},oi="vt",ai=!(void 0!==x||void 0!==R)&&-1===(null==P?void 0:P.indexOf("MSIE"))&&-1===(null==P?void 0:P.indexOf("Mozilla"));null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=ai);var li,di=(li=si[oi]=new ni,function(){function e(){e.done||(e.done=!0,ai=!1,null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=!1),w(si,function(e){e._dom_loaded()}))}M&&"function"==typeof M.addEventListener?"complete"===M.readyState?e():S(M,"DOMContentLoaded",e,{capture:!1}):T&&console.error("Browser doesn't support `document.addEventListener` so vTilt couldn't be initialized")}(),li);export{et as ALL_WEB_VITALS_METRICS,tt as DEFAULT_WEB_VITALS_METRICS,ni as VTilt,di as default,di as vt};
2
2
  //# sourceMappingURL=module.no-external.js.map