wineater-bot 3.0.2 → 3.0.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 +154 -145
- package/dist/wineater-chatbot.umd.js +49 -40
- package/index.html +3 -3
- package/package.json +1 -1
- package/src/index.js +4 -4
- package/src/js/api.js +2 -2
- package/src/js/styles.js +5 -1
- package/src/js/widget.js +16 -10
|
@@ -435,10 +435,14 @@ border-bottom-right-radius: 15px;
|
|
|
435
435
|
justify-content: center;
|
|
436
436
|
align-items: center;
|
|
437
437
|
height: 0;
|
|
438
|
-
|
|
438
|
+
visibility: hidden;
|
|
439
439
|
background-color: white;
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
+
#loading-indicator .typing-indicator {
|
|
443
|
+
visibility: visible;
|
|
444
|
+
}
|
|
445
|
+
|
|
442
446
|
.typing-indicator span {
|
|
443
447
|
display: block;
|
|
444
448
|
width: 8px;
|
|
@@ -636,16 +640,16 @@ border-bottom-right-radius: 15px;
|
|
|
636
640
|
height: 80px;
|
|
637
641
|
}
|
|
638
642
|
}
|
|
639
|
-
`,Wn=document.createElement("style");Wn.textContent=it,document.head.appendChild(Wn);function Ii(){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 rt(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 se(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 Ci(t){document.cookie=t+"=; Max-Age=-99999999;"}function _i(){const t="uniqueUserID";let e=se(t);return e||(e=Ii(),rt(t,e,365)),e}function Ke(t,e){fetch("https://wineater-backend.vercel.app/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:t,properties:e})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function Ni(){Ke("Chatbot Opened",{distinct_id:se("uniqueUserID"),client:se("chatbotToken")})}function qn(){Ke("Chatbot Closed",{distinct_id:se("uniqueUserID"),client:se("chatbotToken")})}function Oi(t){Ke("Message Sent",{distinct_id:se("uniqueUserID"),message_content:t,client:se("chatbotToken")})}function Ri(t){Ke("Products Got",{distinct_id:se("uniqueUserID"),products:t,client:se("chatbotToken")})}function Fi(t){Ke("Product Clicked",{distinct_id:se("uniqueUserID"),product_id:t,client:se("chatbotToken")})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Dt={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var u=this;return new Promise(function(m,g){try{var w=u.getItemSync(b);f==null||f(null,w),m(w)}catch(x){f&&f(x,null),g(x)}})},setItem:function(b,f,u){return new Promise(function(m,g){try{localStorage.setItem(b,f),u&&u(null,f),m(f)}catch(w){u&&u(w,null),g(w)}})}},i=function(){return i=Object.assign||function(b){for(var f,u=1,m=arguments.length;u<m;u++)for(var g in f=arguments[u])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,u,m){return new(u||(u=Promise))(function(g,w){function x(H){try{L(m.next(H))}catch(_){w(_)}}function R(H){try{L(m.throw(H))}catch(_){w(_)}}function L(H){var _;H.done?g(H.value):(_=H.value,_ instanceof u?_:new u(function(W){W(_)})).then(x,R)}L((m=m.apply(b,f||[])).next())})}function o(b,f){var u,m,g,w,x={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return w={next:R(0),throw:R(1),return:R(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function R(L){return function(H){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;x;)try{if(u=1,m&&(g=2&_[0]?m.return:_[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,_[1])).done)return g;switch(m=0,g&&(_=[2&_[0],g.value]),_[0]){case 0:case 1:g=_;break;case 4:return x.label++,{value:_[1],done:!1};case 5:x.label++,m=_[1],_=[0];continue;case 7:_=x.ops.pop(),x.trys.pop();continue;default:if(g=x.trys,!((g=g.length>0&&g[g.length-1])||_[0]!==6&&_[0]!==2)){x=0;continue}if(_[0]===3&&(!g||_[1]>g[0]&&_[1]<g[3])){x.label=_[1];break}if(_[0]===6&&x.label<g[1]){x.label=g[1],g=_;break}if(g&&x.label<g[2]){x.label=g[2],x.ops.push(_);break}g[2]&&x.ops.pop(),x.trys.pop();continue}_=f.call(b,x)}catch(W){_=[6,W],m=0}finally{u=g=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([L,H])}}}function l(b,f,u){if(u||arguments.length===2)for(var m,g=0,w=f.length;g<w;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var a=function b(f,u){if(f===u)return!0;if(f&&u&&typeof f=="object"&&typeof u=="object"){if(f.constructor!==u.constructor)return!1;var m,g,w;if(Array.isArray(f)){if((m=f.length)!=u.length)return!1;for(g=m;g--!=0;)if(!b(f[g],u[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===u.source&&f.flags===u.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===u.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===u.toString();if((m=(w=Object.keys(f)).length)!==Object.keys(u).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(u,w[g]))return!1;for(g=m;g--!=0;){var x=w[g];if(!b(f[x],u[x]))return!1}return!0}return f!=f&&u!=u};function h(b,f){var u=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],w=f==null?void 0:f[m];return!a(g,w)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||u.push(m)}),Object.keys(u).length?u:null}var c,d;function p(b,f,u){var m="shortString",g=!0;typeof u=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?u+"":u}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function S(b){return Object.fromEntries(Object.entries(b).map(function(f){var u=f[0],m=f[1];return[u,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:S(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(c||(c={}));var T,F=null,B="BULLET_TRAIN_DB",A="BULLET_TRAIN_EVENT",k="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",O="flagsmith_enabled_",D="flagsmith_trait_",I=function(){function b(f){var u=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=u,g=m.api,w=m.evaluationContext;u.log("Get Flags"),u.isLoading=!0,u.loadingState.isFetching||u.setLoadingState(i(i({},u.loadingState),{isFetching:!0}));var x="".concat(u.getContext().identity),R=function(L){var H,_,W,ee;if(L&&x==="".concat(u.getContext().identity)){var ae=L.flags,te=L.traits,ne=L.identifier;u.isLoading=!1;var ue={},de={};te=te||[],(ae=ae||[]).forEach(function(X){ue[X.feature.name.toLowerCase().replace(/ /g,"_")]={id:X.feature.id,enabled:X.enabled,value:X.feature_state_value}}),te.forEach(function(X){de[X.trait_key.toLowerCase().replace(/ /g,"_")]={transient:X.transient,value:X.trait_value}}),u.oldFlags=i({},u.flags);var we=h(u.oldFlags,ue),Ze=h((H=u.evaluationContext.identity)===null||H===void 0?void 0:H.traits,de);if((ne||Object.keys(de).length)&&(u.evaluationContext.identity={traits:de},ne&&(u.evaluationContext.identity.identifier=ne)),u.flags=ue,u.updateStorage(),u._onChange(u.oldFlags,{isFromServer:!0,flagsChanged:we,traitsChanged:Ze},u._loadedState(null,c.SERVER)),u.datadogRum)try{if(u.datadogRum.trackTraits){var et={};Object.keys(((_=u.evaluationContext.identity)===null||_===void 0?void 0:_.traits)||{}).map(function(X){et[D+X]=u.getTrait(X)});var qe=i(i(i({},u.datadogRum.client.getUser()),{id:u.datadogRum.client.getUser().id||((W=u.evaluationContext.identity)===null||W===void 0?void 0:W.identifier)}),et);u.log("Setting Datadog user",qe),u.datadogRum.client.setUser(qe)}}catch(X){console.error(X)}if(u.dtrum)try{var re={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(u.flags).map(function(X){p(re,N+X,u.getValue(X,{skipAnalytics:!0})),p(re,O+X,u.hasFeature(X,{skipAnalytics:!0}))}),Object.keys(((ee=u.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(X){p(re,D+X,u.getTrait(X))}),u.log("Sending javaLongOrObject traits to dynatrace",re.javaLongOrObject),u.log("Sending date traits to dynatrace",re.date),u.log("Sending shortString traits to dynatrace",re.shortString),u.log("Sending javaDouble to dynatrace",re.javaDouble),u.dtrum.sendSessionProperties(re.javaLongOrObject,re.date,re.shortString,re.javaDouble)}catch(X){console.error(X)}}};return w.identity?Promise.all([w.identity.traits&&Object.keys(w.identity.traits).length||!w.identity.identifier?u.getJSON(g+"identities/","POST",JSON.stringify({identifier:w.identity.identifier,transient:w.identity.transient,traits:Object.entries(w.identity.traits).map(function(L){var H=L[0],_=L[1];return{trait_key:H,trait_value:_==null?void 0:_.value,transient:_==null?void 0:_.transient}}).filter(function(L){return L.trait_value!==void 0||(u.log("Warning - attempted to set an undefined trait value for key",L.trait_key),!1)})})):u.getJSON(g+"identities/?identifier="+encodeURIComponent(w.identity.identifier)+(w.identity.transient?"&transient=true":""))]).then(function(L){return u.evaluationContext.identity=i(i({},u.evaluationContext.identity),{traits:{}}),R(L==null?void 0:L[0])}).catch(function(L){var H=L.message,_=new Error(H);return Promise.reject(_)}):u.getJSON(g+"flags/").then(function(L){return R({flags:L,traits:void 0})})},this.analyticsFlags=function(){var m=u.api;if(u.evaluationEvent&&u.evaluationContext.environment&&u.evaluationEvent[u.evaluationContext.environment.apiKey])return u.evaluationEvent&&Object.getOwnPropertyNames(u.evaluationEvent).length!==0&&Object.getOwnPropertyNames(u.evaluationEvent[u.evaluationContext.environment.apiKey]).length!==0?u.getJSON(m+"analytics/flags/","POST",JSON.stringify(u.evaluationEvent[u.evaluationContext.environment.apiKey])).then(function(g){if(u.evaluationContext.environment){var w=u.getState();u.evaluationEvent||(u.evaluationEvent={}),u.evaluationEvent[u.evaluationContext.environment.apiKey]={},u.setState(i(i({},w),{evaluationEvent:u.evaluationEvent})),u.updateEventStorage()}}).catch(function(g){u.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,w){var x=u.flags&&u.flags[m.toLowerCase().replace(/ /g,"_")],R=null;if(x&&(R=x.value),g!=null&&g.skipAnalytics||w||u.evaluateFlag(m,"VALUE"),R===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return R===null?(u.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(R)}catch{return g.fallback}return R},this.getTrait=function(m){var g,w;return((g=u.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((w=u.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||w===void 0?void 0:w.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=u.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var w=g[0],x=g[1];return[w,x==null?void 0:x.value]}))},this.setContext=function(m){var g=y(m);return u.evaluationContext=i(i({},g),{environment:g.environment||u.evaluationContext.environment}),u.initialised?u.getFlags():Promise.resolve()},this.getContext=function(){return u.evaluationContext},this.updateContext=function(m){return u.setContext(i(i({},u.getContext()),m))},this.setTrait=function(m,g){var w;if(u.api)return u.setContext(i(i({},u.evaluationContext),{identity:i(i({},u.evaluationContext.identity),{traits:i(i({},(w=u.evaluationContext.identity)===null||w===void 0?void 0:w.traits),S(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(u.api)return u.setContext(i(i({},u.evaluationContext),{identity:i(i({},u.evaluationContext.identity),{traits:i(i({},(g=u.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(w){var x=w[0],R=w[1];return[x,v(R)?R:{value:R}]})))})}));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 w=typeof g=="object",x=u.flags&&u.flags[m.toLowerCase().replace(/ /g,"_")],R=!1;return!x&&w&&g.fallback!==void 0?R=g==null?void 0:g.fallback:x&&x.enabled&&(R=!0),(w&&!g.skipAnalytics||!g)&&u.evaluateFlag(m,"ENABLED"),R},this.getJSON=function(m,g,w){var x,R=u;R.evaluationContext;var L=R.headers,H={method:g||"GET",body:w,cache:"no-cache",headers:{}};u.evaluationContext.environment&&(H.headers["X-Environment-Key"]=u.evaluationContext.environment.apiKey),g&&g!=="GET"&&(H.headers["Content-Type"]="application/json; charset=utf-8"),L&&Object.assign(H.headers,L),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var _="".concat((x=u.evaluationContext.identity)===null||x===void 0?void 0:x.identifier);return d(m,H).then(function(W){var ee,ae,te="".concat((ee=u.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(_===te){var ne=(ae=W.headers)===null||ae===void 0?void 0:ae.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");u.timestamp=ue}catch(de){u.log(de,"Failed to parse x-flagsmith-document-updated-at",ne)}return u.log("Fetch response: "+W.status+" "+(g||"GET")+0+m),W.text().then(function(de){var we=de;try{we=JSON.parse(de)}catch{}return!we&&W.status&&(we="API Response: ".concat(W.status)),W.status&&W.status>=200&&W.status<300?we:Promise.reject(new Error(we))})}u.log("Received response with identity mismatch, ignoring response. Requested: ".concat(_,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(u.datadogRum&&(u.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?u.datadogRum.client.addFeatureFlagEvaluation(N+m,u.getValue(m,{},!0)):u.datadogRum.client.addFeatureFlagEvaluation(O+m,u.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),u.enableAnalytics){if(!u.evaluationEvent||!u.evaluationContext.environment)return;u.evaluationEvent[u.evaluationContext.environment.apiKey]||(u.evaluationEvent[u.evaluationContext.environment.apiKey]={}),u.evaluationEvent[u.evaluationContext.environment.apiKey][m]===void 0&&(u.evaluationEvent[u.evaluationContext.environment.apiKey][m]=0),u.evaluationEvent[u.evaluationContext.environment.apiKey][m]+=1}u.updateEventStorage()},this._onChange=function(m,g,w){var x,R;u.setLoadingState(w),(x=u.onChange)===null||x===void 0||x.call(u,m,g,u.loadingState),(R=u._trigger)===null||R===void 0||R.call(u)},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&&(T=f.eventSource),f.AsyncStorage&&(F=f.AsyncStorage)}return b.prototype.init=function(f){var u,m,g;return r(this,void 0,void 0,function(){var w,x,R,L,H,_,W,ee,ae,te,ne,ue,de,we,Ze,et,qe,re,X,kn,tt,wi,nt,Tn,Si,xi,En,ki,In,st,Ve,Ti,oe=this;return o(this,function(ge){switch(ge.label){case 0:w=y(f.evaluationContext||this.evaluationContext),ge.label=1;case 1:if(ge.trys.push([1,13,,14]),x=f.environmentID,R=f.api,L=R===void 0?k:R,H=f.headers,_=f.onChange,W=f.cacheFlags,ee=f.datadogRum,ae=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,de=f.enableLogs,we=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,re=qe===void 0?"https://realtime.flagsmith.com/":qe,X=f.AsyncStorage,kn=f.identity,tt=f.traits,wi=f.state,nt=f.cacheOptions,Tn=f.angularHttpClient,Si=f._trigger,xi=f._triggerLoadingState,w.environment=x?{apiKey:x}:w.environment,!w.environment||!w.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(w.identity=kn||tt?{identifier:kn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(fe){return[fe[0],{value:fe[1]}]})):{}}:w.identity,this.evaluationContext=w,this.api=L,this.headers=H,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=_,En="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=Si||this._trigger,this._triggerLoadingState=xi||this._triggerLoadingState,this.onError=function(fe){oe.setLoadingState(i(i({},oe.loadingState),{isFetching:!1,isLoading:!1,error:fe})),ae==null||ae(fe)},this.enableLogs=de||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=F!==void 0&&!!W,X&&(F=X),et&&typeof window<"u"&&this.setupRealtime(re,w.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:c.DEFAULT_FLAGS})),this.setState(wi),this.log("Initialising with properties",f,this),we&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Tn&&(d=function(fe){return function(Se,xe){var Ne=xe.headers,Y=xe.method,Ge=xe.body;return new Promise(function(De){switch(Y){case"GET":return fe.get(Se,{headers:Ne}).subscribe(function(Te){De({ok:!0,text:function(){return Promise.resolve(Te)}})});case"POST":case"PUT":return fe.post(Se,Ge,{headers:Ne}).subscribe(function(Te){De({ok:!0,text:function(){return Promise.resolve(Te)}})})}})}}(Tn)),F&&this.canUseStorage&&F.getItem(A).then(function(fe){try{oe.evaluationEvent=JSON.parse(fe)||{}}catch{oe.evaluationEvent={}}oe.analyticsInterval=setInterval(oe.analyticsFlags,oe.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),F&&this.canUseStorage&&F.getItem(A,function(fe,Se){if(Se&&oe.evaluationContext.environment){var xe=JSON.parse(Se);if(xe[oe.evaluationContext.environment.apiKey]){var Ne=oe.getState();oe.log("Retrieved events from cache",Se),oe.setState(i(i({},Ne),{evaluationEvent:xe[oe.evaluationContext.environment.apiKey]}))}}})),!W)return[3,9];if(!F||!this.canUseStorage)return[3,8];ki=function(fe,Se){return r(oe,void 0,void 0,function(){var xe,Ne,Y,Ge,De,Te,Cn,Ei,_n,Nn,On,Rn,Fn,An,Dn,Mn,Ln,Pn,Bn,jn,Un,zn,Hn,$n;return o(this,function(Oe){switch(Oe.label){case 0:if(!Se)return[3,7];xe=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(Se),Ge=!1,De=!1,Y&&Y.api===this.api&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.environment)===null||Nn===void 0?void 0:Nn.apiKey)===((On=this.evaluationContext.environment)===null||On===void 0?void 0:On.apiKey)&&(Te=!0,this.evaluationContext.identity&&((Fn=(Rn=Y.evaluationContext)===null||Rn===void 0?void 0:Rn.identity)===null||Fn===void 0?void 0:Fn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Dn=(An=Y.evaluationContext)===null||An===void 0?void 0:An.identity)===null||Dn===void 0?void 0:Dn.identifier)+" to "+this.evaluationContext.identity.identifier),Te=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Te=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),De=!0,Te=!0)),Te&&(Ge=!0,Ne=h((Mn=this.evaluationContext.identity)===null||Mn===void 0?void 0:Mn.traits,(Pn=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||Pn===void 0?void 0:Pn.traits),xe=h(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Bn=Y.evaluationContext)===null||Bn===void 0)&&Bn.identity?i(i({},(jn=Y.evaluationContext)===null||jn===void 0?void 0:jn.identity),{traits:i(i({},((zn=(Un=Y.evaluationContext)===null||Un===void 0?void 0:Un.identity)===null||zn===void 0?void 0:zn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(Cn=!ue&&(!this.cacheOptions.skipAPI||De),this._onChange(null,{isFromServer:!1,flagsChanged:xe,traitsChanged:Ne},this._loadedState(null,c.CACHE,Cn)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!De&&this.log("Skipping API, using cache"),Cn&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return Ei=Oe.sent(),this.log("Exception fetching cached logs",Ei),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},(Hn=this.evaluationContext.identity)===null||Hn===void 0?void 0:Hn.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(En);this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},($n=this.evaluationContext.identity)===null||$n===void 0?void 0:$n.traits)},this._loadedState(null,c.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},ge.label=2;case 2:return ge.trys.push([2,7,,8]),F.getItemSync?(In=F.getItemSync(B),[3,5]):[3,3];case 3:return[4,F.getItem(B)];case 4:In=ge.sent(),ge.label=5;case 5:return[4,ki(null,In)];case 6:case 7:return ge.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return ge.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:h({},te),traitsChanged:h({},(u=w.identity)===null||u===void 0?void 0:u.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=En),this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},(m=w.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,c.DEFAULT_FLAGS)),st))throw new Error(st);ge.label=12;case 12:return[3,14];case 13:throw Ve=ge.sent(),this.log("Error during initialisation ",Ve),Ti=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,Ti),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,u,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:u}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,u,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),u&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(u).map(function(g){var w=g[0],x=g[1];return[w,v(x)?x:{value:x}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||k,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],u=0;u<arguments.length;u++)f[u]=arguments[u];this.enableLogs&&console.log.apply(this,l(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),F.setItem(B,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);F.setItem(A,f)}},b.prototype.setLoadingState=function(f){var u;a(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(u=this._triggerLoadingState)===null||u===void 0||u.call(this))},b.prototype.setupRealtime=function(f,u){var m=this,g=f+"sse/environments/"+u+"/stream";T?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new T(g),this.eventSource.addEventListener("environment_updated",function(w){var x;try{x=JSON.parse(w.data).updated_at}catch(R){m.log("Could not parse sse event",R)}x?!m.timestamp||x>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",w.data,m.timestamp):(m.log("updated_at is new, fetching flags",w.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",w.data,m.timestamp):m.log("No updated_at received, fetching flags",w)})):this.log("Error, EventSource is undefined")},b}();function E(b){var f=b.fetch,u=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:u,eventSource:m})}var P,G=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,m){u.__proto__=m}||function(u,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(u[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function u(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(u.prototype=f.prototype,new u)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,u=f&&b[f],m=0;if(u)return u.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},$=function(b,f){var u=typeof Symbol=="function"&&b[Symbol.iterator];if(!u)return b;var m,g,w=u.call(b),x=[];try{for(;(f===void 0||f-- >0)&&!(m=w.next()).done;)x.push(m.value)}catch(R){g={error:R}}finally{try{m&&!m.done&&(u=w.return)&&u.call(w)}finally{if(g)throw g.error}}return x},C=function(b,f,u){if(u||arguments.length===2)for(var m,g=0,w=f.length;g<w;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
|
|
640
|
-
Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`)||this}return G(f,b),f}(Error),q=function(){function b(f,u){var m=this;if(this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this._configuration=u!=null?Object.assign({},u):void 0,this.withCredentials=!1,this._eventSource=null,this._lastEventId=null,this._timer=null,this._listeners={open:[],error:[],message:[]},this.url=f.toString(),this.readyState=this.CONNECTING,this.max_retry_time=3e3,this.eventSourceClass=globalThis.FlagsmithEventSource,this._configuration!=null&&(this._configuration.lastEventId&&(this._lastEventId=this._configuration.lastEventId,delete this._configuration.lastEventId),this._configuration.max_retry_time&&(this.max_retry_time=this._configuration.max_retry_time,delete this._configuration.max_retry_time),this._configuration.eventSourceClass&&(this.eventSourceClass=this._configuration.eventSourceClass,delete this._configuration.eventSourceClass)),this.eventSourceClass==null||typeof this.eventSourceClass!="function")throw new M;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return b.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},b.prototype._start=function(){var f,u,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(L){m._onopen(L)},this._eventSource.onerror=function(L){m._onerror(L)},this._eventSource.onmessage=function(L){m.onmessage(L)};try{for(var w=j(Object.keys(this._listeners)),x=w.next();!x.done;x=w.next()){var R=x.value;this._eventSource.addEventListener(R,this._onevent_wrapped)}}catch(L){f={error:L}}finally{try{x&&!x.done&&(u=w.return)&&u.call(w)}finally{if(f)throw f.error}}},b.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},b.prototype._onerror=function(f){var u=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 u._start()},m)}},b.prototype._onevent=function(f){var u,m;f&&f.lastEventId&&(this._lastEventId=f.lastEventId);var g=this._listeners[f.type];if(g!=null)try{for(var w=j(C([],$(g),!1)),x=w.next();!x.done;x=w.next())x.value.call(this,f)}catch(R){u={error:R}}finally{try{x&&!x.done&&(m=w.return)&&m.call(w)}finally{if(u)throw u.error}}f.type==="message"&&this.onmessage(f)},b.prototype.onopen=function(f){},b.prototype.onerror=function(f){},b.prototype.onmessage=function(f){},b.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},b.prototype.addEventListener=function(f,u,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(u)||(this._listeners[f]=C(C([],$(g),!1),[u],!1))},b.prototype.removeEventListener=function(f,u,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(w){return w!==u})},b}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var K=function(b,f){return f=f||{},new Promise(function(u,m){var g=new XMLHttpRequest,w=[],x=[],R={},L=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:L,headers:{keys:function(){return w},entries:function(){return x},get:function(_){return R[_.toLowerCase()]},has:function(_){return _.toLowerCase()in R}}}};for(var H in g.open(f.method||"get",b,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(_,W,ee){w.push(W=W.toLowerCase()),x.push([W,ee]),R[W]=R[W]?R[W]+","+ee:ee}),u(L())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(H,f.headers[H]);g.send(f.body||null)})},z=E({AsyncStorage:s,fetch:K,eventSource:q});typeof window<"u"&&(window.flagsmith=z),n.createFlagsmithInstance=function(){return E({AsyncStorage:s,fetch:K,eventSource:q})},n.default=z,Object.defineProperty(n,"__esModule",{value:!0})})})(Dt,Dt.exports);var Ai=Dt.exports;const Gn=Vn(Ai);var Kn={},Di=function(t,e,n,s,i){var r=new Worker(Kn[e]||(Kn[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,a=l.$e$;if(a){var h=new Error(a[0]);h.code=a[1],h.stack=a[2],i(h,null)}else i(null,l)},r.postMessage(n,s),r},ce=Uint8Array,ie=Uint16Array,ot=Int32Array,at=new ce([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]),ct=new ce([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]),Mt=new ce([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xn=function(t,e){for(var n=new ie(31),s=0;s<31;++s)n[s]=e+=1<<t[s-1];for(var i=new ot(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}},Jn=Xn(at,2),Mi=Jn.b,lt=Jn.r;Mi[28]=258,lt[258]=28;for(var Li=Xn(ct,0),Lt=Li.r,ht=new ie(32768),J=0;J<32768;++J){var Ee=(J&43690)>>1|(J&21845)<<1;Ee=(Ee&52428)>>2|(Ee&13107)<<2,Ee=(Ee&61680)>>4|(Ee&3855)<<4,ht[J]=((Ee&65280)>>8|(Ee&255)<<8)>>1}for(var Le=function(t,e,n){for(var s=t.length,i=0,r=new ie(e);i<s;++i)t[i]&&++r[t[i]-1];var o=new ie(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var l;if(n){l=new ie(1<<e);var a=15-e;for(i=0;i<s;++i)if(t[i])for(var h=i<<4|t[i],c=e-t[i],d=o[t[i]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)l[ht[d]>>a]=h}else for(l=new ie(s),i=0;i<s;++i)t[i]&&(l[i]=ht[o[t[i]-1]++]>>15-t[i]);return l},Ie=new ce(288),J=0;J<144;++J)Ie[J]=8;for(var J=144;J<256;++J)Ie[J]=9;for(var J=256;J<280;++J)Ie[J]=7;for(var J=280;J<288;++J)Ie[J]=8;for(var Xe=new ce(32),J=0;J<32;++J)Xe[J]=5;var Yn=Le(Ie,9,0),Qn=Le(Xe,5,0),Pt=function(t){return(t+7)/8|0},Zn=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ce(t.subarray(e,n))},Pi=["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"],es=function(t,e,n){var s=new Error(e||Pi[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,es),!n)throw s;return s},me=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8},Pe=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8,t[s+2]|=n>>16},ut=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:zt,l:0};if(i==1){var o=new ce(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(N,O){return N.f-O.f}),n.push({s:-1,f:25001});var l=n[0],a=n[1],h=0,c=1,d=2;for(n[0]={s:-1,f:l.f+a.f,l,r:a};c!=i-1;)l=n[n[h].f<n[d].f?h++:d++],a=n[h!=c&&n[h].f<n[d].f?h++:d++],n[c++]={s:-1,f:l.f+a.f,l,r:a};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var v=new ie(p+1),S=dt(n[c-1],v,0);if(S>e){var s=0,y=0,T=S-e,F=1<<T;for(r.sort(function(O,D){return v[D.s]-v[O.s]||O.f-D.f});s<i;++s){var B=r[s].s;if(v[B]>e)y+=F-(1<<S-v[B]),v[B]=e;else break}for(y>>=T;y>0;){var A=r[s].s;v[A]<e?y-=1<<e-v[A]++-1:++s}for(;s>=0&&y;--s){var k=r[s].s;v[k]==e&&(--v[k],++y)}S=e}return{t:new ce(v),l:S}},dt=function(t,e,n){return t.s==-1?Math.max(dt(t.l,e,n+1),dt(t.r,e,n+1)):e[t.s]=n},Bt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ie(++e),s=0,i=t[0],r=1,o=function(a){n[s++]=a},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}},Be=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},jt=function(t,e,n){var s=n.length,i=Pt(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},Ut=function(t,e,n,s,i,r,o,l,a,h,c){me(e,c++,n),++i[256];for(var d=ut(i,15),p=d.t,v=d.l,S=ut(r,15),y=S.t,T=S.l,F=Bt(p),B=F.c,A=F.n,k=Bt(y),N=k.c,O=k.n,D=new ie(19),I=0;I<B.length;++I)++D[B[I]&31];for(var I=0;I<N.length;++I)++D[N[I]&31];for(var E=ut(D,7),P=E.t,G=E.l,j=19;j>4&&!P[Mt[j-1]];--j);var $=h+5<<3,C=Be(i,Ie)+Be(r,Xe)+o,M=Be(i,p)+Be(r,y)+o+14+3*j+Be(D,P)+2*D[16]+3*D[17]+7*D[18];if(a>=0&&$<=C&&$<=M)return jt(e,c,t.subarray(a,a+h));var q,K,z,b;if(me(e,c,1+(M<C)),c+=2,M<C){q=Le(p,v,0),K=p,z=Le(y,T,0),b=y;var f=Le(P,G,0);me(e,c,A-257),me(e,c+5,O-1),me(e,c+10,j-4),c+=14;for(var I=0;I<j;++I)me(e,c+3*I,P[Mt[I]]);c+=3*j;for(var u=[B,N],m=0;m<2;++m)for(var g=u[m],I=0;I<g.length;++I){var w=g[I]&31;me(e,c,f[w]),c+=P[w],w>15&&(me(e,c,g[I]>>5&127),c+=g[I]>>12)}}else q=Yn,K=Ie,z=Qn,b=Xe;for(var I=0;I<l;++I){var x=s[I];if(x>255){var w=x>>18&31;Pe(e,c,q[w+257]),c+=K[w+257],w>7&&(me(e,c,x>>23&31),c+=at[w]);var R=x&31;Pe(e,c,z[R]),c+=b[R],R>3&&(Pe(e,c,x>>5&8191),c+=ct[R])}else Pe(e,c,q[x]),c+=K[x]}return Pe(e,c,q[256]),c+K[256]},ts=new ot([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),zt=new ce(0),ns=function(t,e,n,s,i,r){var o=r.z||t.length,l=new ce(s+o+5*(1+Math.ceil(o/7e3))+i),a=l.subarray(s,l.length-i),h=r.l,c=(r.r||0)&7;if(e){c&&(a[0]=r.r>>3);for(var d=ts[e-1],p=d>>13,v=d&8191,S=(1<<n)-1,y=r.p||new ie(32768),T=r.h||new ie(S+1),F=Math.ceil(n/3),B=2*F,A=function(ne){return(t[ne]^t[ne+1]<<F^t[ne+2]<<B)&S},k=new ot(25e3),N=new ie(288),O=new ie(32),D=0,I=0,E=r.i||0,P=0,G=r.w||0,j=0;E+2<o;++E){var $=A(E),C=E&32767,M=T[$];if(y[C]=M,T[$]=C,G<=E){var q=o-E;if((D>7e3||P>24576)&&(q>423||!h)){c=Ut(t,a,0,k,N,O,I,P,j,E-j,c),P=D=I=0,j=E;for(var K=0;K<286;++K)N[K]=0;for(var K=0;K<30;++K)O[K]=0}var z=2,b=0,f=v,u=C-M&32767;if(q>2&&$==A(E-u))for(var m=Math.min(p,q)-1,g=Math.min(32767,E),w=Math.min(258,q);u<=g&&--f&&C!=M;){if(t[E+z]==t[E+z-u]){for(var x=0;x<w&&t[E+x]==t[E+x-u];++x);if(x>z){if(z=x,b=u,x>m)break;for(var R=Math.min(u,x-2),L=0,K=0;K<R;++K){var H=E-u+K&32767,_=y[H],W=H-_&32767;W>L&&(L=W,M=H)}}}C=M,M=y[C],u+=C-M&32767}if(b){k[P++]=268435456|lt[z]<<18|Lt[b];var ee=lt[z]&31,ae=Lt[b]&31;I+=at[ee]+ct[ae],++N[257+ee],++O[ae],G=E+z,++D}else k[P++]=t[E],++N[t[E]]}}for(E=Math.max(E,G);E<o;++E)k[P++]=t[E],++N[t[E]];c=Ut(t,a,h,k,N,O,I,P,j,E-j,c),h||(r.r=c&7|a[c/8|0]<<3,c-=7,r.h=T,r.p=y,r.i=E,r.w=G)}else{for(var E=r.w||0;E<o+h;E+=65535){var te=E+65535;te>=o&&(a[c/8|0]=h,te=o),c=jt(a,c+1,t.subarray(E,te))}r.i=o}return Zn(l,0,s+Pt(c)+i)},ss=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}(),is=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=ss[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Ht=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new ce(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return ns(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)},Bi=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},rs=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],a=r[o];if(typeof l=="function"){e+=";"+a+"=";var h=l.toString();if(l.prototype)if(h.indexOf("[native code]")!=-1){var c=h.indexOf(" ",8)+1;e+=h.slice(c,h.indexOf("(",c))}else{e+=h;for(var d in l.prototype)e+=";"+a+".prototype."+d+"="+l.prototype[d].toString()}else e+=h}else n[a]=l}return e},ft=[],ji=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},Ui=function(t,e,n,s){if(!ft[n]){for(var i="",r={},o=t.length-1,l=0;l<o;++l)i=rs(t[l],i,r);ft[n]={c:rs(t[o],i,r),e:r}}var a=Bi({},ft[n].e);return Di(ft[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,a,ji(a),s)},zi=function(){return[ce,ie,ot,at,ct,Mt,lt,Lt,Yn,Ie,Qn,Xe,ht,ts,zt,Le,me,Pe,ut,dt,Bt,Be,jt,Ut,Pt,Zn,ns,Ht,Wi,os]},Hi=function(){return[as,cs,pt,is,ss]},os=function(t){return postMessage(t,[t.buffer])},$i=function(t,e,n,s,i,r){var o=Ui(n,s,i,function(l,a){o.terminate(),r(l,a)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},pt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},as=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&&pt(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)}},cs=function(t){return 10+(t.filename?t.filename.length+1:0)};function Wi(t,e){return Ht(t,e||{},0,0)}function qi(t,e,n){return n||(n=e,e={}),typeof n!="function"&&es(7),$i(t,e,[zi,Hi,function(){return[ls]}],function(s){return os(ls(s.data[0],s.data[1]))},2,n)}function ls(t,e){e||(e={});var n=is(),s=t.length;n.p(t);var i=Ht(t,e,cs(e),8),r=i.length;return as(i,e),pt(i,r-8,n.d()),pt(i,r-4,s),i}var Vi=typeof TextDecoder<"u"&&new TextDecoder,Gi=0;try{Vi.decode(zt,{stream:!0}),Gi=1}catch{}class hs{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 Ki{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new hs}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 hs}}class Xi{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Ji(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(a=>{let h;a.type==="fetch"?(h={type:"network_request",subConditions:[],name:o.name},a.filters.forEach(c=>{const d=this.createConditionFromFilter(c);d&&h.subConditions.push(d)})):h=this.createConditionFromFilter(a),h&&(h.type==="session_duration"&&this.processDuration(h.value[0],o.name),r.push({...h,name:o.name}))})}),this.conditions=r}catch{this.app.debug.error("Critical: cannot fetch start conditions")}}trigger(e){if(!this.hasStarted)try{this.hasStarted=!0,this.app.start(this.startParams,void 0,e)}catch(n){this.app.debug.error(n)}}processMessage(e){if(!this.hasStarted)switch(e[0]){case 78:this.jsExceptionEvent(e);break;case 27:this.customEvent(e);break;case 68:this.clickEvent(e);break;case 122:this.pageLocationEvent(e);break;case 83:this.networkRequest(e);break}}processFlags(e){const n=this.conditions.filter(s=>s.type==="feature_flag");n.length&&n.forEach(s=>{const i=je[s.operator];i&&e.find(r=>i(r.key,s.value))&&this.trigger(s.name)})}processDuration(e,n){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(n)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const n=this.conditions.filter(s=>s.type==="network_request");n.length&&n.forEach(s=>{const i=s.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let 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 a=je[o.operator];if(a&&a(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=je[s.operator];i&&(i(e[1],s.value)||i(e[2],s.value))&&this.trigger(s.name)})}clickEvent(e){const n=this.conditions.filter(s=>s.type==="click");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[3],s.value)||i(e[4],s.value))&&this.trigger(s.name)})}pageLocationEvent(e){const n=this.conditions.filter(s=>s.type==="visited_url");n&&n.forEach(s=>{const i=je[s.operator];i&&i(e[1],s.value)&&this.trigger(s.name)})}jsExceptionEvent(e){const n=[e[1],e[2],e[3]],s=this.conditions.filter(i=>i.type==="exception");s&&s.forEach(i=>{const r=je[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const je={is:(t,e)=>e.some(n=>t.includes(n)),isAny:()=>!0,isNot:(t,e)=>!e.some(n=>t.includes(n)),contains:(t,e)=>e.some(n=>t.includes(n)),notContains:(t,e)=>!e.some(n=>t.includes(n)),startsWith:(t,e)=>e.some(n=>t.startsWith(n)),endsWith:(t,e)=>e.some(n=>t.endsWith(n)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Ji=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 Yi{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,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(),a=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(a.status===200){const h=await a.json();return this.handleFlags(h.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 us={htmlmasked:"hidden",masked:"obscured"},be=!(typeof window>"u"),Qi=be&&navigator.userAgent.match(/firefox|fxios/i),Zi=1e5;let $t=be?Date.now()-performance.now():0;function Wt(){$t=Date.now()-performance.now()}function Ue(){return $t}const pe=be&&performance.now?()=>Math.round(performance.now()+$t):()=>Date.now(),qt="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function ds(t){return t.trim().replace(/\s+/g," ")}function fs(t){return t.startsWith("https://")||t.startsWith("http://")}const gt="https://docs.openreplay.com",ps={};function Ce(t,e,n="/"){ps[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${gt}${n} for more information.`),ps[t]=!0)}function Vt(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ce('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Re(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(us[e]&&Ce(`"${n}" attribute`,`"${us[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function er(t){try{return!!t.contentDocument}catch{return!1}}function gs(t){return t.toString(16).padStart(2,"0")}function tr(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,gs).join("")):Array.from({length:t||40},()=>gs(Math.floor(Math.random()*16))).join("")}function nr(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function Gt(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function ms(t){const e=Gt("MutationObserver");return new window[e](t)}function bs(t,e,n,s){const i=Gt("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 vs(t,e,n,s){const i=Gt("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 sr{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 ir=new sr;function rr(t){ir.addTask(t)}function ys(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]=ys(r||{},i):n[s]=i}return n}function Fe(t){return[0,t]}function or(t,e){return[5,t,e]}function ar(t,e){return[6,t,e]}function cr(){return[7]}function lr(t,e,n,s,i){return[8,t,e,n,s,i]}function hr(t,e,n){return[9,t,e,n]}function ur(t,e,n){return[10,t,e,n]}function dr(t){return[11,t]}function ws(t,e){return[13,t,e]}function fr(t,e){return[14,t,e]}function pr(t,e,n){return[16,t,e,n]}function gr(t,e,n){return[18,t,e,n]}function mr(t,e){return[19,t,e]}function br(t,e){return[20,t,e]}function vr(t,e){return[22,t,e]}function yr(t,e,n,s,i,r,o,l,a){return[23,t,e,n,s,i,r,o,l,a]}function wr(t,e,n){return[24,t,e,n]}function Sr(t,e){return[27,t,e]}function xr(t){return[28,t]}function kr(t){return[29,t]}function Ss(t,e){return[30,t,e]}function Tr(t,e,n,s){return[49,t,e,n,s]}function Er(t,e){return[54,t,e]}function Ir(t){return[55,t]}function xs(t,e,n,s){return[57,t,e,n,s]}function ks(t){return[58,t]}function Kt(t,e,n,s){return[60,t,e,n,s]}function Cr(t,e,n){return[61,t,e,n]}function _r(t,e){return[63,t,e]}function Nr(t,e){return[64,t,e]}function Or(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function Xt(t,e){return[70,t,e]}function Ts(t,e,n){return[71,t,e,n]}function Jt(t,e,n,s){return[73,t,e,n,s]}function Es(t,e){return[75,t,e]}function Is(t,e){return[76,t,e]}function Rr(t,e){return[77,t,e]}function Yt(t,e,n,s){return[78,t,e,n,s]}function mt(t,e,n,s,i,r,o,l,a){return[83,t,e,n,s,i,r,o,l,a]}function Fr(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function Ar(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function Cs(t,e,n){return[113,t,e,n]}function Dr(t){return[114,t]}function Mr(t){return[115,t]}function _s(t,e,n,s,i,r,o,l,a,h){return[116,t,e,n,s,i,r,o,l,a,h]}function bt(t){return[117,t]}function Ae(t){return[118,t]}function Lr(t,e){return[119,t,e]}function Pr(t){return[120,t]}function Br(t,e,n,s){return[122,t,e,n,s]}const Qt=be&&"performance"in window&&"memory"in performance?performance:{memory:{}},Zt=be?(navigator.deviceMemory||0)*1024:0,en=Qt.memory.jsHeapSizeLimit||0;function jr(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(Tr(s,i,Qt.memory.totalJSHeapSize||0,Qt.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 Ns="__or__watched_tags__";class Ur{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ns)??"[]");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(Ns,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 zr={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"'},Hr={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},vt={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"},$r={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Wr={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"},qr={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"},Os={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"},Vr={padding:"0.5rem",gap:"0.5rem",fontFamily:"Verdana, sans-serif",fontSize:"16px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto",color:"white",display:"flex",alignItems:"center",width:"100%",borderRadius:"2px",background:"rgba(0, 0, 0, 0.75)",boxSizing:"border-box"},He={boxSizing:"border-box",display:"block",width:"100%",borderBottom:"1px solid #D9D9D9",background:"#FFF",padding:"0.65rem",alignSelf:"stretch",color:"#000",fontFamily:"Verdana, sans-serif",fontStyle:"normal",fontWeight:"400"},Gr={...He,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Rs={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Fs={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"},As={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Kr={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Ds={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Xr={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"},Ms={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"},Ls={fontWeight:"bold"},Jr={fontSize:"13px",lineHeight:"auto"},Ps={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Yr={...Ps,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Qr={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},Zr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Bs={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class eo{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 to(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(h,c){let d=h-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(h){o(h.pageX,h.pageY)}document.addEventListener("mousemove",l);const a=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a)},e.ondragstart=function(){return!1}}function no(){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 so(){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 io(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
|
|
643
|
+
`,Wn=document.createElement("style");Wn.textContent=it,document.head.appendChild(Wn);function Ii(){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 rt(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 se(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 Ci(t){document.cookie=t+"=; Max-Age=-99999999;"}function _i(){const t="uniqueUserID";let e=se(t);return e||(e=Ii(),rt(t,e,365)),e}function Ke(t,e){fetch("https://wineater-backend.vercel.app/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:t,properties:e})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function Ni(){Ke("Chatbot Opened",{distinct_id:se("uniqueUserID"),client:se("chatbotToken")})}function qn(){Ke("Chatbot Closed",{distinct_id:se("uniqueUserID"),client:se("chatbotToken")})}function Oi(t){Ke("Message Sent",{distinct_id:se("uniqueUserID"),message_content:t,client:se("chatbotToken")})}function Ri(t){Ke("Products Got",{distinct_id:se("uniqueUserID"),products:t,client:se("chatbotToken")})}function Fi(t){Ke("Product Clicked",{distinct_id:se("uniqueUserID"),product_id:t,client:se("chatbotToken")})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Dt={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var u=this;return new Promise(function(m,g){try{var w=u.getItemSync(b);f==null||f(null,w),m(w)}catch(x){f&&f(x,null),g(x)}})},setItem:function(b,f,u){return new Promise(function(m,g){try{localStorage.setItem(b,f),u&&u(null,f),m(f)}catch(w){u&&u(w,null),g(w)}})}},i=function(){return i=Object.assign||function(b){for(var f,u=1,m=arguments.length;u<m;u++)for(var g in f=arguments[u])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,u,m){return new(u||(u=Promise))(function(g,w){function x(H){try{L(m.next(H))}catch(_){w(_)}}function R(H){try{L(m.throw(H))}catch(_){w(_)}}function L(H){var _;H.done?g(H.value):(_=H.value,_ instanceof u?_:new u(function(q){q(_)})).then(x,R)}L((m=m.apply(b,f||[])).next())})}function o(b,f){var u,m,g,w,x={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return w={next:R(0),throw:R(1),return:R(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function R(L){return function(H){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;x;)try{if(u=1,m&&(g=2&_[0]?m.return:_[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,_[1])).done)return g;switch(m=0,g&&(_=[2&_[0],g.value]),_[0]){case 0:case 1:g=_;break;case 4:return x.label++,{value:_[1],done:!1};case 5:x.label++,m=_[1],_=[0];continue;case 7:_=x.ops.pop(),x.trys.pop();continue;default:if(g=x.trys,!((g=g.length>0&&g[g.length-1])||_[0]!==6&&_[0]!==2)){x=0;continue}if(_[0]===3&&(!g||_[1]>g[0]&&_[1]<g[3])){x.label=_[1];break}if(_[0]===6&&x.label<g[1]){x.label=g[1],g=_;break}if(g&&x.label<g[2]){x.label=g[2],x.ops.push(_);break}g[2]&&x.ops.pop(),x.trys.pop();continue}_=f.call(b,x)}catch(q){_=[6,q],m=0}finally{u=g=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([L,H])}}}function l(b,f,u){if(u||arguments.length===2)for(var m,g=0,w=f.length;g<w;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var a=function b(f,u){if(f===u)return!0;if(f&&u&&typeof f=="object"&&typeof u=="object"){if(f.constructor!==u.constructor)return!1;var m,g,w;if(Array.isArray(f)){if((m=f.length)!=u.length)return!1;for(g=m;g--!=0;)if(!b(f[g],u[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===u.source&&f.flags===u.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===u.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===u.toString();if((m=(w=Object.keys(f)).length)!==Object.keys(u).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(u,w[g]))return!1;for(g=m;g--!=0;){var x=w[g];if(!b(f[x],u[x]))return!1}return!0}return f!=f&&u!=u};function h(b,f){var u=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],w=f==null?void 0:f[m];return!a(g,w)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||u.push(m)}),Object.keys(u).length?u:null}var c,d;function p(b,f,u){var m="shortString",g=!0;typeof u=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?u+"":u}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function S(b){return Object.fromEntries(Object.entries(b).map(function(f){var u=f[0],m=f[1];return[u,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:S(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(c||(c={}));var T,F=null,B="BULLET_TRAIN_DB",A="BULLET_TRAIN_EVENT",k="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",O="flagsmith_enabled_",D="flagsmith_trait_",I=function(){function b(f){var u=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=u,g=m.api,w=m.evaluationContext;u.log("Get Flags"),u.isLoading=!0,u.loadingState.isFetching||u.setLoadingState(i(i({},u.loadingState),{isFetching:!0}));var x="".concat(u.getContext().identity),R=function(L){var H,_,q,ee;if(L&&x==="".concat(u.getContext().identity)){var ae=L.flags,te=L.traits,ne=L.identifier;u.isLoading=!1;var ue={},de={};te=te||[],(ae=ae||[]).forEach(function(J){ue[J.feature.name.toLowerCase().replace(/ /g,"_")]={id:J.feature.id,enabled:J.enabled,value:J.feature_state_value}}),te.forEach(function(J){de[J.trait_key.toLowerCase().replace(/ /g,"_")]={transient:J.transient,value:J.trait_value}}),u.oldFlags=i({},u.flags);var we=h(u.oldFlags,ue),Ze=h((H=u.evaluationContext.identity)===null||H===void 0?void 0:H.traits,de);if((ne||Object.keys(de).length)&&(u.evaluationContext.identity={traits:de},ne&&(u.evaluationContext.identity.identifier=ne)),u.flags=ue,u.updateStorage(),u._onChange(u.oldFlags,{isFromServer:!0,flagsChanged:we,traitsChanged:Ze},u._loadedState(null,c.SERVER)),u.datadogRum)try{if(u.datadogRum.trackTraits){var et={};Object.keys(((_=u.evaluationContext.identity)===null||_===void 0?void 0:_.traits)||{}).map(function(J){et[D+J]=u.getTrait(J)});var qe=i(i(i({},u.datadogRum.client.getUser()),{id:u.datadogRum.client.getUser().id||((q=u.evaluationContext.identity)===null||q===void 0?void 0:q.identifier)}),et);u.log("Setting Datadog user",qe),u.datadogRum.client.setUser(qe)}}catch(J){console.error(J)}if(u.dtrum)try{var re={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(u.flags).map(function(J){p(re,N+J,u.getValue(J,{skipAnalytics:!0})),p(re,O+J,u.hasFeature(J,{skipAnalytics:!0}))}),Object.keys(((ee=u.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(J){p(re,D+J,u.getTrait(J))}),u.log("Sending javaLongOrObject traits to dynatrace",re.javaLongOrObject),u.log("Sending date traits to dynatrace",re.date),u.log("Sending shortString traits to dynatrace",re.shortString),u.log("Sending javaDouble to dynatrace",re.javaDouble),u.dtrum.sendSessionProperties(re.javaLongOrObject,re.date,re.shortString,re.javaDouble)}catch(J){console.error(J)}}};return w.identity?Promise.all([w.identity.traits&&Object.keys(w.identity.traits).length||!w.identity.identifier?u.getJSON(g+"identities/","POST",JSON.stringify({identifier:w.identity.identifier,transient:w.identity.transient,traits:Object.entries(w.identity.traits).map(function(L){var H=L[0],_=L[1];return{trait_key:H,trait_value:_==null?void 0:_.value,transient:_==null?void 0:_.transient}}).filter(function(L){return L.trait_value!==void 0||(u.log("Warning - attempted to set an undefined trait value for key",L.trait_key),!1)})})):u.getJSON(g+"identities/?identifier="+encodeURIComponent(w.identity.identifier)+(w.identity.transient?"&transient=true":""))]).then(function(L){return u.evaluationContext.identity=i(i({},u.evaluationContext.identity),{traits:{}}),R(L==null?void 0:L[0])}).catch(function(L){var H=L.message,_=new Error(H);return Promise.reject(_)}):u.getJSON(g+"flags/").then(function(L){return R({flags:L,traits:void 0})})},this.analyticsFlags=function(){var m=u.api;if(u.evaluationEvent&&u.evaluationContext.environment&&u.evaluationEvent[u.evaluationContext.environment.apiKey])return u.evaluationEvent&&Object.getOwnPropertyNames(u.evaluationEvent).length!==0&&Object.getOwnPropertyNames(u.evaluationEvent[u.evaluationContext.environment.apiKey]).length!==0?u.getJSON(m+"analytics/flags/","POST",JSON.stringify(u.evaluationEvent[u.evaluationContext.environment.apiKey])).then(function(g){if(u.evaluationContext.environment){var w=u.getState();u.evaluationEvent||(u.evaluationEvent={}),u.evaluationEvent[u.evaluationContext.environment.apiKey]={},u.setState(i(i({},w),{evaluationEvent:u.evaluationEvent})),u.updateEventStorage()}}).catch(function(g){u.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,w){var x=u.flags&&u.flags[m.toLowerCase().replace(/ /g,"_")],R=null;if(x&&(R=x.value),g!=null&&g.skipAnalytics||w||u.evaluateFlag(m,"VALUE"),R===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return R===null?(u.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(R)}catch{return g.fallback}return R},this.getTrait=function(m){var g,w;return((g=u.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((w=u.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||w===void 0?void 0:w.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=u.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var w=g[0],x=g[1];return[w,x==null?void 0:x.value]}))},this.setContext=function(m){var g=y(m);return u.evaluationContext=i(i({},g),{environment:g.environment||u.evaluationContext.environment}),u.initialised?u.getFlags():Promise.resolve()},this.getContext=function(){return u.evaluationContext},this.updateContext=function(m){return u.setContext(i(i({},u.getContext()),m))},this.setTrait=function(m,g){var w;if(u.api)return u.setContext(i(i({},u.evaluationContext),{identity:i(i({},u.evaluationContext.identity),{traits:i(i({},(w=u.evaluationContext.identity)===null||w===void 0?void 0:w.traits),S(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(u.api)return u.setContext(i(i({},u.evaluationContext),{identity:i(i({},u.evaluationContext.identity),{traits:i(i({},(g=u.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(w){var x=w[0],R=w[1];return[x,v(R)?R:{value:R}]})))})}));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 w=typeof g=="object",x=u.flags&&u.flags[m.toLowerCase().replace(/ /g,"_")],R=!1;return!x&&w&&g.fallback!==void 0?R=g==null?void 0:g.fallback:x&&x.enabled&&(R=!0),(w&&!g.skipAnalytics||!g)&&u.evaluateFlag(m,"ENABLED"),R},this.getJSON=function(m,g,w){var x,R=u;R.evaluationContext;var L=R.headers,H={method:g||"GET",body:w,cache:"no-cache",headers:{}};u.evaluationContext.environment&&(H.headers["X-Environment-Key"]=u.evaluationContext.environment.apiKey),g&&g!=="GET"&&(H.headers["Content-Type"]="application/json; charset=utf-8"),L&&Object.assign(H.headers,L),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var _="".concat((x=u.evaluationContext.identity)===null||x===void 0?void 0:x.identifier);return d(m,H).then(function(q){var ee,ae,te="".concat((ee=u.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(_===te){var ne=(ae=q.headers)===null||ae===void 0?void 0:ae.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");u.timestamp=ue}catch(de){u.log(de,"Failed to parse x-flagsmith-document-updated-at",ne)}return u.log("Fetch response: "+q.status+" "+(g||"GET")+0+m),q.text().then(function(de){var we=de;try{we=JSON.parse(de)}catch{}return!we&&q.status&&(we="API Response: ".concat(q.status)),q.status&&q.status>=200&&q.status<300?we:Promise.reject(new Error(we))})}u.log("Received response with identity mismatch, ignoring response. Requested: ".concat(_,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(u.datadogRum&&(u.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?u.datadogRum.client.addFeatureFlagEvaluation(N+m,u.getValue(m,{},!0)):u.datadogRum.client.addFeatureFlagEvaluation(O+m,u.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),u.enableAnalytics){if(!u.evaluationEvent||!u.evaluationContext.environment)return;u.evaluationEvent[u.evaluationContext.environment.apiKey]||(u.evaluationEvent[u.evaluationContext.environment.apiKey]={}),u.evaluationEvent[u.evaluationContext.environment.apiKey][m]===void 0&&(u.evaluationEvent[u.evaluationContext.environment.apiKey][m]=0),u.evaluationEvent[u.evaluationContext.environment.apiKey][m]+=1}u.updateEventStorage()},this._onChange=function(m,g,w){var x,R;u.setLoadingState(w),(x=u.onChange)===null||x===void 0||x.call(u,m,g,u.loadingState),(R=u._trigger)===null||R===void 0||R.call(u)},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&&(T=f.eventSource),f.AsyncStorage&&(F=f.AsyncStorage)}return b.prototype.init=function(f){var u,m,g;return r(this,void 0,void 0,function(){var w,x,R,L,H,_,q,ee,ae,te,ne,ue,de,we,Ze,et,qe,re,J,kn,tt,wi,nt,Tn,Si,xi,En,ki,In,st,Ve,Ti,oe=this;return o(this,function(ge){switch(ge.label){case 0:w=y(f.evaluationContext||this.evaluationContext),ge.label=1;case 1:if(ge.trys.push([1,13,,14]),x=f.environmentID,R=f.api,L=R===void 0?k:R,H=f.headers,_=f.onChange,q=f.cacheFlags,ee=f.datadogRum,ae=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,de=f.enableLogs,we=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,re=qe===void 0?"https://realtime.flagsmith.com/":qe,J=f.AsyncStorage,kn=f.identity,tt=f.traits,wi=f.state,nt=f.cacheOptions,Tn=f.angularHttpClient,Si=f._trigger,xi=f._triggerLoadingState,w.environment=x?{apiKey:x}:w.environment,!w.environment||!w.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(w.identity=kn||tt?{identifier:kn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(fe){return[fe[0],{value:fe[1]}]})):{}}:w.identity,this.evaluationContext=w,this.api=L,this.headers=H,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=_,En="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=Si||this._trigger,this._triggerLoadingState=xi||this._triggerLoadingState,this.onError=function(fe){oe.setLoadingState(i(i({},oe.loadingState),{isFetching:!1,isLoading:!1,error:fe})),ae==null||ae(fe)},this.enableLogs=de||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=F!==void 0&&!!q,J&&(F=J),et&&typeof window<"u"&&this.setupRealtime(re,w.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:c.DEFAULT_FLAGS})),this.setState(wi),this.log("Initialising with properties",f,this),we&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Tn&&(d=function(fe){return function(Se,xe){var Ne=xe.headers,Y=xe.method,Ge=xe.body;return new Promise(function(De){switch(Y){case"GET":return fe.get(Se,{headers:Ne}).subscribe(function(Te){De({ok:!0,text:function(){return Promise.resolve(Te)}})});case"POST":case"PUT":return fe.post(Se,Ge,{headers:Ne}).subscribe(function(Te){De({ok:!0,text:function(){return Promise.resolve(Te)}})})}})}}(Tn)),F&&this.canUseStorage&&F.getItem(A).then(function(fe){try{oe.evaluationEvent=JSON.parse(fe)||{}}catch{oe.evaluationEvent={}}oe.analyticsInterval=setInterval(oe.analyticsFlags,oe.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),F&&this.canUseStorage&&F.getItem(A,function(fe,Se){if(Se&&oe.evaluationContext.environment){var xe=JSON.parse(Se);if(xe[oe.evaluationContext.environment.apiKey]){var Ne=oe.getState();oe.log("Retrieved events from cache",Se),oe.setState(i(i({},Ne),{evaluationEvent:xe[oe.evaluationContext.environment.apiKey]}))}}})),!q)return[3,9];if(!F||!this.canUseStorage)return[3,8];ki=function(fe,Se){return r(oe,void 0,void 0,function(){var xe,Ne,Y,Ge,De,Te,Cn,Ei,_n,Nn,On,Rn,Fn,An,Dn,Mn,Ln,Pn,Bn,jn,Un,zn,Hn,$n;return o(this,function(Oe){switch(Oe.label){case 0:if(!Se)return[3,7];xe=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(Se),Ge=!1,De=!1,Y&&Y.api===this.api&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.environment)===null||Nn===void 0?void 0:Nn.apiKey)===((On=this.evaluationContext.environment)===null||On===void 0?void 0:On.apiKey)&&(Te=!0,this.evaluationContext.identity&&((Fn=(Rn=Y.evaluationContext)===null||Rn===void 0?void 0:Rn.identity)===null||Fn===void 0?void 0:Fn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Dn=(An=Y.evaluationContext)===null||An===void 0?void 0:An.identity)===null||Dn===void 0?void 0:Dn.identifier)+" to "+this.evaluationContext.identity.identifier),Te=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Te=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),De=!0,Te=!0)),Te&&(Ge=!0,Ne=h((Mn=this.evaluationContext.identity)===null||Mn===void 0?void 0:Mn.traits,(Pn=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||Pn===void 0?void 0:Pn.traits),xe=h(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Bn=Y.evaluationContext)===null||Bn===void 0)&&Bn.identity?i(i({},(jn=Y.evaluationContext)===null||jn===void 0?void 0:jn.identity),{traits:i(i({},((zn=(Un=Y.evaluationContext)===null||Un===void 0?void 0:Un.identity)===null||zn===void 0?void 0:zn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(Cn=!ue&&(!this.cacheOptions.skipAPI||De),this._onChange(null,{isFromServer:!1,flagsChanged:xe,traitsChanged:Ne},this._loadedState(null,c.CACHE,Cn)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!De&&this.log("Skipping API, using cache"),Cn&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return Ei=Oe.sent(),this.log("Exception fetching cached logs",Ei),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},(Hn=this.evaluationContext.identity)===null||Hn===void 0?void 0:Hn.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(En);this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},($n=this.evaluationContext.identity)===null||$n===void 0?void 0:$n.traits)},this._loadedState(null,c.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},ge.label=2;case 2:return ge.trys.push([2,7,,8]),F.getItemSync?(In=F.getItemSync(B),[3,5]):[3,3];case 3:return[4,F.getItem(B)];case 4:In=ge.sent(),ge.label=5;case 5:return[4,ki(null,In)];case 6:case 7:return ge.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return ge.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:h({},te),traitsChanged:h({},(u=w.identity)===null||u===void 0?void 0:u.traits)},this._loadedState(null,c.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=En),this._onChange(null,{isFromServer:!1,flagsChanged:h({},this.flags),traitsChanged:h({},(m=w.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,c.DEFAULT_FLAGS)),st))throw new Error(st);ge.label=12;case 12:return[3,14];case 13:throw Ve=ge.sent(),this.log("Error during initialisation ",Ve),Ti=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,Ti),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,u,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:u}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,u,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),u&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(u).map(function(g){var w=g[0],x=g[1];return[w,v(x)?x:{value:x}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||k,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],u=0;u<arguments.length;u++)f[u]=arguments[u];this.enableLogs&&console.log.apply(this,l(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),F.setItem(B,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);F.setItem(A,f)}},b.prototype.setLoadingState=function(f){var u;a(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(u=this._triggerLoadingState)===null||u===void 0||u.call(this))},b.prototype.setupRealtime=function(f,u){var m=this,g=f+"sse/environments/"+u+"/stream";T?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new T(g),this.eventSource.addEventListener("environment_updated",function(w){var x;try{x=JSON.parse(w.data).updated_at}catch(R){m.log("Could not parse sse event",R)}x?!m.timestamp||x>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",w.data,m.timestamp):(m.log("updated_at is new, fetching flags",w.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",w.data,m.timestamp):m.log("No updated_at received, fetching flags",w)})):this.log("Error, EventSource is undefined")},b}();function E(b){var f=b.fetch,u=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:u,eventSource:m})}var P,G=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,m){u.__proto__=m}||function(u,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(u[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function u(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(u.prototype=f.prototype,new u)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,u=f&&b[f],m=0;if(u)return u.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},$=function(b,f){var u=typeof Symbol=="function"&&b[Symbol.iterator];if(!u)return b;var m,g,w=u.call(b),x=[];try{for(;(f===void 0||f-- >0)&&!(m=w.next()).done;)x.push(m.value)}catch(R){g={error:R}}finally{try{m&&!m.done&&(u=w.return)&&u.call(w)}finally{if(g)throw g.error}}return x},C=function(b,f,u){if(u||arguments.length===2)for(var m,g=0,w=f.length;g<w;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
|
|
644
|
+
Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`)||this}return G(f,b),f}(Error),V=function(){function b(f,u){var m=this;if(this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this._configuration=u!=null?Object.assign({},u):void 0,this.withCredentials=!1,this._eventSource=null,this._lastEventId=null,this._timer=null,this._listeners={open:[],error:[],message:[]},this.url=f.toString(),this.readyState=this.CONNECTING,this.max_retry_time=3e3,this.eventSourceClass=globalThis.FlagsmithEventSource,this._configuration!=null&&(this._configuration.lastEventId&&(this._lastEventId=this._configuration.lastEventId,delete this._configuration.lastEventId),this._configuration.max_retry_time&&(this.max_retry_time=this._configuration.max_retry_time,delete this._configuration.max_retry_time),this._configuration.eventSourceClass&&(this.eventSourceClass=this._configuration.eventSourceClass,delete this._configuration.eventSourceClass)),this.eventSourceClass==null||typeof this.eventSourceClass!="function")throw new M;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return b.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},b.prototype._start=function(){var f,u,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(L){m._onopen(L)},this._eventSource.onerror=function(L){m._onerror(L)},this._eventSource.onmessage=function(L){m.onmessage(L)};try{for(var w=j(Object.keys(this._listeners)),x=w.next();!x.done;x=w.next()){var R=x.value;this._eventSource.addEventListener(R,this._onevent_wrapped)}}catch(L){f={error:L}}finally{try{x&&!x.done&&(u=w.return)&&u.call(w)}finally{if(f)throw f.error}}},b.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},b.prototype._onerror=function(f){var u=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 u._start()},m)}},b.prototype._onevent=function(f){var u,m;f&&f.lastEventId&&(this._lastEventId=f.lastEventId);var g=this._listeners[f.type];if(g!=null)try{for(var w=j(C([],$(g),!1)),x=w.next();!x.done;x=w.next())x.value.call(this,f)}catch(R){u={error:R}}finally{try{x&&!x.done&&(m=w.return)&&m.call(w)}finally{if(u)throw u.error}}f.type==="message"&&this.onmessage(f)},b.prototype.onopen=function(f){},b.prototype.onerror=function(f){},b.prototype.onmessage=function(f){},b.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},b.prototype.addEventListener=function(f,u,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(u)||(this._listeners[f]=C(C([],$(g),!1),[u],!1))},b.prototype.removeEventListener=function(f,u,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(w){return w!==u})},b}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var K=function(b,f){return f=f||{},new Promise(function(u,m){var g=new XMLHttpRequest,w=[],x=[],R={},L=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:L,headers:{keys:function(){return w},entries:function(){return x},get:function(_){return R[_.toLowerCase()]},has:function(_){return _.toLowerCase()in R}}}};for(var H in g.open(f.method||"get",b,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(_,q,ee){w.push(q=q.toLowerCase()),x.push([q,ee]),R[q]=R[q]?R[q]+","+ee:ee}),u(L())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(H,f.headers[H]);g.send(f.body||null)})},z=E({AsyncStorage:s,fetch:K,eventSource:V});typeof window<"u"&&(window.flagsmith=z),n.createFlagsmithInstance=function(){return E({AsyncStorage:s,fetch:K,eventSource:V})},n.default=z,Object.defineProperty(n,"__esModule",{value:!0})})})(Dt,Dt.exports);var Ai=Dt.exports;const Gn=Vn(Ai);var Kn={},Di=function(t,e,n,s,i){var r=new Worker(Kn[e]||(Kn[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,a=l.$e$;if(a){var h=new Error(a[0]);h.code=a[1],h.stack=a[2],i(h,null)}else i(null,l)},r.postMessage(n,s),r},ce=Uint8Array,ie=Uint16Array,ot=Int32Array,at=new ce([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]),ct=new ce([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]),Mt=new ce([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Jn=function(t,e){for(var n=new ie(31),s=0;s<31;++s)n[s]=e+=1<<t[s-1];for(var i=new ot(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}},Xn=Jn(at,2),Mi=Xn.b,lt=Xn.r;Mi[28]=258,lt[258]=28;for(var Li=Jn(ct,0),Lt=Li.r,ht=new ie(32768),X=0;X<32768;++X){var Ee=(X&43690)>>1|(X&21845)<<1;Ee=(Ee&52428)>>2|(Ee&13107)<<2,Ee=(Ee&61680)>>4|(Ee&3855)<<4,ht[X]=((Ee&65280)>>8|(Ee&255)<<8)>>1}for(var Le=function(t,e,n){for(var s=t.length,i=0,r=new ie(e);i<s;++i)t[i]&&++r[t[i]-1];var o=new ie(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var l;if(n){l=new ie(1<<e);var a=15-e;for(i=0;i<s;++i)if(t[i])for(var h=i<<4|t[i],c=e-t[i],d=o[t[i]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)l[ht[d]>>a]=h}else for(l=new ie(s),i=0;i<s;++i)t[i]&&(l[i]=ht[o[t[i]-1]++]>>15-t[i]);return l},Ie=new ce(288),X=0;X<144;++X)Ie[X]=8;for(var X=144;X<256;++X)Ie[X]=9;for(var X=256;X<280;++X)Ie[X]=7;for(var X=280;X<288;++X)Ie[X]=8;for(var Je=new ce(32),X=0;X<32;++X)Je[X]=5;var Yn=Le(Ie,9,0),Qn=Le(Je,5,0),Pt=function(t){return(t+7)/8|0},Zn=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ce(t.subarray(e,n))},Pi=["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"],es=function(t,e,n){var s=new Error(e||Pi[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,es),!n)throw s;return s},me=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8},Pe=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8,t[s+2]|=n>>16},ut=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:zt,l:0};if(i==1){var o=new ce(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(N,O){return N.f-O.f}),n.push({s:-1,f:25001});var l=n[0],a=n[1],h=0,c=1,d=2;for(n[0]={s:-1,f:l.f+a.f,l,r:a};c!=i-1;)l=n[n[h].f<n[d].f?h++:d++],a=n[h!=c&&n[h].f<n[d].f?h++:d++],n[c++]={s:-1,f:l.f+a.f,l,r:a};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var v=new ie(p+1),S=dt(n[c-1],v,0);if(S>e){var s=0,y=0,T=S-e,F=1<<T;for(r.sort(function(O,D){return v[D.s]-v[O.s]||O.f-D.f});s<i;++s){var B=r[s].s;if(v[B]>e)y+=F-(1<<S-v[B]),v[B]=e;else break}for(y>>=T;y>0;){var A=r[s].s;v[A]<e?y-=1<<e-v[A]++-1:++s}for(;s>=0&&y;--s){var k=r[s].s;v[k]==e&&(--v[k],++y)}S=e}return{t:new ce(v),l:S}},dt=function(t,e,n){return t.s==-1?Math.max(dt(t.l,e,n+1),dt(t.r,e,n+1)):e[t.s]=n},Bt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ie(++e),s=0,i=t[0],r=1,o=function(a){n[s++]=a},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}},Be=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},jt=function(t,e,n){var s=n.length,i=Pt(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},Ut=function(t,e,n,s,i,r,o,l,a,h,c){me(e,c++,n),++i[256];for(var d=ut(i,15),p=d.t,v=d.l,S=ut(r,15),y=S.t,T=S.l,F=Bt(p),B=F.c,A=F.n,k=Bt(y),N=k.c,O=k.n,D=new ie(19),I=0;I<B.length;++I)++D[B[I]&31];for(var I=0;I<N.length;++I)++D[N[I]&31];for(var E=ut(D,7),P=E.t,G=E.l,j=19;j>4&&!P[Mt[j-1]];--j);var $=h+5<<3,C=Be(i,Ie)+Be(r,Je)+o,M=Be(i,p)+Be(r,y)+o+14+3*j+Be(D,P)+2*D[16]+3*D[17]+7*D[18];if(a>=0&&$<=C&&$<=M)return jt(e,c,t.subarray(a,a+h));var V,K,z,b;if(me(e,c,1+(M<C)),c+=2,M<C){V=Le(p,v,0),K=p,z=Le(y,T,0),b=y;var f=Le(P,G,0);me(e,c,A-257),me(e,c+5,O-1),me(e,c+10,j-4),c+=14;for(var I=0;I<j;++I)me(e,c+3*I,P[Mt[I]]);c+=3*j;for(var u=[B,N],m=0;m<2;++m)for(var g=u[m],I=0;I<g.length;++I){var w=g[I]&31;me(e,c,f[w]),c+=P[w],w>15&&(me(e,c,g[I]>>5&127),c+=g[I]>>12)}}else V=Yn,K=Ie,z=Qn,b=Je;for(var I=0;I<l;++I){var x=s[I];if(x>255){var w=x>>18&31;Pe(e,c,V[w+257]),c+=K[w+257],w>7&&(me(e,c,x>>23&31),c+=at[w]);var R=x&31;Pe(e,c,z[R]),c+=b[R],R>3&&(Pe(e,c,x>>5&8191),c+=ct[R])}else Pe(e,c,V[x]),c+=K[x]}return Pe(e,c,V[256]),c+K[256]},ts=new ot([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),zt=new ce(0),ns=function(t,e,n,s,i,r){var o=r.z||t.length,l=new ce(s+o+5*(1+Math.ceil(o/7e3))+i),a=l.subarray(s,l.length-i),h=r.l,c=(r.r||0)&7;if(e){c&&(a[0]=r.r>>3);for(var d=ts[e-1],p=d>>13,v=d&8191,S=(1<<n)-1,y=r.p||new ie(32768),T=r.h||new ie(S+1),F=Math.ceil(n/3),B=2*F,A=function(ne){return(t[ne]^t[ne+1]<<F^t[ne+2]<<B)&S},k=new ot(25e3),N=new ie(288),O=new ie(32),D=0,I=0,E=r.i||0,P=0,G=r.w||0,j=0;E+2<o;++E){var $=A(E),C=E&32767,M=T[$];if(y[C]=M,T[$]=C,G<=E){var V=o-E;if((D>7e3||P>24576)&&(V>423||!h)){c=Ut(t,a,0,k,N,O,I,P,j,E-j,c),P=D=I=0,j=E;for(var K=0;K<286;++K)N[K]=0;for(var K=0;K<30;++K)O[K]=0}var z=2,b=0,f=v,u=C-M&32767;if(V>2&&$==A(E-u))for(var m=Math.min(p,V)-1,g=Math.min(32767,E),w=Math.min(258,V);u<=g&&--f&&C!=M;){if(t[E+z]==t[E+z-u]){for(var x=0;x<w&&t[E+x]==t[E+x-u];++x);if(x>z){if(z=x,b=u,x>m)break;for(var R=Math.min(u,x-2),L=0,K=0;K<R;++K){var H=E-u+K&32767,_=y[H],q=H-_&32767;q>L&&(L=q,M=H)}}}C=M,M=y[C],u+=C-M&32767}if(b){k[P++]=268435456|lt[z]<<18|Lt[b];var ee=lt[z]&31,ae=Lt[b]&31;I+=at[ee]+ct[ae],++N[257+ee],++O[ae],G=E+z,++D}else k[P++]=t[E],++N[t[E]]}}for(E=Math.max(E,G);E<o;++E)k[P++]=t[E],++N[t[E]];c=Ut(t,a,h,k,N,O,I,P,j,E-j,c),h||(r.r=c&7|a[c/8|0]<<3,c-=7,r.h=T,r.p=y,r.i=E,r.w=G)}else{for(var E=r.w||0;E<o+h;E+=65535){var te=E+65535;te>=o&&(a[c/8|0]=h,te=o),c=jt(a,c+1,t.subarray(E,te))}r.i=o}return Zn(l,0,s+Pt(c)+i)},ss=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}(),is=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=ss[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Ht=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new ce(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return ns(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)},Bi=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},rs=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],a=r[o];if(typeof l=="function"){e+=";"+a+"=";var h=l.toString();if(l.prototype)if(h.indexOf("[native code]")!=-1){var c=h.indexOf(" ",8)+1;e+=h.slice(c,h.indexOf("(",c))}else{e+=h;for(var d in l.prototype)e+=";"+a+".prototype."+d+"="+l.prototype[d].toString()}else e+=h}else n[a]=l}return e},ft=[],ji=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},Ui=function(t,e,n,s){if(!ft[n]){for(var i="",r={},o=t.length-1,l=0;l<o;++l)i=rs(t[l],i,r);ft[n]={c:rs(t[o],i,r),e:r}}var a=Bi({},ft[n].e);return Di(ft[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,a,ji(a),s)},zi=function(){return[ce,ie,ot,at,ct,Mt,lt,Lt,Yn,Ie,Qn,Je,ht,ts,zt,Le,me,Pe,ut,dt,Bt,Be,jt,Ut,Pt,Zn,ns,Ht,Wi,os]},Hi=function(){return[as,cs,pt,is,ss]},os=function(t){return postMessage(t,[t.buffer])},$i=function(t,e,n,s,i,r){var o=Ui(n,s,i,function(l,a){o.terminate(),r(l,a)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},pt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},as=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&&pt(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)}},cs=function(t){return 10+(t.filename?t.filename.length+1:0)};function Wi(t,e){return Ht(t,e||{},0,0)}function qi(t,e,n){return n||(n=e,e={}),typeof n!="function"&&es(7),$i(t,e,[zi,Hi,function(){return[ls]}],function(s){return os(ls(s.data[0],s.data[1]))},2,n)}function ls(t,e){e||(e={});var n=is(),s=t.length;n.p(t);var i=Ht(t,e,cs(e),8),r=i.length;return as(i,e),pt(i,r-8,n.d()),pt(i,r-4,s),i}var Vi=typeof TextDecoder<"u"&&new TextDecoder,Gi=0;try{Vi.decode(zt,{stream:!0}),Gi=1}catch{}class hs{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 Ki{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new hs}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 hs}}class Ji{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Xi(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(a=>{let h;a.type==="fetch"?(h={type:"network_request",subConditions:[],name:o.name},a.filters.forEach(c=>{const d=this.createConditionFromFilter(c);d&&h.subConditions.push(d)})):h=this.createConditionFromFilter(a),h&&(h.type==="session_duration"&&this.processDuration(h.value[0],o.name),r.push({...h,name:o.name}))})}),this.conditions=r}catch{this.app.debug.error("Critical: cannot fetch start conditions")}}trigger(e){if(!this.hasStarted)try{this.hasStarted=!0,this.app.start(this.startParams,void 0,e)}catch(n){this.app.debug.error(n)}}processMessage(e){if(!this.hasStarted)switch(e[0]){case 78:this.jsExceptionEvent(e);break;case 27:this.customEvent(e);break;case 68:this.clickEvent(e);break;case 122:this.pageLocationEvent(e);break;case 83:this.networkRequest(e);break}}processFlags(e){const n=this.conditions.filter(s=>s.type==="feature_flag");n.length&&n.forEach(s=>{const i=je[s.operator];i&&e.find(r=>i(r.key,s.value))&&this.trigger(s.name)})}processDuration(e,n){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(n)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const n=this.conditions.filter(s=>s.type==="network_request");n.length&&n.forEach(s=>{const i=s.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let 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 a=je[o.operator];if(a&&a(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=je[s.operator];i&&(i(e[1],s.value)||i(e[2],s.value))&&this.trigger(s.name)})}clickEvent(e){const n=this.conditions.filter(s=>s.type==="click");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[3],s.value)||i(e[4],s.value))&&this.trigger(s.name)})}pageLocationEvent(e){const n=this.conditions.filter(s=>s.type==="visited_url");n&&n.forEach(s=>{const i=je[s.operator];i&&i(e[1],s.value)&&this.trigger(s.name)})}jsExceptionEvent(e){const n=[e[1],e[2],e[3]],s=this.conditions.filter(i=>i.type==="exception");s&&s.forEach(i=>{const r=je[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const je={is:(t,e)=>e.some(n=>t.includes(n)),isAny:()=>!0,isNot:(t,e)=>!e.some(n=>t.includes(n)),contains:(t,e)=>e.some(n=>t.includes(n)),notContains:(t,e)=>!e.some(n=>t.includes(n)),startsWith:(t,e)=>e.some(n=>t.startsWith(n)),endsWith:(t,e)=>e.some(n=>t.endsWith(n)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Xi=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 Yi{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,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(),a=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(a.status===200){const h=await a.json();return this.handleFlags(h.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 us={htmlmasked:"hidden",masked:"obscured"},be=!(typeof window>"u"),Qi=be&&navigator.userAgent.match(/firefox|fxios/i),Zi=1e5;let $t=be?Date.now()-performance.now():0;function Wt(){$t=Date.now()-performance.now()}function Ue(){return $t}const pe=be&&performance.now?()=>Math.round(performance.now()+$t):()=>Date.now(),qt="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function ds(t){return t.trim().replace(/\s+/g," ")}function fs(t){return t.startsWith("https://")||t.startsWith("http://")}const gt="https://docs.openreplay.com",ps={};function Ce(t,e,n="/"){ps[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${gt}${n} for more information.`),ps[t]=!0)}function Vt(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ce('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Re(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(us[e]&&Ce(`"${n}" attribute`,`"${us[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function er(t){try{return!!t.contentDocument}catch{return!1}}function gs(t){return t.toString(16).padStart(2,"0")}function tr(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,gs).join("")):Array.from({length:t||40},()=>gs(Math.floor(Math.random()*16))).join("")}function nr(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function Gt(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function ms(t){const e=Gt("MutationObserver");return new window[e](t)}function bs(t,e,n,s){const i=Gt("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 vs(t,e,n,s){const i=Gt("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 sr{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 ir=new sr;function rr(t){ir.addTask(t)}function ys(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]=ys(r||{},i):n[s]=i}return n}function Fe(t){return[0,t]}function or(t,e){return[5,t,e]}function ar(t,e){return[6,t,e]}function cr(){return[7]}function lr(t,e,n,s,i){return[8,t,e,n,s,i]}function hr(t,e,n){return[9,t,e,n]}function ur(t,e,n){return[10,t,e,n]}function dr(t){return[11,t]}function ws(t,e){return[13,t,e]}function fr(t,e){return[14,t,e]}function pr(t,e,n){return[16,t,e,n]}function gr(t,e,n){return[18,t,e,n]}function mr(t,e){return[19,t,e]}function br(t,e){return[20,t,e]}function vr(t,e){return[22,t,e]}function yr(t,e,n,s,i,r,o,l,a){return[23,t,e,n,s,i,r,o,l,a]}function wr(t,e,n){return[24,t,e,n]}function Sr(t,e){return[27,t,e]}function xr(t){return[28,t]}function kr(t){return[29,t]}function Ss(t,e){return[30,t,e]}function Tr(t,e,n,s){return[49,t,e,n,s]}function Er(t,e){return[54,t,e]}function Ir(t){return[55,t]}function xs(t,e,n,s){return[57,t,e,n,s]}function ks(t){return[58,t]}function Kt(t,e,n,s){return[60,t,e,n,s]}function Cr(t,e,n){return[61,t,e,n]}function _r(t,e){return[63,t,e]}function Nr(t,e){return[64,t,e]}function Or(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function Jt(t,e){return[70,t,e]}function Ts(t,e,n){return[71,t,e,n]}function Xt(t,e,n,s){return[73,t,e,n,s]}function Es(t,e){return[75,t,e]}function Is(t,e){return[76,t,e]}function Rr(t,e){return[77,t,e]}function Yt(t,e,n,s){return[78,t,e,n,s]}function mt(t,e,n,s,i,r,o,l,a){return[83,t,e,n,s,i,r,o,l,a]}function Fr(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function Ar(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function Cs(t,e,n){return[113,t,e,n]}function Dr(t){return[114,t]}function Mr(t){return[115,t]}function _s(t,e,n,s,i,r,o,l,a,h){return[116,t,e,n,s,i,r,o,l,a,h]}function bt(t){return[117,t]}function Ae(t){return[118,t]}function Lr(t,e){return[119,t,e]}function Pr(t){return[120,t]}function Br(t,e,n,s){return[122,t,e,n,s]}const Qt=be&&"performance"in window&&"memory"in performance?performance:{memory:{}},Zt=be?(navigator.deviceMemory||0)*1024:0,en=Qt.memory.jsHeapSizeLimit||0;function jr(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(Tr(s,i,Qt.memory.totalJSHeapSize||0,Qt.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 Ns="__or__watched_tags__";class Ur{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ns)??"[]");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(Ns,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 zr={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"'},Hr={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},vt={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"},$r={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Wr={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"},qr={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"},Os={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"},Vr={padding:"0.5rem",gap:"0.5rem",fontFamily:"Verdana, sans-serif",fontSize:"16px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto",color:"white",display:"flex",alignItems:"center",width:"100%",borderRadius:"2px",background:"rgba(0, 0, 0, 0.75)",boxSizing:"border-box"},He={boxSizing:"border-box",display:"block",width:"100%",borderBottom:"1px solid #D9D9D9",background:"#FFF",padding:"0.65rem",alignSelf:"stretch",color:"#000",fontFamily:"Verdana, sans-serif",fontStyle:"normal",fontWeight:"400"},Gr={...He,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Rs={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Fs={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"},As={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Kr={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Ds={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Jr={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"},Ms={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"},Ls={fontWeight:"bold"},Xr={fontSize:"13px",lineHeight:"auto"},Ps={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Yr={...Ps,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Qr={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},Zr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Bs={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class eo{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 to(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(h,c){let d=h-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(h){o(h.pageX,h.pageY)}document.addEventListener("mousemove",l);const a=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a)},e.ondragstart=function(){return!1}}function no(){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 so(){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 io(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
|
|
641
645
|
0% { transform: rotate(0deg); }
|
|
642
646
|
100% { transform: rotate(360deg); }
|
|
643
647
|
}`,document.head.appendChild(t)}function ro(){io();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,Zr),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 yt="or_uxt_test_start",tn="or_uxt_task_index",nn="or_uxt_session_id",oo="or_uxt_test_id";class ao{constructor(e,n,s,i,r,o,l,a,h){this.ingestPoint=e,this.getTimestamp=n,this.token=s,this.testId=i,this.storageKey=r,this.setStorageKey=o,this.removeStorageKey=l,this.getStorageKey=a,this.getSessionId=h,this.durations={testStart:0,tasks:[]},this.getDurations=()=>this.durations,this.setDurations=d=>{this.durations.testStart=d.testStart,this.durations.tasks=d.tasks},this.signalTask=(d,p,v)=>{if(!d)return console.error("User Testing: No Task ID Given");const S=this.durations.tasks.find(F=>F.taskId===d),y=this.getTimestamp(),T=S?y-S.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:T,timestamp:y,taskAnswer:v})})},this.signalTest=d=>{const p=this.getTimestamp();if(d==="begin"&&this.testId){const y=this.getSessionId();this.setStorageKey(nn,y),this.setStorageKey(this.storageKey,this.testId.toString()),this.setStorageKey(yt,p.toString())}else this.removeStorageKey(this.storageKey),this.removeStorageKey(tn),this.removeStorageKey(yt);const v=this.durations.testStart||p,S=p-v;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,status:d,duration:S,timestamp:p})})};const c=this.getStorageKey(yt);c&&(this.durations.testStart=parseInt(c,10))}}class co{constructor(e,n){this.app=e,this.storageKey=n,this.bg=U("div","bg",zr,void 0,"__or_ut_bg"),this.container=U("div","container",Hr,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,a)=>{this.testId=o;const h=this.app.options.ingestPoint;return fetch(`${h}/v1/web/uxt/test/${o}`,{headers:{Authorization:`Bearer ${l}`}}).then(c=>c.json()).then(({test:c})=>{this.isActive=!0,this.test=c,this.signalManager=new ao(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(c.title,c.reqMic,c.reqCamera),a&&((c.reqMic||c.reqCamera)&&this.userRecorder.startRecording(30,Bs.Standard,c.reqMic,c.reqCamera),this.showWidget(c.description,c.tasks,!0),this.showTaskSection())}).then(()=>o).catch(c=>{console.log("OR: Error fetching test",c)})},this.hideTaskSection=()=>!1,this.showTaskSection=()=>!0,this.collapseWidget=()=>!1,this.removeGreeting=()=>!1,this.toggleDescriptionVisibility=()=>{},this.currentTaskIndex=0,this.userRecorder=new eo(e);const s=this.app.getSessionID(),i=this.app.localStorage.getItem(nn);s!==i&&(this.app.localStorage.removeItem(this.storageKey),this.app.localStorage.removeItem(nn),this.app.localStorage.removeItem(oo),this.app.localStorage.removeItem(tn),this.app.localStorage.removeItem(yt));const r=this.app.localStorage.getItem(tn);r&&(this.currentTaskIndex=parseInt(r,10))}getTestId(){return this.testId}createGreeting(e,n,s){const i=U("div","title",$r,e),r=U("div","description",Wr,`Welcome, you're here to help us improve, not to be judged. Your insights matter!
|
|
644
648
|
|
|
645
649
|
📹 We're recording this browser tab to learn from your experience.
|
|
646
|
-
🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=U("div","button",qr,"Read guidelines to begin");this.removeGreeting=()=>((n||s)&&this.userRecorder.startRecording(30,Bs.Standard,n,s),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var a,h,c,d;this.removeGreeting();const l=(a=this.signalManager)==null?void 0:a.getDurations();l&&this.signalManager&&(l.testStart=this.app.timestamp(),this.signalManager.setDurations(l)),(h=this.signalManager)==null||h.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,vt),this.showWidget(((c=this.test)==null?void 0:c.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,vt);const r=this.createDescriptionSection(e),o=this.createTasksSection(n),l=U("div","stop_bn_or",As,"Abort Session"),a=U("div","stop_ct_or",{fontSize:"13px!important"});a.style.fontSize="13px",a.append(l),this.container.append(i,r,o,a),this.taskSection=o,this.descriptionSection=r,this.stopButton=l,this.stopButtonContainer=a,l.onclick=()=>{var h;this.userRecorder.discard(),(h=this.signalManager)==null||h.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},s?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var l;const e=U("div","title",Vr),n=no(),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=so();e.append(n,s,i);const r=a=>(this.widgetVisible=a,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?vt:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?He:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?He:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?He:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?As:{display:"none"}),a),o=()=>{Object.assign(i.style,{transform:this.widgetVisible?"rotate(0deg)":"rotate(180deg)"}),r(!this.widgetVisible)};return s.onclick=o,i.onclick=o,to(this.bg,n),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const n=U("div","description_section_or",He),s=U("div","description_s_title_or",Os),i=U("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=U("div","icon",Rs,"-"),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 a=U("div","button_begin_or",Fs,"Begin Test");s.append(i,r),o.append(l,a),n.append(s,o);const h=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"})};return s.onclick=h,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"}),o.removeChild(a)},a.onclick=()=>{var c,d,p;if(h(),this.test){const v=(c=this.signalManager)==null?void 0:c.getDurations(),S=v?v.tasks.findIndex(y=>this.test&&y.taskId===this.test.tasks[0].task_id):null;v&&S===-1&&(v.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(d=this.signalManager)==null||d.setDurations(v)),(p=this.signalManager)==null||p.signalTask(this.test.tasks[0].task_id,"begin")}this.showTaskSection(),o.removeChild(a)},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,vt);const n=U("div","task_section_or",He),s=U("div","description_t_title_or",Os),i=U("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=U("div","icon",Rs,"-"),o=U("div","content",ze),l=U("div","pagination",Kr),a=U("div","taskCard",Ms),h=U("div","taskText",Ls),c=U("div","taskDescription",
|
|
650
|
+
🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=U("div","button",qr,"Read guidelines to begin");this.removeGreeting=()=>((n||s)&&this.userRecorder.startRecording(30,Bs.Standard,n,s),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var a,h,c,d;this.removeGreeting();const l=(a=this.signalManager)==null?void 0:a.getDurations();l&&this.signalManager&&(l.testStart=this.app.timestamp(),this.signalManager.setDurations(l)),(h=this.signalManager)==null||h.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,vt),this.showWidget(((c=this.test)==null?void 0:c.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,vt);const r=this.createDescriptionSection(e),o=this.createTasksSection(n),l=U("div","stop_bn_or",As,"Abort Session"),a=U("div","stop_ct_or",{fontSize:"13px!important"});a.style.fontSize="13px",a.append(l),this.container.append(i,r,o,a),this.taskSection=o,this.descriptionSection=r,this.stopButton=l,this.stopButtonContainer=a,l.onclick=()=>{var h;this.userRecorder.discard(),(h=this.signalManager)==null||h.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},s?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var l;const e=U("div","title",Vr),n=no(),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=so();e.append(n,s,i);const r=a=>(this.widgetVisible=a,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?vt:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?He:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?He:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?He:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?As:{display:"none"}),a),o=()=>{Object.assign(i.style,{transform:this.widgetVisible?"rotate(0deg)":"rotate(180deg)"}),r(!this.widgetVisible)};return s.onclick=o,i.onclick=o,to(this.bg,n),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const n=U("div","description_section_or",He),s=U("div","description_s_title_or",Os),i=U("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=U("div","icon",Rs,"-"),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 a=U("div","button_begin_or",Fs,"Begin Test");s.append(i,r),o.append(l,a),n.append(s,o);const h=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"})};return s.onclick=h,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ze:{display:"none"}),o.removeChild(a)},a.onclick=()=>{var c,d,p;if(h(),this.test){const v=(c=this.signalManager)==null?void 0:c.getDurations(),S=v?v.tasks.findIndex(y=>this.test&&y.taskId===this.test.tasks[0].task_id):null;v&&S===-1&&(v.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(d=this.signalManager)==null||d.setDurations(v)),(p=this.signalManager)==null||p.signalTask(this.test.tasks[0].task_id,"begin")}this.showTaskSection(),o.removeChild(a)},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,vt);const n=U("div","task_section_or",He),s=U("div","description_t_title_or",Os),i=U("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=U("div","icon",Rs,"-"),o=U("div","content",ze),l=U("div","pagination",Kr),a=U("div","taskCard",Ms),h=U("div","taskText",Ls),c=U("div","taskDescription",Xr),d=U("div","taskButtons",Qr),p=U("div","taskText",Ls);p.textContent="Your answer";const v=U("textarea","taskDescription",{resize:"vertical"}),S=U("div","inputArea",Ms);S.append(p,v);const y=U("div","closePanelButton",Ps,"Collapse Panel"),T=U("div","nextButton",Yr,"Done, Next");s.append(i,r),a.append(h,c),d.append(y,T),o.append(l,a,S,d),n.append(s,o);const F=()=>{const k=e[this.currentTaskIndex];h.textContent=k.title,c.textContent=k.description,k.allow_typing?S.style.display="flex":S.style.display="none"};e.forEach((k,N)=>{const O=U("span",`or_task_${N}`,{outline:"1px solid #efefef",fontSize:"13px",height:"24px",width:"24px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em"},(N+1).toString());O.id=`or_task_${N}`,l.append(O)});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,Ds);for(let N=0;N<this.currentTaskIndex;N++){const O=document.getElementById(`or_task_${N}`);O&&Object.assign(O.style,Jr)}};return s.onclick=B,y.onclick=this.collapseWidget,T.onclick=()=>{var N,O,D,I;const k=e[this.currentTaskIndex].allow_typing?v.value:void 0;if(v.value="",(N=this.signalManager)==null||N.signalTask(e[this.currentTaskIndex].task_id,"done",k),this.currentTaskIndex<e.length-1){this.currentTaskIndex++,F();const E=(O=this.signalManager)==null?void 0:O.getDurations();E&&E.tasks.findIndex(P=>P.taskId===e[this.currentTaskIndex].task_id)===-1&&(E.tasks.push({taskId:e[this.currentTaskIndex].task_id,started:this.app.timestamp()}),(D=this.signalManager)==null||D.setDurations(E)),(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,Ds),F(),A()},1),n}showEndSection(){var l,a,h,c;let e=!0;(l=this.signalManager)==null||l.signalTest("done");const n=U("div","end_section_or",Gr),s=U("div","end_title_or",{fontSize:"1.25rem",fontWeight:"500"},"Thank you! 👍"),i=U("div","end_description_or",{},((a=this.test)==null?void 0:a.conclusion)??`Thank you for participating in our usability test. Your feedback has been captured and will be used to enhance our website.
|
|
647
651
|
|
|
648
|
-
We appreciate your time and valuable input.`),r=U("div","end_button_or",Fs,"Submitting Feedback"),o=ro();r.appendChild(o),(h=this.test)!=null&&h.reqMic||(c=this.test)!=null&&c.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 js(t){return!!t&&t.nodeType!=null}function sn(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function ke(t){return t.nodeType===Node.ELEMENT_NODE}function lo(t){return t.nodeType===Node.COMMENT_NODE}function rn(t){return t.nodeType===Node.TEXT_NODE}function wt(t){return t.nodeType===Node.DOCUMENT_NODE}function St(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Q(t,e){return t.localName===e}class ho{constructor(e,n){this.app=e,this.options=n,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=s=>{const i=this.app.nodes.getID(s);if(!i||!Q(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Q(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.forEach(a=>{a.isIntersecting&&(a.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(a.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=Lr(i.toString(),r);this.app.send(o);const l=h=>{uo(h,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=[]))})},a=setInterval(()=>{const h=this.app.nodes.getID(s),c=h?this.app.nodes.getNode(h):void 0;!c||!Q(c,"canvas")||c!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(a)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(c)}):l(c))},this.interval);this.intervals.push(a)},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&&fo(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 Us={low:.35,medium:.55,high:.8};function uo(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 a=n.getContext("2d");if(!a)return"";a.clearRect(0,0,n.width,n.height),a.drawImage(t,0,0,n.width,n.height),n.toBlob(r,o,Us[e])}else t.toBlob(r,o,Us[e])}function fo(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 Je={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class po{constructor(e=Je.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Je.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Je.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Je.Errors)&&console.error(...n)},this.level=e}}class go{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;bs(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=>vs(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 on(t){if(lo(t))return!0;if(rn(t))return!1;if(!ke(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const n=t.getAttribute("rel"),s=t.getAttribute("as");return!(n!=null&&n.includes("stylesheet")||s==="style"||s==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function an(t){return St(t)?!0:!on(t)}var ve;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(ve||(ve={}));class cn{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=ms(this.app.safe(s=>{for(const i of s){const r=i.target,o=i.type;if(!an(r))continue;if(o==="childList"){for(let a=0;a<i.removedNodes.length;a++)an(i.removedNodes[a])&&this.bindNode(i.removedNodes[a]);for(let a=0;a<i.addedNodes.length;a++)this.bindTree(i.addedNodes[a]);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 a=i.attributeName;if(a===null)continue;let h=this.attributesMap.get(l);h===void 0&&this.attributesMap.set(l,h=new Set),h.add(a);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(sn(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(ws(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Kt(e,s,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,s,i);return}if(!(s==="src"||s==="srcset"||s==="integrity"||s==="crossorigin"||s==="autocomplete"||s.substr(0,2)==="on")&&!(s==="value"&&Q(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(ws(e,s));return}if(s==="style"||s==="href"&&Q(n,"link")){this.app.send(Kt(e,s,i,this.app.getBaseHref()));return}(s==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,s,i)}}sendNodeData(e,n,s){if(Q(n,"style")){this.app.send(Cr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(fr(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(!an(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),on(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(dr(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>on(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(Mr(o))}}_commitNode(e,n){if(St(n))return!0;const s=n.parentNode;let i;if(!Q(n,"html")||!this.isTopContext){if(s===null)return this.unbindTree(n),!1;if(i=this.app.nodes.getID(s),i===void 0)return this.unbindTree(n),!1;if(!this.commitNode(i))return this.unbindTree(n),!1;if(this.app.sanitizer.handleNode(e,i,n),this.app.sanitizer.isHidden(i))return!1}let r=n.previousSibling;for(;r!==null;){const 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 o=this.recents.get(e),l=o===ve.New,a=this.indexes[e];if(a===void 0)throw"commitNode: missing node index";if(l){if(ke(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(lr(e,i,a,c.tagName,sn(n)))}for(let d=0;d<c.attributes.length;d++){const p=c.attributes[d];this.sendNodeAttribute(e,c,p.nodeName,p.value)}}else rn(n)&&(this.app.send(hr(e,i,a)),this.sendNodeData(e,s,n.data));return!0}o===ve.Removed&&i!==void 0&&this.app.send(ur(e,i,a));const h=this.attributesMap.get(e);if(h!==void 0){if(!ke(n))throw"commitNode: node is not an element";for(const c of h)this.sendNodeAttribute(e,n,c,n.getAttribute(c))}if(this.textSet.has(e)){if(!rn(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 zs extends cn{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(Xt(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(Xt(e,s))})}}class mo extends cn{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(Xt(s,i))})}}class bo{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 a;s.removeEventListener("scroll",o),(a=s.defaultView)==null||a.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 ln=be?Element.prototype.attachShadow:()=>new ShadowRoot;class vo extends cn{constructor(e,n){super(e,!0),this.iframeOffsets=new bo,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Q(s,"iframe")&&(this.options.captureIFrames&&!Re(s,"obscured")||Re(s,"capture"))&&this.handleIframe(s)}),this.app.nodes.attachNodeCallback(s=>{ke(s)&&s.shadowRoot!==null&&this.handleShadowRoot(s.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let n=null;const s=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!er(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==n){const l=new zs(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 mo(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=ln.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(cr()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=ln.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new zs(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=ln,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var xt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(xt||(xt={}));const yo=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class wo{constructor(e,n){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},n)}handleNode(e,n,s){if((this.obscured.has(n)||ke(s)&&(Re(s,"masked")||Re(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||ke(s)&&(Re(s,"htmlmasked")||Re(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&ke(s)){const i=this.options.domSanitizer(s);i===xt.Obscured&&this.obscured.add(e),i===xt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?yo(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`${qt(i)}@${qt(o)}.${qt(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 So{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=tr(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 xo(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class ko{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?xo(e,n):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ye="canceled",Hs="or_uxt_active",hn="or_buffer_1",_e=t=>({reason:t,success:!1}),To=t=>({...t,success:!0});var Z;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Z||(Z={}));const $s="https://api.openreplay.com/ingest";function un(){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 Eo=t=>new Promise(e=>setTimeout(e,t)),le={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 Io=class{constructor(e,n,s,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=Z.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var a;(a=this.canvasRecorder)==null||a.restartTracking()},this.flushBuffer=async a=>new Promise(h=>{let c=!1;const d=[a.shift()];for(;!c;){const p=a[0];!p||p[0]===0?c=!0:d.push(a.shift())}this.postToWorker(d),h(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(s).findIndex(a=>["fixedCanvasScaling","disableCanvas"].includes(a))!==-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:$s,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Je.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=ys(o,s),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const a=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${a}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new wo(this,s),this.nodes=new go(this.options.node_id),this.observer=new vo(this,s),this.ticker=new ko(this),this.ticker.attach(()=>this.commit()),this.debug=new po(this.options.__debug__),this.session=new So(this,this.options),this.attributeSender=new Ki(this,!!this.options.disableStringDict),this.featureFlags=new Yi(this),this.tagWatcher=new Ur(this.sessionStorage,this.debug.error,a=>{this.send(Pr(a))}),this.session.attachUpdateCallback(({userID:a,metadata:h})=>{a!=null&&this.send(xr(a)),h!=null&&Object.entries(h).forEach(([c,d])=>this.send(Ss(c,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const l=this.session.getTabId();if(this.insideIframe){const a=c=>{const{data:d}=c;d.line===le.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",a),this.attachStopCallback(()=>{window.removeEventListener("message",a)});const h=this.initialHostName;window.parent.postMessage({line:le.iframeSignal,source:l,context:this.contextId,domain:h},"*")}else{let a=0;const h=c=>{const{data:d}=c;if(d.line===le.iframeSignal){const p=d.domain,v=Array.from(document.querySelectorAll("iframe"));this.pageFrames=v,(async()=>{let y=0;for(;y<10;){const T=this.checkNodeId(v,p);if(T){this.waitStarted().then(()=>{var A;a++;const F=this.session.getSessionToken(),B={line:le.iframeId,context:this.contextId,domain:p,id:T,token:F,frameOrderNumber:a};this.debug.log("iframe_data",B),(A=c.source)==null||A.postMessage(B,"*")}).catch(console.error),y=10;break}y++,await Eo(100)}})()}if(d.line===le.iframeBatch){const v=d.messages.map(S=>{if(S[0]===20){let y=S;return this.pageFrames.forEach(T=>{if(T.dataset.domain===c.data.domain){const[F,B,A]=S,{left:k,top:N}=T.getBoundingClientRect();y=[F,B+k,A+N]}}),y}if(S[0]===68){let y=S;return this.pageFrames.forEach(T=>{if(T.dataset.domain===c.data.domain){const[F,B,A,k,N,O,D]=S,{left:I,top:E,width:P,height:G}=T.getBoundingClientRect(),j=document.documentElement.scrollWidth,$=document.documentElement.scrollHeight,C=O/100*P+I,M=D/100*G+E,q=C/j,K=M/$;y=[F,B,A,k,N,Math.round(q*1e3)/10,Math.round(K*1e3)/10]}}),y}return S});this.messages.push(...v)}};window.addEventListener("message",h),this.attachStopCallback(()=>{window.removeEventListener("message",h)})}this.bc!==null&&(this.bc.postMessage({line:le.ask,source:l,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=a=>{if(a.data.context!==this.contextId){if(a.data.line===le.resp){const h=a.data.token;this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===le.reg){const h=a.data.token;this.session.regenerateTabId(),this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===le.ask){const h=this.session.getSessionToken();h&&this.bc&&this.bc.postMessage({line:a.data.source===l?le.reg:le.resp,token:h,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?qi(e.batch,{mtime:0},(r,o)=>{var l,a;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.postMessage({type:"uncompressed",batch:s})):(a=this.worker)==null||a.postMessage({type:"compressed",batch:o})}):(n=this.worker)==null||n.postMessage({type:"uncompressed",batch:s})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,n){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${n}`})}),this.debug.error("OpenReplay error: ",e,n)}send(e,n=!1){var s;this.activityState!==Z.NotActive&&(this.activityState===Z.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Z.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(Ae(this.session.getTabId())),this.messages.unshift(Fe(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:le.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{rr(()=>{var e;this.messages.unshift(Ae(this.session.getTabId())),this.messages.unshift(Fe(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(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId())),this.bufferedMessages2.push(Fe(this.timestamp())),this.bufferedMessages2.push(Ae(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Z.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var n;(n=this.worker)==null||n.postMessage(e),this.commitCallbacks.forEach(s=>s(e)),e.length=0}timestamp(){return pe()+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?bs(e,n,s,r):null,l=()=>e?vs(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,a=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${n}/session/${s}`);if(e!=null&&e.withCurrentTime){const h=pe()-i;return`${a}?jumpto=${h}`}return a}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,n;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((n=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:n.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const n=new URL(this.getBaseHref());return n.pathname+="/"+new URL(e).pathname,n.pathname.replace(/\/+/g,"/"),n.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===Z.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const n=this.sessionStorage.getItem(this.options.session_reset_key)!==null,s=e||n,i=this.session.getSessionToken();return s||!i}async coldStart(e={},n){this.singleBuffer=!1;const s=1e3,i=this.checkSessionToken(e.forceNew);n&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,Wt(),this.coldStartTs=pe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(Fe(this.timestamp())),this.bufferedMessages2.push(Ae(this.session.getTabId()))),this.stop(!1),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(bt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,v;this.conditionsManager=new Xi(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:pe(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Zt,jsHeapSizeLimit:en,timezone:un(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,projectID:c}=await n.json();this.session.assign({projectID:c}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});const d={sessionToken:s,userUUID:"",sessionID:""};this.startCallbacks.forEach(S=>S(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),(v=this.conditionsManager)==null||v.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);Wt(),this.coldStartTs=pe();const i=this.localStorage.getItem(hn);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(hn)}this.bufferedMessages1.push(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId())),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),s||this.send(bt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(hn,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,v;this.stop(!1);const e=pe();(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:Zt,jsHeapSizeLimit:en,timezone:un()})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,beaconSizeLimit:c,projectID:d}=await n.json();for((v=this.worker)==null||v.postMessage({type:"auth",token:s,beaconSizeLimit:c}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},n=!1,s){const i=this.activityState===Z.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const a="No worker found: perhaps, CSP is not set.";return this.signalError(a,[]),Promise.resolve(_e(a))}if(this.activityState===Z.Active||this.activityState===Z.Starting)return Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Z.Starting,i||Wt(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=pe();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 a=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:Zt,jsHeapSizeLimit:en,timezone:un(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(a.status!==200){const C=await a.text(),M=C===Ye?Ye:`Server error: ${a.status}. ${C}`;return _e(M)}if(!this.worker){const C="no worker found after start request (this should not happen in real world)";return this.signalError(C,[]),_e(C)}const{token:h,userUUID:c,projectID:d,beaconSizeLimit:p,compressionThreshold:v,delay:S,sessionID:y,startTimestamp:T,userBrowser:F,userCity:B,userCountry:A,userDevice:k,userOS:N,userState:O,canvasEnabled:D,canvasQuality:I,canvasFPS:E,assistOnly:P}=await a.json();if(typeof h!="string"||typeof c!="string"||typeof T!="number"&&typeof T<"u"||typeof y!="string"||typeof S!="number"||typeof p!="number"&&typeof p<"u"){const C=`Incorrect server response: ${JSON.stringify(a)}`;return this.signalError(C,[]),_e(C)}this.delay=S,this.session.setSessionToken(h),this.session.setUserInfo({userBrowser:F,userCity:B,userCountry:A,userDevice:k,userOS:N,userState:O}),this.session.assign({sessionID:y,timestamp:T||r,projectID:d}),P?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:h,beaconSizeLimit:p}),!l&&h===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(bt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([C,M])=>this.send(Ss(C,M))),this.localStorage.setItem(this.options.local_uuid_key,c),this.compressionThreshold=v;const G={sessionToken:h,userUUID:c,sessionID:y};if(this.startCallbacks.forEach(C=>C(G)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,h),this.activityState=Z.Active,D&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new ho(this,{fps:E,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 co(this,Hs);let j;const $=this.localStorage.getItem(Hs);if($&&(j=parseInt($,10)),location!=null&&location.search){const C=new URLSearchParams(location.search);if(C.has("oruxt")){const M=C.get("oruxt");j=M?parseInt(M,10):void 0}}return j&&(this.uxtManager.isActive?this.onUxtCb.forEach(C=>C(j)):this.uxtManager.getTest(j,h,!!$).then(C=>{C&&this.onUxtCb.forEach(M=>M(C))})),To(G)}catch(a){if(this.stop(),this.session.reset(),a===Ye)return this.signalError(Ye,[]),_e(Ye);this._debug("session_start",a);const h=a instanceof Error?a.message:a.toString();return this.signalError(h,[]),_e(h)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const n=()=>{this.canStart?e(!0):setTimeout(n,25)};n()})}async waitStarted(){return new Promise(e=>{const n=()=>{this.activityState===Z.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Z.Active||this.activityState===Z.Starting?Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(n=>{const s=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",s),n(this._start(...e)))};document.addEventListener("visibilitychange",s)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const n=e;return(s,i,r="down")=>{typeof s!="string"||typeof i!="string"||i.length>5*1024*1024||s.length>255||this.send(Fr("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Z.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(s=>s()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(n=this.canvasRecorder)==null||n.clear()}finally{this.activityState=Z.NotActive}}};function Co(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(Er(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const Ws=be&&"InstallTrigger"in window?t=>t.message+`
|
|
652
|
+
We appreciate your time and valuable input.`),r=U("div","end_button_or",Fs,"Submitting Feedback"),o=ro();r.appendChild(o),(h=this.test)!=null&&h.reqMic||(c=this.test)!=null&&c.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 js(t){return!!t&&t.nodeType!=null}function sn(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function ke(t){return t.nodeType===Node.ELEMENT_NODE}function lo(t){return t.nodeType===Node.COMMENT_NODE}function rn(t){return t.nodeType===Node.TEXT_NODE}function wt(t){return t.nodeType===Node.DOCUMENT_NODE}function St(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Q(t,e){return t.localName===e}class ho{constructor(e,n){this.app=e,this.options=n,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=s=>{const i=this.app.nodes.getID(s);if(!i||!Q(s,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!Q(s,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.forEach(a=>{a.isIntersecting&&(a.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(a.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=Lr(i.toString(),r);this.app.send(o);const l=h=>{uo(h,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=[]))})},a=setInterval(()=>{const h=this.app.nodes.getID(s),c=h?this.app.nodes.getNode(h):void 0;!c||!Q(c,"canvas")||c!==s?(this.app.debug.log("Canvas element not in sync"),clearInterval(a)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(c)}):l(c))},this.interval);this.intervals.push(a)},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&&fo(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 Us={low:.35,medium:.55,high:.8};function uo(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 a=n.getContext("2d");if(!a)return"";a.clearRect(0,0,n.width,n.height),a.drawImage(t,0,0,n.width,n.height),n.toBlob(r,o,Us[e])}else t.toBlob(r,o,Us[e])}function fo(t,e){const n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=e,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const Xe={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class po{constructor(e=Xe.Silent){this.shouldLog=n=>this.level>=n,this.log=(...n)=>{this.shouldLog(Xe.Log)&&console.log(...n)},this.warn=(...n)=>{this.shouldLog(Xe.Warnings)&&console.warn(...n)},this.error=(...n)=>{this.shouldLog(Xe.Errors)&&console.error(...n)},this.level=e}}class go{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;bs(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=>vs(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 on(t){if(lo(t))return!0;if(rn(t))return!1;if(!ke(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const n=t.getAttribute("rel"),s=t.getAttribute("as");return!(n!=null&&n.includes("stylesheet")||s==="style"||s==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function an(t){return St(t)?!0:!on(t)}var ve;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(ve||(ve={}));class cn{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=ms(this.app.safe(s=>{for(const i of s){const r=i.target,o=i.type;if(!an(r))continue;if(o==="childList"){for(let a=0;a<i.removedNodes.length;a++)an(i.removedNodes[a])&&this.bindNode(i.removedNodes[a]);for(let a=0;a<i.addedNodes.length;a++)this.bindTree(i.addedNodes[a]);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 a=i.attributeName;if(a===null)continue;let h=this.attributesMap.get(l);h===void 0&&this.attributesMap.set(l,h=new Set),h.add(a);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(sn(n)){s.substr(0,6)==="xlink:"&&(s=s.substr(6)),i===null?this.app.send(ws(e,s)):s==="href"?(i.length>1e5&&(i=""),this.app.send(Kt(e,s,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,s,i);return}if(!(s==="src"||s==="srcset"||s==="integrity"||s==="crossorigin"||s==="autocomplete"||s.substr(0,2)==="on")&&!(s==="value"&&Q(n,"input")&&n.type!=="button"&&n.type!=="reset"&&n.type!=="submit")){if(i===null){this.app.send(ws(e,s));return}if(s==="style"||s==="href"&&Q(n,"link")){this.app.send(Kt(e,s,i,this.app.getBaseHref()));return}(s==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,s,i)}}sendNodeData(e,n,s){if(Q(n,"style")){this.app.send(Cr(e,s,this.app.getBaseHref()));return}s=this.app.sanitizer.sanitize(e,s),this.app.send(fr(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(!an(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),on(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(dr(n));const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>on(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(Mr(o))}}_commitNode(e,n){if(St(n))return!0;const s=n.parentNode;let i;if(!Q(n,"html")||!this.isTopContext){if(s===null)return this.unbindTree(n),!1;if(i=this.app.nodes.getID(s),i===void 0)return this.unbindTree(n),!1;if(!this.commitNode(i))return this.unbindTree(n),!1;if(this.app.sanitizer.handleNode(e,i,n),this.app.sanitizer.isHidden(i))return!1}let r=n.previousSibling;for(;r!==null;){const 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 o=this.recents.get(e),l=o===ve.New,a=this.indexes[e];if(a===void 0)throw"commitNode: missing node index";if(l){if(ke(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(lr(e,i,a,c.tagName,sn(n)))}for(let d=0;d<c.attributes.length;d++){const p=c.attributes[d];this.sendNodeAttribute(e,c,p.nodeName,p.value)}}else rn(n)&&(this.app.send(hr(e,i,a)),this.sendNodeData(e,s,n.data));return!0}o===ve.Removed&&i!==void 0&&this.app.send(ur(e,i,a));const h=this.attributesMap.get(e);if(h!==void 0){if(!ke(n))throw"commitNode: node is not an element";for(const c of h)this.sendNodeAttribute(e,n,c,n.getAttribute(c))}if(this.textSet.has(e)){if(!rn(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 zs extends cn{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(Jt(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(Jt(e,s))})}}class mo extends cn{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(Jt(s,i))})}}class bo{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 a;s.removeEventListener("scroll",o),(a=s.defaultView)==null||a.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 ln=be?Element.prototype.attachShadow:()=>new ShadowRoot;class vo extends cn{constructor(e,n){super(e,!0),this.iframeOffsets=new bo,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},n),this.app.nodes.attachNodeCallback(s=>{Q(s,"iframe")&&(this.options.captureIFrames&&!Re(s,"obscured")||Re(s,"capture"))&&this.handleIframe(s)}),this.app.nodes.attachNodeCallback(s=>{ke(s)&&s.shadowRoot!==null&&this.handleShadowRoot(s.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let n=null;const s=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!er(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==n){const l=new zs(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 mo(this.app);this.shadowRootObservers.push(n),n.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const n=ln.apply(this,arguments);return e.handleShadowRoot(n),n},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(cr()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,n){const s=this;Element.prototype.attachShadow=function(){const r=ln.apply(this,arguments);return s.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(n);const i=new zs(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=ln,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var xt;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(xt||(xt={}));const yo=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class wo{constructor(e,n){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},n)}handleNode(e,n,s){if((this.obscured.has(n)||ke(s)&&(Re(s,"masked")||Re(s,"obscured")))&&this.obscured.add(e),(this.hidden.has(n)||ke(s)&&(Re(s,"htmlmasked")||Re(s,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&ke(s)){const i=this.options.domSanitizer(s);i===xt.Obscured&&this.obscured.add(e),i===xt.Hidden&&this.hidden.add(e)}}sanitize(e,n){return this.obscured.has(e)?yo(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`${qt(i)}@${qt(o)}.${qt(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 So{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=tr(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 xo(t,e){let n=0;return()=>{n++>=e&&(n=0,t())}}class ko{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?xo(e,n):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ye="canceled",Hs="or_uxt_active",hn="or_buffer_1",_e=t=>({reason:t,success:!1}),To=t=>({...t,success:!0});var Z;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(Z||(Z={}));const $s="https://api.openreplay.com/ingest";function un(){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 Eo=t=>new Promise(e=>setTimeout(e,t)),le={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 Io=class{constructor(e,n,s,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=Z.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var a;(a=this.canvasRecorder)==null||a.restartTracking()},this.flushBuffer=async a=>new Promise(h=>{let c=!1;const d=[a.shift()];for(;!c;){const p=a[0];!p||p[0]===0?c=!0:d.push(a.shift())}this.postToWorker(d),h(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(s).findIndex(a=>["fixedCanvasScaling","disableCanvas"].includes(a))!==-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:$s,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Xe.Silent,__save_canvas_locally:!1,localStorage:null,sessionStorage:null,disableStringDict:!1,forceSingleTab:!1,assistSocketHost:"",fixedCanvasScaling:!1,disableCanvas:!1,captureIFrames:!0,obscureTextEmails:!0,obscureTextNumbers:!1,crossdomain:{parentDomain:"*"},canvas:{disableCanvas:!1,fixedCanvasScaling:!1,__save_canvas_locally:!1,useAnimationFrame:!1}};if(this.options=ys(o,s),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const a=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${a}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new wo(this,s),this.nodes=new go(this.options.node_id),this.observer=new vo(this,s),this.ticker=new ko(this),this.ticker.attach(()=>this.commit()),this.debug=new po(this.options.__debug__),this.session=new So(this,this.options),this.attributeSender=new Ki(this,!!this.options.disableStringDict),this.featureFlags=new Yi(this),this.tagWatcher=new Ur(this.sessionStorage,this.debug.error,a=>{this.send(Pr(a))}),this.session.attachUpdateCallback(({userID:a,metadata:h})=>{a!=null&&this.send(xr(a)),h!=null&&Object.entries(h).forEach(([c,d])=>this.send(Ss(c,d)))}),n!=null&&this.session.applySessionHash(n),this.initWorker();const l=this.session.getTabId();if(this.insideIframe){const a=c=>{const{data:d}=c;d.line===le.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",a),this.attachStopCallback(()=>{window.removeEventListener("message",a)});const h=this.initialHostName;window.parent.postMessage({line:le.iframeSignal,source:l,context:this.contextId,domain:h},"*")}else{let a=0;const h=c=>{const{data:d}=c;if(d.line===le.iframeSignal){const p=d.domain,v=Array.from(document.querySelectorAll("iframe"));this.pageFrames=v,(async()=>{let y=0;for(;y<10;){const T=this.checkNodeId(v,p);if(T){this.waitStarted().then(()=>{var A;a++;const F=this.session.getSessionToken(),B={line:le.iframeId,context:this.contextId,domain:p,id:T,token:F,frameOrderNumber:a};this.debug.log("iframe_data",B),(A=c.source)==null||A.postMessage(B,"*")}).catch(console.error),y=10;break}y++,await Eo(100)}})()}if(d.line===le.iframeBatch){const v=d.messages.map(S=>{if(S[0]===20){let y=S;return this.pageFrames.forEach(T=>{if(T.dataset.domain===c.data.domain){const[F,B,A]=S,{left:k,top:N}=T.getBoundingClientRect();y=[F,B+k,A+N]}}),y}if(S[0]===68){let y=S;return this.pageFrames.forEach(T=>{if(T.dataset.domain===c.data.domain){const[F,B,A,k,N,O,D]=S,{left:I,top:E,width:P,height:G}=T.getBoundingClientRect(),j=document.documentElement.scrollWidth,$=document.documentElement.scrollHeight,C=O/100*P+I,M=D/100*G+E,V=C/j,K=M/$;y=[F,B,A,k,N,Math.round(V*1e3)/10,Math.round(K*1e3)/10]}}),y}return S});this.messages.push(...v)}};window.addEventListener("message",h),this.attachStopCallback(()=>{window.removeEventListener("message",h)})}this.bc!==null&&(this.bc.postMessage({line:le.ask,source:l,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=a=>{if(a.data.context!==this.contextId){if(a.data.line===le.resp){const h=a.data.token;this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===le.reg){const h=a.data.token;this.session.regenerateTabId(),this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===le.ask){const h=this.session.getSessionToken();h&&this.bc&&this.bc.postMessage({line:a.data.source===l?le.reg:le.resp,token:h,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?qi(e.batch,{mtime:0},(r,o)=>{var l,a;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.postMessage({type:"uncompressed",batch:s})):(a=this.worker)==null||a.postMessage({type:"compressed",batch:o})}):(n=this.worker)==null||n.postMessage({type:"uncompressed",batch:s})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,n){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${n}`})}),this.debug.error("OpenReplay error: ",e,n)}send(e,n=!1){var s;this.activityState!==Z.NotActive&&(this.activityState===Z.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(s=this.conditionsManager)==null||s.processMessage(e)):this.messages.push(e),this.activityState===Z.Active&&n&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(Ae(this.session.getTabId())),this.messages.unshift(Fe(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:le.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{rr(()=>{var e;this.messages.unshift(Ae(this.session.getTabId())),this.messages.unshift(Fe(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(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId())),this.bufferedMessages2.push(Fe(this.timestamp())),this.bufferedMessages2.push(Ae(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===Z.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var n;(n=this.worker)==null||n.postMessage(e),this.commitCallbacks.forEach(s=>s(e)),e.length=0}timestamp(){return pe()+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?bs(e,n,s,r):null,l=()=>e?vs(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,a=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${n}/session/${s}`);if(e!=null&&e.withCurrentTime){const h=pe()-i;return`${a}?jumpto=${h}`}return a}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,n;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((n=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:n.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const n=new URL(this.getBaseHref());return n.pathname+="/"+new URL(e).pathname,n.pathname.replace(/\/+/g,"/"),n.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===Z.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const n=this.sessionStorage.getItem(this.options.session_reset_key)!==null,s=e||n,i=this.session.getSessionToken();return s||!i}async coldStart(e={},n){this.singleBuffer=!1;const s=1e3,i=this.checkSessionToken(e.forceNew);n&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,Wt(),this.coldStartTs=pe(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(Fe(this.timestamp())),this.bufferedMessages2.push(Ae(this.session.getTabId()))),this.stop(!1),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(bt(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*s),r()}async setupConditionalStart(e){var p,v;this.conditionsManager=new Ji(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:pe(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:Zt,jsHeapSizeLimit:en,timezone:un(),width:window.screen.width,height:window.screen.height})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,projectID:c}=await n.json();this.session.assign({projectID:c}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});const d={sessionToken:s,userUUID:"",sessionID:""};this.startCallbacks.forEach(S=>S(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),(v=this.conditionsManager)==null||v.processFlags(this.featureFlags.flags)}offlineRecording(e={},n){this.onSessionSent=n,this.singleBuffer=!0;const s=this.checkSessionToken(e.forceNew);Wt(),this.coldStartTs=pe();const i=this.localStorage.getItem(hn);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(hn)}this.bufferedMessages1.push(Fe(this.timestamp())),this.bufferedMessages1.push(Ae(this.session.getTabId())),this.activityState=Z.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),s||this.send(bt(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(hn,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var p,v;this.stop(!1);const e=pe();(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:Zt,jsHeapSizeLimit:en,timezone:un()})}),{token:s,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,beaconSizeLimit:c,projectID:d}=await n.json();for((v=this.worker)==null||v.postMessage({type:"auth",token:s,beaconSizeLimit:c}),this.session.assign({projectID:d}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},n=!1,s){const i=this.activityState===Z.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const a="No worker found: perhaps, CSP is not set.";return this.signalError(a,[]),Promise.resolve(_e(a))}if(this.activityState===Z.Active||this.activityState===Z.Starting)return Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=Z.Starting,i||Wt(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=pe();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 a=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:Zt,jsHeapSizeLimit:en,timezone:un(),condition:s,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(a.status!==200){const C=await a.text(),M=C===Ye?Ye:`Server error: ${a.status}. ${C}`;return _e(M)}if(!this.worker){const C="no worker found after start request (this should not happen in real world)";return this.signalError(C,[]),_e(C)}const{token:h,userUUID:c,projectID:d,beaconSizeLimit:p,compressionThreshold:v,delay:S,sessionID:y,startTimestamp:T,userBrowser:F,userCity:B,userCountry:A,userDevice:k,userOS:N,userState:O,canvasEnabled:D,canvasQuality:I,canvasFPS:E,assistOnly:P}=await a.json();if(typeof h!="string"||typeof c!="string"||typeof T!="number"&&typeof T<"u"||typeof y!="string"||typeof S!="number"||typeof p!="number"&&typeof p<"u"){const C=`Incorrect server response: ${JSON.stringify(a)}`;return this.signalError(C,[]),_e(C)}this.delay=S,this.session.setSessionToken(h),this.session.setUserInfo({userBrowser:F,userCity:B,userCountry:A,userDevice:k,userOS:N,userState:O}),this.session.assign({sessionID:y,timestamp:T||r,projectID:d}),P?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:h,beaconSizeLimit:p}),!l&&h===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(bt(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([C,M])=>this.send(Ss(C,M))),this.localStorage.setItem(this.options.local_uuid_key,c),this.compressionThreshold=v;const G={sessionToken:h,userUUID:c,sessionID:y};if(this.startCallbacks.forEach(C=>C(G)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,h),this.activityState=Z.Active,D&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new ho(this,{fps:E,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 co(this,Hs);let j;const $=this.localStorage.getItem(Hs);if($&&(j=parseInt($,10)),location!=null&&location.search){const C=new URLSearchParams(location.search);if(C.has("oruxt")){const M=C.get("oruxt");j=M?parseInt(M,10):void 0}}return j&&(this.uxtManager.isActive?this.onUxtCb.forEach(C=>C(j)):this.uxtManager.getTest(j,h,!!$).then(C=>{C&&this.onUxtCb.forEach(M=>M(C))})),To(G)}catch(a){if(this.stop(),this.session.reset(),a===Ye)return this.signalError(Ye,[]),_e(Ye);this._debug("session_start",a);const h=a instanceof Error?a.message:a.toString();return this.signalError(h,[]),_e(h)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const n=()=>{this.canStart?e(!0):setTimeout(n,25)};n()})}async waitStarted(){return new Promise(e=>{const n=()=>{this.activityState===Z.Active?e(!0):setTimeout(n,25)};n()})}async start(...e){return this.activityState===Z.Active||this.activityState===Z.Starting?Promise.resolve(_e("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(n=>{const s=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",s),n(this._start(...e)))};document.addEventListener("visibilitychange",s)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const n=e;return(s,i,r="down")=>{typeof s!="string"||typeof i!="string"||i.length>5*1024*1024||s.length>255||this.send(Fr("websocket",n,i,this.timestamp(),r,s))}}stop(e=!0){var n;if(this.activityState!==Z.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(s=>s()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(n=this.canvasRecorder)==null||n.clear()}finally{this.activityState=Z.NotActive}}};function Co(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const n=()=>t.send(Er(Math.round(e.downlink*1e3),e.type||"unknown"));n(),e.addEventListener("change",n)}const Ws=be&&"InstallTrigger"in window?t=>t.message+`
|
|
649
653
|
`+t.stack:t=>t.stack||t.message;function dn(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?Ws(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function _o(t){return typeof t!="number"?"NaN":t.toString()}function No(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function qs(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return Ws(t);if(Array.isArray(t)){const e=t.length,n=t.slice(0,10).map(dn).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+": "+dn(i))}return"{"+e.join(", ")+"}"}return t.toString()}function Oo(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 qs(s);case"s":return dn(s);case"f":return _o(s);case"d":case"i":return No(s);default:return e}})),t.map(qs).join(" ")}const Vs=["log","info","warn","error","debug","assert"];function Ro(t,e){const n=Object.assign({consoleMethods:Vs,consoleThrottling:30},e);if(!Array.isArray(n.consoleMethods)||n.consoleMethods.length===0)return;const s=t.safe((a,h)=>t.send(vr(a,Oo(h))));let i=0;const r=()=>{i=0};t.attachStartCallback(r),t.ticker.attach(r,33,!1);const o=(a,h)=>{const c={apply:function(d,p,v){Reflect.apply(d,h,v),i=i+1,!(i>n.consoleThrottling)&&s(d.name,v)}};n.consoleMethods.forEach(d=>{if(Vs.indexOf(d)===-1){t.debug.error(`OpenReplay: unsupported console method "${d}"`);return}const p=h.console[d];a[d]=new Proxy(p,c)})},l=t.safe(a=>o(a.console,a));l(window),t.observer.attachContextCallback(l)}var Gs={exports:{}},fn={exports:{}},Ks;function Fo(){return Ks||(Ks=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"],a=["args"],h=["evalOrigin"],c=r.concat(o,l,a,h);function d(y){if(y)for(var T=0;T<c.length;T++)y[c[T]]!==void 0&&this["set"+s(c[T])](y[c[T]])}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()||"",T=this.getLineNumber()||"",F=this.getColumnNumber()||"",B=this.getFunctionName()||"";return this.getIsEval()?y?"[eval] ("+y+":"+T+":"+F+")":"[eval]:"+T+":"+F:B?B+" ("+y+":"+T+":"+F+")":y+":"+T+":"+F}},d.fromString=function(T){var F=T.indexOf("("),B=T.lastIndexOf(")"),A=T.substring(0,F),k=T.substring(F+1,B).split(","),N=T.substring(B+1);if(N.indexOf("@")===0)var O=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(N,""),D=O[1],I=O[2],E=O[3];return new d({functionName:A,args:k||void 0,fileName:D,lineNumber:I||void 0,columnNumber:E||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(T){this[y]=!!T}}(r[p]);for(var v=0;v<o.length;v++)d.prototype["get"+s(o[v])]=i(o[v]),d.prototype["set"+s(o[v])]=function(y){return function(T){if(!n(T))throw new TypeError(y+" must be a Number");this[y]=Number(T)}}(o[v]);for(var S=0;S<l.length;S++)d.prototype["get"+s(l[S])]=i(l[S]),d.prototype["set"+s(l[S])]=function(y){return function(T){this[y]=String(T)}}(l[S]);return d})}(fn)),fn.exports}(function(t,e){(function(n,s){t.exports=s(Fo())})(Me,function(s){var i=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,o=/^(eval@)?(\[native code])?$/;return{parse:function(a){if(typeof a.stacktrace<"u"||typeof a["opera#sourceloc"]<"u")return this.parseOpera(a);if(a.stack&&a.stack.match(r))return this.parseV8OrIE(a);if(a.stack)return this.parseFFOrSafari(a);throw new Error("Cannot parse given Error object")},extractLocation:function(a){if(a.indexOf(":")===-1)return[a];var h=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=h.exec(a.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(a){var h=a.stack.split(`
|
|
650
654
|
`).filter(function(c){return!!c.match(r)},this);return h.map(function(c){c.indexOf("(eval ")>-1&&(c=c.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var d=c.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),p=d.match(/ (\(.+\)$)/);d=p?d.replace(p[0],""):d;var v=this.extractLocation(p?p[1]:d),S=p&&d||void 0,y=["eval","<anonymous>"].indexOf(v[0])>-1?void 0:v[0];return new s({functionName:S,fileName:y,lineNumber:v[1],columnNumber:v[2],source:c})},this)},parseFFOrSafari:function(a){var h=a.stack.split(`
|
|
651
655
|
`).filter(function(c){return!c.match(o)},this);return h.map(function(c){if(c.indexOf(" > eval")>-1&&(c=c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),c.indexOf("@")===-1&&c.indexOf(":")===-1)return new s({functionName:c});var d=/((.*".+"[^@]*)?[^@]*)(?:@)/,p=c.match(d),v=p&&p[1]?p[1]:void 0,S=this.extractLocation(c.replace(d,""));return new s({functionName:v,fileName:S[0],lineNumber:S[1],columnNumber:S[2],source:c})},this)},parseOpera:function(a){return!a.stacktrace||a.message.indexOf(`
|
|
@@ -654,9 +658,9 @@ We appreciate your time and valuable input.`),r=U("div","end_button_or",Fs,"Subm
|
|
|
654
658
|
`).length?this.parseOpera9(a):a.stack?this.parseOpera11(a):this.parseOpera10(a)},parseOpera9:function(a){for(var h=/Line (\d+).*script (?:in )?(\S+)/i,c=a.message.split(`
|
|
655
659
|
`),d=[],p=2,v=c.length;p<v;p+=2){var S=h.exec(c[p]);S&&d.push(new s({fileName:S[2],lineNumber:S[1],source:c[p]}))}return d},parseOpera10:function(a){for(var h=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,c=a.stacktrace.split(`
|
|
656
660
|
`),d=[],p=0,v=c.length;p<v;p+=2){var S=h.exec(c[p]);S&&d.push(new s({functionName:S[3]||void 0,fileName:S[2],lineNumber:S[1],source:c[p]}))}return d},parseOpera11:function(a){var h=a.stack.split(`
|
|
657
|
-
`).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return h.map(function(c){var d=c.split("@"),p=this.extractLocation(d.pop()),v=d.shift()||"",S=v.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;v.match(/\(([^)]*)\)/)&&(y=v.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var T=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:S,args:T,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:c})},this)}}})})(Gs);var Ao=Gs.exports;const Do=Vn(Ao);function Xs(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function kt(t,e,n={}){let s=e;try{s=Do.parse(t)}catch{}return Yt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function Js(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return kt(t.error,Xs(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),Yt(s,i,JSON.stringify(Xs(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return kt(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return Yt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function Mo(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(o){const l=Js(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 Ys(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 Lo(t){return Qi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const Po="https://static.openreplay.com/tracker/placeholder.jpeg";function Bo(t){function e(l,a){t.attributeSender.sendSetAttribute(l,"src",Po);const{width:h,height:c}=a.getBoundingClientRect();a.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(h)),a.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(c))}const n=function(l,a){const{srcset:h}=a;if(!h)return;const c=h.split(h.match(/,\s+/)?/,\s+/:",").map(d=>Ys(d)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",c)},s=function(l,a){a.src.length>Zi&&e(l,a),t.send(Kt(l,"src",a.src,t.getBaseHref()))},i=t.safe(function(l){const a=Ys(l.src||"");fs(a)&&t.send(_s(t.timestamp(),0,0,0,0,0,a,"img",0,!1))}),r=t.safe(function(l){const a=t.nodes.getID(l);a!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!Lo(l.src)?i(l):t.sanitizer.isHidden(a)||t.sanitizer.isObscured(a)?e(a,l):(s(a,l),n(a,l)))}),o=ms(t.safe(l=>{for(const a of l)if(a.type==="attributes"){const h=a.target,c=t.nodes.getID(h);if(c===void 0)return;a.attributeName==="src"&&s(c,h),a.attributeName==="srcset"&&n(c,h)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(l=>{Q(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 jo=["text","password","email","search","number","range","date","tel","time"];function Uo(t){return Q(t,"textarea")?!0:Q(t,"input")?jo.includes(t.type):!1}function zo(t){if(!Q(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Ho=be&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.labels;if(n!==null&&n.length===1)return n[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.id;if(n){const s=t.ownerDocument.querySelectorAll('label[for="'+n+'"]');if(s!==null&&s.length===1)return s[0]}};function Qs(t){let e=Vt(t);if(e===null){const n=Ho(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return ds(e).slice(0,100)}const $e={Plain:0,Obscured:1,Hidden:2};function $o(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:$e.Obscured,obscureInputDates:!1},e);function s(c,d){let p=d.value,v=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(c)?v=$e.Hidden:(t.sanitizer.isObscured(c)||v===$e.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(v=$e.Obscured);let S=0;switch(v){case $e.Hidden:S=-1,p="";break;case $e.Obscured:S=p.length,p="";break}return{value:p,mask:S}}function i(c,d){const{value:p,mask:v}=s(c,d);t.send(gr(c,p,v))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function l(c,d){r.get(c)!==d.value&&(r.set(c,d.value),i(c,d))}function a(c,d){o.get(c)!==d&&(o.set(c,d),t.send(mr(c,d)))}t.ticker.attach(()=>{r.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);l(d,p)}),o.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return o.delete(d);a(d,p.checked)})},3);function h(c,d,p,v){const{value:S,mask:y}=s(c,d),T=Qs(d);t.send(Ar(c,S,y!==0,T,p,v))}t.nodes.attachNodeCallback(t.safe(c=>{const d=t.nodes.getID(c);if(d!==void 0){if(Q(c,"select")&&(i(d,c),t.nodes.attachNodeListener(c,"change",()=>i(d,c))),Uo(c)){l(d,c);let p=0,v=0,S=0;const y=()=>{p=pe()},T=()=>{v===0&&p!==0&&(v=pe()-p)},F=()=>{p!==0&&(S=pe()-p),h(d,c,v,S),v=0,S=0,p=0};t.nodes.attachNodeListener(c,"focus",y),t.nodes.attachNodeListener(c,"input",T),t.nodes.attachNodeListener(c,"change",F);return}if(zo(c)){a(d,c.checked),t.nodes.attachNodeListener(c,"change",()=>a(d,c.checked));return}}}))}let he,pn,Zs;function Wo(t,e){if(Zs=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};he={...n,...e},pn=qo(he.root,n);let s=Tt(t,"all",()=>Tt(t,"two",()=>Tt(t,"one",()=>Tt(t,"none"))));if(s){const i=ri(oi(s,t));return i.length>0&&(s=i[0]),Et(s)}else throw new Error("Selector was not found.")}function qo(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Tt(t,e,n){let s=null,i=[],r=t,o=0;for(;r;){const l=new Date().getTime()-Zs.getTime();if(he.timeoutMs!==void 0&&l>he.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let a=Ct(Vo(r))||Ct(...Go(r))||Ct(...Ko(r))||Ct(Xo(r))||[si()];const h=Jo(r);if(e=="all")h&&(a=a.concat(a.filter(gn).map(c=>It(c,h))));else if(e=="two")a=a.slice(0,1),h&&(a=a.concat(a.filter(gn).map(c=>It(c,h))));else if(e=="one"){const[c]=a=a.slice(0,1);h&&gn(c)&&(a=[It(c,h)])}else e=="none"&&(a=[si()],h&&(a=[It(a[0],h)]));for(let c of a)c.level=o;if(i.push(a),i.length>=he.seedMinLength&&(s=ei(i,n),s))break;r=r.parentElement,o++}return s||(s=ei(i,n)),!s&&n?n():s}function ei(t,e){const n=ri(ii(t));if(n.length>he.threshold)return e?e():null;for(let s of n)if(ni(s))return s;return null}function Et(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 ti(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function ni(t){const e=Et(t);switch(pn.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 Vo(t){const e=t.getAttribute("id");return e&&he.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Go(t){return Array.from(t.attributes).filter(n=>he.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Ko(t){return Array.from(t.classList).filter(he.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Xo(t){const e=t.tagName.toLowerCase();return he.tagName(e)?{name:e,penalty:2}:null}function si(){return{name:"*",penalty:3}}function Jo(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 It(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function gn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Ct(...t){const e=t.filter(Yo);return e.length>0?e:null}function Yo(t){return t!=null}function*ii(t,e=[]){if(t.length>0)for(let n of t[0])yield*ii(t.slice(1,t.length),e.concat(n));else yield e}function ri(t){return[...t].sort((e,n)=>ti(e)-ti(n))}function*oi(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>he.optimizedMinLength)for(let s=1;s<t.length-1;s++){if(n.counter>he.maxNumberOfTries)return;n.counter+=1;const i=[...t];i.splice(s,1);const r=Et(i);if(n.visited.has(r))return;ni(i)&&Qo(i,e)&&(yield i,n.visited.set(r,!0),yield*oi(i,e,n))}}function Qo(t,e){return pn.querySelector(Et(t))===e}function Zo(t,e,n){return Wo(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 mn(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 ai(t,e){return t instanceof Element?ea(t,e):null}function ea(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Re(n,"masked"))return null;n=n.parentElement}if(sn(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"||mn(n)||Vt(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function ta(t,e){const{disableClickmaps:n=!1}=e||{};function s(k){const N=Vt(k);if(N!==null)return N;if(Q(k,"input"))return Qs(k);if(mn(k)){let O="";return k instanceof HTMLElement&&(O=t.sanitizer.getInnerTextSecure(k)),O=O||k.id||k.className,ds(O).slice(0,100)}return""}let i=-1,r=-1,o=!1,l=null,a=0,h={},c=0,d=0,p=0,v=0,S;const y=.008,T=225;function F(){const k=v/T;if(!c){c=k;return}const N=(k-c)/T;p>4&&N>y&&t.send(Dr(pe())),v=0,p=0,c=k}t.attachStartCallback(()=>{S=setInterval(()=>F(),T)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,l=null,h={},S&&clearInterval(S)});const B=()=>{o&&(t.send(br(i,r)),o=!1)},A=(k,N=!1)=>{function O(I,E,P){return h[I]=h[I]||Zo(E,k,P)}const D=N?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);D(k.documentElement,"mouseover",I=>{const E=ai(I.target,k);E!==l&&(l=E,a=performance.now())}),D(k,"mousemove",I=>{const[E,P]=t.observer.getDocumentOffset(k);i=I.clientX+E,r=I.clientY+P,o=!0;const G=Math.sign(I.movementX);v+=Math.abs(I.movementX)+Math.abs(I.movementY),G!==d&&(d=G,p++)},!1),D(k,"click",I=>{const E=ai(I.target,k);if(!I.clientX&&!I.clientY||E===null)return;const P=t.nodes.getID(E);if(P!==void 0){const G=I.pageX,j=I.pageY,$=k.documentElement.scrollWidth,C=k.documentElement.scrollHeight,M=ci(G/$),q=ci(j/C);B(),t.send(Or(P,l===E?Math.round(performance.now()-a):0,s(E),mn(E)&&!n?O(P,E,e):"",M,q),!0)}l=null})};t.nodes.attachNodeCallback(k=>{wt(k)&&A(k)}),A(document,!0),t.ticker.attach(B,(e==null?void 0:e.trackingOffset)||7)}function ci(t){return Math.round(t*1e4)}function na(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let o="";if(Q(r,"img")&&(o=r.currentSrc||r.src),!o){const S=getComputedStyle(r).getPropertyValue("background-image");if(S){const y=s.exec(S);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 a=r.getBoundingClientRect(),h=Math.max(a.top,0),c=Math.max(a.left,0),d=Math.min(a.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),p=Math.min(a.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(d<=h||p<=c)continue;const v=(d-h)*(p-c);e.push({time:l,area:v})}return e}function sa(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 ia(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(h){var d;if(h.duration<0||!fs(h.name)||t.isServiceURL(h.name))return;s!==null&&(s[h.name]=h.startTime+h.duration);let c=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(h.name.startsWith(p)){c=!0;return}}),!c&&t.send(_s(h.startTime+Ue(),h.duration,h.responseStart&&h.startTime?h.responseStart-h.startTime:0,h.transferSize>h.encodedBodySize?h.transferSize-h.encodedBodySize:0,h.encodedBodySize||0,h.decodedBodySize||0,h.name,h.initiatorType,h.transferSize,h.responseStatus&&h.responseStatus===304||h.transferSize===0))}const r=new PerformanceObserver(h=>h.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:h}){h!==o&&(performance.getEntriesByType("resource").forEach(i),o=h),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,a=0;if(n.capturePageLoadTimings){let h=!1;t.ticker.attach(()=>{if(!h&&((l===0||a===0)&&performance.getEntriesByType("paint").forEach(c=>{const{name:d,startTime:p}=c;switch(d){case"first-paint":l=p;break;case"first-contentful-paint":a=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){h=!0;const{navigationStart:c,requestStart:d,responseStart:p,responseEnd:v,domContentLoadedEventStart:S,domContentLoadedEventEnd:y,loadEventStart:T,loadEventEnd:F}=performance.timing;t.send(yr(d-c||0,p-c||0,v-c||0,S-c||0,y-c||0,T-c||0,F-c||0,l,a))}},30)}if(n.capturePageRenderTimings){let h=0,c=0,d=0,p=null,v=!1;t.ticker.attach(()=>{if(v)return;const S=performance.now();if(s!==null&&(h=Math.max.apply(null,Object.keys(s).map(y=>s[y])),S-h>1e3&&(p=na(s),s=null)),d!==null&&(S-d>50&&(c=S),d=S-c>5e3?null:S),p!==null&&d===null||S>3e4){v=!0,s=null;const y=p===null?0:sa(a||l,p),{domContentLoadedEventEnd:T,navigationStart:F}=performance.timing,B=d===null?Math.max(c,a,T-F||0):0;t.send(wr(y,a>h?a:h,B))}})}}function bn(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 ra(t,e){let n=!1;const s=new Map;function i(l){js(l)&&(ke(l)&&s.set(l,[l.scrollLeft,l.scrollTop]),wt(l)&&s.set(l,bn(l)))}const r=t.safe(()=>{e||t.send(ar(...bn(document)))}),o=t.safe((l,a)=>{const h=t.nodes.getID(a);h!==void 0&&t.send(pr(h,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((l,a)=>{a&&(ke(l)&&l.scrollLeft+l.scrollTop>0?s.set(l,[l.scrollLeft,l.scrollTop]):wt(l)&&s.set(l,bn(l))),St(l)&&t.nodes.attachNodeListener(l,"scroll",h=>{i(h.target)})}),t.attachEventListener(document,"scroll",l=>{const a=l.target;if(a===document){n=!0;return}i(a)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(o),s.clear()},5,!1)}function oa(t){let e,n,s,i,r=document.referrer;const o=t.safe(()=>{const{URL:h}=document;h!==e&&(e=h,t.send(Br(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:h,innerHeight:c}=window;(h!==n||c!==s)&&(n=h,s=c,t.send(or(n,s)))}),a=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(Ir(document.hidden)));t.attachStartCallback(()=>{e=null,i=Ue(),n=s=-1,o(),l(),a()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",a,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(l,5,!1)}function li(t){return St(t)&&!!t.adoptedStyleSheets}let aa=15;function hi(){return aa++}const _t=new Map;function ca(t){if(t===null||!li(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 a=n.get(l);a||(a=[]);const h=[],c=o.adoptedStyleSheets;if(c&&Symbol.iterator in c)for(const d of c){let p=e.get(d);const v=!p;if(p||(p=hi(),e.set(d,p)),a.includes(p)||t.send(Is(p,l)),v){const S=d.cssRules;for(let y=0;y<S.length;y++)t.send(Jt(p,S[y].cssText,y,t.getBaseHref()))}h.push(p)}if(Symbol.iterator in a)for(const d of a)h.includes(d)||t.send(Rr(d,l));n.set(l,h)},20);function i(o){const l=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");l&&Object.defineProperty(o,"adoptedStyleSheets",{...l,set:function(a){const h=l.set.call(this,a);return s(this),h}})}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:a}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(h){return l.call(this,h).then(c=>{const d=e.get(this);return d&&t.send(Ts(d,h,t.getBaseHref())),c})},o.CSSStyleSheet.prototype.replaceSync=function(h){const c=e.get(this);return c&&t.send(Ts(c,h,t.getBaseHref())),a.call(this,h)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(o=>{li(o)&&s(o)})}function la(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(_r("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const l=_t.get(i);l&&(typeof o=="string"?t.send(Jt(l,o,r,t.getBaseHref())):t.send(Es(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=_t.get(o);if(!l){t.debug.warn("No sheedID found for",o,_t);return}const a=r.cssText,h=o.cssRules,c=Array.from(h).indexOf(r);c>=0?(t.send(Jt(l,a,c,t.getBaseHref())),t.send(Es(l,c+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:a}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(h,c=0){return e(this,c,h),r.call(this,h,c)},i.CSSStyleSheet.prototype.deleteRule=function(h){return e(this,h),o.call(this,h)},i.CSSGroupingRule.prototype.insertRule=function(h,c=0){const d=l.call(this,h,c);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(h=0){const c=a.call(this,h);return n(this),c}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Q(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,l=hi();_t.set(o,l),t.send(Is(l,r));const a=o.cssRules;for(let h=0;h<a.length;h++)e(o,h,a[h].cssText)})}function ha(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(ks(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Q(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{js(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(ks(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Q(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function ua(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 a=[o[0],o[1],l],h=e.get(s.document)||[];h.push(a),e.set(s.document,h);const c=s===window?0:t.nodes.getID(s.document);if(c===void 0)return;t.active()&&t.send(xs(c,...a))}super(...o)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!wt(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(xs(r,...o))})}))}function da(t,e,n,s,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(p){t.debug.log("Openreplay: capturing axios response data",p);const{headers:v,data:S,method:y,url:T,baseURL:F}=p.config,{data:B,headers:A,status:k,response:N}=p,{data:O,headers:D,status:I}=N||{},E=n.ignoreHeaders,P=Array.isArray(E)?z=>E.includes(z):()=>E;function G(z,b){P(b[0])||(z[b[0]]=b[1])}let j={},$={};v.toJSON?j=v.toJSON():v instanceof Headers?v.forEach((z,b)=>G(j,[b,z])):Array.isArray(v)?v.forEach(z=>G(j,z)):typeof v=="object"&&Object.entries(v).forEach(z=>G(j,z));const C=D||A;C.toJSON?$=C.toJSON():C instanceof Headers?C.forEach((z,b)=>G($,[b,z])):Array.isArray(C)?C.forEach(z=>G($,z)):typeof C=="object"&&Object.entries(C).forEach(([z,b])=>{P(z)||($[z]=b)});const M=s({url:T,method:y||"",status:k||I||0,request:{headers:j,body:S},response:{headers:$,body:O||B}});if(!M){t.debug.log("Openreplay: empty request/response info, skipping");return}const q=p.config.__openreplay_timing,K=performance.now()-q;t.debug.log("Openreplay: final req object",M),t.send(mt("xhr",String(y),String(M.url),i(M.request),i(M.response),M.status,q+Ue(),K,0))}function o(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const v=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",S=t.getSessionToken();S&&p.headers.set(v,S)}return p}function l(p){return n.failuresOnly||r(p),p}function a(p){return t.debug.log("Openreplay: capturing API request error",p),fa(p)&&p.response?r(p.response):p instanceof Error&&t.send(kt(p,[])),Promise.reject(p)}function h(p){t.debug.log("Openreplay: failed API request, skipping",p)}const c=e.interceptors.request.use(o,h,{synchronous:!0}),d=e.interceptors.response.use(l,a,{synchronous:!0});t.attachStopCallback(()=>{var p,v,S,y;(v=(p=e.interceptors.request).eject)==null||v.call(p,c),(y=(S=e.interceptors.response).eject)==null||y.call(S,d)})}function fa(t){return pa(t)&&t.isAxiosError===!0}function pa(t){return t!==null&&typeof t=="object"}var ye;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(ye||(ye={}));class vn{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 mt(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+Ue(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([s,i])=>{this.isHeaderIgnored(s)||(e[s]=i)}),this.setSessionTokenHeader((s,i)=>{e[s]=i});const n={};return Object.entries(this.header).forEach(([s,i])=>{this.isHeaderIgnored(s)||(n[s]=i)}),{reqHs:e,resHs:n}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(n=>n.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const Qe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:wn(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},yn=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(ma(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":wn(t)?e=t:e=`can't parse body ${typeof t}`;return e},ga=(t,e={})=>{wn(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 wn(t){return t!==null&&typeof t=="object"}function ma(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Nt(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const Sn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class ba{constructor(e,n){this.resp=e,this.item=n,this.mockReader()}set(e,n,s){return Reflect.set(e,n,s)}get(e,n){const s=Reflect.get(e,n);switch(n){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=n.toLowerCase(),s.apply(e).then(i=>(this.item.response=Qe(this.item.responseType,i),i)))}return typeof s=="function"?s.bind(e):s}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const n=this.resp.body.getReader;this.resp.body.getReader=()=>{const s=n.apply(this.resp.body);if(this.item.readyState===ye.DONE)return s;const i=s.read,r=s.cancel;return this.item.responseType="arraybuffer",s.read=()=>i.apply(s).then(o=>{if(!e)e=new Uint8Array(o.value);else{const 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=Nt(this.item.responseSize),o.done&&(this.item.response=Qe(this.item.responseType,e)),o}),s.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=Qe(this.item.responseType,e),r.apply(s,o)),s}}}class va{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 vn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((a,h)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(a,h);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(a,h):Array.isArray(s[1].headers)?s[1].headers.push([a,h]):s[1].headers[a]=h}}),e.apply(window,s).then(this.afterFetch(l)).catch(a=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),a})}beforeFetch(e,n,s){let i,r="GET",o={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=Sn(n),o=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=Sn(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,a]of o)e.requestHeader[l]=a}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[l,a]of i.searchParams)e.getData[l]=a}s!=null&&s.body&&(e.requestData=yn(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=Nt(e.responseSize),e.response=Qe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new ba(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 ya{static create(e,n,s,i,r,o){return new Proxy(fetch,new va(e,n,s,i,r,o))}}class wa{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 vn(n,s,i),this.item.requestType="xhr"}get(e,n){switch(n){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const s=Reflect.get(e,n);return typeof s=="function"?s.bind(e):s}}set(e,n,s){switch(n){case"onreadystatechange":return this.setOnReadyStateChange(e,n,s);case"onabort":return this.setOnAbort(e,n,s);case"ontimeout":return this.setOnTimeout(e,n,s)}return Reflect.set(e,n,s)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=Qe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===ye.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const n=Reflect.get(e,"open");return(...s)=>{var o,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=ga(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=yn(i),n.apply(e,s)}}getSetRequestHeader(e){const n=Reflect.get(e,"setRequestHeader");return(...s)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[s[0]]=s[1],n.apply(e,s))}setOnReadyStateChange(e,n,s){return Reflect.set(e,n,(...i)=>{this.onReadyStateChange(),s==null||s.apply(e,i)})}setOnAbort(e,n,s){return Reflect.set(e,n,(...i)=>{this.onAbort(),s.apply(e,i)})}setOnTimeout(e,n,s){return Reflect.set(e,n,(...i)=>{this.onTimeout(),s.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case ye.UNSENT:case ye.OPENED:this.item.status=ye.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case ye.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",n=e.split(`
|
|
661
|
+
`).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return h.map(function(c){var d=c.split("@"),p=this.extractLocation(d.pop()),v=d.shift()||"",S=v.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,y;v.match(/\(([^)]*)\)/)&&(y=v.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var T=y===void 0||y==="[arguments not available]"?void 0:y.split(",");return new s({functionName:S,args:T,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:c})},this)}}})})(Gs);var Ao=Gs.exports;const Do=Vn(Ao);function Js(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function kt(t,e,n={}){let s=e;try{s=Do.parse(t)}catch{}return Yt(t.name,t.message,JSON.stringify(s),JSON.stringify(n))}function Xs(t,e=window,n={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return kt(t.error,Js(t),n);{let[s,i]=t.message.split(":");return i||(s="Error",i=t.message),Yt(s,i,JSON.stringify(Js(t)),JSON.stringify(n))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return kt(t.reason,[],n);{let s;try{s=JSON.stringify(t.reason)}catch{s=String(t.reason)}return Yt("Unhandled Promise Rejection",s,"[]",JSON.stringify(n))}}return null}function Mo(t,e){const n=Object.assign({captureExceptions:!0},e);function s(i){function r(o){const l=Xs(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 Ys(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 Lo(t){return Qi&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const Po="https://static.openreplay.com/tracker/placeholder.jpeg";function Bo(t){function e(l,a){t.attributeSender.sendSetAttribute(l,"src",Po);const{width:h,height:c}=a.getBoundingClientRect();a.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(h)),a.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(c))}const n=function(l,a){const{srcset:h}=a;if(!h)return;const c=h.split(h.match(/,\s+/)?/,\s+/:",").map(d=>Ys(d)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",c)},s=function(l,a){a.src.length>Zi&&e(l,a),t.send(Kt(l,"src",a.src,t.getBaseHref()))},i=t.safe(function(l){const a=Ys(l.src||"");fs(a)&&t.send(_s(t.timestamp(),0,0,0,0,0,a,"img",0,!1))}),r=t.safe(function(l){const a=t.nodes.getID(l);a!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!Lo(l.src)?i(l):t.sanitizer.isHidden(a)||t.sanitizer.isObscured(a)?e(a,l):(s(a,l),n(a,l)))}),o=ms(t.safe(l=>{for(const a of l)if(a.type==="attributes"){const h=a.target,c=t.nodes.getID(h);if(c===void 0)return;a.attributeName==="src"&&s(c,h),a.attributeName==="srcset"&&n(c,h)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(l=>{Q(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 jo=["text","password","email","search","number","range","date","tel","time"];function Uo(t){return Q(t,"textarea")?!0:Q(t,"input")?jo.includes(t.type):!1}function zo(t){if(!Q(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Ho=be&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.labels;if(n!==null&&n.length===1)return n[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(Q(e,"label"))return e;const n=t.id;if(n){const s=t.ownerDocument.querySelectorAll('label[for="'+n+'"]');if(s!==null&&s.length===1)return s[0]}};function Qs(t){let e=Vt(t);if(e===null){const n=Ho(t);e=n&&n.innerText||t.placeholder||t.name||t.id||t.className||t.type}return ds(e).slice(0,100)}const $e={Plain:0,Obscured:1,Hidden:2};function $o(t,e){const n=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:$e.Obscured,obscureInputDates:!1},e);function s(c,d){let p=d.value,v=n.defaultInputMode;d.type==="password"||t.sanitizer.isHidden(c)?v=$e.Hidden:(t.sanitizer.isObscured(c)||v===$e.Plain&&(n.obscureInputNumbers&&d.type!=="date"&&/\d\d\d\d/.test(p)||n.obscureInputDates&&d.type==="date"||n.obscureInputEmails&&(d.type==="email"||~p.indexOf("@"))))&&(v=$e.Obscured);let S=0;switch(v){case $e.Hidden:S=-1,p="";break;case $e.Obscured:S=p.length,p="";break}return{value:p,mask:S}}function i(c,d){const{value:p,mask:v}=s(c,d);t.send(gr(c,p,v))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function l(c,d){r.get(c)!==d.value&&(r.set(c,d.value),i(c,d))}function a(c,d){o.get(c)!==d&&(o.set(c,d),t.send(mr(c,d)))}t.ticker.attach(()=>{r.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return r.delete(d);l(d,p)}),o.forEach((c,d)=>{const p=t.nodes.getNode(d);if(!p)return o.delete(d);a(d,p.checked)})},3);function h(c,d,p,v){const{value:S,mask:y}=s(c,d),T=Qs(d);t.send(Ar(c,S,y!==0,T,p,v))}t.nodes.attachNodeCallback(t.safe(c=>{const d=t.nodes.getID(c);if(d!==void 0){if(Q(c,"select")&&(i(d,c),t.nodes.attachNodeListener(c,"change",()=>i(d,c))),Uo(c)){l(d,c);let p=0,v=0,S=0;const y=()=>{p=pe()},T=()=>{v===0&&p!==0&&(v=pe()-p)},F=()=>{p!==0&&(S=pe()-p),h(d,c,v,S),v=0,S=0,p=0};t.nodes.attachNodeListener(c,"focus",y),t.nodes.attachNodeListener(c,"input",T),t.nodes.attachNodeListener(c,"change",F);return}if(zo(c)){a(d,c.checked),t.nodes.attachNodeListener(c,"change",()=>a(d,c.checked));return}}}))}let he,pn,Zs;function Wo(t,e){if(Zs=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};he={...n,...e},pn=qo(he.root,n);let s=Tt(t,"all",()=>Tt(t,"two",()=>Tt(t,"one",()=>Tt(t,"none"))));if(s){const i=ri(oi(s,t));return i.length>0&&(s=i[0]),Et(s)}else throw new Error("Selector was not found.")}function qo(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Tt(t,e,n){let s=null,i=[],r=t,o=0;for(;r;){const l=new Date().getTime()-Zs.getTime();if(he.timeoutMs!==void 0&&l>he.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let a=Ct(Vo(r))||Ct(...Go(r))||Ct(...Ko(r))||Ct(Jo(r))||[si()];const h=Xo(r);if(e=="all")h&&(a=a.concat(a.filter(gn).map(c=>It(c,h))));else if(e=="two")a=a.slice(0,1),h&&(a=a.concat(a.filter(gn).map(c=>It(c,h))));else if(e=="one"){const[c]=a=a.slice(0,1);h&&gn(c)&&(a=[It(c,h)])}else e=="none"&&(a=[si()],h&&(a=[It(a[0],h)]));for(let c of a)c.level=o;if(i.push(a),i.length>=he.seedMinLength&&(s=ei(i,n),s))break;r=r.parentElement,o++}return s||(s=ei(i,n)),!s&&n?n():s}function ei(t,e){const n=ri(ii(t));if(n.length>he.threshold)return e?e():null;for(let s of n)if(ni(s))return s;return null}function Et(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 ti(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function ni(t){const e=Et(t);switch(pn.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 Vo(t){const e=t.getAttribute("id");return e&&he.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Go(t){return Array.from(t.attributes).filter(n=>he.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Ko(t){return Array.from(t.classList).filter(he.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Jo(t){const e=t.tagName.toLowerCase();return he.tagName(e)?{name:e,penalty:2}:null}function si(){return{name:"*",penalty:3}}function Xo(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 It(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function gn(t){return t.name!=="html"&&!t.name.startsWith("#")}function Ct(...t){const e=t.filter(Yo);return e.length>0?e:null}function Yo(t){return t!=null}function*ii(t,e=[]){if(t.length>0)for(let n of t[0])yield*ii(t.slice(1,t.length),e.concat(n));else yield e}function ri(t){return[...t].sort((e,n)=>ti(e)-ti(n))}function*oi(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>he.optimizedMinLength)for(let s=1;s<t.length-1;s++){if(n.counter>he.maxNumberOfTries)return;n.counter+=1;const i=[...t];i.splice(s,1);const r=Et(i);if(n.visited.has(r))return;ni(i)&&Qo(i,e)&&(yield i,n.visited.set(r,!0),yield*oi(i,e,n))}}function Qo(t,e){return pn.querySelector(Et(t))===e}function Zo(t,e,n){return Wo(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 mn(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 ai(t,e){return t instanceof Element?ea(t,e):null}function ea(t,e){let n=t;for(;n!==null&&n!==e.documentElement;){if(Re(n,"masked"))return null;n=n.parentElement}if(sn(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"||mn(n)||Vt(n)!==null)return n;n=n.parentElement}return t===e.documentElement?null:t}function ta(t,e){const{disableClickmaps:n=!1}=e||{};function s(k){const N=Vt(k);if(N!==null)return N;if(Q(k,"input"))return Qs(k);if(mn(k)){let O="";return k instanceof HTMLElement&&(O=t.sanitizer.getInnerTextSecure(k)),O=O||k.id||k.className,ds(O).slice(0,100)}return""}let i=-1,r=-1,o=!1,l=null,a=0,h={},c=0,d=0,p=0,v=0,S;const y=.008,T=225;function F(){const k=v/T;if(!c){c=k;return}const N=(k-c)/T;p>4&&N>y&&t.send(Dr(pe())),v=0,p=0,c=k}t.attachStartCallback(()=>{S=setInterval(()=>F(),T)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,l=null,h={},S&&clearInterval(S)});const B=()=>{o&&(t.send(br(i,r)),o=!1)},A=(k,N=!1)=>{function O(I,E,P){return h[I]=h[I]||Zo(E,k,P)}const D=N?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);D(k.documentElement,"mouseover",I=>{const E=ai(I.target,k);E!==l&&(l=E,a=performance.now())}),D(k,"mousemove",I=>{const[E,P]=t.observer.getDocumentOffset(k);i=I.clientX+E,r=I.clientY+P,o=!0;const G=Math.sign(I.movementX);v+=Math.abs(I.movementX)+Math.abs(I.movementY),G!==d&&(d=G,p++)},!1),D(k,"click",I=>{const E=ai(I.target,k);if(!I.clientX&&!I.clientY||E===null)return;const P=t.nodes.getID(E);if(P!==void 0){const G=I.pageX,j=I.pageY,$=k.documentElement.scrollWidth,C=k.documentElement.scrollHeight,M=ci(G/$),V=ci(j/C);B(),t.send(Or(P,l===E?Math.round(performance.now()-a):0,s(E),mn(E)&&!n?O(P,E,e):"",M,V),!0)}l=null})};t.nodes.attachNodeCallback(k=>{wt(k)&&A(k)}),A(document,!0),t.ticker.attach(B,(e==null?void 0:e.trackingOffset)||7)}function ci(t){return Math.round(t*1e4)}function na(t){const e=[],n=document.getElementsByTagName("*"),s=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<n.length;i++){const r=n[i];let o="";if(Q(r,"img")&&(o=r.currentSrc||r.src),!o){const S=getComputedStyle(r).getPropertyValue("background-image");if(S){const y=s.exec(S);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 a=r.getBoundingClientRect(),h=Math.max(a.top,0),c=Math.max(a.left,0),d=Math.min(a.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),p=Math.min(a.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(d<=h||p<=c)continue;const v=(d-h)*(p-c);e.push({time:l,area:v})}return e}function sa(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 ia(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(h){var d;if(h.duration<0||!fs(h.name)||t.isServiceURL(h.name))return;s!==null&&(s[h.name]=h.startTime+h.duration);let c=!1;(d=n.excludedResourceUrls)==null||d.forEach(p=>{if(h.name.startsWith(p)){c=!0;return}}),!c&&t.send(_s(h.startTime+Ue(),h.duration,h.responseStart&&h.startTime?h.responseStart-h.startTime:0,h.transferSize>h.encodedBodySize?h.transferSize-h.encodedBodySize:0,h.encodedBodySize||0,h.decodedBodySize||0,h.name,h.initiatorType,h.transferSize,h.responseStatus&&h.responseStatus===304||h.transferSize===0))}const r=new PerformanceObserver(h=>h.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:h}){h!==o&&(performance.getEntriesByType("resource").forEach(i),o=h),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,a=0;if(n.capturePageLoadTimings){let h=!1;t.ticker.attach(()=>{if(!h&&((l===0||a===0)&&performance.getEntriesByType("paint").forEach(c=>{const{name:d,startTime:p}=c;switch(d){case"first-paint":l=p;break;case"first-contentful-paint":a=p;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){h=!0;const{navigationStart:c,requestStart:d,responseStart:p,responseEnd:v,domContentLoadedEventStart:S,domContentLoadedEventEnd:y,loadEventStart:T,loadEventEnd:F}=performance.timing;t.send(yr(d-c||0,p-c||0,v-c||0,S-c||0,y-c||0,T-c||0,F-c||0,l,a))}},30)}if(n.capturePageRenderTimings){let h=0,c=0,d=0,p=null,v=!1;t.ticker.attach(()=>{if(v)return;const S=performance.now();if(s!==null&&(h=Math.max.apply(null,Object.keys(s).map(y=>s[y])),S-h>1e3&&(p=na(s),s=null)),d!==null&&(S-d>50&&(c=S),d=S-c>5e3?null:S),p!==null&&d===null||S>3e4){v=!0,s=null;const y=p===null?0:sa(a||l,p),{domContentLoadedEventEnd:T,navigationStart:F}=performance.timing,B=d===null?Math.max(c,a,T-F||0):0;t.send(wr(y,a>h?a:h,B))}})}}function bn(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 ra(t,e){let n=!1;const s=new Map;function i(l){js(l)&&(ke(l)&&s.set(l,[l.scrollLeft,l.scrollTop]),wt(l)&&s.set(l,bn(l)))}const r=t.safe(()=>{e||t.send(ar(...bn(document)))}),o=t.safe((l,a)=>{const h=t.nodes.getID(a);h!==void 0&&t.send(pr(h,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{n=!1,s.clear()}),t.nodes.attachNodeCallback((l,a)=>{a&&(ke(l)&&l.scrollLeft+l.scrollTop>0?s.set(l,[l.scrollLeft,l.scrollTop]):wt(l)&&s.set(l,bn(l))),St(l)&&t.nodes.attachNodeListener(l,"scroll",h=>{i(h.target)})}),t.attachEventListener(document,"scroll",l=>{const a=l.target;if(a===document){n=!0;return}i(a)}),t.ticker.attach(()=>{n&&(r(),n=!1),s.forEach(o),s.clear()},5,!1)}function oa(t){let e,n,s,i,r=document.referrer;const o=t.safe(()=>{const{URL:h}=document;h!==e&&(e=h,t.send(Br(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:h,innerHeight:c}=window;(h!==n||c!==s)&&(n=h,s=c,t.send(or(n,s)))}),a=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(Ir(document.hidden)));t.attachStartCallback(()=>{e=null,i=Ue(),n=s=-1,o(),l(),a()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",a,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(l,5,!1)}function li(t){return St(t)&&!!t.adoptedStyleSheets}let aa=15;function hi(){return aa++}const _t=new Map;function ca(t){if(t===null||!li(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 a=n.get(l);a||(a=[]);const h=[],c=o.adoptedStyleSheets;if(c&&Symbol.iterator in c)for(const d of c){let p=e.get(d);const v=!p;if(p||(p=hi(),e.set(d,p)),a.includes(p)||t.send(Is(p,l)),v){const S=d.cssRules;for(let y=0;y<S.length;y++)t.send(Xt(p,S[y].cssText,y,t.getBaseHref()))}h.push(p)}if(Symbol.iterator in a)for(const d of a)h.includes(d)||t.send(Rr(d,l));n.set(l,h)},20);function i(o){const l=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");l&&Object.defineProperty(o,"adoptedStyleSheets",{...l,set:function(a){const h=l.set.call(this,a);return s(this),h}})}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:a}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(h){return l.call(this,h).then(c=>{const d=e.get(this);return d&&t.send(Ts(d,h,t.getBaseHref())),c})},o.CSSStyleSheet.prototype.replaceSync=function(h){const c=e.get(this);return c&&t.send(Ts(c,h,t.getBaseHref())),a.call(this,h)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),n.clear()}),t.attachStartCallback(()=>{s(document)}),t.nodes.attachNodeCallback(o=>{li(o)&&s(o)})}function la(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(_r("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const l=_t.get(i);l&&(typeof o=="string"?t.send(Xt(l,o,r,t.getBaseHref())):t.send(Es(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=_t.get(o);if(!l){t.debug.warn("No sheedID found for",o,_t);return}const a=r.cssText,h=o.cssRules,c=Array.from(h).indexOf(r);c>=0?(t.send(Xt(l,a,c,t.getBaseHref())),t.send(Es(l,c+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:a}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(h,c=0){return e(this,c,h),r.call(this,h,c)},i.CSSStyleSheet.prototype.deleteRule=function(h){return e(this,h),o.call(this,h)},i.CSSGroupingRule.prototype.insertRule=function(h,c=0){const d=l.call(this,h,c);return n(this),d},i.CSSGroupingRule.prototype.deleteRule=function(h=0){const c=a.call(this,h);return n(this),c}});s(window),t.observer.attachContextCallback(s),t.nodes.attachNodeCallback(i=>{if(!Q(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,l=hi();_t.set(o,l),t.send(Is(l,r));const a=o.cssRules;for(let h=0;h<a.length;h++)e(o,h,a[h].cssText)})}function ha(t){function e(s){const i=t.nodes.getID(s);i!==void 0&&t.send(ks(i))}let n=!1;t.nodes.attachNodeCallback(s=>{Q(s,"body")&&(t.nodes.attachNodeListener(s,"focus",i=>{js(i.target)&&(e(i.target),n=!1)}),t.nodes.attachNodeListener(s,"blur",i=>{i.relatedTarget===null&&(n=!0,setTimeout(()=>{n&&t.send(ks(-1))},0))}))}),t.attachStartCallback(()=>{let s=document.activeElement;for(;s&&Q(s,"iframe")&&s.contentDocument;)s=s.contentDocument.activeElement;s&&s!==s.ownerDocument.body&&e(s)},!0)}function ua(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 a=[o[0],o[1],l],h=e.get(s.document)||[];h.push(a),e.set(s.document,h);const c=s===window?0:t.nodes.getID(s.document);if(c===void 0)return;t.active()&&t.send(xs(c,...a))}super(...o)}}s.FontFace=i};t.observer.attachContextCallback(n),n(window),t.nodes.attachNodeCallback(t.safe(s=>{if(!wt(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(xs(r,...o))})}))}function da(t,e,n,s,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(p){t.debug.log("Openreplay: capturing axios response data",p);const{headers:v,data:S,method:y,url:T,baseURL:F}=p.config,{data:B,headers:A,status:k,response:N}=p,{data:O,headers:D,status:I}=N||{},E=n.ignoreHeaders,P=Array.isArray(E)?z=>E.includes(z):()=>E;function G(z,b){P(b[0])||(z[b[0]]=b[1])}let j={},$={};v.toJSON?j=v.toJSON():v instanceof Headers?v.forEach((z,b)=>G(j,[b,z])):Array.isArray(v)?v.forEach(z=>G(j,z)):typeof v=="object"&&Object.entries(v).forEach(z=>G(j,z));const C=D||A;C.toJSON?$=C.toJSON():C instanceof Headers?C.forEach((z,b)=>G($,[b,z])):Array.isArray(C)?C.forEach(z=>G($,z)):typeof C=="object"&&Object.entries(C).forEach(([z,b])=>{P(z)||($[z]=b)});const M=s({url:T,method:y||"",status:k||I||0,request:{headers:j,body:S},response:{headers:$,body:O||B}});if(!M){t.debug.log("Openreplay: empty request/response info, skipping");return}const V=p.config.__openreplay_timing,K=performance.now()-V;t.debug.log("Openreplay: final req object",M),t.send(mt("xhr",String(y),String(M.url),i(M.request),i(M.response),M.status,V+Ue(),K,0))}function o(p){if(t.debug.log("Openreplay: capturing API request",p),p.__openreplay_timing=performance.now(),n.sessionTokenHeader){const v=typeof n.sessionTokenHeader=="string"?n.sessionTokenHeader:"X-OpenReplay-Session-Token",S=t.getSessionToken();S&&p.headers.set(v,S)}return p}function l(p){return n.failuresOnly||r(p),p}function a(p){return t.debug.log("Openreplay: capturing API request error",p),fa(p)&&p.response?r(p.response):p instanceof Error&&t.send(kt(p,[])),Promise.reject(p)}function h(p){t.debug.log("Openreplay: failed API request, skipping",p)}const c=e.interceptors.request.use(o,h,{synchronous:!0}),d=e.interceptors.response.use(l,a,{synchronous:!0});t.attachStopCallback(()=>{var p,v,S,y;(v=(p=e.interceptors.request).eject)==null||v.call(p,c),(y=(S=e.interceptors.response).eject)==null||y.call(S,d)})}function fa(t){return pa(t)&&t.isAxiosError===!0}function pa(t){return t!==null&&typeof t=="object"}var ye;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(ye||(ye={}));class vn{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 mt(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+Ue(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([s,i])=>{this.isHeaderIgnored(s)||(e[s]=i)}),this.setSessionTokenHeader((s,i)=>{e[s]=i});const n={};return Object.entries(this.header).forEach(([s,i])=>{this.isHeaderIgnored(s)||(n[s]=i)}),{reqHs:e,resHs:n}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(n=>n.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const Qe=(t,e)=>{let n="";switch(t){case"":case"text":case"json":typeof e=="string"?n=e:wn(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},yn=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(ma(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":wn(t)?e=t:e=`can't parse body ${typeof t}`;return e},ga=(t,e={})=>{wn(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 wn(t){return t!==null&&typeof t=="object"}function ma(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Nt(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const Sn=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class ba{constructor(e,n){this.resp=e,this.item=n,this.mockReader()}set(e,n,s){return Reflect.set(e,n,s)}get(e,n){const s=Reflect.get(e,n);switch(n){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=n.toLowerCase(),s.apply(e).then(i=>(this.item.response=Qe(this.item.responseType,i),i)))}return typeof s=="function"?s.bind(e):s}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const n=this.resp.body.getReader;this.resp.body.getReader=()=>{const s=n.apply(this.resp.body);if(this.item.readyState===ye.DONE)return s;const i=s.read,r=s.cancel;return this.item.responseType="arraybuffer",s.read=()=>i.apply(s).then(o=>{if(!e)e=new Uint8Array(o.value);else{const 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=Nt(this.item.responseSize),o.done&&(this.item.response=Qe(this.item.responseType,e)),o}),s.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=Qe(this.item.responseType,e),r.apply(s,o)),s}}}class va{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 vn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((a,h)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(s[1]===void 0&&s[0]instanceof Request)return s[0].headers.append(a,h);s[1]||(s[1]={}),s[1].headers===void 0&&(s[1]={...s[1],headers:{}}),s[1].headers instanceof Headers?s[1].headers.append(a,h):Array.isArray(s[1].headers)?s[1].headers.push([a,h]):s[1].headers[a]=h}}),e.apply(window,s).then(this.afterFetch(l)).catch(a=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),a})}beforeFetch(e,n,s){let i,r="GET",o={};if(typeof n=="string"?(r=(s==null?void 0:s.method)||"GET",i=Sn(n),o=(s==null?void 0:s.headers)||{}):(r=n.method||"GET",i=Sn(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,a]of o)e.requestHeader[l]=a}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[l,a]of i.searchParams)e.getData[l]=a}s!=null&&s.body&&(e.requestData=yn(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=Nt(e.responseSize),e.response=Qe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(n,new ba(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 ya{static create(e,n,s,i,r,o){return new Proxy(fetch,new va(e,n,s,i,r,o))}}class wa{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 vn(n,s,i),this.item.requestType="xhr"}get(e,n){switch(n){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const s=Reflect.get(e,n);return typeof s=="function"?s.bind(e):s}}set(e,n,s){switch(n){case"onreadystatechange":return this.setOnReadyStateChange(e,n,s);case"onabort":return this.setOnAbort(e,n,s);case"ontimeout":return this.setOnTimeout(e,n,s)}return Reflect.set(e,n,s)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=Qe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===ye.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const n=Reflect.get(e,"open");return(...s)=>{var o,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=ga(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=yn(i),n.apply(e,s)}}getSetRequestHeader(e){const n=Reflect.get(e,"setRequestHeader");return(...s)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[s[0]]=s[1],n.apply(e,s))}setOnReadyStateChange(e,n,s){return Reflect.set(e,n,(...i)=>{this.onReadyStateChange(),s==null||s.apply(e,i)})}setOnAbort(e,n,s){return Reflect.set(e,n,(...i)=>{this.onAbort(),s.apply(e,i)})}setOnTimeout(e,n,s){return Reflect.set(e,n,(...i)=>{this.onTimeout(),s.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case ye.UNSENT:case ye.OPENED:this.item.status=ye.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case ye.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",n=e.split(`
|
|
658
662
|
`);for(let s=0;s<n.length;s++){const i=n[s];if(!i)continue;const r=i.split(": "),o=r[0];this.item.header[o]=r.slice(1).join(": ")}break;case ye.LOADING:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Nt(this.item.responseSize));break;case ye.DONE:this.item.status=this.XMLReq.status||this.item.status||0,this.item.statusText=String(this.item.status),this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=this.XMLReq.response,this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Nt(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class Sa{static create(e,n,s,i,r,o){return new Proxy(XMLHttpRequest,{construct(l){const a=new l;return new Proxy(a,new wa(a,e,n,s,i,r,o))}})}}const xa=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 ka{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 vn(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(n,s);const l=Sn(i);if(o.method="POST",o.url=i,o.name=(l.pathname.split("/").pop()||"")+l.search,o.requestType="beacon",o.requestHeader={"Content-Type":xa(r)},o.status=0,o.statusText="Pending",l.search&&l.searchParams){o.getData={};for(const[c,d]of l.searchParams)o.getData[c]=d}o.requestData=yn(r),o.startTime||(o.startTime=performance.now());const a=e.apply(n,s);a?(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 h=o.getMessage();return h&&this.sendMessage(h),a}}class We{static hasSendBeacon(){return!!We.origSendBeacon}static create(e,n,s,i,r){if(We.hasSendBeacon())return new Proxy(We.origSendBeacon,new ka(e,n,s,i,r))}}We.origSendBeacon=(gi=window==null?void 0:window.navigator)==null?void 0:gi.sendBeacon;const ui=t=>console.warn(`Openreplay: Can't find ${t} in global context.
|
|
659
|
-
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function Ta(t,e,n,s,i,r,o){var l;t.XMLHttpRequest?t.XMLHttpRequest=Sa.create(e,n,s,i,r,o):ui("XMLHttpRequest"),t.fetch?t.fetch=ya.create(e,n,s,i,r,o):ui("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=We.create(e,n,s,i,r))}function xn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function di(t){return typeof t=="string"?t.toUpperCase():"GET"}function Ea(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 o(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 a(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 h=c=>{if(n.useProxy)return Ta(c,n.ignoreHeaders,o,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);o(function(O,D){k.headers===void 0&&(k.headers={}),k.headers instanceof Headers?k.headers.append(O,D):Array.isArray(k.headers)?k.headers.push([O,D]):k.headers[O]=D});const N=performance.now();return d(A,k).then(O=>{const D=performance.now()-N;if(n.failuresOnly&&O.status<400)return O;const I=O.clone();return I.text().then(E=>{const P={},G={};if(s!==!0){const C=([M,q])=>{i(M)||(P[M]=q)};k.headers instanceof Headers?k.headers.forEach((M,q)=>C([q,M])):Array.isArray(k.headers)?k.headers.forEach(C):typeof k.headers=="object"&&Object.entries(k.headers).forEach(C),I.headers.forEach((M,q)=>{i(q)||(G[q]=M)})}const j=di(k.method),$=l({url:String(A),method:j,status:I.status,request:{headers:P,body:k.body||null},response:{headers:G,body:E}});$&&t.send(mt("fetch",j,String($.url),a($.request),a($.response),I.status,N+Ue(),D,0))}).catch(E=>t.debug.error("Could not process Fetch response:",E)),O})};c.fetch=p;const v=c.XMLHttpRequest.prototype.open,S=c.XMLHttpRequest.prototype.setRequestHeader,y=c.XMLHttpRequest.prototype.send;function T(A,k){const N=this;o((D,I)=>N.setRequestHeader(D,I));let O=0;return N.addEventListener("loadstart",D=>{O=D.timeStamp}),N.addEventListener("load",t.safe(D=>{const{headers:I,body:E}=xn(N),P=O>0?D.timeStamp-O:0,j=(N.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),$={};j.forEach(function(q){const K=q.split(": "),z=K.shift();i(z)||($[z]=K.join(": "))});const C=di(A),M=l({url:String(k),method:C,status:N.status,request:{headers:I,body:E||null},response:{headers:$,body:N.response}});M&&t.send(mt("xhr",C,String(M.url),a(M.request),a(M.response),N.status,O+Ue(),P,0))})),v.apply(this,arguments)}function F(A){const k=xn(this);return k.body=A,y.apply(this,arguments)}function B(A,k){if(!i(A)){const N=xn(this);N.headers[A]=k}return S.apply(this,arguments)}n.axiosInstances||(c.XMLHttpRequest.prototype.open=T,c.XMLHttpRequest.prototype.send=F,c.XMLHttpRequest.prototype.setRequestHeader=B)};h(window),n.axiosInstances&&n.axiosInstances.forEach(c=>{da(t,c,n,l,a)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(h))}function Ia(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(Cs(n,s,i))}else t.send(Cs(-1,-1,""))})}function Ca(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(bt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Ot="/installation/javascript-sdk";function _a(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${gt}${Ot}`),!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 ${gt}${Ot} for more information.`),!1;t.projectKey=t.projectID.toString(),Ce("`projectID` option","`projectKey` option",Ot)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ce("`sessionToken` option","`sessionHash` start() option","/"),!0}class Na{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=(a,h)=>{const c=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||$s;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:c,reason:h.length?`missing api: ${h.join(",")}`:a}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(a,h={})=>{if(this.app!==null){if(a instanceof Error){const c=kt(a,[],h);this.app.send(c)}else if(a instanceof ErrorEvent||"PromiseRejectionEvent"in window&&a instanceof PromiseRejectionEvent){const c=Js(a,void 0,h);c!=null&&this.app.send(c)}}},this.crossdomainMode=!!(nr()&&((l=e.crossdomain)!=null&&l.enabled)),!be||!_a(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 a of i)if(a==="timing"){if("performance"in window&&!(a in performance)){s.push(a);break}}else if(a==="startsWith"){if(!(a in String.prototype)){s.push(a);break}}else if(!(a in window)){s.push(a);break}if(s.length>0){const a=s.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${a}`),this.signalStartIssue("missing_api",s);return}const r=new Io(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(oa(r),Co(r),jr(r,e),Ca(r)),ta(r,e.mouse),ra(r,this.crossdomainMode),la(r),ca(r),Ro(r,e),Mo(r,e),Bo(r),$o(r,e),ia(r,e),ha(r),ua(r),Ea(r,e.network),Ia(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 a=r.getTabId(),h=r.sessionStorage??window.sessionStorage;window.open=function(...c){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&h.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),h.setItem(e.session_tabid_key||"__openreplay_tabid",a),o.call(window,...c)}}),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 be?!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 ${gt}${Ot}`),!1)}coldStart(e,n){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,n)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,n){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,n):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return Ce("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){Ce("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(kr(e))}userAnonymousID(e){Ce("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,n){typeof e=="string"&&typeof n=="string"&&this.app!==null&&this.app.session.setMetadata(e,n)}metadata(e,n){Ce("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,n)}event(e,n=null,s=!1){if(typeof e=="string"&&this.app!==null){if(s)return this.issue(e,n);try{n=JSON.stringify(n)}catch{return}this.app.send(Sr(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(Nr(e,n))}}}const Oa=`
|
|
663
|
+
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function Ta(t,e,n,s,i,r,o){var l;t.XMLHttpRequest?t.XMLHttpRequest=Sa.create(e,n,s,i,r,o):ui("XMLHttpRequest"),t.fetch?t.fetch=ya.create(e,n,s,i,r,o):ui("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=We.create(e,n,s,i,r))}function xn(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function di(t){return typeof t=="string"?t.toUpperCase():"GET"}function Ea(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 o(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 a(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 h=c=>{if(n.useProxy)return Ta(c,n.ignoreHeaders,o,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);o(function(O,D){k.headers===void 0&&(k.headers={}),k.headers instanceof Headers?k.headers.append(O,D):Array.isArray(k.headers)?k.headers.push([O,D]):k.headers[O]=D});const N=performance.now();return d(A,k).then(O=>{const D=performance.now()-N;if(n.failuresOnly&&O.status<400)return O;const I=O.clone();return I.text().then(E=>{const P={},G={};if(s!==!0){const C=([M,V])=>{i(M)||(P[M]=V)};k.headers instanceof Headers?k.headers.forEach((M,V)=>C([V,M])):Array.isArray(k.headers)?k.headers.forEach(C):typeof k.headers=="object"&&Object.entries(k.headers).forEach(C),I.headers.forEach((M,V)=>{i(V)||(G[V]=M)})}const j=di(k.method),$=l({url:String(A),method:j,status:I.status,request:{headers:P,body:k.body||null},response:{headers:G,body:E}});$&&t.send(mt("fetch",j,String($.url),a($.request),a($.response),I.status,N+Ue(),D,0))}).catch(E=>t.debug.error("Could not process Fetch response:",E)),O})};c.fetch=p;const v=c.XMLHttpRequest.prototype.open,S=c.XMLHttpRequest.prototype.setRequestHeader,y=c.XMLHttpRequest.prototype.send;function T(A,k){const N=this;o((D,I)=>N.setRequestHeader(D,I));let O=0;return N.addEventListener("loadstart",D=>{O=D.timeStamp}),N.addEventListener("load",t.safe(D=>{const{headers:I,body:E}=xn(N),P=O>0?D.timeStamp-O:0,j=(N.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),$={};j.forEach(function(V){const K=V.split(": "),z=K.shift();i(z)||($[z]=K.join(": "))});const C=di(A),M=l({url:String(k),method:C,status:N.status,request:{headers:I,body:E||null},response:{headers:$,body:N.response}});M&&t.send(mt("xhr",C,String(M.url),a(M.request),a(M.response),N.status,O+Ue(),P,0))})),v.apply(this,arguments)}function F(A){const k=xn(this);return k.body=A,y.apply(this,arguments)}function B(A,k){if(!i(A)){const N=xn(this);N.headers[A]=k}return S.apply(this,arguments)}n.axiosInstances||(c.XMLHttpRequest.prototype.open=T,c.XMLHttpRequest.prototype.send=F,c.XMLHttpRequest.prototype.setRequestHeader=B)};h(window),n.axiosInstances&&n.axiosInstances.forEach(c=>{da(t,c,n,l,a)}),n.captureInIframes&&t.observer.attachContextCallback(t.safe(h))}function Ia(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(Cs(n,s,i))}else t.send(Cs(-1,-1,""))})}function Ca(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(bt(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Ot="/installation/javascript-sdk";function _a(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${gt}${Ot}`),!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 ${gt}${Ot} for more information.`),!1;t.projectKey=t.projectID.toString(),Ce("`projectID` option","`projectKey` option",Ot)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&Ce("`sessionToken` option","`sessionHash` start() option","/"),!0}class Na{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=(a,h)=>{const c=this.checkDoNotTrack(),d=new XMLHttpRequest,p=this.options.ingestPoint||$s;d.open("POST",p+"/v1/web/not-started"),d.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:c,reason:h.length?`missing api: ${h.join(",")}`:a}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(a,h={})=>{if(this.app!==null){if(a instanceof Error){const c=kt(a,[],h);this.app.send(c)}else if(a instanceof ErrorEvent||"PromiseRejectionEvent"in window&&a instanceof PromiseRejectionEvent){const c=Xs(a,void 0,h);c!=null&&this.app.send(c)}}},this.crossdomainMode=!!(nr()&&((l=e.crossdomain)!=null&&l.enabled)),!be||!_a(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 a of i)if(a==="timing"){if("performance"in window&&!(a in performance)){s.push(a);break}}else if(a==="startsWith"){if(!(a in String.prototype)){s.push(a);break}}else if(!(a in window)){s.push(a);break}if(s.length>0){const a=s.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${a}`),this.signalStartIssue("missing_api",s);return}const r=new Io(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(oa(r),Co(r),jr(r,e),Ca(r)),ta(r,e.mouse),ra(r,this.crossdomainMode),la(r),ca(r),Ro(r,e),Mo(r,e),Bo(r),$o(r,e),ia(r,e),ha(r),ua(r),Ea(r,e.network),Ia(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 a=r.getTabId(),h=r.sessionStorage??window.sessionStorage;window.open=function(...c){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&h.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),h.setItem(e.session_tabid_key||"__openreplay_tabid",a),o.call(window,...c)}}),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 be?!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 ${gt}${Ot}`),!1)}coldStart(e,n){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,n)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,n){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,n):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return Ce("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){Ce("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(kr(e))}userAnonymousID(e){Ce("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,n){typeof e=="string"&&typeof n=="string"&&this.app!==null&&this.app.session.setMetadata(e,n)}metadata(e,n){Ce("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,n)}event(e,n=null,s=!1){if(typeof e=="string"&&this.app!==null){if(s)return this.issue(e,n);try{n=JSON.stringify(n)}catch{return}this.app.send(Sr(e,n))}}issue(e,n=null){if(typeof e=="string"&&this.app!==null){try{n=JSON.stringify(n)}catch{return}this.app.send(Nr(e,n))}}}const Oa=`
|
|
660
664
|
/* Общие стили */
|
|
661
665
|
#wine-widget-container {
|
|
662
666
|
display: flex;
|
|
@@ -970,58 +974,63 @@ If you're using serverside rendering in your app, make sure that tracker is load
|
|
|
970
974
|
max-width: 100px;
|
|
971
975
|
}
|
|
972
976
|
}
|
|
973
|
-
`,fi=document.createElement("style");fi.textContent=Oa,document.head.appendChild(fi);const Ra=["climats","telckel","biobio","weinpoint","vinigrandi","ampely"],Fa="
|
|
977
|
+
`,fi=document.createElement("style");fi.textContent=Oa,document.head.appendChild(fi);const Ra=["climats","telckel","biobio","weinpoint","vinigrandi","ampely","test"],Fa="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Rt{constructor(e){var n;this.baseURL="https://wineater-backend.vercel.app/",this.store=Ra.find(s=>window.location.href.includes(s)),this.token=((n=window==null?void 0:window.wineaterData)==null?void 0:n.CLIENT_TOKEN)||Fa}async getStoreConfig(e){console.log(e);try{const n=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:e})});if(console.log(n),!n.ok)throw new Error(`HTTP error! Status: ${n.status}`);return await n.json()}catch(n){throw console.error("Error fetching store configuration:",n),n}}async getWineRecommendations(e){console.log(window.location.href);try{const n=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),s=await n.json();if(!n.ok)throw new Error(`API call failed with status ${n.status}: ${s.message||"No additional error information"}`);return s}catch(n){throw console.error("Fetching wine recommendations failed:",n.message),new Error(`Error in getWineRecommendations: ${n.message}`)}}async getWineRecommendationsSearch(e){console.log(window.location.href);try{const n=await fetch(`${this.baseURL}dish/recommendations/search`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),s=await n.json();if(!n.ok)throw new Error(`API call failed with status ${n.status}: ${s.message||"No additional error information"}`);return s}catch(n){throw console.error("Fetching wine recommendations failed:",n.message),new Error(`Error in getWineRecommendations: ${n.message}`)}}async getPossibleDishesWithMeta(e,n){try{const s=await fetch(`${this.baseURL}dish/possible_dishes`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({title:e,description:n})}),i=await s.json();if(console.log(i),!s.ok)throw new Error(`API call failed with status ${s.status}: ${i.message||"No additional error information"}`);return i}catch(s){throw console.error("Error fetching possible dishes:",s),s}}async getInstantRecommendations(){console.log("Fetching instant recommendations...");try{const e=await fetch(`${this.baseURL}dish/recommendations/instant`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:this.store})}),n=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${n.message||"No additional error information"}`);return console.log("Instant recommendations:",n),n}catch(e){throw console.error("Fetching instant recommendations failed:",e.message),new Error(`Error in getInstantRecommendations: ${e.message}`)}}}class Aa{constructor(){this.api=new Rt,this.language="en",this.translations={fr:{welcomeMessage:"Quel plat allez-vous déguster ? Décrivez-le-moi et je vous proposerai le vin qui l'accompagnera parfaitement.",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton1:"Trouvez l'accord parfait",chatButton2:"Associez le vin",chatButton3:"Obtenez des conseils",chatTitle:"Accord Mets & Vins 🍷",chatSubtitle:"Décrivez votre plat et obtenez une recommandation en 30 secondes",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",poweredBy:"Propulsé par",price:"Prix",region:"Région",type:"Type",reason:"Suggestion",moreInfo:"Plus d'infos",winePairingIntro:"Pour ce vin, voici quelques suggestions de plats :",askForDinner:"Que voulez-vous manger ce soir?",clearChatButton:"Effacer le chat",widgetTitle:"Découvrez votre vin",widgetSubtitle:"Recherchez par vos préférences",searchPlaceholder:"Entrez un mot-clé ou une description",searchButton:"Rechercher",priceRange:"Gamme de prix",wineColor:"Couleur du vin",intensity:"Intensité",red:"Rouge",white:"Blanc",rose:"Rosé",light:"Léger",medium:"Moyen",full:"Puissant"},es:{welcomeMessage:"¿Qué vas a comer? Cuéntame tu plato y te recomendaré el maridaje perfecto.",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton1:"Encuentra tu maridaje",chatButton2:"Combina vino ya",chatButton3:"Recibe asesoría ahora",chatTitle:"Maridaje de Vinos 🍷",chatSubtitle:"Describe tu comida y obtén una recomendación en 30 segundos",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Combinar",poweredBy:"Desarrollado por",price:"Precio",region:"Región",type:"Tipo",reason:"Sugerencia",moreInfo:"Más info",winePairingIntro:"Para este vino, aquí tienes algunas sugerencias de platos:",askForDinner:"¿Qué te gustaría cenar?",clearChatButton:"Limpiar el chat",widgetTitle:"Encuentra tu vino",widgetSubtitle:"Busca según tus preferencias",searchPlaceholder:"Escribe una palabra clave o descripción",searchButton:"Buscar",priceRange:"Rango de precios",wineColor:"Color del vino",intensity:"Intensidad",red:"Tinto",white:"Blanco",rose:"Rosado",light:"Ligero",medium:"Medio",full:"Intenso"},en:{welcomeMessage:"What are you planning to eat? Share your dish and I'll recommend the perfect wine pairing for your meal.",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton1:"Find Your Pairing",chatButton2:"Pair Wine Now",chatButton3:"Get Wine Advice",chatTitle:"Wine Pairing Assistant 🍷",chatSubtitle:"Describe your meal and get a recommendation in 30 seconds",inputPlaceholder:"e.g., Tuna salad",sendButton:"Match",poweredBy:"Powered by",price:"Price",region:"Region",type:"Type",reason:"Suggestion",moreInfo:"More info",winePairingIntro:"For this wine, here are some suggested dishes:",askForDinner:"What would you like to have for dinner?",clearChatButton:"Clear Chat",widgetTitle:"Discover Your Wine",widgetSubtitle:"Search by your preferences",searchPlaceholder:"Enter a keyword or description",searchButton:"Search",priceRange:"Price Range",wineColor:"Wine Color",intensity:"Intensity",red:"Red",white:"White",rose:"Rosé",light:"Light",medium:"Medium",full:"Full"},de:{welcomeMessage:"Was möchten Sie essen? Beschreiben Sie Ihr Gericht und ich empfehle Ihnen den perfekten Wein dazu.",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton1:"Finde Dein Pairing",chatButton2:"Wein jetzt wählen",chatButton3:"Erhalte Weinberatung",chatTitle:"Wein & Speisen 🍷",chatSubtitle:"Beschreiben Sie Ihr Gericht und erhalten Sie in 30 Sekunden eine Empfehlung",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",poweredBy:"Unterstützt von",price:"Preis",region:"Region",type:"Typ",reason:"Anregung",moreInfo:"Mehr Info",winePairingIntro:"Für diesen Wein gibt es folgende Essensvorschläge:",askForDinner:"Was möchten Sie zum Abendessen essen?",clearChatButton:"Chat löschen",widgetTitle:"Finden Sie Ihren Wein",widgetSubtitle:"Suchen Sie nach Ihren Vorlieben",searchPlaceholder:"Geben Sie ein Stichwort oder eine Beschreibung ein",searchButton:"Suche",priceRange:"Preisspanne",wineColor:"Weinfarbe",intensity:"Intensität",red:"Rot",white:"Weiß",rose:"Rosé",light:"Leicht",medium:"Mittel",full:"Voll"}}}async fetchConfig(e){console.log(e);try{const n=await this.api.getStoreConfig(e);console.log(n),this.language=n.lang}catch{this.language="en"}console.log(this.language)}translate(e){return this.translations[this.language][e]||e}}const W=new Aa;class Da{constructor(){this.api=new Rt,this.selectedFilters={price:null,color:null,intensity:null},this.initializeWidget(),this.loadInstantRecommendations()}initializeWidget(){const e=document.getElementById("wineater-widget-conteiner"),n=`
|
|
974
978
|
<div id="wine-widget-container">
|
|
975
979
|
<div id="wine-widget-left">
|
|
976
980
|
<div id="wine-widget-header">
|
|
977
|
-
<h1>${
|
|
978
|
-
<p>${
|
|
981
|
+
<h1>${W.translate("widgetTitle")}</h1>
|
|
982
|
+
<p>${W.translate("widgetSubtitle")}</p>
|
|
979
983
|
</div>
|
|
980
984
|
<div id="wine-widget-search">
|
|
981
|
-
<input type="text" id="wine-search-input" placeholder="${
|
|
982
|
-
<button id="wine-search-button">${
|
|
985
|
+
<input type="text" id="wine-search-input" placeholder="${W.translate("searchPlaceholder")}">
|
|
986
|
+
<button id="wine-search-button">${W.translate("searchButton")}</button>
|
|
983
987
|
</div>
|
|
984
988
|
<div id="wine-widget-filters">
|
|
985
989
|
<div class="filter-group">
|
|
986
|
-
<span class="filter-label">${
|
|
990
|
+
<span class="filter-label">${W.translate("priceRange")}:</span>
|
|
987
991
|
<div class="filter-buttons" id="price-buttons">
|
|
988
|
-
<button data-value="<
|
|
989
|
-
<button data-value="
|
|
990
|
-
<button data-value=">
|
|
992
|
+
<button data-value="< 500">< $500</button>
|
|
993
|
+
<button data-value="500 - 1000">$500 - $1000</button>
|
|
994
|
+
<button data-value="> 1000">> $1000</button>
|
|
995
|
+
<button data-value=" " class="selected">Any</button>
|
|
991
996
|
</div>
|
|
992
997
|
</div>
|
|
993
998
|
<div class="filter-group">
|
|
994
|
-
<span class="filter-label">${
|
|
999
|
+
<span class="filter-label">${W.translate("wineColor")}:</span>
|
|
995
1000
|
<div class="filter-buttons" id="color-buttons">
|
|
996
|
-
<button data-value="red">${
|
|
997
|
-
<button data-value="white">${
|
|
998
|
-
<button data-value="rose">${
|
|
1001
|
+
<button data-value="red">${W.translate("red")}</button>
|
|
1002
|
+
<button data-value="white">${W.translate("white")}</button>
|
|
1003
|
+
<button data-value="rose">${W.translate("rose")}</button>
|
|
1004
|
+
<button data-value=" " class="selected">${W.translate("Any")}</button>
|
|
999
1005
|
</div>
|
|
1000
1006
|
</div>
|
|
1001
1007
|
<div class="filter-group">
|
|
1002
|
-
<span class="filter-label">${
|
|
1008
|
+
<span class="filter-label">${W.translate("intensity")}:</span>
|
|
1003
1009
|
<div class="filter-buttons" id="intensity-buttons">
|
|
1004
|
-
<button data-value="light">${
|
|
1005
|
-
<button data-value="medium">${
|
|
1006
|
-
<button data-value="full">${
|
|
1010
|
+
<button data-value="light">${W.translate("light")}</button>
|
|
1011
|
+
<button data-value="medium">${W.translate("medium")}</button>
|
|
1012
|
+
<button data-value="full">${W.translate("full")}</button>
|
|
1013
|
+
<button data-value=" " class="selected">${W.translate("Any")}</button>
|
|
1007
1014
|
</div>
|
|
1008
1015
|
</div>
|
|
1009
1016
|
</div>
|
|
1010
1017
|
<div id="powered-by-widget">
|
|
1011
1018
|
<a href="https://wineater.com" target="_blank">
|
|
1012
|
-
<span>${
|
|
1019
|
+
<span>${W.translate("poweredBy")}</span>
|
|
1013
1020
|
<img src="https://czvgkhagwvmknscoerfy.supabase.co/storage/v1/object/public/static-media/logo.svg" alt="Wineater Logo">
|
|
1014
1021
|
</a>
|
|
1015
1022
|
</div>
|
|
1016
1023
|
</div>
|
|
1017
1024
|
<div id="wine-widget-right">
|
|
1018
1025
|
<div id="loading-indicator" class="hidden">
|
|
1019
|
-
<
|
|
1026
|
+
<div id="typing-indicator" class="typing-indicator">
|
|
1027
|
+
<span></span><span></span><span></span>
|
|
1028
|
+
</div>
|
|
1020
1029
|
</div>
|
|
1021
1030
|
<div id="wine-placeholder"></div>
|
|
1022
1031
|
</div>
|
|
1023
1032
|
</div>
|
|
1024
|
-
`;
|
|
1033
|
+
`;e.insertAdjacentHTML("beforeend",n),this.addEventListeners()}addEventListeners(){document.getElementById("wine-search-button").addEventListener("click",()=>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.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()}}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.hideLoadingIndicator(),s.innerHTML="",e.forEach((i,r)=>{const o=`
|
|
1025
1034
|
<div class="wine-recommendation-tile ${r===e.length-1?"somm-selection":""}">
|
|
1026
1035
|
${r===e.length-1?'<div class="somm-selection-badge">Somm Selection</div>':""}
|
|
1027
1036
|
<img src="${i.Image}" alt="${i.Title}" />
|
|
@@ -1035,28 +1044,28 @@ If you're using serverside rendering in your app, make sure that tracker is load
|
|
|
1035
1044
|
</div>
|
|
1036
1045
|
`;s.insertAdjacentHTML("beforeend",o);const l=s.children[r];setTimeout(()=>{l.style.opacity="1",l.style.transform="translateY(0)"},n?r*200:0)})}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=`
|
|
1037
1046
|
<div class="no-results">
|
|
1038
|
-
<p>${
|
|
1047
|
+
<p>${W.translate("noResultsMessage")||"No recommendations found for your query."}</p>
|
|
1039
1048
|
</div>
|
|
1040
1049
|
`}displayErrorMessage(){const e=document.getElementById("wine-placeholder");e.innerHTML=`
|
|
1041
1050
|
<div class="error-message">
|
|
1042
|
-
<p>${
|
|
1051
|
+
<p>${W.translate("errorMessage")||"Something went wrong. Please try again later."}</p>
|
|
1043
1052
|
</div>
|
|
1044
|
-
`}async loadInstantRecommendations(){
|
|
1053
|
+
`}async loadInstantRecommendations(){this.showLoadingIndicator();try{const e=await this.api.getInstantRecommendations();this.displayResults(e)}catch(e){console.error("Error loading instant recommendations:",e.message)}}}class Ma{constructor(){var n;this.api=new Rt;const e=((n=window==null?void 0:window.wineaterData)==null?void 0:n.FIRST_MESSAGE_TEXT)||W.translate("welcomeMessage");this.displayFirstMessage(e)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",s=>{s.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(e,n="api"){const s=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${n}`,i.textContent=e,s.appendChild(i),s.scrollTop=s.scrollHeight}async handleUserInput(){const e=document.getElementById("user-input"),n=e.value.trim();if(n){this.displayMessage(n,"user"),e.value="",this.showTypingIndicator();try{Oi(n);const s=await this.api.getWineRecommendations(n);this.hideTypingIndicator(),s&&s.length?this.displayResults(s):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(W.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(e,n){const s=document.getElementById("message-container"),i=document.createElement("div");i.textContent=e,i.className="message "+n,s.appendChild(i),s.scrollTop=s.scrollHeight}sendAnalytics(e){console.log(e),Fi(e)}displayResults(e){console.log(e);const n=document.getElementById("message-container");Ri(e.map(s=>s.Title)),e.forEach(s=>{const i=document.createElement("div");i.className="wine-recommendation";const r=document.createElement("div");r.className="wine-item",i.appendChild(r);const o=document.createElement("img");o.src=s.Image,r.appendChild(o),console.log(r,"wine div");const l=document.createElement("div");l.innerHTML=`
|
|
1045
1054
|
<strong>${s.Title}</strong><br>
|
|
1046
|
-
${
|
|
1047
|
-
${
|
|
1048
|
-
${
|
|
1049
|
-
<a href="${s.Url}" target="_blank">${
|
|
1050
|
-
`,l.querySelector("a").addEventListener("click",c=>{c.preventDefault(),this.sendAnalytics(s.Title),window.open(s.Url,"_blank")}),r.appendChild(l);const h=document.createElement("div");h.className="wine-description",h.innerHTML=s.Reason,i.appendChild(h),console.log(i),n.appendChild(i)}),n.scrollTop=n.scrollHeight}}const La=3;let Ft=null;function Pa(){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");t.classList.contains("visible")?(qn(),Ba(),e.style.display="flex"):(Ft&&(clearTimeout(Ft),Ft=null),Ni(),t.classList.add("visible"),e.style.display="none")}function Ba(){console.log("ghbdtn"),qn(),document.getElementById("chat-window").classList.remove("visible");let e=parseInt(se("chatCloseCount"))||0;e+=1,e>=La?(console.log(e),rt("disableAutoOpen","true",1),Ci("chatCloseCount")):(console.log(e),rt("chatCloseCount",e,1))}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});function ja(t){Ft=t}new Rt;const At={PRODUCT_PAGES:/producto\/[^\/]+\/$/},pi={FESTIVAL_PAGES:/festival/,TASTING_PAGES:/tasting/},Ua={FESTIVAL_PAGES:((mi=window.wineaterData)==null?void 0:mi.FESTIVAL_PAGES)||pi.FESTIVAL_PAGES,TASTING_PAGES:((bi=window.wineaterData)==null?void 0:bi.TASTING_PAGES)||pi.TASTING_PAGES},za={PRODUCT_PAGES:((vi=window.wineaterData)==null?void 0:vi.PRODUCT_PAGES)||At.PRODUCT_PAGES,CART_PAGE:((yi=window.wineaterData)==null?void 0:yi.CART_PAGE)||(At==null?void 0:At.CART_PAGE)};async function Ha(){const t=window.location.href;for(const[e,n]of Object.entries(Ua))if(n.test(t))return!1;for(const[e,n]of Object.entries(za))if(n.test(t))try{console.log(dishes);const s=setTimeout(()=>{openChatWindow()},15e3);return ja(s),!0}catch(s){return console.error("Error fetching dishes:",s),!1}return!1}const $a="
|
|
1055
|
+
${W.translate("price")}: ${s.Price}<br>
|
|
1056
|
+
${W.translate("region")}: ${s.Region}<br>
|
|
1057
|
+
${W.translate("type")}: ${s.Type}<br>
|
|
1058
|
+
<a href="${s.Url}" target="_blank">${W.translate("moreInfo")}</a>
|
|
1059
|
+
`,l.querySelector("a").addEventListener("click",c=>{c.preventDefault(),this.sendAnalytics(s.Title),window.open(s.Url,"_blank")}),r.appendChild(l);const h=document.createElement("div");h.className="wine-description",h.innerHTML=s.Reason,i.appendChild(h),console.log(i),n.appendChild(i)}),n.scrollTop=n.scrollHeight}}const La=3;let Ft=null;function Pa(){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");t.classList.contains("visible")?(qn(),Ba(),e.style.display="flex"):(Ft&&(clearTimeout(Ft),Ft=null),Ni(),t.classList.add("visible"),e.style.display="none")}function Ba(){console.log("ghbdtn"),qn(),document.getElementById("chat-window").classList.remove("visible");let e=parseInt(se("chatCloseCount"))||0;e+=1,e>=La?(console.log(e),rt("disableAutoOpen","true",1),Ci("chatCloseCount")):(console.log(e),rt("chatCloseCount",e,1))}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});function ja(t){Ft=t}new Rt;const At={PRODUCT_PAGES:/producto\/[^\/]+\/$/},pi={FESTIVAL_PAGES:/festival/,TASTING_PAGES:/tasting/},Ua={FESTIVAL_PAGES:((mi=window.wineaterData)==null?void 0:mi.FESTIVAL_PAGES)||pi.FESTIVAL_PAGES,TASTING_PAGES:((bi=window.wineaterData)==null?void 0:bi.TASTING_PAGES)||pi.TASTING_PAGES},za={PRODUCT_PAGES:((vi=window.wineaterData)==null?void 0:vi.PRODUCT_PAGES)||At.PRODUCT_PAGES,CART_PAGE:((yi=window.wineaterData)==null?void 0:yi.CART_PAGE)||(At==null?void 0:At.CART_PAGE)};async function Ha(){const t=window.location.href;for(const[e,n]of Object.entries(Ua))if(n.test(t))return!1;for(const[e,n]of Object.entries(za))if(n.test(t))try{console.log(dishes);const s=setTimeout(()=>{openChatWindow()},15e3);return ja(s),!0}catch(s){return console.error("Error fetching dishes:",s),!1}return!1}const $a="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Wa{constructor(){var e,n;this.stores=["climats","telckel","biobio","weinpoint","vinigrandi","ampely","test"],this.tracker=new Na({projectKey:"PA8j9fAi49i6g2QnvpNs",__DISABLE_SECURE_MODE:!0}),this.position=((e=window==null?void 0:window.wineaterData)==null?void 0:e.POSITION)||"right-center",this.type=((n=window==null?void 0:window.wineaterData)==null?void 0:n.TYPE)||"chatbot",this.store=this.detectStore()}detectStore(){return this.stores.find(e=>window.location.href.includes(e))||null}async initFlagsmith(){try{await Gn.init({environmentID:"5RfiDoiqb4dHrNdQvzbkfM",cacheFlags:!1,enableAnalytics:!0,identity:se("uniqueUserID")})}catch(e){console.error("Flagsmith initialization failed:",e)}}async initTranslator(){const e=this.store?this.store.charAt(0).toUpperCase()+this.store.slice(1):"Test";await W.fetchConfig(e||"Test")}initCookies(){var e;rt("chatbotToken",((e=window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||$a,365),_i()}async initializeChatbotOrWidget(){this.type==="widget"?new Da:(this.createChatbotUI(),this.setupChatListeners(),this.setupChatButtonListener(),qa(this.position),new Ma().initialize())}createChatbotUI(){var i;const e=Gn.getValue("chat-btn-txt"),s=`
|
|
1051
1060
|
<div id="chatbot-container">
|
|
1052
1061
|
<div id="chat-icon">
|
|
1053
1062
|
<img src="https://czvgkhagwvmknscoerfy.supabase.co/storage/v1/object/public/static-media/chat-icon.svg" alt="Chat Icon">
|
|
1054
|
-
<span>${((i=window==null?void 0:window.wineaterData)==null?void 0:i.BUTTON_TEXT)||
|
|
1063
|
+
<span>${((i=window==null?void 0:window.wineaterData)==null?void 0:i.BUTTON_TEXT)||W.translate(`chatButton${e}`)}</span>
|
|
1055
1064
|
</div>
|
|
1056
1065
|
<div id="chat-window" class="hidden">
|
|
1057
1066
|
<div id="chat-header">
|
|
1058
1067
|
<div id="chat-title">
|
|
1059
|
-
<h1>${
|
|
1068
|
+
<h1>${W.translate("chatTitle")}</h1>
|
|
1060
1069
|
</div>
|
|
1061
1070
|
<div id="close-btn">×</div>
|
|
1062
1071
|
</div>
|
|
@@ -1065,12 +1074,12 @@ If you're using serverside rendering in your app, make sure that tracker is load
|
|
|
1065
1074
|
<span></span><span></span><span></span>
|
|
1066
1075
|
</div>
|
|
1067
1076
|
<div id="input-container">
|
|
1068
|
-
<input type="text" id="user-input" placeholder="${
|
|
1069
|
-
<button id="send-button">${
|
|
1077
|
+
<input type="text" id="user-input" placeholder="${W.translate("inputPlaceholder")}">
|
|
1078
|
+
<button id="send-button">${W.translate("sendButton")}</button>
|
|
1070
1079
|
</div>
|
|
1071
1080
|
<div id="powered-by">
|
|
1072
1081
|
<a href="https://wineater.com" target="_blank">
|
|
1073
|
-
<span>${
|
|
1082
|
+
<span>${W.translate("poweredBy")}</span>
|
|
1074
1083
|
<img src="https://czvgkhagwvmknscoerfy.supabase.co/storage/v1/object/public/static-media/logo.svg" alt="Wineater Logo" id="chatbot-logo">
|
|
1075
1084
|
</a>
|
|
1076
1085
|
</div>
|