PageSourceSearch

https://scriptflo.ai/_next/static/chunks/0lfo0m.iethu0.js

js scriptflo.ai collected 2026-10-05 12:38:46 UTC 341,569 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,22284,(e,t,n)=>{var r=Object.prototype.hasOwnProperty;function i(e){return"[Throws: "+(e?e.message:"?")+"]"}function o(e){var t=[];return function e(n){if(null===n||"object"!=typeof n)return n;if(-1!==t.indexOf(n))return"[Circular]";if(t.push(n),"function"==typeof n.toJSON)try{var o=e(n.toJSON());return t.pop(),o}catch(e){return i(e)}if(Array.isArray(n)){var s=n.map(e);return t.pop(),s}var a=Object.keys(n).reduce(function(t,o){return t[o]=e(function(e,t){if(r.call(e,t))try{return e[t]}catch(e){return i(e)}return e[t]}(n,o)),t},{});return t.pop(),a}(e)}t.exports=function(e,t,n){return JSON.stringify(o(e),t,n)},t.exports.ensureProperties=o},60953,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Observable=void 0;let r=e=>!!Symbol[e],i=e=>r(e)?Symbol[e]:"@@"+e,o=i("iterator"),s=i("observable"),a=i("species");function u(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw TypeError(n+" is not a function");return n}}function l(e){let t=e.constructor;return void 0!==t&&null===(t=t[a])&&(t=void 0),void 0!==t?t:m}function c(e){c.log?c.log(e):setTimeout(()=>{throw e})}function d(e){Promise.resolve().then(()=>{try{e()}catch(e){c(e)}})}function f(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=u(t,"unsubscribe");e&&e.call(t)}}catch(e){c(e)}}function g(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function h(e,t,n){e._state="running";let r=e._observer;try{let i=u(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(g(e),i)i.call(r,n);else throw n;break;case"complete":g(e),i&&i.call(r)}}catch(e){c(e)}"closed"===e._state?f(e):"running"===e._state&&(e._state="ready")}function p(e,t,n){if("closed"!==e._state){if("buffering"===e._state)return void e._queue.push({type:t,value:n});if("ready"!==e._state){e._state="buffering",e._queue=[{type:t,value:n}],d(()=>(function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(h(e,t[n].type,t[n].value),"closed"!==e._state);++n);}})(e));return}h(e,t,n)}}class v{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){p(n,"next",e)},error(e){p(n,"error",e)},complete(){p(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(g(this),f(this))}}class m{constructor(e){if(!(this instanceof m))throw TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return("object"!=typeof e||null===e)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new v(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if("function"!=typeof e)return void n(TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if("function"!=typeof e)throw TypeError(e+" is not a function");return new(l(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw TypeError(e+" is not a function");return new(l(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw TypeError(e+" is not a function");let t=l(this),n=arguments.length>1,r=!1,i=arguments[1],o=i;return new t(t=>this.subscribe({next(i){let s=!r;if(r=!0,!s||n)try{o=e(o,i)}catch(e){return t.error(e)}else o=i},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(TypeError("Cannot reduce an empty sequence"));t.next(o),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=l(this);return new t(n=>{let r,i=0;return!function o(s){r=s.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if("function"!=typeof e)throw TypeError(e+" is not a function");let t=l(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let s=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(s);e>=0&&r.splice(e,1),o()}});r.push(s)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>
1{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[s](){return this}static from(e){let t="function"==typeof this?this:m;if(null==e)throw TypeError(e+" is not an object");let n=u(e,s);if(n){let r=n.call(e);if(Object(r)!==r)throw TypeError(r+" is not an object");return r instanceof m&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(r("iterator")&&(n=u(e,o)))return new t(t=>{d(()=>{if(!t.closed){for(let r of n.call(e))if(t.next(r),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{d(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})});throw TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:m)(t=>{d(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})})}static get[a](){return this}}n.Observable=m,Object.defineProperty(m,Symbol("extensions"),{value:{symbol:s,hostReportError:c},configurable:!0})},81243,(e,t,n)=>{t.exports=e.r(60953).Observable},78869,e=>{"use strict";let t;e.i(47167);var n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,S,w,E,k,I,T,C,P,x,A,O,R,M,D,L,N,F,q,U,j,B,z,W,G,H,K,V,$,J,Y,Q,X,Z=e.i(90571);(n=x||(x={}))[n.None=0]="None",n[n.Error=1]="Error",n[n.Warn=2]="Warn",n[n.Verbose=3]="Verbose",n[n.Debug=4]="Debug";var ee=function(e){return void 0===e&&(e=0),(Error().stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},et=function(e){return function(){var t=(0,Z.__assign)({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},en=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=(0,Z.__values)(t.split(".")),o=i.next();!o.done;o=i.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},er=function(e,t){return function(){var n,r,i={};try{for(var o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=en(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ei=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n(),u=a.logger,l=a.logLevel;if(l&&l<x.Debug||!l||!u)return e.apply(i,o);var c={type:"invoke public method",name:t,args:o,stacktrace:ee(1),time:{start:new Date().toISOString()},states:{}};r&&c.states&&(c.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))}):(r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))),d}};(r=A||(A={})).SET="$set",r.SET_ONCE="$setOnce",r.ADD="$add",r.APPEND="$append",r.PREPEND="$prepend",r.REMOVE="$remove",r.PREINSERT="$preInsert",r.POSTINSERT="$postInsert",r.UNSET="$unset",r.CLEAR_ALL="$clearAll",(i=O||(O={})).IDENTIFY="$identify",i.GROUP_IDENTIFY="$groupidentify",i.REVENUE="revenue_amount";var eo="".concat("AMP","_unsent"),es="$default_instance",ea="https://api2.amplitude.com/2/httpapi",eu="https://api.eu.amplitude.com/2/httpapi",el="https://api2.amplitude.com/batch",ec="https://api.eu.amplitude.com/batch",ed="dclid",ef="fbclid",eg="gbraid",eh="gclid",ep="ko_click_id",ev="li_fat_id",em="msclkid",ey="rdt_cid",e_="ttclid",eb="twclid",eS="wbraid",ew={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},eE=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],ek=["authorization","cookie","set-cookie"],eI=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!eT(t,n))return!1}return!0},eT=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)i=i&&eI(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else if(null==t)return!1;else if("object"==typeof t)return eI(t);else if(!["number","string","boolean"].includes(typeof t))return!1;return!0},eC=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return(0,Z.__assign)({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(R.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(R.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(R.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(R.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(R.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(R.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(R.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(R.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(R.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[R.CLEAR_ALL]="-",this}
1,e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return!(void 0!==this._properties[R.CLEAR_ALL]||this._propertySet.has(t))&&(e===R.ADD?"number"==typeof n:e===R.UNSET||e===R.REMOVE||eT(t,n))},e}();(o=R||(R={})).SET="$set",o.SET_ONCE="$setOnce",o.ADD="$add",o.APPEND="$append",o.PREPEND="$prepend",o.REMOVE="$remove",o.PREINSERT="$preInsert",o.POSTINSERT="$postInsert",o.UNSET="$unset",o.CLEAR_ALL="$clearAll";var eP=[R.CLEAR_ALL,R.UNSET,R.SET,R.SET_ONCE,R.ADD,R.APPEND,R.PREPEND,R.PREINSERT,R.POSTINSERT,R.REMOVE];(s=M||(M={})).Unknown="unknown",s.Skipped="skipped",s.Success="success",s.RateLimit="rate_limit",s.PayloadTooLarge="payload_too_large",s.Invalid="invalid",s.Failed="failed",s.Timeout="Timeout",s.SystemError="SystemError";var ex=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=M.Unknown),{event:e,code:t,message:n}},eA=e.i(89812),eO=(0,Z.__spreadArray)([],(0,Z.__read)(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),eR=function(e){var t,n=(0,eA.getGlobalScope)();if(!(null==(t=null==n?void 0:n.crypto)?void 0:t.getRandomValues))return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,eR);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(0,Z.__spreadArray)([],(0,Z.__read)(r.entries()),!1).map(function(e){var t=(0,Z.__read)(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(eO[r]):eO[r]}).join("")},eM=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(void 0===e.name&&(e.name=eR(),this.loggerProvider.warn("Plugin name is undefined.\n      Generating a random UUID for plugin name: ".concat(e.name,".\n      Set a name for the plugin to prevent it from being added multiple times."))),i=e.name,this.pluginStatus.has(i))return this.loggerProvider.warn("Plugin with name ".concat(i," already exists, skipping registration")),[2];return e.type=null!=(n=e.type)?n:"enrichment",this.pluginStatus.set(i,"locked"),[4,null==(r=e.setup)?void 0:r.call(e,t,this.client)];case 1:if(o.sent(),"locked"!==this.pluginStatus.get(i))return[2];return this.plugins.push(e),this.pluginStatus.set(i,"installed"),[2]}})})},e.prototype.deregister=function(e,t){var n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(this.pluginStatus.delete(e),-1===(r=this.plugins.findIndex(function(t){return t.name===e})))return t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2];return i=this.plugins[r],this.plugins.splice(r,1),[4,null==(n=i.teardown)?void 0:n.call(i)];case 1:return o.sent(),[2]}})})},e.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1,this.plugins.map(function(e){var t;return null==(t=e.teardown)?void 0:t.call(e)}),this.plugins=[],this.pluginStatus.clear(),this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(n){t.queue.push([e,n]),t.scheduleApply(0)})},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout(function(){t.apply(t.queue.shift()).then(function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)})},e))},e.prototype.apply=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s,a,u,l,c,d,f,g,h,p;return(0,Z.__generator)(this,function(v){switch(v.label){case 0:if(!e)return[2];t=(0,Z.__read)(e,1)[0],n=(0,Z.__read)(e,2)[1],this.loggerProvider.log("Timeline.apply: Initial event",t),r=this.plugins.filter(function(e){return"before"===e.type}),v.label=1;case 1:v.trys.push([1,6,7,8]),o=(i=(0,Z.__values)(r)).next(),v.label=2;case 2:if(o.done)return[3,5];if(!(s=o.value).execute)return[3,4];return[4,s.execute((0,Z.__assign)({},t))];case 3:if(null===(a=v.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),n({event:t,code:0,message:""}),[2];t=a,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),v.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f={error:v.sent()},[3,8];case 7:try{o&&!o.done&&(g=i.return)&&g.call(i)}finally{if(f)throw f.error}
1return[7];case 8:u=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),v.label=9;case 9:v.trys.push([9,14,15,16]),c=(l=(0,Z.__values)(u)).next(),v.label=10;case 10:if(c.done)return[3,13];if(!(s=c.value).execute)return[3,12];return[4,s.execute((0,Z.__assign)({},t))];case 11:if(null===(a=v.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),n({event:t,code:0,message:""}),[2];t=a,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),v.label=12;case 12:return c=l.next(),[3,10];case 13:return[3,16];case 14:return h={error:v.sent()},[3,16];case 15:try{c&&!c.done&&(p=l.return)&&p.call(l)}finally{if(h)throw h.error}return[7];case 16:return d=this.plugins.filter(function(e){return"destination"===e.type}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(t))),Promise.all(d.map(function(e){var n=(0,Z.__assign)({},t);return e.execute(n).catch(function(e){return ex(n,0,String(e))})})).then(function(e){var r=(0,Z.__read)(e,1)[0]||ex(t,100,"Event not tracked, no destination plugins on the instance");n(r)}),[2]}})})},e.prototype.flush=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return t.apply(e)}))];case 1:return n.sent(),[4,Promise.all(this.plugins.filter(function(e){return"destination"===e.type}).map(function(e){return e.flush&&e.flush()}))];case 2:return n.sent(),[2]}})})},e.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},e.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(t){var n;null==(n=t.onIdentityChanged)||n.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var n;null==(n=t.onSessionIdChanged)||n.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var n;null==(n=t.onOptOutChanged)||n.call(t,e)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=(t=(0,Z.__values)(this._optOutListeners)).next(),a.label=1;case 1:if(n.done)return[3,6];r=n.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,r(e)];case 3:return a.sent(),[3,5];case 4:return i=a.sent(),this.loggerProvider.error("Error calling optOut listener",i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return o={error:a.sent()},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null==(t=e.onReset)||t.call(e)})},e}(),eD=function(e,t){return(0,Z.__assign)((0,Z.__assign)({},t),{event_type:O.IDENTIFY,user_properties:e.getUserProperties()})},eL=function(e,t,n,r){var i;return(0,Z.__assign)((0,Z.__assign)({},r),{event_type:O.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:((i={})[e]=t,i)})},eN=function(e,t,n){var r,i=new eC;return i.set(e,t),(0,Z.__assign)((0,Z.__assign)({},n),{event_type:O.IDENTIFY,user_properties:i.getUserProperties(),groups:((r={})[e]=t,r)})},eF=function(e){return{promise:e||Promise.resolve()}},eq=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new eM(this),this.name=e}return e.prototype._init=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q",function(){return t.isReady=!0})];case 1:return n.sent(),[2]}})})},e.prototype.runQueuedFunctions=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i,o,s,a;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:n=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),i=(r=(0,Z.__values)(n)).next(),u.label=2;case 2:if(i.done)return[3,7];if(!((o=(0,i.value)())&&"promise"in o))return[3,4];return[4,o.promise];case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return i=r.next(),[3,2];case 7:return[3,10];case 8:return s={error:u.sent()},[3,10];case 9:try{i&&!i.done&&(a=r.return)&&a.call(r)}finally{if(s)throw s.error}
1return[7];case 10:if(!this[e].length)return[3,12];return[4,this.runQueuedFunctions(e,t)];case 11:return u.sent(),[3,13];case 12:null==t||t(),u.label=13;case 13:return[2]}})})},e.prototype.track=function(e,t,n){var r=(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t});return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),eF(this.dispatch(r))},e.prototype.identify=function(e,t){var n=eD(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),eF(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=eL(e,t,n,r);return eF(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=eN(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),eF(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=(0,Z.__assign)((0,Z.__assign)({},t),{event_type:O.REVENUE,event_properties:e.getEventProperties()});return eF(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),eF())},e.prototype._addPlugin=function(e){return eF(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),eF())},e.prototype._removePlugin=function(e){return eF(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(ex(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,Z.__generator)(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))})]})})},e.prototype.getOperationAppliedUserProperties=function(e){var t,n=null!=(t=this.userProperties)?t:{},r=(0,Z.__assign)({},n);if(void 0===e)return r;var i={};return Object.keys(e).forEach(function(t){Object.values(A).includes(t)||(i[t]=e[t])}),eP.forEach(function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case A.CLEAR_ALL:Object.keys(r).forEach(function(e){delete r[e]});break;case A.UNSET:Object.keys(n).forEach(function(e){delete r[e]});break;case A.SET:Object.assign(r,n)}}}),Object.assign(r,i),r},e.prototype.process=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),this.config.optOut)return[2,ex(e,0,"Event skipped due to optOut config")];return e.event_type===O.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)];case 1:return 200===(t=r.sent()).code?this.config.loggerProvider.log(t.message):100===t.code?this.config.loggerProvider.warn(t.message):this.config.loggerProvider.error(t.message),[2,t];case 2:return n=String(r.sent()),this.config.loggerProvider.error(n),[2,t=ex(e,0,n)];case 3:return[2]}})})},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,!!e))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=!!e,this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return eF(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find(function(t){return t.name===e});return void 0===t?void this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e)):t},e.prototype.plugins=function(e){return this.timeline.plugins.filter(function(t){return t instanceof e})},e}(),eU=function(e,t){var n=Math.max(t,1);return e.reduce(function(e,t,r){var i=Math.floor(r/n);return e[i]||(e[i]=[]),e[i].push(t),e},[])},ej="Amplitude Logger ",eB=function(){function e(){this.logLevel=x.None}return e.prototype.disable=function(){this.logLevel=x.None},e.prototype.enable=function(e){void 0===e&&(e=x.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Verbose||console.log("".concat(ej,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Warn||console.warn("".concat(ej,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Error||console.error("".concat(ej,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Debug||console.log("".concat(ej,"[Debug]: ").concat(e.join(" ")))},e}(),ez=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:es,logLevel:x.Warn,loggerProvider:new eB,offline:!1,optOut:!1,serverUrl:ea,serverZone:"US",useBatch:!1}},eW=function(){function e(e){this._optOut=!1;var t,n,r,i,o=ez();this.apiKey=e.apiKey,this.flushIntervalMillis=null!=(t=e.flushIntervalMillis)?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!=(n=e.logLevel)?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!=(r=e.optOut)?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!=(i=e.useBatch)?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=eG(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
1,enumerable:!1,configurable:!0}),e}(),eG=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=ez().serverZone),void 0===n&&(n=ez().useBatch),e)return{serverUrl:e,serverZone:void 0};var r,i=["US","EU"].includes(t)?t:ez().serverZone;return{serverZone:i,serverUrl:(r=n,"EU"===i?r?ec:eu:r?el:ea)}},eH=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function eK(e){return e>=200&&e<300}var eV=new Set([ea,eu,el,ec]);function e$(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var eJ=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r=this;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(eo,"_").concat(this.config.apiKey.substring(0,10)),[4,null==(t=this.config.storageProvider)?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map(function(e){return r.execute(e)})).catch(),[2,Promise.resolve(void 0)]}})})},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=eR()),new Promise(function(n){t.queue.push({event:e,attempts:0,callback:function(e){return n(e)},timeout:0}),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter(function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)})},e.prototype.scheduleEvents=function(e){var t=this;e.forEach(function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)})},e.prototype.schedule=function(e){var t=this;if(!this.config.offline&&(null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout)){this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,this.scheduleId=setTimeout(function(){t.queue=t.queue.map(function(e){return e.timeout=0,e}),t.flush(!0)},e);return}},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r=this;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(this.config.offline)return this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2];if(this.flushId)return this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2];return this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):n.push(e)}),[4,eU(t,this.config.flushQueueSize).reduce(function(t,n){return(0,Z.__awaiter)(r,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}})})},Promise.resolve())];case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a;return(0,Z.__generator)(this,function(u){var l,c,d;switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,(0,Z.__rest)(t,["extra"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new eH,u.label=1;case 1:return u.trys.push([1,3,,4]),l=i=eG(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,void 0===(c=this.config.enableRequestBodyCompression)&&(c=!1),o=!!eV.has(l)||c,[4,this.config.transportProvider.send(i,r,o)];case 2:if(null===(s=u.sent()))return this.fulfillRequest(e,0,"Unexpected error occurred"),[2];if(!t)return"body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(e$(s))):this.fulfillRequest(e,s.statusCode,s.status),[2];return this.handleResponse(s,e),[3,4];case 3:return a=(d=u.sent())instanceof Error?d.message:String(d),this.config.loggerProvider.error(a),null==(n=this.diagnosticsClient)||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:a,stack_trace:ee()}),this.handleResponse({status:M.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},e.prototype.handleResponse=function(e,t){eK(e.statusCode)||null==(n=this.diagnosticsClient)||n.recordEvent("analytics.events.unsuccessful",{events:t.map(function(e){return e.event.event_type}),code:e.statusCode,status:e.status,body:e$(e),stack_trace:ee()});var n,r=e.status;switch(r){case M.Success:this.handleSuccessResponse(e,t);break;case M.Invalid:this.handleInvalidResponse(e,t);break;case M.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case M.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))return void this.fulfillRequest(t,e.statusCode,e.body.error);var r=new Set((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(Object.values(e.body.eventsWithInvalidFields)),!1),(0,Z.__read)(Object.values(e.body.eventsWithMissingFields)),!1),(0,Z.__read)(Object.values(e.body.eventsWithInvalidIdLengths)),!1),(0,Z.__read)(e.body.silencedEvents),!1).flat()),i=t.filter(function(t,i){return!r.has(i)||void n.fulfillRequest([t],e.statusCode,e.body.error)});i.length>0&&this.config.loggerProvider.warn(e$(e));
1var o=this.removeEventsExceedFlushMaxRetries(i);this.scheduleEvents(o)},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1===t.length)return void this.fulfillRequest(t,e.statusCode,e.body.error);this.config.loggerProvider.warn(e$(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),a=new Set(i),u=new Set(o),l=t.filter(function(t,r){return t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)?void n.fulfillRequest([t],e.statusCode,e.body.error):(u.has(r)&&(t.timeout=n.throttleTimeout),!0)});l.length>0&&this.config.loggerProvider.warn(e$(e));var c=this.removeEventsExceedFlushMaxRetries(l);this.scheduleEvents(c)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map(function(e){return e.timeout=e.attempts*t.retryTimeout,e}),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;eK(t)?null==(o=this.diagnosticsClient)||o.increment("analytics.events.sent",e.length):(null==(r=this.diagnosticsClient)||r.increment("analytics.events.dropped",e.length),null==(i=this.diagnosticsClient)||i.recordEvent("analytics.events.dropped",{events:e.map(function(e){return e.event.event_type}),code:t,message:n,stack_trace:ee()})),this.removeEvents(e),e.forEach(function(e){return e.callback(ex(e.event,t,n))})},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(e){return e.event});this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(t){return!e.some(function(e){return e.event.insert_id===t.event.insert_id})}),this.saveEvents()},e}(),eY=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){try{var t=JSON.parse(JSON.stringify(e));eI(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?(0,Z.__assign)({},this.properties):{};return e[D.REVENUE_PRODUCT_ID]=this.productId,e[D.REVENUE_QUANTITY]=this.quantity,e[D.REVENUE_PRICE]=this.price,e[D.REVENUE_TYPE]=this.revenueType,e[D.REVENUE_CURRENCY]=this.currency,e[D.REVENUE]=this.revenue,e[D.RECEIPT]=this.receipt,e[D.RECEIPT_SIG]=this.receiptSig,e},e}();(a=D||(D={})).REVENUE_PRODUCT_ID="$productId",a.REVENUE_QUANTITY="$quantity",a.REVENUE_PRICE="$price",a.REVENUE_TYPE="$revenueType",a.REVENUE_CURRENCY="$currency",a.REVENUE="$revenue",a.RECEIPT="$receipt",a.RECEIPT_SIG="$receiptSig";var eQ=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:eX(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),eX=function(){return"u">typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},eZ=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(t){e(t)}),this.queue=[])},e}(),e0=function(){return(e0=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function e1(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);
1if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function e2(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var e3=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=e1(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next())if(s.value===i)return e===t}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t||e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(a&&u){for(var l=0;l<e.length;l++)if(!e3(e[l],t[l]))return!1}else{if(!e3(Object.keys(e).sort(),Object.keys(t).sort()))return!1;var c=!0;return Object.keys(e).forEach(function(n){e3(e[n],t[n])||(c=!1)}),c}return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var e4=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=e0({},this.identity.userProperties),n=e0(e0({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,s,a,u=n.userProperties||{};try{for(var l=e1(Object.entries(e)),c=l.next();!c.done;c=l.next()){var d=e2(c.value,2),f=d[0],g=d[1];switch(f){case"$set":try{for(var h=(i=void 0,e1(Object.entries(g))),p=h.next();!p.done;p=h.next()){var v=e2(p.value,2),m=v[0],y=v[1];u[m]=y}}catch(e){i={error:e}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}break;case"$unset":try{for(var _=(s=void 0,e1(Object.keys(g))),b=_.next();!b.done;b=_.next()){var m=b.value;delete u[m]}}catch(e){s={error:e}}finally{try{b&&!b.done&&(a=_.return)&&a.call(_)}finally{if(s)throw s.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return e0({},this.identity)},e.prototype.setIdentity=function(e){var t=e0({},this.identity);this.identity=e0({},e),e3(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),e5="u">typeof globalThis?globalThis:e.g,e6=function(){function e(){this.identityStore=new e4,this.eventBridge=new eZ,this.applicationContextProvider=new eQ}return e.getInstance=function(t){return e5.analyticsConnectorInstances||(e5.analyticsConnectorInstances={}),e5.analyticsConnectorInstances[t]||(e5.analyticsConnectorInstances[t]=new e),e5.analyticsConnectorInstances[t]},e}(),e8=function(e){return void 0===e&&(e=es),e6.getInstance(e)},e7=function(e,t){e8(t).identityStore.editIdentity().setUserId(e).commit()},e9=function(e,t){e8(t).identityStore.editIdentity().setDeviceId(e).commit()},te=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},tt=function(){function e(){this.name="identity",this.type="before",this.identityStore=e8().identityStore}return e.prototype.execute=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return e.instanceName&&(this.identityStore=e8(e.instanceName).identityStore),[2]})})},e}(),tn=function(){var e,t=(0,eA.getGlobalScope)();return(null==(e=null==t?void 0:t.location)?void 0:e.search)?t.location.search.substring(1).split("&").filter(
1Boolean).reduce(function(e,t){var n=t.split("=",2),r=tr(n[0]),i=tr(n[1]);return i&&(e[r]=i),e},{}):{}},tr=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},ti=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),to=function(){function e(e,t,n,r,i){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new ti(e,t),this.customFetch=i}return e.prototype.subscribe=function(e,t,n){var r=eR(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return -1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5)return this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2];return[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null})):this.fetchPromise=this.fetch().then(function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null})),this.fetchPromise},e.prototype.subscribeAll=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending c
1allback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i,o,s,a,u=this;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,a,l,c,d,f,g,h;return(0,Z.__generator)(this,function(p){switch(p.label){case 0:i=!0,s=new AbortController,a=setTimeout(function(){return s.abort()},t),p.label=1;case 1:var v,m;if(p.trys.push([1,10,11,12]),l=o.getUrlParams(),c={Accept:"*/*"},!o.customFetch)return[3,3];return[4,(v=o.customFetch({url:l,method:"GET",headers:c,signal:s.signal}),m=s.signal,new Promise(function(e,t){var n=function(){var e=Error("Remote config custom fetch aborted by timeout");e.name="AbortError",t(e)};m.addEventListener("abort",n,{once:!0}),v.then(function(t){m.removeEventListener("abort",n),e(t)},function(e){m.removeEventListener("abort",n),t(e)})}))];case 2:return f=p.sent(),[3,5];case 3:return[4,fetch(l,{method:"GET",headers:c,signal:s.signal})];case 4:f=p.sent(),p.label=5;case 5:if((d=f).ok||d.status>=200&&d.status<300)return[3,7];return[4,d.text()];case 6:return g=p.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(d.status,": ").concat(g)),401===d.status||403===d.status?(o.logger.error("Remote config client fetch failed with ".concat(d.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):d.status>=400&&d.status<500&&429!==d.status&&(i=!1),[3,9];case 7:return[4,d.json()];case 8:return[2,{value:{remoteConfig:p.sent(),lastFetch:new Date}}];case 9:return[3,12];case 10:return(h=p.sent())instanceof Error&&"AbortError"===h.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),h),[3,12];case 11:return clearTimeout(a),[7];case 12:if(!i)return[2,"break"];if(!(r<e-1))return[3,14];return[4,new Promise(function(e){return setTimeout(e,u.getJitterDelay(n))})];case 13:p.sent(),p.label=14;case 14:return[2]}})},o=this,s=0,l.label=1;case 1:if(!(s<e))return[3,4];return[5,i(s)];case 2:if("object"==typeof(a=l.sent()))return[2,a.value];if("break"===a)return[3,4];l.label=3;case 3:return s++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),ts="tags",ta="counters",tu="histograms",tl="events",tc="internal",td="last_flush_timestamp",tf=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return(null==(e=(0,eA.getGlobalScope)())?void 0:e.indexedDB)!==void 0},e.prototype.getDB=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},e.prototype.openDB=function(){var e=this;return new Promise(function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(Error("Failed to open IndexedDB"))},r.onsuccess=function(){var n=r.result;
1n.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},n.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),n.close()},t(n)},r.onupgradeneeded=function(){var t=r.result;t?e.createTables(t):e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.")}})},e.prototype.createTables=function(e){e.objectStoreNames.contains(ts)||e.createObjectStore(ts,{keyPath:"key"}),e.objectStoreNames.contains(ta)||e.createObjectStore(ta,{keyPath:"key"}),e.objectStoreNames.contains(tu)||e.createObjectStore(tu,{keyPath:"key"}),e.objectStoreNames.contains(tl)||e.createObjectStore(tl,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1}),e.objectStoreNames.contains(tc)||e.createObjectStore(tc,{keyPath:"key"})},e.prototype.setTags=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return n=(t=o.sent().transaction([ts],"readwrite")).objectStore(ts),[2,new Promise(function(r){var o=Object.entries(e);t.oncomplete=function(){r()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to set tags",e),r()},o.forEach(function(e){var t=(0,Z.__read)(e,2),r=t[0],o=t[1];n.put({key:r,value:o}).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to set tag",r,o,e)}})})];case 2:return r=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",r),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return n=(t=o.sent().transaction([ta],"readwrite")).objectStore(ta),[2,new Promise(function(r){var o=Object.entries(e);t.oncomplete=function(){r()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to increment counters",e),r()},o.forEach(function(e){var t=(0,Z.__read)(e,2),r=t[0],o=t[1],s=n.get(r);s.onsuccess=function(){var e=s.result,t=e?e.value:0;n.put({key:r,value:t+o}).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to update counter",r,e)}},s.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to read existing counter",r,e)}})})];case 2:return r=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",r),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return n=(t=o.sent().transaction([tu],"readwrite")).objectStore(tu),[2,new Promise(function(r){var o=Object.entries(e);t.oncomplete=function(){r()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),r()},o.forEach(function(e){var t=(0,Z.__read)(e,2),r=t[0],o=t[1],s=n.get(r);s.onsuccess=function(){var e,t=s.result;e=t?{key:r,count:t.count+o.count,min:Math.min(t.min,o.min),max:Math.max(t.max,o.max),sum:t.sum+o.sum}:{key:r,count:o.count,min:o.min,max:o.max,sum:o.sum},n.put(e).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to set histogram stats",r,e)}},s.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",r,e)}})})];case 2:return r=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",r),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===e.length)return[2];return[4,this.getDB()];case 1:return n=(t=o.sent().transaction([tl],"readwrite")).objectStore(tl),[2,new Promise(function(r){t.oncomplete=function(){r()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to add event records",e),r()};var o=n.count();o.onsuccess=function(){var t=Math.max(0,10-o.result);t<e.length&&i.logger.debug("DiagnosticsStorage: Only added ".concat(t," of ").concat(e.length," events due to storage limit")),e.slice(0,t).forEach(function(e){n.add(e).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to add event record",e)}})},o.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}})];case 2:return r=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",r),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return r=(n=o.sent().transaction([tc],"readwrite")).objectStore(tc),[2,new Promise(function(i,o){n.onabort=function(){return o(Error("Failed to set internal value"))};var s=r.put({key:e,value:t});s.onsuccess=function(){return i()},s.onerror=function(){return o(Error("Failed to set internal value"))}})];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",i),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=(t=i.sent().transaction([tc],"readonly")).objectStore(tc),[2,new Promise(function(r,i){t.onabort=function(){return i(Error("Failed to get internal value"))};var o=n.get(e);o.onsuccess=function(){return r(o.result)},o.onerror=function(){return i(Error("Failed to get internal value"))}})];case 2:return r=i.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",r),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(td)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}})})},e.prototype.setLastFlushTimestamp=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(td,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}})})},e.prototype.clearTable=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(Error("Failed to clear table ".concat(t)))}})},e.prototype.getAllAndClear=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,n,r,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=a.sent().transaction([ts,ta,tu,tl],"readwrite"),[4,Promise.all([this.getAllFromStore(e,ts),this.getAllFromStore(e,ta),this.getAllFromStore(e,tu),this.getAllFromStore(e,tl)])];case 2:return n=(t=Z.__read.apply(void 0,[a.sent(),4]))[0],r=t[1],i=t[2],o=t[3],[4,Promise.all([this.clearTable(e,ta),this.clearTable(e,tu),this.clearTable(e,tl)])];case 3:return a.sent(),[2,{tags:n,counters:r,histogramStats:i,events:o}];case 4:return s=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",s),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(Error("Failed to get all from ".concat(t)))}})},e}(),tg=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}
1,th=function(e,t){return 31*Math.abs(tg(e.toString()))%1e5/1e5<t},tp=function(){var e=(0,eA.getGlobalScope)();if(!e)return[];var t=e.__AMPLITUDE_SCRIPT_URL__;return Array.isArray(t)?t:"string"==typeof t?[t]:[]},tv=function(e){var t=(0,eA.getGlobalScope)();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",(0,Z.__assign)({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=tm({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})},!0),t.addEventListener("unhandledrejection",function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=ty(i),s=tm({filename:o,stack:i});s&&n({type:"unhandledrejection",message:null!=(t=null==r?void 0:r.message)?t:t_(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:s}})},!0)}},tm=function(e){var t,n,r=tp();if(0!==r.length)try{for(var i=(0,Z.__values)(r),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.filename&&e.filename.includes(s))return"filename";if(e.stack&&e.stack.includes(s))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},ty=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},t_=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},tb=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=(0,Z.__assign)({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=th(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,tf.isSupported()?this.storage=new tf(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),tv(this))}return e.prototype.isStorageAndTrackEnabled=function(){return!!this.storage&&!!this.shouldTrack},e.prototype.setTag=function(e,t){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryTags).length>=1e4)return void this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit");this.inMemoryTags[e]=t,this.startTimersIfNeeded()}},e.prototype.increment=function(e,t){if(void 0===t&&(t=1),this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryCounters).length>=1e4)return void this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit");this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()}},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryHistograms).length>=1e4)return void this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){if(this.isStorageAndTrackEnabled()){if(this.inMemoryEvents.length>=10)return void this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit");this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()}},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout(function(){e.saveAllDataToStorage().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)}).finally(function(){e.saveTimer=null})},1e3)),this.flushTimer||(this.flushTimer=setTimeout(function(){e._flush().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)}).finally(function(){e.flushTimer=null})},3e5))},e.prototype.saveAllDataToStorage=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];return e=(0,Z.__assign)({},this.inMemoryTags),t=(0,Z.__assign)({},this.inMemoryCounters),n=(0,Z.__assign)({},this.inMemoryHistograms),r=(0,Z.__spreadArray)([],(0,Z.__read)(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])];case 1:return i.sent(),[2]}})})},e.prototype._flush=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l;return(0,Z.__generator)(this,function(c){switch(c.label){case 0:if(!this.storage)return[2];return[4,this.saveAllDataToStorage()];case 1:return c.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:if(t=(e=c.sent()).tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={}
1,n.forEach(function(e){s[e.key]=e.value}),a={},r.forEach(function(e){a[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),u=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(s).length&&0===Object.keys(a).length&&0===u.length)return[2];return l={tags:o,histogram:a,counters:s,events:u},this.fetch(l),[2]}})})},e.prototype.fetch=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!(0,eA.getGlobalScope)())throw Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:if(!n.sent().ok)return this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2];return this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}})})},e.prototype.initializeFlushInterval=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,n;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(!this.storage)return[2];return e=Date.now(),[4,this.storage.getLastFlushTimestamp()];case 1:if(-1===(t=r.sent()||-1))return this.storage.setLastFlushTimestamp(e),this._setFlushTimer(3e5),[2];return(n=e-t)>=3e5?this._flush():this._setFlushTimer(3e5-n),[2]}})})},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout(function(){t._flush().catch(function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)}).finally(function(){t.flushTimer=null})},e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=th(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),tS=e.i(22284),tw=tS.default||tS,tE=function(e,t){var n,r,i;return"boolean"==typeof e?e:(null==e?void 0:e[t])!==!1&&("string"!=typeof(null==(r=null==(n=null==(i=(0,eA.getGlobalScope)())?void 0:i.chrome)?void 0:n.runtime)?void 0:r.id)||!!(null==e?void 0:e[t]))},tk=function(e){return tE(e,"attribution")},tI=function(e){return tE(e,"formInteractions")},tT=function(e){return tE(e,"pageViews")},tC=function(e){return tE(e,"sessions")},tP=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},tx=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},tA=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},tO=function(e){if("object"==typeof e.autocapture){var t=e.autocapture.performanceTracking;if(!0===t)return{mainThreadBlock:!0};if("object"==typeof t&&null!==t)return t}},tR=function(e){if(tx(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},tM=function(e){if(tA(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},tD=function(e){if(tP(e.autocapture)){var t,n,r=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?r=e.autocapture.networkTracking:e.networkTrackingOptions&&(r=e.networkTrackingOptions),(0,Z.__assign)((0,Z.__assign)({},r),{captureRules:(t=null==r?void 0:r.captureRules,n=e.loggerProvider,null==t?void 0:t.map(function(e){var t,r;if((null==(t=e.urls)?void 0:t.length)&&(null==(r=e.hosts)?void 0:r.length)){var i=JSON.stringify(e.hosts),o=JSON.stringify(e.urls);return null==n||n.warn("Found network capture rule with both urls='".concat(o,"' and hosts='").concat(i,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),(0,Z.__assign)((0,Z.__assign)({},e),{hosts:void 0})}return e}))})}},tL=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return tT(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},tN=function(e){if(tI(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions},tF=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,s=r.resolve,a=e&&e[i];if("function"==typeof a){var u=a.apply(e,o);"function"==typeof s&&s(null==u?void 0:u.promise)}}return e},tq=function(e){return e&&void 0!==e._q},tU=function(){if("u"<typeof navigator)return"";var e,t,n,r,i=navigator.userLanguage;return null!=(r=null!=(n=null!=(t=null==(e=navigator.languages)?void 0:e[0])?t:navigator.language)?n:i)?r:""},tj="2.45.5",tB="amplitude-ts",tz=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(tB,"/").concat(tj),"u">typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,Z.__generator)(this,function(s){return r=new Date().getTime(),i=null!=(t=this.config.lastEventId)?t:-1,o=null!=(n=e.event_id)?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:tU()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:eR(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:o,library:this.library,user_agent:this.userAgent})]})})},e}(),tW=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}})})},e.prototype.set=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),tG=function(){var e,t=(0,eA.getGlobalScope)();return null==(e=null==t?void 0:t.navigator)?void 0:e.locks},tH=function(){function e(e,t){void 0===t&&(t={}),this.options=(0,Z.__assign)({},e),this.config=t}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:return t="AMP_TEST",n=new e((0,Z.__assign)({},this.options)),r=String(Date.now()),[4,n.transaction(t,function(e){var n,o;try{e.set(r);var s=e.get()===r;return!s&&i.config.diagnosticsClient&&(null==(n=i.config.diagnosticsClient)||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:r,sync:!0})),s}catch(e){if(i.config.diagnosticsClient){var a=e instanceof Error?e.message:String(e);null==(o=i.config.diagnosticsClient)||o.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:r,error:a,sync:!0})}return!1}
1finally{e.set(null)}})];case 1:return[2,o.sent()]}})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}})})},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=t$(t);if(void 0===n)return void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t));return JSON.parse(n)}catch(n){console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t));return}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,l,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:r=(0,eA.getGlobalScope)(),d.label=1;case 1:if(d.trys.push([1,4,,5]),!(i=null==r?void 0:r.cookieStore))return[3,3];return[4,i.getAll(e)];case 2:if(o=d.sent()){o.length>1&&(null==(t=this.config.diagnosticsClient)||t.recordEvent("cookies.duplicate",{cookies:o.map(function(e){return e.domain})}),null==(n=this.config.diagnosticsClient)||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(a=(s=(0,Z.__values)(o)).next();!a.done;a=s.next())if(u=a.value,tJ(u.domain,this.options.domain))return[2,u.value]}catch(e){l={error:e}}finally{try{a&&!a.done&&(c=s.return)&&c.call(s)}finally{if(l)throw l.error}}}d.label=3;case 3:return[3,5];case 4:return d.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t,n,r=this,i=(0,eA.getGlobalScope)(),o=(null!=(n=null==(t=null==i?void 0:i.document)?void 0:t.cookie.split("; "))?n:[]).filter(function(t){return 0===t.indexOf(e+"=")}),s=void 0,a=this.config.duplicateResolverFn;if("function"==typeof a&&o.length>1&&(s=o.find(function(t){var n;try{var i=a(t.substring(e.length+1));return i||null==(n=r.config.diagnosticsClient)||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}})),s||(s=o[0]),s)return s.substring(e.length+1)},e.prototype.set=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){var n;try{var r=(0,eA.getGlobalScope)();if(!r||!r.document||"function"!=typeof r.btoa||"function"!=typeof r.encodeURIComponent)return;var i=null!=(n=this.options.expirationDays)?n:0,o=null!==t?i:-1,s=void 0;if(o){var a=new Date;a.setTime(a.getTime()+24*o*36e5),s=a}var u="".concat(e,"=").concat(r.btoa(r.encodeURIComponent(JSON.stringify(t))));s&&(u+="; expires=".concat(s.toUTCString())),u+="; path=/",this.options.domain&&(u+="; domain=".concat(this.options.domain)),this.options.secure&&(u+="; Secure"),this.options.sameSite&&(u+="; SameSite=".concat(this.options.sameSite)),r.document.cookie=u}catch(t){var l=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}},e.prototype.remove=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}})})},e.prototype.reset=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2]})})},e.isDomainWritable=function(t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];n="AMP_TLDTEST",r=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.transaction(n,function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}})];case 2:return[2,!!i.sent()];case 3:return i.sent(),[2,!1];case 4:return[2]}})})},e.prototype.transaction=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(n=tG(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,r()];case 4:return[2]}})})},e.cachedTlds={},e}(),tK=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}},tV=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}},t$=function(e){var t;return null!=(t=tK(e))?t:tV(e)},tJ=function(e,t){if(""===e&&""===t)return!0;
1if(!e||!t)return!1;var n=e.startsWith(".")?e.substring(1):e,r=t.startsWith(".")?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},tY=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),["AMP",t,e.substring(0,n)].filter(Boolean).join("_")},tQ=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:if(!(t=n.sent()))return[2,void 0];return[2,JSON.parse(t)];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},e.prototype.getRaw=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return[2,(null==(t=this.storage)?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var n;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){try{null==(n=this.storage)||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){try{null==(t=this.storage)||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){try{null==(e=this.storage)||e.clear()}catch(e){}return[2]})})},e}(),tX=function(e){function t(t){var n,r,i,o=this;try{i=null==(n=(0,eA.getGlobalScope)())?void 0:n.localStorage}catch(e){null==(r=null==t?void 0:t.loggerProvider)||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return(0,Z.__extends)(t,e),t.prototype.set=function(t,n){var r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(!(Array.isArray(n)&&n.length>1e3))return[3,2];return i=n.length-1e3,[4,e.prototype.set.call(this,t,n.slice(0,1e3))];case 1:return o.sent(),null==(r=this.loggerProvider)||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(1e3,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},t}(tQ),tZ=function(e){function t(){var t;return e.call(this,null==(t=(0,eA.getGlobalScope)())?void 0:t.sessionStorage)||this}return(0,Z.__extends)(t,e),t}(tQ),t0=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){if("object"!=typeof e)return null;var t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,S,w,E=e.code||0,k=this.buildStatus(E);switch(k){case M.Success:return{status:k,statusCode:E,body:{eventsIngested:null!=(t=e.events_ingested)?t:0,payloadSizeBytes:null!=(n=e.payload_size_bytes)?n:0,serverUploadTime:null!=(r=e.server_upload_time)?r:0}};case M.Invalid:return{status:k,statusCode:E,body:{error:null!=(i=e.error)?i:"",missingField:null!=(o=e.missing_field)?o:"",eventsWithInvalidFields:null!=(s=e.events_with_invalid_fields)?s:{},eventsWithMissingFields:null!=(a=e.events_with_missing_fields)?a:{},eventsWithInvalidIdLengths:null!=(u=e.events_with_invalid_id_lengths)?u:{},epsThreshold:null!=(l=e.eps_threshold)?l:0,exceededDailyQuotaDevices:null!=(c=e.exceeded_daily_quota_devices)?c:{},silencedDevices:null!=(d=e.silenced_devices)?d:[],silencedEvents:null!=(f=e.silenced_events)?f:[],throttledDevices:null!=(g=e.throttled_devices)?g:{},throttledEvents:null!=(h=e.throttled_events)?h:[]}};case M.PayloadTooLarge:return{status:k,statusCode:E,body:{error:null!=(p=e.error)?p:""}};case M.RateLimit:return{status:k,statusCode:E,body:{error:null!=(v=e.error)?v:"",epsThreshold:null!=(m=e.eps_threshold)?m:0,throttledDevices:null!=(y=e.throttled_devices)?y:{},throttledUsers:null!=(_=e.throttled_users)?_:{},exceededDailyQuotaDevices:null!=(b=e.exceeded_daily_quota_devices)?b:{},exceededDailyQuotaUsers:null!=(S=e.exceeded_daily_quota_users)?S:{},throttledEvents:null!=(w=e.throttled_events)?w:[]}};case M.Timeout:default:return{status:k,statusCode:E}}},e.prototype.buildStatus=function(e){return eK(e)?M.Success:429===e?M.RateLimit:413===e?M.PayloadTooLarge:408===e?M.Timeout:e>
1=400&&e<500?M.Invalid:e>=500?M.Failed:M.Unknown},e}();function t1(){return"u">typeof CompressionStream}function t2(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,new Response(new Blob([e]).stream().pipeThrough(new t("gzip"))).arrayBuffer()];case 2:return[2,n.sent()];case 3:return n.sent(),[2,void 0];case 4:return[2]}})})}var t3=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var r=this;return(0,Z.__generator)(this,function(i){return[2,new Promise(function(i,o){"u"<typeof XMLHttpRequest&&o(Error("XHRTransport is not supported."));var s=new XMLHttpRequest;s.open("POST",e,!0),s.onreadystatechange=function(){if(s.readyState===r.state.done){var e=s.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch(e){i(r.buildResponse({code:s.status}))}}};var a={"Content-Type":"application/json",Accept:"*/*"},u=JSON.stringify(t),l=n&&u.length>=2048&&t1(),c=function(e){var t,n;a=(0,Z.__assign)((0,Z.__assign)({},r.customHeaders),a);try{for(var i=(0,Z.__values)(Object.entries(a)),o=i.next();!o.done;o=i.next()){var u=(0,Z.__read)(o.value,2),l=u[0],c=u[1];s.setRequestHeader(l,c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}s.send(e)};(0,Z.__awaiter)(r,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(!l)return[3,2];return[4,t2(u)];case 1:return(e=t.sent())?(a["Content-Encoding"]="gzip",c(e)):c(u),[3,3];case 2:c(u),t.label=3;case 3:return[2]}})}).catch(o)})]})})},t}(t0),t4=function(e){function t(t,n,r){void 0===t&&(t={});var i=e.call(this)||this;return i.customHeaders=t,i.enableKeepalive=!1!==n,i.referrerPolicy=r,i}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,l,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:if("u"<typeof fetch)throw Error("FetchTransport is not supported");if(r=JSON.stringify(t),i=n&&r.length>=2048&&t1(),o=r,s={"Content-Type":"application/json",Accept:"*/*"},!i)return[3,2];return[4,t2(r)];case 1:(a=f.sent())&&(s["Content-Encoding"]="gzip",o=a),f.label=2;case 2:return s=(0,Z.__assign)((0,Z.__assign)({},this.customHeaders),s),u="string"==typeof o?o.length:o.byteLength,l={headers:s,body:o,method:"POST",keepalive:this.enableKeepalive&&u<=16384},this.referrerPolicy&&(l.referrerPolicy=this.referrerPolicy),[4,fetch(e,l)];case 3:return[4,(c=f.sent()).text()];case 4:d=f.sent();try{return[2,this.buildResponse(JSON.parse(d))]}catch(e){return[2,this.buildResponse({code:c.status})]}}})})},t}(t0),t5=function(e){function t(){return e.call(this)||this}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var n=this;return(0,Z.__generator)(this,function(r){return[2,new Promise(function(r,i){var o=(0,eA.getGlobalScope)();if(!(null==o?void 0:o.navigator.sendBeacon))throw Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);if(o.navigator.sendBeacon(e,s))return r(n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}));return r(n.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(t0),t6=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},t8=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},t7="[Amplitude]",t9="".concat(t7," Form Started"),ne="".concat(t7," Form Submitted"),nt="".concat(t7," File Downloaded"),nn="session_start",nr="session_end",ni="".concat(t7," File Extension"),no="".concat(t7," File Name"),ns="".concat(t7," Link ID"),na="".concat(t7," Link Text"),nu="".concat(t7," Link URL"),nl="".concat(t7," Form ID"),nc="".concat(t7," Form Name"),nd="".concat(t7," Form Destination"),nf="cookie",ng={always:"always",ifEmptyCampaign:"ifEmptyCampaign"},nh=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},np=function(e,t,n,r,i,o){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=(0,Z.__rest)(e,["referrer","referring_domain"]),u=t||{},l=(u.referrer,u.referring_domain),c=(0,Z.__rest)(u,["referrer","referring_domain"]),d=n.excludeInternalReferrers;if(d){var f=n_(d,r);if(!(f instanceof TypeError)&&e.referring_domain&&nE(e.referring_domain,o)){if
1("always"===f)return nb(f,e.referring_domain,r),!1;else if("ifEmptyCampaign"===f&&Object.values((0,Z.__assign)((0,Z.__assign)({},e),{referring_domain:void 0,referrer:void 0})).every(function(e){return!e}))return nb(f,e.referring_domain,r),!1}}if(nv(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&Object.values(e).every(function(e){return!e})&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var g=JSON.stringify(a)!==JSON.stringify(c),h=nh(s||"")!==nh(l||""),p=!t||g||h;return p?r.debug("This is a new campaign. An $identify event will be sent."):r.debug("This is not a new campaign because it's the same as the previous one."),p},nv=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some(function(e){return e instanceof RegExp?e.test(t):e===t})},nm=function(e,t){var n=t.startsWith(".")?t:".".concat(t);return!!(e.startsWith(".")?e:".".concat(e)).endsWith(n)},ny=function(e){var t=e;return t?(t.startsWith(".")&&(t=t.substring(1)),[new RegExp("".concat(t.replace(".","\\."),"$"))]):[]},n_=function(e,t){if(!0===e)return ng.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(ng).includes(n))return n;if(void 0===n)return ng.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),TypeError(r)};function nb(e,t,n){var r="This is not a new campaign because referring_domain=".concat(t," is on the same domain as the current page and it is configured to exclude internal referrers");"always"===e?n.debug(r):"ifEmptyCampaign"===e&&n.debug("".concat(r," with empty campaign parameters"))}var nS=["ac.in","ac.jp","ac.kr","ac.th","ac.uk","ac.za","appspot.com","asn.au","azurewebsites.net","cloudfront.net","myshopify.com","blogspot.com","co.ca","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.ar","com.au","com.br","com.cn","com.hk","com.in","com.jp","com.kr","com.mx","com.pl","com.sg","com.tr","com.tw","ed.jp","edu.au","edu.br","edu.cn","edu.hk","edu.sg","edu.th","edu.tr","edu.tw","firebaseapp.com","fly.dev","gc.ca","geek.nz","github.io","gitlab.io","go.jp","go.kr","go.th","gob.ar","gob.mx","gov.au","gov.br","gov.cn","gov.hk","gov.in","gov.pl","gov.sg","gov.tr","gov.tw","gov.uk","gov.za","govt.nz","gr.jp","herokuapp.com","id.au","idv.hk","iwi.nz","lg.jp","ltd.uk","maori.nz","me.uk","mil.kr","ne.jp","ne.kr","net.au","net.br","net.cn","net.hk","net.in","net.nz","net.pl","net.sg","net.tr","net.tw","net.za","onrender.com","or.jp","or.kr","or.th","org.ar","org.au","org.br","org.cn","org.hk","org.in","org.mx","org.nz","org.pl","org.sg","org.tw","org.uk","org.za","pages.dev","pe.kr","plc.uk","re.kr","res.in","sch.uk","vercel.app","netlify.app","workers.dev"],nw=function(e){var t,n,r=e||(null==(n=null==(t=(0,eA.getGlobalScope)())?void 0:t.location)?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],s=i[i.length-2];return(nS.find(function(e){return r.endsWith(".".concat(e))})&&(o=i[i.length-2]+"."+i[i.length-1],s=i[i.length-3]),s)?"".concat(s,".").concat(o):o},nE=function(e,t){var n=(0,eA.getGlobalScope)();return!!n&&nm(e,(t||"").trim()||nw(n.location.hostname))},nk=function(e){function t(t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,S,w,E,k,I,T,C,P,A,O,R,M,D,L,N,F,q,U,j,B,z,W,G,H){void 0===r&&(r=new tW),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===l&&(l=5),void 0===c&&(c=30),void 0===d&&(d=nf),void 0===v&&(v=new eB),void 0===m&&(m=x.Warn),void 0===_&&(_=!1),void 0===b&&(b=!1),void 0===E&&(E=""),void 0===k&&(k="US"),void 0===C&&(C=18e5),void 0===P&&(P=new tX({loggerProvider:v})),void 0===A&&(A={ipAddress:!0,language:!0,platform:!0}),void 0===O&&(O="fetch"),void 0===R&&(R=!1),void 0===M&&(M=!0),void 0===U&&(U=!0),void 0===j&&(j=0),void 0===G&&(G=!1);var K,V=this;(V=e.call(this,{apiKey:t,storageProvider:P,transportProvider:nC(O)})||this).apiKey=t,V.appVersion=n,V.cookieOptions=i,V.defaultTracking=o,V.autocapture=s,V.flushIntervalMillis=u,V.flushMaxRetries=l,V.flushQueueSize=c,V.identityStorage=d,V.ingestionMetadata=f,V.instanceName=g,V.loggerProvider=v,V.logLevel=m,V.minIdLength=y,V.offline=_,V.partnerId=S,V.plan=w,V.serverUrl=E,V.serverZone=k,V.sessionTimeout=C,V.storageProvider=P,V.trackingOptions=A,V.transport=O,V.useBatch=R,V.fetchRemoteConfig=M,V.networkTrackingOptions=F,V.identify=q,V.enableDiagnostics=U,V.diagnosticsSampleRate=j,V.diagnosticsClient=B,V.remoteConfig=z,V.topLevelDomain=W,V.enableRequestBodyCompression=G,V.customEnrichment=H,V.version=tj,V._optOut=!1,V._cookieStorage=r,V.deviceId=a,V.lastEventId=h,V.lastEventTime=p,V.optOut=b,V.deferredSessionId=T,V.sessionId=I,V.pageCounter=L,V.userId=D,V.debugLogsEnabled=N,V.loggerProvider.enable(N?x.Debug:V.logLevel),V.networkTrackingOptions=F,V.identify=q,V.enableDiagnostics=U,V.diagnosticsSampleRate=j,V.diagnosticsClient=B;var $=null!=(K=null==z?void 0:z.fetchRemoteConfig)?K:M;return V.remoteConfig=V.remoteConfig||{},V.remoteConfig.fetchRemoteConfig=$,V.fetchRemoteConfig=$,V.topLevelDomain=W||nw(),V}return(0,Z.__extends)(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,void 0!==e&&void 0!==this._deferredSessionId&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof tH&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(tY(this.apiKey),e)},t}(eW),nI=function(e,t,n){switch(void 0===e&&(e=nf),void 0===t&&(t={}),e){case"localStorage":return new tX;case"sessionStorage":return new tZ;case"none":return new tW;default:return new tH((0,Z.__assign)((0,Z.__assign)({},t),{expirationDays:t.expiration}),n)}},nT=function(e){var t,n;return void 0===e&&(e={}),(null==(t=e.remoteConfig)?void 0:t.fetchRemoteConfig)===!0||(null==(n=e.remoteConfig)?void 0:n.fetchRemoteConfig)!==!1&&!1!==e.fetchRemoteConfig},nC=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0,r="object"==typeof e?e.enableKeepalive:void 0,i="object"==typeof e?e.referrerPolicy:void 0;return"xhr"===t?new t3(n):"beacon"===t?new t5:new t4(n,r,i)},nP="data-amp-mask",nx="*****",nA=/\b(?:\d[ -]*?){13,16}\b/,nO=/(\d{3}-?\d{2}-?\d{4})/g,nR=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,nM=function(e,t){if(void 0===t&&(t=[]),"string"!=typeof e)return"";var n,r,i=e;i=(i=(i=i.replace(nA,nx)).replace(nO,nx)).replace(nR,nx);try{for(var o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,nx)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},nD=function(e){if("u"<typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(nP)?nx:e?e(document.title):document.title},nL=function(){function e(){}return e.prototype.parse=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2,(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({},ew),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=tn();
1return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!=(t=null==(e=n.referrer)?void 0:e.split("/")[2])?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=tn();return(e={})[ed]=t[ed],e[ef]=t[ef],e[eg]=t[eg],e[eh]=t[eh],e[ep]=t[ep],e[ev]=t[ev],e[em]=t[em],e[ey]=t[ey],e[e_]=t[e_],e[eb]=t[eb],e[eS]=t[eS],e},e}(),nN=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},nF="AMP_PAGE_VIEW",nq=function(e){void 0===e&&(e={});var t,n,r,i=(0,eA.getGlobalScope)(),o=void 0,s=!1,a=e.trackOn,u=e.trackHistoryChanges,l=e.eventType,c=void 0===l?"[Amplitude] Page Viewed":l,d=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==o||o.error("Malformed URI sequence: ",e)}return t},f=function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return t=d("u">typeof location&&location.href||""),r={event_type:c},n=[{}],[4,nU()];case 1:return[2,(r.event_properties=Z.__assign.apply(void 0,[Z.__assign.apply(void 0,n.concat([i.sent()])),{"[Amplitude] Page Domain":"u">typeof location&&location.hostname||"","[Amplitude] Page Location":t,"[Amplitude] Page Path":"u">typeof location&&d(location.pathname)||"","[Amplitude] Page Title":nD(nM),"[Amplitude] Page URL":t.split("?")[0],"[Amplitude] Page View ID":e}]),r)]}})})},g=function(){return void 0===a||"function"==typeof a&&a()},h="u">typeof location?location.href:null,p=function(){(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,n,i,s,a;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:if(n=nB(u,e=location.href,h||"")&&g(),h=e,!n)return[3,4];if(i=void 0,r&&(i=eR(),r.set(nF,{pageViewId:i})),null==o||o.log("Tracking page view event"),null!=t)return[3,1];return[3,3];case 1:return a=(s=t).track,[4,f(i)];case 2:a.apply(s,[l.sent()]),l.label=3;case 3:l.label=4;case 4:return[2]}})})};return{name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,a){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var u,l,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:if(t=a,n=e,(o=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),s=!0,i){try{r=new tQ(i.sessionStorage)}catch(e){null==o||o.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",p),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,n){var r=(0,Z.__read)(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),s&&p()}})}if(!g())return[3,2];return o.log("Tracking page view event"),u=void 0,r&&(u=eR(),r.set(nF,{pageViewId:u})),c=(l=t).track,[4,f(u)];case 1:c.apply(l,[d.sent()]),d.label=2;case 2:return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,i,s;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:if(!("attribution"===a&&nj(e)))return[3,4];if(null==o||o.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,!r)return[3,2];return[4,r.get(nF)];case 1:t=null==(i=u.sent())?void 0:i.pageViewId,u.label=2;case 2:return[4,f(t)];case 3:e.event_type=(s=u.sent()).event_type,e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),s.event_properties),u.label=4;case 4:return n&&e.event_type===c&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return i&&(i.removeEventListener("popstate",p),s=!1),[2]})})}}},nU=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(t){switch(t.label){case 0:return e=nN,[4,new nL().parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},nj=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[A.SET]||{},r=t[A.UNSET]||{},i=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(Object.keys(n)),!1),(0,Z.__read)(Object.keys(r)),!1);return Object.keys(ew).every(function(e){return i.includes(e)})}return!1},nB=function(e,t,n){if("pathOnly"!==e)return t!==n;if(""==n)return!0;
1var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname},nz=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})},i=function(){n.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),n=[]};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Z.__generator)(this,function(a){return t=tN(n),o=function(){if(!i)return void n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.");if("u">typeof document){var o=new WeakSet,s=function(e){if(!o.has(e)){o.add(e);var s=!1;r(e,"change",function(){var t,n=nG(e);s||i.track(t9,((t={})[nl]=nW(e.id),t[nc]=nW(e.name),t[nd]=n,t)),s=!0}),r(e,"submit",function(r){var o,a,u=nG(e);if(s||i.track(t9,((o={})[nl]=nW(e.id),o[nc]=nW(e.name),o[nd]=u,o)),s=!0,(null==t?void 0:t.shouldTrackSubmit)!==void 0)if("function"==typeof t.shouldTrackSubmit&&"u">typeof SubmitEvent&&r instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(r))return}catch(e){n.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else n.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(ne,((a={})[nl]=nW(e.id),a[nc]=nW(e.name),a[nd]=u,a)),s=!1})}};Array.from(document.getElementsByTagName("form")).forEach(s),"u">typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"FORM"===e.nodeName&&s(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(s)})})})).observe(document.body,{subtree:!0,childList:!0})}},"complete"===document.readyState?o():(s=(0,eA.getGlobalScope)())?s.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return null==e||e.disconnect(),i(),[2]})})}}},nW=function(e){if("string"==typeof e)return e},nG=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},nH=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},r=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),t=[]};return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(t,r){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var i,o;return(0,Z.__generator)(this,function(s){return i=function(){if(!r)return void t.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.");if("u">typeof document){var i=function(e){try{t=new URL(e.href,window.location.href)}catch(e){return}var t,i=o.exec(t.href),s=null==i?void 0:i[1];s&&n(e,"click",function(){var n;s&&r.track(nt,((n={})[ni]=s,n[no]=t.pathname,n[ns]=e.id,n[na]=e.text,n[nu]=e.href,n))})},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"u">typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)})})})).observe(document.body,{subtree:!0,childList:!0})}},"complete"===document.readyState?i():(o=(0,eA.getGlobalScope)())?o.addEventListener("load",i):t.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return null==e||e.disconnect(),r(),[2]})})}}},nK=!1,nV=function(e){nK||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n  defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),nK=!0)},n$=function(){var e=(0,eA.getGlobalScope)(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))},r=function(){t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[]};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return"u"<typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1):(e.offline=!navigator.onLine,n("online",function(){!1!==e.offline&&(e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis))}),n("offline",function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return r(),[2]})})}}};function nJ(e,t,n){var r,i,o=[];try{for(var s=(0,Z.__values)(null!=t?t:[]),a=s.next();!a.done;a=s.next()){var u=a.value;try{o.push(new RegExp(u))}catch(e){n.warn("Invalid regex pattern: ".concat(u),e)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return e.concat(o)}var nY=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],nQ="data-amp-track-",nX=["div","span","h1","h2","h3","h4","h5","h6"],nZ="https://app.amplitude.com",n0={US:nZ,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},n1="__AMPLITUDE_MESSENGER_INSTANCE__",n2="__AMPLITUDE_MESSENGER__",n3=function(){function e(e){var t=(void 0===e?{}:e).origin;this[L]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=void 0===t?nZ:t}return e.prototype.notify=function(e){var t,n,r,i;null==(n=null==(t=this.logger)?void 0:t.debug)||n.call(t,"Message sent: ",JSON.stringify(e)),null==(i=null==(r=window.opener)?void 0:r.postMessage)||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise(function(t,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),n.timeout>0&&setTimeout(function(){s(Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;if(!this.requestCallbacks[e.id]){null==(t=this.logger)||t.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},e.prototype.registerActionHandler=function(e,t){this.actionHandlers.has(e)&&(null==(o=null==(i=this.logger)?void 0:i.warn)||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var n,r,i,o,s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var a=(0,Z.__values)(s),u=a.next();!u.done;u=a.next()){var l=u.value;t(l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=(document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise(function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",function(){t({status:!0})},{once:!0}),i.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(e)})}),null==(r=document.head)||r.appendChild(i)}catch(e){n(e)}})).then(function(){}),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,s=i.endpoint;o&&(this.logger=o),s&&this.endpoint===nZ&&(this.endpoint=s),this.isSetup||(this.isSetup=!0,null==(n=null==(t=this.logger)?void 0:t.debug)||n.call(t,"Setting up messenger"),this.messageHandler=function(e){if(null==(n=null==(t=r.logger)?void 0:t.debug)||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var t,n,i,o,s,a=e.data,u=null==a?void 0:a.action;if(u)if("id"in a&&a.id)null==(o=null==(i=r.logger)?void 0:i.debug)||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a
1);else{if("ping"===u)return void r.notify({action:"pong"});var l=r.actionHandlers.get(u);if(l)l(a.data);else{var c=null!=(s=r.pendingMessages.get(u))?s:[];c.push(a.data),r.pendingMessages.set(u,c)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=(0,eA.getGlobalScope)();(null==e?void 0:e[n2])===this&&delete e[n2]},e}();function n4(e){var t=(0,eA.getGlobalScope)(),n=null==t?void 0:t[n2];if("object"==typeof n&&null!==n&&n1 in n&&!0===n[n1])return n;var r=new n3(e);return t&&(t[n2]=r),r}L=n1;var n5="__AMPLITUDE_BACKGROUND_CAPTURE__";function n6(e,t){var n;if(!0!==e[n5]){e[n5]=!0;var r=null!=(n=null==t?void 0:t.scriptUrl)?n:"https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",i=null,o=function(t,n){var r,i;"background-capture-complete"===t&&(null==(i=null==(r=e.logger)?void 0:r.debug)||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){null==(n=null==(t=e.logger)?void 0:t.debug)||n.call(t,"Initializing background capture (external script)");var t,n,s=new URL(r,e.endpoint).toString();e.loadScriptOnce(s).then(function(){var t,n,r;null==(n=null==(t=e.logger)?void 0:t.debug)||n.call(t,"Background capture script loaded (external)"),i=null==(r=null==window?void 0:window.amplitudeBackgroundCapture)?void 0:r.call(window,{messenger:e,onBackgroundCapture:o}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null==(t=e.logger)||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null==(e=null==i?void 0:i.close)||e.call(i),i=null})}}var n8=e.i(81243);function n7(e,t){return new n8.default(function(n){e.subscribe({next:function(e){t(e).then(function(e){return n.next(e)}).catch(function(e){return n.error(e)})},error:function(e){n.error(e)},complete:function(){n.complete()}})})}function n9(e,t){return new n8.default(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=(0,Z.__values)(i),o=n.next();!o.done;o=n.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return s(e),s(t),o})}function re(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new n8.default(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){try{for(var n,r,i,o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;null==(i=a.next)||i.call(a,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){try{for(var n,i,o,s=(0,Z.__values)(t),a=s.next();!a.done;a=s.next()){var u=a.value;null==(o=u.error)||o.call(u,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}r()},complete:function(){try{for(var e,n,i,o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;null==(i=a.complete)||i.call(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}})}var rt="1.28.10",rn="[Amplitude] Element Clicked",rr="[Amplitude] Element Tag",ri="[Amplitude] Element Text",ro="[Amplitude] Page URL",rs="[Amplitude] Viewport Height",ra="[Amplitude] Viewport Width",ru="[Amplitude] Page View ID",rl="data-amp-mask-attributes",rc=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},rd=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},rf=["input","select","textarea"],rg=function(e,t){var n,r=null==(n=null==window?void 0:window.getComputedStyle)?void 0:n.call(window,e);return(null==r?void 0:r.getPropertyValue("cursor"))==="pointer"&&"click"===t},rh=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&rc(window.location.href,n))&&!!rc(window.location.href,t)},rp=function(e,t){return function(n,r){var i,o,s=e.shouldTrackEventResolver,a=null==(o=null==(i=null==r?void 0:r.tagName)?void 0:i.toLowerCase)?void 0:o.call(i);if(!a)return!1;if(s)return s(n,r);if(!rh(e))return!1;var u=String(null==r?void 0:r.getAttribute("type"))||"";if("string"==typeof u)switch(u.toLowerCase()){case"hidden":case"password":return!1}if(t&&!t.some(function(e){var t;return!!(null==(t=null==r?void 0:r.matches)?void 0:t.call(r,e))}))return!1;switch(a){case"input":case"select":case"textarea":return"change"===n||"click"===n;default:return"click"===n}}},rv=function(e){var t,n,r,i=null==(n=null==(t=null==e?void 0:e.tagName)?void 0:t.toLowerCase)?void 0:n.call(t),o=e instanceof HTMLElement&&(null==(r=e.getAttribute("contenteditable"))?void 0:r.toLowerCase())==="true";return!rf.includes(i)&&!o},rm=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return null!=r&&("object"!=typeof r||0!==Object.keys(r).length)&&("string"!=typeof r||0!==r.trim().length)&&(t[n]=r),t},{})},ry=function(){var e;try{var t=(0,eA.getGlobalScope)(),n=null==(e=null==t?void 0:t.sessionStorage)?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},r_=function(e,t){return e?t.some(function(t){var n;return null==(n=null==e?void 0:e.matches)?void 0:n.call(e,t)})?e:r_(null==e?void 0:e.parentElement,t):null},rb=function(e){return null!==e.event.target&&!!e.closestTrackedAncestor};(u=N||(N={}))[u.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",u[u.MIDDLE=1]="MIDDLE",u[u.RIGHT=2]="RIGHT";var rS="__AMPLITUDE_VISUAL_TAGGING__",rw=n8,rE=(0,eA.getGlobalScope)(),rk=null==rE?void 0:rE.console,rI={},rT={},rC=!1,rP=function(e,t){if(!rk||"function"!=typeof rk[e]||!rT[e]&&(rT[e]=rk[e],rk[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{if(rI[e]&&!rC){rC=!0;var r=rI[e];r&&r.forEach(function(n){try{n(e,t)}catch(e){}})}}catch(e){}return rC=!1,rT[e].apply(rk,t)},0))return Error("Console override failed");rI[e]?rI[e].push(t):rI[e]=[t]},rx=function(e){var t,n;try{for(var r=(0,Z.__values)(Object.values(rI)),i=r.next();!i.done;i=r.next())for(var o=i.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},rA=(0,eA.getGlobalScope)(),rO=function(){return new rw.default(function(e){var t=new MutationObserver(function(t){e.next(t)});return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}})},rR=function(e){return void 0===e&&(e="click"),new rw.default(function(t){var n,r=function(e){t.next(e)};return null==(n=(0,eA.getGlobalScope)())||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null==(t=(0,eA.getGlobalScope)())||t.document.removeEventListener(e,r,{capture:!0})}})},rM=function(){var e=n9(new rw.default(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=(0,Z.__assign)((0,Z.__assign)({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(n.message=t.error),e.next(n)}};return rA.addEventListener("error",t),function(){rA.removeEventListener("error",t)}}),new rw.default(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return rA.addEventListener("unhandledrejection",t),function(){rA.removeEventListener("unhandledrejection",t)}}));return n9(e,new rw.default(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return rP("error",t),function(){rx(t)}}
1))},rD=function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){console.error("Error matching event to filter",e)}return!1},rL=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;if(e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector)return n.querySelector(e.selector);return n}}catch(e){}},rN=function(e,t,n){e.forEach(function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}})},rF={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},rq=function(e){var t,n,r,i,o=Object.values(rF).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var u=a.value;try{try{for(var l=(r=void 0,(0,Z.__values)(u.definition)),c=l.next();!c.done;c=l.next()){var d=rF[c.value.event_type];d&&o[d].add(u.id)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==u?void 0:u.id,e)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},rU=function(e){var t,n,r,i,o=new Map;try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var u=a.value;try{for(var l=(r=void 0,(0,Z.__values)(u.conditions)),c=l.next();!c.done;c=l.next()){var d=c.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,g=o.get(f);g||(g=[],o.set(f,g)),g.push(u)}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},rj=function(e,t){var n,r,i,o,s=new Set;try{for(var a=(0,Z.__values)(e),u=a.next();!u.done;u=a.next()){var l=u.value,c=t.get(l.id);if(c)try{for(var d=(i=void 0,(0,Z.__values)(c)),f=d.next();!f.done;f=d.next()){var g=f.value;s.add(g)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return Array.from(s)},rB=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=rj(Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]}).filter(function(t){return t.definition.some(function(t){return rF[t.event_type]===e.type&&t.filters.every(function(t){return rD(e,t)})})}),this.labeledEventToTriggerMap);try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value;rN(a.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}(),rz=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",rl,nP]),rW=["type"],rG=["svg","path","g"],rH=["password","hidden"];function rK(e,t){var n=e.getAttribute(t.explicitTrackingAttribute);if(null!==n&&""===n)return null;var r=e.getAttribute("id");return null===r||""===r||!function(e,t){var n,r;if(null==e||""===e)return!1;try{for(var i=(0,Z.__values)(t),o=i.next();!o.done;o=i.next())if(o.value.test(e))return!1}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!0}(r,t.autogeneratedIdPatterns)?null:r}function rV(e){var t=globalThis.CSS;if(t&&"function"==typeof t.escape)return t.escape(e);for(var n=String(e),r=n.length,i="",o=0;o<r;o++){var s=n.charCodeAt(o);
1if(0===s){i+="�";continue}if(s>=1&&s<=31||127===s||0===o&&s>=48&&s<=57||1===o&&s>=48&&s<=57&&45===n.charCodeAt(0)){i+="\\".concat(s.toString(16)," ");continue}if(0===o&&1===r&&45===s){i+="\\-";continue}if(s>=128||45===s||95===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122){i+=n.charAt(o);continue}i+="\\".concat(n.charAt(o))}return i}function r$(e){var t=e.tagName.toLowerCase(),n=e.parentElement;if(null===n)return t;var r=function(e,t){for(var n=0,r=0;r<t.children.length;r++){var i=t.children[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}(e,n);return"".concat(t,":nth-of-type(").concat(r,")")}var rJ=[{name:"explicitTrackingAttribute",try:function(e,t){var n=t.config.explicitTrackingAttribute,r=e.getAttribute(n);return null===r||""===r?null:"[".concat(n,"=").concat(JSON.stringify(r),"]")}},{name:"stableId",try:function(e,t){var n=rK(e,t.config);return null===n?null:"".concat(e.tagName.toLowerCase(),"#").concat(rV(n))}}];function rY(e,t,n,r,i){var o;try{o=e.querySelectorAll(t)}catch(e){var s=e instanceof Error?e.message:String(e);return null==i||i.debug('@amplitude/element-selector: strategy "'.concat(r,'" emitted a malformed selector "').concat(t,'" (').concat(s,")")),!1}return 1===o.length&&o[0]===n}var rQ=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),rX=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=rZ(r,!!t,r===e);if(!i||(n.push(i),i.optimized))break;r=r.parentElement}return n.reverse(),n.join(" > ")},rZ=function(e,t,n){if(e.nodeType!==Node.ELEMENT_NODE)return null;var r,i,o=e.getAttribute("id");if(t){if(o)return new rQ(r1(o),!0);var s=e.tagName.toLowerCase();if("body"===s||"head"===s||"html"===s)return new rQ(s,!0)}var a=e.tagName.toLowerCase();if(o)return new rQ(a+r1(o),!0);var u=e.parentNode;if(!u||u.nodeType===Node.DOCUMENT_NODE)return new rQ(a,!0);for(var l=r0(e),c=!1,d=!1,f=-1,g=-1,h=u.children,p=0;h&&(-1===f||!d)&&p<h.length;++p){var v=h[p];if(v.nodeType===Node.ELEMENT_NODE){if(g+=1,v===e){f=g;continue}if(!d&&v.tagName.toLowerCase()===a){c=!0;var m=new Set(l);if(!m.size){d=!0;continue}for(var y=r0(v),_=0;_<y.length;++_){var b=y[_];if(m.has(b)&&(m.delete(b),!m.size)){d=!0;break}}}}}var S=a;if(n&&"input"===a.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(S+="[type="+rV(e.getAttribute("type")||"")+"]"),d)S+=":nth-child("+String(f+1)+")";else if(c)try{for(var w=(0,Z.__values)(l),E=w.next();!E.done;E=w.next()){var k=E.value;S+="."+rV(k.slice(1))}}catch(e){r={error:e}}finally{try{E&&!E.done&&(i=w.return)&&i.call(w)}finally{if(r)throw r.error}}return new rQ(S,!1)},r0=function(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]},r1=function(e){return"#"+rV(e)};function r2(e,t){try{return rX(e)}catch(e){var n=e instanceof Error?e.message:String(e);return null==t||t.warn("@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ".concat(n)),""}}var r3=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:(0,Z.__spreadArray)([],(0,Z.__read)([/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/]),!1),unstableClassPatterns:(0,Z.__spreadArray)([],(0,Z.__read)([/^(p|m|px|py|mx|my|pt|pb|pl|pr|mt|mb|ml|mr)-\d+$/,/^(w|h|min-w|max-w|min-h|max-h)-/,/^(text|bg|border|ring|fill|stroke)-/,/^(hover|focus|active|disabled|group-hover):/,/^(sm|md|lg|xl|2xl):/,/^z-\d+$/,/^data-\[/,/^\[/,/^css-[a-z0-9]{6,}$/,/^[a-zA-Z]+_[a-zA-Z0-9]{3,}__[a-zA-Z0-9]{5,}$/,/^sc-[a-zA-Z0-9]{6,}$/,/^jsx-\d+$/,/^swiper-slide-(visible|fully-visible|active|prev|next|duplicate)$/,/^is-(active|open|selected|hovered|focused|expanded)$/,/^Mui[A-Z][a-zA-Z]+-(focused|selected|disabled|expanded|focusVisible|active|checked)$/,/^Mui-(selected|focused|disabled|expanded|focusVisible|active|checked)$/,/^data-state-/]),!1),maxAncestorWalkDepth:void 0});function r4(e,t){if(!e)return r5();var n=r5();return"boolean"==typeof e.enabled&&(n.enabled=e.enabled),"string"==typeof e.explicitTrackingAttribute&&""!==e.explicitTrackingAttribute&&(n.explicitTrackingAttribute=e.explicitTrackingAttribute),Array.isArray(e.autogeneratedIdPatterns)&&(n.autogeneratedIdPatterns=function(e,t){var n,r,i=[];try{for(var o=(0,Z.__values)(e),s=o.next();!s.done;s=o.next()){var a=s.value;try{i.push(new RegExp(a))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(a,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.autogeneratedIdPatterns,t)),Array.isArray(e.unstableClassPatterns)&&(n.unstableClassPatterns=function(e,t){var n,r,i=[];try{for(var o=(0,Z.__values)(e),s=o.next();!s.done;s=o.next()){var a=s.value;try{i.push(new RegExp(a))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(a,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.unstableClassPatterns,t)),n.maxAncestorWalkDepth=function(e){if("number"==typeof e&&Number.isFinite(e)&&!(e<=0))return Math.floor(e)}(e.maxAncestorWalkDepth),n}function r5(){return{enabled:r3.enabled,explicitTrackingAttribute:r3.explicitTrackingAttribute,autogeneratedIdPatterns:(0,Z.__spreadArray)([],(0,Z.__read)(r3.autogeneratedIdPatterns),!1),unstableClassPatterns:(0,Z.__spreadArray)([],(0,Z.__read)(r3.unstableClassPatterns),!1),maxAncestorWalkDepth:r3.maxAncestorWalkDepth}}var r6=function(e,t){var n,r,i,o,s,a,u,l,c,d=this;
1this.replaceSensitiveString=function(e){return nM(e,d.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,o=performance.now(),s=[];if(!e)return[];for(var a=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),u=new Map,l=a.length-1;l>=0;l--){var c=a[l];if(c){var f,g=(f=c.getAttribute(rl))?f.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[],h=l===a.length-1?[]:null!=(r=u.get(a[l+1]))?r:new Set,p=new Set((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(h),!1),(0,Z.__read)(g),!1));u.set(c,p)}}s=a.map(function(e){var t;return function(e,t){if(null===e)return null;var n,r,i,o,s,a,u=String(e.tagName).toLowerCase(),l={tag:u},c=Array.from(null!=(o=null==(i=e.parentElement)?void 0:i.children)?o:[]);c.length&&(l.index=c.indexOf(e),l.indexOfType=c.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var d=null==(a=null==(s=e.previousElementSibling)?void 0:s.tagName)?void 0:a.toLowerCase();d&&(l.prevSib=String(d));var f=e.getAttribute("id");f&&(l.id=String(f));var g=Array.from(e.classList);g.length&&(l.classes=g);var h={},p=Array.from(e.attributes).filter(function(e){return!rz.has(e.name)}),v=!rv(e);if(!rH.includes(String(e.getAttribute("type")))&&!rG.includes(u))try{for(var m=(0,Z.__values)(p),y=m.next();!y.done;y=m.next()){var _=y.value;if(!v||rW.includes(_.name)){if(t.has(_.name)){h[_.name]=nx;continue}h[_.name]=String(_.value).substring(0,128)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(h).length&&(l.attrs=h),l}(e,null!=(t=u.get(e))?t:new Set)});var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=(0,Z.__read)(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=d.replaceSensitiveString(i))})};try{for(var m=(0,Z.__values)(s),y=m.next();!y.done;y=m.next()){var _=y.value;v(_)}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null==(i=d.diagnosticsClient)||i.recordHistogram("autocapturePlugin.getHierarchy",b-o),s},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?d.getText(t):d.getNearestLabel(n)},this.getElementPath=function(e){if(!e)return"";var t,n=performance.now(),r=d.selectorEngine.generate(e),i=performance.now();return null==(t=d.diagnosticsClient)||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.updateSelectorConfig=function(e,t){if(null==e||"boolean"!=typeof e.enabled){null==t||t.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` flag — keeping current engine state.");return}var n=d.selectorEngine.getConfig().enabled,r=r4(e,t);d.selectorEngine.updateConfig(r),!n&&r.enabled?null==t||t.debug("@amplitude/element-selector: engine enabled — now emitting new element-selector element paths for autocapture events."):n&&!r.enabled&&(null==t||t.debug("@amplitude/element-selector: engine disabled — reverting to legacy cssPath for element paths."))},this.getEventProperties=function(e,t,n){var r,i,o,s,a=null==(o=null==(i=null==t?void 0:t.tagName)?void 0:i.toLowerCase)?void 0:o.call(i),u="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},l=d.getHierarchy(t),c=null==(s=l[0])?void 0:s.attrs,f=d.getNearestLabel(t),g=Object.entries(null!=c?c:{}).reduce(function(e,t){var r=(0,Z.__read)(t,2),i=r[0],o=r[1];if(i.startsWith(n)){var s=i.replace(n,"");s&&(e[s]=o||"")}return e},{}),h=((r={})["[Amplitude] Element Hierarchy"]=l,r[rr]=a,r[ri]=d.getText(t),r["[Amplitude] Element Position Left"]=null==u.left?null:Math.round(u.left),r["[Amplitude] Element Position Top"]=null==u.top?null:Math.round(u.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Path"]=d.getElementPath(t),r["[Amplitude] Element Parent Label"]=f,r[ro]=rd(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=nD(d.replaceSensitiveStr
1ing),r[rs]=window.innerHeight,r[ra]=window.innerWidth,r),p=ry();if(p&&(h[ru]=p),h["[Amplitude] Element ID"]=t.getAttribute("id")||"",h["[Amplitude] Element Class"]=t.getAttribute("class"),h["[Amplitude] Element Aria Label"]=null==c?void 0:c["aria-label"],"a"===a&&"click"===e&&t instanceof HTMLAnchorElement){var v=t.href.substring(0,128);h["[Amplitude] Element Href"]=d.replaceSensitiveString(v)}return rm(h)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var o=d.addTypeAndTimestamp(e,t);if(("click"===o.type||"change"===o.type)&&null!==o.event.target){if(i&&rg(o.event.target,o.type))return o.closestTrackedAncestor=o.event.target,o.targetElementProperties=d.getEventProperties(o.type,o.closestTrackedAncestor,r),o;var s=r_(o.event.target,n);s&&(o.closestTrackedAncestor=s,o.targetElementProperties=d.getEventProperties(o.type,s,r))}return o},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=rL(e,t);if(n){if("TEXT"===e.elementExtractType)return d.getText(n);if("ATTRIBUTE"===e.elementExtractType&&e.attribute)return n.getAttribute(e.attribute)}}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(nP,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",o=Array.from(e.childNodes);try{for(var s=(0,Z.__values)(o),a=s.next();!a.done;a=s.next()){var u=a.value;if(u.nodeType===Node.TEXT_NODE){i+=u.textContent||"";continue}if(u instanceof Element){if(u.hasAttribute(nP)||u.hasAttribute("contenteditable")){i+=nx;continue}i+=d.getTextWithMaskedDescendants(u)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},this.getText=function(e){if(null!==e.closest("[".concat(nP,"]")))return nx;var t="";return t=e.querySelector("[".concat(nP,"], [contenteditable]"))?d.getTextWithMaskedDescendants(e):e.innerText||"",d.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){if(!e)return{};var t,n,r,i=null==(r=null==(n=null==e?void 0:e.tagName)?void 0:n.toLowerCase)?void 0:r.call(n);return rm(((t={})[rr]=i,t[ri]=d.getText(e),t[ro]=window.location.href.split("?")[0],t))},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient,this.selectorEngine=(F||(n=r4(),void 0===r&&(r={}),i=n,o=new Set,s=r.logger,a={strategies:r.strategies,scope:r.scope,logger:s},F={generate:function(e){var t,n;if(!i.enabled)return r2(e,s);try{var o=function(e,t,n){void 0===n&&(n={});var r,i,o,s,a,u=null!=(o=n.strategies)?o:rJ,l=null!=(a=null!=(s=n.scope)?s:e.ownerDocument)?a:document,c={scope:l,config:t},d=function(e,t){for(var n=[],r=e;null!==r&&(n.push(r),void 0===t||!(n.length>t));)r=r.parentElement;return n}(e,t.maxAncestorWalkDepth);try{for(var f=(0,Z.__values)(u),g=f.next();!g.done;g=f.next())for(var h=g.value,p=0;p<d.length;p++){var v=d[p],m=h.try(v,c);if(null!==m){if(0===p){if(rY(l,m,e,h.name,n.logger))return m;continue}var y=d.slice(0,p).reverse().map(r$).join(" > "),_="".concat(m," > ").concat(y);if(rY(l,_,e,h.name,n.logger))return _}}}catch(e){r={error:e}}finally{try{g&&!g.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}return null}(e,i,a);if(null!==o)return o;return function(e,t,n){void 0===n&&(n={});for(var r,i,o=null!=(i=null!=(r=n.scope)?r:e.ownerDocument)?i:document,s=[],a=e,u=0;null!==a&&(void 0===t.maxAncestorWalkDepth||!(u>t.maxAncestorWalkDepth));){var l=rK(a,t);if(null!==l){var c="".concat(a.tagName.toLowerCase(),"#").concat(rV(l)),d=(0,Z.__spreadArray)([c],(0,Z.__read)(s),!1).join(" > ");if(function(e,t,n){var r;try{r=e.querySelectorAll(t)}catch(e){return!1}return 1===r.length&&r[0]===n}(o,d,e))return d}s.unshift(function(e){var t=e.tagName.toLowerCase(),n=e.parentElement;if(null===n)return t;var r=function(e,t){for(var n=0,r=0;r<t.children.length;r++){var i=t.children[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}(e,n);return"".concat(t,":nth-of-type(").concat(r,")")}(a)),a=a.parentElement,u+=1}return s.join(" > ")}(e,i,{scope:null!=(n=null!=(t=r.scope)?t:e.ownerDocument)?n:document})}catch(t){var u=t instanceof Error?t.message:String(t);return null==s||s.warn("@amplitude/element-selector: strategy chain threw — falling back to legacy cssPath: ".concat(u)),r2(e,s)}},getConfig:function(){return i},updateConfig:function(e){var t,n;i=e;try{for(var r=(0,Z.__values)(o),a=r.next();!a.done;a=r.next()){var u=a.value;try{u(e)}catch(e){var l=e instanceof Error?e.message:String(e);null==s||s.warn("@amplitude/element-selector: onConfigChange subscriber threw — ".concat(l))}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},onConfigChange:function(e){return o.add(e),function(){o.delete(e)}}}),F);var f=null!=(c=e.maskTextRegex)?c:[],g=[];try{for(var h=(0,Z.__values)(f),p=h.next();!p.done;p=h.next()){var v=p.value;if(g.length>=25)break;if(v instanceof RegExp)g.push(v);else if("pattern"in v&&"string"==typeof v.pattern)try{g.push(RegExp(v.pattern,"i"))}catch(e){}}}catch(e){u={error:e}}finally{try{p&&!p.done&&(l=h.return)&&l.call(h)}finally{if(u)throw u.error}}this.additionalMaskTextPatterns=g};function r8(e,t){var n=e.remoteConfigClient;if(e.fetchRemoteConfig&&n){var r=n.subscribe("configs.analyticsSDK.browserSDK.autocapture.elementSelector","all",function(n,r){e.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(r),") ").concat(JSON.stringify(n))),t.updateSelectorConfig(n,e.loggerProvider)});return function(){n.unsubscribe(r)}}}var rw=n8;(l=q||(q={})).ClickObservable="clickObservable",l.ChangeObservable="changeObservable",l.NavigateObservable="navigateObservable",l.MutationObservable="mutationObservable",l.ScrollObservable="scrollObservable",l.ExposureObservable="exposureObservable",l.BrowserErrorObservable="browserErrorObservable",l.SelectionObservable="selectionObservable",l.MouseMoveObservable="mouseMoveObservable";var r7=function(e,t){void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",rt);var n,r,i,o,s,a,u,l,c,d,f,g,h,p=e.dataAttributePrefix,v=void 0===p?nQ:p,m=e.visualTaggingOptions,y=void 0===m?{enabled:!0}:m;e.cssSelectorAllowlist=null!=(n=e.cssSelectorAllowlist)?n:nY,e.actionClickAllowlist=null!=(r=e.actionClickAllowlist)?r:nX,e.debounceTime=null!=(i=e.debounceTime)?i:0;var _=(null==(o=e.viewportContentUpdated)?void 0:o.enabled)!==!1,b=null!=(u=null!=(a=null==(s=e.viewportContentUpdated)?void 0:s.exposureDuration)?a:e.exposureDuration)?u:150;e.viewportContentUpdated=(0,Z.__assign)((0,Z.__assign)({},e.viewportContentUpdated),{exposureDuration:b}),e.pageUrlExcludelist=null==(l=e.pageUrlExcludelist)?void 0:l.reduce(function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(e){console.warn("Invalid regex pattern: ".concat(t.pattern),e)}return e},[]);var S="@amplitude/plugin-autocapture-browser",w=[],E=new r6(e,t),k=new Set,I=new Set,T=function(){var t,n,r,i=re(rR().map(function(t){return E.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,v)})),o=re(new rw.default(function(t){var n,r=function(n){var r=E.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,v);t.next(r)};return null==(n=(0,eA.getGlobalScope)())||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null==(e=(0,eA.getGlobalScope)())?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(r=re(new rw.default(function(t){var n=function(n){var r=E.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,v);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var s=re(rO().map(function(t){return E.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,v)})),a=new rw.default(function(e){var t,n=function(t){e.next(t)};return null==(t=(0,eA.getGlobalScope)())||t.addEventListener("scroll",n),function(){var e;null==(e=(0,eA.getGlobalScope)())||e.removeEventListener("scroll",n)}}),u=(t=e.cssSelectorAllowlist,new rw.default(function(e){var n,r=(0,eA.getGlobalScope)();if(!(null==r?void 0:r.IntersectionObserver))return function(){};var i=new IntersectionObserver(function(t){t.forEach(function(t){e.next(t)})},{root:null,rootMargin:"0px",threshold:1}),o=t.join(",");
1(null!=(n=null==r?void 0:r.document.querySelectorAll(o))?n:[]).forEach(function(e){i.observe(e)});var a=s.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){e instanceof Element&&(e.matches(o)&&i.observe(e),e.querySelectorAll(o).forEach(function(e){i.observe(e)}))})})});return function(){a.unsubscribe(),i.disconnect()}}));return(n={})[q.ChangeObservable]=o,n[q.ClickObservable]=i,n[q.MutationObservable]=s,n[q.NavigateObservable]=r,n[q.ScrollObservable]=a,n[q.ExposureObservable]=u,n},C=rq(Object.values(null!=(d=null==(c=e.pageActions)?void 0:c.labeledEvents)?d:{})),P=rU(null!=(g=null==(f=e.pageActions)?void 0:f.triggers)?g:[]),x=new rB(C,P,E,e),A=function(t){var n,r;t&&(e.pageActions=(0,Z.__assign)((0,Z.__assign)({},e.pageActions),t),C=rq(Object.values(null!=(n=e.pageActions.labeledEvents)?n:{})),P=rU(null!=(r=e.pageActions.triggers)?r:[]),x.update(C,P,e))};return{name:S,type:"enrichment",setup:function(t,n){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var r,i,o,s,a,u,l,c,d,f,g,p,m,C,P,O,R,M,D,L,N,F;return(0,Z.__generator)(this,function(U){var j,B,z,W,G,H,K,V,$,J,Y,Q,X,ee,et,en,er,ei,eo,es,ea,eu,el,ec,ed,ef,eg,eh,ep,ev,em,ey,e_,eb,eS,ew,eE,ek,eI;return"u"<typeof document?[2]:(r=!1,i={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(e){A(e)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),(o=r8(t,E))&&w.push({unsubscribe:o}),s=rp(e,e.cssSelectorAllowlist),a=rp(e,e.actionClickAllowlist),B=(j={allObservables:u=T(),amplitude:n,shouldTrackEvent:s,evaluateTriggers:x.evaluate.bind(x)}).amplitude,z=j.allObservables,W=j.shouldTrackEvent,G=j.evaluateTriggers,l=z.clickObservable.filter(rb).filter(function(e){return W("click",e.closestTrackedAncestor)}).map(function(e){return G(e)}).subscribe(function(e){null==B||B.track(rn,e.targetElementProperties)}),w.push(l),K=(H={allObservables:u,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return E.getEventProperties.apply(E,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(e),!1),[v],!1))},amplitude:n,shouldTrackEvent:s,evaluateTriggers:x.evaluate.bind(x)}).amplitude,V=H.allObservables,$=H.getEventProperties,J=H.shouldTrackEvent,Y=H.evaluateTriggers,c=V.changeObservable.filter(rb).filter(function(e){return J("change",e.closestTrackedAncestor)}).map(function(e){return Y(e)}).subscribe(function(e){null==K||K.track("[Amplitude] Element Changed",$("change",e.closestTrackedAncestor))}),w.push(c),X=(Q={allObservables:u,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return E.getEventProperties.apply(E,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(e),!1),[v],!1))},amplitude:n,shouldTrackEvent:s,shouldTrackActionClick:a}).amplitude,ee=Q.allObservables,et=Q.options,en=Q.getEventProperties,er=Q.shouldTrackEvent,ei=Q.shouldTrackActionClick,eo=ee.clickObservable,es=ee.mutationObservable,ea=ee.navigateObservable,eu=eo.filter(function(e){return!er("click",e.closestTrackedAncestor)}).map(function(e){var t=r_(e.event.target,et.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=en(e.type,e.closestTrackedAncestor)),e}).filter(rb).filter(function(e){return ei("click",e.closestTrackedAncestor)}),el=ea?n9(es,ea):es,ec=n9(eu,el),ed=null,ef=null,(d=n7(ec,function(e){if(ed&&(clearTimeout(ed),ed=null),"click"===e.type)ef=e,ed=setTimeout(function(){ed=null,ef=null},500);else if(ef){var t=ef;return ef=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==X||X.track(rn,en("click",e.closestTrackedAncestor)))}))&&w.push(d),(eg={allObservables:u,amplitude:n}).amplitude,eh=eg.allObservables.scrollObservable,ep={maxX:0,maxY:0},ev=eh.subscribe(function(){var e,t,n,r,i=(0,eA.getGlobalScope)(),o=Math.floor(null!=(t=null!=(e=null==i?void 0:i.scrollX)?e:null==i?void 0:i.pageXOffset)?t:0),s=Math.floor(null!=(r=null!=(n=null==i?void 0:i.scrollY)?n:null==i?void 0:i.pageYOffset)?r:0);ep.maxX=Math.max(ep.maxX,o),ep.maxY=Math.max(ep.maxY,s)}),f={unsubscribe:function(){ev.unsubscribe()},getState:function(){return ep},reset:function(){ep.maxX=0,ep.maxY=0}},w.push(f),g={},p=(0,eA.getGlobalScope)(),m=function(e){e&&r||(setTimeout(function(){r=!1},100),r=!0,function(e){var t,n,r,i,o,s,a=e.amplitude,u=e.scrollTracker,l=e.currentElementExposed,c=e.elementExposedForPage,d=e.exposureTracker,f=e.isPageEnd,g=e.lastScroll,h=u.getState(),p=(0,eA.getGlobalScope)(),v=null!=(n=null==p?void 0:p.innerWidth)?n:0,m=null!=(r=null==p?void 0:p.innerHeight)?r:0,y=((t={})[ro]=rd(null!=(s=null==(o=null==(i=null==p?void 0:p.location)?void 0:i.href)?void 0:o.split("?")[0])?s:""),t["[Amplitude] Max Page X"]=h.maxX+v,t["[Amplitude] Max Page Y"]=h.maxY+m,t[rs]=m,t[ra]=v,t["[Amplitude] Element Exposed"]=Array.from(l),t),_=ry();if(_&&(y[ru]=_),0===l.size&&h.maxX===g.maxX&&h.maxY===g.maxY){f&&(u.reset(),c.clear(),null==d||d.reset());return}null==a||a.track("[Amplitude] Viewport Content Updated",y),g.maxX=h.maxX,g.maxY=h.maxY,l.clear(),f&&(u.reset(),c.clear(),null==d||d.reset())}({amplitude:n,scrollTracker:f,currentElementExposed:I,elementExposedForPage:k,exposureTracker:g.exposure,isPageEnd:e,lastScroll:i}))},C=function(e){!k.has(e)&&(k.add(e),I.add(e),JSON.stringify(Array.from(I)).length>=18e3&&m(!1))},_&&(ey=(em={allObservables:u,onExposure:C,dataExtractor:E,exposureDuration:b}).allObservables,e_=em.onExposure,eb=em.dataExtractor,ew=void 0===(eS=em.exposureDuration)?150:eS,eE=new Map,ek=new Map,eI=ey.exposureObservable.subscribe(function(e){var t=e.target;if(e.isIntersecting){if(!eE.get(t)){var n=setTimeout(function(){eE.set(t,!0),e_(eb.getElementPath(t)),ek.set(t,null)},ew);ek.set(t,n)}}else if(!e.isIntersecting&&e.intersectionRatio<1){var n=ek.get(t);n&&(clearTimeout(n),ek.set(t,null))}}),g.exposure={unsubscribe:function(){eI.unsubscribe()}
1,reset:function(){ek.forEach(function(e){e&&clearTimeout(e)}),ek.clear(),eE.clear()}},g.exposure&&w.push(g.exposure),P=function(){m(!0)},null==p||p.addEventListener("beforeunload",P),h=function(){null==p||p.removeEventListener("beforeunload",P)},w.push({unsubscribe:function(){return h()}}),(O=u[q.NavigateObservable])?w.push(O.subscribe(function(){m(!0)})):p&&(R=function(){m(!0)},p.addEventListener("popstate",R),M=p.history.pushState,p.history&&M&&(p.history.pushState=new Proxy(M,{apply:function(e,t,n){var r=(0,Z.__read)(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),m(!0)}})),w.push({unsubscribe:function(){p.removeEventListener("popstate",R),p.history&&M&&(p.history.pushState=M)}}))),null==(F=null==t?void 0:t.loggerProvider)||F.log("".concat(S," has been successfully added.")),window.opener&&y.enabled&&(D=e.cssSelectorAllowlist,L=e.actionClickAllowlist,!function(e,t){if(!0!==e[rS]){e[rS]=!0;var n=t.dataExtractor,r=t.isElementSelectable,i=t.cssSelectorAllowlist,o=t.actionClickAllowlist,s=null,a=function(t){e.notify({action:"element-selected",data:t})},u=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var l;s=null==(l=null==window?void 0:window.amplitudeVisualTaggingSelector)?void 0:l.call(window,{getEventTagProps:n.getEventTagProps,isElementSelectable:function(e){return!r||r((null==t?void 0:t.actionType)||"click",e)},onTrack:u,onSelect:a,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:i,actionClickAllowlist:o,extractDataFromDataSource:n.extractDataFromDataSource,dataExtractor:n,diagnostics:{autocapture:{version:rt}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null==(t=e.logger)||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null==(e=null==s?void 0:s.close)||e.call(s)})}}(N=n4(),{dataExtractor:E,isElementSelectable:rp(e,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(D),!1),(0,Z.__read)(L),!1)),cssSelectorAllowlist:D,actionClickAllowlist:L}),n6(N),N.setup((0,Z.__assign)({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:n0[t.serverZone]}))),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r;return(0,Z.__generator)(this,function(i){try{for(t=(e=(0,Z.__values)(w)).next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]})})}}},rw=n8,r9=(0,Z.__spreadArray)(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],(0,Z.__read)(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),ie=["*"],it=["mutation","navigate"];function ir(e,t){var n,r,i,o,s=t.event,a=s.pageX,u=s.pageY;e.yMin=Math.min(null!=(n=e.yMin)?n:u,u),e.yMax=Math.max(null!=(r=e.yMax)?r:u,u),e.xMin=Math.min(null!=(i=e.xMin)?i:a,a),e.xMax=Math.max(null!=(o=e.xMax)?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function ii(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:(0,Z.__assign)({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}var rw=n8;(c=U||(U={})).INCREASING="increasing",c.DECREASING="decreasing",(d=j||(j={})).X="x",d.Y="y";var io=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new rw.default(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};if(null===n){n=o;return}o.x>n.x?(r===U.DECREASING&&e.next(j.X),r=U.INCREASING):o.x<n.x&&(r===U.INCREASING&&e.next(j.X),r=U.DECREASING),o.y>n.y?(i===U.DECREASING&&e.next(j.Y),i=U.INCREASING):o.y<n.y&&(i===U.INCREASING&&e.next(j.Y),i=U.DECREASING),n=o})})};function is(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function ia(e){e.changes=[],e.startTime=void 0}function iu(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length&&!(i-t[r]<n);r++);0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var il=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new rw.default(function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},s=void 0,a=null;function u(){void 0!==s&&(e.next(s),s=void 0,null!==a&&clearTimeout(a),ia(n),ia(i))}return t.subscribe(function(e){null!==a&&clearTimeout(a),t=e===j.X?n:i,r=+Date.now(),t.startTime=t.startTime||r,l=t.changes,c=t.changesThreshold,l.push(r),l.length>c&&l.shift();var t,r,l,c,d=function(e,t){var n=void 0;if(is(e)&&(n=e.startTime),is(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return d?(s=s||d,a=setTimeout(function(){u(),a=null},o)):u(),iu(n),iu(i),function(){null!==a&&(clearTimeout(a),a=null)}})})},ic=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=e.thresholdMs;return il({mouseDirectionChangeObservable:io({allWindowObservables:r}),directionChanges:void 0===i?20:i,thresholdMs:void 0===o?2e3:o}).subscribe(function(e){rh(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function id(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var ig=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-frustration-browser",r=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var o=!1!==e.deadClicks&&null!==e.deadClicks,s=!1!==e.rageClicks&&null!==e.rageClicks,a=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(a=!1);var u=id(e,"rageClicks",ie,s),l=id(e,"deadClicks",r9,o),c=id(e,"errorClicks",r9,i),d=null!=(t=e.dataAttributePrefix)?t:nQ,f=new r6(e),g=(0,Z.__spreadArray)([],(0,Z.__read)(new Set((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(u),!1),(0,Z.__read)(l),!1),(0,Z.__read)(c),!1))),!1),h=function(){var e,t,n=re(rR("pointerdown").map(function(e){return f.addAdditionalEventProperties(e,"click",g,d,!0)})),r=re(rM().map(function(e){return f.addTypeAndTimestamp(e,"error")})),i=re(rO().map(function(e){return f.addAdditionalEventProperties(e,"mutation",g,d)}));window.navigation&&(t=re(new rw.default(function(e){var t=function(t){e.next((0,Z.__assign)((0,Z.__assign)({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return f.addAdditionalEventProperties(e,"navigate",g,d)})));var o=re(new rw.default(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){var n=void 0,r=void 0;try{if(n=t.selectionStart,r=t.selectionEnd,n===r)return}catch(e){return}return e.next()}var i=window.getSelection();if(i&&!i.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}})),s=re(new rw.default(function(e){var t=function(t){e.next(t)},n={capture:!0};return rA.document.addEventListener("mousemove",t,n),function(){rA.document.removeEventListener("mousemove",t,n)}}));return(e={})[q.ClickObservable]=n,e[q.MutationObservable]=i,e[q.NavigateObservable]=t,e[q.BrowserErrorObservable]=r,e[q.SelectionObservable]=o,e[q.MouseMoveObservable]=s,e};return{name:n,type:"enrichment",setup:function(t,g){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var p,v,m,y,_,b,S,w,E;return(0,Z.__generator)(this,function(k){var I,T,C,P,x,A,O,R,M,D,L,F,q,U,j,B,z,W,G,H,K,V;return"u"<typeof document?[2]:(p=h(),(v=r8(t,f))&&r.push({unsubscribe:v}),s&&(m=function(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,s=r.selectionObservable,a=[],u={},l=null;function c(e){a=[],u={},e&&(ir(u,e),a.push(e))}var d=n7(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return(0,Z.__awaiter)(t,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){var r,i,o,s;return(ir(u,e),t=null,0===a.length||(r=a).length>0&&r[r.length-1].closestTrackedAncestor!==e.closestTrackedAncestor||(o=Math.max(0,(i=a).length-4+1),s=i[o],e.timestamp-s.timestamp>=1e3)||u.isOutOfBounds)?(l&&(t=ii(a)),c(e)):a.push(e),(l&&(clearTimeout(l.timerId),l.resolve(t),l=null),a.length>=4)?[2,new Promise(function(e){l={resolve:e,timerId:setTimeout(function(){e(ii(a))},1e3)}})]:[2,null]})})}),f=null==s?void 0:s.subscribe(function(){c()}),g=d.subscribe(function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){g.unsubscribe(),null==f||f.unsubscribe()}}}({allObservables:p,amplitude:g,shouldTrackRageClick:rp(e,u)}),r.push(m)),o&&(T=(I={amplitude:g,allObservables:p,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:rp(e,l)}).amplitude,C=I.allObservables,P=I.getEventProperties,x=I.shouldTrackDeadClick,A=C.clickObservable,O=C.mutationObservable,R=C.navigateObservable,M=A.filter(function(e){return rb(e)&&x("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===N.LEFT_OR_TOUCH_CONTACT}),D=R?n9(O,R):O,L=n9(M,D),F=null,y=n7(L,function(e){if(F&&it.includes(e.type))clearTimeout(F),F=null;else if("click"===e.type)return F?Promise.resolve(null):new Promise(function(t){F=setTimeout(function(){t(e),F=null},3e3)});return Promise.resolve(null)}).subscribe(function(e){if(e){var t={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};T.track("[Amplitude] Dead Click",(0,Z.__assign)((0,Z.__assign)({},P("click",e.closestTrackedAncestor)),t),{time:e.timestamp})}}),r.push(y)),i&&(U=(q={amplitude:g,allObservables:p,shouldTrackErrorClick:rp(e,c)}).amplitude,j=q.allObservables,B=q.shouldTrackErrorClick,z=j.clickObservable,W
1=j.browserErrorObservable,G=z.filter(function(e){return rb(e)&&B("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===N.LEFT_OR_TOUCH_CONTACT}),H=null,K=null,V=function(){null!==H&&(clearTimeout(H),H=null),K=null},_=n9(G,W).subscribe(function(e){var t;if("click"===e.type){V(),K=e,H=setTimeout(V,2e3);return}"error"===e.type&&K&&(U.track("[Amplitude] Error Click",(0,Z.__assign)(((t={})["[Amplitude] Kind"]=e.event.kind,t["[Amplitude] Message"]=e.event.message,t["[Amplitude] Stack"]=e.event.stack,t["[Amplitude] Filename"]=e.event.filename,t["[Amplitude] Line Number"]=e.event.lineNumber,t["[Amplitude] Column Number"]=e.event.columnNumber,t),K.targetElementProperties)),V())}),r.push(_)),a&&(b=void 0,S=void 0,"object"==typeof e.thrashedCursor&&(b=e.thrashedCursor.directionChanges,S=e.thrashedCursor.threshold,b&&b<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(b," is below the minimum of ").concat(5,", setting to ").concat(5)),b=5),S&&S>4e3&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(S," is above the maximum of ").concat(4e3,", setting to ").concat(4e3)),S=4e3)),w=ic({amplitude:g,options:e,allObservables:p,directionChanges:b,thresholdMs:S}),r.push(w)),null==(E=null==t?void 0:t.loggerProvider)||E.log("".concat(n," has been successfully added.")),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,i;return(0,Z.__generator)(this,function(o){try{for(t=(e=(0,Z.__values)(r)).next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]})})}}};function ih(e,t){var n=e.startTime+e.duration;return t.filter(function(t){return t.startTime<n&&t.startTime+t.duration>e.startTime}).map(function(e){return e.name})}var ip=function(e){void 0===e&&(e={});var t="@amplitude/plugin-performance-browser",n=[],r=!0===e.mainThreadBlock||"object"==typeof e.mainThreadBlock&&null!==e.mainThreadBlock;return{name:t,type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s,a,u;return(0,Z.__generator)(this,function(l){return"u"<typeof document||(r&&(s=100,"object"==typeof e.mainThreadBlock&&void 0!==e.mainThreadBlock.durationThreshold&&(s=e.mainThreadBlock.durationThreshold),a=function(e){var t=e.amplitude,n=e.options,r=e.durationThreshold,i=void 0===r?100:r,o=function(){if("u"<typeof PerformanceObserver)return null;try{var e=PerformanceObserver.supportedEntryTypes;if(e.includes("long-animation-frame"))return"long-animation-frame";if(e.includes("longtask"))return"longtask"}catch(e){}return null}();if(!o)return{unsubscribe:function(){}};var s=[],a=new PerformanceObserver(function(e){var t,n,r=performance.now();try{for(var i=(0,Z.__values)(e.getEntries()),o=i.next();!o.done;o=i.next()){var a=o.value;s.push(a)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}for(var u=r-1e4;s.length>0&&s[0].startTime<u;)s.shift()});try{a.observe({entryTypes:["measure"]})}catch(e){}var u=new PerformanceObserver(function(e){var r,a;try{for(var u=(0,Z.__values)(e.getEntries()),l=u.next();!l.done;l=u.next()){var c=l.value;if(!rh(n))return;if(!(c.duration<i)){var d="long-animation-frame"===o?function(e,t){var n,r=ih(e,t),i=null!=(n=e.scripts)?n:[],o=i.map(function(e){return e.sourceURL}).filter(Boolean),s=i.map(function(e){return e.sourceFunctionName}).filter(Boolean),a=i.map(function(e){return e.sourceCharPosition}).filter(function(e){return"number"==typeof e&&e>=0}),u=i.map(function(e){return e.invokerType}).filter(Boolean),l=i.map(function(e){return e.invoker}).filter(Boolean);return(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.blockingDuration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),{"[Amplitude] Main Thread Block Render Start":e.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":e.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),o.length>0&&{"[Amplitude] Main Thread Block Script URLs":o}),s.length>0&&{"[Amplitude] Main Thread Block Script Functions":s}),a.length>0&&{"[Amplitude] Main Thread Block Script Positions":a}),u.length>0&&{"[Amplitude] Main Thread Block Invoker Types":u}),l.length>0&&{"[Amplitude] Main Thread Block Invokers":l})}(c,s):function(e,t){var n,r=ih(e,t),i=null!=(n=e.attribution)?n:[];return(0,Z.__assign)((0,Z.__assign)({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.duration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(e){return e.name})})}(c,s);t.track("[Amplitude] Main Thread Block",d)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(a=u.return)&&a.call(u)}finally{if(r)throw r.error}}});try{u.observe({entryTypes:[o]})}catch(e){return a.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){u.disconnect(),a.disconnect()}}}({amplitude:o,options:e,durationThreshold:s}),n.push(a)),null==(u=null==i?void 0:i.loggerProvider)||u.log("".concat(t," performance tracking has been successfully added."))),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,i;return(0,Z.__generator)(this,function(o){try{for(t=(e=(0,Z.__values)(n)).next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]})})}}},iv=e.i(79509),im=function(){function e(e){this.request=e}return e.prototype.headers=function(e){void 0===e&&(e=[]);var t,n,r=this.request.headers,i={};if(Array.isArray(r))r.forEach(function(e){var t=(0,Z.__read)(e,2),n=t[0],r=t[1];i[n]=r});else if(r instanceof Headers)r.forEach(function(e,t){i[t]=e});else if("object"==typeof r&&null!==r)try{for(var o=(0,Z.__values)(Object.entries(r)),s=o.next();!s.done;s=o.next()){var a=(0,Z.__read)(s.value,2),u=a[0],l=a[1];i[u]=l}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return ik(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=(0,eA.getGlobalScope)();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=i_(t,100),this._bodySize}}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return 0===e.length?[2,null]:[2,iw(this.body,e,t)]})})},e}(),iy=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),ik(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return i_(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return 0===e.length?[2,null]:[2,iw(this.body,e,t)]})})},e}();function i_(e,t){var n,r,i,o,s=(0,eA.getGlobalScope)(),a=null==s?void 0:s.TextEncoder;if(a&&null!=e){if("string"==typeof e)o=e,i=new a().encode(o).length;else if("u">typeof Blob&&e instanceof Blob)i=(o=e).size;else if("u">typeof URLSearchParams&&e instanceof URLSearchParams)o=e,i=new a().encode(o.toString()).length;else if(ArrayBuffer.isView(e))i=(o=e).byteLength;else if(e instanceof ArrayBuffer)i=(o=e).byteLength;else if("u">typeof FormData&&e instanceof FormData){var u=0,l=0;try{for(var c=(0,Z.__values)(e.entries()),d=c.next();!d.done;d=c.next()){var f=(0,Z.__read)(d.value,2),g=f[0],h=f[1];if(u+=g.length,"string"==typeof h)u+=new a().encode(h).length;else{if(!("u">typeof Blob&&h instanceof Blob))return;u+=h.size}if(++l>=t)return}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}i=u}else if("u">typeof ReadableStream&&e instanceof ReadableStream){o=e;return}return i}}var ib=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null==(t=null==n?void 0:n.forEach)||t.call(n,function(e,t){r[t]=e}),ik(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){if(void 0!==this._bodySize)return this._bodySize;var e,t,n=null==(t=null==(e=this.response.headers)?void 0:e.get)?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Promise.race([this.clonedResponse.text(),new Promise(function(e){return setTimeout(function(){return e(null)},500)})])];case 2:return[2,e.sent()];case 3:return e.sent(),[2,null];case 4:return[2]}})})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(0===e.length)return[2,null];return[4,this.text()];case 1:return[2,iw(n.sent(),e,t)]}})})},e}(),iS=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){if(void 0===e&&(e=[]),!this.headersString)return{};var t,n,r={},i=this.headersString.split("\r\n");try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value,u=(0,Z.__read)(a.split(": "),2),l=u[0],c=u[1];l&&c&&(r[l]=c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return ik(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){var n;return(0,Z.__generator)(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?((0,iv.pruneJson)(n,e,t),[2,n]):[2,null]})})},e}();function iw(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return(0,iv.pruneJson)(r,t,n),r}catch(e){return null}}(f=B||(B={})).REDACT="redact",f.REMOVE="remove";var iE="[REDACTED]",ik=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?B.REMOVE:s,u=(0,Z.__spreadArray)([],(0,Z.__read)(ek),!1),l={};try{for(var c=(0,Z.__values)(Object.keys(e)),d=c.next();!d.done;d=c.next()){var f=d.value;!function(t){var n=t.toLowerCase();u.find(function(e){return e.toLowerCase()===n})?a===B.REDACT&&(l[t]=iE):o.find(function(e){return e.toLowerCase()===n})?l[t]=e[t]:a===B.REDACT&&(l[t]=iE)}(f)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return l},iI=function(){function e(e,t,n,r,i,o,s,a,u,l,c){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=u,this.error=l,this.endTime=c}return e.prototype.toSerializable=function(){var e,t,n,r;
1return Object.fromEntries(Object.entries({type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null==(e=this.requestWrapper)?void 0:e.headers((0,Z.__spreadArray)([],(0,Z.__read)(eE),!1)),requestBodySize:null==(t=this.requestWrapper)?void 0:t.bodySize,responseHeaders:null==(n=this.responseWrapper)?void 0:n.headers((0,Z.__spreadArray)([],(0,Z.__read)(eE),!1)),responseBodySize:null==(r=this.responseWrapper)?void 0:r.bodySize}).filter(function(e){var t=(0,Z.__read)(e,2);return void 0!==(t[0],t[1])}))},e}(),iT=function(e,t){void 0===t&&(t=eR()),this.callback=e,this.id=t};function iC(e){try{e()}catch(e){}}var iP=new(function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=(0,eA.getGlobalScope)();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=(0,eA.getGlobalScope)();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,s,a,u,l,c,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null==(i=null==(r=null==(n=this.globalScope)?void 0:n.XMLHttpRequest)?void 0:r.prototype)?void 0:i.open,g=null==(a=null==(s=null==(o=this.globalScope)?void 0:o.XMLHttpRequest)?void 0:s.prototype)?void 0:a.send,h=null==(c=null==(l=null==(u=this.globalScope)?void 0:u.XMLHttpRequest)?void 0:l.prototype)?void 0:c.setRequestHeader;f&&g&&h&&this.observeXhr(f,g,h);var p=null==(d=this.globalScope)?void 0:d.fetch;p&&this.observeFetch(p),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach(function(n){try{n.callback(e)}catch(e){iC(function(){var n;null==(n=t.logger)||n.debug("an unexpected error occurred while triggering event callbacks",e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,s){if(void 0!==o&&void 0!==s){var a,u,l,c,d="GET";if("object"==typeof t&&null!==t&&"url"in t&&"method"in t?(u=t.url,d=t.method):u=null==(a=null==t?void 0:t.toString)?void 0:a.call(t),u)try{var f=new URL(u);u="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(l=r.status),i&&(c={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},l=0);var g=Math.floor(performance.now()-s),h=Math.floor(o+g),p=new iI(e,d,o,o,u,n,l,g,r,c,h);this.triggerEventCallbacks(p)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null==(e=Date.now)?void 0:e.call(Date),durationStart:null==(t=null==performance?void 0:performance.now)?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return(0,Z.__awaiter)(t,void 0,void 0,function(){var t,i,o,s=this;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:try{t=this.getTimestamps()}catch(e){iC(function(){var t;return null==(t=s.logger)?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)})}a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=a.sent(),[3,4];case 3:return o=a.sent(),[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new im(r):void 0,i?new ib(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){iC(function(){var t;return null==(t=s.logger)?void 0:t.debug("an unexpected error occurred while handling fetch",e)})}if(i)return[2,i];throw o}})})})},e.createXhrJsonParser=function(e,t){return function(){var n;try{if("json"===e.responseType){if(null==(n=t.globalScope)?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){n instanceof Error&&"InvalidStateError"===n.name&&iC(function(){var n;return null==(n=t.logger)?void 0:n.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))})}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=(0,Z.__read)(n,2),s=i[0],a=i[1];try{this.$$AmplitudeAnalyticsEvent=(0,Z.__assign)({method:s,url:null==(e=null==a?void 0:a.toString)?void 0:e.call(a),headers:{}},o.getTimestamps())}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while calling xhr open",e)})}return t.apply(this,n)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,s=e.createXhrJsonParser(this,o),a=t[0],u=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),n=new iS(i.status,e,t?parseInt(t,10):void 0,s),r=i.$$AmplitudeAnalyticsEvent.headers,l=new iy(a,r);u.status=i.status,o.handleNetworkRequestEvent("xhr",{url:u.url,method:u.method},l,n,void 0,u.startTime,u.durationStart)}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while handling xhr send",e)})}}),n.apply(i,t)},i.setRequestHeader=function(e,t){try{var n=this.$$AmplitudeAnalyticsEvent;n&&(n.headers[e]=t)}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)})}r.apply(this,[e,t])}}},e}()),ix="[Amplitude] Network Request",rw=n8,iA="500-599";function iO(e,t){return RegExp("^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$").test(e)}function iR(e,t){var n,r,i=t.split(",");try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value,u=(0,Z.__read)(a.split("-").map(Number),2),l=u[0],c=u[1];if(e===l&&void 0===c||e>=l&&e<=c)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function iM(e){if(e)try{var t,n,r,i,o,s,a,u,l,c=null==(t=(0,eA.getGlobalScope)())?void 0:t.location.href,d=new URL(e,c),f=d.searchParams.toString(),g=d.hash.replace("#",""),h=d.href,p=d.host;d.hash="",d.search="";var v=d.href;return{query:f,fragment:g,href:h,hrefWithoutQueryOrHash:v,host:p}}catch(t){try{return i=(r=e.indexOf("#"))>=0?e.slice(r+1):"",a=(s=(o=r>=0?e.slice(0,r):e).indexOf("?"))>=0?o.slice(s+1):"",l=(u=s>=0?o.slice(0,s):o).match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i),{query:a,fragment:i,href:e,hrefW
1ithoutQueryOrHash:u,host:null!=(n=null==l?void 0:l[1])?n:""}}catch(e){return}}}function iD(e){return"object"!=typeof e||null===e?e?(0,Z.__spreadArray)([],(0,Z.__read)(eE),!1):void 0:0!==e.length?e:void 0}function iL(e){var t,n,r;return!(null==(t=null==e?void 0:e.allowlist)?void 0:t.length)&&!(null==(n=null==e?void 0:e.blocklist)?void 0:n.length)&&!(null==(r=null==e?void 0:e.excludelist)?void 0:r.length)}(z||(z={})).NetworkObservable="networkObservable";var iN=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new rw.default(function(e){var n=new iT(function(t){var n={event:t,timestamp:Date.now(),type:"network"};e.next(n)});return iP.subscribe(n,t),function(){iP.unsubscribe(n)}});return(e={})[z.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s;return(0,Z.__generator)(this,function(a){var u,l,c,d,f,g,h;return"u"<typeof document&&(null==(u=null==(l=(0,eA.getGlobalScope)())?void 0:l.navigator)?void 0:u.product)!=="ReactNative"?[2]:(s=r(),t=null==i?void 0:i.loggerProvider,d=(c={allObservables:s,networkTrackingOptions:e,amplitude:o,loggerProvider:t}).allObservables,f=c.networkTrackingOptions,g=c.amplitude,h=c.loggerProvider,W=d.networkObservable.filter(function(e){return function(e,t){void 0===t&&(t={});var n,r,i=iM(e.url);if(!i)return!1;var o=i.host;return!(!1!==t.ignoreAmplitudeRequests&&(iO(o,"*.amplitude.com")||iO(o,"amplitude.com"))||(null==(n=t.ignoreHosts)?void 0:n.find(function(e){return iO(o,e)})))&&(!!t.captureRules||void 0===e.status||!!iR(e.status,iA))&&(!t.captureRules||((0,Z.__spreadArray)([],(0,Z.__read)(t.captureRules),!1).reverse().find(function(t){if(r=function(e,t,n,r,i){if((!e.hosts||e.hosts.find(function(e){return iO(t,e)}))&&(!r||!e.urls||rc(r,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return(!n&&0!==n||!!iR(n,e.statusCodeRange||iA))&&!0}(t,o,e.status,e.url,e.method)){var n=iD(t.responseHeaders);if(e.responseWrapper&&n){var i=e.responseWrapper.headers(n);i&&(e.responseHeaders=i)}var s=iD(t.requestHeaders);if(e.requestWrapper&&s){var a=e.requestWrapper.headers(s);a&&(e.requestHeaders=a)}if(e.responseWrapper&&t.responseBody&&!iL(t.responseBody)){var u=t.responseBody.excludelist||t.responseBody.blocklist;e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,u)}if(e.requestWrapper&&t.requestBody&&!iL(t.requestBody)){var u=t.requestBody.excludelist||t.requestBody.blocklist;e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,u)}}return void 0!==r}),!!r))&&!(e.requestWrapper&&function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find(function(e){return e.event_type===ix}))return!0}catch(e){}return!1}(o,e.requestWrapper))}(e.event,f)}).subscribe(function(e){var t,n,r,i=e.event,o=iM(i.url);if(o){var s=null==(n=i.responseWrapper)?void 0:n.bodySize,a=null==(r=i.requestWrapper)?void 0:r.bodySize;!function(e,t,n,r){(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(!(t.requestBodyJson||t.responseBodyJson))return[3,2];return[4,Promise.all([t.requestBodyJson,t.responseBodyJson])];case 1:if(o=(i=Z.__read.apply(void 0,[a.sent(),2]))[0],s=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(s)try{e["[Amplitude] Response Body"]=JSON.stringify(s)}catch(e){null==r||r.debug("Failed to stringify response body")}a.label=2;case 2:return null==n||n.track(ix,e),[2]}})})}(((t={})["[Amplitude] URL"]=o.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=o.query,t["[Amplitude] URL Fragment"]=o.fragment,t["[Amplitude] Request Method"]=i.method,t["[Amplitude] Status Code"]=i.status,t["[Amplitude] Start Time"]=i.startTime,t["[Amplitude] Completion Time"]=i.endTime,t["[Amplitude] Duration"]=i.duration,t["[Amplitude] Request Body Size"]=a,t["[Amplitude] Response Body Size"]=s,t["[Amplitude] Request Type"]=i.type,t["[Amplitude] Request Headers"]=i.requestHeaders,t["[Amplitude] Response Headers"]=i.responseHeaders,t),i,g,h)}}),null==t||t.log("".concat(n," has been successfully added.")),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return W.unsubscribe(),[2]})})}}};let iF=-1,iq=e=>{addEventListener("pageshow",t=>{t.persisted&&(iF=t.timeStamp,e(t))},!0)},iU=(e,t,n,r)=>{let i,o;return s=>{let a;t.value>=0&&(s||r)&&((o=t.value-(i??0))||void 0===i)&&(i=t.value,t.delta=o,a=t.value,t.rating=a>n[1]?"poor":a>n[0]?"needs-improvement":"good",e(t))}},ij=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},iB=()=>{let e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},iz=()=>{let e=iB();return e?.activationStart??0},iW=(e,t=-1)=>{let n=iB(),r="navigate";return iF>=0?r="back-forward-cache":n&&(document.prerendering||iz()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(0x82f79cd8fff*Math.random())+1e12}`,navigationType:r}},iG=new WeakMap;function iH(e,t){return iG.get(e)||iG.set(e,new t),iG.get(e)}class iK{t;i=0;o=[];h(e){if(e.hadRecentInput)return;let t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}let iV=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{Promise.resolve().then(()=>{t(e.getEntries())})});return r.observe({type:e,buffered:!0,...n}),r}}catch{}},i$=e=>{let t=!1;return()=>{t||(e(),t=!0)}},iJ=-1,iY=new Set,iQ=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,iX=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(let e of iY)e();isFinite(iJ)||(iJ="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",iX,!0))}},iZ=()=>
1{if(iJ<0){let e=iz();iJ=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime)??iQ(),addEventListener("visibilitychange",iX,!0),addEventListener("prerenderingchange",iX,!0),iq(()=>{setTimeout(()=>{iJ=iQ()})})}return{get firstHiddenTime(){return iJ},onHidden(e){iY.add(e)}}},i0=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},i1=[1800,3e3],i2=(e,t={})=>{i0(()=>{let n=iZ(),r,i=iW("FCP"),o=iV("paint",e=>{for(let t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-iz(),0),i.entries.push(t),r(!0)))});o&&(r=iU(e,i,i1,t.reportAllChanges),iq(n=>{r=iU(e,i=iW("FCP"),i1,t.reportAllChanges),ij(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},i3=[.1,.25],i4=0,i5=1/0,i6=0,i8=e=>{for(let t of e)t.interactionId&&(i5=Math.min(i5,t.interactionId),i4=(i6=Math.max(i6,t.interactionId))?(i6-i5)/7+1:0)},i7=()=>t?i4:performance.interactionCount??0,i9=0;class oe{u=[];l=new Map;m;p;v(){i9=i7(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((i7()-i9)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;let t=this.u.at(-1),n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort((e,t)=>t.P-e.P),this.u.length>10)for(let e of this.u.splice(10))this.l.delete(e.id);this.p?.(n)}}}let ot=e=>{let t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(addEventListener("visibilitychange",e=i$(e),{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},on=[200,500];class or{m;h(e){this.m?.(e)}}let oi=[2500,4e3],oo=[800,1800],os=e=>{document.prerendering?i0(()=>os(e)):"complete"!==document.readyState?addEventListener("load",()=>os(e),!0):setTimeout(e)};function oa(e){var t,n;return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor((n=(null==(t=e.entries[0])?void 0:t.startTime)||0,performance.timeOrigin+n)),navigationStart:Math.floor(performance.timeOrigin)}}var ou=function(){var e=null,n=(0,eA.getGlobalScope)(),r=null==n?void 0:n.document,i=null==n?void 0:n.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(n,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s,a;return(0,Z.__generator)(this,function(u){return void 0===r||(s=rd((null==i?void 0:i.href)||"",n.loggerProvider),a={"[Amplitude] Page Domain":(null==i?void 0:i.hostname)||"","[Amplitude] Page Location":s,"[Amplitude] Page Path":rd((null==i?void 0:i.pathname)||"",n.loggerProvider),"[Amplitude] Page Title":"u">typeof document&&document.title||"","[Amplitude] Page URL":rd(s.split("?")[0],n.loggerProvider)},((e,t={})=>{i0(()=>{let n=iZ(),r,i=iW("LCP"),o=iH(t,or),s=e=>{for(let s of(t.reportAllChanges||(e=e.slice(-1)),e))o.h(s),s.startTime<n.firstHiddenTime&&(i.value=Math.max(s.startTime-iz(),0),i.entries=[s],r())},a=iV("largest-contentful-paint",s);if(a){r=iU(e,i,oi,t.reportAllChanges);let n=i$(()=>{s(a.takeRecords()),a.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(ot(n),removeEventListener(e.type,o,{capture:!0}))};for(let e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});iq(n=>{r=iU(e,i=iW("LCP"),oi,t.reportAllChanges),ij(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(function(e){a["[Amplitude] LCP"]=oa(e)}),i2(function(e){a["[Amplitude] FCP"]=oa(e)}),((e,n={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let r=iZ();i0(()=>{"interactionCount"in performance||t||(t=iV("event",i8,{type:"event",buffered:!0,durationThreshold:0}));let i,o=iW("INP"),s=iH(n,oe),a=e=>{ot(()=>{for(let t of e)s.h(t);let t=s.L();t&&t.P!==o.value&&(o.value=t.P,o.entries=t.entries,i())})},u=iV("event",a,{durationThreshold:n.durationThreshold??40});i=iU(e,o,on,n.reportAllChanges),u&&(u.observe({type:"first-input",buffered:!0}),r.onHidden(()=>{a(u.takeRecords()),i(!0)}),iq(()=>{s.v(),i=iU(e,o=iW("INP"),on,n.reportAllChanges)}))})})(function(e){a["[Amplitude] INP"]=oa(e)}),((e,t={})=>{let n=iZ();i2(i$(()=>{let r,i=iW("CLS",0),o=iH(t,iK),s=e=>{for(let t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},a=iV("layout-shift",s);a&&(r=iU(e,i,i3,t.reportAllChanges),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),iq(()=>{o.i=0,r=iU(e,i=iW("CLS",0),i3,t.reportAllChanges),ij(()=>r())}),setTimeout(r))}))})(function(e){a["[Amplitude] CLS"]=oa(e)}),((e,t={})=>{let n=iW("TTFB"),r=iU(e,n,oo,t.reportAllChanges);os(()=>{let i=iB();i&&(n.value=Math.max(i.responseStart-iz(),0),n.entries=[i],r(!0),iq(()=>{(r=iU(e,n=iW("TTFB",0),oo,t.reportAllChanges))(!0)}))})})(function(e){a["[Amplitude] TTFB"]=oa(e)}),e=function(){"hidden"===r.visibilityState&&e&&(o.track("[Amplitude] Web Vitals",a),r.removeEventListener("visibilitychange",e),e=null)},r.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return e&&(null==r||r.removeEventListener("visibilitychange",e)),[2]})})}}},ol=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),["AMP",t,e.substring(0,n)].filter(
1Boolean).join("_")},oc=function(){function e(e,t){var n;this.shouldTrackNewCampaign=!1,this.options=(0,Z.__assign)({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:ny((null==(n=t.cookieOptions)?void 0:n.domain)||t.topLevelDomain),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=ol(t.apiKey,"MKTG"),this.webExpStorageKey=ol(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=ew,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(this.options.optOut)return[2];return[4,this.fetchCampaign()];case 1:if(t=Z.__read.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||te(this.sessionTimeout,this.lastEventTime),!np(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain))return[3,3];return this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:if(!(e=t.sent()))return[3,3];return[4,this.storage.remove(this.webExpStorageKey)];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||new nL().parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r=(t=this.currentCampaign,n=this.options,eD(Object.entries((0,Z.__assign)((0,Z.__assign)({},ew),t)).reduce(function(e,t){var r,i=(0,Z.__read)(t,2),o=i[0],s=i[1];return(e.setOnce("initial_".concat(o),null!=(r=null!=s?s:n.initialEmptyValue)?r:"EMPTY"),s)?e.set(o,s):e.unset(o)},new eC)));return e&&(r.event_id=e),r},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),od=new Set([O.IDENTIFY,O.GROUP_IDENTIFY]),of=function(e){void 0===e&&(e={});var t,n,r,i,o,s,a,u=null!=(t=e.fallbackAttributionEvent)&&t,l=(0,eA.getGlobalScope)(),c={},d=!1,f=!1,g=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,new nL().parse()];case 1:return c=nN(e.sent()),u&&(null==r||r.log("Tracking attribution fallback event."),null==n||n.track("[Amplitude] Attribution",c)),[2]}})})},h=function(){g()},p=function(e){return new Proxy(e,{apply:function(e,t,n){Reflect.apply(e,t,n),d&&h()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(u){switch(u.label){case 0:return n=t,r=e.loggerProvider,d=!0,r.log("Installing event property attribution tracking."),[4,g()];case 1:if(u.sent(),!l)return[2];if(l.addEventListener("popstate",h),!f){if(i=Reflect.get(l.history,"pushState"),o=Reflect.get(l.history,"replaceState"),!i||!o)return[2];s=p(i),l.history.pushState=s,a=p(o),l.history.replaceState=a,f=!0}return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return od.has(e.event_type)||(e.event_properties=(0,Z.__assign)((0,Z.__assign)({},c),e.event_properties)),[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(n){return l&&(l.removeEventListener("popstate",h),e=Reflect.get(l.history,"pushState"),t=Reflect.get(l.history,"replaceState"),f&&e===s&&i&&(l.history.pushState=i),f&&t===a&&o&&(l.history.replaceState=o)),d=!1,f=!1,i=void 0,o=void 0,s=void 0,a=void 0,c={},[2]})})}}},og="AMP_CURRENT_PAGE",oh="AMP_PREVIOUS_PAGE",op="AMP_URL_INFO";(g=G||(G={})).Direct="direct",g.Internal="internal",g.External="external";var ov=new Set([O.IDENTIFY,O.GROUP_IDENTIFY,O.REVENUE]),om=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=(0,eA.getGlobalScope)(),i=void 0,o=!1,s=void 0,a=!1,u=!1,l=function(e){var t;try{var n=rd(e,s);
1t=new URL(n).hostname}catch(e){null==s||s.error("Could not parse URL: ",e)}return t},c=function(e){var t="u">typeof location&&location.hostname||"",r=e?l(e):void 0;if(!r)return G.Direct;var i=n.some(function(e){return -1!==t.indexOf(e)}),o=n.some(function(e){return -1!==r.indexOf(e)});return t===r||o&&i?G.Internal:G.External},d=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(!(i&&o))return[3,3];return[4,i.get(op)];case 1:return e=a.sent(),t=rd("u">typeof location&&location.href||""),n=(null==e?void 0:e[og])||"",r=void 0,r=t===n?(null==e?void 0:e[oh])||"":n||document.referrer||"",[4,i.set(op,((s={})[og]=t,s[oh]=r,s))];case 2:a.sent(),a.label=3;case 3:return[2]}})})},f=function(){d()};return{name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,n,c,g,h,p,v,m;return(0,Z.__generator)(this,function(y){switch(y.label){case 0:if((s=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),u=!0,!r)return[3,7];try{i=new tQ(r.sessionStorage)}catch(e){null==s||s.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:if(o=null!=(m=y.sent())&&m,!(i&&o))return[3,6];return n=(t="u">typeof document&&document.referrer||"")?l(t):void 0,c="u">typeof location&&location.hostname||"",g=rd("u">typeof location&&location.href||""),[4,i.get(op)];case 2:if(p=(null==(h=y.sent())?void 0:h[og])||"",!(n&&n!==c&&p!==g))return[3,4];return[4,i.set(op,((v={})[og]=g,v[oh]=t,v))];case 3:return y.sent(),[3,6];case 4:return[4,d()];case 5:y.sent(),y.label=6;case 6:r.addEventListener("popstate",f),a||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=(0,Z.__read)(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),u&&f()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=(0,Z.__read)(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),u&&f()}}),a=!0),y.label=7;case 7:return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,n,r;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:if(t=rd("u">typeof location&&location.href||""),!(i&&o))return[3,2];return[4,i.get(op)];case 1:if(r=(null==(n=s.sent())?void 0:n[oh])||"",ov.has(e.event_type))return[2,e];e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties||{}),{"[Amplitude] Page Domain":oy(e,"[Amplitude] Page Domain","u">typeof location&&location.hostname||""),"[Amplitude] Page Location":oy(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":oy(e,"[Amplitude] Page Path","u">typeof location&&rd(location.pathname)||""),"[Amplitude] Page Title":oy(e,"[Amplitude] Page Title",nD(nM)),"[Amplitude] Page URL":oy(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":r,"[Amplitude] Previous Page Type":c(r)}),s.label=2;case 2:return[2,e]}})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:if(r&&(r.removeEventListener("popstate",f),u=!1),!(i&&o))return[3,2];return[4,i.set(op,{})];case 1:e.sent(),e.label=2;case 2:return[2]}})})}}};function oy(e,t,n){return(e.event_properties||(e.event_properties={}),void 0===e.event_properties[t])?n:e.event_properties[t]}var o_=function(){var e,t,n;function r(t){if(t)try{var n=Function("return "+t)();if("function"==typeof n)return n;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}return{name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Z.__generator)(this,function(a){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null==(s=i.remoteConfig)?void 0:s.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(e){n=e&&"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?r(e.body||""):r("")}),t=function(){var e;return null==(e=i.remoteConfigClient)?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var r;return(0,Z.__generator)(this,function(i){if(n)try{return[2,null!=(r=n(t))?r:null]}catch(t){null==e||e.error("Could not execute custom enrichment function",t)}return[2,t]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return t&&t(),[2]})})}}},ob="userProperty",oS="eventProperty",ow=function(e){return e===ob||e===oS},oE=[ob,oS],ok=function(e){var t=(0,Z.__spreadArray)([],(0,Z.__read)(new Set((Array.isArray(e)?e:[e]).filter(ow))),!1);return t.length>0?t:(0,Z.__spreadArray)([],(0,Z.__read)(oE),!1)},oI=function(e,t){return ok(e.trackingMethod).includes(t)},oT=function(e){return oI(e,ob)};let oC={init:ei((h=new(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return(0,Z.__extends)(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>
12?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),eF(this._init((0,Z.__assign)((0,Z.__assign)({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o,s,a,u,l;return(0,Z.__awaiter)(this,void 0,void 0,function(){var c,d,f,g,h,p,v,m,y,_,b,S,w,E,k=this;return(0,Z.__generator)(this,function(I){var T,C,P,A,O,R,M,D,L;switch(I.label){case 0:if(this.initializing)return[2];if(this.initializing=!0,c=nT(t),d=null!=(n=t.loggerProvider)?n:new eB,t.loggerProvider||d.enable(null!=(r=t.logLevel)?r:x.Warn),f=null!=(i=t.serverZone)?i:"US",h=this._diagnosticsSampleRate,p=null==(o=t.enableDiagnostics)||o,!c)return[3,2];return g=new to(t.apiKey,d,f,null==(s=t.remoteConfig)?void 0:s.serverUrl),[4,new Promise(function(e){null==g||g.subscribe("configs.diagnostics.browserSDK","all",function(t,n,r){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(h=i);var o=t.enabled;"boolean"==typeof o&&(p=o)}e()})})];case 1:I.sent(),I.label=2;case 2:return(v=new tb(t.apiKey,d,f,{enabled:p,sampleRate:h})).setTag("library","".concat(tB,"/").concat(tj)),"u">typeof navigator&&v.setTag("user_agent",navigator.userAgent),[4,(T=t.apiKey,C=t,P=this,A=v,O={loggerProvider:d,serverZone:f,enableDiagnostics:p,diagnosticsSampleRate:h},void 0===C&&(C={}),(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,S,w,E,k,I,x,R,M,D,L,N,F,q,U,j,B,z,W,G,H,K,V,$,J,Y,Q,X,ee,et,en;return(0,Z.__generator)(this,function(er){var ei,eo,es,ea;switch(er.label){case 0:if(e=C.identityStorage||nf,t="",!(e===nf&&!(null==(S=C.cookieOptions)?void 0:S.domain)&&(null==(w=C.cookieOptions)?void 0:w.domain)!==""))return[3,2];return[4,(ei=void 0,eo=A,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return[4,new tH(void 0,{diagnosticsClient:eo}).isEnabled()];case 1:if(!a.sent()||!ei&&("u"<typeof location||!location.hostname)||1===(t=(e=null!=ei?ei:location.hostname).split(".")).length)return[2,""];for(n=[],r=1,nS.find(function(t){return e.endsWith(".".concat(t))})&&(r=2),i=t.length-r-1;i>=0;--i)n.push(t.slice(i).join("."));i=0,a.label=2;case 2:if(!(i<n.length))return[3,7];o=n[i],a.label=3;case 3:return a.trys.push([3,5,,6]),[4,tH.isDomainWritable(o)];case 4:if(a.sent())return[2,"."+o];return[3,6];case 5:return s=a.sent(),eo&&eo.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(o),error:s instanceof Error?s.message:String(s)}),[3,6];case 6:return i++,[3,2];case 7:return eo&&eo.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(e)}),[2,""]}})}))];case 1:t=er.sent(),er.label=2;case 2:return n=(0,Z.__assign)({domain:null!=(k=null==(E=C.cookieOptions)?void 0:E.domain)?k:t,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},C.cookieOptions),r={duplicateResolverFn:function(e){var t=t$(e);return!!t&&tJ(JSON.parse(t).cookieDomain,n.domain)},diagnosticsClient:A},[4,(es=i=nI(C.identityStorage,n,r),void 0===(ea=null==(x=null==(I=C.cookieOptions)?void 0:I.upgrade)||x)&&(ea=!0),(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:return e="".concat("amp","_").concat(T.substring(0,6)),[4,es.getRaw(e)];case 1:if(!(t=l.sent()))return[2,{optOut:!1}];if(!ea)return[3,3];return[4,es.remove(e)];case 2:l.sent(),l.label=3;case 3:return r=(n=(0,Z.__read)(t.split("."),6))[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],[2,{deviceId:r,userId:t8(i),sessionId:t6(s),lastEventId:t6(u),lastEventTime:t6(a),optOut:!!o}]}})}))];case 3:return o=er.sent(),[4,i.get(tY(T))];case 4:return s=er.sent(),l=!(u=(a=tn()).ampTimestamp?Number(a.ampTimestamp):void 0)||Date.now()<u,c=null!=(N=null!=(L=null!=(D=null!=(R=C.deviceId)?R:l?null!=(M=a.ampDeviceId)?M:a.deviceId:void 0)?D:null==s?void 0:s.deviceId)?L:o.deviceId)?N:eR(),d=null!=(F=null==s?void 0:s.lastEventId)?F:o.lastEventId,f=null!=(q=null==s?void 0:s.lastEventTime)?q:o.lastEventTime,g=null!=(j=null!=(U=C.optOut)?U:null==s?void 0:s.optOut)?j:o.optOut,h=null!=(B=null==s?void 0:s.sessionId)?B:o.sessionId,p=null==s?void 0:s.deferredSessionId,v=null!=(W=null!=(z=C.userId)?z:null==s?void 0:s.userId)?W:o.userId,P.previousSessionDeviceId=null!=(G=null==s?void 0:s.deviceId)?G:o.deviceId,P.previousSessionUserId=null!=(H=null==s?void 0:s.userId)?H:o.userId,m={ipAddress:null==(V=null==(K=C.trackingOptions)?void 0:K.ipAddress)||V,language:null==(J=null==($=C.trackingOptions)?void 0:$.language)||J,platform:null==(Q=null==(Y=C.trackingOptions)?void 0:Y.platform)||Q},y=null==s?void 0:s.pageCounter,_=null==s?void 0:s.debugLogsEnabled,void 0!==C.autocapture&&(C.defaultTracking=C.autocapture),[4,(b=new nk(T,C.appVersion,i,n,C.defaultTracking,C.autocapture,c,C.flushIntervalMillis,C.flushMaxRetries,C.flushQueueSize,e,C.ingestionMetadata,C.instanceName,d,f,null!=(X=null==O?void 0:O.loggerProvider)?X:C.loggerProvider,C.logLevel,C.minIdLength,C.offline,g,C.partnerId,C.plan,C.serverUrl,null!=(ee=null==O?void 0:O.serverZone)?ee:C.serverZone,h,p,C.sessionTimeout,C.storageProvider,m,C.transport,C.useBatch,C.fetchRemoteConfig,v,y,_,C.networkTrackingOptions,C.identify,null!=(et=null==O?void 0:O.enableDiagnostics)?et:C.enableDiagnostics,null!=(en=null==O?void 0:O.diagnosticsSampleRate)?en:P._diagnosticsSampleRate,A,C.remoteConfig,t,C.enableRequestBodyCompression,C.customEnrichment)).storageProvider.isEnabled()];case 5:return er.sent()||(b.loggerProvider.warn("Storage provider ".concat(b.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),b.storageProvider=new tW),[2,b]}})}))];case 3:if(m=I.sent(),!(c&&g))return[3,5];return[4,new Promise(function(e){null==g||g.subscribe("configs.analyticsSDK.browserSDK","all",function(t,n,r){m.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&function(e,t){var n,r;if(e){!function e(t){if("object"==typeof t&&null!==t&&!Array.isArray(t)){var n,r,i,o,s,a,u,l,c,d,f,g,h=Object.keys(t);try{for(var p=(0,Z.__values)(h),v=p.next();!v.done;v=p.next()){var m=v.value;try{var y=t[m];"boolean"==typeof(null==y?void 0:y.enabled)&&(y.enabled?(delete y.enabled,0===Object.keys(y).length&&(t[m]=!0)):t[m]=!1),e(y)}catch(e){}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}
1try{if(null==(c=null==(l=null==(u=t.autocapture)?void 0:u.networkTracking)?void 0:l.captureRules)?void 0:c.length)try{for(var _=(0,Z.__values)(t.autocapture.networkTracking.captureRules),b=_.next();!b.done;b=_.next()){var S=b.value;try{for(var w=(s=void 0,(0,Z.__values)(["responseHeaders","requestHeaders"])),E=w.next();!E.done;E=w.next()){var k=E.value,I=null!=(d=S[k])?d:{},T=I.captureSafeHeaders,C=I.allowlist;if(T||C){if(void 0!==C&&!Array.isArray(C)){delete S[k];continue}S[k]=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(T?eE:[]),!1),(0,Z.__read)(null!=C?C:[]),!1)}}}catch(e){s={error:e}}finally{try{E&&!E.done&&(a=w.return)&&a.call(w)}finally{if(s)throw s.error}}}}catch(e){i={error:e}}finally{try{b&&!b.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}catch(e){}var P=null==(f=t.autocapture)?void 0:f.frustrationInteractions;P&&(P.rageClick&&(P.rageClicks=P.rageClick,delete P.rageClick),P.deadClick&&(P.deadClicks=P.deadClick,delete P.deadClick));try{var x=null==(g=t.autocapture)?void 0:g.elementInteractions;if(x&&"object"==typeof x&&(!0===x.viewportContentUpdated&&(x.viewportContentUpdated={}),!1===x.viewportContentUpdated&&(x.viewportContentUpdated={enabled:!1}),void 0!==x.exposureDuration)){var A=x.viewportContentUpdated;void 0===A?x.viewportContentUpdated={exposureDuration:x.exposureDuration}:"object"==typeof A&&void 0===A.exposureDuration&&!1!==A.enabled&&(A.exposureDuration=x.exposureDuration),delete x.exposureDuration}}catch(e){}}}(e);try{if(t.loggerProvider.debug("Update browser config with remote configuration:",tw(e)),e&&"autocapture"in e){if("boolean"==typeof e.autocapture&&(t.autocapture=e.autocapture),"object"==typeof e.autocapture&&null!==e.autocapture){var i=(0,Z.__assign)({},e.autocapture);if(void 0===t.autocapture&&(t.autocapture=e.autocapture),"object"==typeof e.autocapture.elementInteractions&&null!==e.autocapture.elementInteractions&&(null==(n=e.autocapture.elementInteractions.pageUrlAllowlistRegex)?void 0:n.length)){i.elementInteractions=(0,Z.__assign)({},e.autocapture.elementInteractions);var o=i.elementInteractions,s=null!=(r=o.pageUrlAllowlist)?r:[],a=e.autocapture.elementInteractions.pageUrlAllowlistRegex;o.pageUrlAllowlist=nJ(s,a,t.loggerProvider),delete o.pageUrlAllowlistRegex}var u=function(e,t){if("object"==typeof e&&null!==e&&(null==(i=e.captureRules)?void 0:i.length)){var n,r,i,o,s,a=(0,Z.__assign)({},e),u=null!=(o=a.captureRules)?o:[];try{for(var l=(0,Z.__values)(u),c=l.next();!c.done;c=l.next()){var d=c.value;d.urls=nJ(null!=(s=d.urls)?s:[],d.urlsRegex,t),delete d.urlsRegex}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return a}}(e.autocapture.networkTracking,t.loggerProvider);u&&(i.networkTracking=u),"boolean"==typeof t.autocapture&&(t.autocapture=(0,Z.__assign)({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},i)),"object"==typeof t.autocapture&&(t.autocapture=(0,Z.__assign)((0,Z.__assign)({},t.autocapture),i))}t.defaultTracking=t.autocapture}"customEnrichment"in e&&null!==e.customEnrichment&&!1!==t.customEnrichment&&(t.customEnrichment=e.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",tw(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}(t,m),e()})})];case 4:I.sent(),I.label=5;case 5:return[4,e.prototype._init.call(this,m)];case 6:if(I.sent(),this.logBrowserOptions(m),this.config.remoteConfigClient=g,y=tk((R=this.config).defaultTracking)&&R.defaultTracking&&"object"==typeof R.defaultTracking&&R.defaultTracking.attribution&&"object"==typeof R.defaultTracking.attribution?(0,Z.__assign)({},R.defaultTracking.attribution):{},!(tk(this.config.defaultTracking)&&oT(y)))return[3,8];return this.config.optOut&&this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(e)return[3,2];return this.webAttribution=new oc(y,this.config),[4,this.webAttribution.init()];case 1:t.sent(),t.label=2;case 2:return[2]}})})}),this.webAttribution=new oc(y,this.config),[4,this.webAttribution.init()];case 7:I.sent(),I.label=8;case 8:if(S=!(!(b=(_=tn()).ampTimestamp?Number(_.ampTimestamp):void 0)||Date.now()<b)||Number.isNaN(Number(_.ampSessionId))?void 0:Number(_.ampSessionId),-1!==(w=this.config.deferredSessionId)||this.config.optOut||(w=Date.now()),this.setSessionId(null!=(l=null!=(u=null!=(a=t.sessionId)?a:S)?u:w)?l:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),(E=e8(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline)return[3,10];return[4,this.add(n$()).promise];case 9:I.sent(),I.label=10;case 10:return[4,this.add(new eJ({diagnosticsClient:v})).promise];case 11:return I.sent(),[4,this.add(new tz).promise];case 12:return I.sent(),[4,this.add(new tt).promise];case 13:if(I.sent(),nV(this.config),!tE(this.config.defaultTracking,"fileDownloads"))return[3,15];return this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(nH()).promise];case 14:I.sent(),I.label=15;case 15:if(!tI(this.config.defaultTracking))return[3,17];return this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(nz()).promise];case 16:I.sent(),I.label=17;case 17:if(!tT(this.config.defaultTracking))return[3,20];if(this.config.optOut)return[3,19];return this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(nq(tL(this.config))).promise];case 18:return I.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(e)return[2];return this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(nq(tL(this.config))).promise];case 1:return t.sent(),[2]}})})}),I.label=20;case 20:if(!(tk(this.config.defaultTracking)&&oI(y,oS)))return[3,22];return this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(of(y)).promise];case 21:I.sent(),I.label=22;case 22:if(!tx(this.config.autocapture))return[3,24];return this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(r7(tR(this.config),{diagnosticsClient:v})).promise];case 23:I.sent(),I.label=24;case 24:if(!tA(this.config.autocapture))return[3,26];return this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(ig(tM(this.config))).promise];
1case 25:I.sent(),I.label=26;case 26:if(!tP(this.config.autocapture))return[3,28];return this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(iN(tD(this.config))).promise];case 27:I.sent(),I.label=28;case 28:if(!("boolean"==typeof(M=this.config.autocapture)?M:"object"==typeof M&&!0===M.webVitals))return[3,30];return this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(ou()).promise];case 29:I.sent(),I.label=30;case 30:if("object"!=typeof(D=this.config.autocapture)||!0!==D.performanceTracking&&"object"!=typeof D.performanceTracking)return[3,32];return this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(ip(tO(this.config))).promise];case 31:I.sent(),I.label=32;case 32:if(!tE(this.config.autocapture,"pageUrlEnrichment"))return[3,34];return this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(om()).promise];case 33:I.sent(),I.label=34;case 34:if(!("boolean"==typeof(L=this.config.customEnrichment)?L:"object"==typeof L&&null!==L&&!1!==L.enabled))return[3,36];return this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(o_()).promise];case 35:I.sent(),I.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return I.sent(),E.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=(0,Z.__rest)(t,["time"]);k.track(e.eventType,r,"number"==typeof n?{time:n}:void 0)}),[2]}})})},t.prototype.getUserId=function(){var e;return null==(e=this.config)?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),(e!==this.config.userId||void 0===e)&&(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),e7(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null==(e=this.config)?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),e9(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(eR()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null==(e=this.config)?void 0:e.deviceId,userId:null==(t=this.config)?void 0:t.userId,userProperties:this.userProperties}},t.prototype.setIdentity=function(e){if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var t,n,r,i=new eC,o=null!=(r=e.userProperties)?r:{};try{for(var s=(0,Z.__values)(Object.entries(o)),a=s.next();!a.done;a=s.next()){var u=(0,Z.__read)(a.value,2),l=u[0],c=u[1];i.set(l,c)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null==(e=this.config)?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null==(e=this.config)?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),eF(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,eF(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return eF(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!=(t=this.config.lastEventId)?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,tC(this.config.defaultTracking)&&(r&&i&&n.push(this.track(nr,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(eD(this.config.identify)).promise),tC(this.config.defaultTracking)&&n.push(this.track(nn,void 0,{event_id:s?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,eF(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=
1Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=nC(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(tq(t)){var r=t._q;t._q=[],t=tF(new eC,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,r,i){if(tq(r)){var o=r._q;r._q=[],r=tF(new eC,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(tq(t)){var r=t._q;t._q=[],t=tF(new eY,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!oT(this.webAttribution.options))return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},t.prototype.process=function(t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i;return(0,Z.__generator)(this,function(o){return n=Date.now(),r=te(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type!==nn&&t.event_type!==nr&&(!t.session_id||t.session_id===this.getSessionId())&&(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},t.prototype.logBrowserOptions=function(e){try{var t=(0,Z.__assign)((0,Z.__assign)({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",tw(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){if(!(e>1)&&!(e<0)&&!this.config){this._diagnosticsSampleRate=e;return}},t}(eq))).init.bind(h),"init",et(h),er(h,["config"])),add:ei(h.add.bind(h),"add",et(h),er(h,["config.apiKey","timeline.plugins"])),remove:ei(h.remove.bind(h),"remove",et(h),er(h,["config.apiKey","timeline.plugins"])),track:ei(h.track.bind(h),"track",et(h),er(h,["config.apiKey","timeline.queue.length"])),logEvent:ei(h.logEvent.bind(h),"logEvent",et(h),er(h,["config.apiKey","timeline.queue.length"])),identify:ei(h.identify.bind(h),"identify",et(h),er(h,["config.apiKey","timeline.queue.length"])),groupIdentify:ei(h.groupIdentify.bind(h),"groupIdentify",et(h),er(h,["config.apiKey","timeline.queue.length"])),setGroup:ei(h.setGroup.bind(h),"setGroup",et(h),er(h,["config.apiKey","timeline.queue.length"])),revenue:ei(h.revenue.bind(h),"revenue",et(h),er(h,["config.apiKey","timeline.queue.length"])),flush:ei(h.flush.bind(h),"flush",et(h),er(h,["config.apiKey","timeline.queue.length"])),getUserId:ei(h.getUserId.bind(h),"getUserId",et(h),er(h,["config","config.userId"])),setUserId:ei(h.setUserId.bind(h),"setUserId",et(h),er(h,["config","config.userId"])),getDeviceId:ei(h.getDeviceId.bind(h),"getDeviceId",et(h),er(h,["config","config.deviceId"])),setDeviceId:ei(h.setDeviceId.bind(h),"setDeviceId",et(h),er(h,["config","config.deviceId"])),reset:ei(h.reset.bind(h),"reset",et(h),er(h,["config","config.userId","config.deviceId"])),getSessionId:ei(h.getSessionId.bind(h),"getSessionId",et(h),er(h,["config"])),setSessionId:ei(h.setSessionId.bind(h),"setSessionId",et(h),er(h,["config"])),extendSession:ei(h.extendSession.bind(h),"extendSession",et(h),er(h,["config"])),setOptOut:ei(h.setOptOut.bind(h),"setOptOut",et(h),er(h,["config"])),setTransport:ei(h.setTransport.bind(h),"setTransport",et(h),er(h,["config"])),getIdentity:ei(h.getIdentity.bind(h),"getIdentity",et(h),er(h,["config"])),setIdentity:ei(h.setIdentity.bind(h),"setIdentity",et(h),er(h,["config","config.userId","config.deviceId"])),getOptOut:ei(h.getOptOut.bind(h),"getOptOut",et(h),er(h,["config"])),_setDiagnosticsSampleRate:ei(h._setDiagnosticsSampleRate.bind(h),"_setDiagnosticsSampleRate",et(h),er(h,["config"]))};e.s([],41521),e.i(41521),(p=H||(H={})).US="US",p.EU="EU",p.STAGING="STAGING",e.s(["DEFAULT_ACTION_CLICK_ALLOWLIST",0,nX,"DEFAULT_CSS_SELECTOR_ALLOWLIST",0,nY,"DEFAULT_DATA_ATTRIBUTE_PREFIX",0,nQ,"EXCLUDE_INTERNAL_REFERRERS_CONDITIONS",0,ng,"IdentifyOperation",0,A,"LogLevel",0,x,"OfflineDisabled",0,null,"RevenueProperty",0,D,"ServerZone",0,H,"SpecialEventType",0,O],91973),e.i(91973);var oP=oC.add,ox=(oC.extendSession,oC.flush),oA=oC.getDeviceId,oO=(oC.getIdentity,oC.getOptOut,oC.getSessionId,oC.getUserId,oC.groupIdentify,oC.identify,oC.init),oR=(oC.logEvent,oC.remove,oC.reset,oC.revenue,oC.setDeviceId,oC.setGroup,oC.setIdentity,oC.setOptOut,oC.setSessionId,oC.setTransport,oC.setUserId,oC.track);oC._setDiagnosticsSampleRate;var oM=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if("u"<typeof fetch)throw Error("FetchTransport is not supported");return[4,fetch(e,{headers:(0,Z.__assign)({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"})];case 1:return[4,(n=i.sent()).text()];case 2:r=i.sent();try{return[2,this.buildResponse(JSON.parse(r))]}catch(e){return[2,this.buildResponse({code:n.status})]}}})})},t}(t0),oD="[Amplitude]",oL="".concat(oD," Session Replay ID"),oN=H.US,oF={enabled:!0},oq="".concat(oD," Session Replay Debug"),oU="amp-mask",oj="amp-unmask",oB="https://api-sr.amplitude.com/sessions/v2/track",oz="https://api-sr.eu.amplitude.com/sessions/v2/track",oW="https://api-sr.stag2.amplitude.com/sessions/v2/track",oG=/payload.*exceed/i,oH="X-Session-Replay-Event-Skipped",oK="amplitude-sr-iframe";(v=K||(K={})).GET_SR_PROPS="get-sr-props",v.DEBUG_INFO="debug-info",v.FETCH_REQUEST="fetch-request",v.METADATA="metadata",v.TARGETING_DECISION="targeting-decision",v.REPLAY_GATE_DECISION="replay-gate-decision";var oV=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){if(!this.logger)return function(){};var t,n=this.logger[e];return"function"==typeof n?(null!=(t=n.__rrweb_original__)?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),o$="medium",oJ=function(e,t,n){switch(t){case"light":if("input"!==e)return!1;var r,i,o=n?(i=(r=n).type,r.hasAttribute("data-rr-is-password")?"password":i?i.toLowerCase():null):"";if(!o)return!1;if(["password","hidden","email","tel"].includes(o)||n.autocomplete.startsWith("cc-"))return!0;return!1;case"medium":return"input"===e;case"conservative":return!0;default:return oJ(e,o$,n)}},oY=function(e,t){if(e&&t.urlMaskLevels)try{for(var n,r,i,o=(0,Z.__values)(t.urlMaskLevels),s=o.next();!s.done;s=o.next()){var a=s.value;if(o1(a.match).test(e))return a.maskLevel}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null!=(i=t.defaultMaskLevel)?i:o$},oQ=function(e,t,n,r){var i,o;if(void 0===t&&(t={defaultMaskLevel:o$}),n){if(n.closest("."+oU)||(null!=(i=t.maskSelector)?i:[]).some(function(e){return n.closest(e)}))return!0;
1if(n.closest("."+oj)||(null!=(o=t.unmaskSelector)?o:[]).some(function(e){return n.closest(e)}))return!1}return oJ(e,oY(r,t),n)},oX=function(e,t,n){return function(r,i){return oQ(e,t,i,null==n?void 0:n())?r.replace(/[^\s]/g,"*"):r}},oZ=function(){var e=(0,eA.getGlobalScope)();return(null==e?void 0:e.location)?e.location.href:""},o0=new Map,o1=function(e){var t=o0.get(e);if(t)return t;var n="\0TRAIL\0",r="\0MID\0",i="\0DS\0",o="\0ST\0",s="\0QU\0",a=e;a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=a.replace(/\/\*\*$/,n)).replace(/\/\*\*\//g,r)).replace(/\*\*/g,i)).replace(/\*/g,o)).replace(/\?/g,s)).replace(/[.+^${}()|[\]\\]/g,"\\$&")).split(n).join("(/.*)?")).split(r).join("/(.*\\/)?")).split(i).join(".*")).split(o).join(".*")).split(s).join(".");var u=new RegExp("^".concat(a,"$"));return o0.set(e,u),u},o2=function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){var t;return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t)}))throw Error("ugcFilterRules must be an array of objects with valid globs")},o3=function(e,t){var n,r;try{for(var i=(0,Z.__values)(t),o=i.next();!o.done;o=i.next()){var s=o.value,a=o1(s.selector);if(a.test(e))return e.replace(a,s.replacement)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},o4=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(e=(0,eA.getGlobalScope)()))return[3,2];return[4,e.navigator.storage.estimate()];case 1:return n=(t=i.sent()).usage,r=t.quota,[2,{totalStorageSize:n?Math.round(n/1024):0,percentOfQuota:n&&r?Math.round((n/r+Number.EPSILON)*1e3)/1e3:0,usageDetails:JSON.stringify(t.usageDetails)}];case 2:return[3,4];case 3:return i.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},o5=function(e){var t=(0,Z.__assign)({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},o6=function(){return{flushMaxRetries:2,logLevel:x.Warn,loggerProvider:new eB,transportProvider:new oM}},o8=function(e){function t(t,n){var r,i,o,s,a,u,l,c,d,f,g,h,p,v,m=this,y=o6();return(m=e.call(this,(0,Z.__assign)((0,Z.__assign)({transportProvider:y.transportProvider,loggerProvider:new oV(n.loggerProvider||y.loggerProvider)},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=y.flushMaxRetries?n.flushMaxRetries:y.flushMaxRetries,m.apiKey=t,m.sampleRate=n.sampleRate||0,m.serverZone=n.serverZone||oN,m.configServerUrl=n.configServerUrl,m.trackServerUrl=n.trackServerUrl,m.shouldInlineStylesheet=n.shouldInlineStylesheet,m.version=n.version,m.performanceConfig=n.performanceConfig||oF,m.storeType=null!=(r=n.storeType)?r:"memory",m.applyBackgroundColorToBlockedElements=null!=(i=n.applyBackgroundColorToBlockedElements)&&i,m.enableUrlChangePolling=null!=(o=n.enableUrlChangePolling)&&o,m.urlChangePollingInterval=null!=(s=n.urlChangePollingInterval)?s:1e3,m.captureDocumentTitle=null!=(a=n.captureDocumentTitle)&&a,void 0!==n.fullSnapshotIntervalMs&&(m.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),void 0!==n.eagerFullSnapshotSend&&(m.eagerFullSnapshotSend=n.eagerFullSnapshotSend),m.captureFullSnapshotOnFocus=null!=(u=n.captureFullSnapshotOnFocus)&&u,void 0!==n.maxPersistedEventsSizeBytes&&(m.maxPersistedEventsSizeBytes=st(n.maxPersistedEventsSizeBytes,o7,o9,"maxPersistedEventsSizeBytes",m.loggerProvider)),void 0!==n.maxSingleEventSizeBytes&&(m.maxSingleEventSizeBytes=st(n.maxSingleEventSizeBytes,o7,se,"maxSingleEventSizeBytes",m.loggerProvider)),m.privacyConfig=(0,Z.__assign)((0,Z.__assign)({},null!=(l=n.privacyConfig)?l:{}),{unmaskSelector:Array.from(new Set((0,Z.__spreadArray)([".".concat(oj)],(0,Z.__read)(null!=(d=null==(c=n.privacyConfig)?void 0:c.unmaskSelector)?d:[]),!1)))}),n.interactionConfig&&(m.interactionConfig=n.interactionConfig,m.interactionConfig.ugcFilterRules&&o2(m.interactionConfig.ugcFilterRules)),n.debugMode&&(m.debugMode=n.debugMode),m.useWebWorker=null==(h=null!=(f=n.useWebWorker)?f:null==(g=n.experimental)?void 0:g.useWebWorker)||h,m.enableTransportCompression=null==(p=n.enableTransportCompression)||p,m.sendTimeoutMs=n.sendTimeoutMs,m.captureAdoptedStyleSheets=null==(v=n.captureAdoptedStyleSheets)||v,n.crossOriginIframes&&(m.crossOriginIframes=n.crossOriginIframes),n.flushIntervalConfig?m.flushIntervalConfig=function(e,t){var n,r,i={};if(void 0!==e.minIntervalMs&&(!Number.isFinite(e.minIntervalMs)||e.minIntervalMs<100?(t.warn("flushIntervalConfig.minIntervalMs ".concat(e.minIntervalMs," is below floor ").concat(100,"ms; clamping.")),i.minIntervalMs=100):i.minIntervalMs=e.minIntervalMs),void 0!==e.maxIntervalMs&&(Number.isNaN(e.maxIntervalMs)||e.maxIntervalMs<100?(t.warn("flushIntervalConfig.maxIntervalMs ".concat(e.maxIntervalMs," is below floor ").concat(100,"ms; clamping.")),i.maxIntervalMs=100):i.maxIntervalMs=e.maxIntervalMs),void 0!==i.minIntervalMs||void 0!==i.maxIntervalMs){var o=null!=(n=i.minIntervalMs)?n:500,s=null!=(r=i.maxIntervalMs)?r:1e4;s<o&&(void 0===i.maxIntervalMs?(t.warn("flushIntervalConfig.minIntervalMs (".concat(o,") exceeds the default maxIntervalMs (").concat(1e4,"); raising max to match min.")),i.maxIntervalMs=o):void 0===i.minIntervalMs?(t.warn("flushIntervalConfig.maxIntervalMs (".concat(s,") is below the default minIntervalMs (").concat(500,"); lowering min to match max.")),i.minIntervalMs=s):(t.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}(n.flushIntervalConfig,m.loggerProvider):m.flushIntervalConfig={minIntervalMs:1e3,maxIntervalMs:1e4},m.handleSendEvents=n.handleSendEvents,m.handleFetchConfig=n.handleFetchConfig,m}return(0,Z.__extends)(t,e),t}(eW),o7=1e3,o9=8e6,se=1e7;function st(e,t,n,r,i){return Number.isFinite(e)?e<t?(i.warn("".concat(r," ").concat(e," is below floor ").concat(t,"; clamping.")),t):e>n?(i.warn("".concat(r," ").concat(e," exceeds ceiling ").concat(n,"; clamping.")),n):e:void i.warn("".concat(r," value is not a finite number (got ").concat(String(e),"); ignoring."))}var sn=((m=sn||{}
1)[m.DomContentLoaded=0]="DomContentLoaded",m[m.Load=1]="Load",m[m.FullSnapshot=2]="FullSnapshot",m[m.IncrementalSnapshot=3]="IncrementalSnapshot",m[m.Meta=4]="Meta",m[m.Custom=5]="Custom",m[m.Plugin=6]="Plugin",m),sr=((y=sr||{})[y.Mutation=0]="Mutation",y[y.MouseMove=1]="MouseMove",y[y.MouseInteraction=2]="MouseInteraction",y[y.Scroll=3]="Scroll",y[y.ViewportResize=4]="ViewportResize",y[y.Input=5]="Input",y[y.TouchMove=6]="TouchMove",y[y.MediaInteraction=7]="MediaInteraction",y[y.StyleSheetRule=8]="StyleSheetRule",y[y.CanvasMutation=9]="CanvasMutation",y[y.Font=10]="Font",y[y.Log=11]="Log",y[y.Drag=12]="Drag",y[y.StyleDeclaration=13]="StyleDeclaration",y[y.Selection=14]="Selection",y[y.AdoptedStyleSheet=15]="AdoptedStyleSheet",y[y.CustomElement=16]="CustomElement",y),si=((_=si||{})[_.MouseUp=0]="MouseUp",_[_.MouseDown=1]="MouseDown",_[_.Click=2]="Click",_[_.ContextMenu=3]="ContextMenu",_[_.DblClick=4]="DblClick",_[_.Focus=5]="Focus",_[_.Blur=6]="Blur",_[_.TouchStart=7]="TouchStart",_[_.TouchMove_Departed=8]="TouchMove_Departed",_[_.TouchEnd=9]="TouchEnd",_[_.TouchCancel=10]="TouchCancel",_),so=((b=so||{})[b.Mouse=0]="Mouse",b[b.Pen=1]="Pen",b[b.Touch=2]="Touch",b),ss=((S=ss||{})[S["2D"]=0]="2D",S[S.WebGL=1]="WebGL",S[S.WebGL2=2]="WebGL2",S),sa=((w=sa||{})[w.Play=0]="Play",w[w.Pause=1]="Pause",w[w.Seeked=2]="Seeked",w[w.VolumeChange=3]="VolumeChange",w[w.RateChange=4]="RateChange",w),su=((E=su||{}).Start="start",E.Pause="pause",E.Resume="resume",E.Resize="resize",E.Finish="finish",E.FullsnapshotRebuilded="fullsnapshot-rebuilded",E.LoadStylesheetStart="load-stylesheet-start",E.LoadStylesheetEnd="load-stylesheet-end",E.SkipStart="skip-start",E.SkipEnd="skip-end",E.MouseInteraction="mouse-interaction",E.EventCast="event-cast",E.CustomEvent="custom-event",E.Flush="flush",E.StateChange="state-change",E.PlayBack="play-back",E.Destroy="destroy",E.SeekStart="seek-start",E.SeekEnd="seek-end",E),sl=((k=sl||{})[k.Document=0]="Document",k[k.DocumentType=1]="DocumentType",k[k.Element=2]="Element",k[k.Text=3]="Text",k[k.CDATA=4]="CDATA",k[k.Comment=5]="Comment",k),sc=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),0!==(e=e.filter(function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})).length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e},sd=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,n,r,i,o,s;return(0,Z.__awaiter)(this,void 0,void 0,function(){var a,u,l,c,d,f,g,h,p,v,m,y,_,b,S,w,E,k=this;return(0,Z.__generator)(this,function(I){switch(I.label){case 0:(a=(0,Z.__assign)({},this.localConfig)).optOut=this.localConfig.optOut,a.captureEnabled=!0,I.label=1;case 1:return I.trys.push([1,3,,4]),[4,new Promise(function(e,t){k.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:1500},function(n,r){if(k.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(r,":"),JSON.stringify(n,null,2)),!n)return void t(Error("No remote config received"));var i,o=n.sr_sampling_config,s=n.sr_privacy_config,l=n.sr_targeting_config,c=null==(i=a.interactionConfig)?void 0:i.ugcFilterRules;a.interactionConfig=n.sr_interaction_config,a.interactionConfig&&c&&(a.interactionConfig.ugcFilterRules=c),a.loggingConfig=n.sr_logging_config,(o||s||l)&&(u={},o&&(u.sr_sampling_config=o),s&&(u.sr_privacy_config=s),l&&(u.sr_targeting_config=l)),e()})})];case 2:return I.sent(),[3,4];case 3:return l=I.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",l),a.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:void 0}];case 4:if(!u)return[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:u}];if(c=u.sr_sampling_config,d=u.sr_privacy_config,f=u.sr_targeting_config,c&&Object.keys(c).length>0?(Object.prototype.hasOwnProperty.call(c,"capture_enabled")?a.captureEnabled=c.capture_enabled:a.captureEnabled=!1,Object.prototype.hasOwnProperty.call(c,"sample_rate")&&(a.sampleRate=c.sample_rate),Object.prototype.hasOwnProperty.call(c,"min_session_duration_ms")&&(a.minSessionDurationMs=this.sanitizeMinSessionDurationMs(c.min_session_duration_ms))):(a.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){g=null!=(e=a.privacyConfig)?e:{},h={defaultMaskLevel:null!=(n=null!=(t=d.defaultMaskLevel)?t:g.defaultMaskLevel)?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:(0,Z.__spreadArray)([],(0,Z.__read)(new Set((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(null!=(r=g.maskAttributes)?r:[]),!1),(0,Z.__read)(null!=(i=d.maskAttributes)?i:[]),!1))),!1),urlMaskLevels:(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(null!=(o=d.urlMaskLevels)?o:[]),!1),(0,Z.__read)(null!=(s=g.urlMaskLevels)?s:[]),!1)},p=function(e){var t,n,r,i,o,s,a,u,l,c={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var d=(0,Z.__values)(null!=(a=e.blockSelector)?a:[]),f=d.next();!f.done;f=d.next()){var g=f.value;c[g]="block"}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}try{for(var h=(0,Z.__values)(null!=(u=e.maskSelector)?u:[]),p=h.next();!p.done;p=h.next()){var g=p.value;c[g]="mask"}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}try{for(var v=(0,Z.__values)(null!=(l=e.unmaskSelector)?l:[]),m=v.next();!m.done;m=v.next()){var g=m.value;c[g]="unmask"}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}return c},v=(0,Z.__assign)((0,Z.__assign)({},p(g)),p(d));try{for(y=(m=(0,Z.__values)(Object.entries(v))).next();!y.done;y=m.next())b=(_=(0,Z.__read)(y.value,2))[0],S=_[1],"mask"===S?h.maskSelector.push(b):"block"===S?h.blockSelector.push(b):"unmask"===S&&h.unmaskSelector.push(b)}catch(e){w={error:e}}finally{try{y&&!y.done&&(E=m.return)&&E.call(m)}finally{if(w)throw w.error}}a.privacyConfig=sc(h,this.localConfig.loggerProvider)}return f&&Object.keys(f).length>0&&(a.targetingConfig=f),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:o5(a)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:u}]}})})},e.prototype.sanitizeMinSessionDurationMs=function(e){return"number"==typeof e&&Number.isFinite(e)?e<0?void this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring.")):e>sf?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(sf,"ms ceiling; clamping.")),sf):e:void this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."))},e}(),sf=6e4;function sg(e,t){return t||("STAGING"===e?oW:"EU"===e?oz:oB)}function sh(e){if(e.type!==sn.IncrementalSnapshot)return!1;var t=e.data;return t.source===sr.Mutation&&!t.isAttachIframe}var sp=function(){function e(e,t,n,r,i){var o,s=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e.type,n=e.timestamp,r=e.delay,i=e.data;return null!=r?JSON.stringify({type:t,timestamp:n,delay:r,data:i}):JSON.stringify({type:t,timestamp:n,data:i})},this.addCompressedEventToManager=function(e,t){var n,r=new Blob([e]).size;r>(null!=(n=s.config.maxSingleEventSizeBytes)?n:9e6)?s.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(r/1024)," KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.")):s.eventsManager&&s.deviceId&&s.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:s.deviceId})},this.addCompressedEvent=function(e,t){if(s.worker)try{s.worker.postMessage({event:e,sessionId:t})}catch(n){"DataCloneError"===n.name?s.worker.postMessage(JSON.stringify({event:e,sessionId:t})):s.config.loggerProvider.warn("Unexpected error while posting message to worker:",n)}else{var n=s.compressEvent(e);s.addCompressedEventToManager(n,t)}},this.flushQueue=function(){var e;
1for(s.pendingQueue.length>0&&(e=s.taskQueue).push.apply(e,(0,Z.__spreadArray)([],(0,Z.__read)(s.mergeMutationTasks(s.pendingQueue.splice(0))),!1));s.taskQueue.length>0;){var t=s.taskQueue.shift();if(t){var n=t.event,r=t.sessionId,i=s.compressEvent(n);s.addCompressedEventToManager(i,r)}}s.isProcessing=!1},this.terminate=function(){var e;null==(e=s.worker)||e.terminate()};var a=(0,eA.getGlobalScope)();if(this.canUseIdleCallback=a&&"requestIdleCallback"in a,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null==(o=t.performanceConfig)?void 0:o.timeout)||2e3,this.onFullSnapshotProcessed=i,r){t.loggerProvider.log("Enabling web worker for compression");try{var u=new Blob([r],{type:"application/javascript"}),l=URL.createObjectURL(u),c=new Worker(l);c.onerror=function(e){e.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),c.terminate(),s.worker=void 0},c.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;s.addCompressedEventToManager(n,r)},this.worker=c}catch(e){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",e)}}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){if(e.type===sn.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var n,r,i,o,s=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(this.taskQueue.splice(0)),!1),(0,Z.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var a=(0,Z.__values)(s),u=a.next();!u.done;u=a.next()){var l=u.value,c=this.compressEvent(l.event);this.addCompressedEventToManager(c,l.sessionId)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,t),null==(i=this.onFullSnapshotProcessed)||i.call(this);return}this.canUseIdleCallback&&(null==(o=this.config.performanceConfig)?void 0:o.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){var t,n=this;for(this.pendingQueue.length>0&&(t=this.taskQueue).push.apply(t,(0,Z.__spreadArray)([],(0,Z.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var r=this.taskQueue.shift();if(r){var i=r.event,o=r.sessionId;this.addCompressedEvent(i,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(e){n.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e.prototype.mergeMutationTasks=function(e){if((null==(r=this.config.performanceConfig)?void 0:r.mergeMutations)===!1||e.length<=1)return e;for(var t,n,r,i=[],o=0;o<e.length;){for(var s=e[o].sessionId,a=o+1;a<e.length&&e[a].sessionId===s;)a++;var u=function(e){if(e.length<=1)return e;for(var t=[],n=0;n<e.length;){if(!sh(e[n])){t.push(e[n]),n++;continue}for(var r=n+1;r<e.length&&sh(e[r]);)r++;t.push(r>n+1?function(e){var t,n,r,i,o=e[0],s=new Map,a=new Map,u=new Map,l=new Map,c=new Map;e.forEach(function(e,t){var n,r,i,o,d=e.data;try{for(var f=(0,Z.__values)(d.adds),g=f.next();!g.done;g=f.next()){var h=g.value;s.has(h.node.id)||s.set(h.node.id,t),a.set(h.node.id,t),c.set(h.node.id,h.parentId)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}try{for(var p=(0,Z.__values)(d.removes),v=p.next();!v.done;v=p.next()){var m=v.value;u.has(m.id)||u.set(m.id,t),l.set(m.id,t)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}});var d=new Set,f=new Set;try{for(var g=(0,Z.__values)(s),h=g.next();!h.done;h=g.next()){var p=(0,Z.__read)(h.value,2),v=p[0],m=p[1],y=u.get(v);if(void 0!==y){var _=a.get(v),b=l.get(v);!(_>=b)&&(m<y?d.add(v):y<m&&f.add(v))}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}var S=new Set;if(d.size>0||f.size>0)for(var w=!0;w;){w=!1;try{for(var E=(r=void 0,(0,Z.__values)(c)),k=E.next();!k.done;k=E.next()){var I=(0,Z.__read)(k.value,2),T=I[0],C=I[1];if(!d.has(T)&&!f.has(T)&&!S.has(T)&&(d.has(C)||f.has(C)||S.has(C))){var P=u.get(T),x=s.get(T);void 0!==P&&void 0!==x&&P<x?f.add(T):void 0!==P&&void 0!==x&&P===x?S.add(T):d.add(T),w=!0}}}catch(e){r={error:e}}finally{try{k&&!k.done&&(i=E.return)&&i.call(E)}finally{if(r)throw r.error}}}var A=d.size>0||f.size>0||S.size>0,O=[];e.forEach(function(e,t){var n,r;try{for(var i=(0,Z.__values)(e.data.removes),o=i.next();!o.done;o=i.next()){var a=o.value;!(d.has(a.id)||f.has(a.id)&&t>=s.get(a.id))&&(S.has(a.id)&&(d.has(a.parentId)||f.has(a.parentId)||S.has(a.parentId))||O.push(a))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}});var R=e.flatMap(function(e){return e.data.adds}),M=e.flatMap(function(e){return e.data.texts}),D=e.flatMap(function(e){return e.data.attributes}),L=A?D.filter(function(e){return!d.has(e.id)&&!f.has(e.id)&&!S.has(e.id)}):D,N={source:sr.Mutation,removes:O,adds:A?R.filter(function(e){return!d.has(e.node.id)&&!f.has(e.node.id)&&!S.has(e.node.id)}):R,texts:A?M.filter(function(e){return!d.has(e.id)&&!f.has(e.id)&&!S.has(e.id)}):M,attributes:function(e){var t,n,r=new Map;if(e.forEach(function(e,t){if(e.attributes&&"style"in e.attributes){var n=r.get(e.id);n?n.push(t):r.set(e.id,[t])}}),0===r.size)return e;var i=function(t){return e[t].attributes.style},o=new Set,s=new Map;try{for(var a=(0,Z.__values)(r.values()),u=a.next();!u.done;u=a.next()){var l=u.value;!function(e){if(1!==e.length){var t=-1;e.forEach(function(e,n){var r;("object"!=typeof(r=i(e))||null===r)&&(t=n)});var n=[];if(e.forEach(function(e,r){r!==t&&(o.add(e),r>t&&n.push(e))}),n.length>0){var r=n[n.length-1],a=function(e){var t,n,r,i,o={};try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var u=a.value;try{for(var l=(r=void 0,(0,Z.__values)(Object.keys(u))),c=l.next();!c.done;c=l.next()){var d=c.value;o[d]=u[d]}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o}(n.map(function(e){return i(e)}));o.delete(r),s.set(r,a)}}}(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}if(0===o.size&&0===s.size)return e;var c=[];return e.forEach(function(e,t){var n=s.get(t);if(void 0!==n)return void c.push((0,Z.__assign)((0,Z.__assign)({},e),{attributes:(0,Z.__assign)((0,Z.__assign)({},e.attributes),{style:n})}));if(!o.has(t))return void c.push(e);var r=(0,Z.__assign)({},e.attributes);delete r.style,Object.keys(r).length>0&&c.push((0,Z.__assign)((0,Z.__assign)({},e),{attributes:r}))}),c}(L)};return(0,Z.__assign)((0,Z.__assign)({},o),{data:N})}(e.slice(n,r)):e[n]),n=r}return t}(e.slice(o,a).map(function(e){return e.event}));try{for(var l=(t=void 0,(0,Z.__values)(u)),c=l.next();!c.done;c=l.next()){var d=c.value;i.push({event:d,sessionId:s})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}o=a}return i},e}(),sv="Session replay event batch rejected due to exceeded retry count",sm="Failed to store session replay events in IndexedDB",sy="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",s_="1.48.1",sb=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher,i=e.workerScript,o=e.enableTransportCompression,s=e.sendTimeoutMs,a=e.handleSendEvents,u=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.timedOutWorkerRequests=new Map,this.flushPauseUntilMs=0,this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,this.mergeLogFiredThisPause=!1,this.killedSessions=new Set,this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t,this.enableTransportCompression=null==o||o,this.sendTimeoutMs=null!=s?s:1e4,this.handleSendEvents=a,i)try{var l=new Blob([i],{type:"application/javascript"}),c=URL.createObjectURL(l),d=new Worker(c);d.onerror=function(e){var t,r;e.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),d.terminate(),u.worker=void 0;try{for(var i=(0,Z.__values)(u.pendingWorkerRequests),o=i.next();!o.done;o=i.next()){var s=(0,Z.__read)(o.value,2)[1];s.timeout&&clearTimeout(s.timeout),n.warn("Session replay event send failed due to worker crash: ".concat(e.message)),s.resolve()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}u.pendingWorkerRequests.clear(),u.timedOutWorkerRequests.clear()},d.onmessage=function(e){var t=e.data;if("log"===t.type)n.log(t.message);else if("warn"===t.type)n.warn(t.message);else if("payload_too_large"===t.type){var r=u.pendingWorkerRequests.get(t.id);if(r)r.timeout&&clearTimeout(r.timeout),u.handlePayloadTooLargeResponse(r.context,t.isWaf),r.resolve(),u.pendingWorkerRequests.delete(t.id);else{var i=u.timedOutWorkerRequests.get(t.id);i&&(u.timedOutWorkerRequests.delete(t.id),u.handlePayloadTooLargeResponse(i,t.isWaf))}}else if("complete"===t.type){var o=u.pendingWorkerRequests.get(t.id);if(o)o.timeout&&clearTimeout(o.timeout),void 0!==t.skipCode&&u.applyServerDirective(o.context.sessionId,t.skipCode),u.completeRequest({context:o.context}),o.resolve(),u.pendingWorkerRequests.delete(t.id);else{var i=u.timedOutWorkerRequests.get(t.id);i&&(u.timedOutWorkerRequests.delete(t.id),void 0!==t.skipCode&&u.applyServerDirective(i.sessionId,t.skipCode),u.completeRequest({context:i}))}}else"fetch-request"===t.type&&u.handleDelegatedFetch(d,t).catch(function(e){n.warn("Failed to handle delegated session replay fetch:",e)})},this.worker=d}catch(e){n.error("Failed to create track destination worker, falling back to main-thread sending:",e)}}return e.prototype.sendEventsList=function(e){this.addToQueue((0,Z.__assign)((0,Z.__assign)({},e),{attempts:0,timeout:0}))},e.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},e.prototype.sendBeacon=function(e){var t,n,r=this,i=e.events,o=e.sessionId,s=e.deviceId,a=e.apiKey,u=e.serverZone,l=function(e){return new Blob([e]).size},c=i,d=JSON.stringify({version:2,events:c});if(l(d)>65536){for(var f=0,g=c.length;f<g;){var h=Math.floor((f+g+1)/2);65536>=l(JSON.stringify({version:2,events:c.slice(0,h)}))?f=h:g=h-1}d=JSON.stringify({version:2,events:c=c.slice(0,f)}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(i.length," to ").concat(c.length," events"))}if(0!==c.length){if(this.handleSendEvents){var p=new URLSearchParams({device_id:s,session_id:String(o),type:"replay"}),v="".concat(sg(u,this.trackServerUrl),"?").concat(p.toString());this.loggerProvider.debug("Routing session replay exit batch (".concat(c.length," events) through custom transport for session id ").concat(o,"."));try{this.handleSendEvents({url:v,method:"POST",headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(a)},body:d,keepalive:!0}
1).catch(function(e){r.loggerProvider.warn("Custom transport failed to send session replay exit batch:",e)})}catch(e){this.loggerProvider.warn("Custom transport threw while sending session replay exit batch:",e)}return}var m=new URLSearchParams({device_id:s,session_id:String(o),type:"replay",api_key:a}),y="".concat(sg(u,this.trackServerUrl),"?").concat(m.toString()),_=(0,eA.getGlobalScope)();try{var b=new Blob([d],{type:"application/json"}),S=null==(n=null==(t=null==_?void 0:_.navigator)?void 0:t.sendBeacon)?void 0:n.call(t,y,b);!1===S&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch(e){}}},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter(function(t){return e.killedSessions.has(t.sessionId)?(e.completeRequest({context:t,err:sy}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:sv}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),e.schedule(0)})},e.prototype.schedule=function(e){var t=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),r=n>e?n:e;n>0&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},r)}},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,t=this.mergeQueueAfterThrottle(t)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,t=this.mergeDrainBacklog(t)),a.label=1;case 1:a.trys.push([1,6,7,8]),r=(n=(0,Z.__values)(t)).next(),a.label=2;case 2:if(r.done)return[3,5];return i=r.value,[4,this.send(i,e)];case 3:a.sent(),a.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o={error:a.sent()},[3,8];case 7:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}return[7];case 8:return[2]}})})},e.prototype.mergeQueueAfterThrottle=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(t.length," request(s)"))),t},e.prototype.mergeDrainBacklog=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&this.loggerProvider.log("Session replay coalesced ".concat(e.length," persisted page-load backlog batches into ").concat(t.length," request(s)")),t},e.prototype.coalesceByIdentity=function(e){var t,n,r,i,o,s,a,u,l,c,d,f=this;if(e.length<=1)return e;var g=new Map;try{for(var h=(0,Z.__values)(e),p=h.next();!p.done;p=h.next()){var v=p.value,m=[v.sessionId,null!=(o=v.deviceId)?o:"",null!=(s=v.apiKey)?s:"",v.type,null!=(a=v.serverZone)?a:"",v.sampleRate,null!=(l=null==(u=v.version)?void 0:u.type)?l:"",null!=(d=null==(c=v.version)?void 0:c.version)?d:""].join("|"),y=g.get(m);y?y.push(v):g.set(m,[v])}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var _=[];try{for(var b=(0,Z.__values)(g.values()),S=b.next();!S.done;S=b.next()){var w=S.value;!function(e){if(1===e.length)return _.push(e[0]);var t,n,r=null,i=0,o=function(){r&&_.push(r),r=null,i=0};try{for(var s=(t=void 0,(0,Z.__values)(e)),a=s.next();!a.done;a=s.next()){var u=a.value;!function(e){var t=e.events.reduce(function(e,t){return e+new Blob([t]).size},0);if(null===r)return r=(0,Z.__assign)((0,Z.__assign)({},e),{events:(0,Z.__spreadArray)([],(0,Z.__read)(e.events),!1),attempts:0}),i=t;if(i+t>4e6)return o(),r=(0,Z.__assign)((0,Z.__assign)({},e),{events:(0,Z.__spreadArray)([],(0,Z.__read)(e.events),!1),attempts:0}),i=t;var n=r.onComplete,s=e.onComplete;r.events=r.events.concat(e.events),i+=t,r.onComplete=function(){return(0,Z.__awaiter)(f,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,Promise.allSettled([n(),s()])];case 1:return e.sent(),[2]}})})}}(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}o()}(w)}}catch(e){r={error:e}}finally{try{S&&!S.done&&(i=b.return)&&i.call(b)}finally{if(r)throw r.error}}return _},e.prototype.send=function(e,t){return void 0===t&&(t=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i,o;return(0,Z.__generator)(this,function(s){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:sy})]:(n=e.apiKey)?(r=e.deviceId)?0===(i=this.payloadBatcher({version:1,events:e.events})).events.length?(this.completeRequest({context:e}),[2]):(o=this.worker)?[2,this.sendViaWorker(o,e,i,t)]:[2,this.sendOnMainThread(n,r,e,i,t)]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})]})})},e.prototype.sendViaWorker=function(e,t,n,r){return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o=this;return(0,Z.__generator)(this,function(s){return i="".concat(++this.sendIdCounter),[2,new Promise(function(s){var a,u=o.sendTimeoutMs>0?setTimeout(function(){var e=o.pendingWorkerRequests.get(i);
1e&&(o.pendingWorkerRequests.delete(i),o.rememberTimedOutRequest(i,e.context),o.loggerProvider.warn("Session replay worker send timed out after ".concat(o.sendTimeoutMs,"ms; leaving events for retry")),e.resolve())},o.sendTimeoutMs):void 0;o.pendingWorkerRequests.set(i,{context:t,resolve:s,timeout:u}),e.postMessage({type:"send",id:i,payload:n,useRetry:r,useCustomTransport:!!o.handleSendEvents,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:null!=(a=t.flushMaxRetries)?a:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:oZ(),sdkVersion:s_,enableTransportCompression:o.enableTransportCompression,sendTimeoutMs:o.sendTimeoutMs}})})]})})},e.prototype.rememberTimedOutRequest=function(e,t){var n,r;if(this.timedOutWorkerRequests.set(e,t),this.timedOutWorkerRequests.size>256)try{for(var i=(0,Z.__values)(this.timedOutWorkerRequests.keys()),o=i.next();!o.done;o=i.next()){var s=o.value;this.timedOutWorkerRequests.delete(s);break}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.handleDelegatedFetch=function(e,t){var n,r,i;return(0,Z.__awaiter)(this,void 0,void 0,function(){var o,s,a,u,l,c,d,f,g,h,p;return(0,Z.__generator)(this,function(v){switch(v.label){case 0:o=t.requestId,s=t.url,a=t.method,u=t.headers,l=t.body,c=t.keepalive,v.label=1;case 1:if(v.trys.push([1,10,,11]),d=void 0,!this.handleSendEvents)return[3,3];return[4,this.handleSendEvents({url:s,method:a,headers:u,body:l,keepalive:c})];case 2:return d=v.sent(),[3,5];case 3:return this.loggerProvider.warn("Delegated session replay fetch received without a custom transport configured; falling back to built-in fetch."),[4,fetch(s,{method:a,headers:u,body:l,keepalive:c})];case 4:d=v.sent(),v.label=5;case 5:if(f=d.status,g=null,h="",f>=200&&f<300&&(g=null!=(i=null==(r=null==(n=d.headers)?void 0:n.get)?void 0:r.call(n,oH))?i:null),413!==f)return[3,9];v.label=6;case 6:return v.trys.push([6,8,,9]),[4,d.text()];case 7:return h=v.sent(),[3,9];case 8:return v.sent(),[3,9];case 9:return this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") returned status ").concat(f,".")),e.postMessage({type:"fetch-response",requestId:o,status:f,skipHeader:g,body:h}),[3,11];case 10:return p=v.sent(),this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") failed:"),p),e.postMessage({type:"fetch-response",requestId:o,status:0,skipHeader:null,body:String(p),error:!0}),[3,11];case 11:return[2]}})})},e.prototype.sendOnMainThread=function(e,t,n,r,i){var o,s,a,u,l,c,d;return(0,Z.__awaiter)(this,void 0,void 0,function(){var f,g,h,p,v,m,y,_,b,S,w,E,k,I,T,C,P,x,A,O,R,M;return(0,Z.__generator)(this,function(D){switch(D.label){case 0:f=oZ(),g=s_,h=n.sampleRate,p=new URLSearchParams({device_id:t,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),v="".concat(null!=(s=null==(o=n.version)?void 0:o.type)?s:"standalone","/").concat(null!=(u=null==(a=n.version)?void 0:a.version)?u:g),D.label=1;case 1:if(D.trys.push([1,19,,23]),m=JSON.stringify(r),y=(0,eA.getGlobalScope)(),!(this.enableTransportCompression&&y&&"CompressionStream"in y))return[3,3];return[4,function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,r,i,o,s,a,u,l,c,d,f,g,h=this;return(0,Z.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,4,,5]),r=(n=new t.CompressionStream("gzip")).writable.getWriter(),i=n.readable.getReader(),o=[],s=(0,Z.__awaiter)(h,void 0,void 0,function(){var e,t,n;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return[4,i.read()];case 1:if(t=(e=r.sent()).done,n=e.value,t)return[3,3];o.push(n),r.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,r.write(new TextEncoder().encode(e))];case 1:return p.sent(),[4,r.close()];case 2:return p.sent(),[4,s];case 3:p.sent(),a=new Uint8Array(o.reduce(function(e,t){return e+t.length},0)),u=0;try{for(c=(l=(0,Z.__values)(o)).next();!c.done;c=l.next())d=c.value,a.set(d,u),u+=d.length}catch(e){f={error:e}}finally{try{c&&!c.done&&(g=l.return)&&g.call(l)}finally{if(f)throw f.error}}return[2,a];case 4:return p.sent(),[2,null];case 5:return[2]}})})}(m,y)];case 2:return b=D.sent(),[3,4];case 3:b=null,D.label=4;case 4:if(S=(_=b)?_.byteLength:new Blob([m]).size,w=new AbortController,T={headers:E=(0,Z.__assign)({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":g,"X-Client-Library":v,"X-Client-Url":f.substring(0,1e3),"X-Client-Sample-Rate":"".concat(h),"X-Sampling-Hash-Alg":"xxhash32"},_?{"Content-Encoding":"gzip"}:{}),body:k=null!=_?_:m,method:"POST",keepalive:I=S<=65536,signal:w.signal},C="".concat(sg(n.serverZone,this.trackServerUrl),"?").concat(p.toString()),0===r.events.length)return this.completeRequest({context:n}),[2];P=this.sendTimeoutMs>0?setTimeout(function(){w.abort()},this.sendTimeoutMs):void 0,x=void 0,D.label=5;case 5:var L,N;if(D.trys.push([5,,10,11]),!this.handleSendEvents)return[3,7];return[4,(L=this.handleSendEvents({url:C,method:"POST",headers:E,body:k,keepalive:I}),N=w.signal,new Promise(function(e,t){var n=function(){var e=Error("Custom session replay transport aborted by send timeout");e.name="AbortError",t(e)};N.addEventListener("abort",n,{once:!0}),L.then(function(t){N.removeEventListener("abort",n),e(t)},function(e){N.removeEventListener("abort",n),t(e)})}))];case 6:return A=D.sent(),[3,9];case 7:return[4,fetch(C,T)];case 8:A=D.sent(),D.label=9;case 9:return x=A,[3,11];case 10:return P&&clearTimeout(P),[7];case 11:if(null===x)return this.completeRequest({context:n,err:"Unexpected error occurred"}),[2];if(x.status>=200&&x.status<300&&(O=null!=(d=null==(c=null==(l=x.headers)?void 0:l.get)?void 0:c.call(l,oH))?d:null,this.applyServerDirective(n.sessionId,O)),i)return[3,12];R="";try{R=JSON.stringify(x.body,null,2)}catch(e){}return this.completeRequest({context:n,success:"".concat(x.status,": ").concat(R)}),[3,18];
1case 12:if(R="",413!==x.status)return[3,16];D.label=13;case 13:return D.trys.push([13,15,,16]),[4,x.text()];case 14:return R=D.sent(),[3,16];case 15:return D.sent(),[3,16];case 16:return[4,this.handleReponse(x.status,n,R)];case 17:D.sent(),D.label=18;case 18:return[3,23];case 19:if(!((M=D.sent())&&"object"==typeof M&&"AbortError"===M.name&&i))return[3,21];return[4,this.handleOtherResponse(n)];case 20:return D.sent(),[3,22];case 21:this.completeRequest({context:n,err:M}),D.label=22;case 22:return[3,23];case 23:return[2]}})})},e.prototype.handleReponse=function(e,t,n){return void 0===n&&(n=""),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){switch(r.label){case 0:switch(new t0().buildStatus(e)){case M.Success:return[3,1];case M.Failed:case M.Timeout:case M.RateLimit:return[3,2];case M.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:case 6:return r.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,oG.test(n)),[3,8];case 5:if(499!==e)return[3,7];return[4,this.handleOtherResponse(t)];case 7:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),r.label=8;case 8:return[2]}})})},e.prototype.handlePayloadTooLargeResponse=function(e,t){var n=t?"WAF (compressed payload too large)":"server (event too large)",r=Math.round(e.events.reduce(function(e,t){return e+t.length},0)/1024);if(!t)return void this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(r," KB) — not retrying non-WAF 413")});if(1===e.events.length)return void this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(r," KB, 1 event) rejected by ").concat(n," — cannot split further")});this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(r," KB total) — splitting and retrying")),e.onComplete();var i=function(){return Promise.resolve()},o=Math.floor(e.events.length/2);this.sendEventsList((0,Z.__assign)((0,Z.__assign)({},e),{events:e.events.slice(0,o),onComplete:i})),this.sendEventsList((0,Z.__assign)((0,Z.__assign)({},e),{events:e.events.slice(o),onComplete:i}))},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0))return this.completeRequest({context:e,err:sv}),[2];return[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e.prototype.applyServerDirective=function(e,t){if(null===t){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if("429"===t){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+6e4,n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60,"s"));return}("4005"===t||"4004"===t)&&this.killSession(e,t)},e.prototype.killSession=function(e,t){if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>256)try{for(var n,r,i,o,s=(0,Z.__values)(this.killedSessions),a=s.next();!a.done;a=s.next()){var u=a.value;this.killedSessions.delete(u);break}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(t,"; remaining events will be dropped"));var l=[];try{for(var c=(0,Z.__values)(this.queue),d=c.next();!d.done;d=c.next()){var f=d.value;f.sessionId===e?this.completeRequest({context:f,err:sy}):l.push(f)}}catch(e){i={error:e}}
1finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}this.queue=l}},e}(),sS=e.i(10399),sw=function(){function e(e){var t,n,r,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=6e6,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>=i.maxPersistedEventsSize||Date.now()-i.timeAtLastSplit>i.interval&&!!e.length&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!=(t=e.minInterval)?t:this.minInterval,this.maxInterval=null!=(n=e.maxInterval)?n:this.maxInterval,this.maxPersistedEventsSize=null!=(r=e.maxPersistedEventsSize)?r:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<=127)t++;else if(r<=2047)t+=2;else if(r>=55296&&r<=56319){var i=n+1<e.length?e.charCodeAt(n+1):NaN;i>=56320&&i<=57343?(t+=4,n++):t+=3}else t+=3}return t},e.prototype.getEventsArraySize=function(e){var t,n,r=0;try{for(var i=(0,Z.__values)(e),o=i.next();!o.done;o=i.next()){var s=o.value;r+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}(),sE=function(e,t,n){"object"==typeof n&&null!==n&&"AbortError"===n.name?e.debug(t):e.warn(t)},sk="sessionCurrentSequence",sI="sequencesToSend";function sT(e,t,n){var r=setTimeout(n,t);return e.then(function(){return clearTimeout(r)},function(){return clearTimeout(r)}),function(){return clearTimeout(r)}}var sC=function(e){var t,n;return e.objectStoreNames.contains(sk)||(n=e.createObjectStore(sk,{keyPath:"sessionId"})),e.objectStoreNames.contains(sI)||(t=e.createObjectStore(sI,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},sP=function(e){function t(t){var n,r=this;return(r=e.call(this,t)||this).consecutiveFailures=0,r.hasTriggeredFallback=!1,r.emptyFilteredCount=0,r.getSequencesToSend=function(){return(0,Z.__awaiter)(r,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l,c=this;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:e=!1,t=!1,d.label=1;case 1:return d.trys.push([1,9,,10]),n=[],(r=this.db.transaction("sequencesToSend","readwrite")).done.catch(function(n){e||t||(sE(c.loggerProvider,"".concat(sm,": ").concat(n),n),c.recordFailure())}),i=sT(r.done,5e3,function(){e||t||(t=!0,sE(c.loggerProvider,"".concat(sm,": transaction timed out")),c.recordFailure())}),[4,r.store.openCursor()];case 2:o=d.sent(),d.label=3;case 3:if(!o)return[3,8];if(a=(s=o.value).sessionId,0!==(u=s.events).length)return[3,5];return this.maybeLogEmptyFiltered("getSequencesToSend"),[4,o.delete()];case 4:return d.sent(),[3,6];case 5:n.push({events:u,sequenceId:o.key,sessionId:a}),d.label=6;case 6:return[4,o.continue()];case 7:return o=d.sent(),[3,3];case 8:return this.recordSuccess(),i(),[2,n];case 9:return l=d.sent(),t||(e=!0,sE(this.loggerProvider,"".concat(sm,": ").concat(l),l),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},r.storeCurrentSequence=function(e){return(0,Z.__awaiter)(r,void 0,void 0,function(){var t,n,r,i,o,s,a,u,l=this;return(0,Z.__generator)(this,function(c){switch(c.label){case 0:t=!1,n=!1,c.label=1;case 1:return c.trys.push([1,5,,6]),(r=this.db.transaction([sk,sI],"readwrite")).done.catch(function(e){t||n||(sE(l.loggerProvider,"".concat(sm,": ").concat(e),e),l.recordFailure())}),i=sT(r.done,5e3,function(){t||n||(n=!0,sE(l.loggerProvider,"".concat(sm,": transaction timed out")),l.recordFailure())}),[4,r.objectStore(sk).get(e)];case 2:if(!(o=c.sent())||o.tabId&&o.tabId!==this.tabId)return i(),[2,void 0];if(0===o.events.length)return this.maybeLogEmptyFiltered("storeCurrentSequence"),i(),[2,void 0];return[4,r.objectStore(sI).put({sessionId:e,events:o.events,tabId:this.tabId})];case 3:return s=c.sent(),[4,r.objectStore(sk).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return c.sent(),this.recordSuccess(),i(),o.tabId,a=(0,Z.__rest)(o,["tabId"]),[2,(0,Z.__assign)((0,Z.__assign)({},a),{sessionId:e,sequenceId:s})];case 5:return u=c.sent(),n||(t=!0,sE(this.loggerProvider,"".concat(sm,": ").concat(u),u),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},r.addEventToCurrentSequence=function(e,t){return(0,Z.__awaiter)(r,void 0,void 0,function(){var n,r,i,o,s,a,u,l,c,d=this;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:n=!1,r=!1,f.label=1;case 1:return f.trys.push([1,15,,16]),(i=this.db.transaction([sk,sI],"readwrite")).done.catch(function(e){n||r||(sE(d.loggerProvider,"".concat(sm,": ").concat(e),e),d.recordFailure())}),o=sT(i.done,5e3,function(){n||r||(r=!0,sE(d.loggerProvider,"".concat(sm,": transaction timed out")),d.recordFailure())}),[4,i.objectStore(sk).get(e)];case 2:if(!((null==(s=f.sent())?void 0:s.tabId)&&s.tabId!==this.tabId))return[3,6];if(!(s.events.length>0))return[3,4];return[4,i.objectStore(sI).put({sessionId:e,events:s.events,tabId:s.tabId})];case 3:f.sent(),f.label=4;case 4:case 12:return[4,i.objectStore(sk).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:case 7:case 9:case 11:return f.sent(),this.recordSuccess(),o(),[2,void 0];case 6:if(a=s)return[3,8];return[4,i.objectStore(sk).put({sessionId:e,events:[t],tabId:this.tabId})];case 8:if(this.shouldSplitEventsList(a.events,t))return[3,10];return[4,i.objectStore(sk).put({sessionId:e,events:a.events.concat(t),tabId:this.tabId})];case 10:if(0!==(u=a.events).length)return[3,12];return this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,i.objectStore(sk).put({sessionId:e,events:[t],tabId:this.tabId})];case 13:return f.sent(),[4,i.objectStore(sI).put({sessionId:e,events:u,tabId:this.tabId})];case 14:return l=f.sent(),this.recordSuccess(),o(),[2,{events:u,sessionId:e,sequenceId:l}];case 15:return c=f.sent(),r||(n=!0,sE(this.loggerProvider,"".concat(sm,": ").concat(c),c),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},r.storeSendingEvents=function(e,t){return(0,Z.__awaiter)(r,void 0,void 0,function(){var n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.db.put(sI,{sessionId:e,events:t,tabId:this.tabId})];case 1:return n=i.sent(),this.recordSuccess(),[2,n];case 2:return r=i.sent(),sE(this.loggerProvider,"".concat(sm,": ").concat(r),r),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},r.cleanUpSessionEventsStore=function(e,t){return(0,Z.__awaiter)(r,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(sI,t)];case 2:return n.sent(),this.recordSuccess(),[3,4];case 3:return e=n.sent(),sE(this.loggerProvider,"".concat(sm,": ").concat(e),e),this.recordFailure(),[3,4];case 4:return[2]}})})},r.db=t.db,r.tabId=t.tabId,r.onPersistentFailure=t.onPersistentFailure,r.consecutiveFailureThreshold=null!=(n=t.consecutiveFailureThreshold)?n:1,r}return(0,Z.__extends)(t,e),t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (idb store)"))},t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,null==(e=this.onPersistentFailure)||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,n){var r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s,a;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:var l;return u.trys.push([0,2,,3]),i="replay"===e?"":"_".concat(e),[4,(l="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(i),(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:var t;return[4,(t=(0,sS.openDB)(l,1,{upgrade:sC}),new Promise(function(e,n){var r=setTimeout(function(){return n(Error("".concat("IDB openDB timed out"," after ").concat(2e3,"ms")))},2e3);t.then(function(t){clearTimeout(r),e(t)},function(e){clearTimeout(r),n(e)})}))];case 1:return[2,e.sent()]}})}))];case 1:return o=u.sent(),s=null!=(r=n.tabId)?r:function(){try{return crypto.randomUUID()}catch(e){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}(),[2,new t((0,Z.__assign)((0,Z.__assign)({},n),{db:o,tabId:s}
1))];case 2:return a=u.sent(),sE(n.loggerProvider,"".concat(sm,": ").concat(a),a),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s,a;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:if(!e)return[3,2];return[4,this.db.get("sessionCurrentSequence",e)];case 1:if(!(t=u.sent())||t.tabId&&t.tabId!==this.tabId)return[2,void 0];return t.tabId,[2,[n=(0,Z.__rest)(t,["tabId"])]];case 2:r=[],u.label=3;case 3:return u.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:o=(i=Z.__values.apply(void 0,[u.sent()])).next(),u.label=5;case 5:if(o.done)return[3,7];if((t=o.value).tabId&&t.tabId!==this.tabId)return[3,6];t.tabId,n=(0,Z.__rest)(t,["tabId"]),r.push(n),u.label=6;case 6:return o=i.next(),[3,5];case 7:return[3,10];case 8:return s={error:u.sent()},[3,10];case 9:try{o&&!o.done&&(a=i.return)&&a.call(i)}finally{if(s)throw s.error}return[7];case 10:return[2,r]}})})},t}(sw),sx=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t.emptyFilteredCount=0,t}return(0,Z.__extends)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,n=(0,Z.__spreadArray)([],(0,Z.__read)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (in-memory store)"))},t.prototype.getSequencesToSend=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l;return(0,Z.__generator)(this,function(c){e=[];try{for(n=(t=(0,Z.__values)(Object.entries(this.finalizedSequences))).next();!n.done;n=t.next()){if(i=(r=(0,Z.__read)(n.value,2))[0],s=(o=r[1]).sessionId,a=o.events,0===a.length){this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(i)];continue}e.push({sequenceId:Number(i),sessionId:s,events:a})}}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[2,e]})})},t.prototype.storeCurrentSequence=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){return(t=this.sequences[e])?0===t.length?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var n;return(0,Z.__generator)(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(0===this.sequences[e].length?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},t.prototype.storeSendingEvents=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(sw),sA=function(e){var t=e.config,n=e.minInterval,r=e.maxInterval,i=e.maxPersistedEventsSize,o=e.type,s=e.payloadBatcher,a=e.storeType,u=e.trackDestinationWorkerScript,l=e.shouldSend;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,c,d,f,g,h,p,v,m,y,_,b;function S(e){return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,c.flush(e)]})})}return(0,Z.__generator)(this,function(w){switch(w.label){case 0:if(e=null!=(b=t.maxSingleEventSizeBytes)?b:9e6,c=new sb((0,Z.__assign)((0,Z.__assign)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:s,workerScript:u})),d=function(){return new sx({loggerProvider:t.loggerProvider,maxInterval:r,minInterval:n,maxPer
1sistedEventsSize:i})},g=!1,"idb"!==a)return[3,2];return[4,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:return[4,sP.new(o,{loggerProvider:t.loggerProvider,minInterval:n,maxInterval:r,maxPersistedEventsSize:i,apiKey:t.apiKey,onPersistentFailure:function(){(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,n,r;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!g)return[2];if(g=!1,t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),!f)return[3,2];return[4,h.getSequencesToSend()];case 1:return n=i.sent(),[3,3];case 2:n=void 0,i.label=3;case 3:return e=n,h=d(),e&&f&&(r=f,e.forEach(function(e){_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})),[2]}})})}})];case 1:if(!(e=s.sent()))return t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,d()];return g=!0,[2,e]}})})];case 1:return p=w.sent(),[3,3];case 2:p=d(),w.label=3;case 3:return h=p,v=[],m=0,y=function(e){if(!(e<=m)){var t=Math.min(e-m,v.length);t>0&&(v.splice(0,t),m=e)}},_=function(n){var r=n.events,i=n.sessionId,s=n.deviceId,a=n.sequenceId,u=r.map(function(e){return{event:e,bytes:new Blob([e]).size}}),l=u.filter(function(t){return t.bytes>e});l.length>0&&t.loggerProvider.warn("Dropping ".concat(l.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(l.map(function(e){return"".concat(Math.round(e.bytes/1024)," KB")}).join(", "),". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));var d=l.length>0?u.filter(function(t){return t.bytes<=e}).map(function(e){return e.event}):r;0===d.length?h.cleanUpSessionEventsStore(i,a).catch(function(e){t.loggerProvider.warn("Failed to clean up session replay events store:",e)}):(t.debugMode&&o4().then(function(e){var n=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(i))}).catch(function(){}),c.sendEventsList({events:d,sessionId:i,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:o,onComplete:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,h.cleanUpSessionEventsStore(i,a)];case 1:return e.sent(),[2]}})})}}))},[2,{sendCurrentSequenceEvents:function(e){var n=e.sessionId,r=e.deviceId;if(f=r,!l||l()){var i=m+v.length;h.storeCurrentSequence(n).then(function(e){e&&(y(i),_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r}))}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})}},addEvent:function(e){var n=e.event,r=e.sessionId,i=e.deviceId;f=i;var o=!l||l(),s=m+v.length;v.push(n.data),h.addEventToCurrentSequence(r,n.data).then(function(e){if(e){if(!o){h.cleanUpSessionEventsStore(e.sessionId,e.sequenceId).catch(function(e){t.loggerProvider.warn("Failed to clean up dropped session replay sequence:",e)}),y(s);return}y(s),_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})}}).catch(function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)})},sendStoredEvents:function(e){var n=e.deviceId;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return f=n,[4,h.getSequencesToSend()];case 1:if(!(null==(e=r.sent())?void 0:e.length))return[2];return t.loggerProvider.log("Draining ".concat(e.length," stored sequence(s) from previous session.")),e.length>1&&c.markCoalesceNextFlush(),e.forEach(function(e){_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n})}),[2]}})})},flush:S,getBeaconEvents:function(){return(0,Z.__spreadArray)([],(0,Z.__read)(v),!1)},dropPendingBeaconEvents:function(){y(m+v.length)},trackDestination:c}]}})})},sO=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach(function(e){n.set(e.name,e.manager)}),this.managers=n}return e.prototype.sendStoredEvents=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEac
1h(function(n){t.push(n.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,i=e.deviceId;null==(t=this.managers.get(r.type))||t.addEvent({sessionId:n,event:r,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},e.prototype.flush=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e}();function sR(e,t,n){for(var r=null,i=[],o=e,s=0;o&&"break"!==function(){var e,a,u,l,c=new Date().getTime()-J.getTime();if(void 0!==V.timeoutMs&&c>V.timeoutMs)throw Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var d=sj((e=o.getAttribute("id"))&&V.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null)||sj.apply(void 0,(0,Z.__spreadArray)([],(0,Z.__read)(Array.from(o.attributes).filter(function(e){return V.attr(e.name,e.value)}).map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})),!1))||sj.apply(void 0,(0,Z.__spreadArray)([],(0,Z.__read)(Array.from(o.classList).filter(V.className).map(function(e){return{name:"."+CSS.escape(e),penalty:1}})),!1))||sj((a=o.tagName.toLowerCase(),V.tagName(a)?{name:a,penalty:2}:null))||[sF()],f=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;for(var r=0;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(o);if("all"==t)f&&(d=d.concat(d.filter(sU).map(function(e){return sq(e,f)})));else if("two"==t)d=d.slice(0,1),f&&(d=d.concat(d.filter(sU).map(function(e){return sq(e,f)})));else if("one"==t){var g=(0,Z.__read)(d=d.slice(0,1),1)[0];f&&sU(g)&&(d=[sq(g,f)])}else"none"==t&&(d=[sF()],f&&(d=[sq(d[0],f)]));try{for(var h=(u=void 0,(0,Z.__values)(d)),p=h.next();!p.done;p=h.next()){var g=p.value;g.level=s}}catch(e){u={error:e}}finally{try{p&&!p.done&&(l=h.return)&&l.call(h)}finally{if(u)throw u.error}}if(i.push(d),i.length>=V.seedMinLength&&(r=sM(i,n)))return"break";o=o.parentElement,s++}(););return(r||(r=sM(i,n)),!r&&n)?n():r}function sM(e,t){var n,r,i=sz(function e(t,n){var r,i,o,s,a;return void 0===n&&(n=[]),(0,Z.__generator)(this,function(u){switch(u.label){case 0:if(!(t.length>0))return[3,9];u.label=1;case 1:u.trys.push([1,6,7,8]),i=(r=(0,Z.__values)(t[0])).next(),u.label=2;case 2:if(i.done)return[3,5];return o=i.value,[5,(0,Z.__values)(e(t.slice(1,t.length),n.concat(o)))];case 3:u.sent(),u.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return s={error:u.sent()},[3,8];case 7:try{i&&!i.done&&(a=r.return)&&a.call(r)}finally{if(s)throw s.error}return[7];case 8:return[3,11];case 9:return[4,n];case 10:u.sent(),u.label=11;case 11:return[2]}})}(e));if(i.length>V.threshold)return t?t():null;try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value;if(sN(a))return a}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null}function sD(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var i=e[r].level||0;n=t.level===i-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function sL(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function sN(e){var t=sD(e);switch($.querySelectorAll(t).length){case 0:throw Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function sF(){return{name:"*",penalty:3}}function sq(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function sU(e){return"html"!==e.name&&!e.name.startsWith("#")}function sj(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(sB);return n.length>0?n:null}function sB(e){return null!=e}function sz(e){return(0,Z.__spreadArray)([],(0,Z.__read)(e),!1).sort(function(e,t){return sL(e)-sL(t)})}var sW=function(e){var t=e.version,n=e.events,r=[];
1return n.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)}),{version:t,events:r}},sG=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)}),{version:t,events:Object.values(r.reduce(function(e,t){var n=t.x,r=t.y,i=t.selector,o=t.timestamp,s=o-o%36e5,a="".concat(n,":").concat(r,":").concat(null!=i?i:"",":").concat(s);return e[a]?e[a].count+=1:e[a]=(0,Z.__assign)((0,Z.__assign)({},t),{timestamp:s,count:1}),e},{}))}},sH=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,o=e.mirror,s=e.ugcFilterRules,a=e.performanceOptions;return function(e){if(e.type!==si.Click)return;var u,l=(0,eA.getGlobalScope)();if(l){var c=l.location,d=l.innerHeight,f=l.innerWidth;if(c){var g=e.x,h=e.y;if(void 0!==g&&void 0!==h){var p=o.getNode(e.id);if(p)try{u=function(e,t){if(J=new Date,e.nodeType!==Node.ELEMENT_NODE)throw Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n,r,i={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};n=(V=(0,Z.__assign)((0,Z.__assign)({},i),t)).root,r=i,$=n.nodeType===Node.DOCUMENT_NODE?n:n===r.root?n.ownerDocument:n;var o=sR(e,"all",function(){return sR(e,"two",function(){return sR(e,"one",function(){return sR(e,"none")})})});if(o){var s=sz(function e(t,n,r){var i,o,s;return void 0===r&&(r={counter:0,visited:new Map}),(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(!(t.length>2&&t.length>V.optimizedMinLength))return[3,5];i=1,a.label=1;case 1:var u,l;if(!(i<t.length-1))return[3,5];if(r.counter>V.maxNumberOfTries||(r.counter+=1,(o=(0,Z.__spreadArray)([],(0,Z.__read)(t),!1)).splice(i,1),s=sD(o),r.visited.has(s)))return[2];if(!(sN(o)&&(u=o,l=n,$.querySelector(sD(u))===l)))return[3,4];return[4,o];case 2:return a.sent(),r.visited.set(s,!0),[5,(0,Z.__values)(e(o,n,r))];case 3:a.sent(),a.label=4;case 4:return i++,[3,1];case 5:return[2]}})}(o,e));return s.length>0&&(o=s[0]),sD(o)}throw Error("Selector was not found.")}(p,a)}catch(e){n.logger.debug("error resolving selector from finder")}var v=o3(c.href,s),m={x:g+n.scrollWatcher.currentScrollX,y:h+n.scrollWatcher.currentScrollY,selector:u,viewportHeight:d,viewportWidth:f,pageUrl:v,timestamp:Date.now(),type:"click"},y=i();y&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(m)},deviceId:y})}}}}},this.logger=e,this.scrollWatcher=t};function sK(){var e=(0,eA.getGlobalScope)();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function sV(){var e=(0,eA.getGlobalScope)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var s$=function(){function e(e,t){var n=(0,eA.getGlobalScope)();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=sg(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e,this.handleSendEvents=t.handleSendEvents,this.loggerProvider=t.loggerProvider}return e.prototype.send=function(e,t){var n,r=this,i=this.context,o=i.sessionId,s=i.type;if(this.handleSendEvents){var a=new URLSearchParams({device_id:e,session_id:String(o),type:String(s)}),u="".concat(this.basePageUrl,"?").concat(a.toString()),l={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(this.apiKey)};try{this.handleSendEvents({url:u,method:"POST",headers:l,body:JSON.stringify(t),keepalive:!0}).catch(function(e){var t;null==(t=r.loggerProvider)||t.warn("Custom transport failed to send session replay interaction beacon:",e)})}catch(e){null==(n=this.loggerProvider)||n.warn("Custom transport threw while sending session replay interaction beacon:",e)}return}var c=new URLSearchParams({device_id:e,session_id:String(o),type:String(s),api_key:this.apiKey}),d="".concat(this.basePageUrl,"?").concat(c.toString());this.sendBeacon(d,t)||this.sendXhr(d,t)},e}(),sJ=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,i,o,s,a=e(),u=(0,eA.getGlobalScope)();if(u&&a){var l=null!=(r=u.scrollX)?r:0,c=null!=(i=u.scrollY)?i:0;(l>0||c>0)&&n.update({id:1,x:l,y:c}),n.transport.send(a,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHe
1ight:sK(),viewportWidth:sV(),pageUrl:o3(u.location.href,null!=(s=null==(o=n.config.interactionConfig)?void 0:o.ugcFilterRules)?s:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=sV(),this._maxScrollHeight=sK(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new s$(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=sV();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=sK();this._maxScrollY=e.y;var o=e.y+i;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},e}(),sY=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId="".concat(n,"/").concat(t))},sQ=function(e){return"".concat("AMP_SR_START_").concat(e.substring(0,10),"_")},sX=function(e,t){return"".concat(sQ(e)).concat(t)},sZ=function(){try{var e=(0,eA.getGlobalScope)();return null==e?void 0:e.localStorage}catch(e){return}},s0=function(e,t,n,r){var i=sZ();if(i){var o=sX(e,t);try{var s=i.getItem(o);if(null!==s){var a=Number(s);if(Number.isFinite(a)&&a>0&&a<=n&&n-a<864e5)return a}return i.setItem(o,String(n)),n}catch(e){null==r||r.debug("Failed to read/write replay start time from storage: ".concat(String(e)));return}}},s1=function(e,t,n,r){var i=sZ();if(i)try{i.setItem(sX(e,t),String(n))}catch(e){null==r||r.debug("Failed to write replay start time to storage: ".concat(String(e)))}},s2=function(e,t,n){var r=sZ();if(r)try{r.removeItem(sX(e,t))}catch(e){null==n||n.debug("Failed to remove replay start time from storage: ".concat(String(e)))}},s3=function(e,t,n){var r,i,o=sZ();if(o){var s=sQ(e);try{for(var a=[],u=0;u<o.length;u++){var l=o.key(u);if(l&&l.startsWith(s)){var c=o.getItem(l);if(null!==c){var d=Number(c);(!Number.isFinite(d)||d<=0||t-d>=864e5)&&a.push(l)}}}try{for(var f=(0,Z.__values)(a),g=f.next();!g.done;g=f.next()){var l=g.value;o.removeItem(l)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}}catch(e){null==n||n.debug("Failed to prune stale replay start times: ".concat(String(e)))}}},s4=new function(){var e=this;this.dbs={},this.createStore=function(t){return(0,Z.__awaiter)(e,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,(0,sS.openDB)(t,1,{upgrade:function(e){e.objectStoreNames.contains("sessionTargetingMatch")||e.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,n;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(this.dbs&&this.dbs[t])return[2,this.dbs[t]];return e="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(e)];case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(o=a.sent())?void 0:o.targetingMatch];case 3:return s=a.sent(),sE(n,"Failed to get targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,o=t.targetingMatch;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.put("sessionTargetingMatch",{targetingMatch:o,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,a.sent()];case 3:return s=a.sent(),sE(n,"Failed to store targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,o,s,a,u,l,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=d.sent(),t=String(i),[4,(o=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:s=d.sent(),a=0,d.label=3;case 3:if(!(a<s.length))return[3,6];if(u=s[a],l=Date.now()-u.lastUpdated,!(u.sessionId!==t&&l>1728e5))return[3,5];return[4,o.store.delete(u.sessionId)];case 4:d.sent(),d.label=5;case 5:return a++,[3,3];case 6:return[4,o.done];case 7:return d.sent(),[3,9];case 8:return c=d.sent(),sE(n,"Failed to clear old targeting matches for sessions: ".concat(c),c),[3,9];case 9:return[2]}})})}},s5=function(t){var n=t.sessionId,r=t.targetingConfig,i=t.loggerProvider,o=t.apiKey,s=t.targetingParams,a=t.urlChange,u=void 0!==a&&a;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,a,l;return(0,Z.__generator)(this,function(c){switch(c.label){case 0:return[4,s4.clearStoreOfOldSessions({loggerProvider:i,apiKey:o,currentSessionId:n})];case 1:return c.sent(),[4,s4.getTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:n})];case 2:if(!0===c.sent()&&!u)return[2,!0];t=!0,c.label=3;case 3:return c.trys.push([3,6,,7]),[4,e.A(26160)];case 4:return[4,(0,c.sent().evaluateTargeting)((0,Z.__assign)((0,Z.__assign)({},s),{flag:r,sessionId:"string"==typeof n?parseInt(n,10):n,apiKey:o,loggerProvider:i}))];case 5:return(a=c.sent())&&a.sr_targeting_config&&(t="on"===a.sr_targeting_config.key),s4.storeTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:n,targetingMatch:t}),[3,7];case 6:return l=c.sent(),i.warn(l.message),[3,7];case 7:return[2,t]}})})};function s6(e,t){return(e<<t|e>>>32-t)>>>0}function s8(e,t){return Math.imul(e=s6(e=e+Math.imul(t,0x85ebca77)>>>0,13),0x9e3779b1)>>>0}function s7(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}var s9="__amplitude_url_tracking_patched__",ae=new WeakMap;function at(e,t,n){if(void 0===n&&(n={}),!(null==e?void 0:e.location))return function(){};var r=n.enablePolling,i=n.pollingInterval;if(void 0!==r&&r){var o=function(){var t;return null!=(t=e.location.href)?t:""},s=o(),a=e.setInterval(function(){var e=o();e!==s&&(s=e,t(e))},void 0===i?1e3:i);return function(){null!=a&&e.clearInterval(a)}}var u=ae.get(e);if(!u){var l=void 0,c=new Set,d=function(){var t;return null!=(t=e.location.href)?t:""},f=function(){var e=d();
1(void 0===l||e!==l)&&(l=e,c.forEach(function(t){return t(e)}))},g=function(e){var t=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=e.apply(this,t);return f(),r};return t[s9]=!0,t},h=e.history;if(null==h?void 0:h.pushState){var p=Reflect.get(h,"pushState");p[s9]||(h.pushState=g(p))}if(null==h?void 0:h.replaceState){var v=Reflect.get(h,"replaceState");v[s9]||(h.replaceState=g(v))}u={callbacks:c,notify:f,onPopStateOrHashChange:function(){return f()},listenersAttached:!1},ae.set(e,u)}var m=u;return m.listenersAttached||(e.addEventListener("popstate",m.onPopStateOrHashChange),e.addEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!0),m.callbacks.add(t),function(){m.callbacks.delete(t),0===m.callbacks.size&&m.listenersAttached&&(e.removeEventListener("popstate",m.onPopStateOrHashChange),e.removeEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!1)}}function an(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,n,r){var i,o,s,a=(0,Z.__assign)((0,Z.__assign)({},e),r),u=a.ugcFilterRules||[],l=null!=(i=a.enablePolling)&&i,c=null!=(o=a.pollingInterval)?o:1e3,d=null!=(s=a.captureDocumentTitle)&&s;if(!n)return function(){};var f=void 0,g=function(){return n.location&&n.location.href||""},h=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=g(),o="";return d&&(o=(null==r?void 0:r.title)||""),{href:u.length>0?o3(i,u):i,title:o,viewportHeight:e,viewportWidth:t,type:"url-change-event"}},p=function(){var e=g();(void 0===f||e!==f)&&(f=e,t(h()))},v=at(n,function(){return p()},l?{enablePolling:!0,pollingInterval:c}:{});return p(),function(){return v()}},options:e}}an();var ar=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e,t=this;null==(e=this.mutationObserver)||e.disconnect(),(0,eA.getGlobalScope)()&&(this.sendToAllIframes({type:oK,action:"start"}),this.mutationObserver=new MutationObserver(function(e){var n,r,i,o,s,a;try{for(var u=(0,Z.__values)(e),l=u.next();!l.done;l=u.next()){var c=l.value;try{for(var d=(i=void 0,(0,Z.__values)(Array.from(c.addedNodes))),f=d.next();!f.done;f=d.next()){var g=f.value;g instanceof HTMLIFrameElement?t.sendToIframeAfterLoad(g):g instanceof Element&&g.querySelectorAll("iframe").forEach(function(e){t.sendToIframeAfterLoad(e)})}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}try{for(var h=(s=void 0,(0,Z.__values)(Array.from(c.removedNodes))),p=h.next();!p.done;p=h.next()){var g=p.value;if(g instanceof HTMLIFrameElement){var v=t.pendingLoadListeners.get(g);v&&(g.removeEventListener("load",v),t.pendingLoadListeners.delete(g))}}}catch(e){s={error:e}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(s)throw s.error}}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},e.prototype.stop=function(){var e;null==(e=this.mutationObserver)||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener("load",e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:oK,action:"stop"})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:oK,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},e.prototype.sendToAllIframes=function(e){var t=this;document.querySelectorAll("iframe").forEach(function(n){return t.sendToIframe(n,e)})},e.prototype.sendToIframe=function(e,t){var n;try{null==(n=e.contentWindow)||n.postMessage(t,"*")}catch(e){}},e}(),ai=function(){function t(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeC
1oordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=(0,eA.getGlobalScope)();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),t||n.addEventListener("blur",e.blurListener),t||n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),t||n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),t||n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){var t;if(e.recordCancelCallback&&e.recordFunction){if((null==(t=e.config)?void 0:t.captureFullSnapshotOnFocus)===!1)return;try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn("Failed to take full snapshot on focus:",t)}}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var n;null==(n=e.eventCompressor)||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,r,i){return void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),(0,Z.__awaiter)(e,void 0,void 0,function(){var e,o,s,a,u,l,c,d,f,g,h,p;return(0,Z.__generator)(this,function(v){switch(v.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig)if(!n)return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];else this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");if(this.lastTargetingParams=t,!((e=this.config.targetingConfig)&&!this.sessionTargetingMatch))return[3,2];return o=i?this.latestUrlChangeTargetingEvaluationId:void 0,(s=t.event)&&Object.values(O).includes(s.event_type)&&(s=void 0),a=null!=(h=null!=(d=null==(c=t.page)?void 0:c.url)?d:null==(g=null==(f=(0,eA.getGlobalScope)())?void 0:f.location)?void 0:g.href)?h:"",u=null!=(p=t.page)?p:""!==a?{url:a}:void 0,[4,s5({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:s,page:u},urlChange:i})];case 1:if(l=v.sent(),i&&void 0!==o&&o!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(o,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||l,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:s,targetingParams:t},null,2)),v.label=2;case 2:if(!n)return[3,3];return this.initialize(!0),[3,5];case 3:if(!(r||!this.recordCancelCallback))return[3,5];return this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()];case 4:v.sent(),v.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,r){return void 0===n&&(n={}),void 0===r&&(r=!0),(0,Z.__awaiter)(e,void 0,void 0,function(){var e,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(a.trys.push([0,3,,4]),e=void 0,!((i=this.config)&&t!==K.METADATA)||(e={config:o5(i),version:s_},!r))return[3,2];return[4,o4()];case 1:o=a.sent(),e=(0,Z.__assign)((0,Z.__assign)({},o),e),a.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,Z.__assign)((0,Z.__assign)({},n),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return s=a.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",s),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t,n,r;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null==(t=e.networkObservers)||t.stop(),null==(n=e.crossOriginIframeC
1oordinator)||n.stop(),e.crossOriginIframeCoordinator=null,null==(r=e.crossOriginParentSignalCleanup)||r.call(e),e.crossOriginParentSignalCleanup=null}catch(t){e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new oV(new eB)}return t.prototype.init=function(e,t){return eF(this._init(e,t))},t.prototype.setupUrlChangeListener=function(){var e,t,n=this;null==(e=this.urlChangeCleanup)||e.call(this);var r=(0,eA.getGlobalScope)();if(null==r?void 0:r.location){var i=!!(null==(t=this.config)?void 0:t.targetingConfig),o=at(r,function(e){if(n.currentPageUrl=e,i){var t=++n.latestUrlChangeTargetingEvaluationId;n.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:e}},!1,!1,!0),n.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(t," for ").concat(e,"."))}});this.urlChangeCleanup=function(){o(),n.urlChangeCleanup=null}}},t.prototype.isBelowMinSessionDuration=function(){var e,t=null==(e=this.config)?void 0:e.minSessionDurationMs;return void 0!==t&&void 0!==this.sessionStartTime&&Date.now()-this.sessionStartTime<t},t.prototype.getCurrentPageForTargeting=function(){var e,t,n=null==(t=null==(e=(0,eA.getGlobalScope)())?void 0:e.location)?void 0:t.href;return null!=n?{url:n}:void 0},t.prototype._init=function(t,n){var r,i,o,s,a,u,l,c,d,f,g,h,p,v;return(0,Z.__awaiter)(this,void 0,void 0,function(){var m,y,_,b,S,w,E,k,I,T,C,P,x,A,O,R,M,D,L,N,F,q,U,j,B,z,W,G,H,K=this;return(0,Z.__generator)(this,function(V){switch(V.label){case 0:return null==(r=this.urlChangeCleanup)||r.call(this),this.loggerProvider=new oV(n.loggerProvider||new eB),Object.prototype.hasOwnProperty.call(n,"logLevel")&&this.loggerProvider.enable(n.logLevel),this.currentPageUrl=oZ(),this.identifiers=new sY({sessionId:n.sessionId,deviceId:n.deviceId}),s3(t,m=Date.now(),this.loggerProvider),this.sessionStartTime=void 0!==n.sessionId&&null!=(i=s0(t,n.sessionId,m,this.loggerProvider))?i:m,y=this,[4,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(r){return e=new o8(t,n),[2,new sd(new to(t,e.loggerProvider,e.serverZone,n.configServerUrl,n.handleFetchConfig),e)]})})];case 1:return y.joinedConfigGenerator=V.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:if(b=(_=V.sent()).joinedConfig,S=_.localConfig,w=_.remoteConfig,this.config=b,this.setMetadata(n.sessionId,b,S,w,null==(o=n.version)?void 0:o.version,s_,null==(s=n.version)?void 0:s.type),this.pageLeaveFns=[],n.sessionId&&(null==(a=this.config.interactionConfig)?void 0:a.enabled)&&(E=sJ.default({sessionId:n.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[E.send(this.getDeviceId.bind(this)).bind(E)],this.scrollHook=E.hook.bind(E),this.clickHandler=new sH(this.loggerProvider,E)),k=[],"idb"!==(I=this.config.storeType)||(null==(u=(0,eA.getGlobalScope)())?void 0:u.indexedDB)||(I="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(I," for event storage.")),P=(0,eA.getGlobalScope)(),!(this.config.useWebWorker&&P&&P.Worker))return[3,4];return[4,e.A(81696)];case 3:A=(x=V.sent()).compressionScript,O=x.trackDestinationScript,T=A,C=O,V.label=4;case 4:return V.trys.push([4,6,,7]),[4,sA({config:this.config,type:"replay",minInterval:null==(l=this.config.flushIntervalConfig)?void 0:l.minIntervalMs,maxInterval:null==(c=this.config.flushIntervalConfig)?void 0:c.maxIntervalMs,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:I,trackDestinationWorkerScript:C,shouldSend:function(){return!K.isBelowMinSessionDuration()}})];case 5:return R=V.sent(),this.rrwebEventManager=R,k.push({name:"replay",manager:R}),[3,7];case 6:return M=V.sent(),this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(M.toString())),[3,7];case 7:if(!(null==(d=this.config.interactionConfig)?void 0:d.enabled))return[3,11];D=this.config.interactionConfig.batch?sG:sW,V.label=8;case 8:return V.trys.push([8,10,,11]),[4,sA({config:this.config,type:"interaction",minInterval:null!=(f=this.config.interactionConfig.trackEveryNms)?f:3e4,maxInterval:6e4,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:D,storeType:I,trackDestinationWorkerScript:C})];case 9:return L=V.sent(),k.push({name:"interaction",manager:L}),[3,11];case 10:return M=V.sent(),this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(M.toString())),[3,11];case 11:if(this.eventsManager=new(sO.bind.apply(sO,(0,Z.__spreadArray)([void 0],(0,Z.__read)(k),!1))),this.eventCompressor&&this.eventCompressor.terminate(),N=!0===this.config.eagerFullSnapshotSend?function(){return K.sendEvents()}:void 0,this.eventCompressor=new sp(this.eventsManager,this.config,this.getDeviceId(),T,N),this.pendingEmitEvents.length>0){F=this.pendingEmitEvents.splice(0);try{for(U=(q=(0,Z.__values)(F)).next();!U.done;U=q.next())B=(j=U.value).event,z=j.sessionId,this.eventCompressor.enqueueEvent(B,z)}catch(e){G={error:e}}finally{try{U&&!U.done&&(H=q.return)&&H.call(q)}finally{if(G)throw G.error}}}return this.pageLeaveFns=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(this.pageLeaveFns),!1),[function(){if(K.config&&(null==(e=K.identifiers)?void 0:e.sessionId)&&R){var e,t=R.getBeaconEvents();if(t.length){var n=K.getDeviceId();!n||K.isBelowMinSessionDuration()||R.trackDestination.sendBeacon({events:t,sessionId:K.identifiers.sessionId,deviceId:n,apiKey:K.config.apiKey,serverZone:K.config.serverZone})}}}],!1),[4,this.initializeNetworkObservers()];case 12:return V.sent(),(null==(g=(0,eA.getGlobalScope)())?void 0:g.opener)&&(n6(W=n4()),W.setup((0,Z.__assign)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:n0[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:n.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return V.sent(),(this.config.targetingConfig||(null!=(v=null==(p=null==(h=this.config.privacyConfig)?void 0:h.urlMaskLevels)?void 0:p.length)?v:0)>0)&&this.setupUrlChangeListener(),[2]}})})},t.prototype.setSessionId=function(e,t){return eF(this.asyncSetSessionId(e,t))},t.prototype.asyncSetSessionId=function(e,t,n){var r,i,o,s;return(0,Z.__awaiter)(this,void 0,void 0,function(){var a,u,l,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:if(a=null==(r=this.identifiers)?void 0:r.sessionId,u=this.getDeviceId(),void 0!==a&&a===e&&(void 0===t||t===u)&&((null==n?void 0:n.userProperties)===void 0||0===Object.keys(n.userProperties).length))return[2];if(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,a&&this.sendEvents(a),(l=a!==e)&&(null==(i=this.rrwebEventManager)||i.dropPendingBeaconEvents()),c=t||this.getDeviceId(),this.identifiers=new sY({sessionId:e,deviceId:c}),l&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,(null==(o=this.config)?void 0:o.apiKey)&&(s1(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),void 0!==a&&s2(this.config.apiKey,a,this.loggerProvider))),!(this.joinedConfigGenerator&&a))return[3,2];return[4,this.joinedConfigGenerator.generateJoinedConfig()];case 1:d=f.sent().joinedConfig,this.config=d,f.label=2;case 2:if(!(null==(s=this.config)?void 0:s.targetingConfig))return[3,4];return[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)];case 3:return f.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:f.sent(),f.label=6;case 6:return[2]}})})},t.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),i={};return r&&((e={})[oL]=n.sessionReplayId?n.sessionReplayId:null,i=e,t.debugMode&&(i[oq]=JSON.stringify({appHash:tg(t.apiKey).toString()}))),this.addCustomRRWebEvent(K.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},t.prototype.sendEvents=function(e){var t,n,r=e||(null==(t=this.identifiers)?void 0:t.sessionId),i=this.getDeviceId();if(this.eventsManager&&r&&i){if(this.isBelowMinSessionDuration()){var o=this.sessionStartTime,s=this.config.minSessionDurationMs;this.loggerProvider.log("Session ".concat(r," not sent: duration ").concat(Date.now()-o,"ms is below minimum ").concat(s,"ms.")),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&(null==(n=this.config)?void 0:n.minSessionDurationMs)!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var a=void 0!==this.sessionStartTime?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent(K.REPLAY_GATE_DECISION,{sessionId:r,suppressedSendCount:this.suppressedSendCount,elapsedMs:a,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:r,deviceId:i})}},t.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var n;return(0,Z.__generator)(this,function(r){return(null==(t=this.identifiers)?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},t.prototype.shouldOptOut=function(){if(null==(e=this.config)?void 0:e.instanceName){var e,t,n;n=e8(this.config.instanceName).identityStore.getIdentity().optOut}return void 0!==n?n:null==(t=this.config)?void 0:t.optOut},t.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n=!1,r="",i=!1;return this.config.targetingConfig?this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),n=!0,i=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),n=!1,i=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,function(e,t){void 0===t&&(t=0);var n,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=(r-55296<<10)+(i-56320)+65536,n++)}r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<65536?t.push(224|r>>12,128|r>>6&63,128|63&r):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}return new Uint8Array(t)}(e),i=r.length,o=0;if(i>=16){for(var s=t+0x9e3779b1+0x85ebca77>>>0,a=t+0x85ebca77>>>0,u=t>>>0,l=t-0x9e3779b1>>>0;o<=i-16;)s=s8(s,s7(r,o)),o+=4,a=s8(a,s7(r,o)),o+=4,u=s8(u,s7(r,o)),o+=4,l=s8(l,s7(r,o)),o+=4;n=s6(s,1)+s6(a,7)+s6(u,12)+s6(l,18)>>>0}else n=t+0x165667b1>>>0;for(n=n+i>>>0;o<=i-4;)n=Math.imul(s6(n=n+Math.imul(s7(r,o),0xc2b2ae3d)>>>0,17),0x27d4eb2f)>>>0,o+=4;for(;o<i;)n=Math.imul(s6(n=n+Math.imul(r[o],0x165667b1)>>>0,11),0x9e3779b1)>>>0,o++;return n^=n>>>15,n=Math.imul(n,0x85ebca77)>>>0,n^=n>>>13,n=Math.imul(n,0xc2b2ae3d)>>>0,(n^=n>>>16)>>>0}(e.toString())%1e6/1e6<t)?(n=!0,i=!0):(r="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(r),n=!1,i=!1),this.lastShouldRecordDecision!==n&&this.config.targetingConfig&&(this.addCustomRRWebEvent(K.TARGETING_DECISION,{message:r,sessionId:this.identifiers.sessionId,matched:i,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=n),n},t.prototype.getBlockSelectors=function(){var e,t,n,r=null!=(n=null==(t=null==(e=this.config)?void 0:e.privacyConfig)?void 0:t.blockSelector)?n:[];if(0!==r.length)return r},t.prototype.getMaskTextSelectors=function(){var e,t,n=null==(e=this.config)?void 0:e.privacyConfig;if("conservative"===(n?oY(this.currentPageUrl,n):void 0)||(null==(t=null==n?void 0:n.urlMaskLevels)?void 0:t.some(function(e){return"conservative"===e.maskLevel})))return"*";var r=null==n?void 0:n.urlMaskLevels;if((null==n?void 0:n.defaultMaskLevel)==="conservative"&&r&&r.length>0)return"*";var i=null==n?void 0:n.maskSelector;if(i)return i},t.prototype.getRecordingPlugins=function(t){var n,r,i,o,s,a;return(0,Z.__awaiter)(this,void 0,void 0,function(){var u,l,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:u=[];try{l=an({ugcFilterRules:(null==(r=null==(n=this.config)?void 0:n.interactionConfig)?void 0:r.ugcFilterRules)||[],enablePolling:(null==(i=this.config)?void 0:i.enableUrlChangePolling)||!1,pollingInterval:null==(o=this.config)?void 0:o.urlChangePollingInterval,captureDocumentTitle:null==(s=this.config)?void 0:s.captureDocumentTitle}),u.push(l)}catch(e){this.loggerProvider.warn("Failed to create URL tracking plugin:",e)}if(!(null==(a=null==t?void 0:t.console)?void 0:a.enabled))return[3,4];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,e.A(27085)];case 2:return c=f.sent().getRecordConsolePlugin,u.push(c({level:t.console.levels})),[3,4];case 3:return d=f.sent(),this.loggerProvider.warn("Failed to load console plugin:",d),[3,4];case 4:return[2,u.length>0?u:void 0]}})})},t.prototype.getRecordFunction=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(this.recordFunction)return[2,this.recordFunction];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.A(12948)];case 2:return t=r.sent().record,this.recordFunction=t,[2,t];case 3:return n=r.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",n),[2,null];case 4:return[2]}})})},t.prototype.recordEvents=function(e){return void 0===e&&(e=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,n.label=1;case 1:return n.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:n.sent(),n.label=3;case 3:if(null===this.recordEventsPendingShouldLogMetadata)return[3,5];return t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)];case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},t.prototype._recordEvents=function(e){var t,n,r,i,o,s,a,u;return void 0===e&&(e=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var l,c,d,f,g,h,p,v,m,y,_,b,S,w,E,k,I,T,C=this;return(0,Z.__generator)(this,function(P){switch(P.label){case 0:if(l=this.config,c=this.getShouldRecord(),d=null==(t=this.identifiers)?void 0:t.sessionId,!c||!d||!l)return[2];return this.stopRecordingEvents(),[4,this.getRecordFunction()];case 1:if(!(f=P.sent()))return[2];return[4,this.initializeNetworkObservers()];case 2:P.sent(),g=null==(n=l.loggingConfig)?void 0:n.network,h=[oB,oz,oW,sg(l.serverZone,l.trackServerUrl)],null==(r=this.networkObservers)||r.start(function(e){h.some(function(t){return e.url.
1startsWith(t)})||C.addCustomRRWebEvent(K.FETCH_REQUEST,e)},g),p=l.interactionConfig,v=l.loggingConfig,m=(null==p?void 0:p.enabled)?{mouseInteraction:this.eventsManager&&(null==(i=this.clickHandler)?void 0:i.createHook({eventsManager:this.eventsManager,sessionId:d,deviceIdFn:this.getDeviceId.bind(this),mirror:f.mirror,ugcFilterRules:null!=(o=p.ugcFilterRules)?o:[],performanceOptions:null==(s=l.performanceConfig)?void 0:s.interaction})),scroll:this.scrollHook}:{},y=(null==p?void 0:p.enabled)&&p.ugcFilterRules?p.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(d,".")),P.label=3;case 3:if(P.trys.push([3,5,,6]),_=!!(null==(a=l.crossOriginIframes)?void 0:a.enabled),b=(null==(u=l.crossOriginIframes)?void 0:u.coordinateChildren)!==!1,(S=_&&function(){try{var e=(0,eA.getGlobalScope)();if(!e)return!1;return e.parent!==e}catch(e){return!0}}())&&b)return this.crossOriginParentSignalCleanup=function(e){var t=(0,eA.getGlobalScope)();if(!t)return function(){};var n=t.parent;function r(t){if(t.source===n){var r=t.data;(null==r?void 0:r.type)===oK&&("start"===r.action?e.onStart():"stop"===r.action&&e.onStop())}}return t.addEventListener("message",r),function(){return t.removeEventListener("message",r)}}({onStart:function(){return C._recordEventsInChildMode(f,d,l,m)},onStop:function(){try{C.recordCancelCallback&&C.recordCancelCallback(),C.recordCancelCallback=null}catch(e){C.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))}}}),[2];return w=this,E=f,k=[(0,Z.__assign)({},this.buildRRWebRecordOptions(l,m,function(e){if(C.shouldOptOut()){C.loggerProvider.log("Opting session ".concat(d," out of recording due to optOut config.")),C.stopRecordingEvents(),C.sendEvents();return}e.type===sn.Meta&&(e.data.href=o3(e.data.href,y)),C.eventCompressor?C.eventCompressor.enqueueEvent(e,d):C.pendingEmitEvents.push({event:e,sessionId:d})},"Error while capturing replay: "))],T={},[4,this.getRecordingPlugins(v)];case 4:return w.recordCancelCallback=E.apply(void 0,[Z.__assign.apply(void 0,k.concat([(T.plugins=P.sent(),T.recordCrossOriginIframes=_,T)]))]),_&&!S&&b&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new ar),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(K.DEBUG_INFO),e&&this.addCustomRRWebEvent(K.METADATA,this.metadata),[3,6];case 5:return I=P.sent(),this.loggerProvider.warn("Failed to initialize session replay:",I),[3,6];case 6:return[2]}})})},t.prototype.buildRRWebRecordOptions=function(e,t,n,r){var i,o=this,s=e.privacyConfig;return(0,Z.__assign)((0,Z.__assign)({emit:n,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:oU,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:oX("input",s,function(){return o.currentPageUrl}),maskTextFn:oX("text",s,function(){return o.currentPageUrl}),maskAttributeFn:(i=function(){return o.currentPageUrl},function(e,t,n){var r;return"style"!==e&&(null!=(r=null==s?void 0:s.maskAttributes)?r:[]).includes(e)?oQ(["INPUT","SELECT","TEXTAREA"].includes(n.tagName)?"input":"text",s,n,null==i?void 0:i())?t.replace(/[^\s]/g,"*"):t:t}),maskTextSelector:this.getMaskTextSelectors()},void 0!==e.fullSnapshotIntervalMs&&{checkoutEveryNms:e.fullSnapshotIntervalMs}),{recordCanvas:!1,captureAdoptedStyleSheets:e.captureAdoptedStyleSheets,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},errorHandler:function(e){if(e.message.includes("insertRule")&&e.message.includes("CSSStyleSheet")||e._external_)throw e;return o.loggerProvider.warn(r,e.toString()),!0}})},t.prototype._recordEventsInChildMode=function(e,t,n,r){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e((0,Z.__assign)((0,Z.__assign)({},this.buildRRWebRecordOptions(n,r,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t,"."))}catch(e){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",e)}},t.prototype.getDeviceId=function(){var e;return null==(e=this.identifiers)?void 0:e.deviceId},t.prototype.getSessionId=function(){var e;return null==(e=this.identifiers)?void 0:e.sessionId},t.prototype.flush=function(e){var t;return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return[2,null==(t=this.eventsManager)?void 0:t.flush(e)]})})},t.prototype.shutdown=function(){var e,t;null==(e=this.urlChangeCleanup)||e.call(this),null==(t=this.crossOriginParentSignalCleanup)||t.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},t.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},t.prototype.setMetadata=function(e,t,n,r,i,o,s){var a=(null==e?void 0:e.toString())?tg(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:i,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:o}},t.prototype.initializeNetworkObservers=function(){var t,n,r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:if(!((null==(r=null==(n=null==(t=this.config)?void 0:t.loggingConfig)?void 0:n.network)?void 0:r.enabled)&&!this.networkObservers))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,e.A(36374)];case 2:return i=s.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return o=s.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},t}(),ao=function(e){return function(){var t=e.config||o6();return{logger:t.loggerProvider,logLevel:t.logLevel}}};let as={init:ei((I=new ai).init.bind(I),"init",ao(I)),evaluateTargetingAndCapture:ei(I.evaluateTargetingAndCapture.bind(I),"evaluateTargetingAndRecord",ao(I)),setSessionId:ei(I.setSessionId.bind(I),"setSessionId",ao(I)),getSessionId:ei(I.getSessionId.bind(I),"getSessionId",ao(I)),getSessionReplayProperties:ei(I.getSessionReplayProperties.bind(I),"getSessionReplayProperties",ao(I)),flush:ei(I.flush.bind(I),"flush",ao(I)),shutdown:ei(I.shutdown.bind(I),"shutdown",ao(I))};var aa=as.init,au=as.setSessionId,al=as.getSessionId,ac=as.getSessionReplayProperties,ad=as.flush,af=as.shutdown,ag=as.evaluateTargetingAndCapture;(T=Y||(Y={})).SET="$set",T.SET_ONCE="$setOnce",T.ADD="$add",T.APPEND="$append",T.PREPEND="$prepend",T.REMOVE="$remove",T.PREINSERT="$preInsert",T.POSTINSERT="$postInsert",T.UNSET="$unset",T.CLEAR_ALL="$clearAll",(C=Q||(Q={})).REVENUE_PRODUCT_ID="$productId",C.REVENUE_QUANTITY="$quantity",C.REVENUE_PRICE="$price",C.REVENUE_TYPE="$revenueType",C.REVENUE_CURRENCY="$currency",C.REVENUE="$revenue",(P=X||(X={})).IDENTIFY="$identify",P.GROUP_IDENTIFY="$groupidentify",P.REVENUE="revenue_amount";var ah=[Y.SET,Y.SET_ONCE,Y.ADD,Y.APPEND,Y.PREPEND,Y.POSTINSERT],ap=function(e){if(e.user_properties){var t={};
1return Object.keys(e.user_properties).forEach(function(n){if(ah.includes(n)){var r=e.user_properties&&e.user_properties[n];t=(0,Z.__assign)((0,Z.__assign)({},t),r)}}),t}},av="1.33.7",am="".concat("[Amplitude]"," Session Replay ID"),ay=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:ad,getSessionId:al,getSessionReplayProperties:ac,init:aa,setSessionId:au,shutdown:af,evaluateTargetingAndCapture:ag},this.options=(0,Z.__assign)({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var n,r,i,o,s,a,u,l;return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:var f;return d.trys.push([0,2,,3]),null==e||e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(av,".")),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=(0,Z.__assign)((0,Z.__assign)({},e.defaultTracking),{sessions:!0})),t=(void 0===(f=this.config.instanceName)&&(f="$default_instance"),e6.getInstance(f)).identityStore.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!=(n=this.options.deviceId)?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl||(null==(r=this.config.remoteConfig)?void 0:r.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null==(i=this.options.privacyConfig)?void 0:i.blockSelector,maskSelector:null==(o=this.options.privacyConfig)?void 0:o.maskSelector,unmaskSelector:null==(s=this.options.privacyConfig)?void 0:s.unmaskSelector,defaultMaskLevel:null==(a=this.options.privacyConfig)?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:av},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!=(u=this.options.useWebWorker)?u:null==(l=this.options.experimental)?void 0:l.useWebWorker,userProperties:t,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval,captureAdoptedStyleSheets:this.options.captureAdoptedStyleSheets,crossOriginIframes:this.options.crossOriginIframes,flushIntervalConfig:this.options.flushIntervalConfig,eagerFullSnapshotSend:this.options.eagerFullSnapshotSend,captureFullSnapshotOnFocus:this.options.captureFullSnapshotOnFocus,maxPersistedEventsSizeBytes:this.options.maxPersistedEventsSizeBytes,maxSingleEventSizeBytes:this.options.maxSingleEventSizeBytes,sendTimeoutMs:this.options.sendTimeoutMs,handleSendEvents:this.options.handleSendEvents,handleFetchConfig:this.options.handleFetchConfig},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return d.sent(),[3,3];case 2:return c=d.sent(),null==e||e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(c.message)),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return null==(t=this.config)||t.loggerProvider.debug("Analytics session id is changed to ".concat(e,", SR session id is ").concat(String(this.sessionReplay.getSessionId()),".")),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(null==(t=this.config)||t.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),!e)return[3,1];return this.sessionReplay.shutdown(),[3,4];case 1:if(null==this.config)return[3,3];return[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise];case 2:n.sent(),n.label=3;case 3:n.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t,n,r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:if(l.trys.push([0,9,,10]),!this.options.customSessionId)return[3,4];if(!(i=this.options.customSessionId(e)))return[3,3];if(i===this.sessionReplay.getSessionId())return[3,2];return[4,this.sessionReplay.setSessionId(i).promise];case 1:l.sent(),l.label=2;case 2:o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),o),l.label=3;case 3:return[3,8];case 4:if(!((i=null==(t=this.config)?void 0:t.sessionId)&&i!==this.sessionReplay.getSessionId()))return[3,6];return[4,this.sessionReplay.setSessionId(i).promise];case 5:l.sent(),l.label=6;case 6:if(!(i&&i===e.session_id))return[3,8];return s=void 0,e.event_type===O.IDENTIFY&&(s=ap(e)),a=(0,eA.getGlobalScope)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:s,page:(null==(n=null==a?void 0:a.location)?void 0:n.href)!=null?{url:a.location.href}:void 0})];case 7:l.sent(),o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),o),l.label=8;case 8:return e.event_type===O.IDENTIFY&&e.event_properties&&delete e.event_properties[am],[2,Promise.resolve(e)];case 9:return u=l.sent(),null==(r=this.config)||r.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(u.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null==(e=this.config)||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(t.message))}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.pluginName="@amplitude/plugin-session-replay-browser",e}();let a_="22f42d1d9c8df7a8c16b9b849586f06",ab=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],aS="scriptflo-utm",aw=!1;function aE(){try{return JSON.parse(localStorage.getItem(aS)??"{}")}catch{return{}}}function ak(){return aw?oA():void 0}e.s(["getDeviceId",0,ak,"getStoredUtms",0,aE,"initAnalytics",0,function(){if(!aw&&a_){try{let e=new URLSearchParams(window.location.search),t={};for(let n of ab){let r=e.get(n);r&&(t[n]=r)}Object.keys(t).length>0&&localStorage.setItem(aS,JSON.stringify(t))}catch{}"scriptflo.ai"===window.location.hostname&&(oO(a_,{transport:"beacon",autocapture:{attribution:!0,pageViews:!0,sessions:!0,formInteractions:!1,fileDownloads:!1,elementInteractions:!1}}),oP(new ay({sampleRate:1})),aw=!0)}},"trackEvent",0,function(e,t){aw&&(oR(e,{...aE(),...t}),ox())},"withAttribution",0,function(e){try{let t=new URL(e);for(let[e,n]of Object.entries(aE()))t.searchParams.set(e,n);let n=ak();return n&&t.searchParams.set("deviceId",n),t.toString()}catch{return e}}],78869)},41097,e=>{"use strict";var t=e.i(43476),n=e.i(78869);let r="https://app.scriptflo.ai/?signup=1",i="scriptflo:desktop-l
1ink";function o(e,t){if(function(e=e=>window.matchMedia(e)){return e("(max-width: 767px) and (pointer: coarse)").matches}()){e.preventDefault(),(0,n.trackEvent)("early_access_cta_clicked",{placement:t,sheet:"desktop_link"}),window.dispatchEvent(new CustomEvent(i,{detail:{placement:t,trigger:e.currentTarget}}));return}s(e,"early_access_cta_clicked",{placement:t})}function s(e,t,i){var o;let s=(0,n.withAttribution)(r);e.currentTarget.href=s;let a=(o=navigator.userAgent,/\b(iPhone|iPad|iPod)\b/.test(o)&&/AppleWebKit/.test(o)&&!/\bSafari\//.test(o));(0,n.trackEvent)(t,{...i,...a?{handoff:"safari"}:{}}),a&&(e.preventDefault(),window.location.href=function(e){if(!/^https:\/\//.test(e))throw Error("Safari handoff needs an https url");return`x-safari-${e}`}(s),window.setTimeout(()=>{"visible"===document.visibilityState&&(window.location.href=s)},1500))}let a={hero:"inline-flex items-center rounded-md bg-primary px-8 py-3.5 text-base font-semibold text-on-primary hover:bg-primary-hover hover:-translate-y-px transition-all duration-150",primary:"inline-flex items-center rounded-md bg-primary px-6 py-3 text-sm font-medium text-on-primary hover:bg-primary-hover hover:-translate-y-px transition-all duration-150",accent:"inline-flex items-center rounded-md bg-on-accent px-8 py-3.5 text-sm font-medium text-surface-accent hover:bg-on-accent/90 hover:-translate-y-px transition-all duration-150"};e.s(["DESKTOP_LINK_EVENT",0,i,"SIGNUP_URL",0,r,"continueSignupOnPhone",0,function(e,t){s(e,"desktop_link_continue_phone",{placement:t})},"default",0,function({placement:e,variant:n="primary",label:i="Start writing free",className:s,onClick:u}){return(0,t.jsx)("a",{href:r,onClick:t=>{o(t,e),u?.()},className:s??a[n],children:i})},"startSignup",0,o],41097)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.