wineater-bot 3.4.3 → 3.4.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.
- package/dist/wineater-chatbot.mjs +970 -967
- package/dist/wineater-chatbot.umd.js +37 -37
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/js/widget.js +9 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
(function(nt){typeof define=="function"&&define.amd?define(nt):nt()})(function(){"use strict";var ai,ci;function nt(){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 Bn(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 gi(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 mi(){const t="uniqueUserID";let e=gi(t);return e||(e=nt(),Bn(t,e,365)),e}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(v){try{return localStorage.getItem(v)||null}catch{return null}},getItem:function(v,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(v);f==null||f(null,S),m(S)}catch(x){f&&f(x,null),g(x)}})},setItem:function(v,f,h){return new Promise(function(m,g){try{localStorage.setItem(v,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(v){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(v[g]=f[g]);return v},i.apply(this,arguments)};function r(v,f,h,m){return new(h||(h=Promise))(function(g,S){function x(q){try{B(m.next(q))}catch(O){S(O)}}function D(q){try{B(m.throw(q))}catch(O){S(O)}}function B(q){var O;q.done?g(q.value):(O=q.value,O instanceof h?O:new h(function(W){W(O)})).then(x,D)}B((m=m.apply(v,f||[])).next())})}function a(v,f){var h,m,g,S,x={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:D(0),throw:D(1),return:D(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function D(B){return function(q){return function(O){if(h)throw new TypeError("Generator is already executing.");for(;x;)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 x.label++,{value:O[1],done:!1};case 5:x.label++,m=O[1],O=[0];continue;case 7:O=x.ops.pop(),x.trys.pop();continue;default:if(g=x.trys,!((g=g.length>0&&g[g.length-1])||O[0]!==6&&O[0]!==2)){x=0;continue}if(O[0]===3&&(!g||O[1]>g[0]&&O[1]<g[3])){x.label=O[1];break}if(O[0]===6&&x.label<g[1]){x.label=g[1],g=O;break}if(g&&x.label<g[2]){x.label=g[2],x.ops.push(O);break}g[2]&&x.ops.pop(),x.trys.pop();continue}O=f.call(v,x)}catch(W){O=[6,W],m=0}finally{h=g=0}if(5&O[0])throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}([B,q])}}}function l(v,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 v.concat(m||Array.prototype.slice.call(f))}var o=function v(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(!v(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 x=S[g];if(!v(f[x],h[x]))return!1}return!0}return f!=f&&h!=h};function u(v,f){var h=Object.keys(f||{}).filter(function(m){var g=v==null?void 0:v[m],S=f==null?void 0:f[m];return!o(g,S)});return Object.keys(v||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var c,d;function p(v,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),v[m]=v[m]||{},v[m][f]=g?h+"":h}function b(v){return!!v&&typeof v=="object"&&v.value!==void 0}function w(v){return Object.fromEntries(Object.entries(v).map(function(f){var h=f[0],m=f[1];return[h,b(m)?m:{value:m}]}))}function y(v){return i(i({},v),{identity:v.identity?i(i({},v.identity),{traits:w(v.identity.traits||{})}):void 0})}(function(v){v.NONE="NONE",v.DEFAULT_FLAGS="DEFAULT_FLAGS",v.CACHE="CACHE",v.SERVER="SERVER"})(c||(c={}));var E,R=null,j="BULLET_TRAIN_DB",A="BULLET_TRAIN_EVENT",k="https://edge.api.flagsmith.com/api/v1/",C="flagsmith_value_",_="flagsmith_enabled_",M="flagsmith_trait_",I=function(){function v(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 x="".concat(h.getContext().identity),D=function(B){var q,O,W,ee;if(B&&x==="".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=u(h.oldFlags,ue),Ye=u((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.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:Ye},h._loadedState(null,c.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var Qe={};Object.keys(((O=h.evaluationContext.identity)===null||O===void 0?void 0:O.traits)||{}).map(function(K){Qe[M+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.identifier)}),Qe);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,C+K,h.getValue(K,{skipAnalytics:!0})),p(ie,_+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,M+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 q=B[0],O=B[1];return{trait_key:q,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:{}}),D(B==null?void 0:B[0])}).catch(function(B){var q=B.message,O=new Error(q);return Promise.reject(O)}):h.getJSON(g+"flags/").then(function(B){return D({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:c.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 x=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],D=null;if(x&&(D=x.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),D===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return D===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(D)}catch{return g.fallback}return D},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],x=g[1];return[S,x==null?void 0:x.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 x=S[0],D=S[1];return[x,b(D)?D:{value:D}]})))})}));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",x=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],D=!1;return!x&&S&&g.fallback!==void 0?D=g==null?void 0:g.fallback:x&&x.enabled&&(D=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),D},this.getJSON=function(m,g,S){var x,D=h;D.evaluationContext;var B=D.headers,q={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(q.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(q.headers["Content-Type"]="application/json; charset=utf-8"),B&&Object.assign(q.headers,B),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var O="".concat((x=h.evaluationContext.identity)===null||x===void 0?void 0:x.identifier);return d(m,q).then(function(W){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(O===te){var ne=(oe=W.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: "+W.status+" "+(g||"GET")+0+m),W.text().then(function(he){var ye=he;try{ye=JSON.parse(he)}catch{}return!ye&&W.status&&(ye="API Response: ".concat(W.status)),W.status&&W.status>=200&&W.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(C+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(_+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 x,D;h.setLoadingState(S),(x=h.onChange)===null||x===void 0||x.call(h,m,g,h.loadingState),(D=h._trigger)===null||D===void 0||D.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&&(E=f.eventSource),f.AsyncStorage&&(R=f.AsyncStorage)}return v.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,x,D,B,q,O,W,ee,oe,te,ne,ue,he,ye,Ye,Qe,qe,ie,K,vn,Ze,li,et,bn,ui,hi,yn,di,wn,tt,We,fi,re=this;return a(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]),x=f.environmentID,D=f.api,B=D===void 0?k:D,q=f.headers,O=f.onChange,W=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,ye=f.enableDynatrace,Ye=f.enableAnalytics,Qe=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,vn=f.identity,Ze=f.traits,li=f.state,et=f.cacheOptions,bn=f.angularHttpClient,ui=f._trigger,hi=f._triggerLoadingState,S.environment=x?{apiKey:x}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=vn||Ze?{identifier:vn,traits:Ze?Object.fromEntries(Object.entries(Ze).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=B,this.headers=q,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=O,yn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=ui||this._trigger,this._triggerLoadingState=hi||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=et?{skipAPI:!!et.skipAPI,ttl:et.ttl||0,loadStale:!!et.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=Ye||!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=R!==void 0&&!!W,K&&(R=K),Qe&&typeof window<"u"&&this.setupRealtime(ie,S.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:c.DEFAULT_FLAGS})),this.setState(li),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),bn&&(d=function(de){return function(we,Se){var _e=Se.headers,X=Se.method,Ve=Se.body;return new Promise(function(Ae){switch(X){case"GET":return de.get(we,{headers:_e}).subscribe(function(ke){Ae({ok:!0,text:function(){return Promise.resolve(ke)}})});case"POST":case"PUT":return de.post(we,Ve,{headers:_e}).subscribe(function(ke){Ae({ok:!0,text:function(){return Promise.resolve(ke)}})})}})}}(bn)),R&&this.canUseStorage&&R.getItem(A).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),R&&this.canUseStorage&&R.getItem(A,function(de,we){if(we&&re.evaluationContext.environment){var Se=JSON.parse(we);if(Se[re.evaluationContext.environment.apiKey]){var _e=re.getState();re.log("Retrieved events from cache",we),re.setState(i(i({},_e),{evaluationEvent:Se[re.evaluationContext.environment.apiKey]}))}}})),!W)return[3,9];if(!R||!this.canUseStorage)return[3,8];di=function(de,we){return r(re,void 0,void 0,function(){var Se,_e,X,Ve,Ae,ke,Sn,pi,xn,kn,Tn,En,In,Cn,_n,Nn,On,Rn,Dn,An,Mn,Ln,Fn,Pn;return a(this,function(Ne){switch(Ne.label){case 0:if(!we)return[3,7];Se=null,_e=null,Ne.label=1;case 1:return Ne.trys.push([1,5,,6]),X=JSON.parse(we),Ve=!1,Ae=!1,X&&X.api===this.api&&((kn=(xn=X.evaluationContext)===null||xn===void 0?void 0:xn.environment)===null||kn===void 0?void 0:kn.apiKey)===((Tn=this.evaluationContext.environment)===null||Tn===void 0?void 0:Tn.apiKey)&&(ke=!0,this.evaluationContext.identity&&((In=(En=X.evaluationContext)===null||En===void 0?void 0:En.identity)===null||In===void 0?void 0:In.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((_n=(Cn=X.evaluationContext)===null||Cn===void 0?void 0:Cn.identity)===null||_n===void 0?void 0:_n.identifier)+" to "+this.evaluationContext.identity.identifier),ke=!1),this.cacheOptions.ttl&&(!X.ts||new Date().valueOf()-X.ts>this.cacheOptions.ttl)&&(X.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+X.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-X.ts)+"ms"),ke=!1):X.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+X.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-X.ts)+"ms"),Ae=!0,ke=!0)),ke&&(Ve=!0,_e=u((Nn=this.evaluationContext.identity)===null||Nn===void 0?void 0:Nn.traits,(Rn=(On=X.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.traits),Se=u(this.flags,X.flags),this.setState(i(i({},X),{evaluationContext:y(i(i({},X.evaluationContext),{identity:!((Dn=X.evaluationContext)===null||Dn===void 0)&&Dn.identity?i(i({},(An=X.evaluationContext)===null||An===void 0?void 0:An.identity),{traits:i(i({},((Ln=(Mn=X.evaluationContext)===null||Mn===void 0?void 0:Mn.identity)===null||Ln===void 0?void 0:Ln.traits)||{}),Ze||{})}):void 0}))})),this.log("Retrieved flags from cache",X))),Ve?(Sn=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:Se,traitsChanged:_e},this._loadedState(null,c.CACHE,Sn)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ve&&!Ae&&this.log("Skipping API, using cache"),Sn&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Ne.sent(),Ne.label=4;case 4:return[3,6];case 5:return pi=Ne.sent(),this.log("Exception fetching cached logs",pi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Ne.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(Fn=this.evaluationContext.identity)===null||Fn===void 0?void 0:Fn.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(yn);this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(Pn=this.evaluationContext.identity)===null||Pn===void 0?void 0:Pn.traits)},this._loadedState(null,c.DEFAULT_FLAGS))}Ne.label=10;case 10:return[2]}})})},pe.label=2;case 2:return pe.trys.push([2,7,,8]),R.getItemSync?(wn=R.getItemSync(j),[3,5]):[3,3];case 3:return[4,R.getItem(j)];case 4:wn=pe.sent(),pe.label=5;case 5:return[4,di(null,wn)];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:u({},te),traitsChanged:u({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else if(this.flags&&(tt=null,Object.keys(this.flags).length===0&&(tt=yn),this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(tt,c.DEFAULT_FLAGS)),tt))throw new Error(tt);pe.label=12;case 12:return[3,14];case 13:throw We=pe.sent(),this.log("Error during initialisation ",We),fi=We instanceof Error?We:new Error("".concat(We)),(g=this.onError)===null||g===void 0||g.call(this,fi),We;case 14:return[2]}})})},v.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}},v.prototype.getAllFlags=function(){return this.flags},v.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],x=g[1];return[S,b(x)?x:{value:x}]}))),this.initialised?this.getFlags():Promise.resolve()},v.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},v.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||k,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},v.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},v.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},v.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},v.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,l(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},v.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),R.setItem(j,f)}},v.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);R.setItem(A,f)}},v.prototype.setLoadingState=function(f){var h;o(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(h=this._triggerLoadingState)===null||h===void 0||h.call(this))},v.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";E?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new E(g),this.eventSource.addEventListener("environment_updated",function(S){var x;try{x=JSON.parse(S.data).updated_at}catch(D){m.log("Could not parse sse event",D)}x?!m.timestamp||x>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")},v}();function T(v){var f=v.fetch,h=v.AsyncStorage,m=v.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var L,$=(L=function(v,f){return L=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])},L(v,f)},function(v,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=v}L(v,f),v.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),F=function(v){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&v[f],m=0;if(h)return h.call(v);if(v&&typeof v.length=="number")return{next:function(){return v&&m>=v.length&&(v=void 0),{value:v&&v[m++],done:!v}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(v,f){var h=typeof Symbol=="function"&&v[Symbol.iterator];if(!h)return v;var m,g,S=h.call(v),x=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)x.push(m.value)}catch(D){g={error:D}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return x},N=function(v,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 v.concat(m||Array.prototype.slice.call(f))},P=function(v){function f(){return v.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 $(f,v),f}(Error),V=function(){function v(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 P;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return v.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},v.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=F(Object.keys(this._listeners)),x=S.next();!x.done;x=S.next()){var D=x.value;this._eventSource.addEventListener(D,this._onevent_wrapped)}}catch(B){f={error:B}}finally{try{x&&!x.done&&(h=S.return)&&h.call(S)}finally{if(f)throw f.error}}},v.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},v.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)}},v.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=F(N([],z(g),!1)),x=S.next();!x.done;x=S.next())x.value.call(this,f)}catch(D){h={error:D}}finally{try{x&&!x.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}f.type==="message"&&this.onmessage(f)},v.prototype.onopen=function(f){},v.prototype.onerror=function(f){},v.prototype.onmessage=function(f){},v.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},v.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]=N(N([],z(g),!1),[h],!1))},v.prototype.removeEventListener=function(f,h,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(S){return S!==h})},v}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var G=function(v,f){return f=f||{},new Promise(function(h,m){var g=new XMLHttpRequest,S=[],x=[],D={},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 x},get:function(O){return D[O.toLowerCase()]},has:function(O){return O.toLowerCase()in D}}}};for(var q in g.open(f.method||"get",v,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(O,W,ee){S.push(W=W.toLowerCase()),x.push([W,ee]),D[W]=D[W]?D[W]+","+ee:ee}),h(B())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(q,f.headers[q]);g.send(f.body||null)})},H=T({AsyncStorage:s,fetch:G,eventSource:V});typeof window<"u"&&(window.flagsmith=H),n.createFlagsmithInstance=function(){return T({AsyncStorage:s,fetch:G,eventSource:V})},n.default=H,Object.defineProperty(n,"__esModule",{value:!0})})})(jn,jn.exports);var zn={},bi=function(t,e,n,s,i){var r=new Worker(zn[e]||(zn[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(a){var l=a.data,o=l.$e$;if(o){var u=new Error(o[0]);u.code=o[1],u.stack=o[2],i(u,null)}else i(null,l)},r.postMessage(n,s),r},ae=Uint8Array,se=Uint16Array,st=Int32Array,it=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]),rt=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]),_t=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Un=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 st(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}},Hn=Un(it,2),yi=Hn.b,ot=Hn.r;yi[28]=258,ot[258]=28;for(var wi=Un(rt,0),Nt=wi.r,at=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,at[J]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var Le=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 a=new se(e);for(i=1;i<e;++i)a[i]=a[i-1]+r[i-1]<<1;var l;if(n){l=new se(1<<e);var o=15-e;for(i=0;i<s;++i)if(t[i])for(var u=i<<4|t[i],c=e-t[i],d=a[t[i]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)l[at[d]>>o]=u}else for(l=new se(s),i=0;i<s;++i)t[i]&&(l[i]=at[a[t[i]-1]++]>>15-t[i]);return l},Ee=new ae(288),J=0;J<144;++J)Ee[J]=8;for(var J=144;J<256;++J)Ee[J]=9;for(var J=256;J<280;++J)Ee[J]=7;for(var J=280;J<288;++J)Ee[J]=8;for(var Ge=new ae(32),J=0;J<32;++J)Ge[J]=5;var $n=Le(Ee,9,0),qn=Le(Ge,5,0),Ot=function(t){return(t+7)/8|0},Wn=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))},Si=["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"],Vn=function(t,e,n){var s=new Error(e||Si[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,Vn),!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},Fe=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},ct=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:Mt,l:0};if(i==1){var a=new ae(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(C,_){return C.f-_.f}),n.push({s:-1,f:25001});var l=n[0],o=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:l.f+o.f,l,r:o};c!=i-1;)l=n[n[u].f<n[d].f?u++:d++],o=n[u!=c&&n[u].f<n[d].f?u++:d++],n[c++]={s:-1,f:l.f+o.f,l,r:o};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var b=new se(p+1),w=lt(n[c-1],b,0);if(w>e){var s=0,y=0,E=w-e,R=1<<E;for(r.sort(function(_,M){return b[M.s]-b[_.s]||_.f-M.f});s<i;++s){var j=r[s].s;if(b[j]>e)y+=R-(1<<w-b[j]),b[j]=e;else break}for(y>>=E;y>0;){var A=r[s].s;b[A]<e?y-=1<<e-b[A]++-1:++s}for(;s>=0&&y;--s){var k=r[s].s;b[k]==e&&(--b[k],++y)}w=e}return{t:new ae(b),l:w}},lt=function(t,e,n){return t.s==-1?Math.max(lt(t.l,e,n+1),lt(t.r,e,n+1)):e[t.s]=n},Rt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new se(++e),s=0,i=t[0],r=1,a=function(o){n[s++]=o},l=1;l<=e;++l)if(t[l]==i&&l!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(i),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(i);r=1,i=t[l]}return{c:n.subarray(0,s),n:e}},Pe=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},Dt=function(t,e,n){var s=n.length,i=Ot(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},At=function(t,e,n,s,i,r,a,l,o,u,c){ge(e,c++,n),++i[256];for(var d=ct(i,15),p=d.t,b=d.l,w=ct(r,15),y=w.t,E=w.l,R=Rt(p),j=R.c,A=R.n,k=Rt(y),C=k.c,_=k.n,M=new se(19),I=0;I<j.length;++I)++M[j[I]&31];for(var I=0;I<C.length;++I)++M[C[I]&31];for(var T=ct(M,7),L=T.t,$=T.l,F=19;F>4&&!L[_t[F-1]];--F);var z=u+5<<3,N=Pe(i,Ee)+Pe(r,Ge)+a,P=Pe(i,p)+Pe(r,y)+a+14+3*F+Pe(M,L)+2*M[16]+3*M[17]+7*M[18];if(o>=0&&z<=N&&z<=P)return Dt(e,c,t.subarray(o,o+u));var V,G,H,v;if(ge(e,c,1+(P<N)),c+=2,P<N){V=Le(p,b,0),G=p,H=Le(y,E,0),v=y;var f=Le(L,$,0);ge(e,c,A-257),ge(e,c+5,_-1),ge(e,c+10,F-4),c+=14;for(var I=0;I<F;++I)ge(e,c+3*I,L[_t[I]]);c+=3*F;for(var h=[j,C],m=0;m<2;++m)for(var g=h[m],I=0;I<g.length;++I){var S=g[I]&31;ge(e,c,f[S]),c+=L[S],S>15&&(ge(e,c,g[I]>>5&127),c+=g[I]>>12)}}else V=$n,G=Ee,H=qn,v=Ge;for(var I=0;I<l;++I){var x=s[I];if(x>255){var S=x>>18&31;Fe(e,c,V[S+257]),c+=G[S+257],S>7&&(ge(e,c,x>>23&31),c+=it[S]);var D=x&31;Fe(e,c,H[D]),c+=v[D],D>3&&(Fe(e,c,x>>5&8191),c+=rt[D])}else Fe(e,c,V[x]),c+=G[x]}return Fe(e,c,V[256]),c+G[256]},Gn=new st([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Mt=new ae(0),Kn=function(t,e,n,s,i,r){var a=r.z||t.length,l=new ae(s+a+5*(1+Math.ceil(a/7e3))+i),o=l.subarray(s,l.length-i),u=r.l,c=(r.r||0)&7;if(e){c&&(o[0]=r.r>>3);for(var d=Gn[e-1],p=d>>13,b=d&8191,w=(1<<n)-1,y=r.p||new se(32768),E=r.h||new se(w+1),R=Math.ceil(n/3),j=2*R,A=function(ne){return(t[ne]^t[ne+1]<<R^t[ne+2]<<j)&w},k=new st(25e3),C=new se(288),_=new se(32),M=0,I=0,T=r.i||0,L=0,$=r.w||0,F=0;T+2<a;++T){var z=A(T),N=T&32767,P=E[z];if(y[N]=P,E[z]=N,$<=T){var V=a-T;if((M>7e3||L>24576)&&(V>423||!u)){c=At(t,o,0,k,C,_,I,L,F,T-F,c),L=M=I=0,F=T;for(var G=0;G<286;++G)C[G]=0;for(var G=0;G<30;++G)_[G]=0}var H=2,v=0,f=b,h=N-P&32767;if(V>2&&z==A(T-h))for(var m=Math.min(p,V)-1,g=Math.min(32767,T),S=Math.min(258,V);h<=g&&--f&&N!=P;){if(t[T+H]==t[T+H-h]){for(var x=0;x<S&&t[T+x]==t[T+x-h];++x);if(x>H){if(H=x,v=h,x>m)break;for(var D=Math.min(h,x-2),B=0,G=0;G<D;++G){var q=T-h+G&32767,O=y[q],W=q-O&32767;W>B&&(B=W,P=q)}}}N=P,P=y[N],h+=N-P&32767}if(v){k[L++]=268435456|ot[H]<<18|Nt[v];var ee=ot[H]&31,oe=Nt[v]&31;I+=it[ee]+rt[oe],++C[257+ee],++_[oe],$=T+H,++M}else k[L++]=t[T],++C[t[T]]}}for(T=Math.max(T,$);T<a;++T)k[L++]=t[T],++C[t[T]];c=At(t,o,u,k,C,_,I,L,F,T-F,c),u||(r.r=c&7|o[c/8|0]<<3,c-=7,r.h=E,r.p=y,r.i=T,r.w=$)}else{for(var T=r.w||0;T<a+u;T+=65535){var te=T+65535;te>=a&&(o[c/8|0]=u,te=a),c=Dt(o,c+1,t.subarray(T,te))}r.i=a}return Wn(l,0,s+Ot(c)+i)},Jn=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}(),Xn=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=Jn[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Lt=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),a=new ae(r.length+t.length);a.set(r),a.set(t,r.length),t=a,i.w=r.length}return Kn(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)},xi=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},Yn=function(t,e,n){for(var s=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<s.length;++a){var l=s[a],o=r[a];if(typeof l=="function"){e+=";"+o+"=";var u=l.toString();if(l.prototype)if(u.indexOf("[native code]")!=-1){var c=u.indexOf(" ",8)+1;e+=u.slice(c,u.indexOf("(",c))}else{e+=u;for(var d in l.prototype)e+=";"+o+".prototype."+d+"="+l.prototype[d].toString()}else e+=u}else n[o]=l}return e},ut=[],ki=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},Ti=function(t,e,n,s){if(!ut[n]){for(var i="",r={},a=t.length-1,l=0;l<a;++l)i=Yn(t[l],i,r);ut[n]={c:Yn(t[a],i,r),e:r}}var o=xi({},ut[n].e);return bi(ut[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,o,ki(o),s)},Ei=function(){return[ae,se,st,it,rt,_t,ot,Nt,$n,Ee,qn,Ge,at,Gn,Mt,Le,ge,Fe,ct,lt,Rt,Pe,Dt,At,Ot,Wn,Kn,Lt,_i,Qn]},Ii=function(){return[Zn,es,ht,Xn,Jn]},Qn=function(t){return postMessage(t,[t.buffer])},Ci=function(t,e,n,s,i,r){var a=Ti(n,s,i,function(l,o){a.terminate(),r(l,o)});return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},ht=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Zn=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&&ht(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)}},es=function(t){return 10+(t.filename?t.filename.length+1:0)};function _i(t,e){return Lt(t,e||{},0,0)}function Ni(t,e,n){return n||(n=e,e={}),typeof n!="function"&&Vn(7),Ci(t,e,[Ei,Ii,function(){return[ts]}],function(s){return Qn(ts(s.data[0],s.data[1]))},2,n)}function ts(t,e){e||(e={});var n=Xn(),s=t.length;n.p(t);var i=Lt(t,e,es(e),8),r=i.length;return Zn(i,e),ht(i,r-8,n.d()),ht(i,r-4,s),i}var Oi=typeof TextDecoder<"u"&&new TextDecoder,Ri=0;try{Oi.decode(Mt,{stream:!0}),Ri=1}catch{}class ns{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 Di{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new ns}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 ns}}class Ai{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Mi(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(a=>{a.filters.forEach(o=>{let u;o.type==="fetch"?(u={type:"network_request",subConditions:[],name:a.name},o.filters.forEach(c=>{const d=this.createConditionFromFilter(c);d&&u.subConditions.push(d)})):u=this.createConditionFromFilter(o),u&&(u.type==="session_duration"&&this.processDuration(u.value[0],a.name),r.push({...u,name:a.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=Be[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(a=>{let l;switch(a.key){case"url":l=e[3];break;case"status":l=e[6];break;case"method":l=e[2];break;case"duration":l=e[8];break}const o=Be[a.operator];if(o&&o(l,a.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=Be[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=Be[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=Be[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=Be[i.operator];r&&n.some(a=>r(a,i.value))&&this.trigger(i.name)})}}const Be={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},Mi=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 Li{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(c=>{const d=JSON.parse(c);s[d.key]={key:d.key,value:d.value}});const i=this.app.session.getInfo(),r=this.app.session.userInfo,a={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},l=e??this.app.session.getSessionToken(),o=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify(a)});if(o.status===200){const u=await o.json();return this.handleFlags(u.flags)}}handleFlags(e){var r;const n=[];e.forEach(a=>{a.is_persist&&n.push(a)});let s="";return this.diffPersist(n).forEach(a=>{s+=`${JSON.stringify(a)};`}),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(a=>a.key===r.key)===-1)}}const ss={htmlmasked:"hidden",masked:"obscured"},me=!(typeof window>"u"),Fi=me&&navigator.userAgent.match(/firefox|fxios/i),Pi=1e5;let Ft=me?Date.now()-performance.now():0;function Pt(){Ft=Date.now()-performance.now()}function je(){return Ft}const fe=me&&performance.now?()=>Math.round(performance.now()+Ft):()=>Date.now(),Bt="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function is(t){return t.trim().replace(/\s+/g," ")}function rs(t){return t.startsWith("https://")||t.startsWith("http://")}const dt="https://docs.openreplay.com",os={};function Ie(t,e,n="/"){os[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${dt}${n} for more information.`),os[t]=!0)}function jt(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ie('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Oe(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(ss[e]&&Ie(`"${n}" attribute`,`"${ss[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function Bi(t){try{return!!t.contentDocument}catch{return!1}}function as(t){return t.toString(16).padStart(2,"0")}function ji(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,as).join("")):Array.from({length:t||40},()=>as(Math.floor(Math.random()*16))).join("")}function zi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function zt(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function cs(t){const e=zt("MutationObserver");return new window[e](t)}function ls(t,e,n,s){const i=zt("addEventListener");try{t[i](e,n,s)}catch(r){const a=r.message;console.debug(`Openreplay: ${a}; if this error is caused by an IframeObserver, ignore it`)}}function us(t,e,n,s){const i=zt("removeEventListener");try{t[i](e,n,s)}catch(r){const a=r.message;console.debug(`Openreplay: ${a}; if this error is caused by an IframeObserver, ignore it`)}}class Ui{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 Hi=new Ui;function $i(t){Hi.addTask(t)}function hs(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]=hs(r||{},i):n[s]=i}return n}function Re(t){return[0,t]}function qi(t,e){return[5,t,e]}function Wi(t,e){return[6,t,e]}function Vi(){return[7]}function Gi(t,e,n,s,i){return[8,t,e,n,s,i]}function Ki(t,e,n){return[9,t,e,n]}function Ji(t,e,n){return[10,t,e,n]}function Xi(t){return[11,t]}function ds(t,e){return[13,t,e]}function Yi(t,e){return[14,t,e]}function Qi(t,e,n){return[16,t,e,n]}function Zi(t,e,n){return[18,t,e,n]}function er(t,e){return[19,t,e]}function tr(t,e){return[20,t,e]}function nr(t,e){return[22,t,e]}function sr(t,e,n,s,i,r,a,l,o){return[23,t,e,n,s,i,r,a,l,o]}function ir(t,e,n){return[24,t,e,n]}function rr(t,e){return[27,t,e]}function or(t){return[28,t]}function ar(t){return[29,t]}function fs(t,e){return[30,t,e]}function cr(t,e,n,s){return[49,t,e,n,s]}function lr(t,e){return[54,t,e]}function ur(t){return[55,t]}function ps(t,e,n,s){return[57,t,e,n,s]}function gs(t){return[58,t]}function Ut(t,e,n,s){return[60,t,e,n,s]}function hr(t,e,n){return[61,t,e,n]}function dr(t,e){return[63,t,e]}function fr(t,e){return[64,t,e]}function pr(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function Ht(t,e){return[70,t,e]}function ms(t,e,n){return[71,t,e,n]}function $t(t,e,n,s){return[73,t,e,n,s]}function vs(t,e){return[75,t,e]}function bs(t,e){return[76,t,e]}function gr(t,e){return[77,t,e]}function qt(t,e,n,s){return[78,t,e,n,s]}function ft(t,e,n,s,i,r,a,l,o){return[83,t,e,n,s,i,r,a,l,o]}function mr(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function vr(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function ys(t,e,n){return[113,t,e,n]}function br(t){return[114,t]}function yr(t){return[115,t]}function ws(t,e,n,s,i,r,a,l,o,u){return[116,t,e,n,s,i,r,a,l,o,u]}function pt(t){return[117,t]}function De(t){return[118,t]}function wr(t,e){return[119,t,e]}function Sr(t){return[120,t]}function xr(t,e,n,s){return[122,t,e,n,s]}const Wt=me&&"performance"in window&&"memory"in performance?performance:{memory:{}},Vt=me?(navigator.deviceMemory||0)*1024:0,Gt=Wt.memory.jsHeapSizeLimit||0;function kr(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 a=()=>{s===void 0||i===void 0||(t.send(cr(s,i,Wt.memory.totalJSHeapSize||0,Wt.memory.usedJSHeapSize||0)),i=s=document.hidden?-1:0)};t.attachStartCallback(()=>{i=s=-1,a(),r()}),t.attachStopCallback(()=>{i=s=void 0}),t.ticker.attach(a,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",a,!1,!1)}const Ss="__or__watched_tags__";class Tr{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ss)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(a=>{if(a.isIntersecting&&a.target){const l=a.target.__or_watcher_tagname;l&&this.onTagRendered(l),this.observer.unobserve(a.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(Ss,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 Er={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"'},Ir={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},gt={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"},Cr={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},_r={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"},Nr={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"},xs={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},ze={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Or={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"},Ue={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"},Rr={...Ue,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},ks={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Ts={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"},Es={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Dr={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Is={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Ar={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"},Cs={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"},_s={fontWeight:"bold"},Mr={fontSize:"13px",lineHeight:"auto"},Ns={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Lr={...Ns,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Fr={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},Pr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Os={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class Br{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=a=>{a.data.size>0&&this.recordedChunks.push(a.data)},this.mediaRecorder.start()}catch(a){console.error(a)}}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 jr(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,a(n.pageX,n.pageY);function a(u,c){let d=u-i,p=c-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 l(u){a(u.pageX,u.pageY)}document.addEventListener("mousemove",l);const o=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",o)};document.addEventListener("mouseup",o)},e.ondragstart=function(){return!1}}function zr(){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 Ur(){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 Hr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
|
|
1
|
+
(function(nt){typeof define=="function"&&define.amd?define(nt):nt()})(function(){"use strict";var ai,ci;function nt(){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 Bn(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 gi(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 mi(){const t="uniqueUserID";let e=gi(t);return e||(e=nt(),Bn(t,e,365)),e}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(v){try{return localStorage.getItem(v)||null}catch{return null}},getItem:function(v,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(v);f==null||f(null,S),m(S)}catch(x){f&&f(x,null),g(x)}})},setItem:function(v,f,h){return new Promise(function(m,g){try{localStorage.setItem(v,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(v){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(v[g]=f[g]);return v},i.apply(this,arguments)};function r(v,f,h,m){return new(h||(h=Promise))(function(g,S){function x(q){try{P(m.next(q))}catch(N){S(N)}}function D(q){try{P(m.throw(q))}catch(N){S(N)}}function P(q){var N;q.done?g(q.value):(N=q.value,N instanceof h?N:new h(function(W){W(N)})).then(x,D)}P((m=m.apply(v,f||[])).next())})}function o(v,f){var h,m,g,S,x={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:D(0),throw:D(1),return:D(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function D(P){return function(q){return function(N){if(h)throw new TypeError("Generator is already executing.");for(;x;)try{if(h=1,m&&(g=2&N[0]?m.return:N[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,N[1])).done)return g;switch(m=0,g&&(N=[2&N[0],g.value]),N[0]){case 0:case 1:g=N;break;case 4:return x.label++,{value:N[1],done:!1};case 5:x.label++,m=N[1],N=[0];continue;case 7:N=x.ops.pop(),x.trys.pop();continue;default:if(g=x.trys,!((g=g.length>0&&g[g.length-1])||N[0]!==6&&N[0]!==2)){x=0;continue}if(N[0]===3&&(!g||N[1]>g[0]&&N[1]<g[3])){x.label=N[1];break}if(N[0]===6&&x.label<g[1]){x.label=g[1],g=N;break}if(g&&x.label<g[2]){x.label=g[2],x.ops.push(N);break}g[2]&&x.ops.pop(),x.trys.pop();continue}N=f.call(v,x)}catch(W){N=[6,W],m=0}finally{h=g=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([P,q])}}}function l(v,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 v.concat(m||Array.prototype.slice.call(f))}var c=function v(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(!v(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 x=S[g];if(!v(f[x],h[x]))return!1}return!0}return f!=f&&h!=h};function u(v,f){var h=Object.keys(f||{}).filter(function(m){var g=v==null?void 0:v[m],S=f==null?void 0:f[m];return!c(g,S)});return Object.keys(v||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var a,d;function p(v,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),v[m]=v[m]||{},v[m][f]=g?h+"":h}function b(v){return!!v&&typeof v=="object"&&v.value!==void 0}function w(v){return Object.fromEntries(Object.entries(v).map(function(f){var h=f[0],m=f[1];return[h,b(m)?m:{value:m}]}))}function y(v){return i(i({},v),{identity:v.identity?i(i({},v.identity),{traits:w(v.identity.traits||{})}):void 0})}(function(v){v.NONE="NONE",v.DEFAULT_FLAGS="DEFAULT_FLAGS",v.CACHE="CACHE",v.SERVER="SERVER"})(a||(a={}));var E,O=null,B="BULLET_TRAIN_DB",A="BULLET_TRAIN_EVENT",k="https://edge.api.flagsmith.com/api/v1/",_="flagsmith_value_",R="flagsmith_enabled_",M="flagsmith_trait_",I=function(){function v(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 x="".concat(h.getContext().identity),D=function(P){var q,N,W,ee;if(P&&x==="".concat(h.getContext().identity)){var oe=P.flags,te=P.traits,ne=P.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=u(h.oldFlags,ue),Ye=u((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.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:Ye},h._loadedState(null,a.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var Qe={};Object.keys(((N=h.evaluationContext.identity)===null||N===void 0?void 0:N.traits)||{}).map(function(K){Qe[M+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.identifier)}),Qe);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,_+K,h.getValue(K,{skipAnalytics:!0})),p(ie,R+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,M+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(P){var q=P[0],N=P[1];return{trait_key:q,trait_value:N==null?void 0:N.value,transient:N==null?void 0:N.transient}}).filter(function(P){return P.trait_value!==void 0||(h.log("Warning - attempted to set an undefined trait value for key",P.trait_key),!1)})})):h.getJSON(g+"identities/?identifier="+encodeURIComponent(S.identity.identifier)+(S.identity.transient?"&transient=true":""))]).then(function(P){return h.evaluationContext.identity=i(i({},h.evaluationContext.identity),{traits:{}}),D(P==null?void 0:P[0])}).catch(function(P){var q=P.message,N=new Error(q);return Promise.reject(N)}):h.getJSON(g+"flags/").then(function(P){return D({flags:P,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 x=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],D=null;if(x&&(D=x.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),D===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return D===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(D)}catch{return g.fallback}return D},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],x=g[1];return[S,x==null?void 0:x.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 x=S[0],D=S[1];return[x,b(D)?D:{value:D}]})))})}));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",x=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],D=!1;return!x&&S&&g.fallback!==void 0?D=g==null?void 0:g.fallback:x&&x.enabled&&(D=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),D},this.getJSON=function(m,g,S){var x,D=h;D.evaluationContext;var P=D.headers,q={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(q.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(q.headers["Content-Type"]="application/json; charset=utf-8"),P&&Object.assign(q.headers,P),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var N="".concat((x=h.evaluationContext.identity)===null||x===void 0?void 0:x.identifier);return d(m,q).then(function(W){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(N===te){var ne=(oe=W.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: "+W.status+" "+(g||"GET")+0+m),W.text().then(function(he){var ye=he;try{ye=JSON.parse(he)}catch{}return!ye&&W.status&&(ye="API Response: ".concat(W.status)),W.status&&W.status>=200&&W.status<300?ye:Promise.reject(new Error(ye))})}h.log("Received response with identity mismatch, ignoring response. Requested: ".concat(N,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(h.datadogRum&&(h.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?h.datadogRum.client.addFeatureFlagEvaluation(_+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(R+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 x,D;h.setLoadingState(S),(x=h.onChange)===null||x===void 0||x.call(h,m,g,h.loadingState),(D=h._trigger)===null||D===void 0||D.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&&(E=f.eventSource),f.AsyncStorage&&(O=f.AsyncStorage)}return v.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,x,D,P,q,N,W,ee,oe,te,ne,ue,he,ye,Ye,Qe,qe,ie,K,vn,Ze,li,et,bn,ui,hi,yn,di,wn,tt,We,fi,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]),x=f.environmentID,D=f.api,P=D===void 0?k:D,q=f.headers,N=f.onChange,W=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,ye=f.enableDynatrace,Ye=f.enableAnalytics,Qe=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,vn=f.identity,Ze=f.traits,li=f.state,et=f.cacheOptions,bn=f.angularHttpClient,ui=f._trigger,hi=f._triggerLoadingState,S.environment=x?{apiKey:x}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=vn||Ze?{identifier:vn,traits:Ze?Object.fromEntries(Object.entries(Ze).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=P,this.headers=q,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=N,yn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=ui||this._trigger,this._triggerLoadingState=hi||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=et?{skipAPI:!!et.skipAPI,ttl:et.ttl||0,loadStale:!!et.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=Ye||!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=O!==void 0&&!!W,K&&(O=K),Qe&&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(li),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),bn&&(d=function(de){return function(we,Se){var _e=Se.headers,X=Se.method,Ve=Se.body;return new Promise(function(Ae){switch(X){case"GET":return de.get(we,{headers:_e}).subscribe(function(ke){Ae({ok:!0,text:function(){return Promise.resolve(ke)}})});case"POST":case"PUT":return de.post(we,Ve,{headers:_e}).subscribe(function(ke){Ae({ok:!0,text:function(){return Promise.resolve(ke)}})})}})}}(bn)),O&&this.canUseStorage&&O.getItem(A).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),O&&this.canUseStorage&&O.getItem(A,function(de,we){if(we&&re.evaluationContext.environment){var Se=JSON.parse(we);if(Se[re.evaluationContext.environment.apiKey]){var _e=re.getState();re.log("Retrieved events from cache",we),re.setState(i(i({},_e),{evaluationEvent:Se[re.evaluationContext.environment.apiKey]}))}}})),!W)return[3,9];if(!O||!this.canUseStorage)return[3,8];di=function(de,we){return r(re,void 0,void 0,function(){var Se,_e,X,Ve,Ae,ke,Sn,pi,xn,kn,Tn,En,In,Cn,_n,Nn,On,Rn,Dn,An,Mn,Ln,Fn,Pn;return o(this,function(Ne){switch(Ne.label){case 0:if(!we)return[3,7];Se=null,_e=null,Ne.label=1;case 1:return Ne.trys.push([1,5,,6]),X=JSON.parse(we),Ve=!1,Ae=!1,X&&X.api===this.api&&((kn=(xn=X.evaluationContext)===null||xn===void 0?void 0:xn.environment)===null||kn===void 0?void 0:kn.apiKey)===((Tn=this.evaluationContext.environment)===null||Tn===void 0?void 0:Tn.apiKey)&&(ke=!0,this.evaluationContext.identity&&((In=(En=X.evaluationContext)===null||En===void 0?void 0:En.identity)===null||In===void 0?void 0:In.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((_n=(Cn=X.evaluationContext)===null||Cn===void 0?void 0:Cn.identity)===null||_n===void 0?void 0:_n.identifier)+" to "+this.evaluationContext.identity.identifier),ke=!1),this.cacheOptions.ttl&&(!X.ts||new Date().valueOf()-X.ts>this.cacheOptions.ttl)&&(X.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+X.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-X.ts)+"ms"),ke=!1):X.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+X.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-X.ts)+"ms"),Ae=!0,ke=!0)),ke&&(Ve=!0,_e=u((Nn=this.evaluationContext.identity)===null||Nn===void 0?void 0:Nn.traits,(Rn=(On=X.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.traits),Se=u(this.flags,X.flags),this.setState(i(i({},X),{evaluationContext:y(i(i({},X.evaluationContext),{identity:!((Dn=X.evaluationContext)===null||Dn===void 0)&&Dn.identity?i(i({},(An=X.evaluationContext)===null||An===void 0?void 0:An.identity),{traits:i(i({},((Ln=(Mn=X.evaluationContext)===null||Mn===void 0?void 0:Mn.identity)===null||Ln===void 0?void 0:Ln.traits)||{}),Ze||{})}):void 0}))})),this.log("Retrieved flags from cache",X))),Ve?(Sn=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:Se,traitsChanged:_e},this._loadedState(null,a.CACHE,Sn)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ve&&!Ae&&this.log("Skipping API, using cache"),Sn&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Ne.sent(),Ne.label=4;case 4:return[3,6];case 5:return pi=Ne.sent(),this.log("Exception fetching cached logs",pi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Ne.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(Fn=this.evaluationContext.identity)===null||Fn===void 0?void 0:Fn.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(yn);this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(Pn=this.evaluationContext.identity)===null||Pn===void 0?void 0:Pn.traits)},this._loadedState(null,a.DEFAULT_FLAGS))}Ne.label=10;case 10:return[2]}})})},pe.label=2;case 2:return pe.trys.push([2,7,,8]),O.getItemSync?(wn=O.getItemSync(B),[3,5]):[3,3];case 3:return[4,O.getItem(B)];case 4:wn=pe.sent(),pe.label=5;case 5:return[4,di(null,wn)];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:u({},te),traitsChanged:u({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else if(this.flags&&(tt=null,Object.keys(this.flags).length===0&&(tt=yn),this._onChange(null,{isFromServer:!1,flagsChanged:u({},this.flags),traitsChanged:u({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(tt,a.DEFAULT_FLAGS)),tt))throw new Error(tt);pe.label=12;case 12:return[3,14];case 13:throw We=pe.sent(),this.log("Error during initialisation ",We),fi=We instanceof Error?We:new Error("".concat(We)),(g=this.onError)===null||g===void 0||g.call(this,fi),We;case 14:return[2]}})})},v.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}},v.prototype.getAllFlags=function(){return this.flags},v.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],x=g[1];return[S,b(x)?x:{value:x}]}))),this.initialised?this.getFlags():Promise.resolve()},v.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},v.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||k,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},v.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},v.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},v.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},v.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,l(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},v.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),O.setItem(B,f)}},v.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);O.setItem(A,f)}},v.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))},v.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";E?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new E(g),this.eventSource.addEventListener("environment_updated",function(S){var x;try{x=JSON.parse(S.data).updated_at}catch(D){m.log("Could not parse sse event",D)}x?!m.timestamp||x>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")},v}();function T(v){var f=v.fetch,h=v.AsyncStorage,m=v.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var F,H=(F=function(v,f){return F=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])},F(v,f)},function(v,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=v}F(v,f),v.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),j=function(v){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&v[f],m=0;if(h)return h.call(v);if(v&&typeof v.length=="number")return{next:function(){return v&&m>=v.length&&(v=void 0),{value:v&&v[m++],done:!v}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(v,f){var h=typeof Symbol=="function"&&v[Symbol.iterator];if(!h)return v;var m,g,S=h.call(v),x=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)x.push(m.value)}catch(D){g={error:D}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return x},C=function(v,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 v.concat(m||Array.prototype.slice.call(f))},L=function(v){function f(){return v.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,v),f}(Error),V=function(){function v(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 L;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return v.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},v.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(P){m._onopen(P)},this._eventSource.onerror=function(P){m._onerror(P)},this._eventSource.onmessage=function(P){m.onmessage(P)};try{for(var S=j(Object.keys(this._listeners)),x=S.next();!x.done;x=S.next()){var D=x.value;this._eventSource.addEventListener(D,this._onevent_wrapped)}}catch(P){f={error:P}}finally{try{x&&!x.done&&(h=S.return)&&h.call(S)}finally{if(f)throw f.error}}},v.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},v.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)}},v.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(C([],z(g),!1)),x=S.next();!x.done;x=S.next())x.value.call(this,f)}catch(D){h={error:D}}finally{try{x&&!x.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}f.type==="message"&&this.onmessage(f)},v.prototype.onopen=function(f){},v.prototype.onerror=function(f){},v.prototype.onmessage=function(f){},v.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},v.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]=C(C([],z(g),!1),[h],!1))},v.prototype.removeEventListener=function(f,h,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(S){return S!==h})},v}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var G=function(v,f){return f=f||{},new Promise(function(h,m){var g=new XMLHttpRequest,S=[],x=[],D={},P=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:P,headers:{keys:function(){return S},entries:function(){return x},get:function(N){return D[N.toLowerCase()]},has:function(N){return N.toLowerCase()in D}}}};for(var q in g.open(f.method||"get",v,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(N,W,ee){S.push(W=W.toLowerCase()),x.push([W,ee]),D[W]=D[W]?D[W]+","+ee:ee}),h(P())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(q,f.headers[q]);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})})})(jn,jn.exports);var zn={},bi=function(t,e,n,s,i){var r=new Worker(zn[e]||(zn[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 l=o.data,c=l.$e$;if(c){var u=new Error(c[0]);u.code=c[1],u.stack=c[2],i(u,null)}else i(null,l)},r.postMessage(n,s),r},ae=Uint8Array,se=Uint16Array,st=Int32Array,it=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]),rt=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]),_t=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Un=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 st(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}},Hn=Un(it,2),yi=Hn.b,ot=Hn.r;yi[28]=258,ot[258]=28;for(var wi=Un(rt,0),Nt=wi.r,at=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,at[J]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var Le=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 l;if(n){l=new se(1<<e);var c=15-e;for(i=0;i<s;++i)if(t[i])for(var u=i<<4|t[i],a=e-t[i],d=o[t[i]-1]++<<a,p=d|(1<<a)-1;d<=p;++d)l[at[d]>>c]=u}else for(l=new se(s),i=0;i<s;++i)t[i]&&(l[i]=at[o[t[i]-1]++]>>15-t[i]);return l},Ee=new ae(288),J=0;J<144;++J)Ee[J]=8;for(var J=144;J<256;++J)Ee[J]=9;for(var J=256;J<280;++J)Ee[J]=7;for(var J=280;J<288;++J)Ee[J]=8;for(var Ge=new ae(32),J=0;J<32;++J)Ge[J]=5;var $n=Le(Ee,9,0),qn=Le(Ge,5,0),Ot=function(t){return(t+7)/8|0},Wn=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))},Si=["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"],Vn=function(t,e,n){var s=new Error(e||Si[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,Vn),!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},Fe=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},ct=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:Mt,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(_,R){return _.f-R.f}),n.push({s:-1,f:25001});var l=n[0],c=n[1],u=0,a=1,d=2;for(n[0]={s:-1,f:l.f+c.f,l,r:c};a!=i-1;)l=n[n[u].f<n[d].f?u++:d++],c=n[u!=a&&n[u].f<n[d].f?u++:d++],n[a++]={s:-1,f:l.f+c.f,l,r:c};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var b=new se(p+1),w=lt(n[a-1],b,0);if(w>e){var s=0,y=0,E=w-e,O=1<<E;for(r.sort(function(R,M){return b[M.s]-b[R.s]||R.f-M.f});s<i;++s){var B=r[s].s;if(b[B]>e)y+=O-(1<<w-b[B]),b[B]=e;else break}for(y>>=E;y>0;){var A=r[s].s;b[A]<e?y-=1<<e-b[A]++-1:++s}for(;s>=0&&y;--s){var k=r[s].s;b[k]==e&&(--b[k],++y)}w=e}return{t:new ae(b),l:w}},lt=function(t,e,n){return t.s==-1?Math.max(lt(t.l,e,n+1),lt(t.r,e,n+1)):e[t.s]=n},Rt=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},l=1;l<=e;++l)if(t[l]==i&&l!=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[l]}return{c:n.subarray(0,s),n:e}},Pe=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},Dt=function(t,e,n){var s=n.length,i=Ot(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},At=function(t,e,n,s,i,r,o,l,c,u,a){ge(e,a++,n),++i[256];for(var d=ct(i,15),p=d.t,b=d.l,w=ct(r,15),y=w.t,E=w.l,O=Rt(p),B=O.c,A=O.n,k=Rt(y),_=k.c,R=k.n,M=new se(19),I=0;I<B.length;++I)++M[B[I]&31];for(var I=0;I<_.length;++I)++M[_[I]&31];for(var T=ct(M,7),F=T.t,H=T.l,j=19;j>4&&!F[_t[j-1]];--j);var z=u+5<<3,C=Pe(i,Ee)+Pe(r,Ge)+o,L=Pe(i,p)+Pe(r,y)+o+14+3*j+Pe(M,F)+2*M[16]+3*M[17]+7*M[18];if(c>=0&&z<=C&&z<=L)return Dt(e,a,t.subarray(c,c+u));var V,G,$,v;if(ge(e,a,1+(L<C)),a+=2,L<C){V=Le(p,b,0),G=p,$=Le(y,E,0),v=y;var f=Le(F,H,0);ge(e,a,A-257),ge(e,a+5,R-1),ge(e,a+10,j-4),a+=14;for(var I=0;I<j;++I)ge(e,a+3*I,F[_t[I]]);a+=3*j;for(var h=[B,_],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+=F[S],S>15&&(ge(e,a,g[I]>>5&127),a+=g[I]>>12)}}else V=$n,G=Ee,$=qn,v=Ge;for(var I=0;I<l;++I){var x=s[I];if(x>255){var S=x>>18&31;Fe(e,a,V[S+257]),a+=G[S+257],S>7&&(ge(e,a,x>>23&31),a+=it[S]);var D=x&31;Fe(e,a,$[D]),a+=v[D],D>3&&(Fe(e,a,x>>5&8191),a+=rt[D])}else Fe(e,a,V[x]),a+=G[x]}return Fe(e,a,V[256]),a+G[256]},Gn=new st([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Mt=new ae(0),Kn=function(t,e,n,s,i,r){var o=r.z||t.length,l=new ae(s+o+5*(1+Math.ceil(o/7e3))+i),c=l.subarray(s,l.length-i),u=r.l,a=(r.r||0)&7;if(e){a&&(c[0]=r.r>>3);for(var d=Gn[e-1],p=d>>13,b=d&8191,w=(1<<n)-1,y=r.p||new se(32768),E=r.h||new se(w+1),O=Math.ceil(n/3),B=2*O,A=function(ne){return(t[ne]^t[ne+1]<<O^t[ne+2]<<B)&w},k=new st(25e3),_=new se(288),R=new se(32),M=0,I=0,T=r.i||0,F=0,H=r.w||0,j=0;T+2<o;++T){var z=A(T),C=T&32767,L=E[z];if(y[C]=L,E[z]=C,H<=T){var V=o-T;if((M>7e3||F>24576)&&(V>423||!u)){a=At(t,c,0,k,_,R,I,F,j,T-j,a),F=M=I=0,j=T;for(var G=0;G<286;++G)_[G]=0;for(var G=0;G<30;++G)R[G]=0}var $=2,v=0,f=b,h=C-L&32767;if(V>2&&z==A(T-h))for(var m=Math.min(p,V)-1,g=Math.min(32767,T),S=Math.min(258,V);h<=g&&--f&&C!=L;){if(t[T+$]==t[T+$-h]){for(var x=0;x<S&&t[T+x]==t[T+x-h];++x);if(x>$){if($=x,v=h,x>m)break;for(var D=Math.min(h,x-2),P=0,G=0;G<D;++G){var q=T-h+G&32767,N=y[q],W=q-N&32767;W>P&&(P=W,L=q)}}}C=L,L=y[C],h+=C-L&32767}if(v){k[F++]=268435456|ot[$]<<18|Nt[v];var ee=ot[$]&31,oe=Nt[v]&31;I+=it[ee]+rt[oe],++_[257+ee],++R[oe],H=T+$,++M}else k[F++]=t[T],++_[t[T]]}}for(T=Math.max(T,H);T<o;++T)k[F++]=t[T],++_[t[T]];a=At(t,c,u,k,_,R,I,F,j,T-j,a),u||(r.r=a&7|c[a/8|0]<<3,a-=7,r.h=E,r.p=y,r.i=T,r.w=H)}else{for(var T=r.w||0;T<o+u;T+=65535){var te=T+65535;te>=o&&(c[a/8|0]=u,te=o),a=Dt(c,a+1,t.subarray(T,te))}r.i=o}return Wn(l,0,s+Ot(a)+i)},Jn=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}(),Xn=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=Jn[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Lt=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 Kn(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)},xi=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},Yn=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 l=s[o],c=r[o];if(typeof l=="function"){e+=";"+c+"=";var u=l.toString();if(l.prototype)if(u.indexOf("[native code]")!=-1){var a=u.indexOf(" ",8)+1;e+=u.slice(a,u.indexOf("(",a))}else{e+=u;for(var d in l.prototype)e+=";"+c+".prototype."+d+"="+l.prototype[d].toString()}else e+=u}else n[c]=l}return e},ut=[],ki=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},Ti=function(t,e,n,s){if(!ut[n]){for(var i="",r={},o=t.length-1,l=0;l<o;++l)i=Yn(t[l],i,r);ut[n]={c:Yn(t[o],i,r),e:r}}var c=xi({},ut[n].e);return bi(ut[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,ki(c),s)},Ei=function(){return[ae,se,st,it,rt,_t,ot,Nt,$n,Ee,qn,Ge,at,Gn,Mt,Le,ge,Fe,ct,lt,Rt,Pe,Dt,At,Ot,Wn,Kn,Lt,_i,Qn]},Ii=function(){return[Zn,es,ht,Xn,Jn]},Qn=function(t){return postMessage(t,[t.buffer])},Ci=function(t,e,n,s,i,r){var o=Ti(n,s,i,function(l,c){o.terminate(),r(l,c)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},ht=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Zn=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&&ht(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)}},es=function(t){return 10+(t.filename?t.filename.length+1:0)};function _i(t,e){return Lt(t,e||{},0,0)}function Ni(t,e,n){return n||(n=e,e={}),typeof n!="function"&&Vn(7),Ci(t,e,[Ei,Ii,function(){return[ts]}],function(s){return Qn(ts(s.data[0],s.data[1]))},2,n)}function ts(t,e){e||(e={});var n=Xn(),s=t.length;n.p(t);var i=Lt(t,e,es(e),8),r=i.length;return Zn(i,e),ht(i,r-8,n.d()),ht(i,r-4,s),i}var Oi=typeof TextDecoder<"u"&&new TextDecoder,Ri=0;try{Oi.decode(Mt,{stream:!0}),Ri=1}catch{}class ns{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 Di{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new ns}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 ns}}class Ai{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Mi(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 u;c.type==="fetch"?(u={type:"network_request",subConditions:[],name:o.name},c.filters.forEach(a=>{const d=this.createConditionFromFilter(a);d&&u.subConditions.push(d)})):u=this.createConditionFromFilter(c),u&&(u.type==="session_duration"&&this.processDuration(u.value[0],o.name),r.push({...u,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=Be[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 l;switch(o.key){case"url":l=e[3];break;case"status":l=e[6];break;case"method":l=e[2];break;case"duration":l=e[8];break}const c=Be[o.operator];if(c&&c(l,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=Be[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=Be[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=Be[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=Be[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const Be={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},Mi=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 Li{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},l=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 ${l}`},body:JSON.stringify(o)});if(c.status===200){const u=await c.json();return this.handleFlags(u.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 ss={htmlmasked:"hidden",masked:"obscured"},me=!(typeof window>"u"),Fi=me&&navigator.userAgent.match(/firefox|fxios/i),Pi=1e5;let Ft=me?Date.now()-performance.now():0;function Pt(){Ft=Date.now()-performance.now()}function je(){return Ft}const fe=me&&performance.now?()=>Math.round(performance.now()+Ft):()=>Date.now(),Bt="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function is(t){return t.trim().replace(/\s+/g," ")}function rs(t){return t.startsWith("https://")||t.startsWith("http://")}const dt="https://docs.openreplay.com",os={};function Ie(t,e,n="/"){os[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${dt}${n} for more information.`),os[t]=!0)}function jt(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ie('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Oe(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(ss[e]&&Ie(`"${n}" attribute`,`"${ss[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function Bi(t){try{return!!t.contentDocument}catch{return!1}}function as(t){return t.toString(16).padStart(2,"0")}function ji(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,as).join("")):Array.from({length:t||40},()=>as(Math.floor(Math.random()*16))).join("")}function zi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function zt(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function cs(t){const e=zt("MutationObserver");return new window[e](t)}function ls(t,e,n,s){const i=zt("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 us(t,e,n,s){const i=zt("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 Ui{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 Hi=new Ui;function $i(t){Hi.addTask(t)}function hs(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]=hs(r||{},i):n[s]=i}return n}function Re(t){return[0,t]}function qi(t,e){return[5,t,e]}function Wi(t,e){return[6,t,e]}function Vi(){return[7]}function Gi(t,e,n,s,i){return[8,t,e,n,s,i]}function Ki(t,e,n){return[9,t,e,n]}function Ji(t,e,n){return[10,t,e,n]}function Xi(t){return[11,t]}function ds(t,e){return[13,t,e]}function Yi(t,e){return[14,t,e]}function Qi(t,e,n){return[16,t,e,n]}function Zi(t,e,n){return[18,t,e,n]}function er(t,e){return[19,t,e]}function tr(t,e){return[20,t,e]}function nr(t,e){return[22,t,e]}function sr(t,e,n,s,i,r,o,l,c){return[23,t,e,n,s,i,r,o,l,c]}function ir(t,e,n){return[24,t,e,n]}function rr(t,e){return[27,t,e]}function or(t){return[28,t]}function ar(t){return[29,t]}function fs(t,e){return[30,t,e]}function cr(t,e,n,s){return[49,t,e,n,s]}function lr(t,e){return[54,t,e]}function ur(t){return[55,t]}function ps(t,e,n,s){return[57,t,e,n,s]}function gs(t){return[58,t]}function Ut(t,e,n,s){return[60,t,e,n,s]}function hr(t,e,n){return[61,t,e,n]}function dr(t,e){return[63,t,e]}function fr(t,e){return[64,t,e]}function pr(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function Ht(t,e){return[70,t,e]}function ms(t,e,n){return[71,t,e,n]}function $t(t,e,n,s){return[73,t,e,n,s]}function vs(t,e){return[75,t,e]}function bs(t,e){return[76,t,e]}function gr(t,e){return[77,t,e]}function qt(t,e,n,s){return[78,t,e,n,s]}function ft(t,e,n,s,i,r,o,l,c){return[83,t,e,n,s,i,r,o,l,c]}function mr(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function vr(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function ys(t,e,n){return[113,t,e,n]}function br(t){return[114,t]}function yr(t){return[115,t]}function ws(t,e,n,s,i,r,o,l,c,u){return[116,t,e,n,s,i,r,o,l,c,u]}function pt(t){return[117,t]}function De(t){return[118,t]}function wr(t,e){return[119,t,e]}function Sr(t){return[120,t]}function xr(t,e,n,s){return[122,t,e,n,s]}const Wt=me&&"performance"in window&&"memory"in performance?performance:{memory:{}},Vt=me?(navigator.deviceMemory||0)*1024:0,Gt=Wt.memory.jsHeapSizeLimit||0;function kr(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(cr(s,i,Wt.memory.totalJSHeapSize||0,Wt.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 Ss="__or__watched_tags__";class Tr{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ss)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const l=o.target.__or_watcher_tagname;l&&this.onTagRendered(l),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(Ss,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 Er={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"'},Ir={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},gt={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"},Cr={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},_r={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"},Nr={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"},xs={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},ze={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Or={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"},Ue={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"},Rr={...Ue,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},ks={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Ts={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"},Es={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Dr={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Is={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Ar={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"},Cs={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"},_s={fontWeight:"bold"},Mr={fontSize:"13px",lineHeight:"auto"},Ns={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Lr={...Ns,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Fr={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},Pr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Os={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class Br{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 jr(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(u,a){let d=u-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 l(u){o(u.pageX,u.pageY)}document.addEventListener("mousemove",l);const c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mouseup",c)},e.ondragstart=function(){return!1}}function zr(){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 Ur(){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 Hr(){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
|
-
}`,document.head.appendChild(t)}function $r(){Hr();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,Pr),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 mt="or_uxt_test_start",Kt="or_uxt_task_index",Jt="or_uxt_session_id",qr="or_uxt_test_id";class Wr{constructor(e,n,s,i,r,
|
|
5
|
+
}`,document.head.appendChild(t)}function $r(){Hr();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,Pr),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 mt="or_uxt_test_start",Kt="or_uxt_task_index",Jt="or_uxt_session_id",qr="or_uxt_test_id";class Wr{constructor(e,n,s,i,r,o,l,c,u){this.ingestPoint=e,this.getTimestamp=n,this.token=s,this.testId=i,this.storageKey=r,this.setStorageKey=o,this.removeStorageKey=l,this.getStorageKey=c,this.getSessionId=u,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,b)=>{if(!d)return console.error("User Testing: No Task ID Given");const w=this.durations.tasks.find(O=>O.taskId===d),y=this.getTimestamp(),E=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:E,timestamp:y,taskAnswer:b})})},this.signalTest=d=>{const p=this.getTimestamp();if(d==="begin"&&this.testId){const y=this.getSessionId();this.setStorageKey(Jt,y),this.setStorageKey(this.storageKey,this.testId.toString()),this.setStorageKey(mt,p.toString())}else this.removeStorageKey(this.storageKey),this.removeStorageKey(Kt),this.removeStorageKey(mt);const b=this.durations.testStart||p,w=p-b;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(mt);a&&(this.durations.testStart=parseInt(a,10))}}class Vr{constructor(e,n){this.app=e,this.storageKey=n,this.bg=U("div","bg",Er,void 0,"__or_ut_bg"),this.container=U("div","container",Ir,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,l,c)=>{this.testId=o;const u=this.app.options.ingestPoint;return fetch(`${u}/v1/web/uxt/test/${o}`,{headers:{Authorization:`Bearer ${l}`}}).then(a=>a.json()).then(({test:a})=>{this.isActive=!0,this.test=a,this.signalManager=new Wr(this.app.options.ingestPoint,()=>this.app.timestamp(),l,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,Os.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 Br(e);const s=this.app.getSessionID(),i=this.app.localStorage.getItem(Jt);s!==i&&(this.app.localStorage.removeItem(this.storageKey),this.app.localStorage.removeItem(Jt),this.app.localStorage.removeItem(qr),this.app.localStorage.removeItem(Kt),this.app.localStorage.removeItem(mt));const r=this.app.localStorage.getItem(Kt);r&&(this.currentTaskIndex=parseInt(r,10))}getTestId(){return this.testId}createGreeting(e,n,s){const i=U("div","title",Cr,e),r=U("div","description",_r,`Welcome, you're here to help us improve, not to be judged. Your insights matter!
|
|
6
6
|
|
|
7
7
|
📹 We're recording this browser tab to learn from your experience.
|
|
8
|
-
🎤 Please enable mic and camera if asked, to give us a complete picture.`),
|
|
9
|
-
|
|
10
|
-
We appreciate your time and valuable input.`),r=U("div","end_button_or",Ts,"Submitting Feedback"),a=$r();r.appendChild(a),(u=this.test)!=null&&u.reqMic||(c=this.test)!=null&&c.reqCamera?this.userRecorder.sendToAPI().then(()=>{r.removeChild(a),r.textContent="End Session",e=!1}).catch(d=>{console.error(d),r.removeChild(a),r.textContent="End Session",e=!1}):(r.removeChild(a),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 Rs(t){return!!t&&t.nodeType!=null}function Xt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function xe(t){return t.nodeType===Node.ELEMENT_NODE}function Gr(t){return t.nodeType===Node.COMMENT_NODE}function Yt(t){return t.nodeType===Node.TEXT_NODE}function vt(t){return t.nodeType===Node.DOCUMENT_NODE}function bt(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Y(t,e){return t.localName===e}class Kr{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||!Y(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Y(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.forEach(o=>{o.isIntersecting&&(o.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(o.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 a=wr(i.toString(),r);this.app.send(a);const l=u=>{Jr(u,this.options.quality,this.snapshots[i].dummy,this.options.fixedScaling,this.fileExt,c=>{c&&(this.snapshots[i].images.push({id:this.app.timestamp(),data:c}),this.snapshots[i].images.length>9&&(this.sendSnaps(this.snapshots[i].images,i,this.snapshots[i].createdAt),this.snapshots[i].images=[]))})},o=setInterval(()=>{const u=this.app.nodes.getID(s),c=u?this.app.nodes.getNode(u):void 0;!c||!Y(c,"canvas")||c!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(o)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(c)}):l(c))},this.interval);this.intervals.push(o)},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 a=r.data;a&&(i.append("snapshot",a,`${s}_${n}_${r.id}.${this.fileExt}`),this.options.isDebug&&Xr(a,`${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 Ds={low:.35,medium:.55,high:.8};function Jr(t,e="medium",n,s=!1,i,r){const a=`image/${i}`;if(s){const l=window.devicePixelRatio||1;n.width=t.width/l,n.height=t.height/l;const o=n.getContext("2d");if(!o)return"";o.clearRect(0,0,n.width,n.height),o.drawImage(t,0,0,n.width,n.height),n.toBlob(r,a,Ds[e])}else t.toBlob(r,a,Ds[e])}function Xr(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 Ke={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class Yr{constructor(e=Ke.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Ke.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Ke.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Ke.Errors)&&console.error(...n)},this.level=e}}class Qr{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;ls(e,n,s,i);let a=this.elementListeners.get(r);a===void 0&&(a=[],this.elementListeners.set(r,a)),a.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=>us(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 Qt(t){if(Gr(t))return!0;if(Yt(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 Zt(t){return bt(t)?!0:!Qt(t)}var ve;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(ve||(ve={}));class en{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=cs(this.app.safe(s=>{for(const i of s){const r=i.target,a=i.type;if(!Zt(r))continue;if(a==="childList"){for(let o=0;o<i.removedNodes.length;o++)Zt(i.removedNodes[o])&&this.bindNode(i.removedNodes[o]);for(let o=0;o<i.addedNodes.length;o++)this.bindTree(i.addedNodes[o]);continue}const l=this.app.nodes.getID(r);if(l!==void 0){if(this.recents.has(l)||this.recents.set(l,ve.Changed),a==="attributes"){const o=i.attributeName;if(o===null)continue;let u=this.attributesMap.get(l);u===void 0&&this.attributesMap.set(l,u=new Set),u.add(o);continue}if(a==="characterData"){this.textSet.add(l);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(Xt(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(ds(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Ut(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"&&Y(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(ds(e,s));return}if(s==="style"||s==="href"&&Y(n,"link")){this.app.send(Ut(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(Y(n,"style")){this.app.send(hr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(Yi(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(!Zt(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),Qt(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(Xi(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>Qt(l)||this.app.nodes.getID(l)===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 a=Math.floor(i/r*100);a>30&&this.app.send(yr(a))}}_commitNode(e,n){if(bt(n))return!0;const s=n.parentNode;let i;if(!Y(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 c=this.app.nodes.getID(r);if(c!==void 0){this.commitNode(c),this.indexes[e]=this.indexes[c]+1;break}r=r.previousSibling}r===null&&(this.indexes[e]=0);const a=this.recents.get(e),l=a===ve.New,o=this.indexes[e];if(o===void 0)throw"commitNode: missing node index";if(l){if(xe(n)){let c=n;if(i!==void 0){if(this.app.sanitizer.isHidden(e)){const d=c.clientWidth,p=c.clientHeight;c=n.cloneNode(),c.style.width=`${d}px`,c.style.height=`${p}px`}this.app.send(Gi(e,i,o,c.tagName,Xt(n)))}for(let d=0;d<c.attributes.length;d++){const p=c.attributes[d];this.sendNodeAttribute(e,c,p.nodeName,p.value)}}else Yt(n)&&(this.app.send(Ki(e,i,o)),this.sendNodeData(e,s,n.data));return!0}a===ve.Removed&&i!==void 0&&this.app.send(Ji(e,i,o));const u=this.attributesMap.get(e);if(u!==void 0){if(!xe(n))throw"commitNode: node is not an element";for(const c of u)this.sendNodeAttribute(e,n,c,n.getAttribute(c))}if(this.textSet.has(e)){if(!Yt(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 As extends en{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(Ht(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(Ht(e,s))})}}class Zr extends en{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(Ht(s,i))})}}class eo{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:a,top:l}=e.iFrame.getBoundingClientRect();e.offset=[a,l]}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 l;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 o;s.removeEventListener("scroll",a),(o=s.defaultView)==null||o.removeEventListener("resize",a)}},a=()=>{r.offset=null};s.addEventListener("scroll",a),(l=s.defaultView)==null||l.addEventListener("resize",a),this.states.set(n,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const tn=me?Element.prototype.attachShadow:()=>new ShadowRoot;class to extends en{constructor(e,n){super(e,!0),this.iframeOffsets=new eo,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Y(s,"iframe")&&(this.options.captureIFrames&&!Oe(s,"obscured")||Oe(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||!Bi(e))return;const r=e.contentWindow,a=e.contentDocument;if(a&&a!==n){const l=new As(this.app);this.iframeObservers.push(l),l.observe(e),n=a,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(l=>l(r)))},100));e.addEventListener("load",s),s()}handleShadowRoot(e){const n=new Zr(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=tn.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(Vi()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=tn.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new As(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=tn,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var yt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(yt||(yt={}));const no=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class so{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)&&(Oe(s,"masked")||Oe(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||xe(s)&&(Oe(s,"htmlmasked")||Oe(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&xe(s)){const i=this.options.domSanitizer(s);i===yt.Obscured&&this.obscured.add(e),i===yt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?no(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("@"),[a,l]=r.split(".");return`${Bt(i)}@${Bt(a)}.${Bt(l)}`})),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 io{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=ji(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 ro(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class oo{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?ro(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 Je="canceled",Ms="or_uxt_active",nn="or_buffer_1",Ce=t=>({reason:t,success:!1}),ao=t=>({...t,success:!0});var Q;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Q||(Q={}));const Ls="https://api.openreplay.com/ingest";function sn(){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 co=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 lo=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=Q.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 o;(o=this.canvasRecorder)==null||o.restartTracking()},this.flushBuffer=async o=>new Promise(u=>{let c=!1;const d=[o.shift()];for(;!c;){const p=o[0];!p||p[0]===0?c=!0:d.push(o.shift())}this.postToWorker(d),u(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(s).findIndex(o=>["fixedCanvasScaling","disableCanvas"].includes(o))!==-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 a={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:Ls,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Ke.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=hs(a,s),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const o=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${o}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new so(this,s),this.nodes=new Qr(this.options.node_id),this.observer=new to(this,s),this.ticker=new oo(this),this.ticker.attach(()=>this.commit()),this.debug=new Yr(this.options.__debug__),this.session=new io(this,this.options),this.attributeSender=new Di(this,!!this.options.disableStringDict),this.featureFlags=new Li(this),this.tagWatcher=new Tr(this.sessionStorage,this.debug.error,o=>{this.send(Sr(o))}),this.session.attachUpdateCallback(({userID:o,metadata:u})=>{o!=null&&this.send(or(o)),u!=null&&Object.entries(u).forEach(([c,d])=>this.send(fs(c,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const l=this.session.getTabId();if(this.insideIframe){const o=c=>{const{data:d}=c;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",o),this.attachStopCallback(()=>{window.removeEventListener("message",o)});const u=this.initialHostName;window.parent.postMessage({line:ce.iframeSignal,source:l,context:this.contextId,domain:u},"*")}else{let o=0;const u=c=>{const{data:d}=c;if(d.line===ce.iframeSignal){const p=d.domain,b=Array.from(document.querySelectorAll("iframe"));this.pageFrames=b,(async()=>{let y=0;for(;y<10;){const E=this.checkNodeId(b,p);if(E){this.waitStarted().then(()=>{var A;o++;const R=this.session.getSessionToken(),j={line:ce.iframeId,context:this.contextId,domain:p,id:E,token:R,frameOrderNumber:o};this.debug.log("iframe_data",j),(A=c.source)==null||A.postMessage(j,"*")}).catch(console.error),y=10;break}y++,await co(100)}})()}if(d.line===ce.iframeBatch){const b=d.messages.map(w=>{if(w[0]===20){let y=w;return this.pageFrames.forEach(E=>{if(E.dataset.domain===c.data.domain){const[R,j,A]=w,{left:k,top:C}=E.getBoundingClientRect();y=[R,j+k,A+C]}}),y}if(w[0]===68){let y=w;return this.pageFrames.forEach(E=>{if(E.dataset.domain===c.data.domain){const[R,j,A,k,C,_,M]=w,{left:I,top:T,width:L,height:$}=E.getBoundingClientRect(),F=document.documentElement.scrollWidth,z=document.documentElement.scrollHeight,N=_/100*L+I,P=M/100*$+T,V=N/F,G=P/z;y=[R,j,A,k,C,Math.round(V*1e3)/10,Math.round(G*1e3)/10]}}),y}return w});this.messages.push(...b)}};window.addEventListener("message",u),this.attachStopCallback(()=>{window.removeEventListener("message",u)})}this.bc!==null&&(this.bc.postMessage({line:ce.ask,source:l,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=o=>{if(o.data.context!==this.contextId){if(o.data.line===ce.resp){const u=o.data.token;this.session.setSessionToken(u),this.allowAppStart()}if(o.data.line===ce.reg){const u=o.data.token;this.session.regenerateTabId(),this.session.setSessionToken(u),this.allowAppStart()}if(o.data.line===ce.ask){const u=this.session.getSessionToken();u&&this.bc&&this.bc.postMessage({line:o.data.source===l?ce.reg:ce.resp,token:u,source:l,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?Ni(e.batch,{mtime:0},(r,a)=>{var l,o;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.postMessage({type:"uncompressed",batch:s})):(o=this.worker)==null||o.postMessage({type:"compressed",batch:a})}):(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!==Q.NotActive&&(this.activityState===Q.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Q.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(De(this.session.getTabId())),this.messages.unshift(Re(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{$i(()=>{var e;this.messages.unshift(De(this.session.getTabId())),this.messages.unshift(Re(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(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId())),this.bufferedMessages2.push(Re(this.timestamp())),this.bufferedMessages2.push(De(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Q.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 a=()=>e?ls(e,n,s,r):null,l=()=>e?us(e,n,s,r):null;this.attachStartCallback(a,i),this.attachStopCallback(l,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,o=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${n}/session/${s}`);if(e!=null&&e.withCurrentTime){const u=fe()-i;return`${o}?jumpto=${u}`}return o}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===Q.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,Pt(),this.coldStartTs=fe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(Re(this.timestamp())),this.bufferedMessages2.push(De(this.session.getTabId()))),this.stop(!1),this.activityState=Q.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(pt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,b;this.conditionsManager=new Ai(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:Vt,jsHeapSizeLimit:Gt,timezone:sn(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:a,userDevice:l,userOS:o,userState:u,projectID:c}=await n.json();this.session.assign({projectID:c}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:a,userDevice:l,userOS:o,userState:u});const d={sessionToken:s,userUUID:"",sessionID:""};this.startCallbacks.forEach(w=>w(d)),await((p=this.conditionsManager)==null?void 0:p.fetchConditions(c,s)),await this.featureFlags.reloadFlags(s),await this.tagWatcher.fetchTags(this.options.ingestPoint,s),(b=this.conditionsManager)==null||b.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);Pt(),this.coldStartTs=fe();const i=this.localStorage.getItem(nn);if(i){const a=JSON.parse(i);this.bufferedMessages1=Array.isArray(a)?a:this.bufferedMessages1,this.localStorage.removeItem(nn)}this.bufferedMessages1.push(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId())),this.activityState=Q.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(a=>a(r)),s||this.send(pt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(nn,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,b;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:Vt,jsHeapSizeLimit:Gt,timezone:sn()})}),{token:s,userBrowser:i,userCity:r,userCountry:a,userDevice:l,userOS:o,userState:u,beaconSizeLimit:c,projectID:d}=await n.json();for((b=this.worker)==null||b.postMessage({type:"auth",token:s,beaconSizeLimit:c}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:a,userDevice:l,userOS:o,userState:u});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===Q.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const o="No worker found: perhaps, CSP is not set.";return this.signalError(o,[]),Promise.resolve(Ce(o))}if(this.activityState===Q.Active||this.activityState===Q.Starting)return Promise.resolve(Ce("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Q.Starting,i||Pt(),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 a=this.session.getSessionToken(),l=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",l,"session token: ",a);try{const o=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:l?void 0:a,deviceMemory:Vt,jsHeapSizeLimit:Gt,timezone:sn(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(o.status!==200){const N=await o.text(),P=N===Je?Je:`Server error: ${o.status}. ${N}`;return Ce(P)}if(!this.worker){const N="no worker found after start request (this should not happen in real world)";return this.signalError(N,[]),Ce(N)}const{token:u,userUUID:c,projectID:d,beaconSizeLimit:p,compressionThreshold:b,delay:w,sessionID:y,startTimestamp:E,userBrowser:R,userCity:j,userCountry:A,userDevice:k,userOS:C,userState:_,canvasEnabled:M,canvasQuality:I,canvasFPS:T,assistOnly:L}=await o.json();if(typeof u!="string"||typeof c!="string"||typeof E!="number"&&typeof E<"u"||typeof y!="string"||typeof w!="number"||typeof p!="number"&&typeof p<"u"){const N=`Incorrect server response: ${JSON.stringify(o)}`;return this.signalError(N,[]),Ce(N)}this.delay=w,this.session.setSessionToken(u),this.session.setUserInfo({userBrowser:R,userCity:j,userCountry:A,userDevice:k,userOS:C,userState:_}),this.session.assign({sessionID:y,timestamp:E||r,projectID:d}),L?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:u,beaconSizeLimit:p}),!l&&u===a&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(pt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([N,P])=>this.send(fs(N,P))),this.localStorage.setItem(this.options.local_uuid_key,c),this.compressionThreshold=b;const $={sessionToken:u,userUUID:c,sessionID:y};if(this.startCallbacks.forEach(N=>N($)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,u),this.activityState=Q.Active,M&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new Kr(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 N=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;N.length>0;)await this.flushBuffer(N);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 Vr(this,Ms);let F;const z=this.localStorage.getItem(Ms);if(z&&(F=parseInt(z,10)),location!=null&&location.search){const N=new URLSearchParams(location.search);if(N.has("oruxt")){const P=N.get("oruxt");F=P?parseInt(P,10):void 0}}return F&&(this.uxtManager.isActive?this.onUxtCb.forEach(N=>N(F)):this.uxtManager.getTest(F,u,!!z).then(N=>{N&&this.onUxtCb.forEach(P=>P(N))})),ao($)}catch(o){if(this.stop(),this.session.reset(),o===Je)return this.signalError(Je,[]),Ce(Je);this._debug("session_start",o);const u=o instanceof Error?o.message:o.toString();return this.signalError(u,[]),Ce(u)}}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===Q.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Q.Active||this.activityState===Q.Starting?Promise.resolve(Ce("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(mr("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Q.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=Q.NotActive}}};function uo(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(lr(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const Fs=me&&"InstallTrigger"in window?t=>t.message+`
|
|
11
|
-
`+t.stack:t=>t.stack||t.message;function rn(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?Fs(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function ho(t){return typeof t!="number"?"NaN":t.toString()}function fo(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function Ps(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return Fs(t);if(Array.isArray(t)){const e=t.length,n=t.slice(0,10).map(rn).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+": "+rn(i))}return"{"+e.join(", ")+"}"}return t.toString()}function po(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 Ps(s);case"s":return rn(s);case"f":return ho(s);case"d":case"i":return fo(s);default:return e}})),t.map(Ps).join(" ")}const Bs=["log","info","warn","error","debug","assert"];function go(t,e){const n=Object.assign({consoleMethods:Bs,consoleThrottling:30},e);if(!Array.isArray(n.consoleMethods)||n.consoleMethods.length===0)return;const s=t.safe((
|
|
12
|
-
`).filter(function(
|
|
13
|
-
`).filter(function(
|
|
14
|
-
`)>-1&&
|
|
15
|
-
`).length>
|
|
16
|
-
`).length?this.parseOpera9(
|
|
17
|
-
`),d=[],p=2,b=
|
|
18
|
-
`),d=[],p=0,b=
|
|
19
|
-
`).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return u.map(function(c){var d=c.split("@"),p=this.extractLocation(d.pop()),b=d.shift()||"",w=b.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;b.match(/\(([^)]*)\)/)&&(y=b.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var E=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:w,args:E,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:c})},this)}}})})(js);var vo=js.exports;const bo=vi(vo);function Us(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function wt(t,e,n={}){let s=e;try{s=bo.parse(t)}catch{}return qt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function Hs(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return wt(t.error,Us(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),qt(s,i,JSON.stringify(Us(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return wt(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return qt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function yo(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(a){const l=Hs(a,i);l!=null&&t.send(l)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}n.captureExceptions&&(t.observer.attachContextCallback(s),s(window))}function $s(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 wo(t){return Fi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const So="https://static.openreplay.com/tracker/placeholder.jpeg";function xo(t){function e(l,o){t.attributeSender.sendSetAttribute(l,"src",So);const{width:u,height:c}=o.getBoundingClientRect();o.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(u)),o.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(c))}const n=function(l,o){const{srcset:u}=o;if(!u)return;const c=u.split(u.match(/,\s+/)?/,\s+/:",").map(d=>$s(d)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",c)},s=function(l,o){o.src.length>Pi&&e(l,o),t.send(Ut(l,"src",o.src,t.getBaseHref()))},i=t.safe(function(l){const o=$s(l.src||"");rs(o)&&t.send(ws(t.timestamp(),0,0,0,0,0,o,"img",0,!1))}),r=t.safe(function(l){const o=t.nodes.getID(l);o!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!wo(l.src)?i(l):t.sanitizer.isHidden(o)||t.sanitizer.isObscured(o)?e(o,l):(s(o,l),n(o,l)))}),a=cs(t.safe(l=>{for(const o of l)if(o.type==="attributes"){const u=o.target,c=t.nodes.getID(u);if(c===void 0)return;o.attributeName==="src"&&s(c,u),o.attributeName==="srcset"&&n(c,u)}}));t.attachStopCallback(()=>{a.disconnect()}),t.nodes.attachNodeCallback(l=>{Y(l,"img")&&(t.nodes.attachNodeListener(l,"error",()=>i(l)),t.nodes.attachNodeListener(l,"load",()=>r(l)),r(l),a.observe(l,{attributes:!0,attributeFilter:["src","srcset"]}))})}const ko=["text","password","email","search","number","range","date","tel","time"];function To(t){return Y(t,"textarea")?!0:Y(t,"input")?ko.includes(t.type):!1}function Eo(t){if(!Y(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Io=me&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Y(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(Y(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 qs(t){let e=jt(t);if(e===null){const n=Io(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return is(e).slice(0,100)}const He={Plain:0,Obscured:1,Hidden:2};function Co(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:He.Obscured,obscureInputDates:!1},e);function s(c,d){let p=d.value,b=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(c)?b=He.Hidden:(t.sanitizer.isObscured(c)||b===He.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(b=He.Obscured);let w=0;switch(b){case He.Hidden:w=-1,p="";break;case He.Obscured:w=p.length,p="";break}return{value:p,mask:w}}function i(c,d){const{value:p,mask:b}=s(c,d);t.send(Zi(c,p,b))}const r=new Map,a=new Map;t.attachStopCallback(()=>{r.clear(),a.clear()});function l(c,d){r.get(c)!==d.value&&(r.set(c,d.value),i(c,d))}function o(c,d){a.get(c)!==d&&(a.set(c,d),t.send(er(c,d)))}t.ticker.attach(()=>{r.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);l(d,p)}),a.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return a.delete(d);o(d,p.checked)})},3);function u(c,d,p,b){const{value:w,mask:y}=s(c,d),E=qs(d);t.send(vr(c,w,y!==0,E,p,b))}t.nodes.attachNodeCallback(t.safe(c=>{const d=t.nodes.getID(c);if(d!==void 0){if(Y(c,"select")&&(i(d,c),t.nodes.attachNodeListener(c,"change",()=>i(d,c))),To(c)){l(d,c);let p=0,b=0,w=0;const y=()=>{p=fe()},E=()=>{b===0&&p!==0&&(b=fe()-p)},R=()=>{p!==0&&(w=fe()-p),u(d,c,b,w),b=0,w=0,p=0};t.nodes.attachNodeListener(c,"focus",y),t.nodes.attachNodeListener(c,"input",E),t.nodes.attachNodeListener(c,"change",R);return}if(Eo(c)){o(d,c.checked),t.nodes.attachNodeListener(c,"change",()=>o(d,c.checked));return}}}))}let le,an,Ws;function _o(t,e){if(Ws=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},an=No(le.root,n);let s=St(t,"all",()=>St(t,"two",()=>St(t,"one",()=>St(t,"none"))));if(s){const i=Ys(Qs(s,t));return i.length>0&&(s=i[0]),xt(s)}else throw new Error("Selector was not found.")}function No(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function St(t,e,n){let s=null,i=[],r=t,a=0;for(;r;){const l=new Date().getTime()-Ws.getTime();if(le.timeoutMs!==void 0&&l>le.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let o=Tt(Oo(r))||Tt(...Ro(r))||Tt(...Do(r))||Tt(Ao(r))||[Js()];const u=Mo(r);if(e=="all")u&&(o=o.concat(o.filter(cn).map(c=>kt(c,u))));else if(e=="two")o=o.slice(0,1),u&&(o=o.concat(o.filter(cn).map(c=>kt(c,u))));else if(e=="one"){const[c]=o=o.slice(0,1);u&&cn(c)&&(o=[kt(c,u)])}else e=="none"&&(o=[Js()],u&&(o=[kt(o[0],u)]));for(let c of o)c.level=a;if(i.push(o),i.length>=le.seedMinLength&&(s=Vs(i,n),s))break;r=r.parentElement,a++}return s||(s=Vs(i,n)),!s&&n?n():s}function Vs(t,e){const n=Ys(Xs(t));if(n.length>le.threshold)return e?e():null;for(let s of n)if(Ks(s))return s;return null}function xt(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 Gs(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ks(t){const e=xt(t);switch(an.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 Oo(t){const e=t.getAttribute("id");return e&&le.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Ro(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 Do(t){return Array.from(t.classList).filter(le.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Ao(t){const e=t.tagName.toLowerCase();return le.tagName(e)?{name:e,penalty:2}:null}function Js(){return{name:"*",penalty:3}}function Mo(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 kt(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function cn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Tt(...t){const e=t.filter(Lo);return e.length>0?e:null}function Lo(t){return t!=null}function*Xs(t,e=[]){if(t.length>0)for(let n of t[0])yield*Xs(t.slice(1,t.length),e.concat(n));else yield e}function Ys(t){return[...t].sort((e,n)=>Gs(e)-Gs(n))}function*Qs(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=xt(i);if(n.visited.has(r))return;Ks(i)&&Fo(i,e)&&(yield i,n.visited.set(r,!0),yield*Qs(i,e,n))}}function Fo(t,e){return an.querySelector(xt(t))===e}function Po(t,e,n){return _o(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 ln(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 Zs(t,e){return t instanceof Element?Bo(t,e):null}function Bo(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Oe(n,"masked"))return null;n=n.parentElement}if(Xt(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"||ln(n)||jt(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function jo(t,e){const{disableClickmaps:n=!1}=e||{};function s(k){const C=jt(k);if(C!==null)return C;if(Y(k,"input"))return qs(k);if(ln(k)){let _="";return k instanceof HTMLElement&&(_=t.sanitizer.getInnerTextSecure(k)),_=_||k.id||k.className,is(_).slice(0,100)}return""}let i=-1,r=-1,a=!1,l=null,o=0,u={},c=0,d=0,p=0,b=0,w;const y=.008,E=225;function R(){const k=b/E;if(!c){c=k;return}const C=(k-c)/E;p>4&&C>y&&t.send(br(fe())),b=0,p=0,c=k}t.attachStartCallback(()=>{w=setInterval(()=>R(),E)}),t.attachStopCallback(()=>{i=-1,r=-1,a=!1,l=null,u={},w&&clearInterval(w)});const j=()=>{a&&(t.send(tr(i,r)),a=!1)},A=(k,C=!1)=>{function _(I,T,L){return u[I]=u[I]||Po(T,k,L)}const M=C?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);M(k.documentElement,"mouseover",I=>{const T=Zs(I.target,k);T!==l&&(l=T,o=performance.now())}),M(k,"mousemove",I=>{const[T,L]=t.observer.getDocumentOffset(k);i=I.clientX+T,r=I.clientY+L,a=!0;const $=Math.sign(I.movementX);b+=Math.abs(I.movementX)+Math.abs(I.movementY),$!==d&&(d=$,p++)},!1),M(k,"click",I=>{const T=Zs(I.target,k);if(!I.clientX&&!I.clientY||T===null)return;const L=t.nodes.getID(T);if(L!==void 0){const $=I.pageX,F=I.pageY,z=k.documentElement.scrollWidth,N=k.documentElement.scrollHeight,P=ei($/z),V=ei(F/N);j(),t.send(pr(L,l===T?Math.round(performance.now()-o):0,s(T),ln(T)&&!n?_(L,T,e):"",P,V),!0)}l=null})};t.nodes.attachNodeCallback(k=>{vt(k)&&A(k)}),A(document,!0),t.ticker.attach(j,(e==null?void 0:e.trackingOffset)||7)}function ei(t){return Math.round(t*1e4)}function zo(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let a="";if(Y(r,"img")&&(a=r.currentSrc||r.src),!a){const w=getComputedStyle(r).getPropertyValue("background-image");if(w){const y=s.exec(w);y!==null&&(a=y[1],(a.startsWith('"')||a.startsWith("'"))&&(a=a.substr(1,a.length-2)))}}if(!a)continue;const l=a.substr(0,10)==="data:image"?0:t[a];if(l===void 0)continue;const o=r.getBoundingClientRect(),u=Math.max(o.top,0),c=Math.max(o.left,0),d=Math.min(o.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),p=Math.min(o.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(d<=u||p<=c)continue;const b=(d-u)*(p-c);e.push({time:l,area:b})}return e}function Uo(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:a}=e[i];n+=a,s+=a*(r>t?r:t)}return n===0?0:s/n}function Ho(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(u){var d;if(u.duration<0||!rs(u.name)||t.isServiceURL(u.name))return;s!==null&&(s[u.name]=u.startTime+u.duration);let c=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(u.name.startsWith(p)){c=!0;return}}),!c&&t.send(ws(u.startTime+je(),u.duration,u.responseStart&&u.startTime?u.responseStart-u.startTime:0,u.transferSize>u.encodedBodySize?u.transferSize-u.encodedBodySize:0,u.encodedBodySize||0,u.decodedBodySize||0,u.name,u.initiatorType,u.transferSize,u.responseStatus&&u.responseStatus===304||u.transferSize===0))}const r=new PerformanceObserver(u=>u.getEntries().forEach(i));let a;t.attachStartCallback(function({sessionID:u}){u!==a&&(performance.getEntriesByType("resource").forEach(i),a=u),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,o=0;if(n.capturePageLoadTimings){let u=!1;t.ticker.attach(()=>{if(!u&&((l===0||o===0)&&performance.getEntriesByType("paint").forEach(c=>{const{name:d,startTime:p}=c;switch(d){case"first-paint":l=p;break;case"first-contentful-paint":o=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){u=!0;const{navigationStart:c,requestStart:d,responseStart:p,responseEnd:b,domContentLoadedEventStart:w,domContentLoadedEventEnd:y,loadEventStart:E,loadEventEnd:R}=performance.timing;t.send(sr(d-c||0,p-c||0,b-c||0,w-c||0,y-c||0,E-c||0,R-c||0,l,o))}},30)}if(n.capturePageRenderTimings){let u=0,c=0,d=0,p=null,b=!1;t.ticker.attach(()=>{if(b)return;const w=performance.now();if(s!==null&&(u=Math.max.apply(null,Object.keys(s).map(y=>s[y])),w-u>1e3&&(p=zo(s),s=null)),d!==null&&(w-d>50&&(c=w),d=w-c>5e3?null:w),p!==null&&d===null||w>3e4){b=!0,s=null;const y=p===null?0:Uo(o||l,p),{domContentLoadedEventEnd:E,navigationStart:R}=performance.timing,j=d===null?Math.max(c,o,E-R||0):0;t.send(ir(y,o>u?o:u,j))}})}}function un(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 $o(t,e){let n=!1;const s=new Map;function i(l){Rs(l)&&(xe(l)&&s.set(l,[l.scrollLeft,l.scrollTop]),vt(l)&&s.set(l,un(l)))}const r=t.safe(()=>{e||t.send(Wi(...un(document)))}),a=t.safe((l,o)=>{const u=t.nodes.getID(o);u!==void 0&&t.send(Qi(u,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((l,o)=>{o&&(xe(l)&&l.scrollLeft+l.scrollTop>0?s.set(l,[l.scrollLeft,l.scrollTop]):vt(l)&&s.set(l,un(l))),bt(l)&&t.nodes.attachNodeListener(l,"scroll",u=>{i(u.target)})}),t.attachEventListener(document,"scroll",l=>{const o=l.target;if(o===document){n=!0;return}i(o)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(a),s.clear()},5,!1)}function qo(t){let e,n,s,i,r=document.referrer;const a=t.safe(()=>{const{URL:u}=document;u!==e&&(e=u,t.send(xr(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:u,innerHeight:c}=window;(u!==n||c!==s)&&(n=u,s=c,t.send(qi(n,s)))}),o=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(ur(document.hidden)));t.attachStartCallback(()=>{e=null,i=je(),n=s=-1,a(),l(),o()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1),t.ticker.attach(a,1,!1),t.ticker.attach(l,5,!1)}function ti(t){return bt(t)&&!!t.adoptedStyleSheets}let Wo=15;function ni(){return Wo++}const Et=new Map;function Vo(t){if(t===null||!ti(document))return;const e=new Map,n=new Map,s=a=>setTimeout(()=>{let l=t.nodes.getID(a);if(a===document&&(l=0),l===void 0)return;let o=n.get(l);o||(o=[]);const u=[],c=a.adoptedStyleSheets;if(c&&Symbol.iterator in c)for(const d of c){let p=e.get(d);const b=!p;if(p||(p=ni(),e.set(d,p)),o.includes(p)||t.send(bs(p,l)),b){const w=d.cssRules;for(let y=0;y<w.length;y++)t.send($t(p,w[y].cssText,y,t.getBaseHref()))}u.push(p)}if(Symbol.iterator in o)for(const d of o)u.includes(d)||t.send(gr(d,l));n.set(l,u)},20);function i(a){const l=Object.getOwnPropertyDescriptor(a,"adoptedStyleSheets");l&&Object.defineProperty(a,"adoptedStyleSheets",{...l,set:function(o){const u=l.set.call(this,o);return s(this),u}})}const r=a=>{if(a.__openreplay_adpss_patched__)return;a.__openreplay_adpss_patched__=!0,i(a.Document.prototype),i(a.ShadowRoot.prototype);const{replace:l,replaceSync:o}=a.CSSStyleSheet.prototype;a.CSSStyleSheet.prototype.replace=function(u){return l.call(this,u).then(c=>{const d=e.get(this);return d&&t.send(ms(d,u,t.getBaseHref())),c})},a.CSSStyleSheet.prototype.replaceSync=function(u){const c=e.get(this);return c&&t.send(ms(c,u,t.getBaseHref())),o.call(this,u)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(a=>{ti(a)&&s(a)})}function Go(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(dr("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,a)=>{const l=Et.get(i);l&&(typeof a=="string"?t.send($t(l,a,r,t.getBaseHref())):t.send(vs(l,r)))}),n=t.safe(i=>{let r=i;for(;r.parentRule;)r=r.parentRule;const a=r.parentStyleSheet;if(!a){t.debug.warn("No parent StyleSheet found for",r,i);return}const l=Et.get(a);if(!l){t.debug.warn("No sheedID found for",a,Et);return}const o=r.cssText,u=a.cssRules,c=Array.from(u).indexOf(r);c>=0?(t.send($t(l,o,c,t.getBaseHref())),t.send(vs(l,c+1))):t.debug.warn("Rule index not found in",a,r)}),s=t.safe(i=>{const{insertRule:r,deleteRule:a}=i.CSSStyleSheet.prototype,{insertRule:l,deleteRule:o}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(u,c=0){return e(this,c,u),r.call(this,u,c)},i.CSSStyleSheet.prototype.deleteRule=function(u){return e(this,u),a.call(this,u)},i.CSSGroupingRule.prototype.insertRule=function(u,c=0){const d=l.call(this,u,c);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(u=0){const c=o.call(this,u);return n(this),c}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Y(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const a=i.sheet,l=ni();Et.set(a,l),t.send(bs(l,r));const o=a.cssRules;for(let u=0;u<o.length;u++)e(a,u,o[u].cssText)})}function Ko(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(gs(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Y(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{Rs(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(gs(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Y(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function Jo(t){if(!window.FontFace)return;const e=new Map,n=s=>{class i extends s.FontFace{constructor(...a){if(typeof a[1]=="string"){let l="";a[2]&&t.safe(()=>{l=JSON.stringify(a[2])});const o=[a[0],a[1],l],u=e.get(s.document)||[];u.push(o),e.set(s.document,u);const c=s===window?0:t.nodes.getID(s.document);if(c===void 0)return;t.active()&&t.send(ps(c,...o))}super(...a)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!vt(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(a=>{t.send(ps(r,...a))})}))}function Xo(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:b,data:w,method:y,url:E,baseURL:R}=p.config,{data:j,headers:A,status:k,response:C}=p,{data:_,headers:M,status:I}=C||{},T=n.ignoreHeaders,L=Array.isArray(T)?H=>T.includes(H):()=>T;function $(H,v){L(v[0])||(H[v[0]]=v[1])}let F={},z={};b.toJSON?F=b.toJSON():b instanceof Headers?b.forEach((H,v)=>$(F,[v,H])):Array.isArray(b)?b.forEach(H=>$(F,H)):typeof b=="object"&&Object.entries(b).forEach(H=>$(F,H));const N=M||A;N.toJSON?z=N.toJSON():N instanceof Headers?N.forEach((H,v)=>$(z,[v,H])):Array.isArray(N)?N.forEach(H=>$(z,H)):typeof N=="object"&&Object.entries(N).forEach(([H,v])=>{L(H)||(z[H]=v)});const P=s({url:E,method:y||"",status:k||I||0,request:{headers:F,body:w},response:{headers:z,body:_||j}});if(!P){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",P),t.send(ft("xhr",String(y),String(P.url),i(P.request),i(P.response),P.status,V+je(),G,0))}function a(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const b=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",w=t.getSessionToken();w&&p.headers.set(b,w)}return p}function l(p){return n.failuresOnly||r(p),p}function o(p){return t.debug.log("Openreplay: capturing API request error",p),Yo(p)&&p.response?r(p.response):p instanceof Error&&t.send(wt(p,[])),Promise.reject(p)}function u(p){t.debug.log("Openreplay: failed API request, skipping",p)}const c=e.interceptors.request.use(a,u,{synchronous:!0}),d=e.interceptors.response.use(l,o,{synchronous:!0});t.attachStopCallback(()=>{var p,b,w,y;(b=(p=e.interceptors.request).eject)==null||b.call(p,c),(y=(w=e.interceptors.response).eject)==null||y.call(w,d)})}function Yo(t){return Qo(t)&&t.isAxiosError===!0}function Qo(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 hn{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 ft(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+je(),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 Xe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:fn(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},dn=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(ea(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":fn(t)?e=t:e=`can't parse body ${typeof t}`;return e},Zo=(t,e={})=>{fn(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 fn(t){return t!==null&&typeof t=="object"}function ea(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function It(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const pn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class ta{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=Xe(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(a=>{if(!e)e=new Uint8Array(a.value);else{const l=new Uint8Array(e.length+a.value.length);l.set(e),l.set(a.value,e.length),e=l}return this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.readyState=a.done?4:3,this.item.statusText=a.done?String(this.item.status):"Loading",this.item.responseSize=e.length,this.item.responseSizeText=It(this.item.responseSize),a.done&&(this.item.response=Xe(this.item.responseType,e)),a}),s.cancel=(...a)=>(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=Xe(this.item.responseType,e),r.apply(s,a)),s}}}class na{constructor(e,n,s,i,r,a){this.ignoredHeaders=e,this.setSessionTokenHeader=n,this.sanitize=s,this.sendMessage=i,this.isServiceUrl=r,this.tokenUrlMatcher=a}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 l=new hn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((o,u)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(o,u);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(o,u):Array.isArray(s[1].headers)?s[1].headers.push([o,u]):s[1].headers[o]=u}}),e.apply(window,s).then(this.afterFetch(l)).catch(o=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),o})}beforeFetch(e,n,s){let i,r="GET",a={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=pn(n),a=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=pn(n.url),a=n.headers),e.method=r,e.requestType="fetch",e.requestHeader=a,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(a)==="[object Headers]"){e.requestHeader={};for(const[l,o]of a)e.requestHeader[l]=o}else e.requestHeader=a;if(i.search&&i.searchParams){e.getData={};for(const[l,o]of i.searchParams)e.getData[l]=o}s!=null&&s.body&&(e.requestData=dn(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=It(e.responseSize),e.response=Xe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new ta(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 sa{static create(e,n,s,i,r,a){return new Proxy(fetch,new na(e,n,s,i,r,a))}}class ia{constructor(e,n,s,i,r,a,l){this.ignoredHeaders=n,this.setSessionTokenHeader=s,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=a,this.tokenUrlMatcher=l,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new hn(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=Xe(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 a,l;const i=s[0],r=s[1];return this.item.method=i?i.toUpperCase():"GET",this.item.url=((a=r.toString)==null?void 0:a.call(r))||"",this.item.name=((l=this.item.url)==null?void 0:l.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=Zo(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=dn(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(": "),
|
|
21
|
-
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function ca(t,e,n,s,i,r,a){var l;t.XMLHttpRequest?t.XMLHttpRequest=ra.create(e,n,s,i,r,a):si("XMLHttpRequest"),t.fetch?t.fetch=sa.create(e,n,s,i,r,a):si("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=$e.create(e,n,s,i,r))}function gn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function ii(t){return typeof t=="string"?t.toUpperCase():"GET"}function la(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)?c=>s.includes(c):()=>s,r=n.sessionTokenHeader===!0?"X-OpenReplay-SessionToken":n.sessionTokenHeader;function a(c){if(r){const d=t.getSessionToken();d&&t.safe(c)(r,d)}}function l(c){if(n.capturePayload||(delete c.request.body,delete c.response.body),n.sanitizer){const d=c.response.body;if(typeof d=="string")try{c.response.body=JSON.parse(d)}catch{}return n.sanitizer(c)}return c}function o(c){if(c&&typeof c.body!="string")try{c.body=JSON.stringify(c.body)}catch{c.body="<unable to stringify>",t.notify.warn("Openreplay fetch couldn't stringify body:",c.body)}return JSON.stringify(c)}const u=c=>{if(n.useProxy)return ca(c,n.ignoreHeaders,a,l,A=>t.send(A),A=>t.isServiceURL(A),n.tokenUrlMatcher);const d=c.fetch.bind(c),p=(A,k={})=>{if(!(typeof A=="string"||A instanceof URL)||t.isServiceURL(String(A)))return d(A,k);a(function(_,M){k.headers===void 0&&(k.headers={}),k.headers instanceof Headers?k.headers.append(_,M):Array.isArray(k.headers)?k.headers.push([_,M]):k.headers[_]=M});const C=performance.now();return d(A,k).then(_=>{const M=performance.now()-C;if(n.failuresOnly&&_.status<400)return _;const I=_.clone();return I.text().then(T=>{const L={},$={};if(s!==!0){const N=([P,V])=>{i(P)||(L[P]=V)};k.headers instanceof Headers?k.headers.forEach((P,V)=>N([V,P])):Array.isArray(k.headers)?k.headers.forEach(N):typeof k.headers=="object"&&Object.entries(k.headers).forEach(N),I.headers.forEach((P,V)=>{i(V)||($[V]=P)})}const F=ii(k.method),z=l({url:String(A),method:F,status:I.status,request:{headers:L,body:k.body||null},response:{headers:$,body:T}});z&&t.send(ft("fetch",F,String(z.url),o(z.request),o(z.response),I.status,C+je(),M,0))}).catch(T=>t.debug.error("Could not process Fetch response:",T)),_})};c.fetch=p;const b=c.XMLHttpRequest.prototype.open,w=c.XMLHttpRequest.prototype.setRequestHeader,y=c.XMLHttpRequest.prototype.send;function E(A,k){const C=this;a((M,I)=>C.setRequestHeader(M,I));let _=0;return C.addEventListener("loadstart",M=>{_=M.timeStamp}),C.addEventListener("load",t.safe(M=>{const{headers:I,body:T}=gn(C),L=_>0?M.timeStamp-_:0,F=(C.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),z={};F.forEach(function(V){const G=V.split(": "),H=G.shift();i(H)||(z[H]=G.join(": "))});const N=ii(A),P=l({url:String(k),method:N,status:C.status,request:{headers:I,body:T||null},response:{headers:z,body:C.response}});P&&t.send(ft("xhr",N,String(P.url),o(P.request),o(P.response),C.status,_+je(),L,0))})),b.apply(this,arguments)}function R(A){const k=gn(this);return k.body=A,y.apply(this,arguments)}function j(A,k){if(!i(A)){const C=gn(this);C.headers[A]=k}return w.apply(this,arguments)}n.axiosInstances||(c.XMLHttpRequest.prototype.open=E,c.XMLHttpRequest.prototype.send=R,c.XMLHttpRequest.prototype.setRequestHeader=j)};u(window),n.axiosInstances&&n.axiosInstances.forEach(c=>{Xo(t,c,n,l,o)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(u))}function ua(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(ys(n,s,i))}else t.send(ys(-1,-1,""))})}function ha(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(pt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Ct="/installation/javascript-sdk";function da(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${dt}${Ct}`),!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 ${dt}${Ct} for more information.`),!1;t.projectKey=t.projectID.toString(),Ie("`projectID` option","`projectKey` option",Ct)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ie("`sessionToken` option","`sessionHash` start() option","/"),!0}class fa{constructor(e){var l;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(o,u)=>{const c=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||Ls;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:c,reason:u.length?`missing api: ${u.join(",")}`:o}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(o,u={})=>{if(this.app!==null){if(o instanceof Error){const c=wt(o,[],u);this.app.send(c)}else if(o instanceof ErrorEvent||"PromiseRejectionEvent"in window&&o instanceof PromiseRejectionEvent){const c=Hs(o,void 0,u);c!=null&&this.app.send(c)}}},this.crossdomainMode=!!(zi()&&((l=e.crossdomain)!=null&&l.enabled)),!me||!da(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 o of i)if(o==="timing"){if("performance"in window&&!(o in performance)){s.push(o);break}}else if(o==="startsWith"){if(!(o in String.prototype)){s.push(o);break}}else if(!(o in window)){s.push(o);break}if(s.length>0){const o=s.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${o}`),this.signalStartIssue("missing_api",s);return}const r=new lo(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(qo(r),uo(r),kr(r,e),ha(r)),jo(r,e.mouse),$o(r,this.crossdomainMode),Go(r),Vo(r),go(r,e),yo(r,e),xo(r),Co(r,e),Ho(r,e),Ko(r),Jo(r),la(r,e.network),ua(r),window.__OPENREPLAY__=this,e.flags&&e.flags.onFlagsLoad&&this.onFlagsLoad(e.flags.onFlagsLoad);const a=window.open;(e.autoResetOnWindowOpen||e.resetTabOnWindowOpen)&&(r.attachStartCallback(()=>{const o=r.getTabId(),u=r.sessionStorage??window.sessionStorage;window.open=function(...c){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&u.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),u.setItem(e.session_tabid_key||"__openreplay_tabid",o),a.call(window,...c)}}),r.attachStopCallback(()=>{window.open=a}))}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 ${dt}${Ct}`),!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 Ie("'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){Ie("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(ar(e))}userAnonymousID(e){Ie("'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){Ie("'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(rr(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(fr(e,n))}}}const pa=`
|
|
8
|
+
🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=U("div","button",Nr,"Read guidelines to begin");this.removeGreeting=()=>((n||s)&&this.userRecorder.startRecording(30,Os.Standard,n,s),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var c,u,a,d;this.removeGreeting();const l=(c=this.signalManager)==null?void 0:c.getDurations();l&&this.signalManager&&(l.testStart=this.app.timestamp(),this.signalManager.setDurations(l)),(u=this.signalManager)==null||u.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,gt),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,gt);const r=this.createDescriptionSection(e),o=this.createTasksSection(n),l=U("div","stop_bn_or",Es,"Abort Session"),c=U("div","stop_ct_or",{fontSize:"13px!important"});c.style.fontSize="13px",c.append(l),this.container.append(i,r,o,c),this.taskSection=o,this.descriptionSection=r,this.stopButton=l,this.stopButtonContainer=c,l.onclick=()=>{var u;this.userRecorder.discard(),(u=this.signalManager)==null||u.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},s?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var l;const e=U("div","title",Or),n=zr(),s=U("div","title_text",{maxWidth:"19rem",overflow:"hidden",textOverflow:"ellipsis",width:"100%",fontSize:16,lineHeight:"auto",cursor:"pointer"},(l=this.test)==null?void 0:l.title),i=Ur();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?gt:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?Ue:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?Ue:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?Ue:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?Es:{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,jr(this.bg,n),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const n=U("div","description_section_or",Ue),s=U("div","description_s_title_or",xs),i=U("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=U("div","icon",ks,"-"),o=U("div","content",ze),l=U("div","text_description",{maxHeight:"250px",overflowY:"auto",whiteSpace:"pre-wrap",fontSize:13,color:"#454545",lineHeight:"auto"});l.innerHTML=e;const c=U("div","button_begin_or",Ts,"Begin Test");s.append(i,r),o.append(l,c),n.append(s,o);const u=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"})};return s.onclick=u,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"}),o.removeChild(c)},c.onclick=()=>{var a,d,p;if(u(),this.test){const b=(a=this.signalManager)==null?void 0:a.getDurations(),w=b?b.tasks.findIndex(y=>this.test&&y.taskId===this.test.tasks[0].task_id):null;b&&w===-1&&(b.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(d=this.signalManager)==null||d.setDurations(b)),(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,gt);const n=U("div","task_section_or",Ue),s=U("div","description_t_title_or",xs),i=U("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=U("div","icon",ks,"-"),o=U("div","content",ze),l=U("div","pagination",Dr),c=U("div","taskCard",Cs),u=U("div","taskText",_s),a=U("div","taskDescription",Mr),d=U("div","taskButtons",Fr),p=U("div","taskText",_s);p.textContent="Your answer";const b=U("textarea","taskDescription",{resize:"vertical"}),w=U("div","inputArea",Cs);w.append(p,b);const y=U("div","closePanelButton",Ns,"Collapse Panel"),E=U("div","nextButton",Lr,"Done, Next");s.append(i,r),c.append(u,a),d.append(y,E),o.append(l,c,w,d),n.append(s,o);const O=()=>{const k=e[this.currentTaskIndex];u.textContent=k.title,a.textContent=k.description,k.allow_typing?w.style.display="flex":w.style.display="none"};e.forEach((k,_)=>{const R=U("span",`or_task_${_}`,{outline:"1px solid #efefef",fontSize:"13px",height:"24px",width:"24px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em"},(_+1).toString());R.id=`or_task_${_}`,l.append(R)});const B=()=>{this.widgetTasksVisible=!this.widgetTasksVisible,r.textContent=this.widgetTasksVisible?"-":"+",Object.assign(o.style,this.widgetTasksVisible?ze:{display:"none"})};this.hideTaskSection=()=>(r.textContent="+",Object.assign(o.style,{display:"none"}),this.widgetTasksVisible=!1,!1),this.showTaskSection=()=>(r.textContent="-",Object.assign(o.style,ze),this.widgetTasksVisible=!0,!0);const A=()=>{const k=document.getElementById(`or_task_${this.currentTaskIndex}`);k&&Object.assign(k.style,Is);for(let _=0;_<this.currentTaskIndex;_++){const R=document.getElementById(`or_task_${_}`);R&&Object.assign(R.style,Ar)}};return s.onclick=B,y.onclick=this.collapseWidget,E.onclick=()=>{var _,R,M,I;const k=e[this.currentTaskIndex].allow_typing?b.value:void 0;if(b.value="",(_=this.signalManager)==null||_.signalTask(e[this.currentTaskIndex].task_id,"done",k),this.currentTaskIndex<e.length-1){this.currentTaskIndex++,O();const T=(R=this.signalManager)==null?void 0:R.getDurations();T&&T.tasks.findIndex(F=>F.taskId===e[this.currentTaskIndex].task_id)===-1&&(T.tasks.push({taskId:e[this.currentTaskIndex].task_id,started:this.app.timestamp()}),(M=this.signalManager)==null||M.setDurations(T)),(I=this.signalManager)==null||I.signalTask(e[this.currentTaskIndex].task_id,"begin"),A()}else this.showEndSection();this.app.localStorage.setItem("or_uxt_task_index",this.currentTaskIndex.toString())},setTimeout(()=>{const k=document.getElementById("or_task_0");k&&Object.assign(k.style,Is),O(),A()},1),n}showEndSection(){var l,c,u,a;let e=!0;(l=this.signalManager)==null||l.signalTest("done");const n=U("div","end_section_or",Rr),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
|
+
|
|
10
|
+
We appreciate your time and valuable input.`),r=U("div","end_button_or",Ts,"Submitting Feedback"),o=$r();r.appendChild(o),(u=this.test)!=null&&u.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 Rs(t){return!!t&&t.nodeType!=null}function Xt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function xe(t){return t.nodeType===Node.ELEMENT_NODE}function Gr(t){return t.nodeType===Node.COMMENT_NODE}function Yt(t){return t.nodeType===Node.TEXT_NODE}function vt(t){return t.nodeType===Node.DOCUMENT_NODE}function bt(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Y(t,e){return t.localName===e}class Kr{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||!Y(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Y(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.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=wr(i.toString(),r);this.app.send(o);const l=u=>{Jr(u,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 u=this.app.nodes.getID(s),a=u?this.app.nodes.getNode(u):void 0;!a||!Y(a,"canvas")||a!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(c)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(a)}):l(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&&Xr(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 Ds={low:.35,medium:.55,high:.8};function Jr(t,e="medium",n,s=!1,i,r){const o=`image/${i}`;if(s){const l=window.devicePixelRatio||1;n.width=t.width/l,n.height=t.height/l;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,Ds[e])}else t.toBlob(r,o,Ds[e])}function Xr(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 Ke={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class Yr{constructor(e=Ke.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Ke.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Ke.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Ke.Errors)&&console.error(...n)},this.level=e}}class Qr{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;ls(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=>us(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 Qt(t){if(Gr(t))return!0;if(Yt(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 Zt(t){return bt(t)?!0:!Qt(t)}var ve;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(ve||(ve={}));class en{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=cs(this.app.safe(s=>{for(const i of s){const r=i.target,o=i.type;if(!Zt(r))continue;if(o==="childList"){for(let c=0;c<i.removedNodes.length;c++)Zt(i.removedNodes[c])&&this.bindNode(i.removedNodes[c]);for(let c=0;c<i.addedNodes.length;c++)this.bindTree(i.addedNodes[c]);continue}const l=this.app.nodes.getID(r);if(l!==void 0){if(this.recents.has(l)||this.recents.set(l,ve.Changed),o==="attributes"){const c=i.attributeName;if(c===null)continue;let u=this.attributesMap.get(l);u===void 0&&this.attributesMap.set(l,u=new Set),u.add(c);continue}if(o==="characterData"){this.textSet.add(l);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(Xt(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(ds(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Ut(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"&&Y(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(ds(e,s));return}if(s==="style"||s==="href"&&Y(n,"link")){this.app.send(Ut(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(Y(n,"style")){this.app.send(hr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(Yi(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(!Zt(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),Qt(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(Xi(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>Qt(l)||this.app.nodes.getID(l)===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(yr(o))}}_commitNode(e,n){if(bt(n))return!0;const s=n.parentNode;let i;if(!Y(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),l=o===ve.New,c=this.indexes[e];if(c===void 0)throw"commitNode: missing node index";if(l){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(Gi(e,i,c,a.tagName,Xt(n)))}for(let d=0;d<a.attributes.length;d++){const p=a.attributes[d];this.sendNodeAttribute(e,a,p.nodeName,p.value)}}else Yt(n)&&(this.app.send(Ki(e,i,c)),this.sendNodeData(e,s,n.data));return!0}o===ve.Removed&&i!==void 0&&this.app.send(Ji(e,i,c));const u=this.attributesMap.get(e);if(u!==void 0){if(!xe(n))throw"commitNode: node is not an element";for(const a of u)this.sendNodeAttribute(e,n,a,n.getAttribute(a))}if(this.textSet.has(e)){if(!Yt(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 As extends en{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(Ht(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(Ht(e,s))})}}class Zr extends en{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(Ht(s,i))})}}class eo{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:l}=e.iFrame.getBoundingClientRect();e.offset=[o,l]}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 l;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),(l=s.defaultView)==null||l.addEventListener("resize",o),this.states.set(n,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const tn=me?Element.prototype.attachShadow:()=>new ShadowRoot;class to extends en{constructor(e,n){super(e,!0),this.iframeOffsets=new eo,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Y(s,"iframe")&&(this.options.captureIFrames&&!Oe(s,"obscured")||Oe(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||!Bi(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==n){const l=new As(this.app);this.iframeObservers.push(l),l.observe(e),n=o,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(l=>l(r)))},100));e.addEventListener("load",s),s()}handleShadowRoot(e){const n=new Zr(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=tn.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(Vi()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=tn.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new As(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=tn,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var yt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(yt||(yt={}));const no=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class so{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)&&(Oe(s,"masked")||Oe(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||xe(s)&&(Oe(s,"htmlmasked")||Oe(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&xe(s)){const i=this.options.domSanitizer(s);i===yt.Obscured&&this.obscured.add(e),i===yt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?no(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,l]=r.split(".");return`${Bt(i)}@${Bt(o)}.${Bt(l)}`})),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 io{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=ji(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 ro(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class oo{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?ro(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 Je="canceled",Ms="or_uxt_active",nn="or_buffer_1",Ce=t=>({reason:t,success:!1}),ao=t=>({...t,success:!0});var Q;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Q||(Q={}));const Ls="https://api.openreplay.com/ingest";function sn(){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 co=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 lo=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=Q.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(u=>{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),u(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:Ls,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Ke.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=hs(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 so(this,s),this.nodes=new Qr(this.options.node_id),this.observer=new to(this,s),this.ticker=new oo(this),this.ticker.attach(()=>this.commit()),this.debug=new Yr(this.options.__debug__),this.session=new io(this,this.options),this.attributeSender=new Di(this,!!this.options.disableStringDict),this.featureFlags=new Li(this),this.tagWatcher=new Tr(this.sessionStorage,this.debug.error,c=>{this.send(Sr(c))}),this.session.attachUpdateCallback(({userID:c,metadata:u})=>{c!=null&&this.send(or(c)),u!=null&&Object.entries(u).forEach(([a,d])=>this.send(fs(a,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const l=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 u=this.initialHostName;window.parent.postMessage({line:ce.iframeSignal,source:l,context:this.contextId,domain:u},"*")}else{let c=0;const u=a=>{const{data:d}=a;if(d.line===ce.iframeSignal){const p=d.domain,b=Array.from(document.querySelectorAll("iframe"));this.pageFrames=b,(async()=>{let y=0;for(;y<10;){const E=this.checkNodeId(b,p);if(E){this.waitStarted().then(()=>{var A;c++;const O=this.session.getSessionToken(),B={line:ce.iframeId,context:this.contextId,domain:p,id:E,token:O,frameOrderNumber:c};this.debug.log("iframe_data",B),(A=a.source)==null||A.postMessage(B,"*")}).catch(console.error),y=10;break}y++,await co(100)}})()}if(d.line===ce.iframeBatch){const b=d.messages.map(w=>{if(w[0]===20){let y=w;return this.pageFrames.forEach(E=>{if(E.dataset.domain===a.data.domain){const[O,B,A]=w,{left:k,top:_}=E.getBoundingClientRect();y=[O,B+k,A+_]}}),y}if(w[0]===68){let y=w;return this.pageFrames.forEach(E=>{if(E.dataset.domain===a.data.domain){const[O,B,A,k,_,R,M]=w,{left:I,top:T,width:F,height:H}=E.getBoundingClientRect(),j=document.documentElement.scrollWidth,z=document.documentElement.scrollHeight,C=R/100*F+I,L=M/100*H+T,V=C/j,G=L/z;y=[O,B,A,k,_,Math.round(V*1e3)/10,Math.round(G*1e3)/10]}}),y}return w});this.messages.push(...b)}};window.addEventListener("message",u),this.attachStopCallback(()=>{window.removeEventListener("message",u)})}this.bc!==null&&(this.bc.postMessage({line:ce.ask,source:l,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 u=c.data.token;this.session.setSessionToken(u),this.allowAppStart()}if(c.data.line===ce.reg){const u=c.data.token;this.session.regenerateTabId(),this.session.setSessionToken(u),this.allowAppStart()}if(c.data.line===ce.ask){const u=this.session.getSessionToken();u&&this.bc&&this.bc.postMessage({line:c.data.source===l?ce.reg:ce.resp,token:u,source:l,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?Ni(e.batch,{mtime:0},(r,o)=>{var l,c;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.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!==Q.NotActive&&(this.activityState===Q.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Q.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(De(this.session.getTabId())),this.messages.unshift(Re(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{$i(()=>{var e;this.messages.unshift(De(this.session.getTabId())),this.messages.unshift(Re(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(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId())),this.bufferedMessages2.push(Re(this.timestamp())),this.bufferedMessages2.push(De(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Q.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?ls(e,n,s,r):null,l=()=>e?us(e,n,s,r):null;this.attachStartCallback(o,i),this.attachStopCallback(l,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 u=fe()-i;return`${c}?jumpto=${u}`}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===Q.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,Pt(),this.coldStartTs=fe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(Re(this.timestamp())),this.bufferedMessages2.push(De(this.session.getTabId()))),this.stop(!1),this.activityState=Q.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(pt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,b;this.conditionsManager=new Ai(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:Vt,jsHeapSizeLimit:Gt,timezone:sn(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:c,userState:u,projectID:a}=await n.json();this.session.assign({projectID:a}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:c,userState:u});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),(b=this.conditionsManager)==null||b.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);Pt(),this.coldStartTs=fe();const i=this.localStorage.getItem(nn);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(nn)}this.bufferedMessages1.push(Re(this.timestamp())),this.bufferedMessages1.push(De(this.session.getTabId())),this.activityState=Q.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(pt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(nn,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,b;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:Vt,jsHeapSizeLimit:Gt,timezone:sn()})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:c,userState:u,beaconSizeLimit:a,projectID:d}=await n.json();for((b=this.worker)==null||b.postMessage({type:"auth",token:s,beaconSizeLimit:a}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:c,userState:u});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===Q.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(Ce(c))}if(this.activityState===Q.Active||this.activityState===Q.Starting)return Promise.resolve(Ce("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Q.Starting,i||Pt(),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(),l=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",l,"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:l?void 0:o,deviceMemory:Vt,jsHeapSizeLimit:Gt,timezone:sn(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(c.status!==200){const C=await c.text(),L=C===Je?Je:`Server error: ${c.status}. ${C}`;return Ce(L)}if(!this.worker){const C="no worker found after start request (this should not happen in real world)";return this.signalError(C,[]),Ce(C)}const{token:u,userUUID:a,projectID:d,beaconSizeLimit:p,compressionThreshold:b,delay:w,sessionID:y,startTimestamp:E,userBrowser:O,userCity:B,userCountry:A,userDevice:k,userOS:_,userState:R,canvasEnabled:M,canvasQuality:I,canvasFPS:T,assistOnly:F}=await c.json();if(typeof u!="string"||typeof a!="string"||typeof E!="number"&&typeof E<"u"||typeof y!="string"||typeof w!="number"||typeof p!="number"&&typeof p<"u"){const C=`Incorrect server response: ${JSON.stringify(c)}`;return this.signalError(C,[]),Ce(C)}this.delay=w,this.session.setSessionToken(u),this.session.setUserInfo({userBrowser:O,userCity:B,userCountry:A,userDevice:k,userOS:_,userState:R}),this.session.assign({sessionID:y,timestamp:E||r,projectID:d}),F?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:u,beaconSizeLimit:p}),!l&&u===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(pt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([C,L])=>this.send(fs(C,L))),this.localStorage.setItem(this.options.local_uuid_key,a),this.compressionThreshold=b;const H={sessionToken:u,userUUID:a,sessionID:y};if(this.startCallbacks.forEach(C=>C(H)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,u),this.activityState=Q.Active,M&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new Kr(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 C=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;C.length>0;)await this.flushBuffer(C);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 Vr(this,Ms);let j;const z=this.localStorage.getItem(Ms);if(z&&(j=parseInt(z,10)),location!=null&&location.search){const C=new URLSearchParams(location.search);if(C.has("oruxt")){const L=C.get("oruxt");j=L?parseInt(L,10):void 0}}return j&&(this.uxtManager.isActive?this.onUxtCb.forEach(C=>C(j)):this.uxtManager.getTest(j,u,!!z).then(C=>{C&&this.onUxtCb.forEach(L=>L(C))})),ao(H)}catch(c){if(this.stop(),this.session.reset(),c===Je)return this.signalError(Je,[]),Ce(Je);this._debug("session_start",c);const u=c instanceof Error?c.message:c.toString();return this.signalError(u,[]),Ce(u)}}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===Q.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Q.Active||this.activityState===Q.Starting?Promise.resolve(Ce("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(mr("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Q.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=Q.NotActive}}};function uo(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(lr(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const Fs=me&&"InstallTrigger"in window?t=>t.message+`
|
|
11
|
+
`+t.stack:t=>t.stack||t.message;function rn(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?Fs(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function ho(t){return typeof t!="number"?"NaN":t.toString()}function fo(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function Ps(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return Fs(t);if(Array.isArray(t)){const e=t.length,n=t.slice(0,10).map(rn).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+": "+rn(i))}return"{"+e.join(", ")+"}"}return t.toString()}function po(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 Ps(s);case"s":return rn(s);case"f":return ho(s);case"d":case"i":return fo(s);default:return e}})),t.map(Ps).join(" ")}const Bs=["log","info","warn","error","debug","assert"];function go(t,e){const n=Object.assign({consoleMethods:Bs,consoleThrottling:30},e);if(!Array.isArray(n.consoleMethods)||n.consoleMethods.length===0)return;const s=t.safe((c,u)=>t.send(nr(c,po(u))));let i=0;const r=()=>{i=0};t.attachStartCallback(r),t.ticker.attach(r,33,!1);const o=(c,u)=>{const a={apply:function(d,p,b){Reflect.apply(d,u,b),i=i+1,!(i>n.consoleThrottling)&&s(d.name,b)}};n.consoleMethods.forEach(d=>{if(Bs.indexOf(d)===-1){t.debug.error(`OpenReplay: unsupported console method "${d}"`);return}const p=u.console[d];c[d]=new Proxy(p,a)})},l=t.safe(c=>o(c.console,c));l(window),t.observer.attachContextCallback(l)}var js={exports:{}},on={exports:{}},zs;function mo(){return zs||(zs=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"],l=["fileName","functionName","source"],c=["args"],u=["evalOrigin"],a=r.concat(o,l,c,u);function d(y){if(y)for(var E=0;E<a.length;E++)y[a[E]]!==void 0&&this["set"+s(a[E])](y[a[E]])}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()||"",E=this.getLineNumber()||"",O=this.getColumnNumber()||"",B=this.getFunctionName()||"";return this.getIsEval()?y?"[eval] ("+y+":"+E+":"+O+")":"[eval]:"+E+":"+O:B?B+" ("+y+":"+E+":"+O+")":y+":"+E+":"+O}},d.fromString=function(E){var O=E.indexOf("("),B=E.lastIndexOf(")"),A=E.substring(0,O),k=E.substring(O+1,B).split(","),_=E.substring(B+1);if(_.indexOf("@")===0)var R=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(_,""),M=R[1],I=R[2],T=R[3];return new d({functionName:A,args:k||void 0,fileName:M,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(E){this[y]=!!E}}(r[p]);for(var b=0;b<o.length;b++)d.prototype["get"+s(o[b])]=i(o[b]),d.prototype["set"+s(o[b])]=function(y){return function(E){if(!n(E))throw new TypeError(y+" must be a Number");this[y]=Number(E)}}(o[b]);for(var w=0;w<l.length;w++)d.prototype["get"+s(l[w])]=i(l[w]),d.prototype["set"+s(l[w])]=function(y){return function(E){this[y]=String(E)}}(l[w]);return d})}(on)),on.exports}(function(t,e){(function(n,s){t.exports=s(mo())})(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 u=/(.+?)(?::(\d+))?(?::(\d+))?$/,a=u.exec(c.replace(/[()]/g,""));return[a[1],a[2]||void 0,a[3]||void 0]},parseV8OrIE:function(c){var u=c.stack.split(`
|
|
12
|
+
`).filter(function(a){return!!a.match(r)},this);return u.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 b=this.extractLocation(p?p[1]:d),w=p&&d||void 0,y=["eval","<anonymous>"].indexOf(b[0])>-1?void 0:b[0];return new s({functionName:w,fileName:y,lineNumber:b[1],columnNumber:b[2],source:a})},this)},parseFFOrSafari:function(c){var u=c.stack.split(`
|
|
13
|
+
`).filter(function(a){return!a.match(o)},this);return u.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),b=p&&p[1]?p[1]:void 0,w=this.extractLocation(a.replace(d,""));return new s({functionName:b,fileName:w[0],lineNumber:w[1],columnNumber:w[2],source:a})},this)},parseOpera:function(c){return!c.stacktrace||c.message.indexOf(`
|
|
14
|
+
`)>-1&&c.message.split(`
|
|
15
|
+
`).length>c.stacktrace.split(`
|
|
16
|
+
`).length?this.parseOpera9(c):c.stack?this.parseOpera11(c):this.parseOpera10(c)},parseOpera9:function(c){for(var u=/Line (\d+).*script (?:in )?(\S+)/i,a=c.message.split(`
|
|
17
|
+
`),d=[],p=2,b=a.length;p<b;p+=2){var w=u.exec(a[p]);w&&d.push(new s({fileName:w[2],lineNumber:w[1],source:a[p]}))}return d},parseOpera10:function(c){for(var u=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,a=c.stacktrace.split(`
|
|
18
|
+
`),d=[],p=0,b=a.length;p<b;p+=2){var w=u.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 u=c.stack.split(`
|
|
19
|
+
`).filter(function(a){return!!a.match(i)&&!a.match(/^Error created at/)},this);return u.map(function(a){var d=a.split("@"),p=this.extractLocation(d.pop()),b=d.shift()||"",w=b.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;b.match(/\(([^)]*)\)/)&&(y=b.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var E=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:w,args:E,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:a})},this)}}})})(js);var vo=js.exports;const bo=vi(vo);function Us(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function wt(t,e,n={}){let s=e;try{s=bo.parse(t)}catch{}return qt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function Hs(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return wt(t.error,Us(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),qt(s,i,JSON.stringify(Us(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return wt(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return qt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function yo(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(o){const l=Hs(o,i);l!=null&&t.send(l)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}n.captureExceptions&&(t.observer.attachContextCallback(s),s(window))}function $s(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 wo(t){return Fi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const So="https://static.openreplay.com/tracker/placeholder.jpeg";function xo(t){function e(l,c){t.attributeSender.sendSetAttribute(l,"src",So);const{width:u,height:a}=c.getBoundingClientRect();c.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(u)),c.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(a))}const n=function(l,c){const{srcset:u}=c;if(!u)return;const a=u.split(u.match(/,\s+/)?/,\s+/:",").map(d=>$s(d)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",a)},s=function(l,c){c.src.length>Pi&&e(l,c),t.send(Ut(l,"src",c.src,t.getBaseHref()))},i=t.safe(function(l){const c=$s(l.src||"");rs(c)&&t.send(ws(t.timestamp(),0,0,0,0,0,c,"img",0,!1))}),r=t.safe(function(l){const c=t.nodes.getID(l);c!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!wo(l.src)?i(l):t.sanitizer.isHidden(c)||t.sanitizer.isObscured(c)?e(c,l):(s(c,l),n(c,l)))}),o=cs(t.safe(l=>{for(const c of l)if(c.type==="attributes"){const u=c.target,a=t.nodes.getID(u);if(a===void 0)return;c.attributeName==="src"&&s(a,u),c.attributeName==="srcset"&&n(a,u)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(l=>{Y(l,"img")&&(t.nodes.attachNodeListener(l,"error",()=>i(l)),t.nodes.attachNodeListener(l,"load",()=>r(l)),r(l),o.observe(l,{attributes:!0,attributeFilter:["src","srcset"]}))})}const ko=["text","password","email","search","number","range","date","tel","time"];function To(t){return Y(t,"textarea")?!0:Y(t,"input")?ko.includes(t.type):!1}function Eo(t){if(!Y(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Io=me&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Y(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(Y(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 qs(t){let e=jt(t);if(e===null){const n=Io(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return is(e).slice(0,100)}const He={Plain:0,Obscured:1,Hidden:2};function Co(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:He.Obscured,obscureInputDates:!1},e);function s(a,d){let p=d.value,b=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(a)?b=He.Hidden:(t.sanitizer.isObscured(a)||b===He.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(b=He.Obscured);let w=0;switch(b){case He.Hidden:w=-1,p="";break;case He.Obscured:w=p.length,p="";break}return{value:p,mask:w}}function i(a,d){const{value:p,mask:b}=s(a,d);t.send(Zi(a,p,b))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function l(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(er(a,d)))}t.ticker.attach(()=>{r.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);l(d,p)}),o.forEach((a,d)=>{const p=t.nodes.getNode(d);if(!p)return o.delete(d);c(d,p.checked)})},3);function u(a,d,p,b){const{value:w,mask:y}=s(a,d),E=qs(d);t.send(vr(a,w,y!==0,E,p,b))}t.nodes.attachNodeCallback(t.safe(a=>{const d=t.nodes.getID(a);if(d!==void 0){if(Y(a,"select")&&(i(d,a),t.nodes.attachNodeListener(a,"change",()=>i(d,a))),To(a)){l(d,a);let p=0,b=0,w=0;const y=()=>{p=fe()},E=()=>{b===0&&p!==0&&(b=fe()-p)},O=()=>{p!==0&&(w=fe()-p),u(d,a,b,w),b=0,w=0,p=0};t.nodes.attachNodeListener(a,"focus",y),t.nodes.attachNodeListener(a,"input",E),t.nodes.attachNodeListener(a,"change",O);return}if(Eo(a)){c(d,a.checked),t.nodes.attachNodeListener(a,"change",()=>c(d,a.checked));return}}}))}let le,an,Ws;function _o(t,e){if(Ws=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},an=No(le.root,n);let s=St(t,"all",()=>St(t,"two",()=>St(t,"one",()=>St(t,"none"))));if(s){const i=Ys(Qs(s,t));return i.length>0&&(s=i[0]),xt(s)}else throw new Error("Selector was not found.")}function No(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function St(t,e,n){let s=null,i=[],r=t,o=0;for(;r;){const l=new Date().getTime()-Ws.getTime();if(le.timeoutMs!==void 0&&l>le.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let c=Tt(Oo(r))||Tt(...Ro(r))||Tt(...Do(r))||Tt(Ao(r))||[Js()];const u=Mo(r);if(e=="all")u&&(c=c.concat(c.filter(cn).map(a=>kt(a,u))));else if(e=="two")c=c.slice(0,1),u&&(c=c.concat(c.filter(cn).map(a=>kt(a,u))));else if(e=="one"){const[a]=c=c.slice(0,1);u&&cn(a)&&(c=[kt(a,u)])}else e=="none"&&(c=[Js()],u&&(c=[kt(c[0],u)]));for(let a of c)a.level=o;if(i.push(c),i.length>=le.seedMinLength&&(s=Vs(i,n),s))break;r=r.parentElement,o++}return s||(s=Vs(i,n)),!s&&n?n():s}function Vs(t,e){const n=Ys(Xs(t));if(n.length>le.threshold)return e?e():null;for(let s of n)if(Ks(s))return s;return null}function xt(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 Gs(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ks(t){const e=xt(t);switch(an.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 Oo(t){const e=t.getAttribute("id");return e&&le.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Ro(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 Do(t){return Array.from(t.classList).filter(le.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Ao(t){const e=t.tagName.toLowerCase();return le.tagName(e)?{name:e,penalty:2}:null}function Js(){return{name:"*",penalty:3}}function Mo(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 kt(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function cn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Tt(...t){const e=t.filter(Lo);return e.length>0?e:null}function Lo(t){return t!=null}function*Xs(t,e=[]){if(t.length>0)for(let n of t[0])yield*Xs(t.slice(1,t.length),e.concat(n));else yield e}function Ys(t){return[...t].sort((e,n)=>Gs(e)-Gs(n))}function*Qs(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=xt(i);if(n.visited.has(r))return;Ks(i)&&Fo(i,e)&&(yield i,n.visited.set(r,!0),yield*Qs(i,e,n))}}function Fo(t,e){return an.querySelector(xt(t))===e}function Po(t,e,n){return _o(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 ln(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 Zs(t,e){return t instanceof Element?Bo(t,e):null}function Bo(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Oe(n,"masked"))return null;n=n.parentElement}if(Xt(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"||ln(n)||jt(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function jo(t,e){const{disableClickmaps:n=!1}=e||{};function s(k){const _=jt(k);if(_!==null)return _;if(Y(k,"input"))return qs(k);if(ln(k)){let R="";return k instanceof HTMLElement&&(R=t.sanitizer.getInnerTextSecure(k)),R=R||k.id||k.className,is(R).slice(0,100)}return""}let i=-1,r=-1,o=!1,l=null,c=0,u={},a=0,d=0,p=0,b=0,w;const y=.008,E=225;function O(){const k=b/E;if(!a){a=k;return}const _=(k-a)/E;p>4&&_>y&&t.send(br(fe())),b=0,p=0,a=k}t.attachStartCallback(()=>{w=setInterval(()=>O(),E)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,l=null,u={},w&&clearInterval(w)});const B=()=>{o&&(t.send(tr(i,r)),o=!1)},A=(k,_=!1)=>{function R(I,T,F){return u[I]=u[I]||Po(T,k,F)}const M=_?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);M(k.documentElement,"mouseover",I=>{const T=Zs(I.target,k);T!==l&&(l=T,c=performance.now())}),M(k,"mousemove",I=>{const[T,F]=t.observer.getDocumentOffset(k);i=I.clientX+T,r=I.clientY+F,o=!0;const H=Math.sign(I.movementX);b+=Math.abs(I.movementX)+Math.abs(I.movementY),H!==d&&(d=H,p++)},!1),M(k,"click",I=>{const T=Zs(I.target,k);if(!I.clientX&&!I.clientY||T===null)return;const F=t.nodes.getID(T);if(F!==void 0){const H=I.pageX,j=I.pageY,z=k.documentElement.scrollWidth,C=k.documentElement.scrollHeight,L=ei(H/z),V=ei(j/C);B(),t.send(pr(F,l===T?Math.round(performance.now()-c):0,s(T),ln(T)&&!n?R(F,T,e):"",L,V),!0)}l=null})};t.nodes.attachNodeCallback(k=>{vt(k)&&A(k)}),A(document,!0),t.ticker.attach(B,(e==null?void 0:e.trackingOffset)||7)}function ei(t){return Math.round(t*1e4)}function zo(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let o="";if(Y(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 l=o.substr(0,10)==="data:image"?0:t[o];if(l===void 0)continue;const c=r.getBoundingClientRect(),u=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<=u||p<=a)continue;const b=(d-u)*(p-a);e.push({time:l,area:b})}return e}function Uo(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 Ho(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(u){var d;if(u.duration<0||!rs(u.name)||t.isServiceURL(u.name))return;s!==null&&(s[u.name]=u.startTime+u.duration);let a=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(u.name.startsWith(p)){a=!0;return}}),!a&&t.send(ws(u.startTime+je(),u.duration,u.responseStart&&u.startTime?u.responseStart-u.startTime:0,u.transferSize>u.encodedBodySize?u.transferSize-u.encodedBodySize:0,u.encodedBodySize||0,u.decodedBodySize||0,u.name,u.initiatorType,u.transferSize,u.responseStatus&&u.responseStatus===304||u.transferSize===0))}const r=new PerformanceObserver(u=>u.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:u}){u!==o&&(performance.getEntriesByType("resource").forEach(i),o=u),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,c=0;if(n.capturePageLoadTimings){let u=!1;t.ticker.attach(()=>{if(!u&&((l===0||c===0)&&performance.getEntriesByType("paint").forEach(a=>{const{name:d,startTime:p}=a;switch(d){case"first-paint":l=p;break;case"first-contentful-paint":c=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){u=!0;const{navigationStart:a,requestStart:d,responseStart:p,responseEnd:b,domContentLoadedEventStart:w,domContentLoadedEventEnd:y,loadEventStart:E,loadEventEnd:O}=performance.timing;t.send(sr(d-a||0,p-a||0,b-a||0,w-a||0,y-a||0,E-a||0,O-a||0,l,c))}},30)}if(n.capturePageRenderTimings){let u=0,a=0,d=0,p=null,b=!1;t.ticker.attach(()=>{if(b)return;const w=performance.now();if(s!==null&&(u=Math.max.apply(null,Object.keys(s).map(y=>s[y])),w-u>1e3&&(p=zo(s),s=null)),d!==null&&(w-d>50&&(a=w),d=w-a>5e3?null:w),p!==null&&d===null||w>3e4){b=!0,s=null;const y=p===null?0:Uo(c||l,p),{domContentLoadedEventEnd:E,navigationStart:O}=performance.timing,B=d===null?Math.max(a,c,E-O||0):0;t.send(ir(y,c>u?c:u,B))}})}}function un(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 $o(t,e){let n=!1;const s=new Map;function i(l){Rs(l)&&(xe(l)&&s.set(l,[l.scrollLeft,l.scrollTop]),vt(l)&&s.set(l,un(l)))}const r=t.safe(()=>{e||t.send(Wi(...un(document)))}),o=t.safe((l,c)=>{const u=t.nodes.getID(c);u!==void 0&&t.send(Qi(u,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((l,c)=>{c&&(xe(l)&&l.scrollLeft+l.scrollTop>0?s.set(l,[l.scrollLeft,l.scrollTop]):vt(l)&&s.set(l,un(l))),bt(l)&&t.nodes.attachNodeListener(l,"scroll",u=>{i(u.target)})}),t.attachEventListener(document,"scroll",l=>{const c=l.target;if(c===document){n=!0;return}i(c)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(o),s.clear()},5,!1)}function qo(t){let e,n,s,i,r=document.referrer;const o=t.safe(()=>{const{URL:u}=document;u!==e&&(e=u,t.send(xr(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:u,innerHeight:a}=window;(u!==n||a!==s)&&(n=u,s=a,t.send(qi(n,s)))}),c=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(ur(document.hidden)));t.attachStartCallback(()=>{e=null,i=je(),n=s=-1,o(),l(),c()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",c,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(l,5,!1)}function ti(t){return bt(t)&&!!t.adoptedStyleSheets}let Wo=15;function ni(){return Wo++}const Et=new Map;function Vo(t){if(t===null||!ti(document))return;const e=new Map,n=new Map,s=o=>setTimeout(()=>{let l=t.nodes.getID(o);if(o===document&&(l=0),l===void 0)return;let c=n.get(l);c||(c=[]);const u=[],a=o.adoptedStyleSheets;if(a&&Symbol.iterator in a)for(const d of a){let p=e.get(d);const b=!p;if(p||(p=ni(),e.set(d,p)),c.includes(p)||t.send(bs(p,l)),b){const w=d.cssRules;for(let y=0;y<w.length;y++)t.send($t(p,w[y].cssText,y,t.getBaseHref()))}u.push(p)}if(Symbol.iterator in c)for(const d of c)u.includes(d)||t.send(gr(d,l));n.set(l,u)},20);function i(o){const l=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");l&&Object.defineProperty(o,"adoptedStyleSheets",{...l,set:function(c){const u=l.set.call(this,c);return s(this),u}})}const r=o=>{if(o.__openreplay_adpss_patched__)return;o.__openreplay_adpss_patched__=!0,i(o.Document.prototype),i(o.ShadowRoot.prototype);const{replace:l,replaceSync:c}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(u){return l.call(this,u).then(a=>{const d=e.get(this);return d&&t.send(ms(d,u,t.getBaseHref())),a})},o.CSSStyleSheet.prototype.replaceSync=function(u){const a=e.get(this);return a&&t.send(ms(a,u,t.getBaseHref())),c.call(this,u)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(o=>{ti(o)&&s(o)})}function Go(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(dr("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const l=Et.get(i);l&&(typeof o=="string"?t.send($t(l,o,r,t.getBaseHref())):t.send(vs(l,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 l=Et.get(o);if(!l){t.debug.warn("No sheedID found for",o,Et);return}const c=r.cssText,u=o.cssRules,a=Array.from(u).indexOf(r);a>=0?(t.send($t(l,c,a,t.getBaseHref())),t.send(vs(l,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:l,deleteRule:c}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(u,a=0){return e(this,a,u),r.call(this,u,a)},i.CSSStyleSheet.prototype.deleteRule=function(u){return e(this,u),o.call(this,u)},i.CSSGroupingRule.prototype.insertRule=function(u,a=0){const d=l.call(this,u,a);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(u=0){const a=c.call(this,u);return n(this),a}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Y(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,l=ni();Et.set(o,l),t.send(bs(l,r));const c=o.cssRules;for(let u=0;u<c.length;u++)e(o,u,c[u].cssText)})}function Ko(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(gs(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Y(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{Rs(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(gs(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Y(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function Jo(t){if(!window.FontFace)return;const e=new Map,n=s=>{class i extends s.FontFace{constructor(...o){if(typeof o[1]=="string"){let l="";o[2]&&t.safe(()=>{l=JSON.stringify(o[2])});const c=[o[0],o[1],l],u=e.get(s.document)||[];u.push(c),e.set(s.document,u);const a=s===window?0:t.nodes.getID(s.document);if(a===void 0)return;t.active()&&t.send(ps(a,...c))}super(...o)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!vt(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(ps(r,...o))})}))}function Xo(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:b,data:w,method:y,url:E,baseURL:O}=p.config,{data:B,headers:A,status:k,response:_}=p,{data:R,headers:M,status:I}=_||{},T=n.ignoreHeaders,F=Array.isArray(T)?$=>T.includes($):()=>T;function H($,v){F(v[0])||($[v[0]]=v[1])}let j={},z={};b.toJSON?j=b.toJSON():b instanceof Headers?b.forEach(($,v)=>H(j,[v,$])):Array.isArray(b)?b.forEach($=>H(j,$)):typeof b=="object"&&Object.entries(b).forEach($=>H(j,$));const C=M||A;C.toJSON?z=C.toJSON():C instanceof Headers?C.forEach(($,v)=>H(z,[v,$])):Array.isArray(C)?C.forEach($=>H(z,$)):typeof C=="object"&&Object.entries(C).forEach(([$,v])=>{F($)||(z[$]=v)});const L=s({url:E,method:y||"",status:k||I||0,request:{headers:j,body:w},response:{headers:z,body:R||B}});if(!L){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",L),t.send(ft("xhr",String(y),String(L.url),i(L.request),i(L.response),L.status,V+je(),G,0))}function o(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const b=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",w=t.getSessionToken();w&&p.headers.set(b,w)}return p}function l(p){return n.failuresOnly||r(p),p}function c(p){return t.debug.log("Openreplay: capturing API request error",p),Yo(p)&&p.response?r(p.response):p instanceof Error&&t.send(wt(p,[])),Promise.reject(p)}function u(p){t.debug.log("Openreplay: failed API request, skipping",p)}const a=e.interceptors.request.use(o,u,{synchronous:!0}),d=e.interceptors.response.use(l,c,{synchronous:!0});t.attachStopCallback(()=>{var p,b,w,y;(b=(p=e.interceptors.request).eject)==null||b.call(p,a),(y=(w=e.interceptors.response).eject)==null||y.call(w,d)})}function Yo(t){return Qo(t)&&t.isAxiosError===!0}function Qo(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 hn{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 ft(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+je(),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 Xe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:fn(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},dn=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(ea(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":fn(t)?e=t:e=`can't parse body ${typeof t}`;return e},Zo=(t,e={})=>{fn(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 fn(t){return t!==null&&typeof t=="object"}function ea(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function It(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const pn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class ta{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=Xe(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 l=new Uint8Array(e.length+o.value.length);l.set(e),l.set(o.value,e.length),e=l}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=It(this.item.responseSize),o.done&&(this.item.response=Xe(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=Xe(this.item.responseType,e),r.apply(s,o)),s}}}class na{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 l=new hn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((c,u)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(c,u);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(c,u):Array.isArray(s[1].headers)?s[1].headers.push([c,u]):s[1].headers[c]=u}}),e.apply(window,s).then(this.afterFetch(l)).catch(c=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),c})}beforeFetch(e,n,s){let i,r="GET",o={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=pn(n),o=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=pn(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[l,c]of o)e.requestHeader[l]=c}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[l,c]of i.searchParams)e.getData[l]=c}s!=null&&s.body&&(e.requestData=dn(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=It(e.responseSize),e.response=Xe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new ta(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 sa{static create(e,n,s,i,r,o){return new Proxy(fetch,new na(e,n,s,i,r,o))}}class ia{constructor(e,n,s,i,r,o,l){this.ignoredHeaders=n,this.setSessionTokenHeader=s,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=o,this.tokenUrlMatcher=l,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new hn(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=Xe(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,l;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=((l=this.item.url)==null?void 0:l.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=Zo(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=dn(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=It(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=It(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class ra{static create(e,n,s,i,r,o){return new Proxy(XMLHttpRequest,{construct(l){const c=new l;return new Proxy(c,new ia(c,e,n,s,i,r,o))}})}}const oa=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 aa{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 hn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(n,s);const l=pn(i);if(o.method="POST",o.url=i,o.name=(l.pathname.split("/").pop()||"")+l.search,o.requestType="beacon",o.requestHeader={"Content-Type":oa(r)},o.status=0,o.statusText="Pending",l.search&&l.searchParams){o.getData={};for(const[a,d]of l.searchParams)o.getData[a]=d}o.requestData=dn(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 u=o.getMessage();return u&&this.sendMessage(u),c}}class $e{static hasSendBeacon(){return!!$e.origSendBeacon}static create(e,n,s,i,r){if($e.hasSendBeacon())return new Proxy($e.origSendBeacon,new aa(e,n,s,i,r))}}$e.origSendBeacon=(ai=window==null?void 0:window.navigator)==null?void 0:ai.sendBeacon;const si=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 ca(t,e,n,s,i,r,o){var l;t.XMLHttpRequest?t.XMLHttpRequest=ra.create(e,n,s,i,r,o):si("XMLHttpRequest"),t.fetch?t.fetch=sa.create(e,n,s,i,r,o):si("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=$e.create(e,n,s,i,r))}function gn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function ii(t){return typeof t=="string"?t.toUpperCase():"GET"}function la(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 l(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 u=a=>{if(n.useProxy)return ca(a,n.ignoreHeaders,o,l,A=>t.send(A),A=>t.isServiceURL(A),n.tokenUrlMatcher);const d=a.fetch.bind(a),p=(A,k={})=>{if(!(typeof A=="string"||A instanceof URL)||t.isServiceURL(String(A)))return d(A,k);o(function(R,M){k.headers===void 0&&(k.headers={}),k.headers instanceof Headers?k.headers.append(R,M):Array.isArray(k.headers)?k.headers.push([R,M]):k.headers[R]=M});const _=performance.now();return d(A,k).then(R=>{const M=performance.now()-_;if(n.failuresOnly&&R.status<400)return R;const I=R.clone();return I.text().then(T=>{const F={},H={};if(s!==!0){const C=([L,V])=>{i(L)||(F[L]=V)};k.headers instanceof Headers?k.headers.forEach((L,V)=>C([V,L])):Array.isArray(k.headers)?k.headers.forEach(C):typeof k.headers=="object"&&Object.entries(k.headers).forEach(C),I.headers.forEach((L,V)=>{i(V)||(H[V]=L)})}const j=ii(k.method),z=l({url:String(A),method:j,status:I.status,request:{headers:F,body:k.body||null},response:{headers:H,body:T}});z&&t.send(ft("fetch",j,String(z.url),c(z.request),c(z.response),I.status,_+je(),M,0))}).catch(T=>t.debug.error("Could not process Fetch response:",T)),R})};a.fetch=p;const b=a.XMLHttpRequest.prototype.open,w=a.XMLHttpRequest.prototype.setRequestHeader,y=a.XMLHttpRequest.prototype.send;function E(A,k){const _=this;o((M,I)=>_.setRequestHeader(M,I));let R=0;return _.addEventListener("loadstart",M=>{R=M.timeStamp}),_.addEventListener("load",t.safe(M=>{const{headers:I,body:T}=gn(_),F=R>0?M.timeStamp-R:0,j=(_.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),z={};j.forEach(function(V){const G=V.split(": "),$=G.shift();i($)||(z[$]=G.join(": "))});const C=ii(A),L=l({url:String(k),method:C,status:_.status,request:{headers:I,body:T||null},response:{headers:z,body:_.response}});L&&t.send(ft("xhr",C,String(L.url),c(L.request),c(L.response),_.status,R+je(),F,0))})),b.apply(this,arguments)}function O(A){const k=gn(this);return k.body=A,y.apply(this,arguments)}function B(A,k){if(!i(A)){const _=gn(this);_.headers[A]=k}return w.apply(this,arguments)}n.axiosInstances||(a.XMLHttpRequest.prototype.open=E,a.XMLHttpRequest.prototype.send=O,a.XMLHttpRequest.prototype.setRequestHeader=B)};u(window),n.axiosInstances&&n.axiosInstances.forEach(a=>{Xo(t,a,n,l,c)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(u))}function ua(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(ys(n,s,i))}else t.send(ys(-1,-1,""))})}function ha(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(pt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Ct="/installation/javascript-sdk";function da(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${dt}${Ct}`),!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 ${dt}${Ct} for more information.`),!1;t.projectKey=t.projectID.toString(),Ie("`projectID` option","`projectKey` option",Ct)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ie("`sessionToken` option","`sessionHash` start() option","/"),!0}class fa{constructor(e){var l;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(c,u)=>{const a=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||Ls;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:a,reason:u.length?`missing api: ${u.join(",")}`:c}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(c,u={})=>{if(this.app!==null){if(c instanceof Error){const a=wt(c,[],u);this.app.send(a)}else if(c instanceof ErrorEvent||"PromiseRejectionEvent"in window&&c instanceof PromiseRejectionEvent){const a=Hs(c,void 0,u);a!=null&&this.app.send(a)}}},this.crossdomainMode=!!(zi()&&((l=e.crossdomain)!=null&&l.enabled)),!me||!da(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 lo(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(qo(r),uo(r),kr(r,e),ha(r)),jo(r,e.mouse),$o(r,this.crossdomainMode),Go(r),Vo(r),go(r,e),yo(r,e),xo(r),Co(r,e),Ho(r,e),Ko(r),Jo(r),la(r,e.network),ua(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(),u=r.sessionStorage??window.sessionStorage;window.open=function(...a){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&u.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),u.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 ${dt}${Ct}`),!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 Ie("'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){Ie("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(ar(e))}userAnonymousID(e){Ie("'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){Ie("'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(rr(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(fr(e,n))}}}const pa=`
|
|
22
22
|
/* ===================== 1) Переменные и шрифты ===================== */
|
|
23
23
|
:root {
|
|
24
24
|
--wineater-corp-color: #0044FF;
|
|
@@ -882,42 +882,42 @@ margin: 5px 0;
|
|
|
882
882
|
</div>
|
|
883
883
|
</div>
|
|
884
884
|
</div>
|
|
885
|
-
`;e.insertAdjacentHTML("beforeend",n),this.addEventListenersStoreVersion()}addEventListenersStoreVersion(){document.getElementById("wine-search-button").addEventListener("click",()=>{this.sendEvent("searchButtonClicked",{query:document.getElementById("wine-search-input").value}),this.handleSearch()}),this.setupFilterButtons("price-buttons","price"),this.setupFilterButtons("color-buttons","color"),this.setupFilterButtons("intensity-buttons","intensity"),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}setupFilterButtons(e,n){const s=document.querySelectorAll(`#${e} button`);s.forEach(i=>{i.addEventListener("click",r=>{s.forEach(
|
|
885
|
+
`;e.insertAdjacentHTML("beforeend",n),this.addEventListenersStoreVersion()}addEventListenersStoreVersion(){document.getElementById("wine-search-button").addEventListener("click",()=>{this.sendEvent("searchButtonClicked",{query:document.getElementById("wine-search-input").value}),this.handleSearch()}),this.setupFilterButtons("price-buttons","price"),this.setupFilterButtons("color-buttons","color"),this.setupFilterButtons("intensity-buttons","intensity"),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}setupFilterButtons(e,n){const s=document.querySelectorAll(`#${e} button`);s.forEach(i=>{i.addEventListener("click",r=>{s.forEach(o=>o.classList.remove("selected")),r.target.classList.add("selected"),this.selectedFilters[n]=r.target.dataset.value,this.handleSearch()})})}async handleSearch(){const e="wine for dish:"+document.getElementById("wine-search-input").value.trim()+";",n=this.selectedFilters,s=[];n.price&&s.push(`price: ${n.price||"any"};`),n.color&&s.push(`color: ${n.color||"any"}; `),n.intensity&&s.push(`intensity: ${n.intensity||"any"}; `);const i=s.length>0?`${e} ${s.join(", ")}`:e;console.log("Searching for:",i),console.log("Applied filters:",n),this.sendEvent("searchPerformed",{query:i,filters:n}),this.animateCardDisappearance();try{const r=await this.api.getWineRecommendationsSearch(i);r&&r.length>0?(console.log("Recommendations:",r),this.displayResults(r,!0)):(console.log("No recommendations found."),this.displayNoResultsMessage())}catch(r){console.error("Error fetching wine recommendations:",r.message),this.displayErrorMessage()}}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"}))})}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.hideLoadingIndicator(),s.innerHTML="",this.sendEvent("resultsDisplayed",{resultsCount:e.length});const i=(u,a)=>u[a]||u[a.charAt(0).toUpperCase()+a.slice(1)],r=(u,a)=>a.map(d=>i(u,d)).filter(Boolean).join(" • "),o=u=>Array.isArray(u)?u.map(a=>`<span class="popup-tag">${a}</span>`).join(""):"",l=u=>{const a=u.tags||u.Tags,d=u.reason||u["Short Description"];return!d&&!a?"":`
|
|
886
886
|
<div class="wine-hover-popup">
|
|
887
|
-
${
|
|
888
|
-
${
|
|
889
|
-
</div>`};e.forEach((
|
|
890
|
-
<div class="wine-recommendation-tile ${
|
|
891
|
-
${
|
|
887
|
+
${d?`<div class="popup-reason">${d}</div>`:""}
|
|
888
|
+
${a?`<div class="popup-tags">${o(a)}</div>`:""}
|
|
889
|
+
</div>`};function c(u){return typeof u!="number"&&(u=Number(u)),u.toLocaleString("en-US")}e.forEach((u,a)=>{const d=i(u,"title"),p=i(u,"image"),b=i(u,"total"),w=i(u,"url"),y=u.tags||u.Tags,E=r(u,["type","country","region","grape"]),O=y?o(y):"",B=l(u),A=u["Short Description"],k=u.pairing_recommendation,_=u.isSommSelection,R=`
|
|
890
|
+
<div class="wine-recommendation-tile ${_?"somm-selection":""}">
|
|
891
|
+
${_?`<div class="somm-selection-badge">${Z.translate("wineDetails.sommSelection")}</div>`:""}
|
|
892
892
|
|
|
893
893
|
<div class="tile-top">
|
|
894
|
-
${
|
|
895
|
-
<div class="wine-price">${
|
|
896
|
-
<h3 class="wine-title">${
|
|
894
|
+
${p?`<img src="${p}" alt="${d}" class="wine-image" />`:""}
|
|
895
|
+
<div class="wine-price">${c(b)} ${Z.getCurrency("label")}</div>
|
|
896
|
+
<h3 class="wine-title">${d}</h3>
|
|
897
897
|
</div>
|
|
898
898
|
|
|
899
|
-
${
|
|
899
|
+
${E?`<div class="wine-params">${E}</div>`:""}
|
|
900
900
|
|
|
901
901
|
<div class="bottom-row">
|
|
902
|
-
${
|
|
902
|
+
${w?`<a class="buy-btn" href="${w}" target="_blank">${Z.translate("wineDetails.buy")}</a>`:`<button class="buy-btn" data-toggle-info>${Z.translate("moreInfo")}</button>`}
|
|
903
903
|
</div>
|
|
904
904
|
|
|
905
905
|
<div class="card-popup hidden">
|
|
906
906
|
<div class="card-popup-header">
|
|
907
|
-
<h2>${
|
|
907
|
+
<h2>${d}</h2>
|
|
908
908
|
<span class="card-popup-close">×</span>
|
|
909
909
|
</div>
|
|
910
|
-
${
|
|
911
|
-
${
|
|
912
|
-
${
|
|
910
|
+
${A?`<p>${A}</p>`:""}
|
|
911
|
+
${u.reason?`<div class="popup-reason">${u.reason}</div>`:k?`<p>${k}</p>`:""}
|
|
912
|
+
${O?`<div class="popup-tags">${O}</div>`:""}
|
|
913
913
|
</div>
|
|
914
914
|
|
|
915
|
-
${
|
|
915
|
+
${B}
|
|
916
916
|
</div>
|
|
917
|
-
`;s.insertAdjacentHTML("beforeend",
|
|
917
|
+
`;s.insertAdjacentHTML("beforeend",R);const M=s.children[a];if(!w){const I=M.querySelector("[data-toggle-info]"),T=M.querySelector(".card-popup"),F=M.querySelector(".card-popup-close");F==null||F.addEventListener("click",H=>{H.stopPropagation(),T.classList.add("hidden")}),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()))}),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,C=document.createElement("div");C.className="mobile-fullscreen-wrapper",C.innerHTML=`
|
|
918
918
|
<div class="mobile-fullscreen-overlay"></div>
|
|
919
|
-
<div class="card-popup mobile-fullscreen-popup">${
|
|
920
|
-
`,(
|
|
919
|
+
<div class="card-popup mobile-fullscreen-popup">${z}</div>
|
|
920
|
+
`,(j=C.querySelector(".card-popup-close"))==null||j.addEventListener("click",()=>C.remove()),document.body.appendChild(C)}else T.classList.remove("hidden")})}setTimeout(()=>{M.style.opacity="1",M.style.transform="translateY(0)"},n?a*200:0)}),this.widgetType==="store"&&this.enableHoverPopups()}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)}showLoadingIndicator(){document.getElementById("loading-indicator").classList.remove("hidden")}hideLoadingIndicator(){document.getElementById("loading-indicator").classList.add("hidden")}displayNoResultsMessage(){const e=document.getElementById("wine-placeholder");e.innerHTML=`
|
|
921
921
|
<div class="no-results">
|
|
922
922
|
<p>${Z.translate("noResultsMessage")||"No recommendations found for your query."}</p>
|
|
923
923
|
</div>
|
|
@@ -925,4 +925,4 @@ margin: 5px 0;
|
|
|
925
925
|
<div class="error-message">
|
|
926
926
|
<p>${Z.translate("errorMessage")||"Something went wrong. Please try again later."}</p>
|
|
927
927
|
</div>
|
|
928
|
-
`}async loadInstantRecommendations(){this.showLoadingIndicator();try{const e=await this.api.getInstantRecommendations();this.displayResults(e)}catch(e){console.error("Error loading instant recommendations:",e.message)}}initializeSearchAnimation(){const e=document.getElementById("wine-search-input"),n=Z.translate("placeholderSuggestions");let s=0,i=0,r=!0,
|
|
928
|
+
`}async loadInstantRecommendations(){this.showLoadingIndicator();try{const e=await this.api.getInstantRecommendations();this.displayResults(e)}catch(e){console.error("Error loading instant recommendations:",e.message)}}initializeSearchAnimation(){const e=document.getElementById("wine-search-input"),n=Z.translate("placeholderSuggestions");let s=0,i=0,r=!0,o=!1;const l=()=>{o||(r?(e.placeholder=n[s].substring(0,i++),i>n[s].length?(r=!1,setTimeout(l,2e3)):setTimeout(l,100)):(e.placeholder=n[s].substring(0,i--),i<0?(r=!0,s=(s+1)%n.length,setTimeout(l,500)):setTimeout(l,50)))};l(),e.addEventListener("focus",()=>{e.placeholder="",o=!0}),e.addEventListener("blur",()=>{o=!1,i=0,r=!0,l()})}}const ya="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class wa{constructor(){this.tracker=new fa({projectKey:"PA8j9fAi49i6g2QnvpNs",__DISABLE_SECURE_MODE:!0})}async initTranslator(){const e=this.store?this.store.charAt(0).toUpperCase()+this.store.slice(1):"Test";await Z.fetchConfig(e||"Test")}initCookies(){var e;Bn("chatbotToken",((e=window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||ya,365),mi()}async initialize(){this.tracker.start(),await this.initTranslator(),this.initCookies(),new ba}}document.addEventListener("DOMContentLoaded",()=>{new wa().initialize()})});
|