wineater-bot 3.9.3 → 3.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(Ke){typeof define=="function"&&define.amd?define(Ke):Ke()})(function(){"use strict";var ui,hi;function Ke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Nt(t,e,n){console.log(t,n);let s="";if(n){const i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3),s="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/; secure; samesite=strict"}function Ot(t){const e=t+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let i=n[s];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null}function Un(){const t="uniqueUserID";let e=Ot(t);return e||(e=Ke(),Nt(t,e,365)),e}function bi(t,e,n={},s={}){const i="https://admin-api.wineater.com/api/widget-events";let r=Ot("uniqueUserID");r||(r=Un());const o={user_agent:navigator.userAgent,screen_width:window.screen.width,screen_height:window.screen.height,language:navigator.language,platform:navigator.platform},u=new Date().toISOString();let c=Ot("sessionID");c||(c=Ke(),Nt("sessionID",c,1));const l={event_type:t,store_id:e,session_id:c,event_time:u,data:n,meta:{...s,user_id:r},device_info:o,region:navigator.language.split("-")[1]||null,language:navigator.language.split("-")[0]||"en"};return fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(a=>a.ok?a.json():a.json().then(d=>{throw new Error(d.message||"Failed to track widget event")})).catch(a=>{throw console.error("Widget event tracking error:",a),a})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(b);f==null||f(null,S),m(S)}catch(k){f&&f(k,null),g(k)}})},setItem:function(b,f,h){return new Promise(function(m,g){try{localStorage.setItem(b,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(b){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,h,m){return new(h||(h=Promise))(function(g,S){function k(W){try{B(m.next(W))}catch(O){S(O)}}function A(W){try{B(m.throw(W))}catch(O){S(O)}}function B(W){var O;W.done?g(W.value):(O=W.value,O instanceof h?O:new h(function(q){q(O)})).then(k,A)}B((m=m.apply(b,f||[])).next())})}function o(b,f){var h,m,g,S,k={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function A(B){return function(W){return function(O){if(h)throw new TypeError("Generator is already executing.");for(;k;)try{if(h=1,m&&(g=2&O[0]?m.return:O[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,O[1])).done)return g;switch(m=0,g&&(O=[2&O[0],g.value]),O[0]){case 0:case 1:g=O;break;case 4:return k.label++,{value:O[1],done:!1};case 5:k.label++,m=O[1],O=[0];continue;case 7:O=k.ops.pop(),k.trys.pop();continue;default:if(g=k.trys,!((g=g.length>0&&g[g.length-1])||O[0]!==6&&O[0]!==2)){k=0;continue}if(O[0]===3&&(!g||O[1]>g[0]&&O[1]<g[3])){k.label=O[1];break}if(O[0]===6&&k.label<g[1]){k.label=g[1],g=O;break}if(g&&k.label<g[2]){k.label=g[2],k.ops.push(O);break}g[2]&&k.ops.pop(),k.trys.pop();continue}O=f.call(b,k)}catch(q){O=[6,q],m=0}finally{h=g=0}if(5&O[0])throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}([B,W])}}}function u(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var c=function b(f,h){if(f===h)return!0;if(f&&h&&typeof f=="object"&&typeof h=="object"){if(f.constructor!==h.constructor)return!1;var m,g,S;if(Array.isArray(f)){if((m=f.length)!=h.length)return!1;for(g=m;g--!=0;)if(!b(f[g],h[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===h.source&&f.flags===h.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===h.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===h.toString();if((m=(S=Object.keys(f)).length)!==Object.keys(h).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(h,S[g]))return!1;for(g=m;g--!=0;){var k=S[g];if(!b(f[k],h[k]))return!1}return!0}return f!=f&&h!=h};function l(b,f){var h=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],S=f==null?void 0:f[m];return!c(g,S)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var a,d;function p(b,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?h+"":h}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function w(b){return Object.fromEntries(Object.entries(b).map(function(f){var h=f[0],m=f[1];return[h,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:w(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(a||(a={}));var x,C=null,F="BULLET_TRAIN_DB",R="BULLET_TRAIN_EVENT",E="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",D="flagsmith_enabled_",L="flagsmith_trait_",I=function(){function b(f){var h=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=h,g=m.api,S=m.evaluationContext;h.log("Get Flags"),h.isLoading=!0,h.loadingState.isFetching||h.setLoadingState(i(i({},h.loadingState),{isFetching:!0}));var k="".concat(h.getContext().identity),A=function(B){var W,O,q,ee;if(B&&k==="".concat(h.getContext().identity)){var oe=B.flags,te=B.traits,ne=B.identifier;h.isLoading=!1;var ue={},he={};te=te||[],(oe=oe||[]).forEach(function(K){ue[K.feature.name.toLowerCase().replace(/ /g,"_")]={id:K.feature.id,enabled:K.enabled,value:K.feature_state_value}}),te.forEach(function(K){he[K.trait_key.toLowerCase().replace(/ /g,"_")]={transient:K.transient,value:K.trait_value}}),h.oldFlags=i({},h.flags);var ye=l(h.oldFlags,ue),Ze=l((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.traits,he);if((ne||Object.keys(he).length)&&(h.evaluationContext.identity={traits:he},ne&&(h.evaluationContext.identity.identifier=ne)),h.flags=ue,h.updateStorage(),h._onChange(h.oldFlags,{isFromServer:!0,flagsChanged:ye,traitsChanged:Ze},h._loadedState(null,a.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var et={};Object.keys(((O=h.evaluationContext.identity)===null||O===void 0?void 0:O.traits)||{}).map(function(K){et[L+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.identifier)}),et);h.log("Setting Datadog user",qe),h.datadogRum.client.setUser(qe)}}catch(K){console.error(K)}if(h.dtrum)try{var ie={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(h.flags).map(function(K){p(ie,N+K,h.getValue(K,{skipAnalytics:!0})),p(ie,D+K,h.hasFeature(K,{skipAnalytics:!0}))}),Object.keys(((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(K){p(ie,L+K,h.getTrait(K))}),h.log("Sending javaLongOrObject traits to dynatrace",ie.javaLongOrObject),h.log("Sending date traits to dynatrace",ie.date),h.log("Sending shortString traits to dynatrace",ie.shortString),h.log("Sending javaDouble to dynatrace",ie.javaDouble),h.dtrum.sendSessionProperties(ie.javaLongOrObject,ie.date,ie.shortString,ie.javaDouble)}catch(K){console.error(K)}}};return S.identity?Promise.all([S.identity.traits&&Object.keys(S.identity.traits).length||!S.identity.identifier?h.getJSON(g+"identities/","POST",JSON.stringify({identifier:S.identity.identifier,transient:S.identity.transient,traits:Object.entries(S.identity.traits).map(function(B){var W=B[0],O=B[1];return{trait_key:W,trait_value:O==null?void 0:O.value,transient:O==null?void 0:O.transient}}).filter(function(B){return B.trait_value!==void 0||(h.log("Warning - attempted to set an undefined trait value for key",B.trait_key),!1)})})):h.getJSON(g+"identities/?identifier="+encodeURIComponent(S.identity.identifier)+(S.identity.transient?"&transient=true":""))]).then(function(B){return h.evaluationContext.identity=i(i({},h.evaluationContext.identity),{traits:{}}),A(B==null?void 0:B[0])}).catch(function(B){var W=B.message,O=new Error(W);return Promise.reject(O)}):h.getJSON(g+"flags/").then(function(B){return A({flags:B,traits:void 0})})},this.analyticsFlags=function(){var m=h.api;if(h.evaluationEvent&&h.evaluationContext.environment&&h.evaluationEvent[h.evaluationContext.environment.apiKey])return h.evaluationEvent&&Object.getOwnPropertyNames(h.evaluationEvent).length!==0&&Object.getOwnPropertyNames(h.evaluationEvent[h.evaluationContext.environment.apiKey]).length!==0?h.getJSON(m+"analytics/flags/","POST",JSON.stringify(h.evaluationEvent[h.evaluationContext.environment.apiKey])).then(function(g){if(h.evaluationContext.environment){var S=h.getState();h.evaluationEvent||(h.evaluationEvent={}),h.evaluationEvent[h.evaluationContext.environment.apiKey]={},h.setState(i(i({},S),{evaluationEvent:h.evaluationEvent})),h.updateEventStorage()}}).catch(function(g){h.log("Exception fetching evaluationEvent",g)}):void 0},this.datadogRum=null,this.loadingState={isLoading:!0,isFetching:!0,error:null,source:a.NONE},this.canUseStorage=!1,this.analyticsInterval=null,this.api=null,this.cacheFlags=!1,this.ts=null,this.enableAnalytics=!1,this.enableLogs=!1,this.evaluationContext={},this.evaluationEvent=null,this.flags=null,this.getFlagInterval=null,this.headers=null,this.initialised=!1,this.oldFlags=null,this.onChange=null,this.onError=null,this.ticks=null,this.timer=null,this.dtrum=null,this.withTraits=null,this.cacheOptions={ttl:0,skipAPI:!1,loadStale:!1},this.getValue=function(m,g,S){var k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=null;if(k&&(A=k.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),A===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return A===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(A)}catch{return g.fallback}return A},this.getTrait=function(m){var g,S;return((g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((S=h.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||S===void 0?void 0:S.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=h.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var S=g[0],k=g[1];return[S,k==null?void 0:k.value]}))},this.setContext=function(m){var g=y(m);return h.evaluationContext=i(i({},g),{environment:g.environment||h.evaluationContext.environment}),h.initialised?h.getFlags():Promise.resolve()},this.getContext=function(){return h.evaluationContext},this.updateContext=function(m){return h.setContext(i(i({},h.getContext()),m))},this.setTrait=function(m,g){var S;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(S=h.evaluationContext.identity)===null||S===void 0?void 0:S.traits),w(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(S){var k=S[0],A=S[1];return[k,v(A)?A:{value:A}]})))})}));console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.")},this.hasFeature=function(m,g){var S=typeof g=="object",k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=!1;return!k&&S&&g.fallback!==void 0?A=g==null?void 0:g.fallback:k&&k.enabled&&(A=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),A},this.getJSON=function(m,g,S){var k,A=h;A.evaluationContext;var B=A.headers,W={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(W.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(W.headers["Content-Type"]="application/json; charset=utf-8"),B&&Object.assign(W.headers,B),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var O="".concat((k=h.evaluationContext.identity)===null||k===void 0?void 0:k.identifier);return d(m,W).then(function(q){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(O===te){var ne=(oe=q.headers)===null||oe===void 0?void 0:oe.get("x-flagsmith-document-updated-at");if(ne)try{var ue=parseFloat(ne);if(isNaN(ue))return Promise.reject("Failed to parse x-flagsmith-document-updated-at");h.timestamp=ue}catch(he){h.log(he,"Failed to parse x-flagsmith-document-updated-at",ne)}return h.log("Fetch response: "+q.status+" "+(g||"GET")+0+m),q.text().then(function(he){var ye=he;try{ye=JSON.parse(he)}catch{}return!ye&&q.status&&(ye="API Response: ".concat(q.status)),q.status&&q.status>=200&&q.status<300?ye:Promise.reject(new Error(ye))})}h.log("Received response with identity mismatch, ignoring response. Requested: ".concat(O,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(h.datadogRum&&(h.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?h.datadogRum.client.addFeatureFlagEvaluation(N+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(D+m,h.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),h.enableAnalytics){if(!h.evaluationEvent||!h.evaluationContext.environment)return;h.evaluationEvent[h.evaluationContext.environment.apiKey]||(h.evaluationEvent[h.evaluationContext.environment.apiKey]={}),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]===void 0&&(h.evaluationEvent[h.evaluationContext.environment.apiKey][m]=0),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]+=1}h.updateEventStorage()},this._onChange=function(m,g,S){var k,A;h.setLoadingState(S),(k=h.onChange)===null||k===void 0||k.call(h,m,g,h.loadingState),(A=h._trigger)===null||A===void 0||A.call(h)},d=f.fetch?f.fetch:typeof fetch<"u"?fetch:Me==null?void 0:Me.fetch,this.canUseStorage=typeof window<"u"||!!f.browserlessStorage,this.log("Constructing flagsmith instance "+f),f.eventSource&&(x=f.eventSource),f.AsyncStorage&&(C=f.AsyncStorage)}return b.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,k,A,B,W,O,q,ee,oe,te,ne,ue,he,ye,Ze,et,qe,ie,K,wn,tt,di,nt,Sn,fi,pi,xn,gi,kn,st,Ve,mi,re=this;return o(this,function(pe){switch(pe.label){case 0:S=y(f.evaluationContext||this.evaluationContext),pe.label=1;case 1:if(pe.trys.push([1,13,,14]),k=f.environmentID,A=f.api,B=A===void 0?E:A,W=f.headers,O=f.onChange,q=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,ye=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,wn=f.identity,tt=f.traits,di=f.state,nt=f.cacheOptions,Sn=f.angularHttpClient,fi=f._trigger,pi=f._triggerLoadingState,S.environment=k?{apiKey:k}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=wn||tt?{identifier:wn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=B,this.headers=W,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=O,xn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=fi||this._trigger,this._triggerLoadingState=pi||this._triggerLoadingState,this.onError=function(de){re.setLoadingState(i(i({},re.loadingState),{isFetching:!1,isLoading:!1,error:de})),oe==null||oe(de)},this.enableLogs=he||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=C!==void 0&&!!q,K&&(C=K),et&&typeof window<"u"&&this.setupRealtime(ie,S.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:a.DEFAULT_FLAGS})),this.setState(di),this.log("Initialising with properties",f,this),ye&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Sn&&(d=function(de){return function(we,Se){var Ne=Se.headers,Y=Se.method,Ge=Se.body;return new Promise(function(Ae){switch(Y){case"GET":return de.get(we,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})});case"POST":case"PUT":return de.post(we,Ge,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})})}})}}(Sn)),C&&this.canUseStorage&&C.getItem(R).then(function(de){try{re.evaluationEvent=JSON.parse(de)||{}}catch{re.evaluationEvent={}}re.analyticsInterval=setInterval(re.analyticsFlags,re.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),C&&this.canUseStorage&&C.getItem(R,function(de,we){if(we&&re.evaluationContext.environment){var Se=JSON.parse(we);if(Se[re.evaluationContext.environment.apiKey]){var Ne=re.getState();re.log("Retrieved events from cache",we),re.setState(i(i({},Ne),{evaluationEvent:Se[re.evaluationContext.environment.apiKey]}))}}})),!q)return[3,9];if(!C||!this.canUseStorage)return[3,8];gi=function(de,we){return r(re,void 0,void 0,function(){var Se,Ne,Y,Ge,Ae,Ee,En,vi,Tn,In,Cn,_n,Nn,On,Rn,Dn,Ln,An,Mn,Fn,Pn,Bn,jn,zn;return o(this,function(Oe){switch(Oe.label){case 0:if(!we)return[3,7];Se=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(we),Ge=!1,Ae=!1,Y&&Y.api===this.api&&((In=(Tn=Y.evaluationContext)===null||Tn===void 0?void 0:Tn.environment)===null||In===void 0?void 0:In.apiKey)===((Cn=this.evaluationContext.environment)===null||Cn===void 0?void 0:Cn.apiKey)&&(Ee=!0,this.evaluationContext.identity&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.identity)===null||Nn===void 0?void 0:Nn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Rn=(On=Y.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.identifier)+" to "+this.evaluationContext.identity.identifier),Ee=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ee=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ae=!0,Ee=!0)),Ee&&(Ge=!0,Ne=l((Dn=this.evaluationContext.identity)===null||Dn===void 0?void 0:Dn.traits,(An=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||An===void 0?void 0:An.traits),Se=l(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Mn=Y.evaluationContext)===null||Mn===void 0)&&Mn.identity?i(i({},(Fn=Y.evaluationContext)===null||Fn===void 0?void 0:Fn.identity),{traits:i(i({},((Bn=(Pn=Y.evaluationContext)===null||Pn===void 0?void 0:Pn.identity)===null||Bn===void 0?void 0:Bn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(En=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:Se,traitsChanged:Ne},this._loadedState(null,a.CACHE,En)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!Ae&&this.log("Skipping API, using cache"),En&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return vi=Oe.sent(),this.log("Exception fetching cached logs",vi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(jn=this.evaluationContext.identity)===null||jn===void 0?void 0:jn.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(xn);this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(zn=this.evaluationContext.identity)===null||zn===void 0?void 0:zn.traits)},this._loadedState(null,a.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},pe.label=2;case 2:return pe.trys.push([2,7,,8]),C.getItemSync?(kn=C.getItemSync(F),[3,5]):[3,3];case 3:return[4,C.getItem(F)];case 4:kn=pe.sent(),pe.label=5;case 5:return[4,gi(null,kn)];case 6:case 7:return pe.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return pe.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},te),traitsChanged:l({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=xn),this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,a.DEFAULT_FLAGS)),st))throw new Error(st);pe.label=12;case 12:return[3,14];case 13:throw Ve=pe.sent(),this.log("Error during initialisation ",Ve),mi=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,mi),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,h,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:h}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,h,m){return this.evaluationContext.identity={identifier:f,transient:m,traits:this.evaluationContext.identity&&this.evaluationContext.identity.identifier==f?this.evaluationContext.identity.traits:{}},this.evaluationContext.identity.identifier=f,this.log("Identify: "+this.evaluationContext.identity.identifier),h&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(h).map(function(g){var S=g[0],k=g[1];return[S,v(k)?k:{value:k}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||E,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,u(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),C.setItem(F,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);C.setItem(R,f)}},b.prototype.setLoadingState=function(f){var h;c(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(h=this._triggerLoadingState)===null||h===void 0||h.call(this))},b.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";x?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new x(g),this.eventSource.addEventListener("environment_updated",function(S){var k;try{k=JSON.parse(S.data).updated_at}catch(A){m.log("Could not parse sse event",A)}k?!m.timestamp||k>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",S.data,m.timestamp):(m.log("updated_at is new, fetching flags",S.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",S.data,m.timestamp):m.log("No updated_at received, fetching flags",S)})):this.log("Error, EventSource is undefined")},b}();function T(b){var f=b.fetch,h=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var P,H=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,m){h.__proto__=m}||function(h,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(h[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function h(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&b[f],m=0;if(h)return h.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(b,f){var h=typeof Symbol=="function"&&b[Symbol.iterator];if(!h)return b;var m,g,S=h.call(b),k=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)k.push(m.value)}catch(A){g={error:A}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return k},_=function(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
2
- Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`)||this}return H(f,b),f}(Error),V=function(){function b(f,h){var m=this;if(this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this._configuration=h!=null?Object.assign({},h):void 0,this.withCredentials=!1,this._eventSource=null,this._lastEventId=null,this._timer=null,this._listeners={open:[],error:[],message:[]},this.url=f.toString(),this.readyState=this.CONNECTING,this.max_retry_time=3e3,this.eventSourceClass=globalThis.FlagsmithEventSource,this._configuration!=null&&(this._configuration.lastEventId&&(this._lastEventId=this._configuration.lastEventId,delete this._configuration.lastEventId),this._configuration.max_retry_time&&(this.max_retry_time=this._configuration.max_retry_time,delete this._configuration.max_retry_time),this._configuration.eventSourceClass&&(this.eventSourceClass=this._configuration.eventSourceClass,delete this._configuration.eventSourceClass)),this.eventSourceClass==null||typeof this.eventSourceClass!="function")throw new M;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return b.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},b.prototype._start=function(){var f,h,m=this,g=this.url;this._lastEventId&&(g.indexOf("?")===-1?g+="?":g+="&",g+="lastEventId="+encodeURIComponent(this._lastEventId)),this._eventSource=new this.eventSourceClass(g,this._configuration),this._eventSource.onopen=function(B){m._onopen(B)},this._eventSource.onerror=function(B){m._onerror(B)},this._eventSource.onmessage=function(B){m.onmessage(B)};try{for(var S=j(Object.keys(this._listeners)),k=S.next();!k.done;k=S.next()){var A=k.value;this._eventSource.addEventListener(A,this._onevent_wrapped)}}catch(B){f={error:B}}finally{try{k&&!k.done&&(h=S.return)&&h.call(S)}finally{if(f)throw f.error}}},b.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},b.prototype._onerror=function(f){var h=this;if(this.readyState===1&&(this.readyState=0,this.onerror(f)),this._eventSource){this._eventSource.close(),this._eventSource=null;var m=Math.round(this.max_retry_time*Math.random());this._timer=setTimeout(function(){return h._start()},m)}},b.prototype._onevent=function(f){var h,m;f&&f.lastEventId&&(this._lastEventId=f.lastEventId);var g=this._listeners[f.type];if(g!=null)try{for(var S=j(_([],z(g),!1)),k=S.next();!k.done;k=S.next())k.value.call(this,f)}catch(A){h={error:A}}finally{try{k&&!k.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}f.type==="message"&&this.onmessage(f)},b.prototype.onopen=function(f){},b.prototype.onerror=function(f){},b.prototype.onmessage=function(f){},b.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},b.prototype.addEventListener=function(f,h,m){this._listeners[f]==null&&(this._listeners[f]=[],this._eventSource!=null&&this._eventSource.addEventListener(f,this._onevent_wrapped));var g=this._listeners[f];g.includes(h)||(this._listeners[f]=_(_([],z(g),!1),[h],!1))},b.prototype.removeEventListener=function(f,h,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(S){return S!==h})},b}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var G=function(b,f){return f=f||{},new Promise(function(h,m){var g=new XMLHttpRequest,S=[],k=[],A={},B=function(){return{ok:(g.status/100|0)==2,statusText:g.statusText,status:g.status,url:g.responseURL,text:function(){return Promise.resolve(g.responseText)},json:function(){return Promise.resolve(g.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([g.response]))},clone:B,headers:{keys:function(){return S},entries:function(){return k},get:function(O){return A[O.toLowerCase()]},has:function(O){return O.toLowerCase()in A}}}};for(var W in g.open(f.method||"get",b,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(O,q,ee){S.push(q=q.toLowerCase()),k.push([q,ee]),A[q]=A[q]?A[q]+","+ee:ee}),h(B())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(W,f.headers[W]);g.send(f.body||null)})},$=T({AsyncStorage:s,fetch:G,eventSource:V});typeof window<"u"&&(window.flagsmith=$),n.createFlagsmithInstance=function(){return T({AsyncStorage:s,fetch:G,eventSource:V})},n.default=$,Object.defineProperty(n,"__esModule",{value:!0})})})(Hn,Hn.exports);var $n={},wi=function(t,e,n,s,i){var r=new Worker($n[e]||($n[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return r.onmessage=function(o){var u=o.data,c=u.$e$;if(c){var l=new Error(c[0]);l.code=c[1],l.stack=c[2],i(l,null)}else i(null,u)},r.postMessage(n,s),r},ae=Uint8Array,se=Uint16Array,it=Int32Array,rt=new ae([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]),ot=new ae([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]),Rt=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wn=function(t,e){for(var n=new se(31),s=0;s<31;++s)n[s]=e+=1<<t[s-1];for(var i=new it(n[30]),s=1;s<30;++s)for(var r=n[s];r<n[s+1];++r)i[r]=r-n[s]<<5|s;return{b:n,r:i}},qn=Wn(rt,2),Si=qn.b,at=qn.r;Si[28]=258,at[258]=28;for(var xi=Wn(ot,0),Dt=xi.r,ct=new se(32768),J=0;J<32768;++J){var Te=(J&43690)>>1|(J&21845)<<1;Te=(Te&52428)>>2|(Te&13107)<<2,Te=(Te&61680)>>4|(Te&3855)<<4,ct[J]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var Fe=function(t,e,n){for(var s=t.length,i=0,r=new se(e);i<s;++i)t[i]&&++r[t[i]-1];var o=new se(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var u;if(n){u=new se(1<<e);var c=15-e;for(i=0;i<s;++i)if(t[i])for(var l=i<<4|t[i],a=e-t[i],d=o[t[i]-1]++<<a,p=d|(1<<a)-1;d<=p;++d)u[ct[d]>>c]=l}else for(u=new se(s),i=0;i<s;++i)t[i]&&(u[i]=ct[o[t[i]-1]++]>>15-t[i]);return u},Ie=new ae(288),J=0;J<144;++J)Ie[J]=8;for(var J=144;J<256;++J)Ie[J]=9;for(var J=256;J<280;++J)Ie[J]=7;for(var J=280;J<288;++J)Ie[J]=8;for(var Je=new ae(32),J=0;J<32;++J)Je[J]=5;var Vn=Fe(Ie,9,0),Gn=Fe(Je,5,0),Lt=function(t){return(t+7)/8|0},Kn=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ae(t.subarray(e,n))},ki=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jn=function(t,e,n){var s=new Error(e||ki[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,Jn),!n)throw s;return s},ge=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8},Pe=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8,t[s+2]|=n>>16},lt=function(t,e){for(var n=[],s=0;s<t.length;++s)t[s]&&n.push({s,f:t[s]});var i=n.length,r=n.slice();if(!i)return{t:Pt,l:0};if(i==1){var o=new ae(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(N,D){return N.f-D.f}),n.push({s:-1,f:25001});var u=n[0],c=n[1],l=0,a=1,d=2;for(n[0]={s:-1,f:u.f+c.f,l:u,r:c};a!=i-1;)u=n[n[l].f<n[d].f?l++:d++],c=n[l!=a&&n[l].f<n[d].f?l++:d++],n[a++]={s:-1,f:u.f+c.f,l:u,r:c};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var v=new se(p+1),w=ut(n[a-1],v,0);if(w>e){var s=0,y=0,x=w-e,C=1<<x;for(r.sort(function(D,L){return v[L.s]-v[D.s]||D.f-L.f});s<i;++s){var F=r[s].s;if(v[F]>e)y+=C-(1<<w-v[F]),v[F]=e;else break}for(y>>=x;y>0;){var R=r[s].s;v[R]<e?y-=1<<e-v[R]++-1:++s}for(;s>=0&&y;--s){var E=r[s].s;v[E]==e&&(--v[E],++y)}w=e}return{t:new ae(v),l:w}},ut=function(t,e,n){return t.s==-1?Math.max(ut(t.l,e,n+1),ut(t.r,e,n+1)):e[t.s]=n},At=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new se(++e),s=0,i=t[0],r=1,o=function(c){n[s++]=c},u=1;u<=e;++u)if(t[u]==i&&u!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(i),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(i);r=1,i=t[u]}return{c:n.subarray(0,s),n:e}},Be=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},Mt=function(t,e,n){var s=n.length,i=Lt(e+2);t[i]=s&255,t[i+1]=s>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<s;++r)t[i+r+4]=n[r];return(i+4+s)*8},Ft=function(t,e,n,s,i,r,o,u,c,l,a){ge(e,a++,n),++i[256];for(var d=lt(i,15),p=d.t,v=d.l,w=lt(r,15),y=w.t,x=w.l,C=At(p),F=C.c,R=C.n,E=At(y),N=E.c,D=E.n,L=new se(19),I=0;I<F.length;++I)++L[F[I]&31];for(var I=0;I<N.length;++I)++L[N[I]&31];for(var T=lt(L,7),P=T.t,H=T.l,j=19;j>4&&!P[Rt[j-1]];--j);var z=l+5<<3,_=Be(i,Ie)+Be(r,Je)+o,M=Be(i,p)+Be(r,y)+o+14+3*j+Be(L,P)+2*L[16]+3*L[17]+7*L[18];if(c>=0&&z<=_&&z<=M)return Mt(e,a,t.subarray(c,c+l));var V,G,$,b;if(ge(e,a,1+(M<_)),a+=2,M<_){V=Fe(p,v,0),G=p,$=Fe(y,x,0),b=y;var f=Fe(P,H,0);ge(e,a,R-257),ge(e,a+5,D-1),ge(e,a+10,j-4),a+=14;for(var I=0;I<j;++I)ge(e,a+3*I,P[Rt[I]]);a+=3*j;for(var h=[F,N],m=0;m<2;++m)for(var g=h[m],I=0;I<g.length;++I){var S=g[I]&31;ge(e,a,f[S]),a+=P[S],S>15&&(ge(e,a,g[I]>>5&127),a+=g[I]>>12)}}else V=Vn,G=Ie,$=Gn,b=Je;for(var I=0;I<u;++I){var k=s[I];if(k>255){var S=k>>18&31;Pe(e,a,V[S+257]),a+=G[S+257],S>7&&(ge(e,a,k>>23&31),a+=rt[S]);var A=k&31;Pe(e,a,$[A]),a+=b[A],A>3&&(Pe(e,a,k>>5&8191),a+=ot[A])}else Pe(e,a,V[k]),a+=G[k]}return Pe(e,a,V[256]),a+G[256]},Xn=new it([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pt=new ae(0),Yn=function(t,e,n,s,i,r){var o=r.z||t.length,u=new ae(s+o+5*(1+Math.ceil(o/7e3))+i),c=u.subarray(s,u.length-i),l=r.l,a=(r.r||0)&7;if(e){a&&(c[0]=r.r>>3);for(var d=Xn[e-1],p=d>>13,v=d&8191,w=(1<<n)-1,y=r.p||new se(32768),x=r.h||new se(w+1),C=Math.ceil(n/3),F=2*C,R=function(ne){return(t[ne]^t[ne+1]<<C^t[ne+2]<<F)&w},E=new it(25e3),N=new se(288),D=new se(32),L=0,I=0,T=r.i||0,P=0,H=r.w||0,j=0;T+2<o;++T){var z=R(T),_=T&32767,M=x[z];if(y[_]=M,x[z]=_,H<=T){var V=o-T;if((L>7e3||P>24576)&&(V>423||!l)){a=Ft(t,c,0,E,N,D,I,P,j,T-j,a),P=L=I=0,j=T;for(var G=0;G<286;++G)N[G]=0;for(var G=0;G<30;++G)D[G]=0}var $=2,b=0,f=v,h=_-M&32767;if(V>2&&z==R(T-h))for(var m=Math.min(p,V)-1,g=Math.min(32767,T),S=Math.min(258,V);h<=g&&--f&&_!=M;){if(t[T+$]==t[T+$-h]){for(var k=0;k<S&&t[T+k]==t[T+k-h];++k);if(k>$){if($=k,b=h,k>m)break;for(var A=Math.min(h,k-2),B=0,G=0;G<A;++G){var W=T-h+G&32767,O=y[W],q=W-O&32767;q>B&&(B=q,M=W)}}}_=M,M=y[_],h+=_-M&32767}if(b){E[P++]=268435456|at[$]<<18|Dt[b];var ee=at[$]&31,oe=Dt[b]&31;I+=rt[ee]+ot[oe],++N[257+ee],++D[oe],H=T+$,++L}else E[P++]=t[T],++N[t[T]]}}for(T=Math.max(T,H);T<o;++T)E[P++]=t[T],++N[t[T]];a=Ft(t,c,l,E,N,D,I,P,j,T-j,a),l||(r.r=a&7|c[a/8|0]<<3,a-=7,r.h=x,r.p=y,r.i=T,r.w=H)}else{for(var T=r.w||0;T<o+l;T+=65535){var te=T+65535;te>=o&&(c[a/8|0]=l,te=o),a=Mt(c,a+1,t.subarray(T,te))}r.i=o}return Kn(u,0,s+Lt(a)+i)},Qn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,s=9;--s;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t}(),Zn=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=Qn[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Bt=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new ae(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return Yn(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,s,i)},Ei=function(t,e){var n={};for(var s in t)n[s]=t[s];for(var s in e)n[s]=e[s];return n},es=function(t,e,n){for(var s=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<s.length;++o){var u=s[o],c=r[o];if(typeof u=="function"){e+=";"+c+"=";var l=u.toString();if(u.prototype)if(l.indexOf("[native code]")!=-1){var a=l.indexOf(" ",8)+1;e+=l.slice(a,l.indexOf("(",a))}else{e+=l;for(var d in u.prototype)e+=";"+c+".prototype."+d+"="+u.prototype[d].toString()}else e+=l}else n[c]=u}return e},ht=[],Ti=function(t){var e=[];for(var n in t)t[n].buffer&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e},Ii=function(t,e,n,s){if(!ht[n]){for(var i="",r={},o=t.length-1,u=0;u<o;++u)i=es(t[u],i,r);ht[n]={c:es(t[o],i,r),e:r}}var c=Ei({},ht[n].e);return wi(ht[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,Ti(c),s)},Ci=function(){return[ae,se,it,rt,ot,Rt,at,Dt,Vn,Ie,Gn,Je,ct,Xn,Pt,Fe,ge,Pe,lt,ut,At,Be,Mt,Ft,Lt,Kn,Yn,Bt,Oi,ts]},_i=function(){return[ns,ss,dt,Zn,Qn]},ts=function(t){return postMessage(t,[t.buffer])},Ni=function(t,e,n,s,i,r){var o=Ii(n,s,i,function(u,c){o.terminate(),r(u,c)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},dt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},ns=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&dt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var s=0;s<=n.length;++s)t[s+10]=n.charCodeAt(s)}},ss=function(t){return 10+(t.filename?t.filename.length+1:0)};function Oi(t,e){return Bt(t,e||{},0,0)}function Ri(t,e,n){return n||(n=e,e={}),typeof n!="function"&&Jn(7),Ni(t,e,[Ci,_i,function(){return[is]}],function(s){return ts(is(s.data[0],s.data[1]))},2,n)}function is(t,e){e||(e={});var n=Zn(),s=t.length;n.p(t);var i=Bt(t,e,ss(e),8),r=i.length;return ns(i,e),dt(i,r-8,n.d()),dt(i,r-4,s),i}var Di=typeof TextDecoder<"u"&&new TextDecoder,Li=0;try{Di.decode(Pt,{stream:!0}),Li=1}catch{}class rs{constructor(){this.idx=1,this.backDict={}}getKey(e){let n=!1;return this.backDict[e]||(n=!0,this.backDict[e]=this.idx++),[this.backDict[e],n]}}class Ai{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new rs}sendSetAttribute(e,n,s){if(this.isDictDisabled){const i=[12,e,n,s];return this.app.send(i)}else{const i=[51,e,this.applyDict(n),this.applyDict(s)];return this.app.send(i)}}applyDict(e){const[n,s]=this.dict.getKey(e);return s&&this.app.send([50,n,e]),n}clear(){this.dict=new rs}}class Mi{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Fi(s);if(i.type)return i}},this.durationInt=null}setConditions(e){this.conditions=e}async fetchConditions(e,n){try{const s=await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${e}`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}),{conditions:i}=await s.json(),r=[];i.forEach(o=>{o.filters.forEach(c=>{let l;c.type==="fetch"?(l={type:"network_request",subConditions:[],name:o.name},c.filters.forEach(a=>{const d=this.createConditionFromFilter(a);d&&l.subConditions.push(d)})):l=this.createConditionFromFilter(c),l&&(l.type==="session_duration"&&this.processDuration(l.value[0],o.name),r.push({...l,name:o.name}))})}),this.conditions=r}catch{this.app.debug.error("Critical: cannot fetch start conditions")}}trigger(e){if(!this.hasStarted)try{this.hasStarted=!0,this.app.start(this.startParams,void 0,e)}catch(n){this.app.debug.error(n)}}processMessage(e){if(!this.hasStarted)switch(e[0]){case 78:this.jsExceptionEvent(e);break;case 27:this.customEvent(e);break;case 68:this.clickEvent(e);break;case 122:this.pageLocationEvent(e);break;case 83:this.networkRequest(e);break}}processFlags(e){const n=this.conditions.filter(s=>s.type==="feature_flag");n.length&&n.forEach(s=>{const i=je[s.operator];i&&e.find(r=>i(r.key,s.value))&&this.trigger(s.name)})}processDuration(e,n){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(n)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const n=this.conditions.filter(s=>s.type==="network_request");n.length&&n.forEach(s=>{const i=s.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let u;switch(o.key){case"url":u=e[3];break;case"status":u=e[6];break;case"method":u=e[2];break;case"duration":u=e[8];break}const c=je[o.operator];if(c&&c(u,o.value))return!0})&&this.trigger(s.name):i.length===0&&s.subConditions.length&&this.trigger(s.name)})}customEvent(e){const n=this.conditions.filter(s=>s.type==="custom_event");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[1],s.value)||i(e[2],s.value))&&this.trigger(s.name)})}clickEvent(e){const n=this.conditions.filter(s=>s.type==="click");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[3],s.value)||i(e[4],s.value))&&this.trigger(s.name)})}pageLocationEvent(e){const n=this.conditions.filter(s=>s.type==="visited_url");n&&n.forEach(s=>{const i=je[s.operator];i&&i(e[1],s.value)&&this.trigger(s.name)})}jsExceptionEvent(e){const n=[e[1],e[2],e[3]],s=this.conditions.filter(i=>i.type==="exception");s&&s.forEach(i=>{const r=je[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const je={is:(t,e)=>e.some(n=>t.includes(n)),isAny:()=>!0,isNot:(t,e)=>!e.some(n=>t.includes(n)),contains:(t,e)=>e.some(n=>t.includes(n)),notContains:(t,e)=>!e.some(n=>t.includes(n)),startsWith:(t,e)=>e.some(n=>t.startsWith(n)),endsWith:(t,e)=>e.some(n=>t.endsWith(n)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Fi=t=>{const e={on:"is",notOn:"isNot",">":"greaterThan","<":"lessThan","=":"is","<=":"lessOrEqual",">=":"greaterOrEqual"},n=i=>{if(Object.keys(e).includes(i))return e[i]};let s={type:"",operator:"",value:t.value,key:""};switch(t.type){case"click":s={type:"click",operator:n(t.operator),value:t.value,key:""};break;case"location":s={type:"visited_url",operator:t.operator,value:t.value,key:""};break;case"custom":s={type:"custom_event",operator:t.operator,value:t.value,key:""};break;case"metadata":s={type:t.source==="featureFlag"?"feature_flag":t.type,operator:t.operator,value:t.value,key:""};break;case"error":s={type:"exception",operator:t.operator,value:t.value,key:""};break;case"duration":s={type:"session_duration",value:t.value[0],key:""};break;case"fetchUrl":s={type:"network_request",key:"url",operator:t.operator,value:t.value};break;case"fetchStatusCode":s={type:"network_request",key:"status",operator:n(t.operator),value:t.value};break;case"fetchMethod":s={type:"network_request",key:"method",operator:n(t.operator),value:t.value};break;case"fetchDuration":s={type:"network_request",key:"duration",operator:n(t.operator),value:t.value};break}return s};class Pi{constructor(e){this.app=e,this.flags=[],this.storageKey="__openreplay_flags";const n=this.app.sessionStorage.getItem(this.storageKey);if(n){const s=n.split(";").filter(Boolean);this.flags=s.map(i=>JSON.parse(i))}}getFeatureFlag(e){return this.flags.find(n=>n.key===e)}isFlagEnabled(e){return this.flags.findIndex(n=>n.key===e)!==-1}onFlagsLoad(e){this.onFlagsCb=e}async reloadFlags(e){const n=this.app.sessionStorage.getItem(this.storageKey),s={};n&&n.split(";").filter(Boolean).forEach(a=>{const d=JSON.parse(a);s[d.key]={key:d.key,value:d.value}});const i=this.app.session.getInfo(),r=this.app.session.userInfo,o={projectID:i.projectID,userID:i.userID,metadata:i.metadata,referrer:document.referrer,os:r.userOS,device:r.userDevice,country:r.userCountry,state:r.userState,city:r.userCity,browser:r.userBrowser,persistFlags:s},u=e??this.app.session.getSessionToken(),c=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(o)});if(c.status===200){const l=await c.json();return this.handleFlags(l.flags)}}handleFlags(e){var r;const n=[];e.forEach(o=>{o.is_persist&&n.push(o)});let s="";return this.diffPersist(n).forEach(o=>{s+=`${JSON.stringify(o)};`}),this.app.sessionStorage.setItem(this.storageKey,s),this.flags=e,(r=this.onFlagsCb)==null?void 0:r.call(this,e)}clearPersistFlags(){this.app.sessionStorage.removeItem(this.storageKey)}diffPersist(e){const n=this.app.sessionStorage.getItem(this.storageKey);if(!n)return e;const i=n.split(";").filter(Boolean).map(r=>JSON.parse(r));return e.filter(r=>i.findIndex(o=>o.key===r.key)===-1)}}const os={htmlmasked:"hidden",masked:"obscured"},me=!(typeof window>"u"),Bi=me&&navigator.userAgent.match(/firefox|fxios/i),ji=1e5;let jt=me?Date.now()-performance.now():0;function zt(){jt=Date.now()-performance.now()}function ze(){return jt}const fe=me&&performance.now?()=>Math.round(performance.now()+jt):()=>Date.now(),Ut="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function as(t){return t.trim().replace(/\s+/g," ")}function cs(t){return t.startsWith("https://")||t.startsWith("http://")}const ft="https://docs.openreplay.com",ls={};function Ce(t,e,n="/"){ls[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${ft}${n} for more information.`),ls[t]=!0)}function Ht(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ce('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Re(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(os[e]&&Ce(`"${n}" attribute`,`"${os[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function zi(t){try{return!!t.contentDocument}catch{return!1}}function us(t){return t.toString(16).padStart(2,"0")}function Ui(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,us).join("")):Array.from({length:t||40},()=>us(Math.floor(Math.random()*16))).join("")}function Hi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function $t(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function hs(t){const e=$t("MutationObserver");return new window[e](t)}function ds(t,e,n,s){const i=$t("addEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}function fs(t,e,n,s){const i=$t("removeEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}class $i{constructor(){this.taskQueue=[],this.isRunning=!1}addTask(e){this.taskQueue.push(e),this.runTasks()}runTasks(){if(this.isRunning||this.taskQueue.length===0)return;this.isRunning=!0;const e=()=>{if(this.taskQueue.length===0){this.isRunning=!1;return}const n=this.taskQueue.shift();Promise.resolve(n()).then(()=>{requestAnimationFrame(()=>e())})};e()}}const Wi=new $i;function qi(t){Wi.addTask(t)}function ps(t,e){const n={...t};for(const s in e)if(e.hasOwnProperty(s)){const i=e[s],r=t[s];typeof i=="object"&&!Array.isArray(i)&&i!==null?n[s]=ps(r||{},i):n[s]=i}return n}function De(t){return[0,t]}function Vi(t,e){return[5,t,e]}function Gi(t,e){return[6,t,e]}function Ki(){return[7]}function Ji(t,e,n,s,i){return[8,t,e,n,s,i]}function Xi(t,e,n){return[9,t,e,n]}function Yi(t,e,n){return[10,t,e,n]}function Qi(t){return[11,t]}function gs(t,e){return[13,t,e]}function Zi(t,e){return[14,t,e]}function er(t,e,n){return[16,t,e,n]}function tr(t,e,n){return[18,t,e,n]}function nr(t,e){return[19,t,e]}function sr(t,e){return[20,t,e]}function ir(t,e){return[22,t,e]}function rr(t,e,n,s,i,r,o,u,c){return[23,t,e,n,s,i,r,o,u,c]}function or(t,e,n){return[24,t,e,n]}function ar(t,e){return[27,t,e]}function cr(t){return[28,t]}function lr(t){return[29,t]}function ms(t,e){return[30,t,e]}function ur(t,e,n,s){return[49,t,e,n,s]}function hr(t,e){return[54,t,e]}function dr(t){return[55,t]}function vs(t,e,n,s){return[57,t,e,n,s]}function bs(t){return[58,t]}function Wt(t,e,n,s){return[60,t,e,n,s]}function fr(t,e,n){return[61,t,e,n]}function pr(t,e){return[63,t,e]}function gr(t,e){return[64,t,e]}function mr(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function qt(t,e){return[70,t,e]}function ys(t,e,n){return[71,t,e,n]}function Vt(t,e,n,s){return[73,t,e,n,s]}function ws(t,e){return[75,t,e]}function Ss(t,e){return[76,t,e]}function vr(t,e){return[77,t,e]}function Gt(t,e,n,s){return[78,t,e,n,s]}function pt(t,e,n,s,i,r,o,u,c){return[83,t,e,n,s,i,r,o,u,c]}function br(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function yr(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function xs(t,e,n){return[113,t,e,n]}function wr(t){return[114,t]}function Sr(t){return[115,t]}function ks(t,e,n,s,i,r,o,u,c,l){return[116,t,e,n,s,i,r,o,u,c,l]}function gt(t){return[117,t]}function Le(t){return[118,t]}function xr(t,e){return[119,t,e]}function kr(t){return[120,t]}function Er(t,e,n,s){return[122,t,e,n,s]}const Kt=me&&"performance"in window&&"memory"in performance?performance:{memory:{}},Jt=me?(navigator.deviceMemory||0)*1024:0,Xt=Kt.memory.jsHeapSizeLimit||0;function Tr(t,e){if(!Object.assign({capturePerformance:!0},e).capturePerformance)return;let s,i;const r=()=>{s===void 0||s===-1||(s++,requestAnimationFrame(r))};t.ticker.attach(()=>{i===void 0||i===-1||i++},0,!1);const o=()=>{s===void 0||i===void 0||(t.send(ur(s,i,Kt.memory.totalJSHeapSize||0,Kt.memory.usedJSHeapSize||0)),i=s=document.hidden?-1:0)};t.attachStartCallback(()=>{i=s=-1,o(),r()}),t.attachStopCallback(()=>{i=s=void 0}),t.ticker.attach(o,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1)}const Es="__or__watched_tags__";class Ir{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Es)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const u=o.target.__or_watcher_tagname;u&&this.onTagRendered(u),this.observer.unobserve(o.target)}})})}async fetchTags(e,n){return fetch(`${e}/v1/web/tags`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}).then(s=>s.json()).then(({tags:s})=>{if(s&&s.length){this.setTags(s);const i=JSON.stringify(s);this.sessionStorage.setItem(Es,i||"")}}).catch(s=>this.errLog(s))}setTags(e){this.tags=e,this.intervals={},e.forEach(n=>{this.intervals[n.id]=setInterval(()=>{const s=document.querySelectorAll(n.selector);if(s.length>0){const i=s[0];i.__or_watcher_tagname=n.id,this.observer.observe(i)}},500)})}onTagRendered(e){this.intervals[e]&&clearInterval(this.intervals[e]),this.onTag(e)}clear(){this.tags.forEach(e=>{clearInterval(this.intervals[e.id])}),this.tags=[],this.intervals={},this.observer.disconnect()}}const Cr={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0, 0, 0, 0.40)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'},_r={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},mt={display:"flex","flex-direction":"column",gap:"unset","align-items":"center",padding:"unset",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',"border-radius":"2px",border:"1px solid #D9D9D9",background:"rgba(255, 255, 255, 0.75)",width:"22rem"},Nr={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Or={borderTop:"1px solid rgba(0, 0, 0, 0.06)",borderBottom:"1px solid rgba(0, 0, 0, 0.06)",padding:"1.25rem 0rem",color:"rgba(0, 0, 0, 0.85)",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"400",lineHeight:"auto",whiteSpace:"pre-wrap"},Rr={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",cursor:"pointer"},Ts={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},Ue={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Dr={padding:"0.5rem",gap:"0.5rem",fontFamily:"Verdana, sans-serif",fontSize:"16px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto",color:"white",display:"flex",alignItems:"center",width:"100%",borderRadius:"2px",background:"rgba(0, 0, 0, 0.75)",boxSizing:"border-box"},He={boxSizing:"border-box",display:"block",width:"100%",borderBottom:"1px solid #D9D9D9",background:"#FFF",padding:"0.65rem",alignSelf:"stretch",color:"#000",fontFamily:"Verdana, sans-serif",fontStyle:"normal",fontWeight:"400"},Lr={...He,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Is={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Cs={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",width:"100%",boxSizing:"border-box",cursor:"pointer"},_s={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Ar={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Ns={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Mr={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #D2DFFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",background:"#D2DFFF",fontSize:"13px",height:"24px",width:"24px"},Os={borderRadius:"0.375rem",border:"1px solid rgba(0, 0, 0, 0.06)",background:"#F5F7FF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",padding:"0.625rem 0.9375rem",gap:"0.5rem",alignSelf:"stretch"},Rs={fontWeight:"bold"},Fr={fontSize:"13px",lineHeight:"auto"},Ds={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Pr={...Ds,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Br={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},jr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Ls={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class zr{constructor(e){this.app=e,this.mediaRecorder=null,this.recordedChunks=[],this.stream=null,this.recStartTs=null}async startRecording(e,n,s,i){this.recStartTs=this.app.timestamp();const r=n;try{this.stream=await navigator.mediaDevices.getUserMedia({video:i?{...r,frameRate:{ideal:e}}:!1,audio:s}),this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:"video/webm;codecs=vp9"}),this.recordedChunks=[],this.mediaRecorder.ondataavailable=o=>{o.data.size>0&&this.recordedChunks.push(o.data)},this.mediaRecorder.start()}catch(o){console.error(o)}}async stopRecording(){return new Promise(e=>{this.mediaRecorder&&(this.mediaRecorder.onstop=()=>{const n=new Blob(this.recordedChunks,{type:"video/webm"});e(n)},this.mediaRecorder.stop())})}async sendToAPI(){const e=await this.stopRecording();return fetch(`${this.app.options.ingestPoint}/v1/web/uxt/upload-url`,{headers:{Authorization:`Bearer ${this.app.session.getSessionToken()}`}}).then(n=>{if(n.ok)return n.json();throw new Error("Failed to get upload url")}).then(({url:n})=>fetch(n,{method:"PUT",headers:{"Content-Type":"video/webm"},body:e})).catch(console.error).finally(()=>{this.discard()})}async saveToFile(e="recorded-video.webm"){const n=await this.stopRecording(),s=URL.createObjectURL(n),i=document.createElement("a");i.style.display="none",i.href=s,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(s),document.body.removeChild(i)}discard(){var e,n;(e=this.mediaRecorder)==null||e.stop(),(n=this.stream)==null||n.getTracks().forEach(s=>s.stop())}}function Ur(t,e){e.onmousedown=function(n){const s=t.getBoundingClientRect(),i=n.clientX-s.left,r=n.clientY-s.top;t.style.position="fixed",t.style.zIndex=99999999999999,o(n.pageX,n.pageY);function o(l,a){let d=l-i,p=a-r;d<=5&&(d=5),p<=5&&(p=5),d>=window.innerWidth-s.width&&(d=window.innerWidth-s.width),p>=window.innerHeight-s.height&&(p=window.innerHeight-s.height),t.style.left=`${d}px`,t.style.top=`${p}px`}function u(l){o(l.pageX,l.pageY)}document.addEventListener("mousemove",u);const c=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",c)};document.addEventListener("mouseup",c)},e.ondragstart=function(){return!1}}function Hr(){const t=document.createElement("div");t.className="grid";for(let e=0;e<16;e++){const n=document.createElement("div");Object.assign(n.style,{width:"2px",height:"2px",borderRadius:"10px",background:"white"}),n.className="cell",t.appendChild(n)}return Object.assign(t.style,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(4, 1fr)",gap:"2px",cursor:"grab"}),t}function $r(){const t=document.createElement("div");Object.assign(t.style,{width:"0",height:"0",borderLeft:"7px solid transparent",borderRight:"7px solid transparent",borderBottom:"7px solid white"});const e=document.createElement("div");return e.appendChild(t),Object.assign(e.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",cursor:"pointer",marginLeft:"auto",transform:"rotate(180deg)"}),e}function Wr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
1
+ (function(Ke){typeof define=="function"&&define.amd?define(Ke):Ke()})(function(){"use strict";var ui,hi;function Ke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Nt(t,e,n){console.log(t,n);let s="";if(n){const i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3),s="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/; secure; samesite=strict"}function Ot(t){const e=t+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let i=n[s];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null}function Un(){const t="uniqueUserID";let e=Ot(t);return e||(e=Ke(),Nt(t,e,365)),e}function bi(t,e,n={},s={}){const i="https://admin-api.wineater.com/api/widget-events";let r=Ot("uniqueUserID");r||(r=Un());const o={user_agent:navigator.userAgent,screen_width:window.screen.width,screen_height:window.screen.height,language:navigator.language,platform:navigator.platform},u=new Date().toISOString();let c=Ot("sessionID");c||(c=Ke(),Nt("sessionID",c,1));const l={event_type:t,store_id:e,session_id:c,event_time:u,data:n,meta:{...s,user_id:r},device_info:o,region:navigator.language.split("-")[1]||null,language:navigator.language.split("-")[0]||"en"};return fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(a=>a.ok?a.json():a.json().then(d=>{throw new Error(d.message||"Failed to track widget event")})).catch(a=>{throw console.error("Widget event tracking error:",a),a})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(b);f==null||f(null,S),m(S)}catch(k){f&&f(k,null),g(k)}})},setItem:function(b,f,h){return new Promise(function(m,g){try{localStorage.setItem(b,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(b){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,h,m){return new(h||(h=Promise))(function(g,S){function k(W){try{B(m.next(W))}catch(O){S(O)}}function A(W){try{B(m.throw(W))}catch(O){S(O)}}function B(W){var O;W.done?g(W.value):(O=W.value,O instanceof h?O:new h(function(q){q(O)})).then(k,A)}B((m=m.apply(b,f||[])).next())})}function o(b,f){var h,m,g,S,k={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function A(B){return function(W){return function(O){if(h)throw new TypeError("Generator is already executing.");for(;k;)try{if(h=1,m&&(g=2&O[0]?m.return:O[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,O[1])).done)return g;switch(m=0,g&&(O=[2&O[0],g.value]),O[0]){case 0:case 1:g=O;break;case 4:return k.label++,{value:O[1],done:!1};case 5:k.label++,m=O[1],O=[0];continue;case 7:O=k.ops.pop(),k.trys.pop();continue;default:if(g=k.trys,!((g=g.length>0&&g[g.length-1])||O[0]!==6&&O[0]!==2)){k=0;continue}if(O[0]===3&&(!g||O[1]>g[0]&&O[1]<g[3])){k.label=O[1];break}if(O[0]===6&&k.label<g[1]){k.label=g[1],g=O;break}if(g&&k.label<g[2]){k.label=g[2],k.ops.push(O);break}g[2]&&k.ops.pop(),k.trys.pop();continue}O=f.call(b,k)}catch(q){O=[6,q],m=0}finally{h=g=0}if(5&O[0])throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}([B,W])}}}function u(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var c=function b(f,h){if(f===h)return!0;if(f&&h&&typeof f=="object"&&typeof h=="object"){if(f.constructor!==h.constructor)return!1;var m,g,S;if(Array.isArray(f)){if((m=f.length)!=h.length)return!1;for(g=m;g--!=0;)if(!b(f[g],h[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===h.source&&f.flags===h.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===h.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===h.toString();if((m=(S=Object.keys(f)).length)!==Object.keys(h).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(h,S[g]))return!1;for(g=m;g--!=0;){var k=S[g];if(!b(f[k],h[k]))return!1}return!0}return f!=f&&h!=h};function l(b,f){var h=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],S=f==null?void 0:f[m];return!c(g,S)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var a,d;function p(b,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?h+"":h}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function w(b){return Object.fromEntries(Object.entries(b).map(function(f){var h=f[0],m=f[1];return[h,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:w(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(a||(a={}));var x,C=null,F="BULLET_TRAIN_DB",R="BULLET_TRAIN_EVENT",E="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",D="flagsmith_enabled_",L="flagsmith_trait_",I=function(){function b(f){var h=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=h,g=m.api,S=m.evaluationContext;h.log("Get Flags"),h.isLoading=!0,h.loadingState.isFetching||h.setLoadingState(i(i({},h.loadingState),{isFetching:!0}));var k="".concat(h.getContext().identity),A=function(B){var W,O,q,ee;if(B&&k==="".concat(h.getContext().identity)){var oe=B.flags,te=B.traits,ne=B.identifier;h.isLoading=!1;var ue={},he={};te=te||[],(oe=oe||[]).forEach(function(K){ue[K.feature.name.toLowerCase().replace(/ /g,"_")]={id:K.feature.id,enabled:K.enabled,value:K.feature_state_value}}),te.forEach(function(K){he[K.trait_key.toLowerCase().replace(/ /g,"_")]={transient:K.transient,value:K.trait_value}}),h.oldFlags=i({},h.flags);var we=l(h.oldFlags,ue),Ze=l((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.traits,he);if((ne||Object.keys(he).length)&&(h.evaluationContext.identity={traits:he},ne&&(h.evaluationContext.identity.identifier=ne)),h.flags=ue,h.updateStorage(),h._onChange(h.oldFlags,{isFromServer:!0,flagsChanged:we,traitsChanged:Ze},h._loadedState(null,a.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var et={};Object.keys(((O=h.evaluationContext.identity)===null||O===void 0?void 0:O.traits)||{}).map(function(K){et[L+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.identifier)}),et);h.log("Setting Datadog user",qe),h.datadogRum.client.setUser(qe)}}catch(K){console.error(K)}if(h.dtrum)try{var ie={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(h.flags).map(function(K){p(ie,N+K,h.getValue(K,{skipAnalytics:!0})),p(ie,D+K,h.hasFeature(K,{skipAnalytics:!0}))}),Object.keys(((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(K){p(ie,L+K,h.getTrait(K))}),h.log("Sending javaLongOrObject traits to dynatrace",ie.javaLongOrObject),h.log("Sending date traits to dynatrace",ie.date),h.log("Sending shortString traits to dynatrace",ie.shortString),h.log("Sending javaDouble to dynatrace",ie.javaDouble),h.dtrum.sendSessionProperties(ie.javaLongOrObject,ie.date,ie.shortString,ie.javaDouble)}catch(K){console.error(K)}}};return S.identity?Promise.all([S.identity.traits&&Object.keys(S.identity.traits).length||!S.identity.identifier?h.getJSON(g+"identities/","POST",JSON.stringify({identifier:S.identity.identifier,transient:S.identity.transient,traits:Object.entries(S.identity.traits).map(function(B){var W=B[0],O=B[1];return{trait_key:W,trait_value:O==null?void 0:O.value,transient:O==null?void 0:O.transient}}).filter(function(B){return B.trait_value!==void 0||(h.log("Warning - attempted to set an undefined trait value for key",B.trait_key),!1)})})):h.getJSON(g+"identities/?identifier="+encodeURIComponent(S.identity.identifier)+(S.identity.transient?"&transient=true":""))]).then(function(B){return h.evaluationContext.identity=i(i({},h.evaluationContext.identity),{traits:{}}),A(B==null?void 0:B[0])}).catch(function(B){var W=B.message,O=new Error(W);return Promise.reject(O)}):h.getJSON(g+"flags/").then(function(B){return A({flags:B,traits:void 0})})},this.analyticsFlags=function(){var m=h.api;if(h.evaluationEvent&&h.evaluationContext.environment&&h.evaluationEvent[h.evaluationContext.environment.apiKey])return h.evaluationEvent&&Object.getOwnPropertyNames(h.evaluationEvent).length!==0&&Object.getOwnPropertyNames(h.evaluationEvent[h.evaluationContext.environment.apiKey]).length!==0?h.getJSON(m+"analytics/flags/","POST",JSON.stringify(h.evaluationEvent[h.evaluationContext.environment.apiKey])).then(function(g){if(h.evaluationContext.environment){var S=h.getState();h.evaluationEvent||(h.evaluationEvent={}),h.evaluationEvent[h.evaluationContext.environment.apiKey]={},h.setState(i(i({},S),{evaluationEvent:h.evaluationEvent})),h.updateEventStorage()}}).catch(function(g){h.log("Exception fetching evaluationEvent",g)}):void 0},this.datadogRum=null,this.loadingState={isLoading:!0,isFetching:!0,error:null,source:a.NONE},this.canUseStorage=!1,this.analyticsInterval=null,this.api=null,this.cacheFlags=!1,this.ts=null,this.enableAnalytics=!1,this.enableLogs=!1,this.evaluationContext={},this.evaluationEvent=null,this.flags=null,this.getFlagInterval=null,this.headers=null,this.initialised=!1,this.oldFlags=null,this.onChange=null,this.onError=null,this.ticks=null,this.timer=null,this.dtrum=null,this.withTraits=null,this.cacheOptions={ttl:0,skipAPI:!1,loadStale:!1},this.getValue=function(m,g,S){var k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=null;if(k&&(A=k.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),A===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return A===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(A)}catch{return g.fallback}return A},this.getTrait=function(m){var g,S;return((g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((S=h.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||S===void 0?void 0:S.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=h.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var S=g[0],k=g[1];return[S,k==null?void 0:k.value]}))},this.setContext=function(m){var g=y(m);return h.evaluationContext=i(i({},g),{environment:g.environment||h.evaluationContext.environment}),h.initialised?h.getFlags():Promise.resolve()},this.getContext=function(){return h.evaluationContext},this.updateContext=function(m){return h.setContext(i(i({},h.getContext()),m))},this.setTrait=function(m,g){var S;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(S=h.evaluationContext.identity)===null||S===void 0?void 0:S.traits),w(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(S){var k=S[0],A=S[1];return[k,v(A)?A:{value:A}]})))})}));console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.")},this.hasFeature=function(m,g){var S=typeof g=="object",k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=!1;return!k&&S&&g.fallback!==void 0?A=g==null?void 0:g.fallback:k&&k.enabled&&(A=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),A},this.getJSON=function(m,g,S){var k,A=h;A.evaluationContext;var B=A.headers,W={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(W.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(W.headers["Content-Type"]="application/json; charset=utf-8"),B&&Object.assign(W.headers,B),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var O="".concat((k=h.evaluationContext.identity)===null||k===void 0?void 0:k.identifier);return d(m,W).then(function(q){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(O===te){var ne=(oe=q.headers)===null||oe===void 0?void 0:oe.get("x-flagsmith-document-updated-at");if(ne)try{var ue=parseFloat(ne);if(isNaN(ue))return Promise.reject("Failed to parse x-flagsmith-document-updated-at");h.timestamp=ue}catch(he){h.log(he,"Failed to parse x-flagsmith-document-updated-at",ne)}return h.log("Fetch response: "+q.status+" "+(g||"GET")+0+m),q.text().then(function(he){var we=he;try{we=JSON.parse(he)}catch{}return!we&&q.status&&(we="API Response: ".concat(q.status)),q.status&&q.status>=200&&q.status<300?we:Promise.reject(new Error(we))})}h.log("Received response with identity mismatch, ignoring response. Requested: ".concat(O,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(h.datadogRum&&(h.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?h.datadogRum.client.addFeatureFlagEvaluation(N+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(D+m,h.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),h.enableAnalytics){if(!h.evaluationEvent||!h.evaluationContext.environment)return;h.evaluationEvent[h.evaluationContext.environment.apiKey]||(h.evaluationEvent[h.evaluationContext.environment.apiKey]={}),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]===void 0&&(h.evaluationEvent[h.evaluationContext.environment.apiKey][m]=0),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]+=1}h.updateEventStorage()},this._onChange=function(m,g,S){var k,A;h.setLoadingState(S),(k=h.onChange)===null||k===void 0||k.call(h,m,g,h.loadingState),(A=h._trigger)===null||A===void 0||A.call(h)},d=f.fetch?f.fetch:typeof fetch<"u"?fetch:Me==null?void 0:Me.fetch,this.canUseStorage=typeof window<"u"||!!f.browserlessStorage,this.log("Constructing flagsmith instance "+f),f.eventSource&&(x=f.eventSource),f.AsyncStorage&&(C=f.AsyncStorage)}return b.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,k,A,B,W,O,q,ee,oe,te,ne,ue,he,we,Ze,et,qe,ie,K,wn,tt,di,nt,Sn,fi,pi,xn,gi,kn,st,Ve,mi,re=this;return o(this,function(ge){switch(ge.label){case 0:S=y(f.evaluationContext||this.evaluationContext),ge.label=1;case 1:if(ge.trys.push([1,13,,14]),k=f.environmentID,A=f.api,B=A===void 0?E:A,W=f.headers,O=f.onChange,q=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,we=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,wn=f.identity,tt=f.traits,di=f.state,nt=f.cacheOptions,Sn=f.angularHttpClient,fi=f._trigger,pi=f._triggerLoadingState,S.environment=k?{apiKey:k}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=wn||tt?{identifier:wn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=B,this.headers=W,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=O,xn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=fi||this._trigger,this._triggerLoadingState=pi||this._triggerLoadingState,this.onError=function(de){re.setLoadingState(i(i({},re.loadingState),{isFetching:!1,isLoading:!1,error:de})),oe==null||oe(de)},this.enableLogs=he||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=C!==void 0&&!!q,K&&(C=K),et&&typeof window<"u"&&this.setupRealtime(ie,S.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:a.DEFAULT_FLAGS})),this.setState(di),this.log("Initialising with properties",f,this),we&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Sn&&(d=function(de){return function(Se,xe){var Ne=xe.headers,Y=xe.method,Ge=xe.body;return new Promise(function(Ae){switch(Y){case"GET":return de.get(Se,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})});case"POST":case"PUT":return de.post(Se,Ge,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})})}})}}(Sn)),C&&this.canUseStorage&&C.getItem(R).then(function(de){try{re.evaluationEvent=JSON.parse(de)||{}}catch{re.evaluationEvent={}}re.analyticsInterval=setInterval(re.analyticsFlags,re.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),C&&this.canUseStorage&&C.getItem(R,function(de,Se){if(Se&&re.evaluationContext.environment){var xe=JSON.parse(Se);if(xe[re.evaluationContext.environment.apiKey]){var Ne=re.getState();re.log("Retrieved events from cache",Se),re.setState(i(i({},Ne),{evaluationEvent:xe[re.evaluationContext.environment.apiKey]}))}}})),!q)return[3,9];if(!C||!this.canUseStorage)return[3,8];gi=function(de,Se){return r(re,void 0,void 0,function(){var xe,Ne,Y,Ge,Ae,Ee,En,vi,Tn,In,Cn,_n,Nn,On,Rn,Dn,Ln,An,Mn,Fn,Pn,Bn,jn,zn;return o(this,function(Oe){switch(Oe.label){case 0:if(!Se)return[3,7];xe=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(Se),Ge=!1,Ae=!1,Y&&Y.api===this.api&&((In=(Tn=Y.evaluationContext)===null||Tn===void 0?void 0:Tn.environment)===null||In===void 0?void 0:In.apiKey)===((Cn=this.evaluationContext.environment)===null||Cn===void 0?void 0:Cn.apiKey)&&(Ee=!0,this.evaluationContext.identity&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.identity)===null||Nn===void 0?void 0:Nn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Rn=(On=Y.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.identifier)+" to "+this.evaluationContext.identity.identifier),Ee=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ee=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ae=!0,Ee=!0)),Ee&&(Ge=!0,Ne=l((Dn=this.evaluationContext.identity)===null||Dn===void 0?void 0:Dn.traits,(An=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||An===void 0?void 0:An.traits),xe=l(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Mn=Y.evaluationContext)===null||Mn===void 0)&&Mn.identity?i(i({},(Fn=Y.evaluationContext)===null||Fn===void 0?void 0:Fn.identity),{traits:i(i({},((Bn=(Pn=Y.evaluationContext)===null||Pn===void 0?void 0:Pn.identity)===null||Bn===void 0?void 0:Bn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(En=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:xe,traitsChanged:Ne},this._loadedState(null,a.CACHE,En)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!Ae&&this.log("Skipping API, using cache"),En&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return vi=Oe.sent(),this.log("Exception fetching cached logs",vi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(jn=this.evaluationContext.identity)===null||jn===void 0?void 0:jn.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(xn);this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(zn=this.evaluationContext.identity)===null||zn===void 0?void 0:zn.traits)},this._loadedState(null,a.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},ge.label=2;case 2:return ge.trys.push([2,7,,8]),C.getItemSync?(kn=C.getItemSync(F),[3,5]):[3,3];case 3:return[4,C.getItem(F)];case 4:kn=ge.sent(),ge.label=5;case 5:return[4,gi(null,kn)];case 6:case 7:return ge.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return ge.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},te),traitsChanged:l({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=xn),this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,a.DEFAULT_FLAGS)),st))throw new Error(st);ge.label=12;case 12:return[3,14];case 13:throw Ve=ge.sent(),this.log("Error during initialisation ",Ve),mi=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,mi),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,h,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:h}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,h,m){return this.evaluationContext.identity={identifier:f,transient:m,traits:this.evaluationContext.identity&&this.evaluationContext.identity.identifier==f?this.evaluationContext.identity.traits:{}},this.evaluationContext.identity.identifier=f,this.log("Identify: "+this.evaluationContext.identity.identifier),h&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(h).map(function(g){var S=g[0],k=g[1];return[S,v(k)?k:{value:k}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||E,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,u(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),C.setItem(F,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);C.setItem(R,f)}},b.prototype.setLoadingState=function(f){var h;c(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(h=this._triggerLoadingState)===null||h===void 0||h.call(this))},b.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";x?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new x(g),this.eventSource.addEventListener("environment_updated",function(S){var k;try{k=JSON.parse(S.data).updated_at}catch(A){m.log("Could not parse sse event",A)}k?!m.timestamp||k>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",S.data,m.timestamp):(m.log("updated_at is new, fetching flags",S.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",S.data,m.timestamp):m.log("No updated_at received, fetching flags",S)})):this.log("Error, EventSource is undefined")},b}();function T(b){var f=b.fetch,h=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var P,H=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,m){h.__proto__=m}||function(h,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(h[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function h(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&b[f],m=0;if(h)return h.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(b,f){var h=typeof Symbol=="function"&&b[Symbol.iterator];if(!h)return b;var m,g,S=h.call(b),k=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)k.push(m.value)}catch(A){g={error:A}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return k},_=function(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
2
+ Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`)||this}return H(f,b),f}(Error),V=function(){function b(f,h){var m=this;if(this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this._configuration=h!=null?Object.assign({},h):void 0,this.withCredentials=!1,this._eventSource=null,this._lastEventId=null,this._timer=null,this._listeners={open:[],error:[],message:[]},this.url=f.toString(),this.readyState=this.CONNECTING,this.max_retry_time=3e3,this.eventSourceClass=globalThis.FlagsmithEventSource,this._configuration!=null&&(this._configuration.lastEventId&&(this._lastEventId=this._configuration.lastEventId,delete this._configuration.lastEventId),this._configuration.max_retry_time&&(this.max_retry_time=this._configuration.max_retry_time,delete this._configuration.max_retry_time),this._configuration.eventSourceClass&&(this.eventSourceClass=this._configuration.eventSourceClass,delete this._configuration.eventSourceClass)),this.eventSourceClass==null||typeof this.eventSourceClass!="function")throw new M;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return b.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},b.prototype._start=function(){var f,h,m=this,g=this.url;this._lastEventId&&(g.indexOf("?")===-1?g+="?":g+="&",g+="lastEventId="+encodeURIComponent(this._lastEventId)),this._eventSource=new this.eventSourceClass(g,this._configuration),this._eventSource.onopen=function(B){m._onopen(B)},this._eventSource.onerror=function(B){m._onerror(B)},this._eventSource.onmessage=function(B){m.onmessage(B)};try{for(var S=j(Object.keys(this._listeners)),k=S.next();!k.done;k=S.next()){var A=k.value;this._eventSource.addEventListener(A,this._onevent_wrapped)}}catch(B){f={error:B}}finally{try{k&&!k.done&&(h=S.return)&&h.call(S)}finally{if(f)throw f.error}}},b.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},b.prototype._onerror=function(f){var h=this;if(this.readyState===1&&(this.readyState=0,this.onerror(f)),this._eventSource){this._eventSource.close(),this._eventSource=null;var m=Math.round(this.max_retry_time*Math.random());this._timer=setTimeout(function(){return h._start()},m)}},b.prototype._onevent=function(f){var h,m;f&&f.lastEventId&&(this._lastEventId=f.lastEventId);var g=this._listeners[f.type];if(g!=null)try{for(var S=j(_([],z(g),!1)),k=S.next();!k.done;k=S.next())k.value.call(this,f)}catch(A){h={error:A}}finally{try{k&&!k.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}f.type==="message"&&this.onmessage(f)},b.prototype.onopen=function(f){},b.prototype.onerror=function(f){},b.prototype.onmessage=function(f){},b.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},b.prototype.addEventListener=function(f,h,m){this._listeners[f]==null&&(this._listeners[f]=[],this._eventSource!=null&&this._eventSource.addEventListener(f,this._onevent_wrapped));var g=this._listeners[f];g.includes(h)||(this._listeners[f]=_(_([],z(g),!1),[h],!1))},b.prototype.removeEventListener=function(f,h,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(S){return S!==h})},b}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var G=function(b,f){return f=f||{},new Promise(function(h,m){var g=new XMLHttpRequest,S=[],k=[],A={},B=function(){return{ok:(g.status/100|0)==2,statusText:g.statusText,status:g.status,url:g.responseURL,text:function(){return Promise.resolve(g.responseText)},json:function(){return Promise.resolve(g.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([g.response]))},clone:B,headers:{keys:function(){return S},entries:function(){return k},get:function(O){return A[O.toLowerCase()]},has:function(O){return O.toLowerCase()in A}}}};for(var W in g.open(f.method||"get",b,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(O,q,ee){S.push(q=q.toLowerCase()),k.push([q,ee]),A[q]=A[q]?A[q]+","+ee:ee}),h(B())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(W,f.headers[W]);g.send(f.body||null)})},$=T({AsyncStorage:s,fetch:G,eventSource:V});typeof window<"u"&&(window.flagsmith=$),n.createFlagsmithInstance=function(){return T({AsyncStorage:s,fetch:G,eventSource:V})},n.default=$,Object.defineProperty(n,"__esModule",{value:!0})})})(Hn,Hn.exports);var $n={},wi=function(t,e,n,s,i){var r=new Worker($n[e]||($n[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return r.onmessage=function(o){var u=o.data,c=u.$e$;if(c){var l=new Error(c[0]);l.code=c[1],l.stack=c[2],i(l,null)}else i(null,u)},r.postMessage(n,s),r},ae=Uint8Array,se=Uint16Array,it=Int32Array,rt=new ae([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]),ot=new ae([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]),Rt=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wn=function(t,e){for(var n=new se(31),s=0;s<31;++s)n[s]=e+=1<<t[s-1];for(var i=new it(n[30]),s=1;s<30;++s)for(var r=n[s];r<n[s+1];++r)i[r]=r-n[s]<<5|s;return{b:n,r:i}},qn=Wn(rt,2),Si=qn.b,at=qn.r;Si[28]=258,at[258]=28;for(var xi=Wn(ot,0),Dt=xi.r,ct=new se(32768),J=0;J<32768;++J){var Te=(J&43690)>>1|(J&21845)<<1;Te=(Te&52428)>>2|(Te&13107)<<2,Te=(Te&61680)>>4|(Te&3855)<<4,ct[J]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var Fe=function(t,e,n){for(var s=t.length,i=0,r=new se(e);i<s;++i)t[i]&&++r[t[i]-1];var o=new se(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var u;if(n){u=new se(1<<e);var c=15-e;for(i=0;i<s;++i)if(t[i])for(var l=i<<4|t[i],a=e-t[i],d=o[t[i]-1]++<<a,p=d|(1<<a)-1;d<=p;++d)u[ct[d]>>c]=l}else for(u=new se(s),i=0;i<s;++i)t[i]&&(u[i]=ct[o[t[i]-1]++]>>15-t[i]);return u},Ie=new ae(288),J=0;J<144;++J)Ie[J]=8;for(var J=144;J<256;++J)Ie[J]=9;for(var J=256;J<280;++J)Ie[J]=7;for(var J=280;J<288;++J)Ie[J]=8;for(var Je=new ae(32),J=0;J<32;++J)Je[J]=5;var Vn=Fe(Ie,9,0),Gn=Fe(Je,5,0),Lt=function(t){return(t+7)/8|0},Kn=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ae(t.subarray(e,n))},ki=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jn=function(t,e,n){var s=new Error(e||ki[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,Jn),!n)throw s;return s},me=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8},Pe=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8,t[s+2]|=n>>16},lt=function(t,e){for(var n=[],s=0;s<t.length;++s)t[s]&&n.push({s,f:t[s]});var i=n.length,r=n.slice();if(!i)return{t:Pt,l:0};if(i==1){var o=new ae(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(N,D){return N.f-D.f}),n.push({s:-1,f:25001});var u=n[0],c=n[1],l=0,a=1,d=2;for(n[0]={s:-1,f:u.f+c.f,l:u,r:c};a!=i-1;)u=n[n[l].f<n[d].f?l++:d++],c=n[l!=a&&n[l].f<n[d].f?l++:d++],n[a++]={s:-1,f:u.f+c.f,l:u,r:c};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var v=new se(p+1),w=ut(n[a-1],v,0);if(w>e){var s=0,y=0,x=w-e,C=1<<x;for(r.sort(function(D,L){return v[L.s]-v[D.s]||D.f-L.f});s<i;++s){var F=r[s].s;if(v[F]>e)y+=C-(1<<w-v[F]),v[F]=e;else break}for(y>>=x;y>0;){var R=r[s].s;v[R]<e?y-=1<<e-v[R]++-1:++s}for(;s>=0&&y;--s){var E=r[s].s;v[E]==e&&(--v[E],++y)}w=e}return{t:new ae(v),l:w}},ut=function(t,e,n){return t.s==-1?Math.max(ut(t.l,e,n+1),ut(t.r,e,n+1)):e[t.s]=n},At=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new se(++e),s=0,i=t[0],r=1,o=function(c){n[s++]=c},u=1;u<=e;++u)if(t[u]==i&&u!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(i),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(i);r=1,i=t[u]}return{c:n.subarray(0,s),n:e}},Be=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},Mt=function(t,e,n){var s=n.length,i=Lt(e+2);t[i]=s&255,t[i+1]=s>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<s;++r)t[i+r+4]=n[r];return(i+4+s)*8},Ft=function(t,e,n,s,i,r,o,u,c,l,a){me(e,a++,n),++i[256];for(var d=lt(i,15),p=d.t,v=d.l,w=lt(r,15),y=w.t,x=w.l,C=At(p),F=C.c,R=C.n,E=At(y),N=E.c,D=E.n,L=new se(19),I=0;I<F.length;++I)++L[F[I]&31];for(var I=0;I<N.length;++I)++L[N[I]&31];for(var T=lt(L,7),P=T.t,H=T.l,j=19;j>4&&!P[Rt[j-1]];--j);var z=l+5<<3,_=Be(i,Ie)+Be(r,Je)+o,M=Be(i,p)+Be(r,y)+o+14+3*j+Be(L,P)+2*L[16]+3*L[17]+7*L[18];if(c>=0&&z<=_&&z<=M)return Mt(e,a,t.subarray(c,c+l));var V,G,$,b;if(me(e,a,1+(M<_)),a+=2,M<_){V=Fe(p,v,0),G=p,$=Fe(y,x,0),b=y;var f=Fe(P,H,0);me(e,a,R-257),me(e,a+5,D-1),me(e,a+10,j-4),a+=14;for(var I=0;I<j;++I)me(e,a+3*I,P[Rt[I]]);a+=3*j;for(var h=[F,N],m=0;m<2;++m)for(var g=h[m],I=0;I<g.length;++I){var S=g[I]&31;me(e,a,f[S]),a+=P[S],S>15&&(me(e,a,g[I]>>5&127),a+=g[I]>>12)}}else V=Vn,G=Ie,$=Gn,b=Je;for(var I=0;I<u;++I){var k=s[I];if(k>255){var S=k>>18&31;Pe(e,a,V[S+257]),a+=G[S+257],S>7&&(me(e,a,k>>23&31),a+=rt[S]);var A=k&31;Pe(e,a,$[A]),a+=b[A],A>3&&(Pe(e,a,k>>5&8191),a+=ot[A])}else Pe(e,a,V[k]),a+=G[k]}return Pe(e,a,V[256]),a+G[256]},Xn=new it([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pt=new ae(0),Yn=function(t,e,n,s,i,r){var o=r.z||t.length,u=new ae(s+o+5*(1+Math.ceil(o/7e3))+i),c=u.subarray(s,u.length-i),l=r.l,a=(r.r||0)&7;if(e){a&&(c[0]=r.r>>3);for(var d=Xn[e-1],p=d>>13,v=d&8191,w=(1<<n)-1,y=r.p||new se(32768),x=r.h||new se(w+1),C=Math.ceil(n/3),F=2*C,R=function(ne){return(t[ne]^t[ne+1]<<C^t[ne+2]<<F)&w},E=new it(25e3),N=new se(288),D=new se(32),L=0,I=0,T=r.i||0,P=0,H=r.w||0,j=0;T+2<o;++T){var z=R(T),_=T&32767,M=x[z];if(y[_]=M,x[z]=_,H<=T){var V=o-T;if((L>7e3||P>24576)&&(V>423||!l)){a=Ft(t,c,0,E,N,D,I,P,j,T-j,a),P=L=I=0,j=T;for(var G=0;G<286;++G)N[G]=0;for(var G=0;G<30;++G)D[G]=0}var $=2,b=0,f=v,h=_-M&32767;if(V>2&&z==R(T-h))for(var m=Math.min(p,V)-1,g=Math.min(32767,T),S=Math.min(258,V);h<=g&&--f&&_!=M;){if(t[T+$]==t[T+$-h]){for(var k=0;k<S&&t[T+k]==t[T+k-h];++k);if(k>$){if($=k,b=h,k>m)break;for(var A=Math.min(h,k-2),B=0,G=0;G<A;++G){var W=T-h+G&32767,O=y[W],q=W-O&32767;q>B&&(B=q,M=W)}}}_=M,M=y[_],h+=_-M&32767}if(b){E[P++]=268435456|at[$]<<18|Dt[b];var ee=at[$]&31,oe=Dt[b]&31;I+=rt[ee]+ot[oe],++N[257+ee],++D[oe],H=T+$,++L}else E[P++]=t[T],++N[t[T]]}}for(T=Math.max(T,H);T<o;++T)E[P++]=t[T],++N[t[T]];a=Ft(t,c,l,E,N,D,I,P,j,T-j,a),l||(r.r=a&7|c[a/8|0]<<3,a-=7,r.h=x,r.p=y,r.i=T,r.w=H)}else{for(var T=r.w||0;T<o+l;T+=65535){var te=T+65535;te>=o&&(c[a/8|0]=l,te=o),a=Mt(c,a+1,t.subarray(T,te))}r.i=o}return Kn(u,0,s+Lt(a)+i)},Qn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,s=9;--s;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t}(),Zn=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=Qn[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Bt=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new ae(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return Yn(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,s,i)},Ei=function(t,e){var n={};for(var s in t)n[s]=t[s];for(var s in e)n[s]=e[s];return n},es=function(t,e,n){for(var s=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<s.length;++o){var u=s[o],c=r[o];if(typeof u=="function"){e+=";"+c+"=";var l=u.toString();if(u.prototype)if(l.indexOf("[native code]")!=-1){var a=l.indexOf(" ",8)+1;e+=l.slice(a,l.indexOf("(",a))}else{e+=l;for(var d in u.prototype)e+=";"+c+".prototype."+d+"="+u.prototype[d].toString()}else e+=l}else n[c]=u}return e},ht=[],Ti=function(t){var e=[];for(var n in t)t[n].buffer&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e},Ii=function(t,e,n,s){if(!ht[n]){for(var i="",r={},o=t.length-1,u=0;u<o;++u)i=es(t[u],i,r);ht[n]={c:es(t[o],i,r),e:r}}var c=Ei({},ht[n].e);return wi(ht[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,Ti(c),s)},Ci=function(){return[ae,se,it,rt,ot,Rt,at,Dt,Vn,Ie,Gn,Je,ct,Xn,Pt,Fe,me,Pe,lt,ut,At,Be,Mt,Ft,Lt,Kn,Yn,Bt,Oi,ts]},_i=function(){return[ns,ss,dt,Zn,Qn]},ts=function(t){return postMessage(t,[t.buffer])},Ni=function(t,e,n,s,i,r){var o=Ii(n,s,i,function(u,c){o.terminate(),r(u,c)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},dt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},ns=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&dt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var s=0;s<=n.length;++s)t[s+10]=n.charCodeAt(s)}},ss=function(t){return 10+(t.filename?t.filename.length+1:0)};function Oi(t,e){return Bt(t,e||{},0,0)}function Ri(t,e,n){return n||(n=e,e={}),typeof n!="function"&&Jn(7),Ni(t,e,[Ci,_i,function(){return[is]}],function(s){return ts(is(s.data[0],s.data[1]))},2,n)}function is(t,e){e||(e={});var n=Zn(),s=t.length;n.p(t);var i=Bt(t,e,ss(e),8),r=i.length;return ns(i,e),dt(i,r-8,n.d()),dt(i,r-4,s),i}var Di=typeof TextDecoder<"u"&&new TextDecoder,Li=0;try{Di.decode(Pt,{stream:!0}),Li=1}catch{}class rs{constructor(){this.idx=1,this.backDict={}}getKey(e){let n=!1;return this.backDict[e]||(n=!0,this.backDict[e]=this.idx++),[this.backDict[e],n]}}class Ai{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new rs}sendSetAttribute(e,n,s){if(this.isDictDisabled){const i=[12,e,n,s];return this.app.send(i)}else{const i=[51,e,this.applyDict(n),this.applyDict(s)];return this.app.send(i)}}applyDict(e){const[n,s]=this.dict.getKey(e);return s&&this.app.send([50,n,e]),n}clear(){this.dict=new rs}}class Mi{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Fi(s);if(i.type)return i}},this.durationInt=null}setConditions(e){this.conditions=e}async fetchConditions(e,n){try{const s=await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${e}`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}),{conditions:i}=await s.json(),r=[];i.forEach(o=>{o.filters.forEach(c=>{let l;c.type==="fetch"?(l={type:"network_request",subConditions:[],name:o.name},c.filters.forEach(a=>{const d=this.createConditionFromFilter(a);d&&l.subConditions.push(d)})):l=this.createConditionFromFilter(c),l&&(l.type==="session_duration"&&this.processDuration(l.value[0],o.name),r.push({...l,name:o.name}))})}),this.conditions=r}catch{this.app.debug.error("Critical: cannot fetch start conditions")}}trigger(e){if(!this.hasStarted)try{this.hasStarted=!0,this.app.start(this.startParams,void 0,e)}catch(n){this.app.debug.error(n)}}processMessage(e){if(!this.hasStarted)switch(e[0]){case 78:this.jsExceptionEvent(e);break;case 27:this.customEvent(e);break;case 68:this.clickEvent(e);break;case 122:this.pageLocationEvent(e);break;case 83:this.networkRequest(e);break}}processFlags(e){const n=this.conditions.filter(s=>s.type==="feature_flag");n.length&&n.forEach(s=>{const i=je[s.operator];i&&e.find(r=>i(r.key,s.value))&&this.trigger(s.name)})}processDuration(e,n){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(n)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const n=this.conditions.filter(s=>s.type==="network_request");n.length&&n.forEach(s=>{const i=s.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let u;switch(o.key){case"url":u=e[3];break;case"status":u=e[6];break;case"method":u=e[2];break;case"duration":u=e[8];break}const c=je[o.operator];if(c&&c(u,o.value))return!0})&&this.trigger(s.name):i.length===0&&s.subConditions.length&&this.trigger(s.name)})}customEvent(e){const n=this.conditions.filter(s=>s.type==="custom_event");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[1],s.value)||i(e[2],s.value))&&this.trigger(s.name)})}clickEvent(e){const n=this.conditions.filter(s=>s.type==="click");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[3],s.value)||i(e[4],s.value))&&this.trigger(s.name)})}pageLocationEvent(e){const n=this.conditions.filter(s=>s.type==="visited_url");n&&n.forEach(s=>{const i=je[s.operator];i&&i(e[1],s.value)&&this.trigger(s.name)})}jsExceptionEvent(e){const n=[e[1],e[2],e[3]],s=this.conditions.filter(i=>i.type==="exception");s&&s.forEach(i=>{const r=je[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const je={is:(t,e)=>e.some(n=>t.includes(n)),isAny:()=>!0,isNot:(t,e)=>!e.some(n=>t.includes(n)),contains:(t,e)=>e.some(n=>t.includes(n)),notContains:(t,e)=>!e.some(n=>t.includes(n)),startsWith:(t,e)=>e.some(n=>t.startsWith(n)),endsWith:(t,e)=>e.some(n=>t.endsWith(n)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Fi=t=>{const e={on:"is",notOn:"isNot",">":"greaterThan","<":"lessThan","=":"is","<=":"lessOrEqual",">=":"greaterOrEqual"},n=i=>{if(Object.keys(e).includes(i))return e[i]};let s={type:"",operator:"",value:t.value,key:""};switch(t.type){case"click":s={type:"click",operator:n(t.operator),value:t.value,key:""};break;case"location":s={type:"visited_url",operator:t.operator,value:t.value,key:""};break;case"custom":s={type:"custom_event",operator:t.operator,value:t.value,key:""};break;case"metadata":s={type:t.source==="featureFlag"?"feature_flag":t.type,operator:t.operator,value:t.value,key:""};break;case"error":s={type:"exception",operator:t.operator,value:t.value,key:""};break;case"duration":s={type:"session_duration",value:t.value[0],key:""};break;case"fetchUrl":s={type:"network_request",key:"url",operator:t.operator,value:t.value};break;case"fetchStatusCode":s={type:"network_request",key:"status",operator:n(t.operator),value:t.value};break;case"fetchMethod":s={type:"network_request",key:"method",operator:n(t.operator),value:t.value};break;case"fetchDuration":s={type:"network_request",key:"duration",operator:n(t.operator),value:t.value};break}return s};class Pi{constructor(e){this.app=e,this.flags=[],this.storageKey="__openreplay_flags";const n=this.app.sessionStorage.getItem(this.storageKey);if(n){const s=n.split(";").filter(Boolean);this.flags=s.map(i=>JSON.parse(i))}}getFeatureFlag(e){return this.flags.find(n=>n.key===e)}isFlagEnabled(e){return this.flags.findIndex(n=>n.key===e)!==-1}onFlagsLoad(e){this.onFlagsCb=e}async reloadFlags(e){const n=this.app.sessionStorage.getItem(this.storageKey),s={};n&&n.split(";").filter(Boolean).forEach(a=>{const d=JSON.parse(a);s[d.key]={key:d.key,value:d.value}});const i=this.app.session.getInfo(),r=this.app.session.userInfo,o={projectID:i.projectID,userID:i.userID,metadata:i.metadata,referrer:document.referrer,os:r.userOS,device:r.userDevice,country:r.userCountry,state:r.userState,city:r.userCity,browser:r.userBrowser,persistFlags:s},u=e??this.app.session.getSessionToken(),c=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(o)});if(c.status===200){const l=await c.json();return this.handleFlags(l.flags)}}handleFlags(e){var r;const n=[];e.forEach(o=>{o.is_persist&&n.push(o)});let s="";return this.diffPersist(n).forEach(o=>{s+=`${JSON.stringify(o)};`}),this.app.sessionStorage.setItem(this.storageKey,s),this.flags=e,(r=this.onFlagsCb)==null?void 0:r.call(this,e)}clearPersistFlags(){this.app.sessionStorage.removeItem(this.storageKey)}diffPersist(e){const n=this.app.sessionStorage.getItem(this.storageKey);if(!n)return e;const i=n.split(";").filter(Boolean).map(r=>JSON.parse(r));return e.filter(r=>i.findIndex(o=>o.key===r.key)===-1)}}const os={htmlmasked:"hidden",masked:"obscured"},ve=!(typeof window>"u"),Bi=ve&&navigator.userAgent.match(/firefox|fxios/i),ji=1e5;let jt=ve?Date.now()-performance.now():0;function zt(){jt=Date.now()-performance.now()}function ze(){return jt}const fe=ve&&performance.now?()=>Math.round(performance.now()+jt):()=>Date.now(),Ut="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function as(t){return t.trim().replace(/\s+/g," ")}function cs(t){return t.startsWith("https://")||t.startsWith("http://")}const ft="https://docs.openreplay.com",ls={};function Ce(t,e,n="/"){ls[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${ft}${n} for more information.`),ls[t]=!0)}function Ht(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ce('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Re(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(os[e]&&Ce(`"${n}" attribute`,`"${os[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function zi(t){try{return!!t.contentDocument}catch{return!1}}function us(t){return t.toString(16).padStart(2,"0")}function Ui(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,us).join("")):Array.from({length:t||40},()=>us(Math.floor(Math.random()*16))).join("")}function Hi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function $t(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function hs(t){const e=$t("MutationObserver");return new window[e](t)}function ds(t,e,n,s){const i=$t("addEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}function fs(t,e,n,s){const i=$t("removeEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}class $i{constructor(){this.taskQueue=[],this.isRunning=!1}addTask(e){this.taskQueue.push(e),this.runTasks()}runTasks(){if(this.isRunning||this.taskQueue.length===0)return;this.isRunning=!0;const e=()=>{if(this.taskQueue.length===0){this.isRunning=!1;return}const n=this.taskQueue.shift();Promise.resolve(n()).then(()=>{requestAnimationFrame(()=>e())})};e()}}const Wi=new $i;function qi(t){Wi.addTask(t)}function ps(t,e){const n={...t};for(const s in e)if(e.hasOwnProperty(s)){const i=e[s],r=t[s];typeof i=="object"&&!Array.isArray(i)&&i!==null?n[s]=ps(r||{},i):n[s]=i}return n}function De(t){return[0,t]}function Vi(t,e){return[5,t,e]}function Gi(t,e){return[6,t,e]}function Ki(){return[7]}function Ji(t,e,n,s,i){return[8,t,e,n,s,i]}function Xi(t,e,n){return[9,t,e,n]}function Yi(t,e,n){return[10,t,e,n]}function Qi(t){return[11,t]}function gs(t,e){return[13,t,e]}function Zi(t,e){return[14,t,e]}function er(t,e,n){return[16,t,e,n]}function tr(t,e,n){return[18,t,e,n]}function nr(t,e){return[19,t,e]}function sr(t,e){return[20,t,e]}function ir(t,e){return[22,t,e]}function rr(t,e,n,s,i,r,o,u,c){return[23,t,e,n,s,i,r,o,u,c]}function or(t,e,n){return[24,t,e,n]}function ar(t,e){return[27,t,e]}function cr(t){return[28,t]}function lr(t){return[29,t]}function ms(t,e){return[30,t,e]}function ur(t,e,n,s){return[49,t,e,n,s]}function hr(t,e){return[54,t,e]}function dr(t){return[55,t]}function vs(t,e,n,s){return[57,t,e,n,s]}function bs(t){return[58,t]}function Wt(t,e,n,s){return[60,t,e,n,s]}function fr(t,e,n){return[61,t,e,n]}function pr(t,e){return[63,t,e]}function gr(t,e){return[64,t,e]}function mr(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function qt(t,e){return[70,t,e]}function ys(t,e,n){return[71,t,e,n]}function Vt(t,e,n,s){return[73,t,e,n,s]}function ws(t,e){return[75,t,e]}function Ss(t,e){return[76,t,e]}function vr(t,e){return[77,t,e]}function Gt(t,e,n,s){return[78,t,e,n,s]}function pt(t,e,n,s,i,r,o,u,c){return[83,t,e,n,s,i,r,o,u,c]}function br(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function yr(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function xs(t,e,n){return[113,t,e,n]}function wr(t){return[114,t]}function Sr(t){return[115,t]}function ks(t,e,n,s,i,r,o,u,c,l){return[116,t,e,n,s,i,r,o,u,c,l]}function gt(t){return[117,t]}function Le(t){return[118,t]}function xr(t,e){return[119,t,e]}function kr(t){return[120,t]}function Er(t,e,n,s){return[122,t,e,n,s]}const Kt=ve&&"performance"in window&&"memory"in performance?performance:{memory:{}},Jt=ve?(navigator.deviceMemory||0)*1024:0,Xt=Kt.memory.jsHeapSizeLimit||0;function Tr(t,e){if(!Object.assign({capturePerformance:!0},e).capturePerformance)return;let s,i;const r=()=>{s===void 0||s===-1||(s++,requestAnimationFrame(r))};t.ticker.attach(()=>{i===void 0||i===-1||i++},0,!1);const o=()=>{s===void 0||i===void 0||(t.send(ur(s,i,Kt.memory.totalJSHeapSize||0,Kt.memory.usedJSHeapSize||0)),i=s=document.hidden?-1:0)};t.attachStartCallback(()=>{i=s=-1,o(),r()}),t.attachStopCallback(()=>{i=s=void 0}),t.ticker.attach(o,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1)}const Es="__or__watched_tags__";class Ir{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Es)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const u=o.target.__or_watcher_tagname;u&&this.onTagRendered(u),this.observer.unobserve(o.target)}})})}async fetchTags(e,n){return fetch(`${e}/v1/web/tags`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}).then(s=>s.json()).then(({tags:s})=>{if(s&&s.length){this.setTags(s);const i=JSON.stringify(s);this.sessionStorage.setItem(Es,i||"")}}).catch(s=>this.errLog(s))}setTags(e){this.tags=e,this.intervals={},e.forEach(n=>{this.intervals[n.id]=setInterval(()=>{const s=document.querySelectorAll(n.selector);if(s.length>0){const i=s[0];i.__or_watcher_tagname=n.id,this.observer.observe(i)}},500)})}onTagRendered(e){this.intervals[e]&&clearInterval(this.intervals[e]),this.onTag(e)}clear(){this.tags.forEach(e=>{clearInterval(this.intervals[e.id])}),this.tags=[],this.intervals={},this.observer.disconnect()}}const Cr={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0, 0, 0, 0.40)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'},_r={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},mt={display:"flex","flex-direction":"column",gap:"unset","align-items":"center",padding:"unset",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',"border-radius":"2px",border:"1px solid #D9D9D9",background:"rgba(255, 255, 255, 0.75)",width:"22rem"},Nr={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Or={borderTop:"1px solid rgba(0, 0, 0, 0.06)",borderBottom:"1px solid rgba(0, 0, 0, 0.06)",padding:"1.25rem 0rem",color:"rgba(0, 0, 0, 0.85)",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"400",lineHeight:"auto",whiteSpace:"pre-wrap"},Rr={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",cursor:"pointer"},Ts={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},Ue={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Dr={padding:"0.5rem",gap:"0.5rem",fontFamily:"Verdana, sans-serif",fontSize:"16px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto",color:"white",display:"flex",alignItems:"center",width:"100%",borderRadius:"2px",background:"rgba(0, 0, 0, 0.75)",boxSizing:"border-box"},He={boxSizing:"border-box",display:"block",width:"100%",borderBottom:"1px solid #D9D9D9",background:"#FFF",padding:"0.65rem",alignSelf:"stretch",color:"#000",fontFamily:"Verdana, sans-serif",fontStyle:"normal",fontWeight:"400"},Lr={...He,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Is={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Cs={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",width:"100%",boxSizing:"border-box",cursor:"pointer"},_s={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Ar={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Ns={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Mr={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #D2DFFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",background:"#D2DFFF",fontSize:"13px",height:"24px",width:"24px"},Os={borderRadius:"0.375rem",border:"1px solid rgba(0, 0, 0, 0.06)",background:"#F5F7FF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",padding:"0.625rem 0.9375rem",gap:"0.5rem",alignSelf:"stretch"},Rs={fontWeight:"bold"},Fr={fontSize:"13px",lineHeight:"auto"},Ds={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Pr={...Ds,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Br={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},jr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Ls={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class zr{constructor(e){this.app=e,this.mediaRecorder=null,this.recordedChunks=[],this.stream=null,this.recStartTs=null}async startRecording(e,n,s,i){this.recStartTs=this.app.timestamp();const r=n;try{this.stream=await navigator.mediaDevices.getUserMedia({video:i?{...r,frameRate:{ideal:e}}:!1,audio:s}),this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:"video/webm;codecs=vp9"}),this.recordedChunks=[],this.mediaRecorder.ondataavailable=o=>{o.data.size>0&&this.recordedChunks.push(o.data)},this.mediaRecorder.start()}catch(o){console.error(o)}}async stopRecording(){return new Promise(e=>{this.mediaRecorder&&(this.mediaRecorder.onstop=()=>{const n=new Blob(this.recordedChunks,{type:"video/webm"});e(n)},this.mediaRecorder.stop())})}async sendToAPI(){const e=await this.stopRecording();return fetch(`${this.app.options.ingestPoint}/v1/web/uxt/upload-url`,{headers:{Authorization:`Bearer ${this.app.session.getSessionToken()}`}}).then(n=>{if(n.ok)return n.json();throw new Error("Failed to get upload url")}).then(({url:n})=>fetch(n,{method:"PUT",headers:{"Content-Type":"video/webm"},body:e})).catch(console.error).finally(()=>{this.discard()})}async saveToFile(e="recorded-video.webm"){const n=await this.stopRecording(),s=URL.createObjectURL(n),i=document.createElement("a");i.style.display="none",i.href=s,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(s),document.body.removeChild(i)}discard(){var e,n;(e=this.mediaRecorder)==null||e.stop(),(n=this.stream)==null||n.getTracks().forEach(s=>s.stop())}}function Ur(t,e){e.onmousedown=function(n){const s=t.getBoundingClientRect(),i=n.clientX-s.left,r=n.clientY-s.top;t.style.position="fixed",t.style.zIndex=99999999999999,o(n.pageX,n.pageY);function o(l,a){let d=l-i,p=a-r;d<=5&&(d=5),p<=5&&(p=5),d>=window.innerWidth-s.width&&(d=window.innerWidth-s.width),p>=window.innerHeight-s.height&&(p=window.innerHeight-s.height),t.style.left=`${d}px`,t.style.top=`${p}px`}function u(l){o(l.pageX,l.pageY)}document.addEventListener("mousemove",u);const c=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",c)};document.addEventListener("mouseup",c)},e.ondragstart=function(){return!1}}function Hr(){const t=document.createElement("div");t.className="grid";for(let e=0;e<16;e++){const n=document.createElement("div");Object.assign(n.style,{width:"2px",height:"2px",borderRadius:"10px",background:"white"}),n.className="cell",t.appendChild(n)}return Object.assign(t.style,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(4, 1fr)",gap:"2px",cursor:"grab"}),t}function $r(){const t=document.createElement("div");Object.assign(t.style,{width:"0",height:"0",borderLeft:"7px solid transparent",borderRight:"7px solid transparent",borderBottom:"7px solid white"});const e=document.createElement("div");return e.appendChild(t),Object.assign(e.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",cursor:"pointer",marginLeft:"auto",transform:"rotate(180deg)"}),e}function Wr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }`,document.head.appendChild(t)}function qr(){Wr();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,jr),t}function U(t,e,n,s,i){const r=document.createElement(t);return r.className=e,Object.assign(r.style,n),s&&(r.textContent=s),i&&(r.id=i),r}const vt="or_uxt_test_start",Yt="or_uxt_task_index",Qt="or_uxt_session_id",Vr="or_uxt_test_id";class Gr{constructor(e,n,s,i,r,o,u,c,l){this.ingestPoint=e,this.getTimestamp=n,this.token=s,this.testId=i,this.storageKey=r,this.setStorageKey=o,this.removeStorageKey=u,this.getStorageKey=c,this.getSessionId=l,this.durations={testStart:0,tasks:[]},this.getDurations=()=>this.durations,this.setDurations=d=>{this.durations.testStart=d.testStart,this.durations.tasks=d.tasks},this.signalTask=(d,p,v)=>{if(!d)return console.error("User Testing: No Task ID Given");const w=this.durations.tasks.find(C=>C.taskId===d),y=this.getTimestamp(),x=w?y-w.started:0;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/task`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,taskId:d,status:p,duration:x,timestamp:y,taskAnswer:v})})},this.signalTest=d=>{const p=this.getTimestamp();if(d==="begin"&&this.testId){const y=this.getSessionId();this.setStorageKey(Qt,y),this.setStorageKey(this.storageKey,this.testId.toString()),this.setStorageKey(vt,p.toString())}else this.removeStorageKey(this.storageKey),this.removeStorageKey(Yt),this.removeStorageKey(vt);const v=this.durations.testStart||p,w=p-v;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,status:d,duration:w,timestamp:p})})};const a=this.getStorageKey(vt);a&&(this.durations.testStart=parseInt(a,10))}}class Kr{constructor(e,n){this.app=e,this.storageKey=n,this.bg=U("div","bg",Cr,void 0,"__or_ut_bg"),this.container=U("div","container",_r,void 0,"__or_ut_ct"),this.widgetGuidelinesVisible=!0,this.widgetTasksVisible=!1,this.widgetVisible=!0,this.isActive=!1,this.descriptionSection=null,this.taskSection=null,this.endSection=null,this.stopButton=null,this.stopButtonContainer=null,this.test=null,this.testId=null,this.signalManager=null,this.getTest=(o,u,c)=>{this.testId=o;const l=this.app.options.ingestPoint;return fetch(`${l}/v1/web/uxt/test/${o}`,{headers:{Authorization:`Bearer ${u}`}}).then(a=>a.json()).then(({test:a})=>{this.isActive=!0,this.test=a,this.signalManager=new Gr(this.app.options.ingestPoint,()=>this.app.timestamp(),u,o,this.storageKey,(d,p)=>this.app.localStorage.setItem(d,p),d=>this.app.localStorage.removeItem(d),d=>this.app.localStorage.getItem(d),()=>this.app.getSessionID()),this.createGreeting(a.title,a.reqMic,a.reqCamera),c&&((a.reqMic||a.reqCamera)&&this.userRecorder.startRecording(30,Ls.Standard,a.reqMic,a.reqCamera),this.showWidget(a.description,a.tasks,!0),this.showTaskSection())}).then(()=>o).catch(a=>{console.log("OR: Error fetching test",a)})},this.hideTaskSection=()=>!1,this.showTaskSection=()=>!0,this.collapseWidget=()=>!1,this.removeGreeting=()=>!1,this.toggleDescriptionVisibility=()=>{},this.currentTaskIndex=0,this.userRecorder=new zr(e);const s=this.app.getSessionID(),i=this.app.localStorage.getItem(Qt);s!==i&&(this.app.localStorage.removeItem(this.storageKey),this.app.localStorage.removeItem(Qt),this.app.localStorage.removeItem(Vr),this.app.localStorage.removeItem(Yt),this.app.localStorage.removeItem(vt));const r=this.app.localStorage.getItem(Yt);r&&(this.currentTaskIndex=parseInt(r,10))}getTestId(){return this.testId}createGreeting(e,n,s){const i=U("div","title",Nr,e),r=U("div","description",Or,`Welcome, you're here to help us improve, not to be judged. Your insights matter!
@@ -7,7 +7,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
7
7
  📹 We're recording this browser tab to learn from your experience.
8
8
  🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=U("div","button",Rr,"Read guidelines to begin");this.removeGreeting=()=>((n||s)&&this.userRecorder.startRecording(30,Ls.Standard,n,s),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var c,l,a,d;this.removeGreeting();const u=(c=this.signalManager)==null?void 0:c.getDurations();u&&this.signalManager&&(u.testStart=this.app.timestamp(),this.signalManager.setDurations(u)),(l=this.signalManager)==null||l.signalTest("begin"),this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,mt),this.showWidget(((a=this.test)==null?void 0:a.guidelines)||"",((d=this.test)==null?void 0:d.tasks)||[])},this.container.append(i,r,o),this.bg.appendChild(this.container),document.body.appendChild(this.bg)}showWidget(e,n,s){this.container.innerHTML="",Object.assign(this.bg.style,{position:"fixed",zIndex:99999999999999,right:"8px",left:"unset",width:"fit-content",top:"8px",height:"fit-content",background:"unset",display:"unset",alignItems:"unset",justifyContent:"unset"});const i=this.createTitleSection();this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,mt);const r=this.createDescriptionSection(e),o=this.createTasksSection(n),u=U("div","stop_bn_or",_s,"Abort Session"),c=U("div","stop_ct_or",{fontSize:"13px!important"});c.style.fontSize="13px",c.append(u),this.container.append(i,r,o,c),this.taskSection=o,this.descriptionSection=r,this.stopButton=u,this.stopButtonContainer=c,u.onclick=()=>{var l;this.userRecorder.discard(),(l=this.signalManager)==null||l.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},s?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var u;const e=U("div","title",Dr),n=Hr(),s=U("div","title_text",{maxWidth:"19rem",overflow:"hidden",textOverflow:"ellipsis",width:"100%",fontSize:16,lineHeight:"auto",cursor:"pointer"},(u=this.test)==null?void 0:u.title),i=$r();e.append(n,s,i);const r=c=>(this.widgetVisible=c,this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,this.widgetVisible?mt:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?He:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?He:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?He:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?_s:{display:"none"}),c),o=()=>{Object.assign(i.style,{transform:this.widgetVisible?"rotate(0deg)":"rotate(180deg)"}),r(!this.widgetVisible)};return s.onclick=o,i.onclick=o,Ur(this.bg,n),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const n=U("div","description_section_or",He),s=U("div","description_s_title_or",Ts),i=U("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=U("div","icon",Is,"-"),o=U("div","content",Ue),u=U("div","text_description",{maxHeight:"250px",overflowY:"auto",whiteSpace:"pre-wrap",fontSize:13,color:"#454545",lineHeight:"auto"});u.innerHTML=e;const c=U("div","button_begin_or",Cs,"Begin Test");s.append(i,r),o.append(u,c),n.append(s,o);const l=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?Ue:{display:"none"})};return s.onclick=l,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?Ue:{display:"none"}),o.removeChild(c)},c.onclick=()=>{var a,d,p;if(l(),this.test){const v=(a=this.signalManager)==null?void 0:a.getDurations(),w=v?v.tasks.findIndex(y=>this.test&&y.taskId===this.test.tasks[0].task_id):null;v&&w===-1&&(v.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(d=this.signalManager)==null||d.setDurations(v)),(p=this.signalManager)==null||p.signalTask(this.test.tasks[0].task_id,"begin")}this.showTaskSection(),o.removeChild(c)},n}createTasksSection(e){this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,mt);const n=U("div","task_section_or",He),s=U("div","description_t_title_or",Ts),i=U("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=U("div","icon",Is,"-"),o=U("div","content",Ue),u=U("div","pagination",Ar),c=U("div","taskCard",Os),l=U("div","taskText",Rs),a=U("div","taskDescription",Fr),d=U("div","taskButtons",Br),p=U("div","taskText",Rs);p.textContent="Your answer";const v=U("textarea","taskDescription",{resize:"vertical"}),w=U("div","inputArea",Os);w.append(p,v);const y=U("div","closePanelButton",Ds,"Collapse Panel"),x=U("div","nextButton",Pr,"Done, Next");s.append(i,r),c.append(l,a),d.append(y,x),o.append(u,c,w,d),n.append(s,o);const C=()=>{const E=e[this.currentTaskIndex];l.textContent=E.title,a.textContent=E.description,E.allow_typing?w.style.display="flex":w.style.display="none"};e.forEach((E,N)=>{const D=U("span",`or_task_${N}`,{outline:"1px solid #efefef",fontSize:"13px",height:"24px",width:"24px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em"},(N+1).toString());D.id=`or_task_${N}`,u.append(D)});const F=()=>{this.widgetTasksVisible=!this.widgetTasksVisible,r.textContent=this.widgetTasksVisible?"-":"+",Object.assign(o.style,this.widgetTasksVisible?Ue:{display:"none"})};this.hideTaskSection=()=>(r.textContent="+",Object.assign(o.style,{display:"none"}),this.widgetTasksVisible=!1,!1),this.showTaskSection=()=>(r.textContent="-",Object.assign(o.style,Ue),this.widgetTasksVisible=!0,!0);const R=()=>{const E=document.getElementById(`or_task_${this.currentTaskIndex}`);E&&Object.assign(E.style,Ns);for(let N=0;N<this.currentTaskIndex;N++){const D=document.getElementById(`or_task_${N}`);D&&Object.assign(D.style,Mr)}};return s.onclick=F,y.onclick=this.collapseWidget,x.onclick=()=>{var N,D,L,I;const E=e[this.currentTaskIndex].allow_typing?v.value:void 0;if(v.value="",(N=this.signalManager)==null||N.signalTask(e[this.currentTaskIndex].task_id,"done",E),this.currentTaskIndex<e.length-1){this.currentTaskIndex++,C();const T=(D=this.signalManager)==null?void 0:D.getDurations();T&&T.tasks.findIndex(P=>P.taskId===e[this.currentTaskIndex].task_id)===-1&&(T.tasks.push({taskId:e[this.currentTaskIndex].task_id,started:this.app.timestamp()}),(L=this.signalManager)==null||L.setDurations(T)),(I=this.signalManager)==null||I.signalTask(e[this.currentTaskIndex].task_id,"begin"),R()}else this.showEndSection();this.app.localStorage.setItem("or_uxt_task_index",this.currentTaskIndex.toString())},setTimeout(()=>{const E=document.getElementById("or_task_0");E&&Object.assign(E.style,Ns),C(),R()},1),n}showEndSection(){var u,c,l,a;let e=!0;(u=this.signalManager)==null||u.signalTest("done");const n=U("div","end_section_or",Lr),s=U("div","end_title_or",{fontSize:"1.25rem",fontWeight:"500"},"Thank you! 👍"),i=U("div","end_description_or",{},((c=this.test)==null?void 0:c.conclusion)??`Thank you for participating in our usability test. Your feedback has been captured and will be used to enhance our website.
9
9
 
10
- We appreciate your time and valuable input.`),r=U("div","end_button_or",Cs,"Submitting Feedback"),o=qr();r.appendChild(o),(l=this.test)!=null&&l.reqMic||(a=this.test)!=null&&a.reqCamera?this.userRecorder.sendToAPI().then(()=>{r.removeChild(o),r.textContent="End Session",e=!1}).catch(d=>{console.error(d),r.removeChild(o),r.textContent="End Session",e=!1}):(r.removeChild(o),r.textContent="End Session",e=!1),this.taskSection&&this.container.removeChild(this.taskSection),this.descriptionSection&&this.container.removeChild(this.descriptionSection),this.stopButton&&this.stopButtonContainer&&this.container.removeChild(this.stopButtonContainer),r.onclick=()=>{e||(window.close(),document.body.removeChild(this.bg))},n.append(s,i,r),this.endSection=n,this.container.append(n)}}function As(t){return!!t&&t.nodeType!=null}function Zt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function xe(t){return t.nodeType===Node.ELEMENT_NODE}function Jr(t){return t.nodeType===Node.COMMENT_NODE}function en(t){return t.nodeType===Node.TEXT_NODE}function bt(t){return t.nodeType===Node.DOCUMENT_NODE}function yt(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Q(t,e){return t.localName===e}class Xr{constructor(e,n){this.app=e,this.options=n,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=s=>{const i=this.app.nodes.getID(s);if(!i||!Q(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Q(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(u=>{u.forEach(c=>{c.isIntersecting&&(c.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(c.target,i):this.snapshots[i]&&(this.snapshots[i].paused=!0))})}).observe(s)},this.recordCanvas=(s,i)=>{const r=this.app.timestamp();this.snapshots[i]={images:[],createdAt:r,paused:!1,dummy:document.createElement("canvas")};const o=xr(i.toString(),r);this.app.send(o);const u=l=>{Yr(l,this.options.quality,this.snapshots[i].dummy,this.options.fixedScaling,this.fileExt,a=>{a&&(this.snapshots[i].images.push({id:this.app.timestamp(),data:a}),this.snapshots[i].images.length>9&&(this.sendSnaps(this.snapshots[i].images,i,this.snapshots[i].createdAt),this.snapshots[i].images=[]))})},c=setInterval(()=>{const l=this.app.nodes.getID(s),a=l?this.app.nodes.getNode(l):void 0;!a||!Q(a,"canvas")||a!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(c)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{u(a)}):u(a))},this.interval);this.intervals.push(c)},this.fileExt=n.fileExt??"webp",this.interval=1e3/n.fps}startTracking(){setTimeout(()=>{this.app.nodes.scanTree(this.captureCanvas),this.app.nodes.attachNodeCallback(e=>{this.captureCanvas(e)})},500)}sendSnaps(e,n,s){if(Object.keys(this.snapshots).length===0)return;const i=new FormData;e.forEach(r=>{const o=r.data;o&&(i.append("snapshot",o,`${s}_${n}_${r.id}.${this.fileExt}`),this.options.isDebug&&Qr(o,`${s}_${n}_${r.id}.${this.fileExt}`))}),fetch(this.app.options.ingestPoint+"/v1/web/images",{method:"POST",headers:{Authorization:`Bearer ${this.app.session.getSessionToken()??""}`},body:i}).then(()=>!0).catch(r=>{this.app.debug.error("error saving canvas",r)})}clear(){this.intervals.forEach(e=>clearInterval(e)),this.snapshots={}}}const Ms={low:.35,medium:.55,high:.8};function Yr(t,e="medium",n,s=!1,i,r){const o=`image/${i}`;if(s){const u=window.devicePixelRatio||1;n.width=t.width/u,n.height=t.height/u;const c=n.getContext("2d");if(!c)return"";c.clearRect(0,0,n.width,n.height),c.drawImage(t,0,0,n.width,n.height),n.toBlob(r,o,Ms[e])}else t.toBlob(r,o,Ms[e])}function Qr(t,e){const n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=e,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const Xe={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class Zr{constructor(e=Xe.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Xe.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Xe.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Xe.Errors)&&console.error(...n)},this.level=e}}class eo{constructor(e){this.node_id=e,this.nodes=[],this.totalNodeAmount=0,this.nodeCallbacks=[],this.elementListeners=new Map,this.nextNodeId=0,this.scanTree=n=>{this.nodes.forEach(s=>n(s))}}syntheticMode(e){const i=99999999*e;if(i>9007199254740900)throw new Error("Placeholder id overflow");this.nextNodeId=i}attachNodeCallback(e){this.nodeCallbacks.push(e)}attachNodeListener(e,n,s,i=!0){const r=this.getID(e);if(r===void 0)return;ds(e,n,s,i);let o=this.elementListeners.get(r);o===void 0&&(o=[],this.elementListeners.set(r,o)),o.push([n,s,i])}registerNode(e){let n=e[this.node_id];const s=n===void 0;return s&&(n=this.nextNodeId,this.totalNodeAmount++,this.nextNodeId++,this.nodes[n]=e,e[this.node_id]=n),[n,s]}unregisterNode(e){const n=e[this.node_id];if(n!==void 0){e[this.node_id]=void 0,delete e[this.node_id],delete this.nodes[n];const s=this.elementListeners.get(n);s!==void 0&&(this.elementListeners.delete(n),s.forEach(i=>fs(e,i[0],i[1],i[2]))),this.totalNodeAmount--}return n}cleanTree(){for(let e=0;e<this.nodes.length;e++){const n=this.nodes[e];n&&!document.contains(n)&&this.unregisterNode(n)}}callNodeCallbacks(e,n){this.nodeCallbacks.forEach(s=>s(e,n))}getID(e){if(e)return e[this.node_id]}getNode(e){return this.nodes[e]}getNodeCount(){return this.totalNodeAmount}clear(){for(let e=0;e<this.nodes.length;e++){const n=this.nodes[e];n&&this.unregisterNode(n)}this.nextNodeId=0,this.nodes.length=0}}function tn(t){if(Jr(t))return!0;if(en(t))return!1;if(!xe(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const n=t.getAttribute("rel"),s=t.getAttribute("as");return!(n!=null&&n.includes("stylesheet")||s==="style"||s==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function nn(t){return yt(t)?!0:!tn(t)}var ve;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(ve||(ve={}));class sn{constructor(e,n=!1){this.app=e,this.isTopContext=n,this.commited=[],this.recents=new Map,this.indexes=[],this.attributesMap=new Map,this.textSet=new Set,this.observer=hs(this.app.safe(s=>{for(const i of s){const r=i.target,o=i.type;if(!nn(r))continue;if(o==="childList"){for(let c=0;c<i.removedNodes.length;c++)nn(i.removedNodes[c])&&this.bindNode(i.removedNodes[c]);for(let c=0;c<i.addedNodes.length;c++)this.bindTree(i.addedNodes[c]);continue}const u=this.app.nodes.getID(r);if(u!==void 0){if(this.recents.has(u)||this.recents.set(u,ve.Changed),o==="attributes"){const c=i.attributeName;if(c===null)continue;let l=this.attributesMap.get(u);l===void 0&&this.attributesMap.set(u,l=new Set),l.add(c);continue}if(o==="characterData"){this.textSet.add(u);continue}}}this.commitNodes()}))}clear(){this.commited.length=0,this.recents.clear(),this.indexes.length=1,this.attributesMap.clear(),this.textSet.clear()}sendNodeAttribute(e,n,s,i){if(Zt(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(gs(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Wt(e,s,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,s,i);return}if(!(s==="src"||s==="srcset"||s==="integrity"||s==="crossorigin"||s==="autocomplete"||s.substr(0,2)==="on")&&!(s==="value"&&Q(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(gs(e,s));return}if(s==="style"||s==="href"&&Q(n,"link")){this.app.send(Wt(e,s,i,this.app.getBaseHref()));return}(s==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,s,i)}}sendNodeData(e,n,s){if(Q(n,"style")){this.app.send(fr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(Zi(e,s))}bindNode(e){const[n,s]=this.app.nodes.registerNode(e);s?this.recents.set(n,ve.New):this.recents.get(n)!==ve.New&&this.recents.set(n,ve.Removed)}bindTree(e){if(!nn(e))return;this.bindNode(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:s=>(this.app.nodes.getID(s)!==void 0&&this.app.debug.error("! Node is already bound",s),tn(s)||this.app.nodes.getID(s)!==void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT)},!1);for(;n.nextNode();)this.bindNode(n.currentNode)}unbindTree(e){const n=this.app.nodes.unregisterNode(e);if(n!==void 0&&this.recents.get(n)===ve.Removed){this.app.send(Qi(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:u=>tn(u)||this.app.nodes.getID(u)===void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},!1);let i=0;const r=this.app.nodes.getNodeCount();for(;s.nextNode();)i+=1,this.app.nodes.unregisterNode(s.currentNode);const o=Math.floor(i/r*100);o>30&&this.app.send(Sr(o))}}_commitNode(e,n){if(yt(n))return!0;const s=n.parentNode;let i;if(!Q(n,"html")||!this.isTopContext){if(s===null)return this.unbindTree(n),!1;if(i=this.app.nodes.getID(s),i===void 0)return this.unbindTree(n),!1;if(!this.commitNode(i))return this.unbindTree(n),!1;if(this.app.sanitizer.handleNode(e,i,n),this.app.sanitizer.isHidden(i))return!1}let r=n.previousSibling;for(;r!==null;){const a=this.app.nodes.getID(r);if(a!==void 0){this.commitNode(a),this.indexes[e]=this.indexes[a]+1;break}r=r.previousSibling}r===null&&(this.indexes[e]=0);const o=this.recents.get(e),u=o===ve.New,c=this.indexes[e];if(c===void 0)throw"commitNode: missing node index";if(u){if(xe(n)){let a=n;if(i!==void 0){if(this.app.sanitizer.isHidden(e)){const d=a.clientWidth,p=a.clientHeight;a=n.cloneNode(),a.style.width=`${d}px`,a.style.height=`${p}px`}this.app.send(Ji(e,i,c,a.tagName,Zt(n)))}for(let d=0;d<a.attributes.length;d++){const p=a.attributes[d];this.sendNodeAttribute(e,a,p.nodeName,p.value)}}else en(n)&&(this.app.send(Xi(e,i,c)),this.sendNodeData(e,s,n.data));return!0}o===ve.Removed&&i!==void 0&&this.app.send(Yi(e,i,c));const l=this.attributesMap.get(e);if(l!==void 0){if(!xe(n))throw"commitNode: node is not an element";for(const a of l)this.sendNodeAttribute(e,n,a,n.getAttribute(a))}if(this.textSet.has(e)){if(!en(n))throw"commitNode: node is not a text";this.sendNodeData(e,s,n.data)}return!0}commitNode(e){const n=this.app.nodes.getNode(e);if(n===void 0)return!1;const s=this.commited[e];return s!==void 0?s:this.commited[e]=this._commitNode(e,n)}commitNodes(e=!1){let n;this.recents.forEach((s,i)=>{this.commitNode(i),s===ve.New&&(n=this.app.nodes.getNode(i))&&this.app.nodes.callNodeCallbacks(n,e)}),this.clear()}observeRoot(e,n,s=e){this.observer.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1}),this.bindTree(s),n(this.app.nodes.getID(e)),this.commitNodes(!0)}disconnect(){this.observer.disconnect(),this.clear()}}class Fs extends sn{observe(e){const n=e.contentDocument,s=this.app.nodes.getID(e);!n||s===void 0||this.observeRoot(n,i=>{if(i===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(qt(s,i))})}syntheticObserve(e,n){this.observeRoot(n,s=>{if(s===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(qt(e,s))})}}class to extends sn{observe(e){const n=e.shadowRoot,s=this.app.nodes.getID(e);!n||s===void 0||this.observeRoot(n,i=>{if(i===void 0){this.app.debug.error("OpenReplay: Shadow Root was not bound");return}this.app.send(qt(s,i))})}}class no{constructor(){this.states=new Map}calcOffset(e){let n=0,s=0;if(e.parent&&([n,s]=this.calcOffset(e.parent)),!e.offset){const{left:o,top:u}=e.iFrame.getBoundingClientRect();e.offset=[o,u]}const[i,r]=e.offset;return[n+i,s+r]}getDocumentOffset(e){const n=this.states.get(e);return n?this.calcOffset(n):[0,0]}observe(e){var u;const n=e.contentDocument;if(!n)return;const s=e.ownerDocument,i=this.states.get(s),r={offset:null,iFrame:e,parent:i||null,clear:()=>{var c;s.removeEventListener("scroll",o),(c=s.defaultView)==null||c.removeEventListener("resize",o)}},o=()=>{r.offset=null};s.addEventListener("scroll",o),(u=s.defaultView)==null||u.addEventListener("resize",o),this.states.set(n,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const rn=me?Element.prototype.attachShadow:()=>new ShadowRoot;class so extends sn{constructor(e,n){super(e,!0),this.iframeOffsets=new no,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Q(s,"iframe")&&(this.options.captureIFrames&&!Re(s,"obscured")||Re(s,"capture"))&&this.handleIframe(s)}),this.app.nodes.attachNodeCallback(s=>{xe(s)&&s.shadowRoot!==null&&this.handleShadowRoot(s.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let n=null;const s=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!zi(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==n){const u=new Fs(this.app);this.iframeObservers.push(u),u.observe(e),n=o,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(u=>u(r)))},100));e.addEventListener("load",s),s()}handleShadowRoot(e){const n=new to(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=rn.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(Ki()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=rn.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new Fs(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=rn,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var wt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(wt||(wt={}));const io=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class ro{constructor(e,n){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},n)}handleNode(e,n,s){if((this.obscured.has(n)||xe(s)&&(Re(s,"masked")||Re(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||xe(s)&&(Re(s,"htmlmasked")||Re(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&xe(s)){const i=this.options.domSanitizer(s);i===wt.Obscured&&this.obscured.add(e),i===wt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?io(n):(this.options.obscureTextNumbers&&(n=n.replace(/\d/g,"0")),this.options.obscureTextEmails&&(n=n.replace(/^\w+([+.-]\w+)*@\w+([.-]\w+)*\.\w{2,3}$/g,s=>{const[i,r]=s.split("@"),[o,u]=r.split(".");return`${Ut(i)}@${Ut(o)}.${Ut(u)}`})),n)}isObscured(e){return this.obscured.has(e)}isHidden(e){return this.hidden.has(e)}getInnerTextSecure(e){const n=this.app.nodes.getID(e);return n?this.sanitize(n,e.innerText):""}clear(){this.obscured.clear(),this.hidden.clear()}}class oo{constructor(e,n){this.app=e,this.options=n,this.metadata={},this.userID=null,this.callbacks=[],this.timestamp=0,this.createTabId()}attachUpdateCallback(e){this.callbacks.push(e)}handleUpdate(e){e.userID==null&&delete e.userID,e.sessionID==null&&delete e.sessionID,this.callbacks.forEach(n=>n(e))}assign(e){e.userID!==void 0&&(this.userID=e.userID),e.metadata!==void 0&&Object.entries(e.metadata).forEach(([n,s])=>this.metadata[n]=s),e.sessionID!==void 0&&(this.sessionID=e.sessionID),e.timestamp!==void 0&&(this.timestamp=e.timestamp),e.projectID!==void 0&&(this.projectID=e.projectID),this.handleUpdate(e)}setMetadata(e,n){this.metadata[e]=n,this.handleUpdate({metadata:{[e]:n}})}setUserID(e){this.userID=e,this.handleUpdate({userID:e})}setUserInfo(e){this.userInfo=e}getPageNumber(){const e=this.app.sessionStorage.getItem(this.options.session_pageno_key);if(e!=null)return parseInt(e)}incPageNo(){let e=this.getPageNumber();return e===void 0?e=0:e++,this.app.sessionStorage.setItem(this.options.session_pageno_key,e.toString()),e}getSessionToken(){return this.app.sessionStorage.getItem(this.options.session_token_key)||void 0}setSessionToken(e){this.app.sessionStorage.setItem(this.options.session_token_key,e)}applySessionHash(e){const n=decodeURI(e).split("&");let s=e,i="100500";n.length==2&&([i,s]=n),!(!i||!s)&&(this.app.sessionStorage.setItem(this.options.session_token_key,s),this.app.sessionStorage.setItem(this.options.session_pageno_key,i))}getSessionHash(){const e=this.getPageNumber(),n=this.getSessionToken();if(!(e===void 0||n===void 0))return encodeURI(String(e)+"&"+n)}getTabId(){return this.tabId||this.createTabId(),this.tabId}regenerateTabId(){const e=Ui(12);this.app.sessionStorage.setItem(this.options.session_tabid_key,e),this.tabId=e}createTabId(){const e=this.app.sessionStorage.getItem(this.options.session_tabid_key);e?this.tabId=e:this.regenerateTabId()}getInfo(){return{sessionID:this.sessionID,metadata:this.metadata,userID:this.userID,timestamp:this.timestamp,projectID:this.projectID}}reset(){this.app.sessionStorage.removeItem(this.options.session_token_key),this.metadata={},this.userID=null,this.sessionID=void 0,this.timestamp=0}}function ao(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class co{constructor(e){this.app=e,this.timer=null,this.callbacks=[]}attach(e,n=0,s=!0,i){i&&(e=e.bind(i)),s&&(e=this.app.safe(e)),this.callbacks.unshift(n?ao(e,n):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ye="canceled",Ps="or_uxt_active",on="or_buffer_1",_e=t=>({reason:t,success:!1}),lo=t=>({...t,success:!0});var Z;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Z||(Z={}));const Bs="https://api.openreplay.com/ingest";function an(){const t=new Date().getTimezoneOffset()*-1,e=t>=0?"+":"-",n=Math.floor(Math.abs(t)/60),s=Math.abs(t)%60;return`UTC${e}${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}const uo=t=>new Promise(e=>setTimeout(e,t)),ce={ask:"never-gonna-give-you-up",resp:"never-gonna-let-you-down",reg:"never-gonna-run-around-and-desert-you",iframeSignal:"never-gonna-make-you-cry",iframeId:"never-gonna-say-goodbye",iframeBatch:"never-gonna-tell-a-lie-and-hurt-you"};let ho=class{constructor(e,n,s,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=Z.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var c;(c=this.canvasRecorder)==null||c.restartTracking()},this.flushBuffer=async c=>new Promise(l=>{let a=!1;const d=[c.shift()];for(;!a;){const p=c[0];!p||p[0]===0?a=!0:d.push(c.shift())}this.postToWorker(d),l(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(s).findIndex(c=>["fixedCanvasScaling","disableCanvas"].includes(c))!==-1&&(console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.'),s={...s,canvas:{__save_canvas_locally:s.__save_canvas_locally,fixedCanvasScaling:s.fixedCanvasScaling,disableCanvas:s.disableCanvas}}),this.networkOptions=s.network;const o={revID:"",node_id:"__openreplay_id",session_token_key:"__openreplay_token",session_pageno_key:"__openreplay_pageno",session_reset_key:"__openreplay_reset",session_tabid_key:"__openreplay_tabid",local_uuid_key:"__openreplay_uuid",ingestPoint:Bs,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Xe.Silent,__save_canvas_locally:!1,localStorage:null,sessionStorage:null,disableStringDict:!1,forceSingleTab:!1,assistSocketHost:"",fixedCanvasScaling:!1,disableCanvas:!1,captureIFrames:!0,obscureTextEmails:!0,obscureTextNumbers:!1,crossdomain:{parentDomain:"*"},canvas:{disableCanvas:!1,fixedCanvasScaling:!1,__save_canvas_locally:!1,useAnimationFrame:!1}};if(this.options=ps(o,s),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const c=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${c}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new ro(this,s),this.nodes=new eo(this.options.node_id),this.observer=new so(this,s),this.ticker=new co(this),this.ticker.attach(()=>this.commit()),this.debug=new Zr(this.options.__debug__),this.session=new oo(this,this.options),this.attributeSender=new Ai(this,!!this.options.disableStringDict),this.featureFlags=new Pi(this),this.tagWatcher=new Ir(this.sessionStorage,this.debug.error,c=>{this.send(kr(c))}),this.session.attachUpdateCallback(({userID:c,metadata:l})=>{c!=null&&this.send(cr(c)),l!=null&&Object.entries(l).forEach(([a,d])=>this.send(ms(a,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const u=this.session.getTabId();if(this.insideIframe){const c=a=>{const{data:d}=a;d.line===ce.iframeId&&(this.rootId=d.id,this.session.setSessionToken(d.token),this.frameOderNumber=d.frameOrderNumber,this.debug.log("starting iframe tracking",d),this.allowAppStart())};window.addEventListener("message",c),this.attachStopCallback(()=>{window.removeEventListener("message",c)});const l=this.initialHostName;window.parent.postMessage({line:ce.iframeSignal,source:u,context:this.contextId,domain:l},"*")}else{let c=0;const l=a=>{const{data:d}=a;if(d.line===ce.iframeSignal){const p=d.domain,v=Array.from(document.querySelectorAll("iframe"));this.pageFrames=v,(async()=>{let y=0;for(;y<10;){const x=this.checkNodeId(v,p);if(x){this.waitStarted().then(()=>{var R;c++;const C=this.session.getSessionToken(),F={line:ce.iframeId,context:this.contextId,domain:p,id:x,token:C,frameOrderNumber:c};this.debug.log("iframe_data",F),(R=a.source)==null||R.postMessage(F,"*")}).catch(console.error),y=10;break}y++,await uo(100)}})()}if(d.line===ce.iframeBatch){const v=d.messages.map(w=>{if(w[0]===20){let y=w;return this.pageFrames.forEach(x=>{if(x.dataset.domain===a.data.domain){const[C,F,R]=w,{left:E,top:N}=x.getBoundingClientRect();y=[C,F+E,R+N]}}),y}if(w[0]===68){let y=w;return this.pageFrames.forEach(x=>{if(x.dataset.domain===a.data.domain){const[C,F,R,E,N,D,L]=w,{left:I,top:T,width:P,height:H}=x.getBoundingClientRect(),j=document.documentElement.scrollWidth,z=document.documentElement.scrollHeight,_=D/100*P+I,M=L/100*H+T,V=_/j,G=M/z;y=[C,F,R,E,N,Math.round(V*1e3)/10,Math.round(G*1e3)/10]}}),y}return w});this.messages.push(...v)}};window.addEventListener("message",l),this.attachStopCallback(()=>{window.removeEventListener("message",l)})}this.bc!==null&&(this.bc.postMessage({line:ce.ask,source:u,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=c=>{if(c.data.context!==this.contextId){if(c.data.line===ce.resp){const l=c.data.token;this.session.setSessionToken(l),this.allowAppStart()}if(c.data.line===ce.reg){const l=c.data.token;this.session.regenerateTabId(),this.session.setSessionToken(l),this.allowAppStart()}if(c.data.line===ce.ask){const l=this.session.getSessionToken();l&&this.bc&&this.bc.postMessage({line:c.data.source===u?ce.reg:ce.resp,token:l,source:u,context:this.contextId})}}})}allowAppStart(){this.canStart=!0,this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}checkNodeId(e,n){for(const s of e)if(s.dataset.domain===n)return s[this.options.node_id];return null}initWorker(){try{this.worker=new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){const e=i?.toString().replace(/^([^_]+)_([^_]+).*/,"$1_$2_$3");this.busy=!0;const n={Authorization:`Bearer ${this.token}`};s&&(n["Content-Encoding"]="gzip"),null!==this.token?fetch(`${this.ingestURL}?batch=${this.pageNo??"noPageNum"}_${e??"noBatchNum"}`,{body:t,method:"POST",headers:n,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${i??"noBatchNum"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn("OpenReplay:",e),this.retry(t,s,`${i??"noBatchNum"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${i??"noBatchNum"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if("q_end"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==l&&(clearInterval(l),l=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function g(){u!==h.Stopped&&(postMessage("a_stop"),c().then((()=>{postMessage("a_start")})))}let p,l=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),void c().then((()=>{u=h.Stopped}));if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Compressed batch."),void g();s.batch&&r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Uncompressed batch."),void g();s.batch&&r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:"queue_empty"}))),null===l&&(l=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("OR WebWorker: writer not initialised. Received auth."),void g()):(console.debug("OR WebWorker: sender not initialised. Received auth."),void g()):void 0}if(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?p=setTimeout((()=>g()),18e5):clearTimeout(p)),t.writeMessage(s)}))}else postMessage("not_init"),g()}else o()}else o()};'],{type:"text/javascript"}))),this.worker.onerror=n=>{this._debug("webworker_error",n)},this.worker.onmessage=({data:n})=>{this.handleWorkerMsg(n)};const e=()=>{this.worker&&this.worker.postMessage(null)};this.attachEventListener(window,"beforeunload",e,!1),this.attachEventListener(document.body,"mouseleave",e,!1,!1),this.attachEventListener(document,"visibilitychange",e,!1)}catch(e){this._debug("worker_start",e)}}handleWorkerMsg(e){var n;if(e==="a_stop")this.stop(!1);else if(e==="a_start")this.start({},!0);else if(e==="not_init")this.debug.warn("OR WebWorker: writer not initialised. Restarting tracker");else if(e.type==="failure")this.stop(!1),this.debug.error("worker_failed",e.reason),this._debug("worker_failed",e.reason);else if(e.type==="compress"){const s=e.batch;s.byteLength>this.compressionThreshold?Ri(e.batch,{mtime:0},(r,o)=>{var u,c;r?(this.debug.error("Openreplay compression error:",r),(u=this.worker)==null||u.postMessage({type:"uncompressed",batch:s})):(c=this.worker)==null||c.postMessage({type:"compressed",batch:o})}):(n=this.worker)==null||n.postMessage({type:"uncompressed",batch:s})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,n){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${n}`})}),this.debug.error("OpenReplay error: ",e,n)}send(e,n=!1){var s;this.activityState!==Z.NotActive&&(this.activityState===Z.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Z.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(Le(this.session.getTabId())),this.messages.unshift(De(this.timestamp())),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}if(!(this.worker===void 0||!this.messages.length)){if(this.insideIframe){window.parent.postMessage({line:ce.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{qi(()=>{var e;this.messages.unshift(Le(this.session.getTabId())),this.messages.unshift(De(this.timestamp())),(e=this.worker)==null||e.postMessage(this.messages),this.commitCallbacks.forEach(n=>n(this.messages)),this.messages.length=0})}catch(e){this._debug("worker_commit",e),this.stop(!0),setTimeout(()=>{this.start()},500)}}}_cStartCommit(){this.coldStartCommitN+=1,this.coldStartCommitN===2&&(this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId())),this.bufferedMessages2.push(De(this.timestamp())),this.bufferedMessages2.push(Le(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Z.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var n;(n=this.worker)==null||n.postMessage(e),this.commitCallbacks.forEach(s=>s(e)),e.length=0}timestamp(){return fe()+this.delay}safe(e){const n=this;return function(...s){try{e.apply(this,s)}catch(i){n._debug("safe_fn_call",i)}}}attachCommitCallback(e){this.commitCallbacks.push(e)}attachStartCallback(e,n=!1){n&&(e=this.safe(e)),this.startCallbacks.push(e)}attachStopCallback(e,n=!1){n&&(e=this.safe(e)),this.stopCallbacks.push(e)}attachEventListener(e,n,s,i=!0,r=!0){i&&(s=this.safe(s));const o=()=>e?ds(e,n,s,r):null,u=()=>e?fs(e,n,s,r):null;this.attachStartCallback(o,i),this.attachStopCallback(u,i)}checkRequiredVersion(e){const n=e.split(/[.-]/),s=this.version.split(/[.-]/);for(let i=0;i<3;i++){if(isNaN(Number(s[i]))||isNaN(Number(n[i])))return!1;if(Number(s[i])>Number(n[i]))return!0;if(Number(s[i])<Number(n[i]))return!1}return!0}getTrackerInfo(){return{userUUID:this.localStorage.getItem(this.options.local_uuid_key),projectKey:this.projectKey,revID:this.revID,trackerVersion:this.version,isSnippet:this.options.__is_snippet}}getSessionInfo(){return{...this.session.getInfo(),...this.getTrackerInfo()}}getSessionToken(){return this.session.getSessionToken()}getSessionID(){return this.session.getInfo().sessionID||void 0}getSessionURL(e){const{projectID:n,sessionID:s,timestamp:i}=this.session.getInfo();if(!n||!s){this.debug.error("OpenReplay error: Unable to build session URL");return}const r=this.options.ingestPoint,c=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${n}/session/${s}`);if(e!=null&&e.withCurrentTime){const l=fe()-i;return`${c}?jumpto=${l}`}return c}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,n;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((n=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:n.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const n=new URL(this.getBaseHref());return n.pathname+="/"+new URL(e).pathname,n.pathname.replace(/\/+/g,"/"),n.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===Z.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const n=this.sessionStorage.getItem(this.options.session_reset_key)!==null,s=e||n,i=this.session.getSessionToken();return s||!i}async coldStart(e={},n){this.singleBuffer=!1;const s=1e3,i=this.checkSessionToken(e.forceNew);n&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,zt(),this.coldStartTs=fe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(De(this.timestamp())),this.bufferedMessages2.push(Le(this.session.getTabId()))),this.stop(!1),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(gt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,v;this.conditionsManager=new Mi(this,e);const n=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:fe(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l,projectID:a}=await n.json();this.session.assign({projectID:a}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l});const d={sessionToken:s,userUUID:"",sessionID:""};this.startCallbacks.forEach(w=>w(d)),await((p=this.conditionsManager)==null?void 0:p.fetchConditions(a,s)),await this.featureFlags.reloadFlags(s),await this.tagWatcher.fetchTags(this.options.ingestPoint,s),(v=this.conditionsManager)==null||v.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);zt(),this.coldStartTs=fe();const i=this.localStorage.getItem(on);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(on)}this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId())),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),s||this.send(gt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(on,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,v;this.stop(!1);const e=fe();(p=this.worker)==null||p.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:this.coldStartTs,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const n=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:e,doNotRecord:!1,bufferDiff:e-this.coldStartTs,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an()})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l,beaconSizeLimit:a,projectID:d}=await n.json();for((v=this.worker)==null||v.postMessage({type:"auth",token:s,beaconSizeLimit:a}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},n=!1,s){const i=this.activityState===Z.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const c="No worker found: perhaps, CSP is not set.";return this.signalError(c,[]),Promise.resolve(_e(c))}if(this.activityState===Z.Active||this.activityState===Z.Starting)return Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Z.Starting,i||zt(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=fe();this.worker.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:i?this.coldStartTs:r,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const o=this.session.getSessionToken(),u=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",u,"session token: ",o);try{const c=await window.fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:r,doNotRecord:!1,bufferDiff:r-this.coldStartTs,userID:this.session.getInfo().userID,token:u?void 0:o,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(c.status!==200){const _=await c.text(),M=_===Ye?Ye:`Server error: ${c.status}. ${_}`;return _e(M)}if(!this.worker){const _="no worker found after start request (this should not happen in real world)";return this.signalError(_,[]),_e(_)}const{token:l,userUUID:a,projectID:d,beaconSizeLimit:p,compressionThreshold:v,delay:w,sessionID:y,startTimestamp:x,userBrowser:C,userCity:F,userCountry:R,userDevice:E,userOS:N,userState:D,canvasEnabled:L,canvasQuality:I,canvasFPS:T,assistOnly:P}=await c.json();if(typeof l!="string"||typeof a!="string"||typeof x!="number"&&typeof x<"u"||typeof y!="string"||typeof w!="number"||typeof p!="number"&&typeof p<"u"){const _=`Incorrect server response: ${JSON.stringify(c)}`;return this.signalError(_,[]),_e(_)}this.delay=w,this.session.setSessionToken(l),this.session.setUserInfo({userBrowser:C,userCity:F,userCountry:R,userDevice:E,userOS:N,userState:D}),this.session.assign({sessionID:y,timestamp:x||r,projectID:d}),P?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:l,beaconSizeLimit:p}),!u&&l===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(gt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([_,M])=>this.send(ms(_,M))),this.localStorage.setItem(this.options.local_uuid_key,a),this.compressionThreshold=v;const H={sessionToken:l,userUUID:a,sessionID:y};if(this.startCallbacks.forEach(_=>_(H)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,l),this.activityState=Z.Active,L&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new Xr(this,{fps:T,quality:I,isDebug:this.options.canvas.__save_canvas_locally,fixedScaling:this.options.canvas.fixedCanvasScaling,useAnimationFrame:this.options.canvas.useAnimationFrame}),this.canvasRecorder.startTracking()),i){const _=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;_.length>0;)await this.flushBuffer(_);this.clearBuffers(),this.commit()}else this.insideIframe&&this.rootId?this.observer.crossdomainObserve(this.rootId,this.frameOderNumber):this.observer.observe(),this.ticker.start();this.uxtManager=this.uxtManager?this.uxtManager:new Kr(this,Ps);let j;const z=this.localStorage.getItem(Ps);if(z&&(j=parseInt(z,10)),location!=null&&location.search){const _=new URLSearchParams(location.search);if(_.has("oruxt")){const M=_.get("oruxt");j=M?parseInt(M,10):void 0}}return j&&(this.uxtManager.isActive?this.onUxtCb.forEach(_=>_(j)):this.uxtManager.getTest(j,l,!!z).then(_=>{_&&this.onUxtCb.forEach(M=>M(_))})),lo(H)}catch(c){if(this.stop(),this.session.reset(),c===Ye)return this.signalError(Ye,[]),_e(Ye);this._debug("session_start",c);const l=c instanceof Error?c.message:c.toString();return this.signalError(l,[]),_e(l)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const n=()=>{this.canStart?e(!0):setTimeout(n,25)};n()})}async waitStarted(){return new Promise(e=>{const n=()=>{this.activityState===Z.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Z.Active||this.activityState===Z.Starting?Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(n=>{const s=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",s),n(this._start(...e)))};document.addEventListener("visibilitychange",s)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const n=e;return(s,i,r="down")=>{typeof s!="string"||typeof i!="string"||i.length>5*1024*1024||s.length>255||this.send(br("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Z.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(s=>s()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(n=this.canvasRecorder)==null||n.clear()}finally{this.activityState=Z.NotActive}}};function fo(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(hr(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const js=me&&"InstallTrigger"in window?t=>t.message+`
10
+ We appreciate your time and valuable input.`),r=U("div","end_button_or",Cs,"Submitting Feedback"),o=qr();r.appendChild(o),(l=this.test)!=null&&l.reqMic||(a=this.test)!=null&&a.reqCamera?this.userRecorder.sendToAPI().then(()=>{r.removeChild(o),r.textContent="End Session",e=!1}).catch(d=>{console.error(d),r.removeChild(o),r.textContent="End Session",e=!1}):(r.removeChild(o),r.textContent="End Session",e=!1),this.taskSection&&this.container.removeChild(this.taskSection),this.descriptionSection&&this.container.removeChild(this.descriptionSection),this.stopButton&&this.stopButtonContainer&&this.container.removeChild(this.stopButtonContainer),r.onclick=()=>{e||(window.close(),document.body.removeChild(this.bg))},n.append(s,i,r),this.endSection=n,this.container.append(n)}}function As(t){return!!t&&t.nodeType!=null}function Zt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function ke(t){return t.nodeType===Node.ELEMENT_NODE}function Jr(t){return t.nodeType===Node.COMMENT_NODE}function en(t){return t.nodeType===Node.TEXT_NODE}function bt(t){return t.nodeType===Node.DOCUMENT_NODE}function yt(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Q(t,e){return t.localName===e}class Xr{constructor(e,n){this.app=e,this.options=n,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=s=>{const i=this.app.nodes.getID(s);if(!i||!Q(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Q(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(u=>{u.forEach(c=>{c.isIntersecting&&(c.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(c.target,i):this.snapshots[i]&&(this.snapshots[i].paused=!0))})}).observe(s)},this.recordCanvas=(s,i)=>{const r=this.app.timestamp();this.snapshots[i]={images:[],createdAt:r,paused:!1,dummy:document.createElement("canvas")};const o=xr(i.toString(),r);this.app.send(o);const u=l=>{Yr(l,this.options.quality,this.snapshots[i].dummy,this.options.fixedScaling,this.fileExt,a=>{a&&(this.snapshots[i].images.push({id:this.app.timestamp(),data:a}),this.snapshots[i].images.length>9&&(this.sendSnaps(this.snapshots[i].images,i,this.snapshots[i].createdAt),this.snapshots[i].images=[]))})},c=setInterval(()=>{const l=this.app.nodes.getID(s),a=l?this.app.nodes.getNode(l):void 0;!a||!Q(a,"canvas")||a!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(c)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{u(a)}):u(a))},this.interval);this.intervals.push(c)},this.fileExt=n.fileExt??"webp",this.interval=1e3/n.fps}startTracking(){setTimeout(()=>{this.app.nodes.scanTree(this.captureCanvas),this.app.nodes.attachNodeCallback(e=>{this.captureCanvas(e)})},500)}sendSnaps(e,n,s){if(Object.keys(this.snapshots).length===0)return;const i=new FormData;e.forEach(r=>{const o=r.data;o&&(i.append("snapshot",o,`${s}_${n}_${r.id}.${this.fileExt}`),this.options.isDebug&&Qr(o,`${s}_${n}_${r.id}.${this.fileExt}`))}),fetch(this.app.options.ingestPoint+"/v1/web/images",{method:"POST",headers:{Authorization:`Bearer ${this.app.session.getSessionToken()??""}`},body:i}).then(()=>!0).catch(r=>{this.app.debug.error("error saving canvas",r)})}clear(){this.intervals.forEach(e=>clearInterval(e)),this.snapshots={}}}const Ms={low:.35,medium:.55,high:.8};function Yr(t,e="medium",n,s=!1,i,r){const o=`image/${i}`;if(s){const u=window.devicePixelRatio||1;n.width=t.width/u,n.height=t.height/u;const c=n.getContext("2d");if(!c)return"";c.clearRect(0,0,n.width,n.height),c.drawImage(t,0,0,n.width,n.height),n.toBlob(r,o,Ms[e])}else t.toBlob(r,o,Ms[e])}function Qr(t,e){const n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=e,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const Xe={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class Zr{constructor(e=Xe.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Xe.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Xe.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Xe.Errors)&&console.error(...n)},this.level=e}}class eo{constructor(e){this.node_id=e,this.nodes=[],this.totalNodeAmount=0,this.nodeCallbacks=[],this.elementListeners=new Map,this.nextNodeId=0,this.scanTree=n=>{this.nodes.forEach(s=>n(s))}}syntheticMode(e){const i=99999999*e;if(i>9007199254740900)throw new Error("Placeholder id overflow");this.nextNodeId=i}attachNodeCallback(e){this.nodeCallbacks.push(e)}attachNodeListener(e,n,s,i=!0){const r=this.getID(e);if(r===void 0)return;ds(e,n,s,i);let o=this.elementListeners.get(r);o===void 0&&(o=[],this.elementListeners.set(r,o)),o.push([n,s,i])}registerNode(e){let n=e[this.node_id];const s=n===void 0;return s&&(n=this.nextNodeId,this.totalNodeAmount++,this.nextNodeId++,this.nodes[n]=e,e[this.node_id]=n),[n,s]}unregisterNode(e){const n=e[this.node_id];if(n!==void 0){e[this.node_id]=void 0,delete e[this.node_id],delete this.nodes[n];const s=this.elementListeners.get(n);s!==void 0&&(this.elementListeners.delete(n),s.forEach(i=>fs(e,i[0],i[1],i[2]))),this.totalNodeAmount--}return n}cleanTree(){for(let e=0;e<this.nodes.length;e++){const n=this.nodes[e];n&&!document.contains(n)&&this.unregisterNode(n)}}callNodeCallbacks(e,n){this.nodeCallbacks.forEach(s=>s(e,n))}getID(e){if(e)return e[this.node_id]}getNode(e){return this.nodes[e]}getNodeCount(){return this.totalNodeAmount}clear(){for(let e=0;e<this.nodes.length;e++){const n=this.nodes[e];n&&this.unregisterNode(n)}this.nextNodeId=0,this.nodes.length=0}}function tn(t){if(Jr(t))return!0;if(en(t))return!1;if(!ke(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const n=t.getAttribute("rel"),s=t.getAttribute("as");return!(n!=null&&n.includes("stylesheet")||s==="style"||s==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function nn(t){return yt(t)?!0:!tn(t)}var be;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(be||(be={}));class sn{constructor(e,n=!1){this.app=e,this.isTopContext=n,this.commited=[],this.recents=new Map,this.indexes=[],this.attributesMap=new Map,this.textSet=new Set,this.observer=hs(this.app.safe(s=>{for(const i of s){const r=i.target,o=i.type;if(!nn(r))continue;if(o==="childList"){for(let c=0;c<i.removedNodes.length;c++)nn(i.removedNodes[c])&&this.bindNode(i.removedNodes[c]);for(let c=0;c<i.addedNodes.length;c++)this.bindTree(i.addedNodes[c]);continue}const u=this.app.nodes.getID(r);if(u!==void 0){if(this.recents.has(u)||this.recents.set(u,be.Changed),o==="attributes"){const c=i.attributeName;if(c===null)continue;let l=this.attributesMap.get(u);l===void 0&&this.attributesMap.set(u,l=new Set),l.add(c);continue}if(o==="characterData"){this.textSet.add(u);continue}}}this.commitNodes()}))}clear(){this.commited.length=0,this.recents.clear(),this.indexes.length=1,this.attributesMap.clear(),this.textSet.clear()}sendNodeAttribute(e,n,s,i){if(Zt(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(gs(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Wt(e,s,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,s,i);return}if(!(s==="src"||s==="srcset"||s==="integrity"||s==="crossorigin"||s==="autocomplete"||s.substr(0,2)==="on")&&!(s==="value"&&Q(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(gs(e,s));return}if(s==="style"||s==="href"&&Q(n,"link")){this.app.send(Wt(e,s,i,this.app.getBaseHref()));return}(s==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,s,i)}}sendNodeData(e,n,s){if(Q(n,"style")){this.app.send(fr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(Zi(e,s))}bindNode(e){const[n,s]=this.app.nodes.registerNode(e);s?this.recents.set(n,be.New):this.recents.get(n)!==be.New&&this.recents.set(n,be.Removed)}bindTree(e){if(!nn(e))return;this.bindNode(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:s=>(this.app.nodes.getID(s)!==void 0&&this.app.debug.error("! Node is already bound",s),tn(s)||this.app.nodes.getID(s)!==void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT)},!1);for(;n.nextNode();)this.bindNode(n.currentNode)}unbindTree(e){const n=this.app.nodes.unregisterNode(e);if(n!==void 0&&this.recents.get(n)===be.Removed){this.app.send(Qi(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:u=>tn(u)||this.app.nodes.getID(u)===void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},!1);let i=0;const r=this.app.nodes.getNodeCount();for(;s.nextNode();)i+=1,this.app.nodes.unregisterNode(s.currentNode);const o=Math.floor(i/r*100);o>30&&this.app.send(Sr(o))}}_commitNode(e,n){if(yt(n))return!0;const s=n.parentNode;let i;if(!Q(n,"html")||!this.isTopContext){if(s===null)return this.unbindTree(n),!1;if(i=this.app.nodes.getID(s),i===void 0)return this.unbindTree(n),!1;if(!this.commitNode(i))return this.unbindTree(n),!1;if(this.app.sanitizer.handleNode(e,i,n),this.app.sanitizer.isHidden(i))return!1}let r=n.previousSibling;for(;r!==null;){const a=this.app.nodes.getID(r);if(a!==void 0){this.commitNode(a),this.indexes[e]=this.indexes[a]+1;break}r=r.previousSibling}r===null&&(this.indexes[e]=0);const o=this.recents.get(e),u=o===be.New,c=this.indexes[e];if(c===void 0)throw"commitNode: missing node index";if(u){if(ke(n)){let a=n;if(i!==void 0){if(this.app.sanitizer.isHidden(e)){const d=a.clientWidth,p=a.clientHeight;a=n.cloneNode(),a.style.width=`${d}px`,a.style.height=`${p}px`}this.app.send(Ji(e,i,c,a.tagName,Zt(n)))}for(let d=0;d<a.attributes.length;d++){const p=a.attributes[d];this.sendNodeAttribute(e,a,p.nodeName,p.value)}}else en(n)&&(this.app.send(Xi(e,i,c)),this.sendNodeData(e,s,n.data));return!0}o===be.Removed&&i!==void 0&&this.app.send(Yi(e,i,c));const l=this.attributesMap.get(e);if(l!==void 0){if(!ke(n))throw"commitNode: node is not an element";for(const a of l)this.sendNodeAttribute(e,n,a,n.getAttribute(a))}if(this.textSet.has(e)){if(!en(n))throw"commitNode: node is not a text";this.sendNodeData(e,s,n.data)}return!0}commitNode(e){const n=this.app.nodes.getNode(e);if(n===void 0)return!1;const s=this.commited[e];return s!==void 0?s:this.commited[e]=this._commitNode(e,n)}commitNodes(e=!1){let n;this.recents.forEach((s,i)=>{this.commitNode(i),s===be.New&&(n=this.app.nodes.getNode(i))&&this.app.nodes.callNodeCallbacks(n,e)}),this.clear()}observeRoot(e,n,s=e){this.observer.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1}),this.bindTree(s),n(this.app.nodes.getID(e)),this.commitNodes(!0)}disconnect(){this.observer.disconnect(),this.clear()}}class Fs extends sn{observe(e){const n=e.contentDocument,s=this.app.nodes.getID(e);!n||s===void 0||this.observeRoot(n,i=>{if(i===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(qt(s,i))})}syntheticObserve(e,n){this.observeRoot(n,s=>{if(s===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(qt(e,s))})}}class to extends sn{observe(e){const n=e.shadowRoot,s=this.app.nodes.getID(e);!n||s===void 0||this.observeRoot(n,i=>{if(i===void 0){this.app.debug.error("OpenReplay: Shadow Root was not bound");return}this.app.send(qt(s,i))})}}class no{constructor(){this.states=new Map}calcOffset(e){let n=0,s=0;if(e.parent&&([n,s]=this.calcOffset(e.parent)),!e.offset){const{left:o,top:u}=e.iFrame.getBoundingClientRect();e.offset=[o,u]}const[i,r]=e.offset;return[n+i,s+r]}getDocumentOffset(e){const n=this.states.get(e);return n?this.calcOffset(n):[0,0]}observe(e){var u;const n=e.contentDocument;if(!n)return;const s=e.ownerDocument,i=this.states.get(s),r={offset:null,iFrame:e,parent:i||null,clear:()=>{var c;s.removeEventListener("scroll",o),(c=s.defaultView)==null||c.removeEventListener("resize",o)}},o=()=>{r.offset=null};s.addEventListener("scroll",o),(u=s.defaultView)==null||u.addEventListener("resize",o),this.states.set(n,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const rn=ve?Element.prototype.attachShadow:()=>new ShadowRoot;class so extends sn{constructor(e,n){super(e,!0),this.iframeOffsets=new no,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Q(s,"iframe")&&(this.options.captureIFrames&&!Re(s,"obscured")||Re(s,"capture"))&&this.handleIframe(s)}),this.app.nodes.attachNodeCallback(s=>{ke(s)&&s.shadowRoot!==null&&this.handleShadowRoot(s.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let n=null;const s=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!zi(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==n){const u=new Fs(this.app);this.iframeObservers.push(u),u.observe(e),n=o,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(u=>u(r)))},100));e.addEventListener("load",s),s()}handleShadowRoot(e){const n=new to(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=rn.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(Ki()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=rn.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new Fs(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=rn,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var wt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(wt||(wt={}));const io=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class ro{constructor(e,n){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},n)}handleNode(e,n,s){if((this.obscured.has(n)||ke(s)&&(Re(s,"masked")||Re(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||ke(s)&&(Re(s,"htmlmasked")||Re(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&ke(s)){const i=this.options.domSanitizer(s);i===wt.Obscured&&this.obscured.add(e),i===wt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?io(n):(this.options.obscureTextNumbers&&(n=n.replace(/\d/g,"0")),this.options.obscureTextEmails&&(n=n.replace(/^\w+([+.-]\w+)*@\w+([.-]\w+)*\.\w{2,3}$/g,s=>{const[i,r]=s.split("@"),[o,u]=r.split(".");return`${Ut(i)}@${Ut(o)}.${Ut(u)}`})),n)}isObscured(e){return this.obscured.has(e)}isHidden(e){return this.hidden.has(e)}getInnerTextSecure(e){const n=this.app.nodes.getID(e);return n?this.sanitize(n,e.innerText):""}clear(){this.obscured.clear(),this.hidden.clear()}}class oo{constructor(e,n){this.app=e,this.options=n,this.metadata={},this.userID=null,this.callbacks=[],this.timestamp=0,this.createTabId()}attachUpdateCallback(e){this.callbacks.push(e)}handleUpdate(e){e.userID==null&&delete e.userID,e.sessionID==null&&delete e.sessionID,this.callbacks.forEach(n=>n(e))}assign(e){e.userID!==void 0&&(this.userID=e.userID),e.metadata!==void 0&&Object.entries(e.metadata).forEach(([n,s])=>this.metadata[n]=s),e.sessionID!==void 0&&(this.sessionID=e.sessionID),e.timestamp!==void 0&&(this.timestamp=e.timestamp),e.projectID!==void 0&&(this.projectID=e.projectID),this.handleUpdate(e)}setMetadata(e,n){this.metadata[e]=n,this.handleUpdate({metadata:{[e]:n}})}setUserID(e){this.userID=e,this.handleUpdate({userID:e})}setUserInfo(e){this.userInfo=e}getPageNumber(){const e=this.app.sessionStorage.getItem(this.options.session_pageno_key);if(e!=null)return parseInt(e)}incPageNo(){let e=this.getPageNumber();return e===void 0?e=0:e++,this.app.sessionStorage.setItem(this.options.session_pageno_key,e.toString()),e}getSessionToken(){return this.app.sessionStorage.getItem(this.options.session_token_key)||void 0}setSessionToken(e){this.app.sessionStorage.setItem(this.options.session_token_key,e)}applySessionHash(e){const n=decodeURI(e).split("&");let s=e,i="100500";n.length==2&&([i,s]=n),!(!i||!s)&&(this.app.sessionStorage.setItem(this.options.session_token_key,s),this.app.sessionStorage.setItem(this.options.session_pageno_key,i))}getSessionHash(){const e=this.getPageNumber(),n=this.getSessionToken();if(!(e===void 0||n===void 0))return encodeURI(String(e)+"&"+n)}getTabId(){return this.tabId||this.createTabId(),this.tabId}regenerateTabId(){const e=Ui(12);this.app.sessionStorage.setItem(this.options.session_tabid_key,e),this.tabId=e}createTabId(){const e=this.app.sessionStorage.getItem(this.options.session_tabid_key);e?this.tabId=e:this.regenerateTabId()}getInfo(){return{sessionID:this.sessionID,metadata:this.metadata,userID:this.userID,timestamp:this.timestamp,projectID:this.projectID}}reset(){this.app.sessionStorage.removeItem(this.options.session_token_key),this.metadata={},this.userID=null,this.sessionID=void 0,this.timestamp=0}}function ao(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class co{constructor(e){this.app=e,this.timer=null,this.callbacks=[]}attach(e,n=0,s=!0,i){i&&(e=e.bind(i)),s&&(e=this.app.safe(e)),this.callbacks.unshift(n?ao(e,n):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ye="canceled",Ps="or_uxt_active",on="or_buffer_1",_e=t=>({reason:t,success:!1}),lo=t=>({...t,success:!0});var Z;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Z||(Z={}));const Bs="https://api.openreplay.com/ingest";function an(){const t=new Date().getTimezoneOffset()*-1,e=t>=0?"+":"-",n=Math.floor(Math.abs(t)/60),s=Math.abs(t)%60;return`UTC${e}${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}const uo=t=>new Promise(e=>setTimeout(e,t)),ce={ask:"never-gonna-give-you-up",resp:"never-gonna-let-you-down",reg:"never-gonna-run-around-and-desert-you",iframeSignal:"never-gonna-make-you-cry",iframeId:"never-gonna-say-goodbye",iframeBatch:"never-gonna-tell-a-lie-and-hurt-you"};let ho=class{constructor(e,n,s,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=Z.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var c;(c=this.canvasRecorder)==null||c.restartTracking()},this.flushBuffer=async c=>new Promise(l=>{let a=!1;const d=[c.shift()];for(;!a;){const p=c[0];!p||p[0]===0?a=!0:d.push(c.shift())}this.postToWorker(d),l(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(s).findIndex(c=>["fixedCanvasScaling","disableCanvas"].includes(c))!==-1&&(console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.'),s={...s,canvas:{__save_canvas_locally:s.__save_canvas_locally,fixedCanvasScaling:s.fixedCanvasScaling,disableCanvas:s.disableCanvas}}),this.networkOptions=s.network;const o={revID:"",node_id:"__openreplay_id",session_token_key:"__openreplay_token",session_pageno_key:"__openreplay_pageno",session_reset_key:"__openreplay_reset",session_tabid_key:"__openreplay_tabid",local_uuid_key:"__openreplay_uuid",ingestPoint:Bs,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Xe.Silent,__save_canvas_locally:!1,localStorage:null,sessionStorage:null,disableStringDict:!1,forceSingleTab:!1,assistSocketHost:"",fixedCanvasScaling:!1,disableCanvas:!1,captureIFrames:!0,obscureTextEmails:!0,obscureTextNumbers:!1,crossdomain:{parentDomain:"*"},canvas:{disableCanvas:!1,fixedCanvasScaling:!1,__save_canvas_locally:!1,useAnimationFrame:!1}};if(this.options=ps(o,s),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const c=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${c}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new ro(this,s),this.nodes=new eo(this.options.node_id),this.observer=new so(this,s),this.ticker=new co(this),this.ticker.attach(()=>this.commit()),this.debug=new Zr(this.options.__debug__),this.session=new oo(this,this.options),this.attributeSender=new Ai(this,!!this.options.disableStringDict),this.featureFlags=new Pi(this),this.tagWatcher=new Ir(this.sessionStorage,this.debug.error,c=>{this.send(kr(c))}),this.session.attachUpdateCallback(({userID:c,metadata:l})=>{c!=null&&this.send(cr(c)),l!=null&&Object.entries(l).forEach(([a,d])=>this.send(ms(a,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const u=this.session.getTabId();if(this.insideIframe){const c=a=>{const{data:d}=a;d.line===ce.iframeId&&(this.rootId=d.id,this.session.setSessionToken(d.token),this.frameOderNumber=d.frameOrderNumber,this.debug.log("starting iframe tracking",d),this.allowAppStart())};window.addEventListener("message",c),this.attachStopCallback(()=>{window.removeEventListener("message",c)});const l=this.initialHostName;window.parent.postMessage({line:ce.iframeSignal,source:u,context:this.contextId,domain:l},"*")}else{let c=0;const l=a=>{const{data:d}=a;if(d.line===ce.iframeSignal){const p=d.domain,v=Array.from(document.querySelectorAll("iframe"));this.pageFrames=v,(async()=>{let y=0;for(;y<10;){const x=this.checkNodeId(v,p);if(x){this.waitStarted().then(()=>{var R;c++;const C=this.session.getSessionToken(),F={line:ce.iframeId,context:this.contextId,domain:p,id:x,token:C,frameOrderNumber:c};this.debug.log("iframe_data",F),(R=a.source)==null||R.postMessage(F,"*")}).catch(console.error),y=10;break}y++,await uo(100)}})()}if(d.line===ce.iframeBatch){const v=d.messages.map(w=>{if(w[0]===20){let y=w;return this.pageFrames.forEach(x=>{if(x.dataset.domain===a.data.domain){const[C,F,R]=w,{left:E,top:N}=x.getBoundingClientRect();y=[C,F+E,R+N]}}),y}if(w[0]===68){let y=w;return this.pageFrames.forEach(x=>{if(x.dataset.domain===a.data.domain){const[C,F,R,E,N,D,L]=w,{left:I,top:T,width:P,height:H}=x.getBoundingClientRect(),j=document.documentElement.scrollWidth,z=document.documentElement.scrollHeight,_=D/100*P+I,M=L/100*H+T,V=_/j,G=M/z;y=[C,F,R,E,N,Math.round(V*1e3)/10,Math.round(G*1e3)/10]}}),y}return w});this.messages.push(...v)}};window.addEventListener("message",l),this.attachStopCallback(()=>{window.removeEventListener("message",l)})}this.bc!==null&&(this.bc.postMessage({line:ce.ask,source:u,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=c=>{if(c.data.context!==this.contextId){if(c.data.line===ce.resp){const l=c.data.token;this.session.setSessionToken(l),this.allowAppStart()}if(c.data.line===ce.reg){const l=c.data.token;this.session.regenerateTabId(),this.session.setSessionToken(l),this.allowAppStart()}if(c.data.line===ce.ask){const l=this.session.getSessionToken();l&&this.bc&&this.bc.postMessage({line:c.data.source===u?ce.reg:ce.resp,token:l,source:u,context:this.contextId})}}})}allowAppStart(){this.canStart=!0,this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}checkNodeId(e,n){for(const s of e)if(s.dataset.domain===n)return s[this.options.node_id];return null}initWorker(){try{this.worker=new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){const e=i?.toString().replace(/^([^_]+)_([^_]+).*/,"$1_$2_$3");this.busy=!0;const n={Authorization:`Bearer ${this.token}`};s&&(n["Content-Encoding"]="gzip"),null!==this.token?fetch(`${this.ingestURL}?batch=${this.pageNo??"noPageNum"}_${e??"noBatchNum"}`,{body:t,method:"POST",headers:n,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${i??"noBatchNum"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn("OpenReplay:",e),this.retry(t,s,`${i??"noBatchNum"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${i??"noBatchNum"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if("q_end"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==l&&(clearInterval(l),l=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function g(){u!==h.Stopped&&(postMessage("a_stop"),c().then((()=>{postMessage("a_start")})))}let p,l=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),void c().then((()=>{u=h.Stopped}));if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Compressed batch."),void g();s.batch&&r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Uncompressed batch."),void g();s.batch&&r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:"queue_empty"}))),null===l&&(l=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("OR WebWorker: writer not initialised. Received auth."),void g()):(console.debug("OR WebWorker: sender not initialised. Received auth."),void g()):void 0}if(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?p=setTimeout((()=>g()),18e5):clearTimeout(p)),t.writeMessage(s)}))}else postMessage("not_init"),g()}else o()}else o()};'],{type:"text/javascript"}))),this.worker.onerror=n=>{this._debug("webworker_error",n)},this.worker.onmessage=({data:n})=>{this.handleWorkerMsg(n)};const e=()=>{this.worker&&this.worker.postMessage(null)};this.attachEventListener(window,"beforeunload",e,!1),this.attachEventListener(document.body,"mouseleave",e,!1,!1),this.attachEventListener(document,"visibilitychange",e,!1)}catch(e){this._debug("worker_start",e)}}handleWorkerMsg(e){var n;if(e==="a_stop")this.stop(!1);else if(e==="a_start")this.start({},!0);else if(e==="not_init")this.debug.warn("OR WebWorker: writer not initialised. Restarting tracker");else if(e.type==="failure")this.stop(!1),this.debug.error("worker_failed",e.reason),this._debug("worker_failed",e.reason);else if(e.type==="compress"){const s=e.batch;s.byteLength>this.compressionThreshold?Ri(e.batch,{mtime:0},(r,o)=>{var u,c;r?(this.debug.error("Openreplay compression error:",r),(u=this.worker)==null||u.postMessage({type:"uncompressed",batch:s})):(c=this.worker)==null||c.postMessage({type:"compressed",batch:o})}):(n=this.worker)==null||n.postMessage({type:"uncompressed",batch:s})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,n){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${n}`})}),this.debug.error("OpenReplay error: ",e,n)}send(e,n=!1){var s;this.activityState!==Z.NotActive&&(this.activityState===Z.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Z.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(Le(this.session.getTabId())),this.messages.unshift(De(this.timestamp())),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}if(!(this.worker===void 0||!this.messages.length)){if(this.insideIframe){window.parent.postMessage({line:ce.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{qi(()=>{var e;this.messages.unshift(Le(this.session.getTabId())),this.messages.unshift(De(this.timestamp())),(e=this.worker)==null||e.postMessage(this.messages),this.commitCallbacks.forEach(n=>n(this.messages)),this.messages.length=0})}catch(e){this._debug("worker_commit",e),this.stop(!0),setTimeout(()=>{this.start()},500)}}}_cStartCommit(){this.coldStartCommitN+=1,this.coldStartCommitN===2&&(this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId())),this.bufferedMessages2.push(De(this.timestamp())),this.bufferedMessages2.push(Le(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Z.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var n;(n=this.worker)==null||n.postMessage(e),this.commitCallbacks.forEach(s=>s(e)),e.length=0}timestamp(){return fe()+this.delay}safe(e){const n=this;return function(...s){try{e.apply(this,s)}catch(i){n._debug("safe_fn_call",i)}}}attachCommitCallback(e){this.commitCallbacks.push(e)}attachStartCallback(e,n=!1){n&&(e=this.safe(e)),this.startCallbacks.push(e)}attachStopCallback(e,n=!1){n&&(e=this.safe(e)),this.stopCallbacks.push(e)}attachEventListener(e,n,s,i=!0,r=!0){i&&(s=this.safe(s));const o=()=>e?ds(e,n,s,r):null,u=()=>e?fs(e,n,s,r):null;this.attachStartCallback(o,i),this.attachStopCallback(u,i)}checkRequiredVersion(e){const n=e.split(/[.-]/),s=this.version.split(/[.-]/);for(let i=0;i<3;i++){if(isNaN(Number(s[i]))||isNaN(Number(n[i])))return!1;if(Number(s[i])>Number(n[i]))return!0;if(Number(s[i])<Number(n[i]))return!1}return!0}getTrackerInfo(){return{userUUID:this.localStorage.getItem(this.options.local_uuid_key),projectKey:this.projectKey,revID:this.revID,trackerVersion:this.version,isSnippet:this.options.__is_snippet}}getSessionInfo(){return{...this.session.getInfo(),...this.getTrackerInfo()}}getSessionToken(){return this.session.getSessionToken()}getSessionID(){return this.session.getInfo().sessionID||void 0}getSessionURL(e){const{projectID:n,sessionID:s,timestamp:i}=this.session.getInfo();if(!n||!s){this.debug.error("OpenReplay error: Unable to build session URL");return}const r=this.options.ingestPoint,c=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${n}/session/${s}`);if(e!=null&&e.withCurrentTime){const l=fe()-i;return`${c}?jumpto=${l}`}return c}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,n;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((n=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:n.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const n=new URL(this.getBaseHref());return n.pathname+="/"+new URL(e).pathname,n.pathname.replace(/\/+/g,"/"),n.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===Z.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const n=this.sessionStorage.getItem(this.options.session_reset_key)!==null,s=e||n,i=this.session.getSessionToken();return s||!i}async coldStart(e={},n){this.singleBuffer=!1;const s=1e3,i=this.checkSessionToken(e.forceNew);n&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,zt(),this.coldStartTs=fe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(De(this.timestamp())),this.bufferedMessages2.push(Le(this.session.getTabId()))),this.stop(!1),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(gt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,v;this.conditionsManager=new Mi(this,e);const n=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:fe(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l,projectID:a}=await n.json();this.session.assign({projectID:a}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l});const d={sessionToken:s,userUUID:"",sessionID:""};this.startCallbacks.forEach(w=>w(d)),await((p=this.conditionsManager)==null?void 0:p.fetchConditions(a,s)),await this.featureFlags.reloadFlags(s),await this.tagWatcher.fetchTags(this.options.ingestPoint,s),(v=this.conditionsManager)==null||v.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);zt(),this.coldStartTs=fe();const i=this.localStorage.getItem(on);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(on)}this.bufferedMessages1.push(De(this.timestamp())),this.bufferedMessages1.push(Le(this.session.getTabId())),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),s||this.send(gt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(on,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,v;this.stop(!1);const e=fe();(p=this.worker)==null||p.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:this.coldStartTs,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const n=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:e,doNotRecord:!1,bufferDiff:e-this.coldStartTs,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an()})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l,beaconSizeLimit:a,projectID:d}=await n.json();for((v=this.worker)==null||v.postMessage({type:"auth",token:s,beaconSizeLimit:a}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:u,userOS:c,userState:l});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},n=!1,s){const i=this.activityState===Z.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const c="No worker found: perhaps, CSP is not set.";return this.signalError(c,[]),Promise.resolve(_e(c))}if(this.activityState===Z.Active||this.activityState===Z.Starting)return Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Z.Starting,i||zt(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=fe();this.worker.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:i?this.coldStartTs:r,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const o=this.session.getSessionToken(),u=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",u,"session token: ",o);try{const c=await window.fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:r,doNotRecord:!1,bufferDiff:r-this.coldStartTs,userID:this.session.getInfo().userID,token:u?void 0:o,deviceMemory:Jt,jsHeapSizeLimit:Xt,timezone:an(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(c.status!==200){const _=await c.text(),M=_===Ye?Ye:`Server error: ${c.status}. ${_}`;return _e(M)}if(!this.worker){const _="no worker found after start request (this should not happen in real world)";return this.signalError(_,[]),_e(_)}const{token:l,userUUID:a,projectID:d,beaconSizeLimit:p,compressionThreshold:v,delay:w,sessionID:y,startTimestamp:x,userBrowser:C,userCity:F,userCountry:R,userDevice:E,userOS:N,userState:D,canvasEnabled:L,canvasQuality:I,canvasFPS:T,assistOnly:P}=await c.json();if(typeof l!="string"||typeof a!="string"||typeof x!="number"&&typeof x<"u"||typeof y!="string"||typeof w!="number"||typeof p!="number"&&typeof p<"u"){const _=`Incorrect server response: ${JSON.stringify(c)}`;return this.signalError(_,[]),_e(_)}this.delay=w,this.session.setSessionToken(l),this.session.setUserInfo({userBrowser:C,userCity:F,userCountry:R,userDevice:E,userOS:N,userState:D}),this.session.assign({sessionID:y,timestamp:x||r,projectID:d}),P?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:l,beaconSizeLimit:p}),!u&&l===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(gt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([_,M])=>this.send(ms(_,M))),this.localStorage.setItem(this.options.local_uuid_key,a),this.compressionThreshold=v;const H={sessionToken:l,userUUID:a,sessionID:y};if(this.startCallbacks.forEach(_=>_(H)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,l),this.activityState=Z.Active,L&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new Xr(this,{fps:T,quality:I,isDebug:this.options.canvas.__save_canvas_locally,fixedScaling:this.options.canvas.fixedCanvasScaling,useAnimationFrame:this.options.canvas.useAnimationFrame}),this.canvasRecorder.startTracking()),i){const _=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;_.length>0;)await this.flushBuffer(_);this.clearBuffers(),this.commit()}else this.insideIframe&&this.rootId?this.observer.crossdomainObserve(this.rootId,this.frameOderNumber):this.observer.observe(),this.ticker.start();this.uxtManager=this.uxtManager?this.uxtManager:new Kr(this,Ps);let j;const z=this.localStorage.getItem(Ps);if(z&&(j=parseInt(z,10)),location!=null&&location.search){const _=new URLSearchParams(location.search);if(_.has("oruxt")){const M=_.get("oruxt");j=M?parseInt(M,10):void 0}}return j&&(this.uxtManager.isActive?this.onUxtCb.forEach(_=>_(j)):this.uxtManager.getTest(j,l,!!z).then(_=>{_&&this.onUxtCb.forEach(M=>M(_))})),lo(H)}catch(c){if(this.stop(),this.session.reset(),c===Ye)return this.signalError(Ye,[]),_e(Ye);this._debug("session_start",c);const l=c instanceof Error?c.message:c.toString();return this.signalError(l,[]),_e(l)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const n=()=>{this.canStart?e(!0):setTimeout(n,25)};n()})}async waitStarted(){return new Promise(e=>{const n=()=>{this.activityState===Z.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Z.Active||this.activityState===Z.Starting?Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(n=>{const s=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",s),n(this._start(...e)))};document.addEventListener("visibilitychange",s)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const n=e;return(s,i,r="down")=>{typeof s!="string"||typeof i!="string"||i.length>5*1024*1024||s.length>255||this.send(br("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Z.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(s=>s()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(n=this.canvasRecorder)==null||n.clear()}finally{this.activityState=Z.NotActive}}};function fo(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(hr(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const js=ve&&"InstallTrigger"in window?t=>t.message+`
11
11
  `+t.stack:t=>t.stack||t.message;function cn(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?js(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function po(t){return typeof t!="number"?"NaN":t.toString()}function go(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function zs(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return js(t);if(Array.isArray(t)){const e=t.length,n=t.slice(0,10).map(cn).join(", ");return`Array(${e})[${n}]`}if(typeof t=="object"){const e=[];let n=0;for(const s in t){if(++n===10)break;const i=t[s];e.push(s+": "+cn(i))}return"{"+e.join(", ")+"}"}return t.toString()}function mo(t){return typeof t[0]=="string"&&t.unshift(t.shift().replace(/%(o|s|f|d|i)/g,(e,n)=>{const s=t.shift();if(s===void 0)return e;switch(n){case"o":return zs(s);case"s":return cn(s);case"f":return po(s);case"d":case"i":return go(s);default:return e}})),t.map(zs).join(" ")}const Us=["log","info","warn","error","debug","assert"];function vo(t,e){const n=Object.assign({consoleMethods:Us,consoleThrottling:30},e);if(!Array.isArray(n.consoleMethods)||n.consoleMethods.length===0)return;const s=t.safe((c,l)=>t.send(ir(c,mo(l))));let i=0;const r=()=>{i=0};t.attachStartCallback(r),t.ticker.attach(r,33,!1);const o=(c,l)=>{const a={apply:function(d,p,v){Reflect.apply(d,l,v),i=i+1,!(i>n.consoleThrottling)&&s(d.name,v)}};n.consoleMethods.forEach(d=>{if(Us.indexOf(d)===-1){t.debug.error(`OpenReplay: unsupported console method "${d}"`);return}const p=l.console[d];c[d]=new Proxy(p,a)})},u=t.safe(c=>o(c.console,c));u(window),t.observer.attachContextCallback(u)}var Hs={exports:{}},ln={exports:{}},$s;function bo(){return $s||($s=1,function(t,e){(function(n,s){t.exports=s()})(Me,function(){function n(y){return!isNaN(parseFloat(y))&&isFinite(y)}function s(y){return y.charAt(0).toUpperCase()+y.substring(1)}function i(y){return function(){return this[y]}}var r=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],u=["fileName","functionName","source"],c=["args"],l=["evalOrigin"],a=r.concat(o,u,c,l);function d(y){if(y)for(var x=0;x<a.length;x++)y[a[x]]!==void 0&&this["set"+s(a[x])](y[a[x]])}d.prototype={getArgs:function(){return this.args},setArgs:function(y){if(Object.prototype.toString.call(y)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=y},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(y){if(y instanceof d)this.evalOrigin=y;else if(y instanceof Object)this.evalOrigin=new d(y);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var y=this.getFileName()||"",x=this.getLineNumber()||"",C=this.getColumnNumber()||"",F=this.getFunctionName()||"";return this.getIsEval()?y?"[eval] ("+y+":"+x+":"+C+")":"[eval]:"+x+":"+C:F?F+" ("+y+":"+x+":"+C+")":y+":"+x+":"+C}},d.fromString=function(x){var C=x.indexOf("("),F=x.lastIndexOf(")"),R=x.substring(0,C),E=x.substring(C+1,F).split(","),N=x.substring(F+1);if(N.indexOf("@")===0)var D=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(N,""),L=D[1],I=D[2],T=D[3];return new d({functionName:R,args:E||void 0,fileName:L,lineNumber:I||void 0,columnNumber:T||void 0})};for(var p=0;p<r.length;p++)d.prototype["get"+s(r[p])]=i(r[p]),d.prototype["set"+s(r[p])]=function(y){return function(x){this[y]=!!x}}(r[p]);for(var v=0;v<o.length;v++)d.prototype["get"+s(o[v])]=i(o[v]),d.prototype["set"+s(o[v])]=function(y){return function(x){if(!n(x))throw new TypeError(y+" must be a Number");this[y]=Number(x)}}(o[v]);for(var w=0;w<u.length;w++)d.prototype["get"+s(u[w])]=i(u[w]),d.prototype["set"+s(u[w])]=function(y){return function(x){this[y]=String(x)}}(u[w]);return d})}(ln)),ln.exports}(function(t,e){(function(n,s){t.exports=s(bo())})(Me,function(s){var i=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,o=/^(eval@)?(\[native code])?$/;return{parse:function(c){if(typeof c.stacktrace<"u"||typeof c["opera#sourceloc"]<"u")return this.parseOpera(c);if(c.stack&&c.stack.match(r))return this.parseV8OrIE(c);if(c.stack)return this.parseFFOrSafari(c);throw new Error("Cannot parse given Error object")},extractLocation:function(c){if(c.indexOf(":")===-1)return[c];var l=/(.+?)(?::(\d+))?(?::(\d+))?$/,a=l.exec(c.replace(/[()]/g,""));return[a[1],a[2]||void 0,a[3]||void 0]},parseV8OrIE:function(c){var l=c.stack.split(`
12
12
  `).filter(function(a){return!!a.match(r)},this);return l.map(function(a){a.indexOf("(eval ")>-1&&(a=a.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var d=a.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),p=d.match(/ (\(.+\)$)/);d=p?d.replace(p[0],""):d;var v=this.extractLocation(p?p[1]:d),w=p&&d||void 0,y=["eval","<anonymous>"].indexOf(v[0])>-1?void 0:v[0];return new s({functionName:w,fileName:y,lineNumber:v[1],columnNumber:v[2],source:a})},this)},parseFFOrSafari:function(c){var l=c.stack.split(`
13
13
  `).filter(function(a){return!a.match(o)},this);return l.map(function(a){if(a.indexOf(" > eval")>-1&&(a=a.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),a.indexOf("@")===-1&&a.indexOf(":")===-1)return new s({functionName:a});var d=/((.*".+"[^@]*)?[^@]*)(?:@)/,p=a.match(d),v=p&&p[1]?p[1]:void 0,w=this.extractLocation(a.replace(d,""));return new s({functionName:v,fileName:w[0],lineNumber:w[1],columnNumber:w[2],source:a})},this)},parseOpera:function(c){return!c.stacktrace||c.message.indexOf(`
@@ -16,9 +16,9 @@ We appreciate your time and valuable input.`),r=U("div","end_button_or",Cs,"Subm
16
16
  `).length?this.parseOpera9(c):c.stack?this.parseOpera11(c):this.parseOpera10(c)},parseOpera9:function(c){for(var l=/Line (\d+).*script (?:in )?(\S+)/i,a=c.message.split(`
17
17
  `),d=[],p=2,v=a.length;p<v;p+=2){var w=l.exec(a[p]);w&&d.push(new s({fileName:w[2],lineNumber:w[1],source:a[p]}))}return d},parseOpera10:function(c){for(var l=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,a=c.stacktrace.split(`
18
18
  `),d=[],p=0,v=a.length;p<v;p+=2){var w=l.exec(a[p]);w&&d.push(new s({functionName:w[3]||void 0,fileName:w[2],lineNumber:w[1],source:a[p]}))}return d},parseOpera11:function(c){var l=c.stack.split(`
19
- `).filter(function(a){return!!a.match(i)&&!a.match(/^Error created at/)},this);return l.map(function(a){var d=a.split("@"),p=this.extractLocation(d.pop()),v=d.shift()||"",w=v.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;v.match(/\(([^)]*)\)/)&&(y=v.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var x=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:w,args:x,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:a})},this)}}})})(Hs);var yo=Hs.exports;const wo=yi(yo);function Ws(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function St(t,e,n={}){let s=e;try{s=wo.parse(t)}catch{}return Gt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function qs(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return St(t.error,Ws(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),Gt(s,i,JSON.stringify(Ws(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return St(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return Gt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function So(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(o){const u=qs(o,i);u!=null&&t.send(u)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}n.captureExceptions&&(t.observer.attachContextCallback(s),s(window))}function Vs(t,e=document.location){return t=t.trim(),t.startsWith("//")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")?t:t.startsWith("/")?e.origin+t:e.origin+e.pathname+t}function xo(t){return Bi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const ko="https://static.openreplay.com/tracker/placeholder.jpeg";function Eo(t){function e(u,c){t.attributeSender.sendSetAttribute(u,"src",ko);const{width:l,height:a}=c.getBoundingClientRect();c.hasAttribute("width")||t.attributeSender.sendSetAttribute(u,"width",String(l)),c.hasAttribute("height")||t.attributeSender.sendSetAttribute(u,"height",String(a))}const n=function(u,c){const{srcset:l}=c;if(!l)return;const a=l.split(l.match(/,\s+/)?/,\s+/:",").map(d=>Vs(d)).join(", ");t.attributeSender.sendSetAttribute(u,"srcset",a)},s=function(u,c){c.src.length>ji&&e(u,c),t.send(Wt(u,"src",c.src,t.getBaseHref()))},i=t.safe(function(u){const c=Vs(u.src||"");cs(c)&&t.send(ks(t.timestamp(),0,0,0,0,0,c,"img",0,!1))}),r=t.safe(function(u){const c=t.nodes.getID(u);c!==void 0&&u.complete&&(u.naturalHeight===0&&u.naturalWidth===0&&!xo(u.src)?i(u):t.sanitizer.isHidden(c)||t.sanitizer.isObscured(c)?e(c,u):(s(c,u),n(c,u)))}),o=hs(t.safe(u=>{for(const c of u)if(c.type==="attributes"){const l=c.target,a=t.nodes.getID(l);if(a===void 0)return;c.attributeName==="src"&&s(a,l),c.attributeName==="srcset"&&n(a,l)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(u=>{Q(u,"img")&&(t.nodes.attachNodeListener(u,"error",()=>i(u)),t.nodes.attachNodeListener(u,"load",()=>r(u)),r(u),o.observe(u,{attributes:!0,attributeFilter:["src","srcset"]}))})}const To=["text","password","email","search","number","range","date","tel","time"];function Io(t){return Q(t,"textarea")?!0:Q(t,"input")?To.includes(t.type):!1}function Co(t){if(!Q(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const _o=me&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.labels;if(n!==null&&n.length===1)return n[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.id;if(n){const s=t.ownerDocument.querySelectorAll('label[for="'+n+'"]');if(s!==null&&s.length===1)return s[0]}};function Gs(t){let e=Ht(t);if(e===null){const n=_o(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return as(e).slice(0,100)}const $e={Plain:0,Obscured:1,Hidden:2};function No(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:$e.Obscured,obscureInputDates:!1},e);function s(a,d){let p=d.value,v=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(a)?v=$e.Hidden:(t.sanitizer.isObscured(a)||v===$e.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(v=$e.Obscured);let w=0;switch(v){case $e.Hidden:w=-1,p="";break;case $e.Obscured:w=p.length,p="";break}return{value:p,mask:w}}function i(a,d){const{value:p,mask:v}=s(a,d);t.send(tr(a,p,v))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function u(a,d){r.get(a)!==d.value&&(r.set(a,d.value),i(a,d))}function c(a,d){o.get(a)!==d&&(o.set(a,d),t.send(nr(a,d)))}t.ticker.attach(()=>{r.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);u(d,p)}),o.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return o.delete(d);c(d,p.checked)})},3);function l(a,d,p,v){const{value:w,mask:y}=s(a,d),x=Gs(d);t.send(yr(a,w,y!==0,x,p,v))}t.nodes.attachNodeCallback(t.safe(a=>{const d=t.nodes.getID(a);if(d!==void 0){if(Q(a,"select")&&(i(d,a),t.nodes.attachNodeListener(a,"change",()=>i(d,a))),Io(a)){u(d,a);let p=0,v=0,w=0;const y=()=>{p=fe()},x=()=>{v===0&&p!==0&&(v=fe()-p)},C=()=>{p!==0&&(w=fe()-p),l(d,a,v,w),v=0,w=0,p=0};t.nodes.attachNodeListener(a,"focus",y),t.nodes.attachNodeListener(a,"input",x),t.nodes.attachNodeListener(a,"change",C);return}if(Co(a)){c(d,a.checked),t.nodes.attachNodeListener(a,"change",()=>c(d,a.checked));return}}}))}let le,un,Ks;function Oo(t,e){if(Ks=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";const n={root:document.body,idName:i=>!0,className:i=>!0,tagName:i=>!0,attr:(i,r)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};le={...n,...e},un=Ro(le.root,n);let s=xt(t,"all",()=>xt(t,"two",()=>xt(t,"one",()=>xt(t,"none"))));if(s){const i=ei(ti(s,t));return i.length>0&&(s=i[0]),kt(s)}else throw new Error("Selector was not found.")}function Ro(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function xt(t,e,n){let s=null,i=[],r=t,o=0;for(;r;){const u=new Date().getTime()-Ks.getTime();if(le.timeoutMs!==void 0&&u>le.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${u}ms`);let c=Tt(Do(r))||Tt(...Lo(r))||Tt(...Ao(r))||Tt(Mo(r))||[Qs()];const l=Fo(r);if(e=="all")l&&(c=c.concat(c.filter(hn).map(a=>Et(a,l))));else if(e=="two")c=c.slice(0,1),l&&(c=c.concat(c.filter(hn).map(a=>Et(a,l))));else if(e=="one"){const[a]=c=c.slice(0,1);l&&hn(a)&&(c=[Et(a,l)])}else e=="none"&&(c=[Qs()],l&&(c=[Et(c[0],l)]));for(let a of c)a.level=o;if(i.push(c),i.length>=le.seedMinLength&&(s=Js(i,n),s))break;r=r.parentElement,o++}return s||(s=Js(i,n)),!s&&n?n():s}function Js(t,e){const n=ei(Zs(t));if(n.length>le.threshold)return e?e():null;for(let s of n)if(Ys(s))return s;return null}function kt(t){let e=t[0],n=e.name;for(let s=1;s<t.length;s++){const i=t[s].level||0;e.level===i-1?n=`${t[s].name} > ${n}`:n=`${t[s].name} ${n}`,e=t[s]}return n}function Xs(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ys(t){const e=kt(t);switch(un.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function Do(t){const e=t.getAttribute("id");return e&&le.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Lo(t){return Array.from(t.attributes).filter(n=>le.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Ao(t){return Array.from(t.classList).filter(le.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Mo(t){const e=t.tagName.toLowerCase();return le.tagName(e)?{name:e,penalty:2}:null}function Qs(){return{name:"*",penalty:3}}function Fo(t){const e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let s=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&s++,n!==t);)n=n.nextSibling;return s}function Et(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function hn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Tt(...t){const e=t.filter(Po);return e.length>0?e:null}function Po(t){return t!=null}function*Zs(t,e=[]){if(t.length>0)for(let n of t[0])yield*Zs(t.slice(1,t.length),e.concat(n));else yield e}function ei(t){return[...t].sort((e,n)=>Xs(e)-Xs(n))}function*ti(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>le.optimizedMinLength)for(let s=1;s<t.length-1;s++){if(n.counter>le.maxNumberOfTries)return;n.counter+=1;const i=[...t];i.splice(s,1);const r=kt(i);if(n.visited.has(r))return;Ys(i)&&Bo(i,e)&&(yield i,n.visited.set(r,!0),yield*ti(i,e,n))}}function Bo(t,e){return un.querySelector(kt(t))===e}function jo(t,e,n){return Oo(t,{root:e.body,seedMinLength:3,optimizedMinLength:(n==null?void 0:n.minSelectorDepth)||2,threshold:(n==null?void 0:n.nthThreshold)||1e3,maxNumberOfTries:(n==null?void 0:n.maxOptimiseTries)||1e4})}function dn(t){const e=t.tagName.toUpperCase();return e==="BUTTON"||e==="A"||e==="LI"||e==="SELECT"||e==="TR"||e==="TH"||t.onclick!=null||t.getAttribute("role")==="button"}function ni(t,e){return t instanceof Element?zo(t,e):null}function zo(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Re(n,"masked"))return null;n=n.parentElement}if(Zt(t)){let s=t.ownerSVGElement;for(;s!==null;)t=s,s=s.ownerSVGElement}for(n=t;n!==null&&n!==e.documentElement;){const s=n.tagName.toUpperCase();if(s==="LABEL")return null;if(s==="INPUT"||dn(n)||Ht(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function Uo(t,e){const{disableClickmaps:n=!1}=e||{};function s(E){const N=Ht(E);if(N!==null)return N;if(Q(E,"input"))return Gs(E);if(dn(E)){let D="";return E instanceof HTMLElement&&(D=t.sanitizer.getInnerTextSecure(E)),D=D||E.id||E.className,as(D).slice(0,100)}return""}let i=-1,r=-1,o=!1,u=null,c=0,l={},a=0,d=0,p=0,v=0,w;const y=.008,x=225;function C(){const E=v/x;if(!a){a=E;return}const N=(E-a)/x;p>4&&N>y&&t.send(wr(fe())),v=0,p=0,a=E}t.attachStartCallback(()=>{w=setInterval(()=>C(),x)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,u=null,l={},w&&clearInterval(w)});const F=()=>{o&&(t.send(sr(i,r)),o=!1)},R=(E,N=!1)=>{function D(I,T,P){return l[I]=l[I]||jo(T,E,P)}const L=N?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);L(E.documentElement,"mouseover",I=>{const T=ni(I.target,E);T!==u&&(u=T,c=performance.now())}),L(E,"mousemove",I=>{const[T,P]=t.observer.getDocumentOffset(E);i=I.clientX+T,r=I.clientY+P,o=!0;const H=Math.sign(I.movementX);v+=Math.abs(I.movementX)+Math.abs(I.movementY),H!==d&&(d=H,p++)},!1),L(E,"click",I=>{const T=ni(I.target,E);if(!I.clientX&&!I.clientY||T===null)return;const P=t.nodes.getID(T);if(P!==void 0){const H=I.pageX,j=I.pageY,z=E.documentElement.scrollWidth,_=E.documentElement.scrollHeight,M=si(H/z),V=si(j/_);F(),t.send(mr(P,u===T?Math.round(performance.now()-c):0,s(T),dn(T)&&!n?D(P,T,e):"",M,V),!0)}u=null})};t.nodes.attachNodeCallback(E=>{bt(E)&&R(E)}),R(document,!0),t.ticker.attach(F,(e==null?void 0:e.trackingOffset)||7)}function si(t){return Math.round(t*1e4)}function Ho(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let o="";if(Q(r,"img")&&(o=r.currentSrc||r.src),!o){const w=getComputedStyle(r).getPropertyValue("background-image");if(w){const y=s.exec(w);y!==null&&(o=y[1],(o.startsWith('"')||o.startsWith("'"))&&(o=o.substr(1,o.length-2)))}}if(!o)continue;const u=o.substr(0,10)==="data:image"?0:t[o];if(u===void 0)continue;const c=r.getBoundingClientRect(),l=Math.max(c.top,0),a=Math.max(c.left,0),d=Math.min(c.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),p=Math.min(c.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(d<=l||p<=a)continue;const v=(d-l)*(p-a);e.push({time:u,area:v})}return e}function $o(t,e){let n=Math.max(document.documentElement&&document.documentElement.clientWidth||0,window.innerWidth||0)*Math.max(document.documentElement&&document.documentElement.clientHeight||0,window.innerHeight||0)/10,s=n*t;for(let i=0;i<e.length;i++){const{time:r,area:o}=e[i];n+=o,s+=o*(r>t?r:t)}return n===0?0:s/n}function Wo(t,e){const n=Object.assign({captureResourceTimings:!0,capturePageLoadTimings:!0,capturePageRenderTimings:!0,excludedResourceUrls:[]},e);if("PerformanceObserver"in window||(n.captureResourceTimings=!1),!n.captureResourceTimings)return;let s={};function i(l){var d;if(l.duration<0||!cs(l.name)||t.isServiceURL(l.name))return;s!==null&&(s[l.name]=l.startTime+l.duration);let a=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(l.name.startsWith(p)){a=!0;return}}),!a&&t.send(ks(l.startTime+ze(),l.duration,l.responseStart&&l.startTime?l.responseStart-l.startTime:0,l.transferSize>l.encodedBodySize?l.transferSize-l.encodedBodySize:0,l.encodedBodySize||0,l.decodedBodySize||0,l.name,l.initiatorType,l.transferSize,l.responseStatus&&l.responseStatus===304||l.transferSize===0))}const r=new PerformanceObserver(l=>l.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:l}){l!==o&&(performance.getEntriesByType("resource").forEach(i),o=l),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let u=0,c=0;if(n.capturePageLoadTimings){let l=!1;t.ticker.attach(()=>{if(!l&&((u===0||c===0)&&performance.getEntriesByType("paint").forEach(a=>{const{name:d,startTime:p}=a;switch(d){case"first-paint":u=p;break;case"first-contentful-paint":c=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){l=!0;const{navigationStart:a,requestStart:d,responseStart:p,responseEnd:v,domContentLoadedEventStart:w,domContentLoadedEventEnd:y,loadEventStart:x,loadEventEnd:C}=performance.timing;t.send(rr(d-a||0,p-a||0,v-a||0,w-a||0,y-a||0,x-a||0,C-a||0,u,c))}},30)}if(n.capturePageRenderTimings){let l=0,a=0,d=0,p=null,v=!1;t.ticker.attach(()=>{if(v)return;const w=performance.now();if(s!==null&&(l=Math.max.apply(null,Object.keys(s).map(y=>s[y])),w-l>1e3&&(p=Ho(s),s=null)),d!==null&&(w-d>50&&(a=w),d=w-a>5e3?null:w),p!==null&&d===null||w>3e4){v=!0,s=null;const y=p===null?0:$o(c||u,p),{domContentLoadedEventEnd:x,navigationStart:C}=performance.timing,F=d===null?Math.max(a,c,x-C||0):0;t.send(or(y,c>l?c:l,F))}})}}function fn(t){const e=t.defaultView;return[e&&e.scrollX||t.documentElement&&t.documentElement.scrollLeft||t.body&&t.body.scrollLeft||0,e&&e.scrollY||t.documentElement&&t.documentElement.scrollTop||t.body&&t.body.scrollTop||0]}function qo(t,e){let n=!1;const s=new Map;function i(u){As(u)&&(xe(u)&&s.set(u,[u.scrollLeft,u.scrollTop]),bt(u)&&s.set(u,fn(u)))}const r=t.safe(()=>{e||t.send(Gi(...fn(document)))}),o=t.safe((u,c)=>{const l=t.nodes.getID(c);l!==void 0&&t.send(er(l,u[0],u[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((u,c)=>{c&&(xe(u)&&u.scrollLeft+u.scrollTop>0?s.set(u,[u.scrollLeft,u.scrollTop]):bt(u)&&s.set(u,fn(u))),yt(u)&&t.nodes.attachNodeListener(u,"scroll",l=>{i(l.target)})}),t.attachEventListener(document,"scroll",u=>{const c=u.target;if(c===document){n=!0;return}i(c)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(o),s.clear()},5,!1)}function Vo(t){let e,n,s,i,r=document.referrer;const o=t.safe(()=>{const{URL:l}=document;l!==e&&(e=l,t.send(Er(e,r,i,document.title)),i=0,r=e)}),u=t.safe(()=>{const{innerWidth:l,innerHeight:a}=window;(l!==n||a!==s)&&(n=l,s=a,t.send(Vi(n,s)))}),c=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(dr(document.hidden)));t.attachStartCallback(()=>{e=null,i=ze(),n=s=-1,o(),u(),c()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",c,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(u,5,!1)}function ii(t){return yt(t)&&!!t.adoptedStyleSheets}let Go=15;function ri(){return Go++}const It=new Map;function Ko(t){if(t===null||!ii(document))return;const e=new Map,n=new Map,s=o=>setTimeout(()=>{let u=t.nodes.getID(o);if(o===document&&(u=0),u===void 0)return;let c=n.get(u);c||(c=[]);const l=[],a=o.adoptedStyleSheets;if(a&&Symbol.iterator in a)for(const d of a){let p=e.get(d);const v=!p;if(p||(p=ri(),e.set(d,p)),c.includes(p)||t.send(Ss(p,u)),v){const w=d.cssRules;for(let y=0;y<w.length;y++)t.send(Vt(p,w[y].cssText,y,t.getBaseHref()))}l.push(p)}if(Symbol.iterator in c)for(const d of c)l.includes(d)||t.send(vr(d,u));n.set(u,l)},20);function i(o){const u=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");u&&Object.defineProperty(o,"adoptedStyleSheets",{...u,set:function(c){const l=u.set.call(this,c);return s(this),l}})}const r=o=>{if(o.__openreplay_adpss_patched__)return;o.__openreplay_adpss_patched__=!0,i(o.Document.prototype),i(o.ShadowRoot.prototype);const{replace:u,replaceSync:c}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(l){return u.call(this,l).then(a=>{const d=e.get(this);return d&&t.send(ys(d,l,t.getBaseHref())),a})},o.CSSStyleSheet.prototype.replaceSync=function(l){const a=e.get(this);return a&&t.send(ys(a,l,t.getBaseHref())),c.call(this,l)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(o=>{ii(o)&&s(o)})}function Jo(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(pr("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const u=It.get(i);u&&(typeof o=="string"?t.send(Vt(u,o,r,t.getBaseHref())):t.send(ws(u,r)))}),n=t.safe(i=>{let r=i;for(;r.parentRule;)r=r.parentRule;const o=r.parentStyleSheet;if(!o){t.debug.warn("No parent StyleSheet found for",r,i);return}const u=It.get(o);if(!u){t.debug.warn("No sheedID found for",o,It);return}const c=r.cssText,l=o.cssRules,a=Array.from(l).indexOf(r);a>=0?(t.send(Vt(u,c,a,t.getBaseHref())),t.send(ws(u,a+1))):t.debug.warn("Rule index not found in",o,r)}),s=t.safe(i=>{const{insertRule:r,deleteRule:o}=i.CSSStyleSheet.prototype,{insertRule:u,deleteRule:c}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(l,a=0){return e(this,a,l),r.call(this,l,a)},i.CSSStyleSheet.prototype.deleteRule=function(l){return e(this,l),o.call(this,l)},i.CSSGroupingRule.prototype.insertRule=function(l,a=0){const d=u.call(this,l,a);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(l=0){const a=c.call(this,l);return n(this),a}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Q(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,u=ri();It.set(o,u),t.send(Ss(u,r));const c=o.cssRules;for(let l=0;l<c.length;l++)e(o,l,c[l].cssText)})}function Xo(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(bs(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Q(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{As(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(bs(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Q(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function Yo(t){if(!window.FontFace)return;const e=new Map,n=s=>{class i extends s.FontFace{constructor(...o){if(typeof o[1]=="string"){let u="";o[2]&&t.safe(()=>{u=JSON.stringify(o[2])});const c=[o[0],o[1],u],l=e.get(s.document)||[];l.push(c),e.set(s.document,l);const a=s===window?0:t.nodes.getID(s.document);if(a===void 0)return;t.active()&&t.send(vs(a,...c))}super(...o)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!bt(s))return;const i=e.get(s);if(!i)return;const r=s.defaultView===window?0:t.nodes.getID(s);r!==void 0&&i.forEach(o=>{t.send(vs(r,...o))})}))}function Qo(t,e,n,s,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(p){t.debug.log("Openreplay: capturing axios response data",p);const{headers:v,data:w,method:y,url:x,baseURL:C}=p.config,{data:F,headers:R,status:E,response:N}=p,{data:D,headers:L,status:I}=N||{},T=n.ignoreHeaders,P=Array.isArray(T)?$=>T.includes($):()=>T;function H($,b){P(b[0])||($[b[0]]=b[1])}let j={},z={};v.toJSON?j=v.toJSON():v instanceof Headers?v.forEach(($,b)=>H(j,[b,$])):Array.isArray(v)?v.forEach($=>H(j,$)):typeof v=="object"&&Object.entries(v).forEach($=>H(j,$));const _=L||R;_.toJSON?z=_.toJSON():_ instanceof Headers?_.forEach(($,b)=>H(z,[b,$])):Array.isArray(_)?_.forEach($=>H(z,$)):typeof _=="object"&&Object.entries(_).forEach(([$,b])=>{P($)||(z[$]=b)});const M=s({url:x,method:y||"",status:E||I||0,request:{headers:j,body:w},response:{headers:z,body:D||F}});if(!M){t.debug.log("Openreplay: empty request/response info, skipping");return}const V=p.config.__openreplay_timing,G=performance.now()-V;t.debug.log("Openreplay: final req object",M),t.send(pt("xhr",String(y),String(M.url),i(M.request),i(M.response),M.status,V+ze(),G,0))}function o(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const v=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",w=t.getSessionToken();w&&p.headers.set(v,w)}return p}function u(p){return n.failuresOnly||r(p),p}function c(p){return t.debug.log("Openreplay: capturing API request error",p),Zo(p)&&p.response?r(p.response):p instanceof Error&&t.send(St(p,[])),Promise.reject(p)}function l(p){t.debug.log("Openreplay: failed API request, skipping",p)}const a=e.interceptors.request.use(o,l,{synchronous:!0}),d=e.interceptors.response.use(u,c,{synchronous:!0});t.attachStopCallback(()=>{var p,v,w,y;(v=(p=e.interceptors.request).eject)==null||v.call(p,a),(y=(w=e.interceptors.response).eject)==null||y.call(w,d)})}function Zo(t){return ea(t)&&t.isAxiosError===!0}function ea(t){return t!==null&&typeof t=="object"}var be;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(be||(be={}));class pn{constructor(e=[],n,s){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.id="",this.name="",this.method="",this.url="",this.status=0,this.statusText="",this.cancelState=0,this.readyState=0,this.header={},this.responseType="",this.requestHeader={},this.responseSize=0,this.responseSizeText="",this.startTime=0,this.endTime=0,this.duration=0,this.getData={},this.requestData=null}getMessage(){const{reqHs:e,resHs:n}=this.writeHeaders(),s={headers:e,body:this.method==="GET"?JSON.stringify(this.getData):this.requestData},i={headers:n,body:this.response},r=this.sanitize({url:this.url,method:this.method,status:this.status,request:s,response:i});if(r)return pt(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+ze(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([s,i])=>{this.isHeaderIgnored(s)||(e[s]=i)}),this.setSessionTokenHeader((s,i)=>{e[s]=i});const n={};return Object.entries(this.header).forEach(([s,i])=>{this.isHeaderIgnored(s)||(n[s]=i)}),{reqHs:e,resHs:n}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(n=>n.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const Qe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:mn(e)||Array.isArray(e)?n=JSON.stringify(e):typeof e<"u"&&(n=Object.prototype.toString.call(e));break;case"blob":case"document":case"arraybuffer":default:typeof e<"u"&&(n=Object.prototype.toString.call(e));break}return n},gn=t=>{if(!t)return null;let e;if(typeof t=="string"){(t[0]==="{"||t[0]==="[")&&(e=t);const n=t.split("&");n.length===1?e=t:e=n.join(",")}else if(na(t)){const n=[];for(const[s,i]of t)n.push(`${s}=${typeof i=="string"?i:"[object Object]"}`);e=n.join(",")}else t instanceof Blob||t instanceof ReadableStream||t instanceof ArrayBuffer?e="byte data":mn(t)?e=t:e=`can't parse body ${typeof t}`;return e},ta=(t,e={})=>{mn(e)||(e={});let n=t?t.split("?"):[];if(n.shift(),n.length>0){n=n.join("?").split("&");for(const s of n){const i=s.split("=");try{e[i[0]]=decodeURIComponent(i[1])}catch{e[i[0]]=i[1]}}}return e};function mn(t){return t!==null&&typeof t=="object"}function na(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Ct(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const vn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class sa{constructor(e,n){this.resp=e,this.item=n,this.mockReader()}set(e,n,s){return Reflect.set(e,n,s)}get(e,n){const s=Reflect.get(e,n);switch(n){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=n.toLowerCase(),s.apply(e).then(i=>(this.item.response=Qe(this.item.responseType,i),i)))}return typeof s=="function"?s.bind(e):s}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const n=this.resp.body.getReader;this.resp.body.getReader=()=>{const s=n.apply(this.resp.body);if(this.item.readyState===be.DONE)return s;const i=s.read,r=s.cancel;return this.item.responseType="arraybuffer",s.read=()=>i.apply(s).then(o=>{if(!e)e=new Uint8Array(o.value);else{const u=new Uint8Array(e.length+o.value.length);u.set(e),u.set(o.value,e.length),e=u}return this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.readyState=o.done?4:3,this.item.statusText=o.done?String(this.item.status):"Loading",this.item.responseSize=e.length,this.item.responseSizeText=Ct(this.item.responseSize),o.done&&(this.item.response=Qe(this.item.responseType,e)),o}),s.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=Qe(this.item.responseType,e),r.apply(s,o)),s}}}class ia{constructor(e,n,s,i,r,o){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.sendMessage=i,this.isServiceUrl=r,this.tokenUrlMatcher=o}apply(e,n,s){const i=s[0],r=s[1];if(!i||typeof i!="string"&&!(i!=null&&i.url)||(i instanceof URL||typeof i=="string"?this.isServiceUrl(String(i)):this.isServiceUrl(String(i.url))))return e.apply(window,s);const u=new pn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(u,i,r),this.setSessionTokenHeader((c,l)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(u.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(c,l);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(c,l):Array.isArray(s[1].headers)?s[1].headers.push([c,l]):s[1].headers[c]=l}}),e.apply(window,s).then(this.afterFetch(u)).catch(c=>{throw u.endTime=performance.now(),u.duration=u.endTime-(u.startTime||u.endTime),c})}beforeFetch(e,n,s){let i,r="GET",o={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=vn(n),o=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=vn(n.url),o=n.headers),e.method=r,e.requestType="fetch",e.requestHeader=o,e.url=i.toString(),e.name=(i.pathname.split("/").pop()||"")+i.search,e.status=0,e.statusText="Pending",e.readyState=1,e.startTime||(e.startTime=performance.now()),Object.prototype.toString.call(o)==="[object Headers]"){e.requestHeader={};for(const[u,c]of o)e.requestHeader[u]=c}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[u,c]of i.searchParams)e.getData[u]=c}s!=null&&s.body&&(e.requestData=gn(s.body))}afterFetch(e){return n=>{e.endTime=performance.now(),e.duration=e.endTime-(e.startTime||e.endTime),e.status=n.status,e.statusText=String(n.status);let s=!1;e.header={};for(const[i,r]of n.headers)e.header[i]=r,s=r.toLowerCase().indexOf("chunked")>-1?!0:s;return s?e.readyState=3:(e.readyState=4,this.handleResponseBody(n.clone(),e).then(i=>{e.responseSize=typeof i=="string"?i.length:i.byteLength,e.responseSizeText=Ct(e.responseSize),e.response=Qe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new sa(n,e))}}handleResponseBody(e,n){const s=e.headers.get("content-type");return s&&s.includes("application/json")?(n.responseType="json",e.text()):s&&(s.includes("text/html")||s.includes("text/plain"))?(n.responseType="text",e.text()):(n.responseType="arraybuffer",e.arrayBuffer())}}class ra{static create(e,n,s,i,r,o){return new Proxy(fetch,new ia(e,n,s,i,r,o))}}class oa{constructor(e,n,s,i,r,o,u){this.ignoredHeaders=n,this.setSessionTokenHeader=s,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=o,this.tokenUrlMatcher=u,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new pn(n,s,i),this.item.requestType="xhr"}get(e,n){switch(n){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const s=Reflect.get(e,n);return typeof s=="function"?s.bind(e):s}}set(e,n,s){switch(n){case"onreadystatechange":return this.setOnReadyStateChange(e,n,s);case"onabort":return this.setOnAbort(e,n,s);case"ontimeout":return this.setOnTimeout(e,n,s)}return Reflect.set(e,n,s)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=Qe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===be.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const n=Reflect.get(e,"open");return(...s)=>{var o,u;const i=s[0],r=s[1];return this.item.method=i?i.toUpperCase():"GET",this.item.url=((o=r.toString)==null?void 0:o.call(r))||"",this.item.name=((u=this.item.url)==null?void 0:u.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=ta(this.item.url,{}),n.apply(e,s)}}getSend(e){const n=Reflect.get(e,"send");return(...s)=>{const i=s[0];return this.item.requestData=gn(i),n.apply(e,s)}}getSetRequestHeader(e){const n=Reflect.get(e,"setRequestHeader");return(...s)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[s[0]]=s[1],n.apply(e,s))}setOnReadyStateChange(e,n,s){return Reflect.set(e,n,(...i)=>{this.onReadyStateChange(),s==null||s.apply(e,i)})}setOnAbort(e,n,s){return Reflect.set(e,n,(...i)=>{this.onAbort(),s.apply(e,i)})}setOnTimeout(e,n,s){return Reflect.set(e,n,(...i)=>{this.onTimeout(),s.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case be.UNSENT:case be.OPENED:this.item.status=be.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case be.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",n=e.split(`
20
- `);for(let s=0;s<n.length;s++){const i=n[s];if(!i)continue;const r=i.split(": "),o=r[0];this.item.header[o]=r.slice(1).join(": ")}break;case be.LOADING:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ct(this.item.responseSize));break;case be.DONE:this.item.status=this.XMLReq.status||this.item.status||0,this.item.statusText=String(this.item.status),this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=this.XMLReq.response,this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ct(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class aa{static create(e,n,s,i,r,o){return new Proxy(XMLHttpRequest,{construct(u){const c=new u;return new Proxy(c,new oa(c,e,n,s,i,r,o))}})}}const ca=t=>t instanceof Blob?t.type:t instanceof FormData?"multipart/form-data":t instanceof URLSearchParams?"application/x-www-form-urlencoded;charset=UTF-8":"text/plain;charset=UTF-8";class la{constructor(e,n,s,i,r){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.sendMessage=i,this.isServiceUrl=r}apply(e,n,s){const i=s[0],r=s[1],o=new pn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(n,s);const u=vn(i);if(o.method="POST",o.url=i,o.name=(u.pathname.split("/").pop()||"")+u.search,o.requestType="beacon",o.requestHeader={"Content-Type":ca(r)},o.status=0,o.statusText="Pending",u.search&&u.searchParams){o.getData={};for(const[a,d]of u.searchParams)o.getData[a]=d}o.requestData=gn(r),o.startTime||(o.startTime=performance.now());const c=e.apply(n,s);c?(o.endTime=performance.now(),o.duration=o.endTime-(o.startTime||o.endTime),o.status=0,o.statusText="Sent",o.readyState=4):(o.status=500,o.statusText="Unknown");const l=o.getMessage();return l&&this.sendMessage(l),c}}class We{static hasSendBeacon(){return!!We.origSendBeacon}static create(e,n,s,i,r){if(We.hasSendBeacon())return new Proxy(We.origSendBeacon,new la(e,n,s,i,r))}}We.origSendBeacon=(ui=window==null?void 0:window.navigator)==null?void 0:ui.sendBeacon;const oi=t=>console.warn(`Openreplay: Can't find ${t} in global context.
21
- If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function ua(t,e,n,s,i,r,o){var u;t.XMLHttpRequest?t.XMLHttpRequest=aa.create(e,n,s,i,r,o):oi("XMLHttpRequest"),t.fetch?t.fetch=ra.create(e,n,s,i,r,o):oi("fetch"),(u=t==null?void 0:t.navigator)!=null&&u.sendBeacon&&(t.navigator.sendBeacon=We.create(e,n,s,i,r))}function bn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function ai(t){return typeof t=="string"?t.toUpperCase():"GET"}function ha(t,e={}){const n=Object.assign({failuresOnly:!1,ignoreHeaders:["cookie","set-cookie","authorization"],capturePayload:!1,sessionTokenHeader:!1,captureInIframes:!0,axiosInstances:void 0,useProxy:!0},e);n.useProxy===!1&&t.debug.warn("Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true");const s=n.ignoreHeaders,i=Array.isArray(s)?a=>s.includes(a):()=>s,r=n.sessionTokenHeader===!0?"X-OpenReplay-SessionToken":n.sessionTokenHeader;function o(a){if(r){const d=t.getSessionToken();d&&t.safe(a)(r,d)}}function u(a){if(n.capturePayload||(delete a.request.body,delete a.response.body),n.sanitizer){const d=a.response.body;if(typeof d=="string")try{a.response.body=JSON.parse(d)}catch{}return n.sanitizer(a)}return a}function c(a){if(a&&typeof a.body!="string")try{a.body=JSON.stringify(a.body)}catch{a.body="<unable to stringify>",t.notify.warn("Openreplay fetch couldn't stringify body:",a.body)}return JSON.stringify(a)}const l=a=>{if(n.useProxy)return ua(a,n.ignoreHeaders,o,u,R=>t.send(R),R=>t.isServiceURL(R),n.tokenUrlMatcher);const d=a.fetch.bind(a),p=(R,E={})=>{if(!(typeof R=="string"||R instanceof URL)||t.isServiceURL(String(R)))return d(R,E);o(function(D,L){E.headers===void 0&&(E.headers={}),E.headers instanceof Headers?E.headers.append(D,L):Array.isArray(E.headers)?E.headers.push([D,L]):E.headers[D]=L});const N=performance.now();return d(R,E).then(D=>{const L=performance.now()-N;if(n.failuresOnly&&D.status<400)return D;const I=D.clone();return I.text().then(T=>{const P={},H={};if(s!==!0){const _=([M,V])=>{i(M)||(P[M]=V)};E.headers instanceof Headers?E.headers.forEach((M,V)=>_([V,M])):Array.isArray(E.headers)?E.headers.forEach(_):typeof E.headers=="object"&&Object.entries(E.headers).forEach(_),I.headers.forEach((M,V)=>{i(V)||(H[V]=M)})}const j=ai(E.method),z=u({url:String(R),method:j,status:I.status,request:{headers:P,body:E.body||null},response:{headers:H,body:T}});z&&t.send(pt("fetch",j,String(z.url),c(z.request),c(z.response),I.status,N+ze(),L,0))}).catch(T=>t.debug.error("Could not process Fetch response:",T)),D})};a.fetch=p;const v=a.XMLHttpRequest.prototype.open,w=a.XMLHttpRequest.prototype.setRequestHeader,y=a.XMLHttpRequest.prototype.send;function x(R,E){const N=this;o((L,I)=>N.setRequestHeader(L,I));let D=0;return N.addEventListener("loadstart",L=>{D=L.timeStamp}),N.addEventListener("load",t.safe(L=>{const{headers:I,body:T}=bn(N),P=D>0?L.timeStamp-D:0,j=(N.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),z={};j.forEach(function(V){const G=V.split(": "),$=G.shift();i($)||(z[$]=G.join(": "))});const _=ai(R),M=u({url:String(E),method:_,status:N.status,request:{headers:I,body:T||null},response:{headers:z,body:N.response}});M&&t.send(pt("xhr",_,String(M.url),c(M.request),c(M.response),N.status,D+ze(),P,0))})),v.apply(this,arguments)}function C(R){const E=bn(this);return E.body=R,y.apply(this,arguments)}function F(R,E){if(!i(R)){const N=bn(this);N.headers[R]=E}return w.apply(this,arguments)}n.axiosInstances||(a.XMLHttpRequest.prototype.open=x,a.XMLHttpRequest.prototype.send=C,a.XMLHttpRequest.prototype.setRequestHeader=F)};l(window),n.axiosInstances&&n.axiosInstances.forEach(a=>{Qo(t,a,n,u,c)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(l))}function da(t){t.attachEventListener(document,"selectionchange",()=>{const e=document.getSelection();if(e!==null&&!e.isCollapsed){const n=t.nodes.getID(e.anchorNode),s=t.nodes.getID(e.focusNode),i=e.toString().replace(/\s+/g," ");n&&s&&t.send(xs(n,s,i))}else t.send(xs(-1,-1,""))})}function fa(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(gt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const _t="/installation/javascript-sdk";function pa(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${ft}${_t}`),!1;if(typeof t.projectKey!="string")if(typeof t.projectKey!="number"){if(typeof t.projectID!="number")return console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${ft}${_t} for more information.`),!1;t.projectKey=t.projectID.toString(),Ce("`projectID` option","`projectKey` option",_t)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ce("`sessionToken` option","`sessionHash` start() option","/"),!0}class ga{constructor(e){var u;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(c,l)=>{const a=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||Bs;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:a,reason:l.length?`missing api: ${l.join(",")}`:c}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(c,l={})=>{if(this.app!==null){if(c instanceof Error){const a=St(c,[],l);this.app.send(a)}else if(c instanceof ErrorEvent||"PromiseRejectionEvent"in window&&c instanceof PromiseRejectionEvent){const a=qs(c,void 0,l);a!=null&&this.app.send(a)}}},this.crossdomainMode=!!(Hi()&&((u=e.crossdomain)!=null&&u.enabled)),!me||!pa(e))return;if(window.__OPENREPLAY__){console.error("OpenReplay: one tracker instance has been initialised already");return}if(!e.__DISABLE_SECURE_MODE&&location.protocol!=="https:"){console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");return}const n=this.checkDoNotTrack(),s=[],i=["Map","Set","MutationObserver","performance","timing","startsWith","Blob","Worker"];if(n)s.push("doNotTrack");else for(const c of i)if(c==="timing"){if("performance"in window&&!(c in performance)){s.push(c);break}}else if(c==="startsWith"){if(!(c in String.prototype)){s.push(c);break}}else if(!(c in window)){s.push(c);break}if(s.length>0){const c=s.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${c}`),this.signalStartIssue("missing_api",s);return}const r=new ho(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(Vo(r),fo(r),Tr(r,e),fa(r)),Uo(r,e.mouse),qo(r,this.crossdomainMode),Jo(r),Ko(r),vo(r,e),So(r,e),Eo(r),No(r,e),Wo(r,e),Xo(r),Yo(r),ha(r,e.network),da(r),window.__OPENREPLAY__=this,e.flags&&e.flags.onFlagsLoad&&this.onFlagsLoad(e.flags.onFlagsLoad);const o=window.open;(e.autoResetOnWindowOpen||e.resetTabOnWindowOpen)&&(r.attachStartCallback(()=>{const c=r.getTabId(),l=r.sessionStorage??window.sessionStorage;window.open=function(...a){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&l.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),l.setItem(e.session_tabid_key||"__openreplay_tabid",c),o.call(window,...a)}}),r.attachStopCallback(()=>{window.open=o}))}isFlagEnabled(e){return this.featureFlags.isFlagEnabled(e)}onFlagsLoad(e){var n;(n=this.app)==null||n.featureFlags.onFlagsLoad(e)}clearPersistFlags(){var e;(e=this.app)==null||e.featureFlags.clearPersistFlags()}reloadFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.reloadFlags()}getFeatureFlag(e){var n;return(n=this.app)==null?void 0:n.featureFlags.getFeatureFlag(e)}getAllFeatureFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.flags}use(e){return e(this.app,this.options)}isActive(){return this.app===null?!1:this.app.active()}trackWs(e){if(this.app!==null)return this.app.trackWs(e)}start(e){return this.browserEnvCheck()?this.app===null?Promise.reject("Browser doesn't support required api, or doNotTrack is active."):this.app.start(e):Promise.reject("Trying to start not in browser.")}browserEnvCheck(){return me?!0:(console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${ft}${_t}`),!1)}coldStart(e,n){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,n)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,n){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,n):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return Ce("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){Ce("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(lr(e))}userAnonymousID(e){Ce("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,n){typeof e=="string"&&typeof n=="string"&&this.app!==null&&this.app.session.setMetadata(e,n)}metadata(e,n){Ce("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,n)}event(e,n=null,s=!1){if(typeof e=="string"&&this.app!==null){if(s)return this.issue(e,n);try{n=JSON.stringify(n)}catch{return}this.app.send(ar(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(gr(e,n))}}}const ma=`
19
+ `).filter(function(a){return!!a.match(i)&&!a.match(/^Error created at/)},this);return l.map(function(a){var d=a.split("@"),p=this.extractLocation(d.pop()),v=d.shift()||"",w=v.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;v.match(/\(([^)]*)\)/)&&(y=v.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var x=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:w,args:x,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:a})},this)}}})})(Hs);var yo=Hs.exports;const wo=yi(yo);function Ws(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function St(t,e,n={}){let s=e;try{s=wo.parse(t)}catch{}return Gt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function qs(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return St(t.error,Ws(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),Gt(s,i,JSON.stringify(Ws(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return St(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return Gt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function So(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(o){const u=qs(o,i);u!=null&&t.send(u)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}n.captureExceptions&&(t.observer.attachContextCallback(s),s(window))}function Vs(t,e=document.location){return t=t.trim(),t.startsWith("//")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")?t:t.startsWith("/")?e.origin+t:e.origin+e.pathname+t}function xo(t){return Bi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const ko="https://static.openreplay.com/tracker/placeholder.jpeg";function Eo(t){function e(u,c){t.attributeSender.sendSetAttribute(u,"src",ko);const{width:l,height:a}=c.getBoundingClientRect();c.hasAttribute("width")||t.attributeSender.sendSetAttribute(u,"width",String(l)),c.hasAttribute("height")||t.attributeSender.sendSetAttribute(u,"height",String(a))}const n=function(u,c){const{srcset:l}=c;if(!l)return;const a=l.split(l.match(/,\s+/)?/,\s+/:",").map(d=>Vs(d)).join(", ");t.attributeSender.sendSetAttribute(u,"srcset",a)},s=function(u,c){c.src.length>ji&&e(u,c),t.send(Wt(u,"src",c.src,t.getBaseHref()))},i=t.safe(function(u){const c=Vs(u.src||"");cs(c)&&t.send(ks(t.timestamp(),0,0,0,0,0,c,"img",0,!1))}),r=t.safe(function(u){const c=t.nodes.getID(u);c!==void 0&&u.complete&&(u.naturalHeight===0&&u.naturalWidth===0&&!xo(u.src)?i(u):t.sanitizer.isHidden(c)||t.sanitizer.isObscured(c)?e(c,u):(s(c,u),n(c,u)))}),o=hs(t.safe(u=>{for(const c of u)if(c.type==="attributes"){const l=c.target,a=t.nodes.getID(l);if(a===void 0)return;c.attributeName==="src"&&s(a,l),c.attributeName==="srcset"&&n(a,l)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(u=>{Q(u,"img")&&(t.nodes.attachNodeListener(u,"error",()=>i(u)),t.nodes.attachNodeListener(u,"load",()=>r(u)),r(u),o.observe(u,{attributes:!0,attributeFilter:["src","srcset"]}))})}const To=["text","password","email","search","number","range","date","tel","time"];function Io(t){return Q(t,"textarea")?!0:Q(t,"input")?To.includes(t.type):!1}function Co(t){if(!Q(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const _o=ve&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.labels;if(n!==null&&n.length===1)return n[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.id;if(n){const s=t.ownerDocument.querySelectorAll('label[for="'+n+'"]');if(s!==null&&s.length===1)return s[0]}};function Gs(t){let e=Ht(t);if(e===null){const n=_o(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return as(e).slice(0,100)}const $e={Plain:0,Obscured:1,Hidden:2};function No(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:$e.Obscured,obscureInputDates:!1},e);function s(a,d){let p=d.value,v=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(a)?v=$e.Hidden:(t.sanitizer.isObscured(a)||v===$e.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(v=$e.Obscured);let w=0;switch(v){case $e.Hidden:w=-1,p="";break;case $e.Obscured:w=p.length,p="";break}return{value:p,mask:w}}function i(a,d){const{value:p,mask:v}=s(a,d);t.send(tr(a,p,v))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function u(a,d){r.get(a)!==d.value&&(r.set(a,d.value),i(a,d))}function c(a,d){o.get(a)!==d&&(o.set(a,d),t.send(nr(a,d)))}t.ticker.attach(()=>{r.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);u(d,p)}),o.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return o.delete(d);c(d,p.checked)})},3);function l(a,d,p,v){const{value:w,mask:y}=s(a,d),x=Gs(d);t.send(yr(a,w,y!==0,x,p,v))}t.nodes.attachNodeCallback(t.safe(a=>{const d=t.nodes.getID(a);if(d!==void 0){if(Q(a,"select")&&(i(d,a),t.nodes.attachNodeListener(a,"change",()=>i(d,a))),Io(a)){u(d,a);let p=0,v=0,w=0;const y=()=>{p=fe()},x=()=>{v===0&&p!==0&&(v=fe()-p)},C=()=>{p!==0&&(w=fe()-p),l(d,a,v,w),v=0,w=0,p=0};t.nodes.attachNodeListener(a,"focus",y),t.nodes.attachNodeListener(a,"input",x),t.nodes.attachNodeListener(a,"change",C);return}if(Co(a)){c(d,a.checked),t.nodes.attachNodeListener(a,"change",()=>c(d,a.checked));return}}}))}let le,un,Ks;function Oo(t,e){if(Ks=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";const n={root:document.body,idName:i=>!0,className:i=>!0,tagName:i=>!0,attr:(i,r)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};le={...n,...e},un=Ro(le.root,n);let s=xt(t,"all",()=>xt(t,"two",()=>xt(t,"one",()=>xt(t,"none"))));if(s){const i=ei(ti(s,t));return i.length>0&&(s=i[0]),kt(s)}else throw new Error("Selector was not found.")}function Ro(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function xt(t,e,n){let s=null,i=[],r=t,o=0;for(;r;){const u=new Date().getTime()-Ks.getTime();if(le.timeoutMs!==void 0&&u>le.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${u}ms`);let c=Tt(Do(r))||Tt(...Lo(r))||Tt(...Ao(r))||Tt(Mo(r))||[Qs()];const l=Fo(r);if(e=="all")l&&(c=c.concat(c.filter(hn).map(a=>Et(a,l))));else if(e=="two")c=c.slice(0,1),l&&(c=c.concat(c.filter(hn).map(a=>Et(a,l))));else if(e=="one"){const[a]=c=c.slice(0,1);l&&hn(a)&&(c=[Et(a,l)])}else e=="none"&&(c=[Qs()],l&&(c=[Et(c[0],l)]));for(let a of c)a.level=o;if(i.push(c),i.length>=le.seedMinLength&&(s=Js(i,n),s))break;r=r.parentElement,o++}return s||(s=Js(i,n)),!s&&n?n():s}function Js(t,e){const n=ei(Zs(t));if(n.length>le.threshold)return e?e():null;for(let s of n)if(Ys(s))return s;return null}function kt(t){let e=t[0],n=e.name;for(let s=1;s<t.length;s++){const i=t[s].level||0;e.level===i-1?n=`${t[s].name} > ${n}`:n=`${t[s].name} ${n}`,e=t[s]}return n}function Xs(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ys(t){const e=kt(t);switch(un.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function Do(t){const e=t.getAttribute("id");return e&&le.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Lo(t){return Array.from(t.attributes).filter(n=>le.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Ao(t){return Array.from(t.classList).filter(le.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Mo(t){const e=t.tagName.toLowerCase();return le.tagName(e)?{name:e,penalty:2}:null}function Qs(){return{name:"*",penalty:3}}function Fo(t){const e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let s=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&s++,n!==t);)n=n.nextSibling;return s}function Et(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function hn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Tt(...t){const e=t.filter(Po);return e.length>0?e:null}function Po(t){return t!=null}function*Zs(t,e=[]){if(t.length>0)for(let n of t[0])yield*Zs(t.slice(1,t.length),e.concat(n));else yield e}function ei(t){return[...t].sort((e,n)=>Xs(e)-Xs(n))}function*ti(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>le.optimizedMinLength)for(let s=1;s<t.length-1;s++){if(n.counter>le.maxNumberOfTries)return;n.counter+=1;const i=[...t];i.splice(s,1);const r=kt(i);if(n.visited.has(r))return;Ys(i)&&Bo(i,e)&&(yield i,n.visited.set(r,!0),yield*ti(i,e,n))}}function Bo(t,e){return un.querySelector(kt(t))===e}function jo(t,e,n){return Oo(t,{root:e.body,seedMinLength:3,optimizedMinLength:(n==null?void 0:n.minSelectorDepth)||2,threshold:(n==null?void 0:n.nthThreshold)||1e3,maxNumberOfTries:(n==null?void 0:n.maxOptimiseTries)||1e4})}function dn(t){const e=t.tagName.toUpperCase();return e==="BUTTON"||e==="A"||e==="LI"||e==="SELECT"||e==="TR"||e==="TH"||t.onclick!=null||t.getAttribute("role")==="button"}function ni(t,e){return t instanceof Element?zo(t,e):null}function zo(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Re(n,"masked"))return null;n=n.parentElement}if(Zt(t)){let s=t.ownerSVGElement;for(;s!==null;)t=s,s=s.ownerSVGElement}for(n=t;n!==null&&n!==e.documentElement;){const s=n.tagName.toUpperCase();if(s==="LABEL")return null;if(s==="INPUT"||dn(n)||Ht(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function Uo(t,e){const{disableClickmaps:n=!1}=e||{};function s(E){const N=Ht(E);if(N!==null)return N;if(Q(E,"input"))return Gs(E);if(dn(E)){let D="";return E instanceof HTMLElement&&(D=t.sanitizer.getInnerTextSecure(E)),D=D||E.id||E.className,as(D).slice(0,100)}return""}let i=-1,r=-1,o=!1,u=null,c=0,l={},a=0,d=0,p=0,v=0,w;const y=.008,x=225;function C(){const E=v/x;if(!a){a=E;return}const N=(E-a)/x;p>4&&N>y&&t.send(wr(fe())),v=0,p=0,a=E}t.attachStartCallback(()=>{w=setInterval(()=>C(),x)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,u=null,l={},w&&clearInterval(w)});const F=()=>{o&&(t.send(sr(i,r)),o=!1)},R=(E,N=!1)=>{function D(I,T,P){return l[I]=l[I]||jo(T,E,P)}const L=N?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);L(E.documentElement,"mouseover",I=>{const T=ni(I.target,E);T!==u&&(u=T,c=performance.now())}),L(E,"mousemove",I=>{const[T,P]=t.observer.getDocumentOffset(E);i=I.clientX+T,r=I.clientY+P,o=!0;const H=Math.sign(I.movementX);v+=Math.abs(I.movementX)+Math.abs(I.movementY),H!==d&&(d=H,p++)},!1),L(E,"click",I=>{const T=ni(I.target,E);if(!I.clientX&&!I.clientY||T===null)return;const P=t.nodes.getID(T);if(P!==void 0){const H=I.pageX,j=I.pageY,z=E.documentElement.scrollWidth,_=E.documentElement.scrollHeight,M=si(H/z),V=si(j/_);F(),t.send(mr(P,u===T?Math.round(performance.now()-c):0,s(T),dn(T)&&!n?D(P,T,e):"",M,V),!0)}u=null})};t.nodes.attachNodeCallback(E=>{bt(E)&&R(E)}),R(document,!0),t.ticker.attach(F,(e==null?void 0:e.trackingOffset)||7)}function si(t){return Math.round(t*1e4)}function Ho(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let o="";if(Q(r,"img")&&(o=r.currentSrc||r.src),!o){const w=getComputedStyle(r).getPropertyValue("background-image");if(w){const y=s.exec(w);y!==null&&(o=y[1],(o.startsWith('"')||o.startsWith("'"))&&(o=o.substr(1,o.length-2)))}}if(!o)continue;const u=o.substr(0,10)==="data:image"?0:t[o];if(u===void 0)continue;const c=r.getBoundingClientRect(),l=Math.max(c.top,0),a=Math.max(c.left,0),d=Math.min(c.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),p=Math.min(c.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(d<=l||p<=a)continue;const v=(d-l)*(p-a);e.push({time:u,area:v})}return e}function $o(t,e){let n=Math.max(document.documentElement&&document.documentElement.clientWidth||0,window.innerWidth||0)*Math.max(document.documentElement&&document.documentElement.clientHeight||0,window.innerHeight||0)/10,s=n*t;for(let i=0;i<e.length;i++){const{time:r,area:o}=e[i];n+=o,s+=o*(r>t?r:t)}return n===0?0:s/n}function Wo(t,e){const n=Object.assign({captureResourceTimings:!0,capturePageLoadTimings:!0,capturePageRenderTimings:!0,excludedResourceUrls:[]},e);if("PerformanceObserver"in window||(n.captureResourceTimings=!1),!n.captureResourceTimings)return;let s={};function i(l){var d;if(l.duration<0||!cs(l.name)||t.isServiceURL(l.name))return;s!==null&&(s[l.name]=l.startTime+l.duration);let a=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(l.name.startsWith(p)){a=!0;return}}),!a&&t.send(ks(l.startTime+ze(),l.duration,l.responseStart&&l.startTime?l.responseStart-l.startTime:0,l.transferSize>l.encodedBodySize?l.transferSize-l.encodedBodySize:0,l.encodedBodySize||0,l.decodedBodySize||0,l.name,l.initiatorType,l.transferSize,l.responseStatus&&l.responseStatus===304||l.transferSize===0))}const r=new PerformanceObserver(l=>l.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:l}){l!==o&&(performance.getEntriesByType("resource").forEach(i),o=l),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let u=0,c=0;if(n.capturePageLoadTimings){let l=!1;t.ticker.attach(()=>{if(!l&&((u===0||c===0)&&performance.getEntriesByType("paint").forEach(a=>{const{name:d,startTime:p}=a;switch(d){case"first-paint":u=p;break;case"first-contentful-paint":c=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){l=!0;const{navigationStart:a,requestStart:d,responseStart:p,responseEnd:v,domContentLoadedEventStart:w,domContentLoadedEventEnd:y,loadEventStart:x,loadEventEnd:C}=performance.timing;t.send(rr(d-a||0,p-a||0,v-a||0,w-a||0,y-a||0,x-a||0,C-a||0,u,c))}},30)}if(n.capturePageRenderTimings){let l=0,a=0,d=0,p=null,v=!1;t.ticker.attach(()=>{if(v)return;const w=performance.now();if(s!==null&&(l=Math.max.apply(null,Object.keys(s).map(y=>s[y])),w-l>1e3&&(p=Ho(s),s=null)),d!==null&&(w-d>50&&(a=w),d=w-a>5e3?null:w),p!==null&&d===null||w>3e4){v=!0,s=null;const y=p===null?0:$o(c||u,p),{domContentLoadedEventEnd:x,navigationStart:C}=performance.timing,F=d===null?Math.max(a,c,x-C||0):0;t.send(or(y,c>l?c:l,F))}})}}function fn(t){const e=t.defaultView;return[e&&e.scrollX||t.documentElement&&t.documentElement.scrollLeft||t.body&&t.body.scrollLeft||0,e&&e.scrollY||t.documentElement&&t.documentElement.scrollTop||t.body&&t.body.scrollTop||0]}function qo(t,e){let n=!1;const s=new Map;function i(u){As(u)&&(ke(u)&&s.set(u,[u.scrollLeft,u.scrollTop]),bt(u)&&s.set(u,fn(u)))}const r=t.safe(()=>{e||t.send(Gi(...fn(document)))}),o=t.safe((u,c)=>{const l=t.nodes.getID(c);l!==void 0&&t.send(er(l,u[0],u[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((u,c)=>{c&&(ke(u)&&u.scrollLeft+u.scrollTop>0?s.set(u,[u.scrollLeft,u.scrollTop]):bt(u)&&s.set(u,fn(u))),yt(u)&&t.nodes.attachNodeListener(u,"scroll",l=>{i(l.target)})}),t.attachEventListener(document,"scroll",u=>{const c=u.target;if(c===document){n=!0;return}i(c)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(o),s.clear()},5,!1)}function Vo(t){let e,n,s,i,r=document.referrer;const o=t.safe(()=>{const{URL:l}=document;l!==e&&(e=l,t.send(Er(e,r,i,document.title)),i=0,r=e)}),u=t.safe(()=>{const{innerWidth:l,innerHeight:a}=window;(l!==n||a!==s)&&(n=l,s=a,t.send(Vi(n,s)))}),c=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(dr(document.hidden)));t.attachStartCallback(()=>{e=null,i=ze(),n=s=-1,o(),u(),c()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",c,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(u,5,!1)}function ii(t){return yt(t)&&!!t.adoptedStyleSheets}let Go=15;function ri(){return Go++}const It=new Map;function Ko(t){if(t===null||!ii(document))return;const e=new Map,n=new Map,s=o=>setTimeout(()=>{let u=t.nodes.getID(o);if(o===document&&(u=0),u===void 0)return;let c=n.get(u);c||(c=[]);const l=[],a=o.adoptedStyleSheets;if(a&&Symbol.iterator in a)for(const d of a){let p=e.get(d);const v=!p;if(p||(p=ri(),e.set(d,p)),c.includes(p)||t.send(Ss(p,u)),v){const w=d.cssRules;for(let y=0;y<w.length;y++)t.send(Vt(p,w[y].cssText,y,t.getBaseHref()))}l.push(p)}if(Symbol.iterator in c)for(const d of c)l.includes(d)||t.send(vr(d,u));n.set(u,l)},20);function i(o){const u=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");u&&Object.defineProperty(o,"adoptedStyleSheets",{...u,set:function(c){const l=u.set.call(this,c);return s(this),l}})}const r=o=>{if(o.__openreplay_adpss_patched__)return;o.__openreplay_adpss_patched__=!0,i(o.Document.prototype),i(o.ShadowRoot.prototype);const{replace:u,replaceSync:c}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(l){return u.call(this,l).then(a=>{const d=e.get(this);return d&&t.send(ys(d,l,t.getBaseHref())),a})},o.CSSStyleSheet.prototype.replaceSync=function(l){const a=e.get(this);return a&&t.send(ys(a,l,t.getBaseHref())),c.call(this,l)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(o=>{ii(o)&&s(o)})}function Jo(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(pr("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const u=It.get(i);u&&(typeof o=="string"?t.send(Vt(u,o,r,t.getBaseHref())):t.send(ws(u,r)))}),n=t.safe(i=>{let r=i;for(;r.parentRule;)r=r.parentRule;const o=r.parentStyleSheet;if(!o){t.debug.warn("No parent StyleSheet found for",r,i);return}const u=It.get(o);if(!u){t.debug.warn("No sheedID found for",o,It);return}const c=r.cssText,l=o.cssRules,a=Array.from(l).indexOf(r);a>=0?(t.send(Vt(u,c,a,t.getBaseHref())),t.send(ws(u,a+1))):t.debug.warn("Rule index not found in",o,r)}),s=t.safe(i=>{const{insertRule:r,deleteRule:o}=i.CSSStyleSheet.prototype,{insertRule:u,deleteRule:c}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(l,a=0){return e(this,a,l),r.call(this,l,a)},i.CSSStyleSheet.prototype.deleteRule=function(l){return e(this,l),o.call(this,l)},i.CSSGroupingRule.prototype.insertRule=function(l,a=0){const d=u.call(this,l,a);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(l=0){const a=c.call(this,l);return n(this),a}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Q(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,u=ri();It.set(o,u),t.send(Ss(u,r));const c=o.cssRules;for(let l=0;l<c.length;l++)e(o,l,c[l].cssText)})}function Xo(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(bs(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Q(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{As(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(bs(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Q(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function Yo(t){if(!window.FontFace)return;const e=new Map,n=s=>{class i extends s.FontFace{constructor(...o){if(typeof o[1]=="string"){let u="";o[2]&&t.safe(()=>{u=JSON.stringify(o[2])});const c=[o[0],o[1],u],l=e.get(s.document)||[];l.push(c),e.set(s.document,l);const a=s===window?0:t.nodes.getID(s.document);if(a===void 0)return;t.active()&&t.send(vs(a,...c))}super(...o)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!bt(s))return;const i=e.get(s);if(!i)return;const r=s.defaultView===window?0:t.nodes.getID(s);r!==void 0&&i.forEach(o=>{t.send(vs(r,...o))})}))}function Qo(t,e,n,s,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(p){t.debug.log("Openreplay: capturing axios response data",p);const{headers:v,data:w,method:y,url:x,baseURL:C}=p.config,{data:F,headers:R,status:E,response:N}=p,{data:D,headers:L,status:I}=N||{},T=n.ignoreHeaders,P=Array.isArray(T)?$=>T.includes($):()=>T;function H($,b){P(b[0])||($[b[0]]=b[1])}let j={},z={};v.toJSON?j=v.toJSON():v instanceof Headers?v.forEach(($,b)=>H(j,[b,$])):Array.isArray(v)?v.forEach($=>H(j,$)):typeof v=="object"&&Object.entries(v).forEach($=>H(j,$));const _=L||R;_.toJSON?z=_.toJSON():_ instanceof Headers?_.forEach(($,b)=>H(z,[b,$])):Array.isArray(_)?_.forEach($=>H(z,$)):typeof _=="object"&&Object.entries(_).forEach(([$,b])=>{P($)||(z[$]=b)});const M=s({url:x,method:y||"",status:E||I||0,request:{headers:j,body:w},response:{headers:z,body:D||F}});if(!M){t.debug.log("Openreplay: empty request/response info, skipping");return}const V=p.config.__openreplay_timing,G=performance.now()-V;t.debug.log("Openreplay: final req object",M),t.send(pt("xhr",String(y),String(M.url),i(M.request),i(M.response),M.status,V+ze(),G,0))}function o(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const v=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",w=t.getSessionToken();w&&p.headers.set(v,w)}return p}function u(p){return n.failuresOnly||r(p),p}function c(p){return t.debug.log("Openreplay: capturing API request error",p),Zo(p)&&p.response?r(p.response):p instanceof Error&&t.send(St(p,[])),Promise.reject(p)}function l(p){t.debug.log("Openreplay: failed API request, skipping",p)}const a=e.interceptors.request.use(o,l,{synchronous:!0}),d=e.interceptors.response.use(u,c,{synchronous:!0});t.attachStopCallback(()=>{var p,v,w,y;(v=(p=e.interceptors.request).eject)==null||v.call(p,a),(y=(w=e.interceptors.response).eject)==null||y.call(w,d)})}function Zo(t){return ea(t)&&t.isAxiosError===!0}function ea(t){return t!==null&&typeof t=="object"}var ye;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(ye||(ye={}));class pn{constructor(e=[],n,s){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.id="",this.name="",this.method="",this.url="",this.status=0,this.statusText="",this.cancelState=0,this.readyState=0,this.header={},this.responseType="",this.requestHeader={},this.responseSize=0,this.responseSizeText="",this.startTime=0,this.endTime=0,this.duration=0,this.getData={},this.requestData=null}getMessage(){const{reqHs:e,resHs:n}=this.writeHeaders(),s={headers:e,body:this.method==="GET"?JSON.stringify(this.getData):this.requestData},i={headers:n,body:this.response},r=this.sanitize({url:this.url,method:this.method,status:this.status,request:s,response:i});if(r)return pt(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+ze(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([s,i])=>{this.isHeaderIgnored(s)||(e[s]=i)}),this.setSessionTokenHeader((s,i)=>{e[s]=i});const n={};return Object.entries(this.header).forEach(([s,i])=>{this.isHeaderIgnored(s)||(n[s]=i)}),{reqHs:e,resHs:n}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(n=>n.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const Qe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:mn(e)||Array.isArray(e)?n=JSON.stringify(e):typeof e<"u"&&(n=Object.prototype.toString.call(e));break;case"blob":case"document":case"arraybuffer":default:typeof e<"u"&&(n=Object.prototype.toString.call(e));break}return n},gn=t=>{if(!t)return null;let e;if(typeof t=="string"){(t[0]==="{"||t[0]==="[")&&(e=t);const n=t.split("&");n.length===1?e=t:e=n.join(",")}else if(na(t)){const n=[];for(const[s,i]of t)n.push(`${s}=${typeof i=="string"?i:"[object Object]"}`);e=n.join(",")}else t instanceof Blob||t instanceof ReadableStream||t instanceof ArrayBuffer?e="byte data":mn(t)?e=t:e=`can't parse body ${typeof t}`;return e},ta=(t,e={})=>{mn(e)||(e={});let n=t?t.split("?"):[];if(n.shift(),n.length>0){n=n.join("?").split("&");for(const s of n){const i=s.split("=");try{e[i[0]]=decodeURIComponent(i[1])}catch{e[i[0]]=i[1]}}}return e};function mn(t){return t!==null&&typeof t=="object"}function na(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Ct(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const vn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class sa{constructor(e,n){this.resp=e,this.item=n,this.mockReader()}set(e,n,s){return Reflect.set(e,n,s)}get(e,n){const s=Reflect.get(e,n);switch(n){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=n.toLowerCase(),s.apply(e).then(i=>(this.item.response=Qe(this.item.responseType,i),i)))}return typeof s=="function"?s.bind(e):s}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const n=this.resp.body.getReader;this.resp.body.getReader=()=>{const s=n.apply(this.resp.body);if(this.item.readyState===ye.DONE)return s;const i=s.read,r=s.cancel;return this.item.responseType="arraybuffer",s.read=()=>i.apply(s).then(o=>{if(!e)e=new Uint8Array(o.value);else{const u=new Uint8Array(e.length+o.value.length);u.set(e),u.set(o.value,e.length),e=u}return this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.readyState=o.done?4:3,this.item.statusText=o.done?String(this.item.status):"Loading",this.item.responseSize=e.length,this.item.responseSizeText=Ct(this.item.responseSize),o.done&&(this.item.response=Qe(this.item.responseType,e)),o}),s.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=Qe(this.item.responseType,e),r.apply(s,o)),s}}}class ia{constructor(e,n,s,i,r,o){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.sendMessage=i,this.isServiceUrl=r,this.tokenUrlMatcher=o}apply(e,n,s){const i=s[0],r=s[1];if(!i||typeof i!="string"&&!(i!=null&&i.url)||(i instanceof URL||typeof i=="string"?this.isServiceUrl(String(i)):this.isServiceUrl(String(i.url))))return e.apply(window,s);const u=new pn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(u,i,r),this.setSessionTokenHeader((c,l)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(u.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(c,l);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(c,l):Array.isArray(s[1].headers)?s[1].headers.push([c,l]):s[1].headers[c]=l}}),e.apply(window,s).then(this.afterFetch(u)).catch(c=>{throw u.endTime=performance.now(),u.duration=u.endTime-(u.startTime||u.endTime),c})}beforeFetch(e,n,s){let i,r="GET",o={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=vn(n),o=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=vn(n.url),o=n.headers),e.method=r,e.requestType="fetch",e.requestHeader=o,e.url=i.toString(),e.name=(i.pathname.split("/").pop()||"")+i.search,e.status=0,e.statusText="Pending",e.readyState=1,e.startTime||(e.startTime=performance.now()),Object.prototype.toString.call(o)==="[object Headers]"){e.requestHeader={};for(const[u,c]of o)e.requestHeader[u]=c}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[u,c]of i.searchParams)e.getData[u]=c}s!=null&&s.body&&(e.requestData=gn(s.body))}afterFetch(e){return n=>{e.endTime=performance.now(),e.duration=e.endTime-(e.startTime||e.endTime),e.status=n.status,e.statusText=String(n.status);let s=!1;e.header={};for(const[i,r]of n.headers)e.header[i]=r,s=r.toLowerCase().indexOf("chunked")>-1?!0:s;return s?e.readyState=3:(e.readyState=4,this.handleResponseBody(n.clone(),e).then(i=>{e.responseSize=typeof i=="string"?i.length:i.byteLength,e.responseSizeText=Ct(e.responseSize),e.response=Qe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new sa(n,e))}}handleResponseBody(e,n){const s=e.headers.get("content-type");return s&&s.includes("application/json")?(n.responseType="json",e.text()):s&&(s.includes("text/html")||s.includes("text/plain"))?(n.responseType="text",e.text()):(n.responseType="arraybuffer",e.arrayBuffer())}}class ra{static create(e,n,s,i,r,o){return new Proxy(fetch,new ia(e,n,s,i,r,o))}}class oa{constructor(e,n,s,i,r,o,u){this.ignoredHeaders=n,this.setSessionTokenHeader=s,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=o,this.tokenUrlMatcher=u,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new pn(n,s,i),this.item.requestType="xhr"}get(e,n){switch(n){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const s=Reflect.get(e,n);return typeof s=="function"?s.bind(e):s}}set(e,n,s){switch(n){case"onreadystatechange":return this.setOnReadyStateChange(e,n,s);case"onabort":return this.setOnAbort(e,n,s);case"ontimeout":return this.setOnTimeout(e,n,s)}return Reflect.set(e,n,s)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=Qe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===ye.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const n=Reflect.get(e,"open");return(...s)=>{var o,u;const i=s[0],r=s[1];return this.item.method=i?i.toUpperCase():"GET",this.item.url=((o=r.toString)==null?void 0:o.call(r))||"",this.item.name=((u=this.item.url)==null?void 0:u.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=ta(this.item.url,{}),n.apply(e,s)}}getSend(e){const n=Reflect.get(e,"send");return(...s)=>{const i=s[0];return this.item.requestData=gn(i),n.apply(e,s)}}getSetRequestHeader(e){const n=Reflect.get(e,"setRequestHeader");return(...s)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[s[0]]=s[1],n.apply(e,s))}setOnReadyStateChange(e,n,s){return Reflect.set(e,n,(...i)=>{this.onReadyStateChange(),s==null||s.apply(e,i)})}setOnAbort(e,n,s){return Reflect.set(e,n,(...i)=>{this.onAbort(),s.apply(e,i)})}setOnTimeout(e,n,s){return Reflect.set(e,n,(...i)=>{this.onTimeout(),s.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case ye.UNSENT:case ye.OPENED:this.item.status=ye.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case ye.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",n=e.split(`
20
+ `);for(let s=0;s<n.length;s++){const i=n[s];if(!i)continue;const r=i.split(": "),o=r[0];this.item.header[o]=r.slice(1).join(": ")}break;case ye.LOADING:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ct(this.item.responseSize));break;case ye.DONE:this.item.status=this.XMLReq.status||this.item.status||0,this.item.statusText=String(this.item.status),this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=this.XMLReq.response,this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ct(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class aa{static create(e,n,s,i,r,o){return new Proxy(XMLHttpRequest,{construct(u){const c=new u;return new Proxy(c,new oa(c,e,n,s,i,r,o))}})}}const ca=t=>t instanceof Blob?t.type:t instanceof FormData?"multipart/form-data":t instanceof URLSearchParams?"application/x-www-form-urlencoded;charset=UTF-8":"text/plain;charset=UTF-8";class la{constructor(e,n,s,i,r){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.sendMessage=i,this.isServiceUrl=r}apply(e,n,s){const i=s[0],r=s[1],o=new pn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(n,s);const u=vn(i);if(o.method="POST",o.url=i,o.name=(u.pathname.split("/").pop()||"")+u.search,o.requestType="beacon",o.requestHeader={"Content-Type":ca(r)},o.status=0,o.statusText="Pending",u.search&&u.searchParams){o.getData={};for(const[a,d]of u.searchParams)o.getData[a]=d}o.requestData=gn(r),o.startTime||(o.startTime=performance.now());const c=e.apply(n,s);c?(o.endTime=performance.now(),o.duration=o.endTime-(o.startTime||o.endTime),o.status=0,o.statusText="Sent",o.readyState=4):(o.status=500,o.statusText="Unknown");const l=o.getMessage();return l&&this.sendMessage(l),c}}class We{static hasSendBeacon(){return!!We.origSendBeacon}static create(e,n,s,i,r){if(We.hasSendBeacon())return new Proxy(We.origSendBeacon,new la(e,n,s,i,r))}}We.origSendBeacon=(ui=window==null?void 0:window.navigator)==null?void 0:ui.sendBeacon;const oi=t=>console.warn(`Openreplay: Can't find ${t} in global context.
21
+ If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function ua(t,e,n,s,i,r,o){var u;t.XMLHttpRequest?t.XMLHttpRequest=aa.create(e,n,s,i,r,o):oi("XMLHttpRequest"),t.fetch?t.fetch=ra.create(e,n,s,i,r,o):oi("fetch"),(u=t==null?void 0:t.navigator)!=null&&u.sendBeacon&&(t.navigator.sendBeacon=We.create(e,n,s,i,r))}function bn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function ai(t){return typeof t=="string"?t.toUpperCase():"GET"}function ha(t,e={}){const n=Object.assign({failuresOnly:!1,ignoreHeaders:["cookie","set-cookie","authorization"],capturePayload:!1,sessionTokenHeader:!1,captureInIframes:!0,axiosInstances:void 0,useProxy:!0},e);n.useProxy===!1&&t.debug.warn("Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true");const s=n.ignoreHeaders,i=Array.isArray(s)?a=>s.includes(a):()=>s,r=n.sessionTokenHeader===!0?"X-OpenReplay-SessionToken":n.sessionTokenHeader;function o(a){if(r){const d=t.getSessionToken();d&&t.safe(a)(r,d)}}function u(a){if(n.capturePayload||(delete a.request.body,delete a.response.body),n.sanitizer){const d=a.response.body;if(typeof d=="string")try{a.response.body=JSON.parse(d)}catch{}return n.sanitizer(a)}return a}function c(a){if(a&&typeof a.body!="string")try{a.body=JSON.stringify(a.body)}catch{a.body="<unable to stringify>",t.notify.warn("Openreplay fetch couldn't stringify body:",a.body)}return JSON.stringify(a)}const l=a=>{if(n.useProxy)return ua(a,n.ignoreHeaders,o,u,R=>t.send(R),R=>t.isServiceURL(R),n.tokenUrlMatcher);const d=a.fetch.bind(a),p=(R,E={})=>{if(!(typeof R=="string"||R instanceof URL)||t.isServiceURL(String(R)))return d(R,E);o(function(D,L){E.headers===void 0&&(E.headers={}),E.headers instanceof Headers?E.headers.append(D,L):Array.isArray(E.headers)?E.headers.push([D,L]):E.headers[D]=L});const N=performance.now();return d(R,E).then(D=>{const L=performance.now()-N;if(n.failuresOnly&&D.status<400)return D;const I=D.clone();return I.text().then(T=>{const P={},H={};if(s!==!0){const _=([M,V])=>{i(M)||(P[M]=V)};E.headers instanceof Headers?E.headers.forEach((M,V)=>_([V,M])):Array.isArray(E.headers)?E.headers.forEach(_):typeof E.headers=="object"&&Object.entries(E.headers).forEach(_),I.headers.forEach((M,V)=>{i(V)||(H[V]=M)})}const j=ai(E.method),z=u({url:String(R),method:j,status:I.status,request:{headers:P,body:E.body||null},response:{headers:H,body:T}});z&&t.send(pt("fetch",j,String(z.url),c(z.request),c(z.response),I.status,N+ze(),L,0))}).catch(T=>t.debug.error("Could not process Fetch response:",T)),D})};a.fetch=p;const v=a.XMLHttpRequest.prototype.open,w=a.XMLHttpRequest.prototype.setRequestHeader,y=a.XMLHttpRequest.prototype.send;function x(R,E){const N=this;o((L,I)=>N.setRequestHeader(L,I));let D=0;return N.addEventListener("loadstart",L=>{D=L.timeStamp}),N.addEventListener("load",t.safe(L=>{const{headers:I,body:T}=bn(N),P=D>0?L.timeStamp-D:0,j=(N.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),z={};j.forEach(function(V){const G=V.split(": "),$=G.shift();i($)||(z[$]=G.join(": "))});const _=ai(R),M=u({url:String(E),method:_,status:N.status,request:{headers:I,body:T||null},response:{headers:z,body:N.response}});M&&t.send(pt("xhr",_,String(M.url),c(M.request),c(M.response),N.status,D+ze(),P,0))})),v.apply(this,arguments)}function C(R){const E=bn(this);return E.body=R,y.apply(this,arguments)}function F(R,E){if(!i(R)){const N=bn(this);N.headers[R]=E}return w.apply(this,arguments)}n.axiosInstances||(a.XMLHttpRequest.prototype.open=x,a.XMLHttpRequest.prototype.send=C,a.XMLHttpRequest.prototype.setRequestHeader=F)};l(window),n.axiosInstances&&n.axiosInstances.forEach(a=>{Qo(t,a,n,u,c)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(l))}function da(t){t.attachEventListener(document,"selectionchange",()=>{const e=document.getSelection();if(e!==null&&!e.isCollapsed){const n=t.nodes.getID(e.anchorNode),s=t.nodes.getID(e.focusNode),i=e.toString().replace(/\s+/g," ");n&&s&&t.send(xs(n,s,i))}else t.send(xs(-1,-1,""))})}function fa(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(gt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const _t="/installation/javascript-sdk";function pa(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${ft}${_t}`),!1;if(typeof t.projectKey!="string")if(typeof t.projectKey!="number"){if(typeof t.projectID!="number")return console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${ft}${_t} for more information.`),!1;t.projectKey=t.projectID.toString(),Ce("`projectID` option","`projectKey` option",_t)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ce("`sessionToken` option","`sessionHash` start() option","/"),!0}class ga{constructor(e){var u;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(c,l)=>{const a=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||Bs;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:a,reason:l.length?`missing api: ${l.join(",")}`:c}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(c,l={})=>{if(this.app!==null){if(c instanceof Error){const a=St(c,[],l);this.app.send(a)}else if(c instanceof ErrorEvent||"PromiseRejectionEvent"in window&&c instanceof PromiseRejectionEvent){const a=qs(c,void 0,l);a!=null&&this.app.send(a)}}},this.crossdomainMode=!!(Hi()&&((u=e.crossdomain)!=null&&u.enabled)),!ve||!pa(e))return;if(window.__OPENREPLAY__){console.error("OpenReplay: one tracker instance has been initialised already");return}if(!e.__DISABLE_SECURE_MODE&&location.protocol!=="https:"){console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");return}const n=this.checkDoNotTrack(),s=[],i=["Map","Set","MutationObserver","performance","timing","startsWith","Blob","Worker"];if(n)s.push("doNotTrack");else for(const c of i)if(c==="timing"){if("performance"in window&&!(c in performance)){s.push(c);break}}else if(c==="startsWith"){if(!(c in String.prototype)){s.push(c);break}}else if(!(c in window)){s.push(c);break}if(s.length>0){const c=s.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${c}`),this.signalStartIssue("missing_api",s);return}const r=new ho(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(Vo(r),fo(r),Tr(r,e),fa(r)),Uo(r,e.mouse),qo(r,this.crossdomainMode),Jo(r),Ko(r),vo(r,e),So(r,e),Eo(r),No(r,e),Wo(r,e),Xo(r),Yo(r),ha(r,e.network),da(r),window.__OPENREPLAY__=this,e.flags&&e.flags.onFlagsLoad&&this.onFlagsLoad(e.flags.onFlagsLoad);const o=window.open;(e.autoResetOnWindowOpen||e.resetTabOnWindowOpen)&&(r.attachStartCallback(()=>{const c=r.getTabId(),l=r.sessionStorage??window.sessionStorage;window.open=function(...a){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&l.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),l.setItem(e.session_tabid_key||"__openreplay_tabid",c),o.call(window,...a)}}),r.attachStopCallback(()=>{window.open=o}))}isFlagEnabled(e){return this.featureFlags.isFlagEnabled(e)}onFlagsLoad(e){var n;(n=this.app)==null||n.featureFlags.onFlagsLoad(e)}clearPersistFlags(){var e;(e=this.app)==null||e.featureFlags.clearPersistFlags()}reloadFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.reloadFlags()}getFeatureFlag(e){var n;return(n=this.app)==null?void 0:n.featureFlags.getFeatureFlag(e)}getAllFeatureFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.flags}use(e){return e(this.app,this.options)}isActive(){return this.app===null?!1:this.app.active()}trackWs(e){if(this.app!==null)return this.app.trackWs(e)}start(e){return this.browserEnvCheck()?this.app===null?Promise.reject("Browser doesn't support required api, or doNotTrack is active."):this.app.start(e):Promise.reject("Trying to start not in browser.")}browserEnvCheck(){return ve?!0:(console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${ft}${_t}`),!1)}coldStart(e,n){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,n)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,n){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,n):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return Ce("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){Ce("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(lr(e))}userAnonymousID(e){Ce("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,n){typeof e=="string"&&typeof n=="string"&&this.app!==null&&this.app.session.setMetadata(e,n)}metadata(e,n){Ce("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,n)}event(e,n=null,s=!1){if(typeof e=="string"&&this.app!==null){if(s)return this.issue(e,n);try{n=JSON.stringify(n)}catch{return}this.app.send(ar(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(gr(e,n))}}}const ma=`
22
22
  /* ===================== 1) Переменные и шрифты ===================== */
23
23
  :root {
24
24
  --wineater-corp-color: #0044FF;
@@ -887,7 +887,7 @@ margin: 5px 0;
887
887
 
888
888
  Now translate the following input:
889
889
  ${JSON.stringify(r,null,2)}
890
- `,u=JSON.stringify({model:"gpt-3.5-turbo",messages:[{role:"system",content:"You are a professional translator."},{role:"user",content:o}],temperature:.2,max_tokens:1e3});try{const w=(d=(a=(l=(c=(await(await fetch(s,{method:"POST",headers:i,body:u})).json()).choices)==null?void 0:c[0])==null?void 0:l.message)==null?void 0:a.content)==null?void 0:d.trim();if(!w)throw new Error("No response from OpenAI");const y=JSON.parse(w),x={};return y.forEach(C=>{C.key&&C.text!==void 0&&(x[C.key]=C.text)}),x}catch(p){return console.error("Error translating texts:",p),e}}}const X=new ya,ke={WIDGET_INITIALIZED:"widget_initialized",WIDGET_LOADED:"widget_loaded",SEARCH_PERFORMED:"search_performed",SEARCH_RESULTS_DISPLAYED:"search_results_displayed",NO_RESULTS_FOUND:"no_results_found",WINE_CARD_HOVER:"wine_card_hover",WINE_CARD_CLICK:"wine_card_click",WINE_DETAILS_VIEWED:"wine_details_viewed",WINE_DETAILS_CLOSED:"wine_details_closed",BUY_BUTTON_CLICKED:"buy_button_clicked",FILTER_APPLIED:"filter_applied",LANGUAGE_CHANGED:"language_changed",ERROR_OCCURRED:"error_occurred",MOBILE_VIEW_ACTIVATED:"mobile_view_activated"};class wa{constructor(e){this.widget=e}getTitle(e){return e?`<h1 class="wine-widget-big-title">${e}</h1>`:`<h1 class="wine-widget-big-title">
890
+ `,u=JSON.stringify({model:"gpt-3.5-turbo",messages:[{role:"system",content:"You are a professional translator."},{role:"user",content:o}],temperature:.2,max_tokens:1e3});try{const w=(d=(a=(l=(c=(await(await fetch(s,{method:"POST",headers:i,body:u})).json()).choices)==null?void 0:c[0])==null?void 0:l.message)==null?void 0:a.content)==null?void 0:d.trim();if(!w)throw new Error("No response from OpenAI");const y=JSON.parse(w),x={};return y.forEach(C=>{C.key&&C.text!==void 0&&(x[C.key]=C.text)}),x}catch(p){return console.error("Error translating texts:",p),e}}}const X=new ya,pe={WIDGET_INITIALIZED:"widget_initialized",WIDGET_LOADED:"widget_loaded",SEARCH_PERFORMED:"search_performed",SEARCH_RESULTS_DISPLAYED:"search_results_displayed",NO_RESULTS_FOUND:"no_results_found",WINE_CARD_HOVER:"wine_card_hover",WINE_CARD_CLICK:"wine_card_click",WINE_DETAILS_VIEWED:"wine_details_viewed",WINE_DETAILS_CLOSED:"wine_details_closed",BUY_BUTTON_CLICKED:"buy_button_clicked",FILTER_APPLIED:"filter_applied",LANGUAGE_CHANGED:"language_changed",ERROR_OCCURRED:"error_occurred",MOBILE_VIEW_ACTIVATED:"mobile_view_activated"};class wa{constructor(e){this.widget=e}getTitle(e){return e?`<h1 class="wine-widget-big-title">${e}</h1>`:`<h1 class="wine-widget-big-title">
891
891
  ${X.translate("headerLine1")}
892
892
  <span class="icon icon-meal"></span>
893
893
  <span class="icon-label">${X.translate("headerMeal")}</span>,
@@ -951,7 +951,7 @@ margin: 5px 0;
951
951
  <div class="error-message">
952
952
  <p>${X.translate("errorMessage")||"Something went wrong. Please try again later."}</p>
953
953
  </div>
954
- `}animateCardDisappearance(){const e=document.querySelectorAll(".wine-recommendation-tile");e.forEach((n,s)=>{setTimeout(()=>{n.style.opacity="0",n.style.transform="translateY(-20px)"},s*100)}),setTimeout(()=>{document.getElementById("wine-placeholder").innerHTML="",this.showLoadingIndicator()},e.length*100+300)}initializeSearchAnimation(){const e=document.getElementById("wine-search-input"),n=X.translate("placeholderSuggestions");let s=0,i=0,r=!0,o=!1;const u=()=>{o||(r?(e.placeholder=n[s].substring(0,i++),i>n[s].length?(r=!1,setTimeout(u,2e3)):setTimeout(u,100)):(e.placeholder=n[s].substring(0,i--),i<0?(r=!0,s=(s+1)%n.length,setTimeout(u,500)):setTimeout(u,50)))};u(),e.addEventListener("focus",()=>{e.placeholder="",o=!0}),e.addEventListener("blur",()=>{o=!1,i=0,r=!0,u()})}enableHoverPopups(){document.querySelectorAll(".wine-recommendation-tile").forEach(n=>{const s=n.querySelector(".wine-hover-popup");s&&(n.addEventListener("mouseenter",()=>{s.style.display="block",s.classList.add("slide-in")}),n.addEventListener("mouseleave",()=>{s.classList.remove("slide-in"),s.style.display="none"}))})}}class Sa{constructor(e){this.widget=e}async handleSearch(){const e=document.getElementById("wine-search-input").value.trim()+";";this.widget.trackEvent(ke.SEARCH_PERFORMED,{query:e}),this.widget.ui.animateCardDisappearance();try{const n=await this.widget.api.getWineRecommendationsSearch(e);n&&n.length>0?(console.log("Recommendations:",n),this.widget.displayResults(n,!0),this.widget.trackEvent(ke.SEARCH_RESULTS_DISPLAYED,{results_count:n.length,results:n.map(s=>s.Title||s.title),query:e})):(console.log("No recommendations found."),this.widget.ui.displayNoResultsMessage(),this.widget.trackEvent(ke.NO_RESULTS_FOUND,{query:e}))}catch(n){console.error("Error fetching wine recommendations:",n.message),this.widget.ui.displayErrorMessage(),this.widget.trackEvent(ke.ERROR_OCCURRED,{error_message:n.message,query:e})}}async loadInstantRecommendations(){this.widget.ui.showLoadingIndicator();try{const e=await this.widget.api.getInstantRecommendations();this.widget.displayResults(e)}catch(e){console.error("Error loading instant recommendations:",e.message)}}addEventListeners(){document.getElementById("wine-search-button").addEventListener("click",()=>{this.handleSearch()}),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}}class xa{constructor(e){this.widget=e}createLanguageSwitcher(){const e=document.querySelector("#powered-by-widget .powered-by-lang"),n=X.getSupportedLanguages();if(!n)return;const s=X.language,i=document.createElement("select");i.id="language-dropdown",i.className="language-dropdown",n.forEach(r=>{const o=document.createElement("option");o.value=r,o.textContent=r.toUpperCase(),o.selected=r===s,i.appendChild(o)}),i.onchange=r=>{const o=r.target.value;this.widget.trackEvent(ke.LANGUAGE_CHANGED,{from_language:s,to_language:o});const u=new URL(window.location.href);u.searchParams.set("lang",o),localStorage.setItem("selectedLanguage",o),window.location.href=u.toString()},e.appendChild(i)}async translatePopupContent(e){if(X.language===X.storeLanguage||this.widget.widgetType!=="bar")return;const n=["Short Description","reason","pairing_recommendation","Tags","tags"],s=e[0],i=n.filter(o=>o in s),r=4;for(let o=0;o<e.length;o+=r){const c=e.slice(o,o+r).map(async(l,a)=>{const d=o+a,p=i.map(x=>{const C=l[x]||l[x.toLowerCase()];return C?{key:x,text:Array.isArray(C)?C.join(", "):C}:null}).filter(Boolean);if(p.length===0)return;const v=await X.translateTexts(Object.fromEntries(p.map(x=>[x.key,x.text]))),w=document.querySelector(`.card-popup[data-wine-index="${d}"]`);if(!w)return;if(v["Short Description"]){const x=w.querySelector(".popup-short-desc");x&&(x.textContent=v["Short Description"])}if(v.reason){const x=w.querySelector(".popup-reason");x&&(x.textContent=v.reason)}if(v.pairing_recommendation){const x=w.querySelector(".popup-pairing");x&&(x.textContent=v.pairing_recommendation)}const y=v.tags||v.Tags;if(y){const C=y.split(",").map(R=>R.trim()).map(R=>`<span class="popup-tag">${R}</span>`).join(""),F=w.querySelector(".popup-tags");F&&(F.innerHTML=C)}});await Promise.all(c)}}}class ka{constructor(){var e,n,s,i,r;this.widgetType=((e=window==null?void 0:window.wineaterData)==null?void 0:e.WIDGET_TYPE)||"store",this.countryCode=((n=window==null?void 0:window.wineaterData)==null?void 0:n.COUNTRY_CODE)||null,this.widgetWrapper=((s=window==null?void 0:window.wineaterData)==null?void 0:s.WIDGET_WRAPPER)||"wineater-widget-conteiner",this.titleText=(i=window==null?void 0:window.wineaterData)==null?void 0:i.TITLE_TEXT,this.subtitleText=(r=window==null?void 0:window.wineaterData)==null?void 0:r.SUBTITLE_TEXT,this.storeId=null,this.api=new li,this.ui=new wa(this),this.search=new Sa(this),this.language=new xa(this),this.selectedFilters={price:null,color:null,intensity:null},this.initialized=this.initialize()}async trackEvent(e,n={},s={}){await this.initialized,bi(e,this.storeId,n,s)}async initialize(){await X.fetchConfig("storeName"),this.storeId=X.storeId,this.ui.initializeWidget(),this.search.addEventListeners(),this.ui.initializeSearchAnimation(),this.search.loadInstantRecommendations(),this.language.createLanguageSwitcher()}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.ui.hideLoadingIndicator(),s.innerHTML="";const i=(l,a)=>l[a]||l[a.charAt(0).toUpperCase()+a.slice(1)],r=(l,a)=>a.map(d=>i(l,d)).filter(Boolean).join(" • "),o=l=>Array.isArray(l)?l.map(a=>`<span class="popup-tag">${a}</span>`).join(""):"",u=l=>{const a=l.tags||l.Tags,d=l.reason||l["Short Description"];return!d&&!a?"":`
954
+ `}animateCardDisappearance(){const e=document.querySelectorAll(".wine-recommendation-tile");e.forEach((n,s)=>{setTimeout(()=>{n.style.opacity="0",n.style.transform="translateY(-20px)"},s*100)}),setTimeout(()=>{document.getElementById("wine-placeholder").innerHTML="",this.showLoadingIndicator()},e.length*100+300)}initializeSearchAnimation(){const e=document.getElementById("wine-search-input"),n=X.translate("placeholderSuggestions");let s=0,i=0,r=!0,o=!1;const u=()=>{o||(r?(e.placeholder=n[s].substring(0,i++),i>n[s].length?(r=!1,setTimeout(u,2e3)):setTimeout(u,100)):(e.placeholder=n[s].substring(0,i--),i<0?(r=!0,s=(s+1)%n.length,setTimeout(u,500)):setTimeout(u,50)))};u(),e.addEventListener("focus",()=>{e.placeholder="",o=!0}),e.addEventListener("blur",()=>{o=!1,i=0,r=!0,u()})}enableHoverPopups(){document.querySelectorAll(".wine-recommendation-tile").forEach(n=>{const s=n.querySelector(".wine-hover-popup");s&&(n.addEventListener("mouseenter",()=>{s.style.display="block",s.classList.add("slide-in")}),n.addEventListener("mouseleave",()=>{s.classList.remove("slide-in"),s.style.display="none"}))})}}class Sa{constructor(e){this.widget=e}async handleSearch(){const e=document.getElementById("wine-search-input").value.trim()+";";this.widget.trackEvent(pe.SEARCH_PERFORMED,{query:e}),this.widget.ui.animateCardDisappearance();try{const n=await this.widget.api.getWineRecommendationsSearch(e);n&&n.length>0?(console.log("Recommendations:",n),this.widget.displayResults(n,!0),this.widget.trackEvent(pe.SEARCH_RESULTS_DISPLAYED,{results_count:n.length,results:n.map(s=>s.Title||s.title),query:e})):(console.log("No recommendations found."),this.widget.ui.displayNoResultsMessage(),this.widget.trackEvent(pe.NO_RESULTS_FOUND,{query:e}))}catch(n){console.error("Error fetching wine recommendations:",n.message),this.widget.ui.displayErrorMessage(),this.widget.trackEvent(pe.ERROR_OCCURRED,{error_message:n.message,query:e})}}async loadInstantRecommendations(){this.widget.ui.showLoadingIndicator();try{const e=await this.widget.api.getInstantRecommendations();this.widget.displayResults(e)}catch(e){console.error("Error loading instant recommendations:",e.message)}}addEventListeners(){document.getElementById("wine-search-button").addEventListener("click",()=>{this.handleSearch()}),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}}class xa{constructor(e){this.widget=e}createLanguageSwitcher(){const e=document.querySelector("#powered-by-widget .powered-by-lang"),n=X.getSupportedLanguages();if(!n)return;const s=X.language,i=document.createElement("select");i.id="language-dropdown",i.className="language-dropdown",n.forEach(r=>{const o=document.createElement("option");o.value=r,o.textContent=r.toUpperCase(),o.selected=r===s,i.appendChild(o)}),i.onchange=r=>{const o=r.target.value;this.widget.trackEvent(pe.LANGUAGE_CHANGED,{from_language:s,to_language:o});const u=new URL(window.location.href);u.searchParams.set("lang",o),localStorage.setItem("selectedLanguage",o),window.location.href=u.toString()},e.appendChild(i)}async translatePopupContent(e){if(X.language===X.storeLanguage||this.widget.widgetType!=="bar")return;const n=["Short Description","reason","pairing_recommendation","Tags","tags"],s=e[0],i=n.filter(o=>o in s),r=4;for(let o=0;o<e.length;o+=r){const c=e.slice(o,o+r).map(async(l,a)=>{const d=o+a,p=i.map(x=>{const C=l[x]||l[x.toLowerCase()];return C?{key:x,text:Array.isArray(C)?C.join(", "):C}:null}).filter(Boolean);if(p.length===0)return;const v=await X.translateTexts(Object.fromEntries(p.map(x=>[x.key,x.text]))),w=document.querySelector(`.card-popup[data-wine-index="${d}"]`);if(!w)return;if(v["Short Description"]){const x=w.querySelector(".popup-short-desc");x&&(x.textContent=v["Short Description"])}if(v.reason){const x=w.querySelector(".popup-reason");x&&(x.textContent=v.reason)}if(v.pairing_recommendation){const x=w.querySelector(".popup-pairing");x&&(x.textContent=v.pairing_recommendation)}const y=v.tags||v.Tags;if(y){const C=y.split(",").map(R=>R.trim()).map(R=>`<span class="popup-tag">${R}</span>`).join(""),F=w.querySelector(".popup-tags");F&&(F.innerHTML=C)}});await Promise.all(c)}}}class ka{constructor(){var e,n,s,i,r;this.widgetType=((e=window==null?void 0:window.wineaterData)==null?void 0:e.WIDGET_TYPE)||"store",this.countryCode=((n=window==null?void 0:window.wineaterData)==null?void 0:n.COUNTRY_CODE)||null,this.widgetWrapper=((s=window==null?void 0:window.wineaterData)==null?void 0:s.WIDGET_WRAPPER)||"wineater-widget-conteiner",this.titleText=(i=window==null?void 0:window.wineaterData)==null?void 0:i.TITLE_TEXT,this.subtitleText=(r=window==null?void 0:window.wineaterData)==null?void 0:r.SUBTITLE_TEXT,this.storeId=null,this.api=new li,this.ui=new wa(this),this.search=new Sa(this),this.language=new xa(this),this.selectedFilters={price:null,color:null,intensity:null},this.initialized=this.initialize()}async trackEvent(e,n={},s={}){await this.initialized,bi(e,this.storeId,n,s)}async initialize(){await X.fetchConfig("storeName"),this.storeId=X.storeId,this.ui.initializeWidget(),this.search.addEventListeners(),this.ui.initializeSearchAnimation(),this.search.loadInstantRecommendations(),this.language.createLanguageSwitcher(),this.trackEvent(pe.WIDGET_INITIALIZED,{store_id:this.storeId})}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.ui.hideLoadingIndicator(),s.innerHTML="";const i=(l,a)=>l[a]||l[a.charAt(0).toUpperCase()+a.slice(1)],r=(l,a)=>a.map(d=>i(l,d)).filter(Boolean).join(" • "),o=l=>Array.isArray(l)?l.map(a=>`<span class="popup-tag">${a}</span>`).join(""):"",u=l=>{const a=l.tags||l.Tags,d=l.reason||l["Short Description"];return!d&&!a?"":`
955
955
  <div class="wine-hover-popup">
956
956
  ${d?`<div class="popup-reason">${d}</div>`:""}
957
957
  ${a?`<div class="popup-tags">${o(a)}</div>`:""}
@@ -983,7 +983,7 @@ margin: 5px 0;
983
983
 
984
984
  ${F}
985
985
  </div>
986
- `;s.insertAdjacentHTML("beforeend",D);const L=s.children[a];if(w){const I=L.querySelector(".buy-btn");I==null||I.addEventListener("click",()=>{this.trackEvent(ke.BUY_BUTTON_CLICKED,{wine_id:l.ID,wine_title:l.title||l.Title,wine_url:l.url||l.URL})})}else{const I=L.querySelector("[data-toggle-info]"),T=L.querySelector(".card-popup"),P=L.querySelector(".card-popup-close");P==null||P.addEventListener("click",H=>{H.stopPropagation(),T.classList.add("hidden"),this.trackEvent(ke.WINE_DETAILS_CLOSED,{wine_id:l.ID,wine_title:l.title||l.Title})}),document.addEventListener("click",H=>{H.target.closest(".card-popup")||H.target.closest(".mobile-fullscreen-popup")||H.target.closest("[data-toggle-info]")||(document.querySelectorAll(".card-popup").forEach(z=>z.classList.add("hidden")),document.querySelectorAll(".mobile-fullscreen-wrapper").forEach(z=>z.remove()))}),this.widgetType==="store"?(L.addEventListener("mouseenter",()=>{T.classList.remove("hidden"),this.trackEvent(ke.WINE_CARD_HOVER,{wine_id:l.ID,wine_title:l.title||l.Title})}),L.addEventListener("mouseleave",()=>{T.classList.add("hidden")})):I==null||I.addEventListener("click",H=>{var j;if(H.stopPropagation(),document.querySelectorAll(".card-popup").forEach(z=>z.classList.add("hidden")),document.querySelectorAll(".mobile-fullscreen-wrapper").forEach(z=>z.remove()),window.innerWidth<=768){const z=T.innerHTML,_=document.createElement("div");_.className="mobile-fullscreen-wrapper",_.innerHTML=`
986
+ `;s.insertAdjacentHTML("beforeend",D);const L=s.children[a];if(L.addEventListener("click",I=>{!I.target.closest(".buy-btn")&&!I.target.closest(".card-popup-close")&&this.trackEvent(pe.WINE_CARD_CLICK,{wine_id:l.ID,wine_title:l.title||l.Title})}),!w&&this.widgetType==="bar"){const I=L.querySelector("[data-toggle-info]"),T=L.querySelector(".card-popup"),P=L.querySelector(".card-popup-close");P==null||P.addEventListener("click",H=>{H.stopPropagation(),T.classList.add("hidden"),this.trackEvent(pe.WINE_DETAILS_CLOSED,{wine_id:l.ID,wine_title:l.title||l.Title})}),document.addEventListener("click",H=>{H.target.closest(".card-popup")||H.target.closest(".mobile-fullscreen-popup")||H.target.closest("[data-toggle-info]")||(document.querySelectorAll(".card-popup").forEach(z=>z.classList.add("hidden")),document.querySelectorAll(".mobile-fullscreen-wrapper").forEach(z=>z.remove()))}),this.widgetType==="store"?(L.addEventListener("mouseenter",()=>{T.classList.remove("hidden"),this.trackEvent(pe.WINE_CARD_HOVER,{wine_id:l.ID,wine_title:l.title||l.Title})}),L.addEventListener("mouseleave",()=>{T.classList.add("hidden")})):I==null||I.addEventListener("click",H=>{var j;if(H.stopPropagation(),document.querySelectorAll(".card-popup").forEach(z=>z.classList.add("hidden")),document.querySelectorAll(".mobile-fullscreen-wrapper").forEach(z=>z.remove()),window.innerWidth<=768){const z=T.innerHTML,_=document.createElement("div");_.className="mobile-fullscreen-wrapper",_.innerHTML=`
987
987
  <div class="mobile-fullscreen-overlay"></div>
988
988
  <div class="card-popup mobile-fullscreen-popup">${z}</div>
989
- `,(j=_.querySelector(".card-popup-close"))==null||j.addEventListener("click",()=>_.remove()),document.body.appendChild(_)}else T.classList.remove("hidden");this.trackEvent(ke.WINE_DETAILS_VIEWED,{wine_id:l.ID,wine_title:l.title||l.Title,is_mobile:window.innerWidth<=768})})}setTimeout(()=>{L.style.opacity="1",L.style.transform="translateY(0)"},n?a*200:0)}),this.language.translatePopupContent(e),this.widgetType==="store"&&this.ui.enableHoverPopups()}}const Ea="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Ta{constructor(){this.tracker=new ga({projectKey:"PA8j9fAi49i6g2QnvpNs",__DISABLE_SECURE_MODE:!0})}async initTranslator(){const e=this.store?this.store.charAt(0).toUpperCase()+this.store.slice(1):"Test";await X.fetchConfig(e||"Test")}initCookies(){var e;Nt("chatbotToken",((e=window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||Ea,365),Un()}async initialize(){this.tracker.start(),await this.initTranslator(),this.initCookies(),new ka}}document.addEventListener("DOMContentLoaded",()=>{new Ta().initialize()})});
989
+ `,(j=_.querySelector(".card-popup-close"))==null||j.addEventListener("click",()=>_.remove()),document.body.appendChild(_)}else T.classList.remove("hidden");this.trackEvent(pe.WINE_DETAILS_VIEWED,{wine_id:l.ID,wine_title:l.title||l.Title,is_mobile:window.innerWidth<=768})})}else{const I=L.querySelector(".buy-btn");I==null||I.addEventListener("click",()=>{this.trackEvent(pe.BUY_BUTTON_CLICKED,{wine_id:l.ID,wine_title:l.title||l.Title,wine_url:l.url||l.URL})})}setTimeout(()=>{L.style.opacity="1",L.style.transform="translateY(0)"},n?a*200:0)}),this.language.translatePopupContent(e),this.widgetType==="store"&&this.ui.enableHoverPopups()}}const Ea="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Ta{constructor(){this.tracker=new ga({projectKey:"PA8j9fAi49i6g2QnvpNs",__DISABLE_SECURE_MODE:!0})}async initTranslator(){const e=this.store?this.store.charAt(0).toUpperCase()+this.store.slice(1):"Test";await X.fetchConfig(e||"Test")}initCookies(){var e;Nt("chatbotToken",((e=window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||Ea,365),Un()}async initialize(){this.tracker.start(),await this.initTranslator(),this.initCookies(),new ka}}document.addEventListener("DOMContentLoaded",()=>{new Ta().initialize()})});