PageSourceSearch

https://friendi.om/_astro/index.Bov8hHdG.js

js friendi.om collected 2026-10-09 04:43:27 UTC 401,260 bytes, 13 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/index.OMs6UZrZ.js","_astro/tslib.es6.CcuSb4g9.js","_astro/_commonjsHelpers.Cu7NZiI_.js","_astro/preload-helper.BwZxz616.js","_astro/observers.DB9d6_ST.js"])))=>i.map(i=>d[i]);
2import{_ as L,e as C,a as W,b as D,c as I,d as _,f as at,g as Le}from"./tslib.es6.CcuSb4g9.js";import{g as Ga}from"./_commonjsHelpers.Cu7NZiI_.js";import{_ as Ht}from"./preload-helper.BwZxz616.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"6f2fe129c5b87a977f9c09e540837c29d04100de"};var e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="16a45bd9-7b7a-413a-b6a0-b400dc3e6b76",t._sentryDebugIdIdentifier="sentry-dbid-16a45bd9-7b7a-413a-b6a0-b400dc3e6b76")}catch{}})();function _l(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in t)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Ke;(function(t){t.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"})(Ke||(Ke={}));var Ae;(function(t){t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount"})(Ae||(Ae={}));var Gi="-",Vr="AMP",Il="".concat(Vr,"_unsent"),ja="$default_instance",hi="https://api2.amplitude.com/2/httpapi",za="https://api.eu.amplitude.com/2/httpapi",$a="https://api2.amplitude.com/batch",Ka="https://api.eu.amplitude.com/batch",wl="utm_campaign",Cl="utm_content",Pl="utm_id",Al="utm_medium",kl="utm_source",Rl="utm_term",ji="dclid",zi="fbclid",$i="gbraid",Ki="gclid",Xi="ko_click_id",Yi="li_fat_id",Qi="msclkid",Ji="rdt_cid",Zi="ttclid",eo="twclid",to="wbraid",Wr={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},Or=["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"],Ol=["authorization","cookie","set-cookie"],Ll=1e3,Bn=function(t){if(Object.keys(t).length>Ll)return!1;for(var e in t){var r=t[e];if(!Xa(e,r))return!1}return!0},Xa=function(t,e){var r,n;if(typeof t!="string")return!1;if(Array.isArray(e)){var i=!0;try{for(var o=L(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if(typeof s=="object")i=i&&Bn(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}else{if(e==null)return!1;if(typeof e=="object")return Bn(e);if(!["number","string","boolean"].includes(typeof e))return!1}return!0},Tt=(function(){function t(){this._propertySet=new Set,this._properties={}}return t.prototype.getUserProperties=function(){return C({},this._properties)},t.prototype.set=function(e,r){return this._safeSet(ae.SET,e,r),this},t.prototype.setOnce=function(e,r){return this._safeSet(ae.SET_ONCE,e,r),this},t.prototype.append=function(e,r){return this._safeSet(ae.APPEND,e,r),this},t.prototype.prepend=function(e,r){return this._safeSet(ae.PREPEND,e,r),this},t.prototype.postInsert=function(e,r){return this._safeSet(ae.POSTINSERT,e,r),this},t.prototype.preInsert=function(e,r){return this._safeSet(ae.PREINSERT,e,r),this},t.prototype.remove=function(e,r){return this._safeSet(ae.REMOVE,e,r),this},t.prototype.add=function(e,r){return this._safeSet(ae.ADD,e,r),this},t.prototype.unset=function(e){return this._safeSet(ae.UNSET,e,Gi),this},t.prototype.clearAll=function(){return this._properties={},this._properties[ae.CLEAR_ALL]=Gi,this}
2,t.prototype._safeSet=function(e,r,n){if(this._validate(e,r,n)){var i=this._properties[e];return i===void 0&&(i={},this._properties[e]=i),i[r]=n,this._propertySet.add(r),!0}return!1},t.prototype._validate=function(e,r,n){return this._properties[ae.CLEAR_ALL]!==void 0||this._propertySet.has(r)?!1:e===ae.ADD?typeof n=="number":e!==ae.UNSET&&e!==ae.REMOVE?Xa(r,n):!0},t})(),ae;(function(t){t.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"})(ae||(ae={}));var Dl=[ae.CLEAR_ALL,ae.UNSET,ae.SET,ae.SET_ONCE,ae.ADD,ae.APPEND,ae.PREPEND,ae.PREINSERT,ae.POSTINSERT,ae.REMOVE],xl="Event tracked successfully",Ml="Unexpected error occurred",Nl="Event rejected due to exceeded retry count",Ul="Event skipped due to optOut config",ro="Event skipped due to empty event type",Fl="Event rejected due to missing API key",Bl="Invalid API key",ql="Client not initialized",fe;(function(t){t.Unknown="unknown",t.Skipped="skipped",t.Success="success",t.RateLimit="rate_limit",t.PayloadTooLarge="payload_too_large",t.Invalid="invalid",t.Failed="failed",t.Timeout="Timeout",t.SystemError="SystemError"})(fe||(fe={}));var it=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=fe.Unknown),{event:t,code:e,message:r}},z=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global},Vl=function(t){return t?(t^Math.random()*16>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Ue)},no=W([],D(Array(256).keys()),!1).map(function(t){return t.toString(16).padStart(2,"0")}),Ue=function(t){var e,r=z();if(!(!((e=r?.crypto)===null||e===void 0)&&e.getRandomValues))return Vl(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,W([],D(n.entries()),!1).map(function(i){var o=D(i,2),a=o[0],s=o[1];return[4,6,8,10].includes(a)?"-".concat(no[s]):no[s]}).join("")},or={exports:{}},io;function Wl(){if(io)return or.exports;io=1;var t=Object.prototype.hasOwnProperty;function e(i){return"[Throws: "+(i?i.message:"?")+"]"}function r(i,o){if(t.call(i,o))try{return i[o]}catch(a){return e(a)}return i[o]}function n(i){var o=[];function a(s){if(s===null||typeof s!="object")return s;if(o.indexOf(s)!==-1)return"[Circular]";if(o.push(s),typeof s.toJSON=="function")try{var u=a(s.toJSON());return o.pop(),u}catch(f){return e(f)}if(Array.isArray(s)){var l=s.map(a);return o.pop(),l}var c=Object.keys(s).reduce(function(f,d){return f[d]=a(r(s,d)),f},{});return o.pop(),c}return a(i)}return or.exports=function(i,o,a){return JSON.stringify(n(i),o,a)},or.exports.ensureProperties=n,or.exports}var Ya=Wl();const gi=Ga(Ya),Qa=_l({__proto__:null,default:gi},[Ya]);var Ge=gi||Qa,Hl=(function(){function t(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return t.prototype.register=function(e,r){var n,i;return I(this,void 0,void 0,function(){var o;return _(this,function(a){switch(a.label){case 0:return e.name===void 0&&(e.name=Ue(),this.loggerProvider.warn(`Plugin name is undefined.
3      Generating a random UUID for plugin name: `.concat(e.name,`.
4      Set a name for the plugin to prevent it from being added multiple times.`))),o=e.name,this.pluginStatus.has(o)?(this.loggerProvider.warn("Plugin with name ".concat(o," already exists, skipping registration")),[2]):(e.type=(n=e.type)!==null&&n!==void 0?n:"enrichment",this.pluginStatus.set(o,"locked"),[4,(i=e.setup)===null||i===void 0?void 0:i.call(e,r,this.client)]);case 1:return a.sent(),this.pluginStatus.get(o)!=="locked"?[2]:(this.plugins.push(e),this.pluginStatus.set(o,"installed"),[2])}})})},t.prototype.deregister=function(e,r){var n;return I(this,void 0,void 0,function(){var i,o;return _(this,function(a){switch(a.label){case 0:return this.pluginStatus.delete(e),i=this.plugins.findIndex(function(s){return s.name===e}),i===-1?(r.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(o=this.plugins[i],this.plugins.splice(i,1),[4,(n=o.teardown)===null||n===void 0?void 0:n.call(o)]);case 1:return a.sent(),[2]}})})},t.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1;var r=this.plugins;r.map(function(n){var i;return(i=n.teardown)===null||i===void 0?void 0:i.call(n)}),this.plugins=[],this.pluginStatus.clear(),this.client=e},t.prototype.push=function(e){var r=this;return new Promise(function(n){r.queue.push([e,n]),r.scheduleApply(0)})},t.prototype.scheduleApply=function(e){var r=this;this.applying||(this.applying=!0,setTimeout(function(){r.apply(r.queue.shift()).then(function(){r.applying=!1,r.queue.length>0&&r.scheduleApply(0)})},e))},t.prototype.apply=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a,s,u,v,h,l,c,f,d,v,h,g,m,p,y,b,E,S;return _(this,function(T){switch(T.label){case 0:if(!e)return[2];r=D(e,1),n=r[0],i=D(e,2),o=i[1],this.loggerProvider.log("Timeline.apply: Initial event",n),a=this.plugins.filter(function(w){return w.type==="before"}),T.label=1;case 1:T.trys.push([1,6,7,8]),s=L(a),u=s.next(),T.label=2;case 2:return u.done?[3,5]:(v=u.value,v.execute?[4,v.execute(C({},n))]:[3,4]);case 3:if(h=T.sent(),h===null)return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(v.name),"', event: ").concat(Ge(n))),o({event:n,code:0,message:""}),[2];n=h,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(v.name),"', event: ").concat(Ge(n))),T.label=4;case 4:return u=s.next(),[3,2];case 5:return[3,8];case 6:return l=T.sent(),y={error:l},[3,8];case 7:try{u&&!u.done&&(b=s.return)&&b.call(s)}finally{if(y)throw y.error}
4return[7];case 8:c=this.plugins.filter(function(w){return w.type==="enrichment"||w.type===void 0}),T.label=9;case 9:T.trys.push([9,14,15,16]),f=L(c),d=f.next(),T.label=10;case 10:return d.done?[3,13]:(v=d.value,v.execute?[4,v.execute(C({},n))]:[3,12]);case 11:if(h=T.sent(),h===null)return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(v.name),"', event: ").concat(Ge(n))),o({event:n,code:0,message:""}),[2];n=h,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(v.name),"', event: ").concat(Ge(n))),T.label=12;case 12:return d=f.next(),[3,10];case 13:return[3,16];case 14:return g=T.sent(),E={error:g},[3,16];case 15:try{d&&!d.done&&(S=f.return)&&S.call(f)}finally{if(E)throw E.error}return[7];case 16:return m=this.plugins.filter(function(w){return w.type==="destination"}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(Ge(n))),p=m.map(function(w){var P=C({},n);return w.execute(P).catch(function(A){return it(P,0,String(A))})}),Promise.all(p).then(function(w){var P=D(w,1),A=P[0],F=A||it(n,100,"Event not tracked, no destination plugins on the instance");o(F)}),[2]}})})},t.prototype.flush=function(){return I(this,void 0,void 0,function(){var e,r,n,i=this;return _(this,function(o){switch(o.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(a){return i.apply(a)}))];case 1:return o.sent(),r=this.plugins.filter(function(a){return a.type==="destination"}),n=r.map(function(a){return a.flush&&a.flush()}),[4,Promise.all(n)];case 2:return o.sent(),[2]}})})},t.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},t.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},t.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onIdentityChanged)===null||n===void 0||n.call(r,e)})},t.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onSessionIdChanged)===null||n===void 0||n.call(r,e)})},t.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onOptOutChanged)===null||n===void 0||n.call(r,e)}),this._callOptOutListeners(e)},t.prototype._callOptOutListeners=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a,s,u;return _(this,function(l){switch(l.label){case 0:l.trys.push([0,7,8,9]),r=L(this._optOutListeners),n=r.next(),l.label=1;case 1:if(n.done)return[3,6];i=n.value,l.label=2;case 2:return l.trys.push([2,4,,5]),[4,i(e)];case 3:return l.sent(),[3,5];case 4:return o=l.sent(),this.loggerProvider.error("Error calling optOut listener",o),[3,5];case 5:return n=r.next(),[3,1];case 6:return[3,9];case 7:return a=l.sent(),s={error:a},[3,9];case 8:try{n&&!n.done&&(u=r.return)&&u.call(r)}finally{if(s)throw s.error}return[7];case 9:return[2]}})})},t.prototype.onReset=function(){this.plugins.forEach(function(e){var r;(r=e.onReset)===null||r===void 0||r.call(e)})},t})(),Gl=function(t,e,r){var n=typeof t=="string"?{event_type:t}:t;return C(C(C({},n),r),e&&{event_properties:e})},pi=function(t,e){var r=C(C({},e),{event_type:Ae.IDENTIFY,user_properties:t.getUserProperties()});return r},jl=function(t,e,r,n){var i,o=C(C({},n),{event_type:Ae.GROUP_IDENTIFY,group_properties:r.getUserProperties(),groups:(i={},i[t]=e,i)});return o},zl=function(t,e,r){var n,i=new Tt;i.set(t,e);var o=C(C({},r),{event_type:Ae.IDENTIFY,user_properties:i.getUserProperties(),groups:(n={},n[t]=e,n)});return o},$l=function(t,e){return C(C({},e),{event_type:Ae.REVENUE,event_properties:t.getEventProperties()})},ye=function(t){return{promise:t||Promise.resolve()}},Kl=(function(){function t(e){e===void 0&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new Hl(this),this.name=e}return t.prototype._init=function(e){return I(this,void 0,void 0,function(){var r=this;return _(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 r.isReady=!0})];case 1:return n.sent(),[2]}})})},t.prototype.runQueuedFunctions=function(e,r){return I(this,void 0,void 0,function(){var n,i,o,a,s,u,l,c;return _(this,function(f){switch(f.label){case 0:n=this[e],this[e]=[],f.label=1;case 1:f.trys.push([1,8,9,10]),i=L(n),o=i.next(),f.label=2;case 2:return o.done?[3,7]:(a=o.value,s=a(),s&&"promise"in s?[4,s.promise]:[3,4]);case 3:return f.sent(),[3,6];case 4:return[4,s];case 5:f.sent(),f.label=6;case 6:return o=i.next(),[3,2];case 7:return[3,10];case 8:return u=f.sent(),l={error:u},[3,10];case 9:try{o&&!o.done&&(c=i.return)&&c.call(i)}finally{if(l)throw l.error}
4return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e,r)]:[3,12];case 11:return f.sent(),[3,13];case 12:r?.(),f.label=13;case 13:return[2]}})})},t.prototype.track=function(e,r,n){var i=Gl(e,r,n);return this.userProperties=this.getOperationAppliedUserProperties(i.user_properties),ye(this.dispatch(i))},t.prototype.identify=function(e,r){var n=pi(e,r);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),ye(this.dispatch(n))},t.prototype.groupIdentify=function(e,r,n,i){var o=jl(e,r,n,i);return ye(this.dispatch(o))},t.prototype.setGroup=function(e,r,n){var i=zl(e,r,n);return this.userProperties=this.getOperationAppliedUserProperties(i.user_properties),ye(this.dispatch(i))},t.prototype.revenue=function(e,r){var n=$l(e,r);return ye(this.dispatch(n))},t.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),ye())},t.prototype._addPlugin=function(e){return ye(this.timeline.register(e,this.config))},t.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),ye())},t.prototype._removePlugin=function(e){return ye(this.timeline.deregister(e,this.config))},t.prototype.dispatchWithCallback=function(e,r){if(!this.isReady)return r(it(e,0,ql));this.process(e).then(r)},t.prototype.dispatch=function(e){return I(this,void 0,void 0,function(){var r=this;return _(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(i){r.dispatchQ.push(r.dispatchWithCallback.bind(r,e,i))})]})})},t.prototype.getOperationAppliedUserProperties=function(e){var r,n=(r=this.userProperties)!==null&&r!==void 0?r:{},i=C({},n);if(e===void 0)return i;var o={};return Object.keys(e).forEach(function(a){Object.values(Ke).includes(a)||(o[a]=e[a])}),Dl.forEach(function(a){if(Object.keys(e).includes(a)){var s=e[a];
4switch(a){case Ke.CLEAR_ALL:Object.keys(i).forEach(function(u){delete i[u]});break;case Ke.UNSET:Object.keys(s).forEach(function(u){delete i[u]});break;case Ke.SET:Object.assign(i,s);break}}}),Object.assign(i,o),i},t.prototype.process=function(e){return I(this,void 0,void 0,function(){var r,o,n,i,o;return _(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),this.config.optOut?[2,it(e,0,Ul)]:(r=e.event_type,typeof r!="string"||r.trim().length===0?(this.config.loggerProvider.error(ro),[2,it(e,0,ro)]):(e.event_type===Ae.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]));case 1:return o=a.sent(),o.code===200?this.config.loggerProvider.log(o.message):o.code===100?this.config.loggerProvider.warn(o.message):this.config.loggerProvider.error(o.message),[2,o];case 2:return n=a.sent(),i=String(n),this.config.loggerProvider.error(i),o=it(e,0,i),[2,o];case 3:return[2]}})})},t.prototype.setOptOut=function(e){if(!this.isReady){this.q.push(this._setOptOut.bind(this,!!e));return}this._setOptOut(e)},t.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=!!e,this.timeline.onOptOutChanged(e))},t.prototype.flush=function(){return ye(this.timeline.flush())},t.prototype.plugin=function(e){var r=this.timeline.plugins.find(function(n){return n.name===e});if(r===void 0){this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e));return}return r},t.prototype.plugins=function(e){return this.timeline.plugins.filter(function(r){return r instanceof e})},t})(),Xl=(function(){function t(){this.productId="",this.quantity=1,this.price=0}return t.prototype.setProductId=function(e){return this.productId=e,this},t.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},t.prototype.setPrice=function(e){return this.price=e,this},t.prototype.setRevenueType=function(e){return this.revenueType=e,this},t.prototype.setCurrency=function(e){return this.currency=e,this},t.prototype.setRevenue=function(e){return this.revenue=e,this},t.prototype.setReceipt=function(e){return this.receipt=e,this},t.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},t.prototype.setEventProperties=function(e){try{var r=JSON.parse(JSON.stringify(e));Bn(r)&&(this.properties=r)}catch{}return this},t.prototype.getEventProperties=function(){var e=this.properties?C({},this.properties):{};return e[xe.REVENUE_PRODUCT_ID]=this.productId,e[xe.REVENUE_QUANTITY]=this.quantity,e[xe.REVENUE_PRICE]=this.price,e[xe.REVENUE_TYPE]=this.revenueType,e[xe.REVENUE_CURRENCY]=this.currency,e[xe.REVENUE]=this.revenue,e[xe.RECEIPT]=this.receipt,e[xe.RECEIPT_SIG]=this.receiptSig,e},t})(),xe;(function(t){t.REVENUE_PRODUCT_ID="$productId",t.REVENUE_QUANTITY="$quantity",t.REVENUE_PRICE="$price",t.REVENUE_TYPE="$revenueType",t.REVENUE_CURRENCY="$currency",t.REVENUE="$revenue",t.RECEIPT="$receipt",t.RECEIPT_SIG="$receiptSig"})(xe||(xe={}));var Yl=function(t,e){var r=Math.max(e,1);return t.reduce(function(n,i,o){var a=Math.floor(o/r);return n[a]||(n[a]=[]),n[a].push(i),n},[])},Ee;(function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Verbose=3]="Verbose",t[t.Debug=4]="Debug"})(Ee||(Ee={}));var ar="Amplitude Logger ",mi=(function(){function t(){this.logLevel=Ee.None}return t.prototype.disable=function(){this.logLevel=Ee.None},t.prototype.enable=function(e){e===void 0&&(e=Ee.Warn),this.logLevel=e},t.prototype.log=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Ee.Verbose||console.log("".concat(ar,"[Log]: ").concat(e.join(" ")))},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Ee.Warn||console.warn("".concat(ar,"[Warn]: ").concat(e.join(" ")))},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Ee.Error||console.error("".concat(ar,"[Error]: ").concat(e.join(" ")))},t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Ee.Debug||console.log("".concat(ar,"[Debug]: ").concat(e.join(" ")))},t})(),Ja=function(t){return t===void 0||t===""?ja:t},Er=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:ja,logLevel:Ee.Warn,loggerProvider:new mi,offline:!1,optOut:!1,serverUrl:hi,serverZone:"US",useBatch:!1}},Ql=(function(){function t(e){var r,n,i,o;this._optOut=!1;var a=Er();this.apiKey=e.apiKey,this.flushIntervalMillis=(r=e.flushIntervalMillis)!==null&&r!==void 0?r:a.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||a.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||a.flushQueueSize,this.instanceName=Ja(e.instanceName),this.loggerProvider=e.loggerProvider||a.loggerProvider,this.logLevel=(n=e.logLevel)!==null&&n!==void 0?n:a.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=e.offline!==void 0?e.offline:a.offline,this.optOut=(i=e.optOut)!==null&&i!==void 0?i:a.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||a.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=(o=e.useBatch)!==null&&o!==void 0?o:a.useBatch,this.loggerProvider.enable(this.logLevel);var s=Za(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
4,enumerable:!1,configurable:!0}),t})(),Jl=function(t,e){return t==="EU"?e?Ka:za:e?$a:hi},Za=function(t,e,r){if(t===void 0&&(t=""),e===void 0&&(e=Er().serverZone),r===void 0&&(r=Er().useBatch),t)return{serverUrl:t,serverZone:void 0};var n=["US","EU"].includes(e)?e:Er().serverZone;return{serverZone:n,serverUrl:Jl(n,r)}},Zl=(function(){function t(){this.sdk={metrics:{histogram:{}}}}return t.prototype.recordHistogram=function(e,r){this.sdk.metrics.histogram[e]=r},t})();function qn(t){return t>=200&&t<300}var Sr=function(t){t===void 0&&(t=0);var e=new Error().stack||"";return e.split(`
5`).slice(2+t).map(function(r){return r.trim()})},le=function(t){return function(){var e=C({},t.config),r=e.loggerProvider,n=e.logLevel;return{logger:r,logLevel:n}}},ec=function(t,e){var r,n;e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,"");try{for(var i=L(e.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(a in t)t=t[a];else return}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t},ce=function(t,e){return function(){var r,n,i={};try{for(var o=L(e),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=ec(t,s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}},de=function(t,e,r,n,i){return i===void 0&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=r(),u=s.logger,l=s.logLevel;if(l&&l<Ee.Debug||!l||!u)return t.apply(i,o);var c={type:"invoke public method",name:e,args:o,stacktrace:Sr(1),time:{start:new Date().toISOString()},states:{}};n&&c.states&&(c.states.before=n());var f=t.apply(i,o);return f&&f.promise?f.promise.then(function(){n&&c.states&&(c.states.after=n()),c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))}):(n&&c.states&&(c.states.after=n()),c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))),f}},tc=new Set([hi,za,$a,Ka]),rc=function(t,e){return e===void 0&&(e=!1),tc.has(t)?!0:e};function nc(t){return t instanceof Error?t.message:String(t)}function Nt(t){var e="";try{"body"in t&&(e=JSON.stringify(t.body,null,2))}catch{}return e}var ic=(function(){function t(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=e?.diagnosticsClient}return t.prototype.setup=function(e){var r;return I(this,void 0,void 0,function(){var n,i=this;return _(this,function(o){switch(o.label){case 0:return this.config=e,this.storageKey="".concat(Il,"_").concat(this.config.apiKey.substring(0,10)),[4,(r=this.config.storageProvider)===null||r===void 0?void 0:r.get(this.storageKey)];case 1:return n=o.sent(),n&&n.length>0&&Promise.all(n.map(function(a){return i.execute(a)})).catch(),[2,Promise.resolve(void 0)]}})})},t.prototype.execute=function(e){var r=this;return e.insert_id||(e.insert_id=Ue()),new Promise(function(n){var i={event:e,attempts:0,callback:function(o){return n(o)},timeout:0};r.queue.push(i),r.schedule(r.config.flushIntervalMillis),r.saveEvents()})},t.prototype.removeEventsExceedFlushMaxRetries=function(e){var r=this;return e.filter(function(n){return n.attempts+=1,n.attempts<r.config.flushMaxRetries?!0:(r.fulfillRequest([n],500,Nl),!1)})},t.prototype.scheduleEvents=function(e){var r=this;e.forEach(function(n){r.schedule(n.timeout===0?r.config.flushIntervalMillis:n.timeout)})},t.prototype.schedule=function(e){var r=this;if(!this.config.offline&&(this.scheduleId===null||this.scheduleId&&e>this.scheduledTimeout)){this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,this.scheduleId=setTimeout(function(){r.queue=r.queue.map(function(n){return n.timeout=0,n}),r.flush(!0)},e);return}},t.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},t.prototype.flush=function(e){return e===void 0&&(e=!1),I(this,void 0,void 0,function(){var r,n,i,o=this;return _(this,function(a){switch(a.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),r=[],n=[],this.queue.forEach(function(s){return s.timeout===0?r.push(s):n.push(s)}),i=Yl(r,this.config.flushQueueSize),[4,i.reduce(function(s,u){return I(o,void 0,void 0,function(){return _(this,function(l){switch(l.label){case 0:return[4,s];case 1:return l.sent(),[4,this.send(u,e)];case 2:return[2,l.sent()]}})})},Promise.resolve())]);case 1:return a.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},t.prototype.send=function(e,r){var n;return r===void 0&&(r=!0),I(this,void 0,void 0,function(){var i,o,a,s,u,l;return _(this,function(c){switch(c.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,Fl)];i={api_key:this.config.apiKey,events:e.map(function(f){var d=f.event;d.extra;var v=at(d,["extra"]);return v}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new Zl,c.label=1;case 1:return c.trys.push([1,3,,4]),o=Za(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,a=rc(o,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(o,i,a)];case 2:return s=c.sent(),s===null?(this.fulfillRequest(e,0,Ml),[2]):r?(this.handleResponse(s,e),[3,4]):("body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(Nt(s))):this.fulfillRequest(e,s.statusCode,s.status),[2]);case 3:return u=c.sent(),l=nc(u),this.config.loggerProvider.error(l),(n=this.diagnosticsClient)===null||n===void 0||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(f){return f.event.event_type}),message:l,stack_trace:Sr()}),this.handleResponse({status:fe.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},t.prototype.handleResponse=function(e,r){var n;qn(e.statusCode)||(n=this.diagnosticsClient)===null||n===void 0||n.recordEvent("analytics.events.unsuccessful",{events:r.map(function(o){return o.event.event_type}),code:e.statusCode,status:e.status,body:Nt(e),stack_trace:Sr()});var i=e.status;switch(i){case fe.Success:{this.handleSuccessResponse(e,r);break}case fe.Invalid:{this.handleInvalidResponse(e,r);break}case fe.PayloadTooLarge:{this.handlePayloadTooLargeResponse(e,r);break}case fe.RateLimit:{this.handleRateLimitResponse(e,r);break}default:{this.config.loggerProvider.warn(`{code: 0, error: "Status '`.concat(i,"' provided for ").concat(r.length,' events"}')),this.handleOtherResponse(r);break}}},t.prototype.handleSuccessResponse=function(e,r){this.fulfillRequest(r,e.statusCode,xl)},t.prototype.handleInvalidResponse=function(e,r){var n=this;if(e.body.missingField||e.body.error.startsWith(Bl)){this.fulfillRequest(r,e.statusCode,e.body.error);return}var i=W(W(W(W([],D(Object.values(e.body.eventsWithInvalidFields)),!1),D(Object.values(e.body.eventsWithMissingFields)),!1),D(Object.values(e.body.eventsWithInvalidIdLengths)),!1),D(e.body.silencedEvents),!1).flat(),o=new Set(i),a=r.filter(function(u,l){if(o.has(l)){n.fulfillRequest([u],e.statusCode,e.body.error);return}return!0});a.length>0&&this.config.loggerProvider.warn(Nt(e));
5var s=this.removeEventsExceedFlushMaxRetries(a);this.scheduleEvents(s)},t.prototype.handlePayloadTooLargeResponse=function(e,r){if(r.length===1){this.fulfillRequest(r,e.statusCode,e.body.error);return}this.config.loggerProvider.warn(Nt(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(r);this.scheduleEvents(n)},t.prototype.handleRateLimitResponse=function(e,r){var n=this,i=Object.keys(e.body.exceededDailyQuotaUsers),o=Object.keys(e.body.exceededDailyQuotaDevices),a=e.body.throttledEvents,s=new Set(i),u=new Set(o),l=new Set(a),c=r.filter(function(d,v){if(d.event.user_id&&s.has(d.event.user_id)||d.event.device_id&&u.has(d.event.device_id)){n.fulfillRequest([d],e.statusCode,e.body.error);return}return l.has(v)&&(d.timeout=n.throttleTimeout),!0});c.length>0&&this.config.loggerProvider.warn(Nt(e));var f=this.removeEventsExceedFlushMaxRetries(c);this.scheduleEvents(f)},t.prototype.handleOtherResponse=function(e){var r=this,n=e.map(function(o){return o.timeout=o.attempts*r.retryTimeout,o}),i=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(i)},t.prototype.fulfillRequest=function(e,r,n){var i,o,a;qn(r)?(a=this.diagnosticsClient)===null||a===void 0||a.increment("analytics.events.sent",e.length):((i=this.diagnosticsClient)===null||i===void 0||i.increment("analytics.events.dropped",e.length),(o=this.diagnosticsClient)===null||o===void 0||o.recordEvent("analytics.events.dropped",{events:e.map(function(s){return s.event.event_type}),code:r,message:n,stack_trace:Sr()})),this.removeEvents(e),e.forEach(function(s){return s.callback(it(s.event,r,n))})},t.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(r){return r.event});this.config.storageProvider.set(this.storageKey,e)}},t.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(r){return!e.some(function(n){return n.event.insert_id===r.event.insert_id})}),this.saveEvents()},t})();let oc=class{getApplicationContext(){return{versionName:this.versionName,language:ac(),platform:"Web",os:void 0,deviceModel:void 0}}};const ac=()=>typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]||navigator.language)||"";let sc=class{constructor(){this.queue=[]}logEvent(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)}setEventReceiver(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(r=>{e(r)}),this.queue=[])}};const Tr=(t,e)=>{const r=["string","number","boolean","undefined"],n=typeof t;if(n!==typeof e)return!1;for(const s of r)if(s===n)return t===e;if(t==null&&e==null)return!0;if(t==null||e==null||t.length!==e.length)return!1;const o=Array.isArray(t),a=Array.isArray(e);if(o!==a)return!1;if(o&&a){for(let s=0;s<t.length;s++)if(!Tr(t[s],e[s]))return!1}else{const s=Object.keys(t).sort(),u=Object.keys(e).sort();if(!Tr(s,u))return!1;let l=!0;return Object.keys(t).forEach(c=>{Tr(t[c],e[c])||(l=!1)}),l}return!0},uc="$set",lc="$unset",cc="$clearAll";Object.entries||(Object.entries=function(t){const e=Object.keys(t);let r=e.length;const n=new Array(r);for(;r--;)n[r]=[e[r],t[e[r]]];return n});let dc=class{constructor(){this.identity={userProperties:{}},this.listeners=new Set}editIdentity(){const e=this,r=Object.assign({},this.identity.userProperties),n=Object.assign(Object.assign({},this.identity),{userProperties:r});return{setUserId:function(i){return n.userId=i,this},setDeviceId:function(i){return n.deviceId=i,this},setUserProperties:function(i){return n.userProperties=i,this},setOptOut(i){return n.optOut=i,this},updateUserProperties:function(i){let o=n.userProperties||{};for(const[a,s]of Object.entries(i))switch(a){case uc:for(const[u,l]of Object.entries(s))o[u]=l;break;case lc:for(const u of Object.keys(s))delete o[u];break;case cc:o={};break}return n.userProperties=o,this},commit:function(){return e.setIdentity(n),this}}}getIdentity(){return Object.assign({},this.identity)}setIdentity(e){const r=Object.assign({},this.identity);this.identity=Object.assign({},e),Tr(r,this.identity)||this.listeners.forEach(n=>{n(e)})}addIdentityListener(e){this.listeners.add(e)}removeIdentityListener(e){this.listeners.delete(e)}};const Ut=typeof globalThis<"u"?globalThis:typeof global<"u"?global:self;let fc=class es{constructor(){this.identityStore=new dc,this.eventBridge=new sc,this.applicationContextProvider=new oc}static getInstance(e){return Ut.analyticsConnectorInstances||(Ut.analyticsConnectorInstances={}),Ut.analyticsConnectorInstances[e]||(Ut.analyticsConnectorInstances[e]=new es),Ut.analyticsConnectorInstances[e]}};var Qt=function(t){return fc.getInstance(Ja(t))},vc=function(t,e){Qt(e).identityStore.editIdentity().setUserId(t).commit()},hc=function(t,e){Qt(e).identityStore.editIdentity().setDeviceId(t).commit()},gc=(function(){function t(){this.name="identity",this.type="before",this.identityStore=Qt().identityStore}return t.prototype.execute=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){return r=e.user_properties,r&&this.identityStore.editIdentity().updateUserProperties(r).commit(),[2,e]})})},t.prototype.setup=function(e){return I(this,void 0,void 0,function(){return _(this,function(r){return e.instanceName&&(this.identityStore=Qt(e.instanceName).identityStore),[2]})})},t})(),ts=function(t,e){e===void 0&&(e=Date.now());var r=Date.now(),n=r-e;return n>t},rs=function(t,e,r){return e===void 0&&(e=""),r===void 0&&(r=10),[Vr,e,t.substring(0,r)].filter(
5Boolean).join("_")},pc=function(t){return"".concat(Vr.toLowerCase(),"_").concat(t.substring(0,6))},mc=function(){var t,e,r,n;if(typeof navigator>"u")return"";var i=navigator.userLanguage;return(n=(r=(e=(t=navigator.languages)===null||t===void 0?void 0:t[0])!==null&&e!==void 0?e:navigator.language)!==null&&r!==void 0?r:i)!==null&&n!==void 0?n:""},Lr=function(){var t,e=z();if(!(!((t=e?.location)===null||t===void 0)&&t.search))return{};var r=e.location.search.substring(1).split("&").filter(Boolean),n=r.reduce(function(i,o){var a=o.split("=",2),s=oo(a[0]),u=oo(a[1]);return u&&(i[s]=u),i},{});return n},oo=function(t){t===void 0&&(t="");try{return decodeURIComponent(t)}catch{return""}},Vn=function(t,e){return!e||!e.length?!0:e.some(function(r){return typeof r=="string"?t===r:t.match(r)})},Se=function(t,e){var r=t;try{r=decodeURI(t)}catch(n){e?.error("Malformed URI sequence: ",n)}return r},yc=function(t){var e=0;if(t.length===0)return e;for(var r=0;r<t.length;r++){var n=t.charCodeAt(r);e=(e<<5)-e+n,e|=0}return e},ao=function(t,e){var r=yc(t.toString()),n=Math.abs(r),i=n*31,o=i%1e5;return o/1e5<e},ns=function(t){var e={};for(var r in t){var n=t[r];n&&(e[r]=n)}return e},yi=(function(){function t(){this.memoryStorage=new Map}return t.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){return _(this,function(e){return[2,!0]})})},t.prototype.get=function(e){return I(this,void 0,void 0,function(){return _(this,function(r){return[2,this.memoryStorage.get(e)]})})},t.prototype.getRaw=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return r=n.sent(),[2,r?JSON.stringify(r):void 0]}})})},t.prototype.set=function(e,r){return I(this,void 0,void 0,function(){return _(this,function(n){return this.memoryStorage.set(e,r),[2]})})},t.prototype.remove=function(e){return I(this,void 0,void 0,function(){return _(this,function(r){return this.memoryStorage.delete(e),[2]})})},t.prototype.reset=function(){return I(this,void 0,void 0,function(){return _(this,function(e){return this.memoryStorage.clear(),[2]})})},t})(),bc=function(){var t,e=z();return(t=e?.navigator)===null||t===void 0?void 0:t.locks},Dr=(function(){function t(e,r){r===void 0&&(r={}),this.options=C({},e),this.config=r}return t.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){var e,r,n,i,o=this;return _(this,function(a){switch(a.label){case 0:return e="AMP_TEST",r=C({},this.options),n=new t(r),i=String(Date.now()),[4,n.transaction(e,function(s){var u,l;try{s.set(i);var c=s.get(),f=c===i;return!f&&o.config.diagnosticsClient&&((u=o.config.diagnosticsClient)===null||u===void 0||u.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:e,testValue:i,sync:!0})),f}catch(v){if(o.config.diagnosticsClient){var d=v instanceof Error?v.message:String(v);(l=o.config.diagnosticsClient)===null||l===void 0||l.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:e,testValue:i,error:d,sync:!0})}return!1}finally{s.set(null)}})];case 1:return[2,a.sent()]}})})},t.prototype.get=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return r=n.sent(),[2,this.decodeCookieValue(e,r)]}})})},t.prototype.decodeCookieValue=function(e,r){if(r)try{var n=is(r);if(n===void 0){console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(r));return}return JSON.parse(n)}catch{console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(r));return}},t.prototype.getSync=function(e){var r=this.getRawSync(e);return this.decodeCookieValue(e,r)},t.prototype.getRaw=function(e){var r,n;return I(this,void 0,void 0,function(){var i,o,a,s,u,l,c,f,d;return _(this,function(v){switch(v.label){case 0:i=z(),o=i,v.label=1;case 1:return v.trys.push([1,4,,5]),a=o?.cookieStore,a?[4,a.getAll(e)]:[3,3];case 2:if(s=v.sent(),s){s.length>1&&((r=this.config.diagnosticsClient)===null||r===void 0||r.recordEvent("cookies.duplicate",{cookies:s.map(function(h){return h.domain})}),(n=this.config.diagnosticsClient)===null||n===void 0||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(u=L(s),l=u.next();!l.done;l=u.next())if(c=l.value,os(c.domain,this.options.domain))return[2,c.value]}catch(h){f={error:h}}finally{try{l&&!l.done&&(d=u.return)&&d.call(u)}finally{if(f)throw f.error}}}v.label=3;case 3:return[3,5];case 4:return v.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},t.prototype.getRawSync=function(e){var r=this,n,i,o=z(),a=((i=(n=o?.document)===null||n===void 0?void 0:n.cookie.split("; "))!==null&&i!==void 0?i:[]).filter(function(l){return l.indexOf(e+"=")===0}),s=void 0,u=this.config.duplicateResolverFn;
5if(typeof u=="function"&&a.length>1&&(s=a.find(function(l){var c;try{var f=u(l.substring(e.length+1));return f||(c=r.config.diagnosticsClient)===null||c===void 0||c.increment("cookies.duplicate.occurrence.document.cookie"),f}catch{return!1}})),s||(s=a[0]),!!s)return s.substring(e.length+1)},t.prototype.set=function(e,r){return I(this,void 0,void 0,function(){return _(this,function(n){return this.setSync(e,r),[2]})})},t.prototype.setSync=function(e,r){var n;try{var i=z();if(!i||!i.document||typeof i.btoa!="function"||typeof i.encodeURIComponent!="function")return;var o=(n=this.options.expirationDays)!==null&&n!==void 0?n:0,a=r!==null?o:-1,s=void 0;if(a){var u=new Date;u.setTime(u.getTime()+a*24*60*60*1e3),s=u}var l="".concat(e,"=").concat(i.btoa(i.encodeURIComponent(JSON.stringify(r))));s&&(l+="; expires=".concat(s.toUTCString())),l+="; path=/",this.options.domain&&(l+="; domain=".concat(this.options.domain)),this.options.secure&&(l+="; Secure"),this.options.sameSite&&(l+="; SameSite=".concat(this.options.sameSite)),i.document.cookie=l}catch(f){var c=f instanceof Error?f.message:String(f);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(c))}},t.prototype.remove=function(e){return I(this,void 0,void 0,function(){return _(this,function(r){switch(r.label){case 0:return[4,this.set(e,null)];case 1:return r.sent(),[2]}})})},t.prototype.reset=function(){return I(this,void 0,void 0,function(){return _(this,function(e){return[2]})})},t.isDomainWritable=function(e){return I(this,void 0,void 0,function(){var r,n,i,o;return _(this,function(a){switch(a.label){case 0:if(t.cachedTlds[e])return[2,!0];r={domain:"."+e},n="AMP_TLDTEST",i=new t(r),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,i.transaction(n,function(s){if(t.cachedTlds[e])return!0;try{s.set(1);var u=!!s.get();return u&&(t.cachedTlds[e]=!0),u}finally{s.set(null)}})];case 2:return o=a.sent(),[2,!!o];case 3:return a.sent(),[2,!1];case 4:return[2]}})})},t.prototype.transaction=function(e,r){return I(this,void 0,void 0,function(){var n,i,o=this;return _(this,function(a){switch(a.label){case 0:if(n=bc(),i=function(){var s={get:function(){return o.getSync(e)},set:function(u){return o.setSync(e,u)}};return r(s)},!n)return[2,i()];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),i)];case 2:return[2,a.sent()];case 3:return a.sent(),[2,i()];case 4:return[2]}})})},t.cachedTlds={},t})(),Ec=function(t){try{return decodeURIComponent(atob(t))}catch{return}},Sc=function(t){try{return decodeURIComponent(atob(decodeURIComponent(t)))}catch{return}},is=function(t){var e;return(e=Ec(t))!==null&&e!==void 0?e:Sc(t)},os=function(t,e){if(t===""&&e==="")return!0;if(!t||!e)return!1;var r=t.startsWith(".")?t.substring(1):t,n=e.startsWith(".")?e.substring(1):e;return r.toLowerCase()===n.toLowerCase()},so=function(t,e,r){return e===void 0&&(e=""),r===void 0&&(r=10),[Vr,e,t.substring(0,r)].filter(Boolean).join("_")},Hr=(function(){function t(e){this.storage=e}return t.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){var e,r,n,i;return _(this,function(o){switch(o.label){case 0:if(!this.storage)return[2,!1];e=String(Date.now()),r=new t(this.storage),n="AMP_TEST",o.label=1;case 1:return o.trys.push([1,4,5,7]),[4,r.set(n,e)];case 2:return o.sent(),[4,r.get(n)];case 3:return i=o.sent(),[2,i===e];case 4:return o.sent(),[2,!1];case 5:return[4,r.remove(n)];case 6:return o.sent(),[7];case 7:return[2]}})})},t.prototype.get=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return r=n.sent(),r?[2,JSON.parse(r)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},t.prototype.getRaw=function(e){var r;return I(this,void 0,void 0,function(){return _(this,function(n){return[2,((r=this.storage)===null||r===void 0?void 0:r.getItem(e))||void 0]})})},t.prototype.set=function(e,r){var n;return I(this,void 0,void 0,function(){return _(this,function(i){try{(n=this.storage)===null||n===void 0||n.setItem(e,JSON.stringify(r))}catch{}return[2]})})},t.prototype.remove=function(e){var r;return I(this,void 0,void 0,function(){return _(this,function(n){try{(r=this.storage)===null||r===void 0||r.removeItem(e)}catch{}return[2]})})},t.prototype.reset=function(){var e;return I(this,void 0,void 0,function(){return _(this,function(r){try{(e=this.storage)===null||e===void 0||e.clear()}catch{}return[2]})})},t})(),Tc=10,_c=1,te={TAGS:"tags",COUNTERS:"counters",HISTOGRAMS:"histograms",EVENTS:"events",INTERNAL:"internal"}
5,uo={LAST_FLUSH_TIMESTAMP:"last_flush_timestamp"},lo=(function(){function t(e,r){this.dbPromise=null,this.logger=r,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return t.isSupported=function(){var e;return((e=z())===null||e===void 0?void 0:e.indexedDB)!==void 0},t.prototype.getDB=function(){return I(this,void 0,void 0,function(){return _(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},t.prototype.openDB=function(){var e=this;return new Promise(function(r,n){var i=indexedDB.open(e.dbName,_c);i.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},i.onsuccess=function(){var o=i.result;o.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},o.onerror=function(a){e.logger.debug("DiagnosticsStorage: A global database error occurred.",a),o.close()},r(o)},i.onupgradeneeded=function(){var o=i.result;if(!o){e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.");return}e.createTables(o)}})},t.prototype.createTables=function(e){if(e.objectStoreNames.contains(te.TAGS)||e.createObjectStore(te.TAGS,{keyPath:"key"}),e.objectStoreNames.contains(te.COUNTERS)||e.createObjectStore(te.COUNTERS,{keyPath:"key"}),e.objectStoreNames.contains(te.HISTOGRAMS)||e.createObjectStore(te.HISTOGRAMS,{keyPath:"key"}),!e.objectStoreNames.contains(te.EVENTS)){var r=e.createObjectStore(te.EVENTS,{keyPath:"id",autoIncrement:!0});r.createIndex("time_idx","time",{unique:!1})}e.objectStoreNames.contains(te.INTERNAL)||e.createObjectStore(te.INTERNAL,{keyPath:"key"})},t.prototype.setTags=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a=this;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([te.TAGS],"readwrite"),i=n.objectStore(te.TAGS),[2,new Promise(function(u){var l=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(c){a.logger.debug("DiagnosticsStorage: Failed to set tags",c),u()},l.forEach(function(c){var f=D(c,2),d=f[0],v=f[1],h=i.put({key:d,value:v});h.onerror=function(g){a.logger.debug("DiagnosticsStorage: Failed to set tag",d,v,g)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",o),[3,3];case 3:return[2]}})})},t.prototype.incrementCounters=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a=this;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([te.COUNTERS],"readwrite"),i=n.objectStore(te.COUNTERS),[2,new Promise(function(u){var l=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(c){a.logger.debug("DiagnosticsStorage: Failed to increment counters",c),u()},l.forEach(function(c){var f=D(c,2),d=f[0],v=f[1],h=i.get(d);h.onsuccess=function(){var g=h.result,m=g?g.value:0,p=i.put({key:d,value:m+v});p.onerror=function(y){a.logger.debug("DiagnosticsStorage: Failed to update counter",d,y)}},h.onerror=function(g){a.logger.debug("DiagnosticsStorage: Failed to read existing counter",d,g)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",o),[3,3];case 3:return[2]}})})},t.prototype.setHistogramStats=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a=this;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([te.HISTOGRAMS],"readwrite"),i=n.objectStore(te.HISTOGRAMS),[2,new Promise(function(u){var l=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(c){a.logger.debug("DiagnosticsStorage: Failed to set histogram stats",c),u()},l.forEach(function(c){var f=D(c,2),d=f[0],v=f[1],h=i.get(d);h.onsuccess=function(){var g=h.result,m;g?m={key:d,count:g.count+v.count,min:Math.min(g.min,v.min),max:Math.max(g.max,v.max),sum:g.sum+v.sum}:m={key:d,count:v.count,min:v.min,max:v.max,sum:v.sum};var p=i.put(m);p.onerror=function(y){a.logger.debug("DiagnosticsStorage: Failed to set histogram stats",d,y)}},h.onerror=function(g){a.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",d,g)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",o),[3,3];case 3:return[2]}})})},t.prototype.addEventRecords=function(e){return I(this,void 0,void 0,function(){var r,n,i,o,a=this;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e.length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([te.EVENTS],"readwrite"),i=n.objectStore(te.
5EVENTS),[2,new Promise(function(u){n.oncomplete=function(){u()},n.onabort=function(c){a.logger.debug("DiagnosticsStorage: Failed to add event records",c),u()};var l=i.count();l.onsuccess=function(){var c=l.result,f=Math.max(0,Tc-c);f<e.length&&a.logger.debug("DiagnosticsStorage: Only added ".concat(f," of ").concat(e.length," events due to storage limit")),e.slice(0,f).forEach(function(d){var v=i.add(d);v.onerror=function(h){a.logger.debug("DiagnosticsStorage: Failed to add event record",h)}})},l.onerror=function(c){a.logger.debug("DiagnosticsStorage: Failed to count existing events",c)}})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",o),[3,3];case 3:return[2]}})})},t.prototype.setInternal=function(e,r){return I(this,void 0,void 0,function(){var n,i,o,a;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=s.sent(),i=n.transaction([te.INTERNAL],"readwrite"),o=i.objectStore(te.INTERNAL),[2,new Promise(function(u,l){i.onabort=function(){return l(new Error("Failed to set internal value"))};var c=o.put({key:e,value:r});c.onsuccess=function(){return u()},c.onerror=function(){return l(new Error("Failed to set internal value"))}})];case 2:return a=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",a),[3,3];case 3:return[2]}})})},t.prototype.getInternal=function(e){return I(this,void 0,void 0,function(){var r,n,i,o;return _(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return r=a.sent(),n=r.transaction([te.INTERNAL],"readonly"),i=n.objectStore(te.INTERNAL),[2,new Promise(function(s,u){n.onabort=function(){return u(new Error("Failed to get internal value"))};var l=i.get(e);l.onsuccess=function(){return s(l.result)},l.onerror=function(){return u(new Error("Failed to get internal value"))}})];case 2:return o=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",o),[2,void 0];case 3:return[2]}})})},t.prototype.getLastFlushTimestamp=function(){return I(this,void 0,void 0,function(){var e,r;return _(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(uo.LAST_FLUSH_TIMESTAMP)];case 1:return e=n.sent(),[2,e?parseInt(e.value,10):void 0];case 2:return r=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",r),[2,void 0];case 3:return[2]}})})},t.prototype.setLastFlushTimestamp=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(uo.LAST_FLUSH_TIMESTAMP,e.toString())];case 1:return n.sent(),[3,3];case 2:return r=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",r),[3,3];case 3:return[2]}})})},t.prototype.clearTable=function(e,r){return new Promise(function(n,i){var o=e.objectStore(r),a=o.clear();a.onsuccess=function(){return n()},a.onerror=function(){return i(new Error("Failed to clear table ".concat(r)))}})},t.prototype.getAllAndClear=function(){return I(this,void 0,void 0,function(){var e,r,n,i,o,a,s,u;return _(this,function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=l.sent(),r=e.transaction([te.TAGS,te.COUNTERS,te.HISTOGRAMS,te.EVENTS],"readwrite"),[4,Promise.all([this.getAllFromStore(r,te.TAGS),this.getAllFromStore(r,te.COUNTERS),this.getAllFromStore(r,te.HISTOGRAMS),this.getAllFromStore(r,te.EVENTS)])];case 2:return n=D.apply(void 0,[l.sent(),4]),i=n[0],o=n[1],a=n[2],s=n[3],[4,Promise.all([this.clearTable(r,te.COUNTERS),this.clearTable(r,te.HISTOGRAMS),this.clearTable(r,te.EVENTS)])];case 3:return l.sent(),[2,{tags:i,counters:o,histogramStats:a,events:s}];case 4:return u=l.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",u),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},t.prototype.getAllFromStore=function(e,r){return new Promise(function(n,i){var o=e.objectStore(r),a=o.getAll();a.onsuccess=function(){return n(a.result)},a.onerror=function(){return i(new Error("Failed to get all from ".concat(r)))}})},t}
5)(),Ic="__AMPLITUDE_SCRIPT_URL__",wc="sdk.error.uncaught",Cc=function(){var t=z();if(!t)return[];var e=t[Ic];return Array.isArray(e)?e:typeof e=="string"?[e]:[]},Pc=function(t){var e=z();if(!(!e||typeof e.addEventListener!="function")){var r=function(o){var a=o.error instanceof Error?o.error:void 0,s=a?.stack,u=co({filename:o.filename,stack:s});u&&i({type:"error",message:o.message,stack:s,filename:o.filename,errorName:a?.name,metadata:{colno:o.colno,lineno:o.lineno,isTrusted:o.isTrusted,matchReason:u}})},n=function(o){var a,s=o.reason instanceof Error?o.reason:void 0,u=s?.stack,l=Ac(u),c=co({filename:l,stack:u});c&&i({type:"unhandledrejection",message:(a=s?.message)!==null&&a!==void 0?a:kc(o.reason),stack:u,filename:l,errorName:s?.name,metadata:{isTrusted:o.isTrusted,matchReason:c}})},i=function(o){t.recordEvent(wc,C({type:o.type,message:o.message,filename:o.filename,error_name:o.errorName,stack:o.stack},o.metadata))};e.addEventListener("error",r,!0),e.addEventListener("unhandledrejection",n,!0)}},co=function(t){var e,r,n=Cc();if(n.length!==0)try{for(var i=L(n),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.filename&&t.filename.includes(a))return"filename";if(t.stack&&t.stack.includes(a))return"stack"}}catch(s){e={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}},Ac=function(t){if(t){var e=t.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return e?e[1]:void 0}},kc=function(t){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return"[object Object]"}},Rc=1e3,sr=300*1e3,Oc="https://diagnostics.prod.us-west-2.amplitude.com/v1/capture",Lc="https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",rn=1e4,Dc=10,xc=(function(){function t(e,r,n,i,o){n===void 0&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=r,this.serverUrl=n==="US"?Oc:Lc,this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(i,null,2)),this.config=C({enabled:!0,sampleRate:0},i),this.startTimestamp=Date.now(),this.shouldTrack=ao(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,o?this.storage=o:lo.isSupported()?this.storage=new lo(e,r):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),Pc(this))}return t.prototype.isStorageAndTrackEnabled=function(){return!!this.storage&&!!this.shouldTrack},t.prototype.setTag=function(e,r){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryTags).length>=rn){this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit");return}this.inMemoryTags[e]=r,this.startTimersIfNeeded()}},t.prototype.increment=function(e,r){if(r===void 0&&(r=1),!!this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryCounters).length>=rn){this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit");return}this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+r,this.startTimersIfNeeded()}},t.prototype.recordHistogram=function(e,r){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryHistograms).length>=rn){this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");return}var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,r),n.max=Math.max(n.max,r),n.sum+=r):this.inMemoryHistograms[e]={count:1,min:r,max:r,sum:r},this.startTimersIfNeeded()}},t.prototype.recordEvent=function(e,r){if(this.isStorageAndTrackEnabled()){if(this.inMemoryEvents.length>=Dc){this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit");return}this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:r}),this.startTimersIfNeeded()}},t.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout(function(){e.saveAllDataToStorage().catch(function(r){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",r)}).finally(function(){e.saveTimer=null})},Rc)),this.flushTimer||(this.flushTimer=setTimeout(function(){e._flush().catch(function(r){e.logger.debug("DiagnosticsClient: Failed to flush",r)}).finally(function(){e.flushTimer=null})},sr))},t.prototype.saveAllDataToStorage=function(){return I(this,void 0,void 0,function(){var e,r,n,i;return _(this,function(o){switch(o.label){case 0:return this.storage?(e=C({},this.inMemoryTags),r=C({},this.inMemoryCounters),n=C({},this.inMemoryHistograms),i=W([],D(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(r),this.storage.setHistogramStats(n),this.storage.addEventRecords(i)])]):[2];case 1:return o.sent(),[2]}})})},t.prototype._flush=function(){return I(this,void 0,void 0,function(){var e,r,n,i,o,a,s,u,l,c;return _(this,function(f){switch(f.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return f.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=f.sent(),r=e.tags,n=e.counters,i=e.histogramStats,o=e.events,this.storage.setLastFlushTimestamp(Date.now()),a={},r.forEach(function(d){a[d.key]=d.value}),s={}
5,n.forEach(function(d){s[d.key]=d.value}),u={},i.forEach(function(d){u[d.key]={count:d.count,min:d.min,max:d.max,avg:Math.round(d.sum/d.count*100)/100}}),l=o.map(function(d){return{event_name:d.event_name,time:d.time,event_properties:d.event_properties}}),Object.keys(s).length===0&&Object.keys(u).length===0&&l.length===0?[2]:(c={tags:a,histogram:u,counters:s,events:l},this.fetch(c),[2])}})})},t.prototype.fetch=function(e){return I(this,void 0,void 0,function(){var r,n;return _(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!z())throw new 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:return r=i.sent(),r.ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return n=i.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",n),[3,3];case 3:return[2]}})})},t.prototype.initializeFlushInterval=function(){return I(this,void 0,void 0,function(){var e,r,n;return _(this,function(i){switch(i.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return r=i.sent()||-1,r===-1?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(sr),[2]):(n=e-r,n>=sr?(this._flush(),[2]):(this._setFlushTimer(sr-n),[2]))}})})},t.prototype._setFlushTimer=function(e){var r=this;this.flushTimer=setTimeout(function(){r._flush().catch(function(n){r.logger.debug("DiagnosticsClient: Failed to flush",n)}).finally(function(){r.flushTimer=null})},e)},t.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=ao(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},t})(),bi=(function(){function t(){}return t.prototype.send=function(e,r,n){return Promise.resolve(null)},t.prototype.buildResponse=function(e){var r,n,i,o,a,s,u,l,c,f,d,v,h,g,m,p,y,b,E,S,T,w;if(typeof e!="object")return null;var P=e.code||0,A=this.buildStatus(P);switch(A){case fe.Success:return{status:A,statusCode:P,body:{eventsIngested:(r=e.events_ingested)!==null&&r!==void 0?r:0,payloadSizeBytes:(n=e.payload_size_bytes)!==null&&n!==void 0?n:0,serverUploadTime:(i=e.server_upload_time)!==null&&i!==void 0?i:0}};case fe.Invalid:return{status:A,statusCode:P,body:{error:(o=e.error)!==null&&o!==void 0?o:"",missingField:(a=e.missing_field)!==null&&a!==void 0?a:"",eventsWithInvalidFields:(s=e.events_with_invalid_fields)!==null&&s!==void 0?s:{},eventsWithMissingFields:(u=e.events_with_missing_fields)!==null&&u!==void 0?u:{},eventsWithInvalidIdLengths:(l=e.events_with_invalid_id_lengths)!==null&&l!==void 0?l:{},epsThreshold:(c=e.eps_threshold)!==null&&c!==void 0?c:0,exceededDailyQuotaDevices:(f=e.exceeded_daily_quota_devices)!==null&&f!==void 0?f:{},silencedDevices:(d=e.silenced_devices)!==null&&d!==void 0?d:[],silencedEvents:(v=e.silenced_events)!==null&&v!==void 0?v:[],throttledDevices:(h=e.throttled_devices)!==null&&h!==void 0?h:{},throttledEvents:(g=e.throttled_events)!==null&&g!==void 0?g:[]}};case fe.PayloadTooLarge:return{status:A,statusCode:P,body:{error:(m=e.error)!==null&&m!==void 0?m:""}};case fe.RateLimit:return{status:A,statusCode:P,body:{error:(p=e.error)!==null&&p!==void 0?p:"",epsThreshold:(y=e.eps_threshold)!==null&&y!==void 0?y:0,throttledDevices:(b=e.throttled_devices)!==null&&b!==void 0?b:{},throttledUsers:(E=e.throttled_users)!==null&&E!==void 0?E:{},exceededDailyQuotaDevices:(S=e.exceeded_daily_quota_devices)!==null&&S!==void 0?S:{},exceededDailyQuotaUsers:(T=e.exceeded_daily_quota_users)!==null&&T!==void 0?T:{},throttledEvents:(w=e.throttled_events)!==null&&w!==void 0?w:[]}};case fe.Timeout:default:return{status:A,statusCode:P}}},t.prototype.buildStatus=function(e){return qn(e)?fe.Success:e===429?fe.RateLimit:e===413?fe.PayloadTooLarge:e===408?fe.Timeout:e>=400&&e<500?fe.Invalid:e>=500?fe.Failed:fe.Unknown},t})(),as=2*1024;function ss(){return typeof CompressionStream<"u"}function us(t){return I(this,void 0,void 0,function(){var e,r;return _(this,function(n){switch(n.label){case 0:if(e=CompressionStream,typeof e>"u")return[2,void 0];n.label=1;case 1:return n.trys.push([1,3,,4]),r=new Blob([t]).stream().pipeThrough(new e("gzip")),[4,new Response(r).arrayBuffer()];case 2:return[2,n.sent()];case 3:return n.sent(),[2,void 0];case 4:return[2]}})})}var Mc=(function(){function t(e,r){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=r;try{this.isSupported=typeof localStorage<"u"}catch(n){this.logger.debug("Remote config localstorage failed to access: ",n),this.isSupported=!1}}return t.prototype.fetchConfig=function(){var e=null,r={remoteConfig:null,lastFetch:new Date};if(!this.isSupported)return Promise.resolve(r);try{e=localStorage.getItem(this.key)}catch(i){return this.logger.debug("Remote config localstorage failed to access: ",i),Promise.resolve(r)}if(e===null)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(r);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(Ge(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(i){return this.logger.debug("Remote config localstorage failed to parse: ",i),localStorage.removeItem(this.key),Promise.resolve(r)}},t.prototype.setConfig=function(e){if(!this.isSupported)return Promise.resolve(!1);try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(r){this.logger.debug("Remote config localstorage failed to set: ",r)}return Promise.resolve(!1)},t})();function Nc(t,e){return new Promise(function(r,n){var i=function(){var o=new Error("Remote config custom fetch aborted by timeout");o.name="AbortError",n(o)};e.addEventListener("abort",i,{once:!0}),t.then(function(o){e.removeEventListener("abort",i),r(o)},function(o){e.removeEventListener("abort",i),n(o)})})}var Uc="https://sr-client-cfg.amplitude.com/config",Fc="https://sr-client-cfg.eu.amplitude.com/config",Bc=3,nn={INVALID_API_KEY:401,FORB
5IDDEN:403,RATE_LIMIT:429},qc=1e3,Vc=300*1e3,Wc=(function(){function t(e,r,n,i,o,a,s){n===void 0&&(n="US"),a===void 0&&(a=t.DEFAULT_CONFIG_GROUP),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.configGroup=a,this.serverUrl=i||(n==="US"?Uc:Fc),this.logger=r,this.storage=s||new Mc(e,r),this.customFetch=o}return t.prototype.subscribe=function(e,r,n){var i=Ue(),o={id:i,key:e,deliveryMode:r,callback:n};return this.callbackInfos.push(o),r==="all"?this.subscribeAll(o):this.subscribeWaitForRemote(o,r.timeout),i},t.prototype.unsubscribe=function(e){var r=this.callbackInfos.findIndex(function(n){return n.id===e});return r===-1?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(r,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},t.prototype.updateConfigs=function(){return I(this,void 0,void 0,function(){var e,r,n=this;return _(this,function(i){switch(i.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<Vc)?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return r=i.sent(),this.storage.setConfig(r),this.callbackInfos.forEach(function(o){n.sendCallback(o,r,"remote")}),[2]}})})},t.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?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.fetchPromise=this.fetch().then(function(r){return r.remoteConfig!==null&&(e.lastSuccessfulFetch=Date.now()),r}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},t.prototype.subscribeAll=function(e){return I(this,void 0,void 0,function(){var r,n,i,o=this;return _(this,function(a){switch(a.label){case 0:return r=this.getOrCreateFetchPromise().then(function(s){o.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(s))),o.sendCallback(e,s,"remote"),o.storage.setConfig(s)}),n=this.storage.fetchConfig().then(function(s){return s}),[4,Promise.race([r,n])];case 1:return i=a.sent(),i!==void 0&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(i))),i.remoteConfig!==null?this.sendCallback(e,i,"cache"):this.logger.debug("Remote config client skips sending c
5allback because cache is empty (first time user).")),[4,r];case 2:return a.sent(),[2]}})})},t.prototype.subscribeWaitForRemote=function(e,r){return I(this,void 0,void 0,function(){var n,i,i;return _(this,function(o){switch(o.label){case 0:n=new Promise(function(a,s){setTimeout(function(){s("Timeout exceeded")},r)}),o.label=1;case 1:return o.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return i=o.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,i,"remote"),this.storage.setConfig(i),[3,5];case 3:return o.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 i=o.sent(),i.remoteConfig!==null?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,i,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,i,"remote")),[3,5];case 5:return[2]}})})},t.prototype.sendCallback=function(e,r,n){e.lastCallback=new Date;var i;e.key?i=e.key.split(".").reduce(function(o,a){return o===null?o:a in o?o[a]:null},r.remoteConfig):i=r.remoteConfig,e.callback(i,n,r.lastFetch)},t.prototype.fetch=function(e,r){return e===void 0&&(e=Bc),r===void 0&&(r=qc),I(this,void 0,void 0,function(){var n,i,o,a,s,u,l=this;return _(this,function(c){switch(c.label){case 0:n=r/e,i={remoteConfig:null,lastFetch:new Date},o=function(f){var d,v,h,g,m,p,y,b,E,S,T;return _(this,function(w){switch(w.label){case 0:d=!0,v=new AbortController,h=setTimeout(function(){return v.abort()},r),w.label=1;case 1:return w.trys.push([1,10,11,12]),g=a.getUrlParams(),m={Accept:"*/*"},a.customFetch?[4,Nc(a.customFetch({url:g,method:"GET",headers:m,signal:v.signal}),v.signal)]:[3,3];case 2:return y=w.sent(),[3,5];case 3:return[4,fetch(g,{method:"GET",headers:m,signal:v.signal})];case 4:y=w.sent(),w.label=5;case 5:return p=y,b=p.ok||p.status>=200&&p.status<300,b?[3,7]:[4,p.text()];case 6:return E=w.sent(),a.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(p.status,": ").concat(E)),p.status===nn.INVALID_API_KEY||p.status===nn.FORBIDDEN?(a.logger.error("Remote config client fetch failed with ".concat(p.status,". Invalid API key; future fetches will be skipped.")),a.isLastFetchInvalidApiKey=!0,d=!1):p.status>=400&&p.status<500&&p.status!==nn.RATE_LIMIT&&(d=!1),[3,9];case 7:return[4,p.json()];case 8:return S=w.sent(),[2,{value:{remoteConfig:S,lastFetch:new Date}}];case 9:return[3,12];case 10:return T=w.sent(),T instanceof Error&&T.name==="AbortError"?a.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(r,"ms")):a.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),T),[3,12];case 11:return clearTimeout(h),[7];case 12:return d?f<e-1?[4,new Promise(function(P){return setTimeout(P,l.getJitterDelay(n))})]:[3,14]:[2,"break"];case 13:w.sent(),w.label=14;case 14:return[2]}})},a=this,s=0,c.label=1;case 1:return s<e?[5,o(s)]:[3,4];case 2:if(u=c.sent(),typeof u=="object")return[2,u.value];if(u==="break")return[3,4];c.label=3;case 3:return s++,[3,1];case 4:return[2,i]}})})},t.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},t.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),r=new URLSearchParams;return r.append("config_group",this.configGroup),"".concat(this.serverUrl,"/").concat(e,"?").concat(r.toString())},t.DEFAULT_CONFIG_GROUP="browser",t})(),on=z(),bt=on?.console,st={},jt={},an=!1;function Hc(t){if(!bt||typeof bt[t]!="function")return!1;if(jt[t])return!0;var e=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{if(st[t]&&!an){an=!0;var i=st[t];i&&i.forEach(function(o){try{o(t,r)}catch{}})}}catch{}return an=!1,jt[t].apply(bt,r)};return jt[t]=bt[t],bt[t]=e,!0}function Gc(t,e){var r=Hc(t);if(!r)return new Error("Console override failed");st[t]?st[t].push(e):st[t]=[e]}function jc(t){var e,r;try{for(var n=L(Object.values(st)),i=n.next();!i.done;i=n.next())for(var o=i.value,a=o.length-1;a>=0;a--)if(o[a]===t){o.splice(a,1);break}}catch(s){e={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}function zc(){var t,e;try{for(var r=L(Object.entries(jt)),n=r.next();!n.done;n=r.next()){var i=D(n.value,2),o=i[0],a=i[1];a&&(bt[o]=a)}}catch(s){t={error:s}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}jt={},st={}}var fo={addListener:Gc,removeListener:jc,_restoreConsole:zc},$c=null,Kc=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],ls="data-amp-track-",Xc=["div","span","h1","h2","h3","h4","h5","h6"],cs=150,Yc=["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]'],ds=W(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],D(Yc),!1),Qc=ds,Jc=ds,Zc=["*"],ed=1e3,td=4,rd=50;
5function nd(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null||t===void 0}function fs(t,e,r){if(t){var n=e.map(vo),i=r.map(vo);vs({json:t,allowlist:n,excludelist:i,ancestors:[]})}}function vs(t){var e,r,n=t.json,i=t.targetObject,o=t.allowlist,a=t.excludelist,s=t.ancestors,u=t.parentObject,l=t.targetKey;i||(i=n);var c=Object.keys(i);try{for(var f=L(c),d=f.next();!d.done;d=f.next()){var v=d.value,h=W(W([],D(s),!1),[v],!1);nd(i[v])?(!ho(h,o)||ho(h,a))&&delete i[v]:vs({json:n,targetObject:i[v],allowlist:o,excludelist:a,ancestors:h,parentObject:i,targetKey:v})}}catch(g){e={error:g}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}Object.keys(i).length===0&&u&&l&&delete u[l]}function vo(t){return t.startsWith("/")&&(t=t.slice(1)),t.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function Wn(t,e,r,n){if(r===void 0&&(r=0),n===void 0&&(n=0),n===e.length)return r===t.length;if(r===t.length){for(;n<e.length&&e[n]==="**";)n++;return n===e.length}var i=e[n];if(i==="**"){if(n+1===e.length)return!0;for(var o=r;o<=t.length;o++)if(Wn(t,e,o,n+1))return!0;return!1}else return i==="*"||i===t[r]?Wn(t,e,r+1,n+1):!1}function ho(t,e){return e.some(function(r){return Wn(t,r)})}var id=500,hs=100,od=(function(){function t(e){this.request=e}return t.prototype.headers=function(e){var r,n;e===void 0&&(e=[]);var i=this.request.headers,o={};if(Array.isArray(i))i.forEach(function(f){var d=D(f,2),v=d[0],h=d[1];o[v]=h});else if(i instanceof Headers)i.forEach(function(f,d){o[d]=f});else if(typeof i=="object"&&i!==null)try{for(var a=L(Object.entries(i)),s=a.next();!s.done;s=a.next()){var u=D(s.value,2),l=u[0],c=u[1];o[l]=c}}catch(f){r={error:f}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return Gr(o,{allow:e})},Object.defineProperty(t.prototype,"bodySize",{get:function(){if(typeof this._bodySize=="number")return this._bodySize;var e=z();if(e?.TextEncoder){var r=this.request.body;return this._bodySize=gs(r,hs),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return typeof this.request.body=="string"?this.request.body:null},enumerable:!1,configurable:!0}),t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),I(this,void 0,void 0,function(){var n;return _(this,function(i){return e.length===0?[2,null]:(n=this.body,[2,Ei(n,e,r)])})})},t})(),ad=(function(){function t(e,r){this.bodyRaw=e,this.requestHeaders=r}return t.prototype.headers=function(e){return e===void 0&&(e=[]),Gr(this.requestHeaders,{allow:e})},Object.defineProperty(t.prototype,"bodySize",{get:function(){return gs(this.bodyRaw,hs)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return typeof this.bodyRaw=="string"?this.bodyRaw:null},enumerable:!1,configurable:!0}),t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),I(this,void 0,void 0,function(){var n;return _(this,function(i){return e.length===0?[2,null]:(n=this.body,[2,Ei(n,e,r)])})})},t})();function gs(t,e){var r,n,i,o=z(),a=o?.TextEncoder;if(a&&t!=null){var s;if(typeof t=="string")s=t,i=new a().encode(s).length;else if(typeof Blob<"u"&&t instanceof Blob)s=t,i=s.size;else if(typeof URLSearchParams<"u"&&t instanceof URLSearchParams)s=t,i=new a().encode(s.toString()).length;else if(ArrayBuffer.isView(t))s=t,i=s.byteLength;else if(t instanceof ArrayBuffer)s=t,i=s.byteLength;else if(typeof FormData<"u"&&t instanceof FormData){var u=t,l=0,c=0;try{for(var f=L(u.entries()),d=f.next();!d.done;d=f.next()){var v=D(d.value,2),h=v[0],g=v[1];if(l+=h.length,typeof g=="string")l+=new a().encode(g).length;else if(typeof Blob<"u"&&g instanceof Blob)l+=g.size;else return;if(++c>=e)return}}catch(m){r={error:m}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}i=l}else if(typeof ReadableStream<"u"&&t instanceof ReadableStream){s=t;return}return i}}var sd=(function(){function t(e){this.response=e}return t.prototype.headers=function(e){var r;if(e===void 0&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,i={};return(r=n?.forEach)===null||r===void 0||r.call(n,function(o,a){i[a]=o}),Gr(i,{allow:e})}},Object.defineProperty(t.prototype,"bodySize",{get:function(){var e,r;if(this._bodySize!==void 0)return this._bodySize;var n=(r=(e=this.response.headers)===null||e===void 0?void 0:e.get)===null||r===void 0?void 0:r.call(e,"content-length"),i=n?parseInt(n,10):void 0;return this._bodySize=i,i}
5,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),t.prototype.text=function(){return I(this,void 0,void 0,function(){var e,r,n;return _(this,function(i){switch(i.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),i.label=1;case 1:return i.trys.push([1,3,,4]),e=this.clonedResponse.text(),r=new Promise(function(o){return setTimeout(function(){return o(null)},id)}),[4,Promise.race([e,r])];case 2:return n=i.sent(),[2,n];case 3:return i.sent(),[2,null];case 4:return[2]}})})},t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),I(this,void 0,void 0,function(){var n;return _(this,function(i){switch(i.label){case 0:return e.length===0?[2,null]:[4,this.text()];case 1:return n=i.sent(),[2,Ei(n,e,r)]}})})},t})(),ud=(function(){function t(e,r,n,i){this.statusCode=e,this.headersString=r,this.size=n,this.getJson=i}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),t.prototype.headers=function(e){var r,n;if(e===void 0&&(e=[]),!this.headersString)return{};var i={},o=this.headersString.split(`\r
6`);try{for(var a=L(o),s=a.next();!s.done;s=a.next()){var u=s.value,l=D(u.split(": "),2),c=l[0],f=l[1];c&&f&&(i[c]=f)}}catch(d){r={error:d}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return Gr(i,{allow:e})},t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),I(this,void 0,void 0,function(){var n;return _(this,function(i){return e.length===0?[2,null]:(n=this.getJson(),n?(fs(n,e,r),[2,n]):[2,null])})})},t})();function Ei(t,e,r){if(!t)return null;try{var n=JSON.parse(t);return fs(n,e,r),n}catch{return null}}var zt;(function(t){t.REDACT="redact",t.REMOVE="remove"})(zt||(zt={}));var go="[REDACTED]",Gr=function(t,e){var r,n,i=e.allow,o=i===void 0?[]:i,a=e.strategy,s=a===void 0?zt.REMOVE:a,u=W([],D(Ol),!1),l={},c=function(h){var g=h.toLowerCase();u.find(function(m){return m.toLowerCase()===g})?s===zt.REDACT&&(l[h]=go):o.find(function(m){return m.toLowerCase()===g})?l[h]=t[h]:s===zt.REDACT&&(l[h]=go)};try{for(var f=L(Object.keys(t)),d=f.next();!d.done;d=f.next()){var v=d.value;c(v)}}catch(h){r={error:h}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return l},ld=(function(){function t(e,r,n,i,o,a,s,u,l,c,f){s===void 0&&(s=0),this.type=e,this.method=r,this.timestamp=n,this.startTime=i,this.url=o,this.requestWrapper=a,this.status=s,this.duration=u,this.responseWrapper=l,this.error=c,this.endTime=f}return t.prototype.toSerializable=function(){var e,r,n,i,o={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:(e=this.requestWrapper)===null||e===void 0?void 0:e.headers(W([],D(Or),!1)),requestBodySize:(r=this.requestWrapper)===null||r===void 0?void 0:r.bodySize,responseHeaders:(n=this.responseWrapper)===null||n===void 0?void 0:n.headers(W([],D(Or),!1)),responseBodySize:(i=this.responseWrapper)===null||i===void 0?void 0:i.bodySize};return Object.fromEntries(Object.entries(o).filter(function(a){var s=D(a,2);s[0];var u=s[1];return u!==void 0}))},t})();function cd(t){return typeof t=="object"&&t!==null&&"url"in t&&"method"in t}var dd=(function(){function t(e,r){r===void 0&&(r=Ue()),this.callback=e,this.id=r}return t})();function et(t){try{t()}catch{}}var fd=(function(){function t(e){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=e;var r=z();t.isSupported()&&(this.globalScope=r)}return t.isSupported=function(){var e=z();return!!e&&!!e.fetch},t.prototype.subscribe=function(e,r){var n,i,o,a,s,u,l,c,f,d;if(this.logger||(this.logger=r),this.eventCallbacks.set(e.id,e),!this.isObserving){var v=(o=(i=(n=this.globalScope)===null||n===void 0?void 0:n.XMLHttpRequest)===null||i===void 0?void 0:i.prototype)===null||o===void 0?void 0:o.open,h=(u=(s=(a=this.globalScope)===null||a===void 0?void 0:a.XMLHttpRequest)===null||s===void 0?void 0:s.prototype)===null||u===void 0?void 0:u.send,g=(f=(c=(l=this.globalScope)===null||l===void 0?void 0:l.XMLHttpRequest)===null||c===void 0?void 0:c.prototype)===null||f===void 0?void 0:f.setRequestHeader;v&&h&&g&&this.observeXhr(v,h,g);var m=(d=this.globalScope)===null||d===void 0?void 0:d.fetch;m&&this.observeFetch(m),this.isObserving=!0}},t.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},t.prototype.triggerEventCallbacks=function(e){var r=this;this.eventCallbacks.forEach(function(n){try{n.callback(e)}catch(i){et(function(){var o;(o=r.logger)===null||o===void 0||o.debug("an unexpected error occurred while triggering event callbacks",i)})}})},t.prototype.handleNetworkRequestEvent=function(e,r,n,i,o,a,s){var u;if(!(a===void 0||s===void 0)){var l,c="GET";if(cd(r)?(l=r.url,c=r.method):l=(u=r?.toString)===null||u===void 0?void 0:u.call(r),l)try{var f=new URL(l);l="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch{}c=n?.method||c;var d,v;i&&(d=i.status),o&&(v={name:o.name||"UnknownError",message:o.message||"An unknown error occurred"},d=0);var h=Math.floor(performance.now()-s),g=Math.floor(a+h),m=new ld(e,c,a,a,l,n,d,h,i,v,g);this.triggerEventCallbacks(m)}},t.prototype.getTimestamps=function(){var e,r;return{startTime:(e=Date.now)===null||e===void 0?void 0:e.call(Date),durationStart:(r=performance?.now)===null||r===void 0?void 0:r.call(performance)}},t.prototype.observeFetch=function(e){var r=this;!this.globalScope||!e||(this.globalScope.fetch=function(n,i){return I(r,void 0,void 0,function(){var o,a,s,u,l=this;return _(this,function(c){switch(c.label){case 0:try{o=this.getTimestamps()}catch(f){et(function(){var d;return(d=l.logger)===null||d===void 0?void 0:d.debug("an unexpected error occurred while retrieving timestamps",f)})}c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e(n,i)];case 2:return a=c.sent(),[3,4];case 3:return u=c.sent(),s=u,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,i?new od(i):void 0,a?new sd(a):void 0,s,o?.startTime,o?.durationStart)}catch(f){et(function(){var d;return(d=l.logger)===null||d===void 0?void 0:d.debug("an unexpected error occurred while handling fetch",f)})}if(a)return[2,a];throw s}})})})},t.createXhrJsonParser=function(e,r){return function(){var n;try{if(e.responseType==="json"){if(!((n=r.globalScope)===null||n===void 0)&&n.structuredClone)return r.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(i){return i instanceof Error&&i.name==="InvalidStateError"&&et(function(){var o;return(o=r.logger)===null||o===void 0?void 0:o.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))}),null}return null}},t.prototype.observeXhr=function(e,r,n){if(!(!this.globalScope||!e||!r)){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var a,s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];var l=this,c=D(s,2),f=c[0],d=c[1];try{l.$$AmplitudeAnalyticsEvent=C({method:f,url:(a=d?.toString)===null||a===void 0?void 0:a.call(d),headers:{}},o.getTimestamps())}catch(v){et(function(){var h;
6return(h=o.logger)===null||h===void 0?void 0:h.debug("an unexpected error occurred while calling xhr open",v)})}return e.apply(l,s)},i.send=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u=this,l=u,c=t.createXhrJsonParser(u,o),f=a[0],d=l.$$AmplitudeAnalyticsEvent;return l.$$AmplitudeAnalyticsEvent&&l.addEventListener("loadend",function(){try{var v=l.getAllResponseHeaders(),h=l.getResponseHeader("content-length"),g=new ud(l.status,v,h?parseInt(h,10):void 0,c),m=l.$$AmplitudeAnalyticsEvent.headers,p=new ad(f,m);d.status=l.status,o.handleNetworkRequestEvent("xhr",{url:d.url,method:d.method},p,g,void 0,d.startTime,d.durationStart)}catch(y){et(function(){var b;return(b=o.logger)===null||b===void 0?void 0:b.debug("an unexpected error occurred while handling xhr send",y)})}}),r.apply(l,a)},i.setRequestHeader=function(a,s){var u=this;try{var l=u.$$AmplitudeAnalyticsEvent;l&&(l.headers[a]=s)}catch(c){et(function(){var f;return(f=o.logger)===null||f===void 0?void 0:f.debug("an unexpected error occurred while calling xhr setRequestHeader",c)})}n.apply(u,[a,s])}}},t})(),po=new fd,vd=function(t,e){return t?.map(function(r){var n,i;if(!((n=r.urls)===null||n===void 0)&&n.length&&(!((i=r.hosts)===null||i===void 0)&&i.length)){var o=JSON.stringify(r.hosts),a=JSON.stringify(r.urls);return e?.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),C(C({},r),{hosts:void 0})}return r})},Si=(function(){function t(){}return t.prototype.parse=function(){return I(this,void 0,void 0,function(){return _(this,function(e){return[2,C(C(C(C({},Wr),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},t.prototype.getUtmParam=function(){var e=Lr(),r=e[wl],n=e[Cl],i=e[Pl],o=e[Al],a=e[kl],s=e[Rl];return{utm_campaign:r,utm_content:n,utm_id:i,utm_medium:o,utm_source:a,utm_term:s}},t.prototype.getReferrer=function(){var e,r,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=(r=(e=n.referrer)===null||e===void 0?void 0:e.split("/")[2])!==null&&r!==void 0?r:void 0}catch{}return n},t.prototype.getClickIds=function(){var e,r=Lr();return e={},e[ji]=r[ji],e[zi]=r[zi],e[$i]=r[$i],e[Ki]=r[Ki],e[Xi]=r[Xi],e[Yi]=r[Yi],e[Qi]=r[Qi],e[Ji]=r[Ji],e[Zi]=r[Zi],e[eo]=r[eo],e[to]=r[to],e},t})(),Ye="data-amp-mask",Xe="*****",hd=/\b(?:\d[ -]*?){13,16}\b/,gd=/(\d{3}-?\d{2}-?\d{4})/g,pd=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Ti=function(t,e){var r,n;if(e===void 0&&(e=[]),typeof t!="string")return"";var i=t;i=i.replace(hd,Xe),i=i.replace(gd,Xe),i=i.replace(pd,Xe);try{for(var o=L(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,Xe)}catch{}}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},_i=function(t){if(typeof document>"u"||!document.title)return"";var e=document.querySelector("title");return e&&e.hasAttribute(Ye)?Xe:t?t(document.title):document.title},Ft={},mo;function md(){if(mo)return Ft;mo=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.Observable=void 0;const t=p=>!!Symbol[p],e=p=>t(p)?Symbol[p]:"@@"+p,r=e("iterator"),n=e("observable"),i=e("species");function o(p,y){let b=p[y];if(b!=null){if(typeof b!="function")throw new TypeError(b+" is not a function");return b}}function a(p){let y=p.constructor;return y!==void 0&&(y=y[i],y===null&&(y=void 0)),y!==void 0?y:m}function s(p){return p instanceof m}function u(p){u.log?u.log(p):setTimeout(()=>{throw p})}function l(p){Promise.resolve().then(()=>{try{p()}catch(y){u(y)}})}function c(p){let y=p._cleanup;if(y!==void 0&&(p._cleanup=void 0,!!y))try{if(typeof y=="function")y();else{let b=o(y,"unsubscribe");b&&b.call(y)}}catch(b){u(b)}}function f(p){p._observer=void 0,p._queue=void 0,p._state="closed"}function d(p){let y=p._queue;if(y){p._queue=void 0,p._state="ready";for(let b=0;b<y.length&&(v(p,y[b].type,y[b].value),p._state!=="closed");++b);}}function v(p,y,b){p._state="running";let E=p._observer;try{let S=o(E,y);switch(y){case"next":S&&S.call(E,b);break;case"error":if(f(p),S)S.call(E,b);else throw b;break;case"complete":f(p),S&&S.call(E);break}}catch(S){u(S)}p._state==="closed"?c(p):p._state==="running"&&(p._state="ready")}function h(p,y,b){if(p._state!=="closed"){if(p._state==="buffering"){p._queue.push({type:y,value:b});return}if(p._state!=="ready"){p._state="buffering",p._queue=[{type:y,value:b}],l(()=>d(p));return}v(p,y,b)}}class g{constructor(y,b){this._cleanup=void 0,this._observer=y,this._queue=void 0,this._state="initializing";let E=this,S={get closed(){return E._state==="closed"},next(T){h(E,"next",T)},error(T){h(E,"error",T)},complete(){h(E,"complete")}};try{this._cleanup=b.call(void 0,S)}catch(T){S.error(T)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}
6unsubscribe(){this._state!=="closed"&&(f(this),c(this))}}let m=class _r{constructor(y){if(!(this instanceof _r))throw new TypeError("Observable cannot be called as a function");if(typeof y!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=y}subscribe(y){return(typeof y!="object"||y===null)&&(y={next:y,error:arguments[1],complete:arguments[2]}),new g(y,this._subscriber)}forEach(y){return new Promise((b,E)=>{if(typeof y!="function"){E(new TypeError(y+" is not a function"));return}function S(){T.unsubscribe(),b()}let T=this.subscribe({next(w){try{y(w,S)}catch(P){E(P),T.unsubscribe()}},error:E,complete:b})})}map(y){if(typeof y!="function")throw new TypeError(y+" is not a function");let b=a(this);return new b(E=>this.subscribe({next(S){try{S=y(S)}catch(T){return E.error(T)}E.next(S)},error(S){E.error(S)},complete(){E.complete()}}))}filter(y){if(typeof y!="function")throw new TypeError(y+" is not a function");let b=a(this);return new b(E=>this.subscribe({next(S){try{if(!y(S))return}catch(T){return E.error(T)}E.next(S)},error(S){E.error(S)},complete(){E.complete()}}))}reduce(y){if(typeof y!="function")throw new TypeError(y+" is not a function");let b=a(this),E=arguments.length>1,S=!1,w=arguments[1];return new b(P=>this.subscribe({next(A){let F=!S;if(S=!0,!F||E)try{w=y(w,A)}catch(k){return P.error(k)}else w=A},error(A){P.error(A)},complete(){if(!S&&!E)return P.error(new TypeError("Cannot reduce an empty sequence"));P.next(w),P.complete()}}))}async all(){let y=[];return await this.forEach(b=>y.push(b)),y}concat(...y){let b=a(this);return new b(E=>{let S,T=0;function w(P){S=P.subscribe({next(A){E.next(A)},error(A){E.error(A)},complete(){T===y.length?(S=void 0,E.complete()):w(b.from(y[T++]))}})}return w(this),()=>{S&&(S.unsubscribe(),S=void 0)}})}flatMap(y){if(typeof y!="function")throw new TypeError(y+" is not a function");let b=a(this);return new b(E=>{let S=[],T=this.subscribe({next(P){if(y)try{P=y(P)}catch(F){return E.error(F)}let A=b.from(P).subscribe({next(F){E.next(F)},error(F){E.error(F)},complete(){let F=S.indexOf(A);F>=0&&S.splice(F,1),w()}});S.push(A)},error(P){E.error(P)},complete(){w()}});function w(){T.closed&&S.length===0&&E.complete()}return()=>{S.forEach(P=>P.unsubscribe()),T.unsubscribe()}})}[n](){return this}static from(y){let b=typeof this=="function"?this:_r;if(y==null)throw new TypeError(y+" is not an object");let E=o(y,n);if(E){let S=E.call(y);if(Object(S)!==S)throw new TypeError(S+" is not an object");return s(S)&&S.constructor===b?S:new b(T=>S.subscribe(T))}if(t("iterator")&&(E=o(y,r),E))return new b(S=>{l(()=>{if(!S.closed){for(let T of E.call(y))if(S.next(T),S.closed)return;S.complete()}})});if(Array.isArray(y))return new b(S=>{l(()=>{if(!S.closed){for(let T=0;T<y.length;++T)if(S.next(y[T]),S.closed)return;S.complete()}})});throw new TypeError(y+" is not observable")}static of(...y){let b=typeof this=="function"?this:_r;return new b(E=>{l(()=>{if(!E.closed){for(let S=0;S<y.length;++S)if(E.next(y[S]),E.closed)return;E.complete()}})})}static get[i](){return this}};return Ft.Observable=m,Object.defineProperty(m,Symbol("extensions"),{value:{symbol:n,hostReportError:u},configurable:!0}),Ft}var sn,yo;function yd(){return yo||(yo=1,sn=md().Observable),sn}var bd=yd();const he=Ga(bd);function Ii(t,e){return new he(function(r){t.subscribe({next:function(n){e(n).then(function(i){return r.next(i)}).catch(function(i){return r.error(i)})},error:function(n){r.error(n)},complete:function(){r.complete()}})})}function lt(t,e){return new he(function(r){var n=!1,i=new Set,o=function(){var s,u;n=!0;try{for(var l=L(i),c=l.next();!c.done;c=l.next()){var f=c.value;try{f.unsubscribe()}catch{}}}catch(d){s={error:d}}finally{try{c&&!c.done&&(u=l.return)&&u.call(l)}finally{if(s)throw s.error}}i.clear()},a=function(s){var u=s.subscribe({next:function(l){n||r.next(l)},error:function(l){n||(n=!0,r.error(l),o())},complete:function(){i.delete(u),!n&&i.size===0&&(r.complete(),o(),n=!0)}});i.add(u)};return a(t),a(e),o})}function Ne(t){var e=new Set,r=null;function n(){r?.unsubscribe(),r=null,e.clear()}return new he(function(i){return e.add(i),r===null&&(r=t.subscribe({next:function(o){var a,s,u;try{for(var l=L(e),c=l.next();!c.done;c=l.next()){var f=c.value;(u=f.next)===null||u===void 0||u.call(f,o)}}catch(d){a={error:d}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}},error:function(o){var a,s,u;try{for(var l=L(e),c=l.next();!c.done;c=l.next()){var f=c.value;(u=f.error)===null||u===void 0||u.call(f,o)}}catch(d){a={error:d}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}n()},complete:function(){var o,a,s;try{for(var u=L(e),l=u.next();!l.done;l=u.next()){var c=l.value;(s=c.complete)===null||s===void 0||s.call(c)}}catch(f){o={error:f}}finally{try{l&&!l.done&&(a=u.return)&&a.call(u)}finally{if(o)throw o.error}}n()}})),function(){e.delete(i),e.size===0&&r&&(r.unsubscribe(),r=null)}})}var Hn="https://app.amplitude.com",Ed="https://app.eu.amplitude.com",Sd="https://apps.stag2.amplitude.com",Td={US:Hn,EU:Ed,STAGING:Sd},_d="https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",Id=function(t){var e=document.querySelector('script[src="'.concat(CSS.escape(t),'"]'));return e?Promise.resolve({status:!0}):new Promise(function(r,n){var i;try{var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=t,o.addEventListener("load",function(){r({status:!0})},{once:!0}),o.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(t)})}),(i=document.head)===null||i===void 0||i.appendChild(o)}catch(a){n(a)}})};function wd(){return"".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9))}var ps,Gn="__AMPLITUDE_MESSENGER_INSTANCE__",xr="__AMPLITUDE_MESSENGER__",Cd=(function(){function t(e){var r=e===void 0?{}:e,n=r.origin,i=n===void 0?Hn:n;this[ps]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=i}return t.prototype.notify=function(e){var r,n,i,o;(n=(r=this.logger)===null||r===void 0?void 0:r.debug)===null||n===void 0||n.call(r,"Message sent: ",JSON.stringify(e)),(o=(i=window.opener)===null||i===void 0?void 0:i.postMessage)===null||o===void 0||o.call(i,e,this.endpoint)},t.prototype.sendRequest=function(e,r,n){var i=this;n===void 0&&(n={timeout:15e3});var o=wd(),a={id:o,action:e,args:r},s=new Promise(function(u,l){i.requestCallbacks[o]={resolve:u,reject:l},i.notify(a),n.timeout>0&&setTimeout(function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete i.requestCallbacks[o]},n.timeout)});return s},t.prototype.handleResponse=function(e){var r;if(!this.requestCallbacks[e.id]){(r=this.logger)===null||r===void 0||r.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},t.prototype.registerActionHandler=function(e,r){var n,i,o,a;this.actionHandlers.has(e)&&((a=(o=this.logger)===null||o===void 0?void 0:o.warn)===null||a===void 0||a.call(o,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,r);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var u=L(s),l=u.next();!l.done;l=u.next()){var c=l.value;r(c)}}catch(f){n={error:f}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}},t.prototype.loadScriptOnce=function(e){return I(this,void 0,void 0,function(){var r,n,i;return _(this,function(o){switch(o.label){case 0:if(r=this.scriptLoadPromises.get(e),r)return[2,r];n=Id(e).then(function(){}),this.scriptLoadPromises.set(e,n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n];case 2:return o.sent(),[3,4];case 3:throw i=o.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},t.prototype.setup=function(e){var r=this,n,i,o=e===void 0?{}:e,a=o.logger,s=o.endpoint;a&&(this.logger=a),s&&this.endpoint===Hn&&(this.endpoint=s),!this.isSetup&&(this.isSetup=!0,(i=(n=this.logger)===null||n===void 0?void 0:n.debug)===null||i===void 0||i.call(n,"Setting up messenger"),this.messageHandler=function(u){var l,c,f,d,v;if((c=(l=r.logger)===null||l===void 0?void 0:l.debug)===null||c===void 0||c.c
6all(l,"Message received: ",JSON.stringify(u)),r.endpoint===u.origin){var h=u.data,g=h?.action;if(g)if("id"in h&&h.id)(d=(f=r.logger)===null||f===void 0?void 0:f.debug)===null||d===void 0||d.call(f,"Received Response to previous request: ",JSON.stringify(u)),r.handleResponse(h);else{if(g==="ping"){r.notify({action:"pong"});return}var m=r.actionHandlers.get(g);if(m)m(h.data);else{var p=(v=r.pendingMessages.get(g))!==null&&v!==void 0?v:[];p.push(h.data),r.pendingMessages.set(g,p)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},t.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=z();e?.[xr]===this&&delete e[xr]},t})();ps=Gn;function Pd(t){return typeof t=="object"&&t!==null&&Gn in t&&t[Gn]===!0}function Ad(t){var e=z(),r=e?.[xr];if(Pd(r))return r;var n=new Cd(t);return e&&(e[xr]=n),n}var bo="__AMPLITUDE_BACKGROUND_CAPTURE__";function kd(t,e){var r,n=t;if(n[bo]!==!0){n[bo]=!0;var i=(r=void 0)!==null&&r!==void 0?r:_d,o=null,a=function(s,u){var l,c;s==="background-capture-complete"&&((c=(l=t.logger)===null||l===void 0?void 0:l.debug)===null||c===void 0||c.call(l,"Background capture complete"),t.notify({action:"background-capture-complete",data:u}))};t.registerActionHandler("initialize-background-capture",function(){var s,u;(u=(s=t.logger)===null||s===void 0?void 0:s.debug)===null||u===void 0||u.call(s,"Initializing background capture (external script)");var l=new URL(i,t.endpoint).toString();t.loadScriptOnce(l).then(function(){var c,f,d;(f=(c=t.logger)===null||c===void 0?void 0:c.debug)===null||f===void 0||f.call(c,"Background capture script loaded (external)"),o=(d=window?.amplitudeBackgroundCapture)===null||d===void 0?void 0:d.call(window,{messenger:t,onBackgroundCapture:a}),t.notify({action:"background-capture-loaded"})}).catch(function(){var c;(c=t.logger)===null||c===void 0||c.warn("Failed to initialize background capture")})}),t.registerActionHandler("close-background-capture",function(){var s;(s=o?.close)===null||s===void 0||s.call(o),o=null})}}var un={always:"always",ifEmptyCampaign:"ifEmptyCampaign"};function Rd(){var t,e,r=z();return typeof((e=(t=r?.chrome)===null||t===void 0?void 0:t.runtime)===null||e===void 0?void 0:e.id)=="string"}function Od(){var t,e=z();return((t=e?.navigator)===null||t===void 0?void 0:t.product)==="ReactNative"}function ms(t,e,r){var n,i,o=[];try{for(var a=L(e??[]),s=a.next();!s.done;s=a.next()){var u=s.value;try{o.push(new RegExp(u))}catch(l){r.warn("Invalid regex pattern: ".concat(u),l)}}}catch(l){n={error:l}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return t.concat(o)}function Ld(t,e){var r,n,i,o,a;if(!(typeof t!="object"||t===null||!(!((i=t.captureRules)===null||i===void 0)&&i.length))){var s=C({},t),u=(o=s.captureRules)!==null&&o!==void 0?o:[];try{for(var l=L(u),c=l.next();!c.done;c=l.next()){var f=c.value;f.urls=ms((a=f.urls)!==null&&a!==void 0?a:[],f.urlsRegex,e),delete f.urlsRegex}}catch(d){r={error:d}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return s}}function ys(t){var e,r,n,i,o,a,s,u,l,c,f,d,v;if(!(typeof t!="object"||t===null)&&!Array.isArray(t)){var h=Object.keys(t);try{for(var g=L(h),m=g.next();!m.done;m=g.next()){var p=m.value;try{var y=t[p];typeof y?.enabled=="boolean"&&(y.enabled?(delete y.enabled,Object.keys(y).length===0&&(t[p]=!0)):t[p]=!1),ys(y)}catch{}}}catch(U){e={error:U}}finally{try{m&&!m.done&&(r=g.return)&&r.call(g)}finally{if(e)throw e.error}}try{if(!((l=(u=(s=t.autocapture)===null||s===void 0?void 0:s.networkTracking)===null||u===void 0?void 0:u.captureRules)===null||l===void 0)&&l.length)try{for(var b=L(t.autocapture.networkTracking.captureRules),E=b.next();!E.done;E=b.next()){var S=E.value;try{for(var T=(o=void 0,L(["responseHeaders","requestHeaders"])),w=T.next();!w.done;w=T.next()){var P=w.value,A=(c=S[P])!==null&&c!==void 0?c:{},F=A.captureSafeHeaders,k=A.allowlist;if(!(!F&&!k)){if(k!==void 0&&!Array.isArray(k)){delete S[P];continue}S[P]=W(W([],D(F?Or:[]),!1),D(k??[]),!1)}}}catch(U){o={error:U}}finally{try{w&&!w.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(U){n={error:U}}finally{try{E&&!E.done&&(i=b.return)&&i.call(b)}finally{if(n)throw n.error}}}catch{}((f=t.autocapture)===null||f===void 0?void 0:f.pageViews)!==void 0&&(t.autocapture.screenViews=t.autocapture.pageViews);var x=(d=t.autocapture)===null||d===void 0?void 0:d.frustrationInteractions;x&&(x.rageClick&&(x.rageClicks=x.rageClick,delete x.rageClick),x.deadClick&&(x.deadClicks=x.deadClick,delete x.deadClick));try{var R=(v=t.autocapture)===null||v===void 0?void 0:v.elementInteractions;if(R&&typeof R=="object"&&(R.viewportContentUpdated===!0&&(R.viewportContentUpdated={}),R.viewportContentUpdated===!1&&(R.viewportContentUpdated={enabled:!1}),R.exposureDuration!==void 0)){var M=R.viewportContentUpdated;M===void 0?R.viewportContentUpdated={exposureDuration:R.exposureDuration}:typeof M=="object"&&M.exposureDuration===void 0&&M.enabled!==!1&&(M.exposureDuration=R.exposureDuration),delete R.exposureDuration}}catch{}}}var At=function(t,e){return typeof t=="boolean"?t:t?.[e]===!1?!1:Rd()?!!t?.[e]:!0},jn=function(t){return At(t,"attribution")},Dd=function(t){return At(t,"fileDownloads")},bs=function(t){return At(t,"formInteractions")},Es=function(t){return At(t,"pageViews")},Eo=function(t){return At(t,"sessions")},xd=function(t){return At(t,"pageUrlEnrichment")},Ss=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.networkTracking===!0||typeof t.networkTracking=="object")},Ts=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.elementInteractions===!0||typeof t.elementInteractions=="object")},Md=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.webVitals===!0||typeof t.webVitals=="object"&&t.webVitals!==null)},Nd=function(t){if(typeof t.autocapture=="object"){var e=t.autocapture.webVitals;if(typeof e=="object"&&e!==null)return e}},_s=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.frustrationInteractions===!0||typeof t.frustrationInteractions=="object")},Ud=function(t){return typeof t=="object"&&(t.performanceTracking===!0||typeof t.performanceTracking=="object")},Fd=function(t){if(typeof t.autocapture=="object"){var e=t.autocapture.performanceTracking;if(e===!0)return{mainThreadBlock:!0};if(typeof e=="object"&&e!==null)return e}},Bd=function(t){return typeof t=="boolean"?t:typeof t=="object"&&t!==null&&t.enabled!==!1},qd=function(t){if(Ts(t.autocapture)&&typeof t.autocapture=="object"&&typeof t.autocapture.elementInteractions=="object")return t.autocapture.elementInteractions},Vd=function(t){if(_s(t.autocapture)&&typeof t.autocapture=="object"&&typeof t.autocapture.frustrationInteractions=="object")return t.autocapture.frustrationInteractions},Wd=function(t){if(Ss(t.autocapture)){var e=void 0;
6return typeof t.autocapture=="object"&&typeof t.autocapture.networkTracking=="object"?e=t.autocapture.networkTracking:t.networkTrackingOptions&&(e=t.networkTrackingOptions),C(C({},e),{captureRules:vd(e?.captureRules,t.loggerProvider)})}},So=function(t){var e=function(){return!1},r=void 0,n,i=t.pageCounter,o=Es(t.defaultTracking);return o&&(e=void 0,n=void 0,t.defaultTracking&&typeof t.defaultTracking=="object"&&t.defaultTracking.pageViews&&typeof t.defaultTracking.pageViews=="object"&&("trackOn"in t.defaultTracking.pageViews&&(e=t.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in t.defaultTracking.pageViews&&(r=t.defaultTracking.pageViews.trackHistoryChanges),"eventType"in t.defaultTracking.pageViews&&t.defaultTracking.pageViews.eventType&&(n=t.defaultTracking.pageViews.eventType))),{trackOn:e,trackHistoryChanges:r,eventType:n,pageCounter:i}},Hd=function(t){return jn(t.defaultTracking)&&t.defaultTracking&&typeof t.defaultTracking=="object"&&t.defaultTracking.attribution&&typeof t.defaultTracking.attribution=="object"?C({},t.defaultTracking.attribution):{}},Gd=function(t){if(bs(t.defaultTracking)&&t.defaultTracking&&typeof t.defaultTracking=="object"&&typeof t.defaultTracking.formInteractions=="object")return t.defaultTracking.formInteractions},ln=function(t,e){for(var r=0;r<e.length;r++){var n=e[r],i=n.name,o=n.args,a=n.resolve,s=t&&t[i];if(typeof s=="function"){var u=s.apply(t,o);typeof a=="function"&&a(u?.promise)}}return t},cn=function(t){var e=t;return e&&e._q!==void 0},jd=function(t){var e,r;return typeof((r=(e=t.chrome)===null||e===void 0?void 0:e.runtime)===null||r===void 0?void 0:r.id)=="string"},zd=function(t){var e=t.ServiceWorkerGlobalScope;return typeof e=="function"&&t instanceof e},$d=function(t){var e=t.WorkerGlobalScope;return typeof e=="function"&&t instanceof e},Kd=function(t){return typeof t.document<"u"},Xd=function(t){var e,r;return typeof((r=(e=t.process)===null||e===void 0?void 0:e.versions)===null||r===void 0?void 0:r.node)=="string"};function Yd(){var t=z();if(!t)return"unknown";var e=jd(t);return zd(t)?e?"chrome_extension_service_worker":"service_worker":$d(t)?"web_worker":Kd(t)?e?"chrome_extension":"browser":Xd(t)?"node":"unknown"}var wi="2.47.0",Is="amplitude-ts",ws="Web",Qd="$remote",Jd=(function(){function t(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(Is,"/").concat(wi),typeof navigator<"u"&&(this.userAgent=navigator.userAgent)}return t.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},t.prototype.execute=function(e){var r,n;return I(this,void 0,void 0,function(){var i,o,a,s;return _(this,function(u){return i=new Date().getTime(),o=(r=this.config.lastEventId)!==null&&r!==void 0?r:-1,a=(n=e.event_id)!==null&&n!==void 0?n:o+1,this.config.lastEventId=a,e.time||(this.config.lastEventTime=i),s=C(C(C(C(C(C(C(C({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:i},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:ws}),this.config.trackingOptions.language&&{language:mc()}),this.config.trackingOptions.ipAddress&&{ip:Qd}),{insert_id:Ue(),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:a,library:this.library,user_agent:this.userAgent}),[2,s]})})},t})(),ur=1e3,Cs=(function(t){Le(e,t);function e(r){var n=this,i,o,a;try{a=(i=z())===null||i===void 0?void 0:i.localStorage}catch(s){(o=r?.loggerProvider)===null||o===void 0||o.debug("Failed to access localStorage. error=".concat(JSON.stringify(s))),a=void 0}return n=t.call(this,a)||this,n.loggerProvider=r?.loggerProvider,n}return e.prototype.set=function(r,n){var i;return I(this,void 0,void 0,function(){var o;return _(this,function(a){switch(a.label){case 0:return Array.isArray(n)&&n.length>ur?(o=n.length-ur,[4,t.prototype.set.call(this,r,n.slice(0,ur))]):[3,2];case 1:return a.sent(),(i=this.loggerProvider)===null||i===void 0||i.error("Failed to save ".concat(o," events because the queue length exceeded ").concat(ur,".")),[3,4];case 2:return[4,t.prototype.set.call(this,r,n)];case 3:a.sent(),a.label=4;case 4:return[2]}})})},e})(Hr),Zd=(function(t){Le(e,t);function e(){var r;return t.call(this,(r=z())===null||r===void 0?void 0:r.sessionStorage)||this}return e})(Hr),ef=(function(t){Le(e,t);function e(r){r===void 0&&(r={});var n=t.call(this)||this;return n.state={done:4},n.customHeaders=r,n}return e.prototype.send=function(r,n,i){return i===void 0&&(i=!1),I(this,void 0,void 0,function(){var o=this;return _(this,function(a){return[2,new Promise(function(s,u){typeof XMLHttpRequest>"u"&&u(new Error("XHRTransport is not supported."));var l=new XMLHttpRequest;l.open("POST",r,!0),l.onreadystatechange=function(){if(l.readyState===o.state.done){var g=l.responseText;try{s(o.buildResponse(JSON.parse(g)))}catch{s(o.buildResponse({code:l.status}))}}};var c={"Content-Type":"application/json",Accept:"*/*"},f=JSON.stringify(n),d=i&&f.length>=as&&ss(),v=function(g){var m,p;c=C(C({},o.customHeaders),c);try{for(var y=L(Object.entries(c)),b=y.next();!b.done;b=y.next()){var E=D(b.value,2),S=E[0],T=E[1];l.setRequestHeader(S,T)}}catch(w){m={error:w}}
6finally{try{b&&!b.done&&(p=y.return)&&p.call(y)}finally{if(m)throw m.error}}l.send(g)},h=function(){return I(o,void 0,void 0,function(){var g;return _(this,function(m){switch(m.label){case 0:return d?[4,us(f)]:[3,2];case 1:return g=m.sent(),g?(c["Content-Encoding"]="gzip",v(g)):v(f),[3,3];case 2:v(f),m.label=3;case 3:return[2]}})})};h().catch(u)})]})})},e})(bi),tf=16*1024,rf=(function(t){Le(e,t);function e(r,n,i){r===void 0&&(r={});var o=t.call(this)||this;return o.customHeaders=r,o.enableKeepalive=n!==!1,o.referrerPolicy=i,o}return e.prototype.send=function(r,n,i){return i===void 0&&(i=!1),I(this,void 0,void 0,function(){var o,a,s,u,l,c,f,d,v;return _(this,function(h){switch(h.label){case 0:if(typeof fetch>"u")throw new Error("FetchTransport is not supported");return o=JSON.stringify(n),a=i&&o.length>=as&&ss(),s=o,u={"Content-Type":"application/json",Accept:"*/*"},a?[4,us(o)]:[3,2];case 1:l=h.sent(),l&&(u["Content-Encoding"]="gzip",s=l),h.label=2;case 2:return u=C(C({},this.customHeaders),u),c=typeof s=="string"?s.length:s.byteLength,f={headers:u,body:s,method:"POST",keepalive:this.enableKeepalive&&c<=tf},this.referrerPolicy&&(f.referrerPolicy=this.referrerPolicy),[4,fetch(r,f)];case 3:return d=h.sent(),[4,d.text()];case 4:v=h.sent();try{return[2,this.buildResponse(JSON.parse(v))]}catch{return[2,this.buildResponse({code:d.status})]}return[2]}})})},e})(bi),nf=(function(t){Le(e,t);function e(){return t.call(this)||this}return e.prototype.send=function(r,n,i){return I(this,void 0,void 0,function(){var o=this;return _(this,function(a){return[2,new Promise(function(s,u){var l=z();if(!l?.navigator.sendBeacon)throw new Error("SendBeaconTransport is not supported");try{var c=JSON.stringify(n),f=l.navigator.sendBeacon(r,c);return s(f?o.buildResponse({code:200,events_ingested:n.events.length,payload_size_bytes:c.length,server_upload_time:Date.now()}):o.buildResponse({code:500}))}catch(d){u(d)}})]})})},e})(bi),of=function(t,e,r){return r===void 0&&(r=!0),I(void 0,void 0,void 0,function(){var n,i,o,a,s,u,l,c,f;return _(this,function(d){switch(d.label){case 0:return n=pc(t),[4,e.getRaw(n)];case 1:return i=d.sent(),i?r?[4,e.remove(n)]:[3,3]:[2,{optOut:!1}];case 2:d.sent(),d.label=3;case 3:return o=D(i.split("."),6),a=o[0],s=o[1],u=o[2],l=o[3],c=o[4],f=o[5],[2,{deviceId:a,userId:af(s),sessionId:dn(l),lastEventId:dn(f),lastEventTime:dn(c),optOut:!!u}]}})})},dn=function(t){var e=parseInt(t,32);if(!isNaN(e))return e},af=function(t){if(!(!atob||!escape||!t))try{return decodeURIComponent(escape(atob(t)))}catch{return}},De="[Amplitude]",To="".concat(De," Form Started"),sf="".concat(De," Form Submitted"),uf="".concat(De," File Downloaded"),_o="session_start",Io="session_end",lf="".concat(De," File Extension"),cf="".concat(De," File Name"),df="".concat(De," Link ID"),ff="".concat(De," Link Text"),vf="".concat(De," Link URL"),fn="".concat(De," Form ID"),vn="".concat(De," Form Name"),hn="".concat(De," Form Destination"),Mr="
6cookie",Ps="US",wo=function(t){var e=t.split(".");return e.length<=2?t:e.slice(e.length-2,e.length).join(".")},hf=function(t){return Object.values(t).every(function(e){return!e})},gf=function(t){var e=C(C({},t),{referring_domain:void 0,referrer:void 0});return Object.values(e).every(function(r){return!r})},pf=function(t,e,r,n,i,o){i===void 0&&(i=!0),t.referrer;var a=t.referring_domain,s=at(t,["referrer","referring_domain"]),u=e||{};u.referrer;var l=u.referring_domain,c=at(u,["referrer","referring_domain"]),f=r.excludeInternalReferrers;if(f){var d=Sf(f,n);if(!(d instanceof TypeError)&&t.referring_domain&&Tf(t.referring_domain,o)){if(d==="always")return Co(d,t.referring_domain,n),!1;if(d==="ifEmptyCampaign"&&gf(t))return Co(d,t.referring_domain,n),!1}}if(mf(r.excludeReferrers,t.referring_domain))return n.debug("This is not a new campaign because ".concat(t.referring_domain," is in the exclude referrer list.")),!1;if(!i&&hf(t)&&e)return n.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var v=JSON.stringify(s)!==JSON.stringify(c),h=wo(a||"")!==wo(l||""),g=!e||v||h;return g?n.debug("This is a new campaign. An $identify event will be sent."):n.debug("This is not a new campaign because it's the same as the previous one."),g},mf=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=""),t.some(function(r){return r instanceof RegExp?r.test(e):r===e})},yf=function(t,e){var r=e.startsWith(".")?e:".".concat(e),n=t.startsWith(".")?t:".".concat(t);return!!n.endsWith(r)},bf=function(t,e){var r=C(C({},Wr),t),n=Object.entries(r).reduce(function(i,o){var a,s=D(o,2),u=s[0],l=s[1];return i.setOnce("initial_".concat(u),(a=l??e.initialEmptyValue)!==null&&a!==void 0?a:"EMPTY"),l?i.set(u,l):i.unset(u)},new Tt);return pi(n)},Ef=function(t){var e=t;return e?(e.startsWith(".")&&(e=e.substring(1)),[new RegExp("".concat(e.replace(".","\\."),"$"))]):[]},Sf=function(t,e){if(t===!0)return un.always;if(typeof t=="object"){var r=t.condition;if(typeof r=="string"&&Object.keys(un).includes(r))return r;if(typeof r>"u")return un.always}var n="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(t));return e.error(n),new TypeError(n)};function Co(t,e,r){var n="This is not a new campaign because referring_domain=".concat(e," is on the same domain as the current page and it is configured to exclude internal referrers");t==="always"?r.debug(n):t==="ifEmptyCampaign"&&r.debug("".concat(n," with empty campaign parameters"))}var As=["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"],ks=function(t){var e,r,n=t||((r=(e=z())===null||e===void 0?void 0:e.location)===null||r===void 0?void 0:r.hostname);if(!n)return"";var i=n.split("."),o=i[i.length-1],a=i[i.length-2];return As.find(function(s){return n.endsWith(".".concat(s))})&&(o=i[i.length-2]+"."+i[i.length-1],a=i[i.length-3]),a?"".concat(a,".").concat(o):o},Tf=function(t,e){var r=z();if(!r)return!1;var n=(e||"").trim()||ks(r.location.hostname);return yf(t,n)},_f=(function(t){Le(e,t);function e(r,n,i,o,a,s,u,l,c,f,d,v,h,g,m,p,y,b,E,S,T,w,P,A,F,k,x,R,M,U,N,q,$,H,j,O,G,V,X,Y,J,Q,re,ee){i===void 0&&(i=new yi),o===void 0&&(o={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),l===void 0&&(l=1e3),c===void 0&&(c=5),f===void 0&&(f=30),d===void 0&&(d=Mr),p===void 0&&(p=new mi),y===void 0&&(y=Ee.Warn),E===void 0&&(E=!1),S===void 0&&(S=!1),P===void 0&&(P=""),A===void 0&&(A=Ps),x===void 0&&(x=1800*1e3),R===void 0&&(R=new Cs({loggerProvider:p})),M===void 0&&(M={ipAddress:!0,language:!0,platform:!0}),U===void 0&&(U="fetch"),N===void 0&&(N=!1),q===void 0&&(q=!0),V===void 0&&(V=!0),X===void 0&&(X=0),re===void 0&&(re=!1);var B=this,ie;B=t.call(this,{apiKey:r,instanceName:h,storageProvider:R,transportProvider:Rs(U)})||this,B.apiKey=r,B.appVersion=n,B.cookieOptions=o,B.defaultTracking=a,B.autocapture=s,B.flushIntervalMillis=l,B.flushMaxRetries=c,B.flushQueueSize=f,B.identityStorage=d,B.ingestionMetadata=v,B.loggerProvider=p,B.logLevel=y,B.minIdLength=b,B.offline=E,B.partnerId=T,B.plan=w,B.serverUrl=P,B.serverZone=A,B.sessionTimeout=x,B.storageProvider=R,B.trackingOptions=M,B.transport=U,B.useBatch=N,B.fetchRemoteConfig=q,B.networkTrackingOptions=O,B.identify=G,B.enableDiagnostics=V,B.diagnosticsSampleRate=X,B.diagnosticsClient=Y,B.remoteConfig=J,B.topLevelDomain=Q,B.enableRequestBodyCompression=re,B.customEnrichment=ee,B.version=wi,B._optOut=!1,B._cookieStorage=i,B.deviceId=u,B.lastEventId=g,B.lastEventTime=m,B.optOut=S,B.deferredSessionId=k,B.sessionId=F,B.pageCounter=H,B.userId=$,B.debugLogsEnabled=j,B.loggerProvider.enable(j?Ee.Debug:B.logLevel),B.networkTrackingOptions=O,B.identify=G,B.enableDiagnostics=V,B.diagnosticsSampleRate=X,B.diagnosticsClient=Y;var oe=(ie=J?.fetchRemoteConfig)!==null&&ie!==void 0?ie:q;return B.remoteConfig=B.remoteConfig||{},B.remoteConfig.fetchRemoteConfig=oe,B.fetchRemoteConfig=oe,B.topLevelDomain=Q||ks(),B}return Object.defineProperty(e.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(r){this._cookieStorage!==r&&(this._cookieStorage=r,this.updateStorage())}
6,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deviceId",{get:function(){return this._deviceId},set:function(r){this._deviceId!==r&&(this._deviceId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"userId",{get:function(){return this._userId},set:function(r){this._userId!==r&&(this._userId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionId",{get:function(){return this._sessionId},set:function(r){this._sessionId!==r&&(this._sessionId=r,r!==void 0&&this._deferredSessionId!==void 0&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(r){this._deferredSessionId!==r&&r!==this.sessionId&&(this._deferredSessionId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(r){this._optOut!==r&&(this._optOut=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(r){this._lastEventTime!==r&&(this._lastEventTime=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(r){this._lastEventId!==r&&(this._lastEventId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(r){this._pageCounter!==r&&(this._pageCounter=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugLogsEnabled",{set:function(r){this._debugLogsEnabled!==r&&(this._debugLogsEnabled=r,this.updateStorage())},enumerable:!1,configurable:!0}),e.prototype.updateStorage=function(){var r={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 Dr&&(r.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(rs(this.apiKey),r)},e})(Ql),If=function(t,e,r,n,i){return e===void 0&&(e={}),I(void 0,void 0,void 0,function(){var o,a,s,u,l,c,f,d,v,h,g,m,p,y,b,E,S,T,w,P,A,F,k,x,R,M,U,N,q,$,H,j,O,G,V,X,Y,J,Q,re,ee,B,ie,oe,se,K,ge,be,Te,Je,Ze;return _(this,function(Be){switch(Be.label){case 0:return o=e.identityStorage||Mr,a="",o===Mr&&!(!((F=e.cookieOptions)===null||F===void 0)&&F.domain)&&((k=e.cookieOptions)===null||k===void 0?void 0:k.domain)!==""?[4,Pf(void 0,n)]:[3,2];case 1:a=Be.sent(),Be.label=2;case 2:return s=C({domain:(R=(x=e.cookieOptions)===null||x===void 0?void 0:x.domain)!==null&&R!==void 0?R:a,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},e.cookieOptions),u={duplicateResolverFn:function(Ot){var vt=is(Ot);if(!vt)return!1;var Lt=JSON.parse(vt);return os(Lt.cookieDomain,s.domain)},diagnosticsClient:n},l=wf(e.identityStorage,s,u),[4,of(t,l,(U=(M=e.cookieOptions)===null||M===void 0?void 0:M.upgrade)!==null&&U!==void 0?U:!0)];case 3:return c=Be.sent(),[4,l.get(rs(t))];case 4:return f=Be.sent(),d=Lr(),v=d.ampTimestamp?Number(d.ampTimestamp):void 0,h=v?Date.now()<v:!0,g=(j=(H=($=(N=e.deviceId)!==null&&N!==void 0?N:h?(q=d.ampDeviceId)!==null&&q!==void 0?q:d.deviceId:void 0)!==null&&$!==void 0?$:f?.deviceId)!==null&&H!==void 0?H:c.deviceId)!==null&&j!==void 0?j:Ue(),m=(O=f?.lastEventId)!==null&&O!==void 0?O:c.lastEventId,p=(G=f?.lastEventTime)!==null&&G!==void 0?G:c.lastEventTime,y=(X=(V=e.optOut)!==null&&V!==void 0?V:f?.optOut)!==null&&X!==void 0?X:c.optOut,b=(Y=f?.sessionId)!==null&&Y!==void 0?Y:c.sessionId,E=f?.deferredSessionId,S=(Q=(J=e.userId)!==null&&J!==void 0?J:f?.userId)!==null&&Q!==void 0?Q:c.userId,r.previousSessionDeviceId=(re=f?.deviceId)!==null&&re!==void 0?re:c.deviceId,r.previousSessionUserId=(ee=f?.userId)!==null&&ee!==void 0?ee:c.userId,T={ipAddress:(ie=(B=e.trackingOptions)===null||B===void 0?void 0:B.ipAddress)!==null&&ie!==void 0?ie:!0,language:(se=(oe=e.trackingOptions)===null||oe===void 0?void 0:oe.language)!==null&&se!==void 0?se:!0,platform:(ge=(K=e.trackingOptions)===null||K===void 0?void 0:K.platform)!==null&&ge!==void 0?ge:!0},w=f?.pageCounter,P=f?.debugLogsEnabled,e.autocapture!==void 0&&(e.defaultTracking=e.autocapture),A=new _f(t,e.appVersion,l,s,e.defaultTracking,e.autocapture,g,e.flushIntervalMillis,e.flushMaxRetries,e.flushQueueSize,o,e.ingestionMetadata,e.instanceName,m,p,(be=i?.loggerProvider)!==null&&be!==void 0?be:e.loggerProvider,e.logLevel,e.minIdLength,e.offline,y,e.partnerId,e.plan,e.serverUrl,(Te=i?.serverZone)!==null&&Te!==void 0?Te:e.serverZone,b,E,e.sessionTimeout,e.storageProvider,T,e.transport,e.useBatch,e.fetchRemoteConfig,S,w,P,e.networkTrackingOptions,e.identify,(Je=i?.enableDiagnostics)!==null&&Je!==void 0?Je:e.enableDiagnostics,(Ze=i?.diagnosticsSampleRate)!==null&&Ze!==void 0?Ze:r._diagnosticsSampleRate,n,e.remoteConfig,a,e.enableRequestBodyCompression,e.customEnrichment),[4,A.storageProvider.isEnabled()];case 5:return Be.sent()||(A.loggerProvider.warn("Storage provider ".concat(A.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),A.storageProvider=new yi),[2,A]}})})},wf=function(t,e,r){switch(t===void 0&&(t=Mr),e===void 0&&(e={}),t){case"localStorage":return new Cs;case"sessionStorage":return new Zd;case"none":return new yi;case"cookie":default:return new Dr(C(C({},e),{expirationDays:e.expiration}),r)}},Cf=function(t){var e,r;return t===void 0&&(t={}),((e=t.remoteConfig)===null||e===void 0?void 0:e.fetchRemoteConfig)===!0?!0:!(((r=t.remoteConfig)===null||r===void 0?void 0:r.fetchRemoteConfig)===!1||t.fetchRemoteConfig===!1)},Rs=function(t){var e=typeof t=="object"?t.type:t,r=typeof t=="object"?t.headers:void 0,n=typeof t=="object"?t.enableKeepalive:void 0,i=typeof t=="object"?t.referrerPolicy:void 0;
6return e==="xhr"?new ef(r):e==="beacon"?new nf:new rf(r,n,i)},Pf=function(t,e){return I(void 0,void 0,void 0,function(){var r,n,i,o,a,a,s,u,l;return _(this,function(c){switch(c.label){case 0:return[4,new Dr(void 0,{diagnosticsClient:e}).isEnabled()];case 1:if(!c.sent()||typeof location>"u"||!location.hostname)return[2,""];if(r=location.hostname,n=r.split("."),n.length===1)return[2,""];for(i=[],o=1,As.find(function(f){return r.endsWith(".".concat(f))})&&(o=2),a=n.length-o-1;a>=0;--a)i.push(n.slice(a).join("."));a=0,c.label=2;case 2:if(!(a<i.length))return[3,7];s=i[a],c.label=3;case 3:return c.trys.push([3,5,,6]),[4,Dr.isDomainWritable(s)];case 4:return u=c.sent(),u?[2,"."+s]:[3,6];case 5:return l=c.sent(),e&&e.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(s),error:l instanceof Error?l.message:String(l)}),[3,6];case 6:return a++,[3,2];case 7:return e&&e.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(r)}),[2,""]}})})},Af="[Amplitude] Page Viewed",gn="AMP_PAGE_VIEW",Po=function(t){t===void 0&&(t={});var e,r=z(),n=void 0,i=!1,o,a,s=t.trackOn,u=t.trackHistoryChanges,l=t.eventType,c=l===void 0?Af:l,f=function(y){var b=y;try{b=decodeURI(y)}catch(E){n?.error("Malformed URI sequence: ",E)}return b},d=function(y){return I(void 0,void 0,void 0,function(){var b,E,S;return _(this,function(T){switch(T.label){case 0:return b=f(typeof location<"u"&&location.href||""),S={event_type:c},E=[{}],[4,kf()];case 1:return[2,(S.event_properties=C.apply(void 0,[C.apply(void 0,E.concat([T.sent()])),{"[Amplitude] Page Domain":typeof location<"u"&&location.hostname||"","[Amplitude] Page Location":b,"[Amplitude] Page Path":typeof location<"u"&&f(location.pathname)||"","[Amplitude] Page Title":_i(Ti),"[Amplitude] Page URL":b.split("?")[0],"[Amplitude] Page View ID":y}]),S)]}})})},v=function(){return typeof s>"u"||typeof s=="function"&&s()},h=typeof location<"u"?location.href:null,g=function(){return I(void 0,void 0,void 0,function(){var y,b,E,S,T;return _(this,function(w){switch(w.label){case 0:return y=location.href,b=Of(u,y,h||"")&&v(),h=y,b?(E=void 0,a&&(E=Ue(),a.set(gn,{pageViewId:E})),n?.log("Tracking page view event"),e!=null?[3,1]:[3,3]):[3,4];case 1:return T=(S=e).track,[4,d(E)];case 2:T.apply(S,[w.sent()]),w.label=3;case 3:w.label=4;case 4:return[2]}})})},m=function(){g()},p={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(y,b){return I(void 0,void 0,void 0,function(){var E,S,T;return _(this,function(w){switch(w.label){case 0:if(e=b,o=y,n=y.loggerProvider,n.log("Installing @amplitude/plugin-page-view-tracking-browser"),i=!0,r){try{a=new Hr(r.sessionStorage)}catch{n?.debug("sessionStorage is not available in this environment.")}r.addEventListener("popstate",m),r.history.pushState=new Proxy(r.history.pushState,{apply:function(P,A,F){var k=D(F,3),x=k[0],R=k[1],M=k[2];P.apply(A,[x,R,M]),i&&m()}})}return v()?(n.log("Tracking page view event"),E=void 0,a&&(E=Ue(),a.set(gn,{pageViewId:E})),T=(S=e).track,[4,d(E)]):[3,2];case 1:T.apply(S,[w.sent()]),w.label=2;case 2:return[2]}})})},execute:function(y){return I(void 0,void 0,void 0,function(){var b,E,S;return _(this,function(T){switch(T.label){case 0:return s==="attribution"&&Rf(y)?(n?.log("Enriching campaign event to page view event with campaign parameters"),b=void 0,a?[4,a.get(gn)]:[3,2]):[3,4];case 1:E=T.sent(),b=E?.pageViewId,T.label=2;case 2:return[4,d(b)];case 3:S=T.sent(),y.event_type=S.event_type,y.event_properties=C(C({},y.event_properties),S.event_properties),T.label=4;case 4:return o&&y.event_type===c&&(o.pageCounter=o.pageCounter?o.pageCounter+1:1,y.event_properties=C(C({},y.event_properties),{"[Amplitude] Page Counter":o.pageCounter})),[2,y]}})})},teardown:function(){return I(void 0,void 0,void 0,function(){return _(this,function(y){return r&&(r.removeEventListener("popstate",m),i=!1),[2]})})}};return p},kf=function(){return I(void 0,void 0,void 0,function(){var t;return _(this,function(e){switch(e.label){case 0:return t=ns,[4,new Si().parse()];case 1:return[2,t.apply(void 0,[e.sent()])]}})})},Rf=function(t){if(t.event_type==="$identify"&&t.user_properties){var e=t.user_properties,r=e[Ke.SET]||{},n=e[Ke.UNSET]||{},i=W(W([],D(Object.keys(r)),!1),D(Object.keys(n)),!1);return Object.keys(Wr).every(function(o){return i.includes(o)})}return!1},Of=function(t,e,r){switch(t){case"pathOnly":{if(r=="")return!0;var n=new URL(e),i=new URL(r),o=n.origin+n.pathname,a=i.origin+i.pathname;return o!==a}default:return e!==r}},Lf=function(){var t,e=[],r=function(c,f,d){c.addEventListener(f,d),e.push({element:c,type:f,handler:d})},n=function(){e.forEach(function(c){var f=c.element,d=c.type,v=c.handler;f?.removeEventListener(d,v)}),e=[]},i,o="@amplitude/plugin-form-interaction-tracking-browser",a="enrichment",s=function(c,f){return I(void 0,void 0,void 0,function(){var d,v;return _(this,function(h){return i=Gd(c),d=function(){if(!f){c.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.");return}if(!(typeof document>"u")){var g=new WeakSet,m=function(y){if(!g.has(y)){g.add(y);var b=!1;r(y,"change",function(){var E,S=Ao(y);b||f.track(To,(E={},E[fn]=ht(y.id),E[vn]=ht(y.name),E[hn]=S,E)),b=!0}),r(y,"submit",function(E){var S,T,w=Ao(y);if(b||f.track(To,(S={},S[fn]=ht(y.id),S[vn]=ht(y.name),S[hn]=w,S)),b=!0,i?.shouldTrackSubmit!==void 0)if(typeof i.shouldTrackSubmit=="function"&&typeof SubmitEvent<"u"&&E instanceof SubmitEvent)try{var P=i.shouldTrackSubmit(E);if(!P)return}catch{c.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else c.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");f.track(sf,(T={},T[fn]=ht(y.id),T[vn]=ht(y.name),T[hn]=w,T)),b=!1})}},p=Array.from(document.getElementsByTagName("form"));p.forEach(m),typeof MutationObserver<"u"&&(t=new MutationObserver(function(y){y.forEac
6h(function(b){b.addedNodes.forEach(function(E){try{if(E.nodeName==="FORM"&&m(E),"querySelectorAll"in E&&typeof E.querySelectorAll=="function"){var S=E,T=S.querySelectorAll("form");T?.forEach(m)}}catch(w){c.loggerProvider.warn("Failed to track form interactions for an added node: ".concat(String(w)))}})})}),t.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState==="complete"?d():(v=z(),v?v.addEventListener("load",d):c.loggerProvider.debug("Form interaction tracking is not installed because global is undefined.")),[2]})})},u=function(c){return I(void 0,void 0,void 0,function(){return _(this,function(f){return[2,c]})})},l=function(){return I(void 0,void 0,void 0,function(){return _(this,function(c){return t?.disconnect(),n(),[2]})})};return{name:o,type:a,setup:s,execute:u,teardown:l}},ht=function(t){if(typeof t=="string")return t},Ao=function(t){var e=t.getAttribute("action");try{e=new URL(encodeURI(e??""),window.location.href).href}catch{}return e},Df=function(){var t,e=[],r=function(l,c,f){l.addEventListener(c,f),e.push({element:l,type:c,handler:f})},n=function(){e.forEach(function(l){var c=l.element,f=l.type,d=l.handler;c?.removeEventListener(f,d)}),e=[]},i="@amplitude/plugin-file-download-tracking-browser",o="enrichment",a=function(l,c){return I(void 0,void 0,void 0,function(){var f,d;return _(this,function(v){return f=function(){if(!c){l.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.");return}if(!(typeof document>"u")){var h=function(p){var y;try{y=new URL(p.href,window.location.href)}catch{return}var b=g.exec(y.href),E=b?.[1];E&&r(p,"click",function(){var S;E&&c.track(uf,(S={},S[lf]=E,S[cf]=y.pathname,S[df]=p.id,S[ff]=p.text,S[vf]=p.href,S))})},g=/\.(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)(\?.+)?$/,m=Array.from(document.getElementsByTagName("a"));m.forEach(h),typeof MutationObserver<"u"&&(t=new MutationObserver(function(p){p.forEach(function(y){y.addedNodes.forEach(function(b){try{if(b.nodeName==="A"&&h(b),"querySelectorAll"in b&&typeof b.querySelectorAll=="function"){var E=b,S=E.querySelectorAll("a");S?.forEach(h)}}catch(T){l.loggerProvider.warn("Failed to track file downloads for an added node: ".concat(String(T)))}})})}),t.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState==="complete"?f():(d=z(),d?d.addEventListener("load",f):l.loggerProvider.debug("File download tracking is not installed because global is undefined.")),[2]})})},s=function(l){return I(void 0,void 0,void 0,function(){return _(this,function(c){return[2,l]})})},u=function(){return I(void 0,void 0,void 0,function(){return _(this,function(l){return t?.disconnect(),n(),[2]})})};return{name:i,type:o,setup:a,execute:s,teardown:u}},ko=!1,xf=function(t){if(!(ko||t.defaultTracking!==void 0)){var e=`\`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:
7
8amplitude.init(<YOUR_API_KEY>, {
9  defaultTracking: true,
10});
11
12Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details.`;t.loggerProvider.warn(e),ko=!0}},Mf=function(){var t="@amplitude/plugin-network-checker-browser",e="before",r=z(),n=[],i=function(u,l){r?.addEventListener&&(r?.addEventListener(u,l),n.push({type:u,handler:l}))},o=function(){n.forEach(function(u){var l=u.type,c=u.handler;r?.removeEventListener(l,c)}),n=[]},a=function(u,l){return I(void 0,void 0,void 0,function(){return _(this,function(c){return typeof navigator>"u"?(u.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),u.offline=!1,[2]):(u.offline=!navigator.onLine,i("online",function(){u.offline!==!1&&(u.loggerProvider.debug("Network connectivity changed to online."),u.offline=!1,setTimeout(function(){l.flush()},u.flushIntervalMillis))}),i("offline",function(){u.loggerProvider.debug("Network connectivity changed to offline."),u.offline=!0}),[2])})})},s=function(){return I(void 0,void 0,void 0,function(){return _(this,function(u){return o(),[2]})})};return{name:t,type:e,setup:a,teardown:s}};function Nf(t,e){var r,n;if(t){ys(t);try{e.loggerProvider.debug("Update browser config with remote configuration:",Ge(t));var i=t;if(i&&"autocapture"in i){if(typeof i.autocapture=="boolean"&&(e.autocapture=i.autocapture),typeof i.autocapture=="object"&&i.autocapture!==null){var o=C({},i.autocapture);if(e.autocapture===void 0&&(e.autocapture=i.autocapture),typeof i.autocapture.elementInteractions=="object"&&i.autocapture.elementInteractions!==null&&(!((r=i.autocapture.elementInteractions.pageUrlAllowlistRegex)===null||r===void 0)&&r.length)){o.elementInteractions=C({},i.autocapture.elementInteractions);var a=o.elementInteractions,s=(n=a.pageUrlAllowlist)!==null&&n!==void 0?n:[],u=i.autocapture.elementInteractions.pageUrlAllowlistRegex;a.pageUrlAllowlist=ms(s,u,e.loggerProvider),delete a.pageUrlAllowlistRegex}
12var l=Ld(i.autocapture.networkTracking,e.loggerProvider);l&&(o.networkTracking=l),typeof e.autocapture=="boolean"&&(e.autocapture=C({attribution:e.autocapture,fileDownloads:e.autocapture,formInteractions:e.autocapture,pageViews:e.autocapture,sessions:e.autocapture,elementInteractions:e.autocapture,webVitals:e.autocapture,frustrationInteractions:e.autocapture},o)),typeof e.autocapture=="object"&&(e.autocapture=C(C({},e.autocapture),o))}e.defaultTracking=e.autocapture}"customEnrichment"in i&&i.customEnrichment!==null&&e.customEnrichment!==!1&&(e.customEnrichment=i.customEnrichment),e.loggerProvider.debug("Browser config after remote config update:",Ge(e))}catch(c){e.loggerProvider.error("Failed to apply remote configuration because of error: ",c)}}}var Os="1.29.3",Uf="@amplitude/plugin-autocapture-browser",Ff="@amplitude/plugin-frustration-browser",Bf="@amplitude/plugin-performance-browser",Ls="[Amplitude] Element Clicked",qf="[Amplitude] Dead Click",Vf="[Amplitude] Rage Click",Wf="[Amplitude] Error Click",Hf="[Amplitude] Element Changed",Gf="[Amplitude] Thrashed Cursor",jf="[Amplitude] Main Thread Block",zf="[Amplitude] Element ID",$f="[Amplitude] Element Class",Ro="[Amplitude] Element Tag",Oo="[Amplitude] Element Text",Kf="[Amplitude] Element Hierarchy",Xf="[Amplitude] Element Href",Yf="[Amplitude] Element Position Left",Qf="[Amplitude] Element Position Top",Jf="[Amplitude] Element Aria Label",Zf="[Amplitude] Element Attributes",ev="[Amplitude] Element Path",tv="[Amplitude] Element Parent Label",zn="[Amplitude] Page URL",rv="[Amplitude] Page Title",Ds="[Amplitude] Viewport Height",xs="[Amplitude] Viewport Width",nv="[Amplitude] Max Page X",iv="[Amplitude] Max Page Y",Ms="[Amplitude] Page View ID",ov="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",av="amp-visual-tagging-selector-highlight",Ns="data-amp-mask-attributes",Us="data-amp-internal-shadow",sv=25,Fs=128,uv="AMP_PAGE_VIEW",lv=18e3,cv=.5,dv=150,fv=4e3,vv=50,hv=[/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/];function gv(t,e){var r,n,i=[];try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(l){var u=l instanceof Error?l.message:String(l);e?.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(s,'" (').concat(u,")"))}}}catch(l){r={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function pv(t,e){var r,n;if(t==null||t==="")return!1;try{for(var i=L(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(a.test(t))return!1}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}var mv=[/^(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-/];function yv(t,e){var r,n,i=[];try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(l){var u=l instanceof Error?l.message:String(l);e?.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(s,'" (').concat(u,")"))}}}catch(l){r={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function Bs(t,e){var r=t.getAttribute(e.explicitTrackingAttribute);if(r!==null&&r==="")return null;var n=t.getAttribute("id");return n===null||n===""||!pv(n,e.autogeneratedIdPatterns)?null:n}function bv(t,e){return e.map(Ev).join(" > ")}function Ev(t){var e=t.tagName.toLowerCase(),r=t.parentElement;if(r===null)return e;var n=Sv(t,r);return"".concat(e,":nth-of-type(").concat(n,")")}function Sv(t,e){for(var r=0,n=0;n<e.children.length;n++){var i=e.children[n];if(i.tagName===t.tagName&&(r+=1,i===t))return r}return 1}var Tv=" >>> ",qs=":scope > ";function je(t){return typeof ShadowRoot<"u"&&t instanceof ShadowRoot}function _v(t,e,r){return t&&r&&je(e)?"".concat(qs).concat(t):t}function Iv(t){for(var e=t;e!==null;e=e.parentElement)if(e.getAttribute("id"))return!1;return!0}function wv(t){var e,r=t.getRootNode();return je(r)?r:(e=t.ownerDocument)!==null&&e!==void 0?e:document}function Cv(t){if(t.parentElement)return t.parentElement;var e=t.getRootNode();return je(e)?e.host:null}var Vs=1024,Pv=5e4;function Ws(t,e){var r,n,i,o;return _(this,function(a){switch(a.label){case 0:r=t,n=0,i=0,a.label=1;case 1:return r!==null&&i<Vs?(i+=1,[4,r]):[3,3];case 2:return a.sent(),r.parentElement?(r=r.parentElement,[3,1]):n<e&&typeof r.getRootNode=="function"&&(o=Cv(r),o&&o!==r)?(n+=1,r=o,[3,1]):[3,3];case 3:return[2]}})}function Hs(t,e){var r=[];if(e<=0)return r;for(var n=[[t,0]],i=0;n.length&&i<Pv;){i+=1;var o=D(n.pop(),2),a=o[0],s=o[1],u=a.shadowRoot;if(u&&s+1<=e){r.push({root:u,depth:s+1});for(var l=u.children,c=0;c<l.length;c++)n.push([l[c],s+1])}for(var f=a.children,c=0;c<f.length;c++)n.push([f[c],s])}return r}function Gs(t,e){for(var r=[],n=t,i=0;n!==null&&i<Vs;){i+=1;var o=wv(n);
12r.push({root:o,target:n});var a=n.getRootNode();if(!je(a))break;n=a.host}var s=r.length-1,u=!1,l=r;return s>e&&(l=r.slice(s-e),u=!0),{segments:l.reverse(),truncated:u}}function Av(t,e){var r=t.tagName.toLowerCase(),n=t.parentElement;if(n===null){var i=t.getRootNode();return e&&je(i)?"".concat(r,":nth-of-type(").concat(Lo(t,i.children),")"):r}return"".concat(r,":nth-of-type(").concat(Lo(t,n.children),")")}function Lo(t,e){for(var r=0,n=0;n<e.length;n++){var i=e[n];if(i.tagName===t.tagName&&(r+=1,i===t))return r}return 1}var kv={name:"explicitTrackingAttribute",try:function(t,e){var r=e.config.explicitTrackingAttribute,n=t.getAttribute(r);return n===null||n===""?null:"[".concat(r,"=").concat(JSON.stringify(n),"]")}};function Nr(t){var e=globalThis.CSS;if(e&&typeof e.escape=="function")return e.escape(t);for(var r=String(t),n=r.length,i="",o=0;o<n;o++){var a=r.charCodeAt(o);if(a===0){i+="�";continue}if(a>=1&&a<=31||a===127||o===0&&a>=48&&a<=57||o===1&&a>=48&&a<=57&&r.charCodeAt(0)===45){i+="\\".concat(a.toString(16)," ");continue}if(o===0&&n===1&&a===45){i+="\\-";continue}if(a>=128||a===45||a===95||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122){i+=r.charAt(o);continue}i+="\\".concat(r.charAt(o))}return i}function js(t){return Nr(t)}var Rv={name:"stableId",try:function(t,e){var r=Bs(t,e.config);return r===null?null:"".concat(t.tagName.toLowerCase(),"#").concat(js(r))}},zs=!1,$s=1,Ov=10,tt=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:W([],D(hv),!1),unstableClassPatterns:W([],D(mv),!1),maxAncestorWalkDepth:void 0,shadowDomEnabled:zs,maxShadowDomDepth:$s});function Jt(t){var e;return C(C({},t),{shadowDomEnabled:(e=t.shadowDomEnabled)!==null&&e!==void 0?e:zs,maxShadowDomDepth:Xs(t.maxShadowDomDepth)})}function Ks(t,e){if(!t)return Do();var r=Do();return typeof t.enabled=="boolean"&&(r.enabled=t.enabled),typeof t.explicitTrackingAttribute=="string"&&t.explicitTrackingAttribute!==""&&(r.explicitTrackingAttribute=t.explicitTrackingAttribute),Array.isArray(t.autogeneratedIdPatterns)&&(r.autogeneratedIdPatterns=gv(t.autogeneratedIdPatterns,e)),Array.isArray(t.unstableClassPatterns)&&(r.unstableClassPatterns=yv(t.unstableClassPatterns,e)),r.maxAncestorWalkDepth=Lv(t.maxAncestorWalkDepth),typeof t.shadowDomEnabled=="boolean"&&(r.shadowDomEnabled=t.shadowDomEnabled),r.maxShadowDomDepth=Xs(t.maxShadowDomDepth),Jt(r)}function Lv(t){if(typeof t=="number"&&Number.isFinite(t)&&!(t<=0))return Math.floor(t)}function Xs(t){return typeof t!="number"||!Number.isFinite(t)?$s:Math.min(Math.max(Math.floor(t),1),Ov)}function Do(){return{enabled:tt.enabled,explicitTrackingAttribute:tt.explicitTrackingAttribute,autogeneratedIdPatterns:W([],D(tt.autogeneratedIdPatterns),!1),unstableClassPatterns:W([],D(tt.unstableClassPatterns),!1),maxAncestorWalkDepth:tt.maxAncestorWalkDepth,shadowDomEnabled:tt.shadowDomEnabled,maxShadowDomDepth:tt.maxShadowDomDepth}}var Dv=[kv,Rv];function xv(t,e,r){var n,i,o,a,s;r===void 0&&(r={});var u=Jt(e),l=(o=r.strategies)!==null&&o!==void 0?o:Dv,c=(s=(a=r.scope)!==null&&a!==void 0?a:t.ownerDocument)!==null&&s!==void 0?s:document,f={scope:c,config:u},d=Mv(t,u.maxAncestorWalkDepth);try{for(var v=L(l),h=v.next();!h.done;h=v.next())for(var g=h.value,m=0;m<d.length;m++){var p=d[m],y=g.try(p,f);if(y!==null){if(m===0){if(xo(c,y,t,g.name,r.logger))return y;continue}var b=d.slice(0,m).reverse(),E=bv(p,b),S="".concat(y," > ").concat(E);if(xo(c,S,t,g.name,r.logger))return S}}}catch(T){n={error:T}}finally{try{h&&!h.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return null}function Mv(t,e){for(var r=[],n=t;n!==null&&(r.push(n),!(e!==void 0&&r.length>e));)n=n.parentElement;return r}function xo(t,e,r,n,i){var o;try{o=t.querySelectorAll(e)}catch(s){var a=s instanceof Error?s.message:String(s);return i?.debug('@amplitude/element-selector: strategy "'.concat(n,'" emitted a malformed selector "').concat(e,'" (').concat(a,")")),!1}return o.length===1&&o[0]===r}function Nv(t,e,r){var n,i;r===void 0&&(r={});for(var o=Jt(e),a=(i=(n=r.scope)!==null&&n!==void 0?n:t.ownerDocument)!==null&&i!==void 0?i:document,s=je(a),u=[],l=t,c=0,f=!(o.shadowDomEnabled&&s);l!==null&&!(f&&o.maxAncestorWalkDepth!==void 0&&c>o.maxAncestorWalkDepth);){var d=Bs(l,o);if(d!==null){var v="".concat(l.tagName.toLowerCase(),"#").concat(js(d)),h=W([v],D(u),!1).join(" > ");if(Uv(a,h,t))return h}u.unshift(Av(l,o.shadowDomEnabled)),l=l.parentElement,c+=1}var g=u.join(" > ");return o.shadowDomEnabled&&s&&l===null?"".concat(qs).concat(g):g}function Uv(t,e,r){var n;try{n=t.querySelectorAll(e)}catch{return!1}return n.length===1&&n[0]===r}var Bt=(function(){function t(e,r){this.value=e,this.optimized=r}return t.prototype.toString=function(){return this.value},t}
12)(),Fv=function(t,e){if(t.nodeType!==Node.ELEMENT_NODE)return"";for(var r=[],n=t;n;){var i=Bv(n,!!e,n===t);if(!i||(r.push(i),i.optimized))break;n=n.parentElement}return r.reverse(),r.join(" > ")},Bv=function(t,e,r){var n,i;if(t.nodeType!==Node.ELEMENT_NODE)return null;var o=t.getAttribute("id");if(e){if(o)return new Bt(No(o),!0);var a=t.tagName.toLowerCase();if(a==="body"||a==="head"||a==="html")return new Bt(a,!0)}var s=t.tagName.toLowerCase();if(o)return new Bt(s+No(o),!0);var u=t.parentNode;if(!u||u.nodeType===Node.DOCUMENT_NODE)return new Bt(s,!0);for(var l=Mo(t),c=!1,f=!1,d=-1,v=-1,h=u.children,g=0;h&&(d===-1||!f)&&g<h.length;++g){var m=h[g];if(m.nodeType===Node.ELEMENT_NODE){if(v+=1,m===t){d=v;continue}if(!f&&m.tagName.toLowerCase()===s){c=!0;var p=new Set(l);if(!p.size){f=!0;continue}for(var y=Mo(m),b=0;b<y.length;++b){var E=y[b];if(p.has(E)&&(p.delete(E),!p.size)){f=!0;break}}}}}var S=s;if(r&&s.toLowerCase()==="input"&&t.getAttribute("type")&&!t.getAttribute("id")&&!t.getAttribute("class")&&(S+="[type="+Nr(t.getAttribute("type")||"")+"]"),f)S+=":nth-child("+String(d+1)+")";else if(c)try{for(var T=L(l),w=T.next();!w.done;w=T.next()){var P=w.value;S+="."+Nr(P.slice(1))}}catch(A){n={error:A}}finally{try{w&&!w.done&&(i=T.return)&&i.call(T)}finally{if(n)throw n.error}}return new Bt(S,!1)},Mo=function(t){var e=t.getAttribute("class");return e?e.split(/\s+/g).filter(Boolean).map(function(r){return"$"+r}):[]},No=function(t){return"#"+Nr(t)};function Uo(t,e){try{return Fv(t)}catch(n){var r=n instanceof Error?n.message:String(n);return e?.warn("@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ".concat(r)),""}}function qv(t,e){e===void 0&&(e={});var r=Jt(t),n=new Set,i=e.logger,o=function(l){return Uo(l,i)},a=function(l,c){var f;return(f=xv(l,r,{strategies:e.strategies,scope:c,logger:i}))!==null&&f!==void 0?f:Nv(l,r,{scope:c})},s=function(l,c){return _v(o(l),c,Iv(l))};function u(l,c){var f=Gs(l,r.maxShadowDomDepth),d=f.segments,v=f.truncated;return v&&i?.debug("@amplitude/element-selector: target is nested deeper than maxShadowDomDepth (".concat(r.maxShadowDomDepth,") — emitting a best-effort selector for the outermost in-budget shadow host")),d.map(function(h){var g=h.target,m=h.root;return c(g,m)}).join(Tv)}return{generate:function(l){var c,f;try{if(!r.shadowDomEnabled){var d=r.enabled?a:o;return d(l,(f=(c=e.scope)!==null&&c!==void 0?c:l.ownerDocument)!==null&&f!==void 0?f:document)}return u(l,r.enabled?a:s)}catch(h){var v=h instanceof Error?h.message:String(h);return i?.warn("@amplitude/element-selector: selector generation threw — falling back to legacy cssPath: ".concat(v)),Uo(l,i)}},getConfig:function(){return r},updateConfig:function(l){var c,f;r=Jt(l);try{for(var d=L(n),v=d.next();!v.done;v=d.next()){var h=v.value;try{h(r)}catch(m){var g=m instanceof Error?m.message:String(m);i?.warn("@amplitude/element-selector: onConfigChange subscriber threw — ".concat(g))}}}catch(m){c={error:m}}finally{try{v&&!v.done&&(f=d.return)&&f.call(d)}finally{if(c)throw c.error}}},onConfigChange:function(l){return n.add(l),function(){n.delete(l)}}}}var Vv=1,dt=Object.freeze({enabled:!1,maxDepth:0}),Wv=function(t){var e,r=(e=t.maxShadowDomDepth)!==null&&e!==void 0?e:Vv;return!t.shadowDomEnabled||r<=0?dt:Object.freeze({enabled:!0,maxDepth:r})},Hv=function(){var t=dt,e=new Set,r=function(n){var i,o;try{for(var a=L(W([],D(e),!1)),s=a.next();!s.done;s=a.next()){var u=s.value;try{u(n)}catch{}}}catch(l){i={error:l}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}e.clear()};return{get:function(){return t},arm:function(n){return t.enabled||!n.enabled||(t=n,r(n)),t},onArm:function(n){if(t.enabled){var i=t;try{n(i)}catch{}return function(){}}return e.add(n),function(){e.delete(n)}}}},pn,Gv=function(){return pn||(pn=Hv()),pn},jv=["input","select","textarea"],zv=function(t,e){var r,n=(r=window?.getComputedStyle)===null||r===void 0?void 0:r.call(window,t);return n?.getPropertyValue("cursor")==="pointer"&&e==="click"},Ci=function(t){var e=t.pageUrlAllowlist,r=t.pageUrlExcludelist;return!(r&&r.length>0&&Vn(window.location.href,r)||!Vn(window.location.href,e))},_t=function(t,e){return function(r,n){var i,o,a=t.shouldTrackEventResolver,s=(o=(i=n?.tagName)===null||i===void 0?void 0:i.toLowerCase)===null||o===void 0?void 0:o.call(i);if(!s)return!1;if(a)return a(r,n);if(!Ci(t))return!1;var u=String(n?.getAttribute("type"))||"";if(typeof u=="string")switch(u.toLowerCase()){case"hidden":return!1;case"password":return!1}if(e){var l=e.some(function(c){var f;return!!(!((f=n?.matches)===null||f===void 0)&&f.call(n,c))});if(!l)return!1}switch(s){case"input":case"select":case"textarea":return r==="change"||r==="click";default:return r==="click"}}},$v=function(t){var e,r,n,i=(r=(e=t?.tagName)===null||e===void 0?void 0:e.toLowerCase)===null||r===void 0?void 0:r.call(e),o=t instanceof HTMLElement?((n=t.getAttribute("contenteditable"))===null||n===void 0?void 0:n.toLowerCase())==="true":!1;return!jv.includes(i)&&!o},Kv=function(t){return t?t.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&e!=="id"&&e!=="class"}):[]},Xv=function(t,e){return Object.entries(t).reduce(function(r,n){var i=D(n,2),o=i[0],a=i[1];if(o.startsWith(e)){var s=o.replace(e,"");s&&(r[s]=a||"")}return r},{})},Yv=function(t){return t==null||typeof t=="object"&&Object.keys(t).length===0||typeof t=="string"&&t.trim().length===0},Fo=function(t){return Object.keys(t).reduce(function(e,r){var n=t[r];return Yv(n)||(e[r]=n),e},{})},Ys=function(){var t;try{var e=z(),r=(t=e?.sessionStorage)===null||t===void 0?void 0:t.getItem(uv);if(!r)return;var n=JSON.parse(r);if(typeof n.pageViewId=="string")return n.pageViewId}catch{}},Qs=function(t,e,r){return r===void 0&&(r=dt),r.enabled?Qv(t,e,r.maxDepth):Js(t,e)},Js=function(t,e){return t?e.some(function(r){var n;return(n=t?.matches)===null||n===void 0?void 0:n.call(t,r)})?t:Js(t?.parentElement,e):null},Qv=function(t,e,r){var n,i;if(!t)return null;var o=function(c){if(e.some(function(f){var d;return(d=c?.matches)===null||d===void 0?void 0:d.call(c,f)}))return{value:c}};try{for(var a=L(Ws(t,r)),s=a.next();!s.done;s=a.next()){var u=s.value,l=o(u);if(typeof l=="object")return l.value}}catch(c){n={error:c}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return null},Bo=function(t,e,r){return r===void 0&&(r=dt),r.enabled?Jv(t,e,r.maxDepth):Zs(t,e)},Zs=function(t,e){var r=[];return e&&t.querySelectorAll(e).forEach(function(n){return r.push(n)}),r},Jv=function(t,e,r){var n=Zs(t,e),i=t instanceof Document?t.documentElement:t;return i&&Hs(i,r).forEach(function(o){var a=o.root;a.querySelectorAll(e).forEach(function(s){return n.push(s)})}),n},Zv=function(t,e){var r,n;if(e===void 0&&(e=dt),!e.enabled)return t.target;var i=(r=t.composedPath)===null||r===void 0?void 0:r.call(t),o=(n=t.target)!==null&&n!==void 0?n:null;if(!i||i.length===0)return o;var a=i[0];if(!(a instanceof Element))return a??o;var s=Gs(a,e.maxDepth),u=s.segments,l=s.truncated;return l&&u.length>0?u[u.length-1].target:a},tr=function(t){return!(t.event.target===null||!t.closestTrackedAncestor)};function eh(t){return t.type==="click"||t.type==="change"}function Pi(t){if(!t)return"";try{var e=new URL(t);return e.search="",Se(e.href)}catch{return Se(t)}}function It(t){var e,r;return t===void 0&&(t=z()),Pi((r=(e=t?.location)===null||e===void 0?void 0:e.href)!==null&&r!==void 0?r:"")}function th(t,e){var r;if(e===void 0&&(e=z()),t==null||t==="")return It(e);var n=((r=e?.location)===null||r===void 0?void 0:r.href)||"http://localhost/";try{return Pi(new URL(t,n).href)}catch{return It(e)}}var Ur;(function(t){t[t.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",t[t.MIDDLE=1]="MIDDLE",t[t.RIGHT=2]="RIGHT"})(Ur||(Ur={}));var qo="__AMPLITUDE_VISUAL_TAGGING__";function rh(t,e){var r=t;if(r[qo]!==!0){r[qo]=!0;var n=e.dataExtractor,i=e.isElementSelectable,o=e.cssSelectorAllowlist,a=e.actionClickAllowlist,s=null,u=function(c){t.notify({action:"element-selected",data:c})},l=function(c,f){c==="selector-mode-changed"?t.notify({action:"track-selector-mode-changed",data:f}):c==="selector-moved"&&t.notify({action:"track-selector-moved",data:f})};t.registerActionHandler("initialize-visual-tagging-selector",function(c){t.loadScriptOnce(ov).then(function(){var f;s=(f=window?.amplitudeVisualTaggingSelector)===null||f===void 0?void 0:f.call(window,{getEventTagProps:n.getEventTagProps,isElementSelectable:function(d){return i?i(c?.actionType||"click",d):!0},onTrack:l,onSelect:u,visualHighlightClass:av,messenger:t,cssSelectorAllowlist:o,actionClickAllowlist:a,extractDataFromDataSource:n.extractDataFromDataSource,dataExtractor:n,diagnostics:{autocapture:{version:Os}}}),t.notify({action:"selector-loaded"})}).catch(function(){var f;(f=t.logger)===null||f===void 0||f.warn("Failed to initialize visual tagging selector")})}),t.registerActionHandler("close-visual-tagging-selector",function(){var c;
12(c=s?.close)===null||c===void 0||c.call(s)})}}function nh(t){var e=t.amplitude,r=t.allObservables,n=t.shouldTrackEvent,i=t.evaluateTriggers,o=r.clickObservable,a=o.filter(tr).filter(function(u){return n("click",u.closestTrackedAncestor)}).map(function(u){return i(u)}),s=a;return s.subscribe(function(u){e?.track(Ls,u.targetElementProperties)})}function ih(t){var e=t.amplitude,r=t.allObservables,n=t.getEventProperties,i=t.shouldTrackEvent,o=t.evaluateTriggers,a=r.changeObservable,s=a.filter(tr).filter(function(u){return i("change",u.closestTrackedAncestor)}).map(function(u){return o(u)});return s.subscribe(function(u){e?.track(Hf,n("change",u.closestTrackedAncestor))})}function oh(t){var e=t.amplitude,r=t.allObservables,n=t.options,i=t.getEventProperties,o=t.shouldTrackEvent,a=t.shouldTrackActionClick,s=r.clickObservable,u=r.mutationObservable,l=r.navigateObservable,c=s.filter(function(m){return!o("click",m.closestTrackedAncestor)}).map(function(m){var p=Qs(m.event.target,n.actionClickAllowlist);return m.closestTrackedAncestor=p,m.closestTrackedAncestor!==null&&(m.targetElementProperties=i(m.type,m.closestTrackedAncestor)),m}).filter(tr).filter(function(m){return a("click",m.closestTrackedAncestor)}),f=l?lt(u,l):u,d=lt(c,f),v=null,h=null,g=Ii(d,function(m){if(v&&(clearTimeout(v),v=null),m.type==="click")return h=m,v=setTimeout(function(){v=null,h=null},500),Promise.resolve(null);if(h){var p=h;return h=null,Promise.resolve(p)}return Promise.resolve(null)});return g.subscribe(function(m){m&&e?.track(Ls,i("click",m.closestTrackedAncestor))})}function ah(t){var e=t.allObservables,r=e.scrollObservable,n={maxX:0,maxY:0},i=r.subscribe(function(){var o,a,s,u,l=z(),c=Math.floor((a=(o=l?.scrollX)!==null&&o!==void 0?o:l?.pageXOffset)!==null&&a!==void 0?a:0),f=Math.floor((u=(s=l?.scrollY)!==null&&s!==void 0?s:l?.pageYOffset)!==null&&u!==void 0?u:0);n.maxX=Math.max(n.maxX,c),n.maxY=Math.max(n.maxY,f)});return{unsubscribe:function(){i.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}var Ct=z(),Gt=function(t){return t.get()},sh={childList:!0,attributes:!0,characterData:!0,subtree:!0},eu=function(t){return t?new he(function(e){var r=new WeakSet,n=new WeakMap,i=function(c,f){r.has(c)||(r.add(c),je(c)&&n.set(c,f),s.observe(c,sh))},o=function(c,f,d){var v=d-f;v<=0||Hs(c,v).forEach(function(h){var g=h.root,m=h.depth;return i(g,f+m)})},a=function(c){var f=c.getRootNode();if(!je(f))return 0;var d=n.get(f);return d??0},s=new MutationObserver(function(c){var f,d;e.next(c);try{var v=Gt(t);if(!v.enabled)return;var h=function(y){var b=a(y.target);y.addedNodes.forEach(function(E){E instanceof Element&&o(E,b,v.maxDepth)})};try{for(var g=L(c),m=g.next();!m.done;m=g.next()){var p=m.value;h(p)}}catch(y){f={error:y}}finally{try{m&&!m.done&&(d=g.return)&&d.call(g)}finally{if(f)throw f.error}}}catch{}}),u;if(document.body){var l=document.body;i(l,0),u=t.onArm(function(c){o(l,0,c.maxDepth)})}return function(){u?.(),s.disconnect()}}):new he(function(e){var r=new MutationObserver(function(n){e.next(n)});return document.body&&r.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return r.disconnect()}})},tu=function(t){return t===void 0&&(t="click"),new he(function(e){var r,n=function(i){e.next(i)};return(r=z())===null||r===void 0||r.document.addEventListener(t,n,{capture:!0}),function(){var i;(i=z())===null||i===void 0||i.document.removeEventListener(t,n,{capture:!0})}})},uh=function(){return new he(function(t){var e,r,n=function(i){t.next(i)};return(e=z())===null||e===void 0||e.addEventListener("scroll",n,{capture:!0,passive:!0}),(r=z())===null||r===void 0||r.addEventListener("resize",n,{passive:!0}),function(){var i,o;(i=z())===null||i===void 0||i.removeEventListener("scroll",n,{capture:!0}),(o=z())===null||o===void 0||o.removeEventListener("resize",n)}})},lh=function(){return new he(function(t){var e=function(r){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var o=void 0;Array.isArray(n[0])&&typeof n[0][0]=="string"&&(o=n[0][0]),t.next({kind:"console",message:o})};return fo.addListener("error",e),function(){fo.removeListener(e)}})},ch=function(t,e,r,n){var i=typeof r=="function"?r:void 0,o=typeof r=="function"?n:r;return new he(function(a){var s=z();if(!s?.IntersectionObserver)return function(){};var u=new IntersectionObserver(function(g){g.forEach(function(m){a.next(m)})},{root:null,rootMargin:"0px",threshold:0}),l=e.join(","),c=function(g){g instanceof Element&&g.matches(l)&&u.observe(g),g.querySelectorAll(l).forEach(function(m){u.observe(m)})}
12,f=function(g){if(o)try{Bo(g,l,Gt(o)).forEach(function(m){u.observe(m)})}catch{}},d=function(){var g=s?.document;if(g){var m=[];try{o&&Gt(o).enabled?m=Bo(g,l,Gt(o)):m=g.querySelectorAll(l)}catch{return}Array.from(m).forEach(function(p){u.unobserve(p),u.observe(p)})}};i?.(d),d();var v=o?.onArm(function(){s?.document&&f(s.document)}),h=t.subscribe(function(g){var m=g.event;return m.forEach(function(p){var y=p.addedNodes;return y.forEach(function(b){if(b instanceof DocumentFragment){c(b);return}if(b instanceof Element){if(!o||!Gt(o).enabled){c(b);return}try{b.matches(l)&&u.observe(b)}catch{}f(b)}})})});return function(){i?.(void 0),v?.(),h.unsubscribe(),u.disconnect()}})},dh=function(){return new he(function(t){var e=function(r){if(r instanceof ErrorEvent){var n={kind:"error"};r.error instanceof Error||r.error instanceof DOMException?n=C(C({},n),{message:r.error.message,stack:r.error.stack,filename:r.filename,lineNumber:r.lineno,columnNumber:r.colno}):typeof r.error=="string"&&(n.message=r.error),t.next(n)}};return Ct.addEventListener("error",e),function(){Ct.removeEventListener("error",e)}})},fh=function(){return new he(function(t){var e=function(r){var n={kind:"unhandledrejection"};r.reason instanceof Error||r.reason instanceof DOMException?(n.message=r.reason.message,n.stack=r.reason.stack):typeof r.reason=="string"&&(n.message=r.reason),t.next(n)};return Ct.addEventListener("unhandledrejection",e),function(){Ct.removeEventListener("unhandledrejection",e)}})},vh=function(){var t=lt(dh(),fh());return lt(t,lh())},hh=function(){return new he(function(t){var e=function(n){t.next(n)},r={capture:!0};return Ct.document.addEventListener("mousemove",e,r),function(){Ct.document.removeEventListener("mousemove",e,r)}})},gh=function(t,e){try{if(e.subprop_key==="[Amplitude] Element Text")return e.subprop_op==="is"&&e.subprop_value.includes(t.targetElementProperties["[Amplitude] Element Text"]);if(e.subprop_key==="[Amplitude] Element Hierarchy")return e.subprop_op==="autotrack css match"&&!!t.closestTrackedAncestor.closest(e.subprop_value.toString())}catch(r){return console.error("Error matching event to filter",r),!1}return!1},ph=function(t,e){try{if(t.sourceType==="DOM_ELEMENT"){var r=document.documentElement;return t.scope&&e&&(r=e.closest(t.scope)),r&&t.selector?r.querySelector(t.selector):r}}catch{return}},mh=function(t,e,r){t.forEach(function(n){if(typeof n!="string"&&n.actionType==="ATTACH_EVENT_PROPERTY"){var i=r.extractDataFromDataSource(n.dataSource,e.closestTrackedAncestor);e.targetElementProperties[n.destinationKey]=i}})},$n={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Vo=function(t){var e,r,n,i,o=Object.values($n).reduce(function(v,h){return v[h]=new Set,v},{});if(!t)return o;try{for(var a=L(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{try{for(var l=(n=void 0,L(u.definition)),c=l.next();!c.done;c=l.next()){var f=c.value,d=$n[f.event_type];d&&o[d].add(u.id)}}catch(v){n={error:v}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}}catch(v){console.warn("Skipping Labeled Event due to malformed definition",u?.id,v)}}}catch(v){e={error:v}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o},Wo=function(t){var e,r,n,i,o=new Map;try{for(var a=L(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var l=(n=void 0,L(u.conditions)),c=l.next();!c.done;c=l.next()){var f=c.value;if(f.type==="LABELED_EVENT"){var d=f.match.eventId,v=o.get(d);v||(v=[],o.set(d,v)),v.push(u)}}}catch(h){n={error:h}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}}}catch(h){e={error:h}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o},yh=function(t,e){return e.filter(function(r){return r.definition.some(function(n){return $n[n.event_type]===t.type&&n.filters.every(function(i){return gh(t,i)})})})},bh=function(t,e){var r,n,i,o,a=new Set;try{for(var s=L(t),u=s.next();!u.done;u=s.next()){var l=u.value,c=e.get(l.id);if(c)try{for(var f=(i=void 0,L(c)),d=f.next();!d.done;d=f.next()){var v=d.value;a.add(v)}}catch(h){i={error:h}}
12finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}}}catch(h){r={error:h}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return Array.from(a)},Eh=(function(){function t(e,r,n,i){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=r,this.dataExtractor=n,this.options=i}return t.prototype.evaluate=function(e){var r,n,i=this.options.pageActions;if(!i)return e;var o=yh(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(c){return i.labeledEvents[c]})),a=bh(o,this.labeledEventToTriggerMap);try{for(var s=L(a),u=s.next();!u.done;u=s.next()){var l=u.value;mh(l.actions,e,this.dataExtractor)}}catch(c){r={error:c}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return e},t.prototype.update=function(e,r,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=r,this.options=n},t})(),Sh=function(t,e,r,n){return new Eh(t,e,r,n)},Th=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Ns,Ye,Us]),_h=["type"],Ih=["svg","path","g"],wh=["password","hidden"];function Ch(t,e){if(t.parentElement)return t.parentElement.children;var r=t.getRootNode();return e&&je(r)?r.children:[]}function Ph(t,e,r){var n,i,o,a,s;if(r===void 0&&(r=dt),t===null)return null;var u=String(t.tagName).toLowerCase(),l={tag:u},c=Array.from(Ch(t,r.enabled));c.length&&(l.index=c.indexOf(t),l.indexOfType=c.filter(function(S){return S.tagName===t.tagName}).indexOf(t));var f=(s=(a=t.previousElementSibling)===null||a===void 0?void 0:a.tagName)===null||s===void 0?void 0:s.toLowerCase();f&&(l.prevSib=String(f));var d=t.getAttribute("id");d&&(l.id=String(d));var v=Array.from(t.classList);v.length&&(l.classes=v);var h={},g=Array.from(t.attributes),m=g.filter(function(S){return!Th.has(S.name)}),p=!$v(t);if(!wh.includes(String(t.getAttribute("type")))&&!Ih.includes(u))try{for(var y=L(m),b=y.next();!b.done;b=y.next()){var E=b.value;
12if(!(p&&!_h.includes(E.name))){if(e.has(E.name)){h[E.name]=Xe;continue}h[E.name]=String(E.value).substring(0,Fs)}}}catch(S){n={error:S}}finally{try{b&&!b.done&&(i=y.return)&&i.call(y)}finally{if(n)throw n.error}}return Object.keys(h).length&&(l.attrs=h),t.shadowRoot&&(l.attrs=C(C({},l.attrs||{}),(o={},o[Us]="true",o)),l.shadow=!0),l}function ru(t,e){return e===void 0&&(e=dt),t?e.enabled?kh(t,e.maxDepth):Ah(t):[]}function Ah(t){var e=[];e.push(t);for(var r=t.parentElement;r&&r.tagName!=="HTML";)e.push(r),r=r.parentElement;return e}function kh(t,e){var r,n,i=[];try{for(var o=L(Ws(t,e)),a=o.next();!a.done;a=o.next()){var s=a.value;if(s.tagName==="HTML")break;i.push(s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}var Rh=function(t){return t.closest("[".concat(Ye,"]"))!==null},Oh=function(t,e){var r,n;return ru(t,e).some(function(i){return i.hasAttribute(Ye)})?!0:(n=(r=document.documentElement)===null||r===void 0?void 0:r.hasAttribute(Ye))!==null&&n!==void 0?n:!1},mn;function Lh(){return mn||(mn=qv(Ks())),mn}var nu=(function(){function t(e,r){var n,i,o=this,a;this.replaceSensitiveString=function(d){return Ti(d,o.additionalMaskTextPatterns)},this.getHierarchy=function(d){var v,h,g,m,p=performance.now(),y=[];if(!d)return[];for(var b=o.getShadowMode(),E=ru(d,b),S=new Map,T=E.length-1;T>=0;T--){var w=E[T];if(w){var P=Kv(w.getAttribute(Ns)),A=T===E.length-1?[]:(g=S.get(E[T+1]))!==null&&g!==void 0?g:new Set,F=new Set(W(W([],D(A),!1),D(P),!1));S.set(w,F)}}y=E.map(function(N){var q;return Ph(N,(q=S.get(N))!==null&&q!==void 0?q:new Set,b)});var k=function(N){N?.attrs&&Object.entries(N.attrs).forEach(function(q){var $=D(q,2),H=$[0],j=$[1];N.attrs&&(N.attrs[H]=o.replaceSensitiveString(j))})};try{for(var x=L(y),R=x.next();!R.done;R=x.next()){var M=R.value;k(M)}}catch(N){v={error:N}}finally{try{R&&!R.done&&(h=x.return)&&h.call(x)}finally{if(v)throw v.error}}var U=performance.now();return(m=o.diagnosticsClient)===null||m===void 0||m.recordHistogram("autocapturePlugin.getHierarchy",U-p),y},this.getNearestLabel=function(d){var v=d.parentElement;if(!v)return"";var h;try{h=v.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch{h=null}return h?o.getText(h):o.getNearestLabel(v)},this.getElementPath=function(d){var v;if(!d)return"";var h=performance.now(),g=o.selectorEngine.generate(d),m=performance.now();return(v=o.diagnosticsClient)===null||v===void 0||v.recordHistogram("autocapturePlugin.getElementPath",m-h),g},this.updateSelectorConfig=function(d,v){var h;if(d!=null){var g=typeof d.enabled=="boolean",m=typeof d.shadowDomEnabled=="boolean";if(!g&&!m){v?.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` or `shadowDomEnabled` flag — keeping current engine state.");return}var p=Ks(d,v),y=o.selectorEngine.getConfig().enabled,b=o.shadowGate.get().enabled,E=o.shadowGate.arm(Wv(p));o.selectorEngine.updateConfig(C(C(C({},g?p:o.selectorEngine.getConfig()),{shadowDomEnabled:E.enabled}),E.enabled&&{maxShadowDomDepth:E.maxDepth})),g&&y!==p.enabled&&v?.debug(p.enabled?"@amplitude/element-selector: engine enabled — now emitting new element-selector element paths for autocapture events.":"@amplitude/element-selector: engine disabled — reverting to legacy cssPath for element paths."),!b&&E.enabled&&((h=o.diagnosticsClient)===null||h===void 0||h.setTag("plugin.autocapture.shadowDom","enabled:".concat(E.maxDepth)))}}
12,this.getShadowMode=function(){return o.shadowGate.get()},this.getEventProperties=function(d,v,h){var g,m,p,y,b=(p=(m=v?.tagName)===null||m===void 0?void 0:m.toLowerCase)===null||p===void 0?void 0:p.call(m),E=typeof v.getBoundingClientRect=="function"?v.getBoundingClientRect():{left:null,top:null},S=o.getHierarchy(v),T=(y=S[0])===null||y===void 0?void 0:y.attrs,w=o.getNearestLabel(v),P=Xv(T??{},h),A=(g={},g[Kf]=S,g[Ro]=b,g[Oo]=o.getText(v),g[Yf]=E.left==null?null:Math.round(E.left),g[Qf]=E.top==null?null:Math.round(E.top),g[Zf]=P,g[ev]=o.getElementPath(v),g[tv]=w,g[zn]=Se(window.location.href.split("?")[0]),g[rv]=_i(o.replaceSensitiveString),g[Ds]=window.innerHeight,g[xs]=window.innerWidth,g),F=Ys();if(F&&(A[Ms]=F),A[zf]=v.getAttribute("id")||"",A[$f]=v.getAttribute("class"),A[Jf]=T?.["aria-label"],b==="a"&&d==="click"&&v instanceof HTMLAnchorElement){var k=v.href.substring(0,Fs);A[Xf]=o.replaceSensitiveString(k)}return Fo(A)},this.addTypeAndTimestamp=function(d,v){return{event:d,timestamp:Date.now(),type:v}},this.addAdditionalEventProperties=function(d,v,h,g,m){m===void 0&&(m=!1);var p=o.addTypeAndTimestamp(d,v);try{if(eh(p)&&p.event.target!==null){var y=o.getShadowMode(),b=Zv(p.event,y);if(m){var E=zv(b,p.type);if(E)return p.closestTrackedAncestor=b,p.targetElementProperties=o.getEventProperties(p.type,p.closestTrackedAncestor,g),p}var S=Qs(b,h,y);S&&(p.closestTrackedAncestor=S,p.targetElementProperties=o.getEventProperties(p.type,S,g))}}catch{}return p},this.extractDataFromDataSource=function(d,v){if(d.sourceType==="DOM_ELEMENT"){var h=ph(d,v);return h?d.elementExtractType==="TEXT"?o.getText(h):d.elementExtractType==="ATTRIBUTE"&&d.attribute?h.getAttribute(d.attribute):void 0:void 0}},this.getTextWithMaskedDescendants=function(d){var v,h,g="[".concat(Ye,"], [contenteditable]");if(!d.querySelector(g))return d.innerText;var m="",p=Array.from(d.childNodes);try{for(var y=L(p),b=y.next();!b.done;b=y.next()){var E=b.value;if(E.nodeType===Node.TEXT_NODE){m+=E.textContent||"";continue}if(E instanceof Element){if(E.hasAttribute(Ye)||E.hasAttribute("contenteditable")){m+=Xe;continue}m+=o.getTextWithMaskedDescendants(E)}}}catch(S){v={error:S}}finally{try{b&&!b.done&&(h=y.return)&&h.call(y)}finally{if(v)throw v.error}}return m},this.hasMaskedAncestor=function(d){var v=o.getShadowMode();return v.enabled?Oh(d,v):Rh(d)},this.getText=function(d){var v=o.hasMaskedAncestor(d);if(v)return Xe;var h="";return d.querySelector("[".concat(Ye,"], [contenteditable]"))?h=o.getTextWithMaskedDescendants(d):h=d.innerText||"",o.replaceSensitiveString(h.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(d){var v,h,g;if(!d)return{};var m=(g=(h=d?.tagName)===null||h===void 0?void 0:h.toLowerCase)===null||g===void 0?void 0:g.call(h),p=(v={},v[Ro]=m,v[Oo]=o.getText(d),v[zn]=window.location.href.split("?")[0],v);return Fo(p)},this.diagnosticsClient=r?.diagnosticsClient,this.selectorEngine=Lh(),this.shadowGate=Gv();var s=(a=e.maskTextRegex)!==null&&a!==void 0?a:[],u=[];try{for(var l=L(s),c=l.next();!c.done;c=l.next()){var f=c.value;if(u.length>=sv)break;if(f instanceof RegExp)u.push(f);else if("pattern"in f&&typeof f.pattern=="string")try{u.push(new RegExp(f.pattern,"i"))}catch{}}}catch(d){n={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=u}return t})(),Dh="configs.analyticsSDK.browserSDK.autocapture.elementSelector";function iu(t,e){var r=t.remoteConfigClient;if(!(!t.fetchRemoteConfig||!r)){var n=r.subscribe(Dh,"all",function(i,o){t.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(o),") ").concat(JSON.stringify(i))),e.updateSelectorConfig(i,t.loggerProvider)});return function(){r.unsubscribe(n)}}}var lr=1,xh=function(t){var e;return t.assignedSlot||t.parentElement||((e=t.parentNode)===null||e===void 0?void 0:e.host)||null},Ho=function(t,e){return(e==="fixed"||e==="absolute")&&t instanceof HTMLElement?t.offsetParent:xh(t)},Mh=function(t){var e=z(),r=e.document.documentElement.clientHeight||e.innerHeight,n=e.document.documentElement.clientWidth||e.innerWidth,i=t.getBoundingClientRect(),o=i.top+i.height*cv,a=Math.max(i.left,0),s=Math.min(i.right,n);if(o<-lr||o>r+lr||a>=s||i.width<=0)return!1;for(var u=Ho(t,e.getComputedStyle(t).position);u;){var l=e.getComputedStyle(u),c=l.overflowY&&l.overflowY!=="visible",f=l.overflowX&&l.overflowX!=="visible";if(c||f){var d=u.getBoundingClientRect();if(c&&(o<d.top-lr||o>d.bottom+lr)||f&&(a=Math.max(a,d.left),s=Math.min(s,d.right),a>=s))return!1}u=Ho(u,l.position)}return!0};function Nh(t){var e=t.allObservables,r=t.onExposure,n=t.dataExtractor,i=t.exposureDuration,o=i===void 0?cs:i,a=new Map,s=new Map,u=new Set,l=function(m){var p=s.get(m);p&&(clearTimeout(p),s.set(m,null))},c=function(m){if(!Mh(m)){l(m);return}if(!(a.get(m)||s.get(m))){var p=setTimeout(function(){a.set(m,!0);var y=n.getElementPath(m);r(y),s.set(m,null)},o);s.set(m,p)}},f=e.exposureObservable,d=e.scrollObservable,v=f.subscribe(function(m){var p=m,y=p.target;p.isIntersecting?(u.add(y),c(y)):(u.delete(y),l(y))}),h=d.subscribe(function(){u.forEach(c)}
12),g=function(){s.forEach(function(m){m&&clearTimeout(m)}),s.clear(),a.clear()};return{unsubscribe:function(){v.unsubscribe(),h.unsubscribe(),g(),u.clear()},reset:function(){g(),u.forEach(c)}}}function Uh(t){var e,r,n,i=t.amplitude,o=t.scrollTracker,a=t.currentElementExposed,s=t.elementExposedForPage,u=t.elementExposedInSentEvents,l=t.exposureTracker,c=t.isPageEnd,f=t.lastScroll,d=o.getState(),v=z(),h=(r=v?.innerWidth)!==null&&r!==void 0?r:0,g=(n=v?.innerHeight)!==null&&n!==void 0?n:0,m=Array.from(a).filter(function(E){return!u.has(E)}),p=(e={},e[zn]=It(v),e[nv]=d.maxX+h,e[iv]=d.maxY+g,e[Ds]=g,e[xs]=h,e["[Amplitude] Element Exposed"]=m,e),y=Ys();y&&(p[Ms]=y);var b=function(){o.reset();var E=o.getState();f.maxX=E.maxX,f.maxY=E.maxY,s.clear(),u.clear(),l?.reset()};if(m.length===0&&d.maxX===f.maxX&&d.maxY===f.maxY){c&&b();return}i?.track("[Amplitude] Viewport Content Updated",p),f.maxX=d.maxX,f.maxY=d.maxY,m.forEach(function(E){u.add(E)}),a.clear(),c&&b()}function Fh(t,e,r,n,i){if(!(e.has(t)||r.has(t))){e.add(t),n.add(t);var o=Array.from(n),a=JSON.stringify(o);a.length>=lv&&i(!1)}}function Bh(t){var e=t.mutationObservable,r=t.onRescan,n=t.onFlush,i=t.exposureDuration,o=t.quietMs,a=o===void 0?dv:o,s=t.maxWaitMs,u=s===void 0?fv:s,l=!1,c,f,d,v,h,g=function(){c&&(clearTimeout(c),c=void 0),f&&(clearTimeout(f),f=void 0),d&&(clearTimeout(d),d=void 0)},m=function(){h&&(document.removeEventListener("DOMContentLoaded",h),h=void 0)},p=function(){return typeof document<"u"&&document.readyState!=="loading"},y=function(){if(!l){if(!p()){h||(h=function(){h=void 0,b()},document.addEventListener("DOMContentLoaded",h));return}l=!0,g(),m(),r(),d=setTimeout(function(){d=void 0,n()},i+vv)}},b=function(){l||(c&&clearTimeout(c),c=setTimeout(y,a))},E=function(){g(),m(),l=!1,b(),f=setTimeout(y,u)};return{start:function(){v||(v=e.subscribe(function(){b()}),E())},reset:function(){E()},stop:function(){v?.unsubscribe(),v=void 0,g(),m()}}}var pe;(function(t){t.ClickObservable="clickObservable",t.PointerDownObservable="pointerDownObservable",t.ChangeObservable="changeObservable",t.NavigateObservable="navigateObservable",t.MutationObservable="mutationObservable",t.ScrollObservable="scrollObservable",t.ExposureObservable="exposureObservable",t.BrowserErrorObservable="browserErrorObservable",t.SelectionObservable="selectionObservable",t.MouseMoveObservable="mouseMoveObservable"})(pe||(pe={}));var qh=function(t,e){var r,n,i,o,a,s,u,l,c,f,d,v;t===void 0&&(t={}),e?.diagnosticsClient.setTag("plugin.autocapture.version",Os);var h=t.dataAttributePrefix,g=h===void 0?ls:h,m=t.visualTaggingOptions,p=m===void 0?{enabled:!0}:m;t.cssSelectorAllowlist=(r=t.cssSelectorAllowlist)!==null&&r!==void 0?r:Kc,t.actionClickAllowlist=(n=t.actionClickAllowlist)!==null&&n!==void 0?n:Xc,t.debounceTime=(i=t.debounceTime)!==null&&i!==void 0?i:0;var y=((o=t.viewportContentUpdated)===null||o===void 0?void 0:o.enabled)!==!1,b=(u=(s=(a=t.viewportContentUpdated)===null||a===void 0?void 0:a.exposureDuration)!==null&&s!==void 0?s:t.exposureDuration)!==null&&u!==void 0?u:cs;t.viewportContentUpdated=C(C({},t.viewportContentUpdated),{exposureDuration:b}),t.pageUrlExcludelist=(l=t.pageUrlExcludelist)===null||l===void 0?void 0:l.reduce(function(O,G){if(typeof G=="string"&&O.push(G),G instanceof RegExp&&O.push(G),typeof G=="object"&&G!==null&&"pattern"in G)try{O.push(new RegExp(G.pattern))}catch(V){return console.warn("Invalid regex pattern: ".concat(G.pattern),V),O}return O},[]);var E=Uf,S="enrichment",T=[],w=new nu(t,e),P=new Set,A=new Set,F=new Set,k,x,R=function(){var O,G=Ne(tu().map(function(ee){return w.addAdditionalEventProperties(ee,"click",t.cssSelectorAllowlist,g)})),V=Ne(new he(function(ee){var B,ie=function(oe){var se=w.addAdditionalEventProperties(oe,"change",t.cssSelectorAllowlist,g);ee.next(se)};return(B=z())===null||B===void 0||B.document.addEventListener("change",ie,{capture:!0}),function(){var oe;return(oe=z())===null||oe===void 0?void 0:oe.document.removeEventListener("change",ie)}})),X;window.navigation&&(X=Ne(new he(function(ee){var B=function(ie){var oe=w.addAdditionalEventProperties(ie,"navigate",t.cssSelectorAllowlist,g);ee.next(oe)};return window.navigation.addEventListener("navigate",B),function(){window.navigation.removeEventListener("navigate",B)}})));var Y=w.shadowGate,J=Ne(eu(Y).map(function(ee){return w.addAdditionalEventProperties(ee,"mutation",t.cssSelectorAllowlist,g)})),Q=uh(),re=ch(J,t.cssSelectorAllowlist,function(ee){x=ee},Y);return O={},O[pe.ChangeObservable]=V,O[pe.ClickObservable]=G,O[pe.MutationObservable]=J,O[pe.NavigateObservable]=X,O[pe.ScrollObservable]=Q,O[pe.ExposureObservable]=re,O},M=Vo(Object.values((f=(c=t.pageActions)===null||c===void 0?void 0:c.labeledEvents)!==null&&f!==void 0?f:{})),U=Wo((v=(d=t.pageActions)===null||d===void 0?void 0:d.triggers)!==null&&v!==void 0?v:[]),N=Sh(M,U,w,t),q=function(O){var G,V;O&&(t.pageActions=C(C({},t.pageActions),O),M=Vo(Object.values((G=t.pageActions.labeledEvents)!==null&&G!==void 0?G:{})),U=Wo((V=t.pageActions.triggers)!==null&&V!==void 0?V:[]),N.update(M,U,t))},$=function(O,G){return I(void 0,void 0,void 0,function(){var V,X,Y,J,Q,re,ee,B,ie,oe,se,K,ge,be,Te,Je,Ze,Be,Ot,vt,Lt,Dt,xt,Zr,en,ir,tn;return _(this,function(My){return typeof document>"u"?[2]:(V=!1,O.fetchRemoteConfig&&(O.remoteConfigClient?O.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(Z){q(Z)}):O.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),X=iu(O,w),X&&T.push({unsubscribe:X}),Y=_t(t,t.cssSelectorAllowlist),J=_t(t,t.actionClickAllowlist),Q=R(),re=nh({allObservables:Q,amplitude:G,shouldTrackEvent:Y,evaluateTriggers:N.evaluate.bind(N)}),T.push(re),ee=ih({allObservables:Q,getEventProperties:function(){for(var Z=[],ne=0;ne<arguments.length;ne++)Z[ne]=arguments[ne];return w.getEventProperties.apply(w,W(W([],D(Z),!1),[g],!1))},amplitude:G,shouldTrackEvent:Y,evaluateTriggers:N.evaluate.bind(N)}),T.push(ee),B=oh({allObservables:Q,options:t,getEventProperties:function(){for(var Z=[],ne=0;ne<arguments.length;ne++)Z[ne]=arguments[ne];return w.getEventProperties.apply(w,W(W([],D(Z),!1),[g],!1))},amplitude:G,shouldTrackEvent:Y,shouldTrackActionClick:J}),B&&T.push(B),ie=ah({allObservables:Q}),T.push(ie),oe=C({},ie.getState()),se={}
12,K=z(),be=function(Z){Z&&ge?.reset(),!(Z&&V)&&(Z&&(V=!0,setTimeout(function(){V=!1},100)),Uh({amplitude:G,scrollTracker:ie,currentElementExposed:F,elementExposedForPage:P,elementExposedInSentEvents:A,exposureTracker:se.exposure,isPageEnd:Z,lastScroll:oe}))},Te=It(K),Je=function(){var Z=It(K);Z!==Te&&(Te=Z,be(!0))},Ze=function(Z,ne){var Oe=It(K),Mt=th(ne,K);if(Oe===Mt){Z();return}Te=Mt,be(!0),Z()},Be=function(Z){Fh(Z,P,A,F,be)},y&&(se.exposure=Nh({allObservables:Q,onExposure:Be,dataExtractor:w,exposureDuration:b}),se.exposure&&T.push(se.exposure),ge=Bh({mutationObservable:Q[pe.MutationObservable],onRescan:function(){var Z,ne;(ne=(Z=O.loggerProvider)===null||Z===void 0?void 0:Z.debug)===null||ne===void 0||ne.call(Z,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — rescanning DOM"),x?.()},onFlush:function(){var Z,ne;(ne=(Z=O.loggerProvider)===null||Z===void 0?void 0:Z.debug)===null||ne===void 0||ne.call(Z,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — flushing viewport content updated"),be(!1)},exposureDuration:b}),ge.start(),T.push({unsubscribe:function(){ge?.stop()}}),Ot=function(){be(!0)},K?.addEventListener("beforeunload",Ot),k=function(){K?.removeEventListener("beforeunload",Ot)},T.push({unsubscribe:function(){return k()}}),vt=Q[pe.NavigateObservable],vt?T.push(vt.subscribe(function(Z){var ne,Oe,Mt=(Oe=(ne=Z.event)===null||ne===void 0?void 0:ne.destination)===null||Oe===void 0?void 0:Oe.url;if(Mt){var Hi=Pi(Mt);if(Hi===Te)return;Te=Hi,be(!0);return}Je()})):K&&(Lt=function(){Je()},K.addEventListener("popstate",Lt),Dt=K.history.pushState,xt=K.history.replaceState,K.history&&Dt&&(K.history.pushState=new Proxy(Dt,{apply:function(Z,ne,Oe){Ze(function(){Z.apply(ne,Oe)},Oe[2])}})),K.history&&xt&&(K.history.replaceState=new Proxy(xt,{apply:function(Z,ne,Oe){Ze(function(){Z.apply(ne,Oe)},Oe[2])}})),T.push({unsubscribe:function(){K.removeEventListener("popstate",Lt),K.history&&Dt&&(K.history.pushState=Dt),K.history&&xt&&(K.history.replaceState=xt)}}))),(tn=O?.loggerProvider)===null||tn===void 0||tn.log("".concat(E," has been successfully added.")),window.opener&&p.enabled&&(Zr=t.cssSelectorAllowlist,en=t.actionClickAllowlist,ir=Ad(),rh(ir,{dataExtractor:w,isElementSelectable:_t(t,W(W([],D(Zr),!1),D(en),!1)),cssSelectorAllowlist:Zr,actionClickAllowlist:en}),kd(ir),ir.setup(C({logger:O?.loggerProvider},O?.serverZone&&{endpoint:Td[O.serverZone]}))),[2])})})},H=function(O){return I(void 0,void 0,void 0,function(){return _(this,function(G){return[2,O]})})},j=function(){return I(void 0,void 0,void 0,function(){var O,G,V,X,Y;return _(this,function(J){try{for(O=L(T),G=O.next();!G.done;G=O.next())V=G.value,V.unsubscribe()}catch(Q){X={error:Q}}finally{try{G&&!G.done&&(Y=O.return)&&Y.call(O)}finally{if(X)throw X.error}}return[2]})})};return{name:E,type:S,setup:$,execute:H,teardown:j}},Vh=3e3,Wh=["mutation","navigate"];function Hh(t){var e=t.amplitude,r=t.allObservables,n=t.getEventProperties,i=t.shouldTrackDeadClick,o=r.clickObservable,a=r.mutationObservable,s=r.navigateObservable,u=o.filter(function(v){return tr(v)&&i("click",v.closestTrackedAncestor)&&v.event.target instanceof Element&&v.event.target.closest('a[target="_blank"]')===null&&v.event.button===Ur.LEFT_OR_TOUCH_CONTACT}),l=s?lt(a,s):a,c=lt(u,l),f=null,d=Ii(c,function(v){return f&&Wh.includes(v.type)?(clearTimeout(f),f=null,Promise.resolve(null)):v.type==="click"?f?Promise.resolve(null):new Promise(function(h){f=setTimeout(function(){h(v),f=null},Vh)}):Promise.resolve(null)});return d.subscribe(function(v){if(v){var h={"[Amplitude] X":v.event.clientX,"[Amplitude] Y":v.event.clientY};e.track(qf,C(C({},n("click",v.closestTrackedAncestor)),h),{time:v.timestamp})}})}var ou=td,au=ed,Go=rd;function jo(t,e){var r,n,i,o,a=e.event,s=a.pageX,u=a.pageY;t.yMin=Math.min((r=t.yMin)!==null&&r!==void 0?r:u,u),t.yMax=Math.max((n=t.yMax)!==null&&n!==void 0?n:u,u),t.xMin=Math.min((i=t.xMin)!==null&&i!==void 0?i:s,s),t.xMax=Math.max((o=t.xMax)!==null&&o!==void 0?o:s,s),t.isOutOfBounds=t.yMax-t.yMin>Go||t.xMax-t.xMin>Go}function zo(t){if(t.length===0)return null;var e=t[0],r=t[t.length-1],n=C({"[Amplitude] Begin Time":new Date(e.timestamp).toISOString(),"[Amplitude] End Time":new Date(r.timestamp).toISOString(),"[Amplitude] Duration":r.timestamp-e.timestamp,"[Amplitude] Clicks":t.map(function(i){return{X:i.event.pageX,Y:i.event.pageY,Time:i.timestamp}}),"[Amplitude] Click Count":t.length},e.targetElementProperties);return{rageClickEvent:n,time:e.timestamp}}function Gh(t,e){var r=Math.max(0,t.length-ou+1),n=t[r];return e.timestamp-n.timestamp>=au}function jh(t,e){return t.length>0&&t[t.length-1].closestTrackedAncestor!==e.closestTrackedAncestor}function zh(t){var e=this,r=t.amplitude,n=t.allObservables,i=t.shouldTrackRageClick,o=n.pointerDownObservable,a=n.selectionObservable,s=[],u={},l=null;function c(h){s=[],u={},h&&(jo(u,h),s.push(h))}var f=Ii(o.filter(function(h){return i("click",h.closestTrackedAncestor)}),function(h){return I(e,void 0,void 0,function(){var g;return _(this,function(m){return jo(u,h),g=null,s.length===0||jh(s,h)||Gh(s,h)||u.isOutOfBounds?(l&&(g=zo(s)),c(h)):s.push(h),l&&(clearTimeout(l.timerId),l.resolve(g),l=null),s.length>=ou?[2,new Promise(function(p){l={resolve:p,timerId:setTimeout(function(){p(zo(s))},au)}})]:[2,null]})})}),d=a?.subscribe(function(){c()}),v=f.subscribe(function(h){h!==null&&r.track(Vf,h.rageClickEvent,{time:h.time})});return{unsubscribe:function(){v.unsubscribe(),d?.unsubscribe()}}}var $h=2e3;function Kh(t){var e=t.amplitude,r=t.allObservables,n=t.shouldTrackErrorClick,i=r.pointerDownObservable,o=r.browserErrorObservable,a=i.filter(function(c){return tr(c)&&n("click",c.closestTrackedAncestor)&&c.event.target instanceof Element&&c.event.target.closest('a[target="_blank"]')===null&&c.event.button===Ur.LEFT_OR_TOUCH_CONTACT}),s=null,u=null,l=function(){s!==null&&(clearTimeout(s),s=null),u=null};return lt(a,o).subscribe(function(c){var f;if(c.type==="click"){l(),u=c,s=setTimeout(l,$h);return}c.type==="error"&&u&&(e.track(Wf,C((f={},f["[Amplitude] Kind"]=c.event.kind,f["[Amplitude] Message"]=c.event.message,f["[Amplitude] Stack"]=c.event.stack,f["[Amplitude] Filename"]=c.event.filename,f["[Amplitude] Line Number"]=c.event.lineNumber,f["[Amplitude] Column Number"]=c.event.columnNumber,f),u.targetElementProperties)),l())})}var Me;(function(t){t.INCREASING="increasing",t.DECREASING="decreasing"})(Me||(Me={}));var ot;(function(t){t.X="x",t.Y="y"})(ot||(ot={}));var Xh=function(t){var e=t.allWindowObservables,r=e.mouseMoveObservable;return new he(function(n){var i=null,o=null,a=null;return r.subscribe(function(s){var u={x:s.clientX,y:s.clientY};if(i===null){i=u;return}u.x>i.x?(o===Me.DECREASING&&n.next(ot.X),o=Me.INCREASING):u.x<i.x&&(o===Me.INCREASING&&n.next(ot.X),o=Me.DECREASING),u.y>i.y?(a===Me.DECREASING&&n.next(ot.Y),a=Me.INCREASING):u.y<i.y&&(a===Me.INCREASING&&n.next(ot.Y),a=Me.DECREASING),i=u})})};function Yh(t){var e=+Date.now();t.startTime=t.startTime||e;var r=t.changes,n=t.changesThreshold;r.push(e),r.length>n&&r.shift()}function $o(t){var e=t.changes,r=t.changesThreshold,n=t.thresholdMs;if(e.length<r)return!1;var i=e[e.length-1]-e[0];return i<n}function Ko(t){t.changes=[],t.startTime=void 0}function Xo(t){for(var e=t.changes,r=t.thresholdMs,n=0,i=e[e.length-1];n<e.length;n++){var o=i-e[n];if(o<r)break}n!==0&&(t.startTime=e[n],t.changes.splice(0,n))}function Qh(t,e){var r=void 0;if($o(t)&&(r=t.startTime),$o(e)){var n=e.startTime;n&&(!r||n<r)&&(r=n)}return r}var su=20,uu=2e3,Jh=function(t){var e=t.mouseDirectionChangeObservable,r=t.directionChanges,n=r===void 0?su:r,i=t.thresholdMs,o=i===void 0?uu:i;return new he(function(a){var s={changes:[],changesThreshold:n,thresholdMs:o},u={changes:[],changesThreshold:n,thresholdMs:o},l=void 0,c=null;function f(){l!==void 0&&(a.next(l),l=void 0,c!==null&&clearTimeout(c),Ko(s),Ko(u))}return e.subscribe(function(d){c!==null&&clearTimeout(c),Yh(d===ot.X?s:u);var v=Qh(s,u);return v?(l=l||v,c=setTimeout(function(){f(),c=null},o)):f(),Xo(s),Xo(u),function(){c!==null&&(clearTimeout(c),c=null)}})})},Zh=function(t){var e=t.amplitude,r=t.options,n=t.allObservables,i=t.directionChanges,o=i===void 0?su:i,a=t.thresholdMs,s=a===void 0?uu:a,u=Xh({allWindowObservables:n}),l=Jh({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:s});return l.subscribe(function(c){Ci(r)&&e.track(Gf,void 0,{time:c})})};function yn(t,e,r,n){if(!n)return[];var i=t[e];return typeof i=="object"&&i!==null&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:r}var cr=5,dr=4e3,eg=function(t){var e;t===void 0&&(t={});var r=Ff,n="enrichment",i=[],o=t.errorClicks!==!1;t.errorClicks||(o=!1);var a=t.deadClicks!==!1&&t.deadClicks!==null,s=t.rageClicks!==!1&&t.rageClicks!==null,u=t.thrashedCursor!==!1&&t.thrashedCursor!==null;t.thrashedCursor||(u=!1);var l=yn(t,"rageClicks",Zc,s),c=yn(t,"deadClicks",Qc,a),f=yn(t,"errorClicks",Jc,o),d=(e=t.dataAttributePrefix)!==null&&e!==void 0?e:ls,v=new nu(t),h=W([],D(new Set(W(W(W([],D(l),!1),D(c),!1),D(f),!1))),!1),g=function(){var b,E=function(R){return Ne(tu(R).map(function(M){return v.addAdditionalEventProperties(M,"click",h,d,!0)}))},S=E("click"),T=E("pointerdown"),w=Ne(vh().map(function(R){return v.addTypeAndTimestamp(R,"error")})),P=Ne(eu(v.shadowGate).map(function(R){return v.addAdditionalEventProperties(R,"mutation",h,d)})),A;if(window.navigation){var F=new he(function(R){var M=function(U){R.next(C(C({},U),{type:"navigate"}))};return window.navigation.addEventListener("navigate",M),function(){window.navigation.removeEventListener("navigate",M)}});A=Ne(F.map(function(R){return v.addAdditionalEventProperties(R,"navigate",h,d)}))}var k=Ne(new he(function(R){var M=function(){var U=document.activeElement;if(U&&(U.tagName==="TEXTAREA"||U.tagName==="INPUT")){var N=void 0,q=void 0;try{if(N=U.selectionStart,q=U.selectionEnd,N===q)return}catch{return}return R.next()}var $=window.getSelection();if(!(!$||$.isCollapsed))return R.next()};return window.document.addEventListener("selectionchange",M),function(){window.document.removeEventListener("selectionchange",M)}})),x=Ne(hh());return b={},b[pe.ClickObservable]=S,b[pe.PointerDownObservable]=T,b[pe.MutationObservable]=P,b[pe.NavigateObservable]=A,b[pe.BrowserErrorObservable]=w,b[pe.SelectionObservable]=k,b[pe.MouseMoveObservable]=x,b},m=function(b,E){return I(void 0,void 0,void 0,function(){var S,T,w,P,A,F,k,x,R,M,U,N;return _(this,function(q){return typeof document>"u"?[2]:(S=g(),T=iu(b,v),T&&i.push({unsubscribe:T}),s&&(w=_t(t,l),P=zh({allObservables:S,amplitude:E,shouldTrackRageClick:w}),i.push(P)),a&&(A=_t(t,c),F=Hh({amplitude:E,allObservables:S,getEventProperties:function($,H){return v.getEventProperties($,H,d)},shouldTrackDeadClick:A}),i.push(F)),o&&(k=_t(t,f),x=Kh({amplitude:E,allObservables:S,shouldTrackErrorClick:k}),i.push(x)),u&&(R=void 0,M=void 0,typeof t.thrashedCursor=="object"&&(R=t.thrashedCursor.directionChanges,M=t.thrashedCursor.threshold,R&&R<cr&&(b.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(R," is below the minimum of ").concat(cr,", setting to ").concat(cr)),R=cr),M&&M>dr&&(b.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(M," is above the maximum of ").concat(dr,", setting to ").concat(dr)),M=dr)),U=Zh({amplitude:E,options:t,allObservables:S,directionChanges:R,thresholdMs:M}),i.push(U)),(N=b?.loggerProvider)===null||N===void 0||N.log("".concat(r," has been successfully added.")),[2])})})},p=function(b){return I(void 0,void 0,void 0,function(){return _(this,function(E){return[2,b]})})},y=function(){return I(void 0,void 0,void 0,function(){var b,E,S,T,w;return _(this,function(P){try{for(b=L(i),E=b.next();!E.done;E=b.next())S=E.value,S.unsubscribe()}catch(A){T={error:A}}finally{try{E&&!E.done&&(w=b.return)&&w.call(b)}finally{if(T)throw T.error}}return[2]})})};return{name:r,type:n,setup:m,execute:p,teardown:y}},tg=100,rg=1e4;function lu(t,e){var r=t.startTime+t.duration;return e.filter(function(n){return n.startTime<r&&n.startTime+n.duration>t.startTime}).map(function(n){return n.name})}function ng(t,e){var r,n=lu(t,e),i=(r=t.scripts)!==null&&r!==void 0?r:[],o=i.map(function(c){return c.sourceURL}
12).filter(Boolean),a=i.map(function(c){return c.sourceFunctionName}).filter(Boolean),s=i.map(function(c){return c.sourceCharPosition}).filter(function(c){return typeof c=="number"&&c>=0}),u=i.map(function(c){return c.invokerType}).filter(Boolean),l=i.map(function(c){return c.invoker}).filter(Boolean);return C(C(C(C(C(C(C({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":t.duration,"[Amplitude] Main Thread Block Blocking Duration":t.blockingDuration,"[Amplitude] Main Thread Block Start Time":t.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),{"[Amplitude] Main Thread Block Render Start":t.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":t.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),o.length>0&&{"[Amplitude] Main Thread Block Script URLs":o}),a.length>0&&{"[Amplitude] Main Thread Block Script Functions":a}),s.length>0&&{"[Amplitude] Main Thread Block Script Positions":s}),u.length>0&&{"[Amplitude] Main Thread Block Invoker Types":u}),l.length>0&&{"[Amplitude] Main Thread Block Invokers":l})}function ig(t,e){var r,n=lu(t,e),i=(r=t.attribution)!==null&&r!==void 0?r:[];return C(C({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":t.duration,"[Amplitude] Main Thread Block Blocking Duration":t.duration,"[Amplitude] Main Thread Block Start Time":t.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(o){return o.name})})}function og(){if(typeof PerformanceObserver>"u")return null;try{var t=PerformanceObserver.supportedEntryTypes;if(t.includes("long-animation-frame"))return"long-animation-frame";if(t.includes("longtask"))return"longtask"}catch{}return null}function ag(t){var e=t.amplitude,r=t.options,n=t.durationThreshold,i=n===void 0?tg:n,o=og();if(!o)return{unsubscribe:function(){}};var a=[],s=new PerformanceObserver(function(l){var c,f,d=performance.now();try{for(var v=L(l.getEntries()),h=v.next();!h.done;h=v.next()){var g=h.value;a.push(g)}}catch(p){c={error:p}}finally{try{h&&!h.done&&(f=v.return)&&f.call(v)}finally{if(c)throw c.error}}for(var m=d-rg;a.length>0&&a[0].startTime<m;)a.shift()});try{s.observe({entryTypes:["measure"]})}catch{}var u=new PerformanceObserver(function(l){var c,f;try{for(var d=L(l.getEntries()),v=d.next();!v.done;v=d.next()){var h=v.value;if(!Ci(r))return;if(!(h.duration<i)){var g=o==="long-animation-frame"?ng(h,a):ig(h,a);e.track(jf,g)}}}catch(m){c={error:m}}finally{try{v&&!v.done&&(f=d.return)&&f.call(d)}finally{if(c)throw c.error}}});try{u.observe({entryTypes:[o]})}catch{return s.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){u.disconnect(),s.disconnect()}}}var sg=100,ug=function(t){t===void 0&&(t={});var e=Bf,r="enrichment",n=[],i=t.mainThreadBlock===!0||typeof t.mainThreadBlock=="object"&&t.mainThreadBlock!==null,o=function(u,l){return I(void 0,void 0,void 0,function(){var c,f,d;return _(this,function(v){return typeof document>"u"?[2]:(i&&(c=sg,typeof t.mainThreadBlock=="object"&&t.mainThreadBlock.durationThreshold!==void 0&&(c=t.mainThreadBlock.durationThreshold),f=ag({amplitude:l,options:t,durationThreshold:c}),n.push(f)),(d=u?.loggerProvider)===null||d===void 0||d.log("".concat(e," performance tracking has been successfully added.")),[2])})})},a=function(u){return I(void 0,void 0,void 0,function(){return _(this,function(l){return[2,u]})})},s=function(){return I(void 0,void 0,void 0,function(){var u,l,c,f,d;return _(this,function(v){try{for(u=L(n),l=u.next();!l.done;l=u.next())c=l.value,c.unsubscribe()}catch(h){f={error:h}}finally{try{l&&!l.done&&(d=u.return)&&d.call(u)}finally{if(f)throw f.error}}return[2]})})};return{name:e,type:r,setup:o,execute:a,teardown:s}},lg="@amplitude/plugin-network-capture-browser",cu="[Amplitude] Network Request",du="500-599";function Ir(t,e){var r=e.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&"),n="^"+r.replace(/\*/g,".*")+"$",i=new RegExp(n);return i.test(t)}function fu(t,e){var r,n,i=e.split(",");try{for(var o=L(i),a=o.next();!a.done;
12a=o.next()){var s=a.value,u=D(s.split("-").map(Number),2),l=u[0],c=u[1];if(t===l&&c===void 0||t>=l&&t<=c)return!0}}catch(f){r={error:f}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function cg(t,e,r,n,i){if(!(t.hosts&&!t.hosts.find(function(a){return Ir(e,a)}))&&!(n&&t.urls&&!Vn(n,t.urls))&&!(i&&t.methods&&!t.methods.find(function(a){return i.toLowerCase()===a.toLowerCase()||a==="*"}))){if(r||r===0){var o=t.statusCodeRange||du;if(!fu(r,o))return!1}return!0}}function dg(t){var e,r=t.indexOf("#"),n=r>=0?t.slice(r+1):"",i=r>=0?t.slice(0,r):t,o=i.indexOf("?"),a=o>=0?i.slice(o+1):"",s=o>=0?i.slice(0,o):i,u=s.match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i),l=(e=u?.[1])!==null&&e!==void 0?e:"";return{query:a,fragment:n,href:t,hrefWithoutQueryOrHash:s,host:l}}function vu(t){var e;if(t)try{var r=(e=z())===null||e===void 0?void 0:e.location.href,n=new URL(t,r),i=n.searchParams.toString(),o=n.hash.replace("#",""),a=n.href,s=n.host;n.hash="",n.search="";var u=n.href;return{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:u,host:s}}catch{try{return dg(t)}catch{return}}}function fg(t,e){if(t.includes("amplitude.com"))try{var r=e.body;if(typeof r!="string")return!1;var n=JSON.parse(r),i=n.events;if(i.find(function(o){return o.event_type===cu}))return!0}catch{}return!1}function Yo(t){if(typeof t!="object"||t===null){if(t)return W([],D(Or),!1);if(t===void 0){var e=void 0;return e}return}if(t.length!==0)return t}function Qo(t){var e,r,n;return!(!((e=t?.allowlist)===null||e===void 0)&&e.length)&&!(!((r=t?.blocklist)===null||r===void 0)&&r.length)&&!(!((n=t?.excludelist)===null||n===void 0)&&n.length)}function vg(t,e){var r;e===void 0&&(e={});var n=vu(t.url);if(!n)return!1;var i=n.host;if(e.ignoreAmplitudeRequests!==!1&&(Ir(i,"*.amplitude.com")||Ir(i,"amplitude.com"))||!((r=e.ignoreHosts)===null||r===void 0)&&r.find(function(a){return Ir(i,a)})||!e.captureRules&&t.status!==void 0&&!fu(t.status,du))return!1;if(e.captureRules){var o;if(W([],D(e.captureRules),!1).reverse().find(function(a){if(o=cg(a,i,t.status,t.url,t.method),o){var s=Yo(a.responseHeaders);if(t.responseWrapper&&s){var u=t.responseWrapper.headers(s);u&&(t.responseHeaders=u)}var l=Yo(a.requestHeaders);if(t.requestWrapper&&l){var c=t.requestWrapper.headers(l);c&&(t.requestHeaders=c)}if(t.responseWrapper&&a.responseBody&&!Qo(a.responseBody)){var f=a.responseBody.excludelist||a.responseBody.blocklist;t.responseBodyJson=t.responseWrapper.json(a.responseBody.allowlist,f)}if(t.requestWrapper&&a.requestBody&&!Qo(a.requestBody)){var f=a.requestBody.excludelist||a.requestBody.blocklist;t.requestBodyJson=t.requestWrapper.json(a.requestBody.allowlist,f)}}return o!==void 0}),!o)return!1}return!(t.requestWrapper&&fg(i,t.requestWrapper))}function hg(t,e,r,n){return I(this,void 0,void 0,function(){var i,o,a;return _(this,function(s){switch(s.label){case 0:return e.requestBodyJson||e.responseBodyJson?[4,Promise.all([e.requestBodyJson,e.responseBodyJson])]:[3,2];case 1:if(i=D.apply(void 0,[s.sent(),2]),o=i[0],a=i[1],o)try{t["[Amplitude] Request Body"]=JSON.stringify(o)}catch(u){n?.debug("Failed to stringify request body",u)}if(a)try{t["[Amplitude] Response Body"]=JSON.stringify(a)}catch{n?.debug("Failed to stringify response body")}s.label=2;case 2:return r?.track(cu,t),[2]}})})}function gg(t){var e=t.allObservables,r=t.networkTrackingOptions,n=t.amplitude,i=t.loggerProvider,o=e.networkObservable,a=o.filter(function(s){return vg(s.event,r)});return a.subscribe(function(s){var u,l,c,f=s.event,d=vu(f.url);if(d){var v=(l=f.responseWrapper)===null||l===void 0?void 0:l.bodySize,h=(c=f.requestWrapper)===null||c===void 0?void 0:c.bodySize,g=(u={},u["[Amplitude] URL"]=d.hrefWithoutQueryOrHash,u["[Amplitude] URL Query"]=d.query,u["[Amplitude] URL Fragment"]=d.fragment,u["[Amplitude] Request Method"]=f.method,u["[Amplitude] Status Code"]=f.status,u["[Amplitude] Start Time"]=f.startTime,u["[Amplitude] Completion Time"]=f.endTime,u["[Amplitude] Duration"]=f.duration,u["[Amplitude] Request Body Size"]=h,u["[Amplitude] Response Body Size"]=v,u["[Amplitude] Request Type"]=f.type,u["[Amplitude] Request Headers"]=f.requestHeaders,u["[Amplitude] Response Headers"]=f.responseHeaders,u);hg(g,f,n,i)}})}var Kn;(function(t){t.NetworkObservable="networkObservable"})(Kn||(Kn={}));var Jo,pg=function(t){t===void 0&&(t={});var e=lg,r="enrichment",n,i=function(l,c){var f={event:l,timestamp:Date.now(),type:c};return f},o=function(){var l,c=new he(function(f){var d=new dd(function(v){var h=i(v,"network");f.next(h)});return po.subscribe(d,n),function(){po.unsubscribe(d)}});return l={},l[Kn.NetworkObservable]=c,l},a=function(l,c){return I(void 0,void 0,void 0,function(){var f;return _(this,function(d){return typeof document>"u"&&!Od()?[2]:(f=o(),n=l?.loggerProvider,Jo=gg({allObservables:f,networkTrackingOptions:t,amplitude:c,loggerProvider:n}),n?.log("".concat(e," has been successfully added.")),[2])})})},s=function(l){return I(void 0,void 0,void 0,function(){return _(this,function(c){return[2,l]})})},u=function(){return I(void 0,void 0,void 0,function(){return _(this,function(l){return Jo.unsubscribe(),[2]})})};return{name:e,type:r,setup:a,execute:s,teardown:u}},hu="web-vitals-browser",gu="[Amplitude] Web Vitals",mg=1e3,Et={LCP:"[Amplitude] LCP",FCP:"[Amplitude] FCP",INP:"[Amplitude] INP",CLS:"[Amplitude] CLS",TTFB:"[Amplitude] TTFB"};let pu=-1;const kt=()=>pu,Rt=t=>{addEventListener("pageshow",e=>{e.persisted&&(pu=e.timeStamp,t(e))},!0)},_e=(t,e,r,n)=>{let i,o;return a=>{e.value>=0&&(a||n)&&(o=e.value-(i??0),(o||i===void 0)&&(i=e.value,e.delta=o,e.rating=((s,u)=>s>u[1]?"poor":s>u[0]?"needs-improvement":"good")(e.value,r),t(e)))}},Ai=t=>{requestAnimationFrame(()=>requestAnimationFrame(()=>t()))},ki=()=>{const t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},rr=()=>ki()?.activationStart??0;let nt=-1;const mu=new Set,Zo=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,Xn=t=>{if(document.visibilityState==="hidden"){if(t.type==="visibilitychange")for(const e of mu)e();isFinite(nt)||(nt=t.type==="visibilitychange"?t.timeStamp:0,removeEventListener("prerenderingchange",Xn,!0))}},Zt=(t=!1)=>
12{if(t&&(nt=1/0),nt<0){const e=rr();nt=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find(n=>n.name==="hidden"&&n.startTime>=e)?.startTime)??Zo(),addEventListener("visibilitychange",Xn,!0),addEventListener("prerenderingchange",Xn,!0),Rt(()=>{setTimeout(()=>{nt=Zo()})})}return{get firstHiddenTime(){return nt},onHidden(e){mu.add(e)}}},ke=(t,e=-1,r,n=0,i,o,a)=>{const s=ki(),u=s?.navigationId||0;let l="navigate";return r?l=r:kt()>=0?l="back-forward-cache":s&&(document.prerendering||rr()>0?l="prerender":document.wasDiscarded?l="restore":s.type&&(l=s.type.replace(/_/g,"-"))),{name:t,value:e,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:l,navigationId:n||u,navigationInteractionId:i,navigationURL:o||s?.name,navigationStartTime:a||0}},ea=new WeakMap;function jr(t,e){let r=ea.get(e);return r||(r=new WeakMap,ea.set(e,r)),r.get(t)||r.set(t,new e),r.get(t)}class yg{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const r=this.o[0],n=this.o.at(-1);this.i&&r&&n&&e.startTime-n.startTime<1e3&&e.startTime-r.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}const ct=(t,e,r={})=>{try{const n=t.filter(i=>PerformanceObserver.supportedEntryTypes.includes(i));if(n.length>0){const i=new PerformanceObserver(o=>{queueMicrotask(()=>{const a=o.getEntries();n.length>1&&a.sort((s,u)=>s.startTime+s.duration-(u.startTime+u.duration)),e(a)})});for(const o of n)i.observe({type:o,buffered:!0,...r});return i}}catch{}},nr=t=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation")&&typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint=="function"&&t&&t.reportSoftNavs,yu=(t,e)=>{if(t.set(e.navigationId,e),t.size>2){const r=t.keys().next().value;r!==void 0&&t.delete(r)}},bu=t=>{let e=!1;return()=>{e||(t(),e=!0)}};class bg{l}const zr=t=>{document.prerendering?addEventListener("prerenderingchange",t,!0):t()},bn=[1800,3e3],Ri=(t,e={})=>{const r=nr(e);zr(()=>{const n=jr(e,bg),i=Zt();let o,a=ke("FCP");const s=ct(["paint"],u=>{for(const l of u)l.name==="first-contentful-paint"&&(s.disconnect(),l.startTime<i.firstHiddenTime&&(a.value=Math.max(l.startTime-rr(),0),a.entries.push(l),a.navigationId=l.navigationId||a.navigationId,o(!0)))});s&&(o=_e(t,a,bn,e.reportAllChanges),Rt(u=>{a=ke("FCP",-1,"back-forward-cache",a.navigationId,a.navigationInteractionId,a.navigationURL,kt()),o=_e(t,a,bn,e.reportAllChanges),Ai(()=>{a.value=performance.now()-u.timeStamp,o(!0)})})),r&&ct(["soft-navigation"],u=>{u.forEach(l=>{n.l&&l.navigationId&&yu(n.l,l);const c=Math.max((l.presentationTime||l.paintTime||0)-l.startTime,0);a=ke("FCP",c,"soft-navigation",l.navigationId,l.interactionId,l.name,l.startTime),o=_e(t,a,bn,e.reportAllChanges),o(!0)})},e)})},ta=[.1,.25],Eu=(t,e={})=>{const r=Zt();Ri(bu(()=>{let n,i=ke("CLS",0);const o=jr(e,yg),a=(d,v,h,g,m)=>{i=ke("CLS",0,d,v,h,g,m),o.i=0,n=_e(t,i,ta,e.reportAllChanges)},s=(d=!1)=>{o.i>i.value&&(i.value=o.i,i.entries=o.o),n(d)},u=d=>{s(!0),a("soft-navigation",d.navigationId,d.interactionId,d.name,d.startTime)},l=d=>{for(const v of d)v.entryType!=="soft-navigation"?o.h(v):u(v);s()},c=["layout-shift"];nr(e)&&c.push("soft-navigation");const f=ct(c,l);f&&(n=_e(t,i,ta,e.reportAllChanges),r.onHidden(()=>{l(f.takeRecords()),n(!0)}),Rt(()=>{a("back-forward-cache",i.navigationId,i.navigationInteractionId,i.navigationURL,kt()),Ai(n)}),setTimeout(n))}))};let Su=0,En=1/0,fr=0;const Eg=t=>{for(const e of t)e.interactionId&&(En=Math.min(En,e.interactionId),fr=Math.max(fr,e.interactionId),Su=fr?(fr-En)/7+1:0)};let Yn;const ra=()=>Yn?Su:performance.interactionCount??0,Sg=()=>{"interactionCount"in performance||Yn||(Yn=ct(["event"],Eg,{durationThreshold:0}))};class Tg{u=0;v=[];m=new Map;p;T;_(){return ra()-this.u}M(){this.u=ra(),this.v.length=0,this.m.clear()}L(e){const r=this._(),n=Math.min(this.v.length-1,Math.floor(r/50));return!r||n!==-1||e!=="soft-navigation"&&e!=="back-forward-cache"?this.v[n]:{P:8,id:-1,entries:[]}}h(e){if(this.p?.(e),!e.interactionId)return;const r=this.v.at(-1);let n=this.m.get(e.interactionId);if(n||this.v.length<10||e.duration>r.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.m.set(n.id,n),this.v.push(n)),this.v.sort((i,o)=>o.P-i.P),this.v.length>10){const i=this.v.splice(10);for(const o of i)this.m.delete(o.id)}this.T?.(n)}}}const Tu=t=>{const e="requestIdleCallback"in globalThis?1e3:0,r=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState==="hidden")t();else{const i=bu(t);let o=-1;const a=()=>{n(o),i()};addEventListener("visibilitychange",a,{once:!0,capture:!0}),o=r(()=>{removeEventListener("visibilitychange",a,{capture:!0}),i()},{timeout:e})}},na=[200,500],_u=(t,e={})=>
12{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const r=Zt();zr(()=>{Sg();let n,i=ke("INP");const o=jr(e,Tg),a=(d,v,h,g,m)=>{o.M(),i=ke("INP",-1,d,v,h,g,m),n=_e(t,i,na,e.reportAllChanges)},s=()=>{const d=o.L(i.navigationType);d&&d.P!==i.value&&(i.value=d.P,i.entries=d.entries,n())},u=d=>{s(),n(!0),a("soft-navigation",d.navigationId,d.interactionId,d.name,d.startTime)},l=(d,v=!1)=>{Tu(()=>{for(const h of d)h.entryType!=="soft-navigation"?o.h(h):u(h);s(),v&&n(!0)})},c=["event","first-input"];nr(e)&&c.push("soft-navigation");const f=ct(c,l,{...e,durationThreshold:e.durationThreshold??40});n=_e(t,i,na,e.reportAllChanges),f&&(r.onHidden(()=>{l(f.takeRecords(),!0)}),Rt(()=>{a("back-forward-cache",i.navigationId,i.navigationInteractionId,i.navigationURL,kt())}))})};class _g{p;l;h(e){this.p?.(e)}}const Sn=[2500,4e3],Iu=(t,e={})=>{let r=!1;const n=nr(e);zr(()=>{let i,o=Zt(),a=ke("LCP");const s=jr(e,_g),u=(v,h,g,m,p)=>{a=ke("LCP",-1,v,h,g,m,p),i=_e(t,a,Sn,e.reportAllChanges),r=!1,v==="soft-navigation"&&(o=Zt(!0))},l=v=>{s.l&&v.navigationId&&yu(s.l,v),r||i(!0),u("soft-navigation",v.navigationId,v.interactionId,v.name,v.startTime);const h=v.getLargestInteractionContentfulPaint?.();h&&c([h])},c=v=>{e.reportAllChanges||n||(v=v.slice(-1));for(const h of v){if(!h)continue;if(h.entryType==="soft-navigation"){l(h);continue}let g=0,m=[],p=h.startTime;if(h.entryType==="largest-contentful-paint")g=Math.max(h.startTime-rr(),0),s.h(h),m=[h];else if(h.entryType==="interaction-contentful-paint"){const y=h;if(!a.navigationId||"interactionId"in y&&y.interactionId!=a.navigationInteractionId)continue;p=y.largestContentfulPaint?.renderTime||0,g=Math.max(p-h.startTime,0),y.largestContentfulPaint&&(s.h(y.largestContentfulPaint),m=[y.largestContentfulPaint])}p<o.firstHiddenTime&&(a.value=g,a.entries=m,i())}},f=["largest-contentful-paint"];n&&f.push("interaction-contentful-paint","soft-navigation");const d=ct(f,c);if(d){i=_e(t,a,Sn,e.reportAllChanges);const v=["keydown","click","visibilitychange"],h=g=>{if(g.isTrusted&&!r){const m=a.id;Tu(()=>{if(!r){if(!n){d.disconnect();for(const p of v)removeEventListener(p,h,{capture:!0})}m===a.id&&(r=!0,i(!0))}})}};for(const g of v)addEventListener(g,h,{capture:!0});Rt(g=>{u("back-forward-cache",a.navigationId,a.navigationInteractionId,a.navigationURL,kt()),i=_e(t,a,Sn,e.reportAllChanges),Ai(()=>{a.value=performance.now()-g.timeStamp,r=!0,i(!0)})})}})},Tn=[800,1800],Qn=t=>{document.prerendering?zr(()=>Qn(t)):document.readyState!=="complete"?addEventListener("load",()=>Qn(t),!0):setTimeout(t)},wu=(t,e={})=>{const r=nr(e);let n=ke("TTFB"),i=_e(t,n,Tn,e.reportAllChanges);Qn(()=>{const o=ki();if(o){const a=o.responseStart;n.value=Math.max(a-rr(),0),n.entries=[o],i(!0),Rt(()=>{n=ke("TTFB",0,"back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,kt()),i=_e(t,n,Tn,e.reportAllChanges),i(!0)}),r&&ct(["soft-navigation"],s=>{s.forEach(u=>{u.navigationId&&(n=ke("TTFB",0,"soft-navigation",u.navigationId,u.interactionId,u.name,u.startTime),n.entries=[u],i=_e(t,n,Tn,e.reportAllChanges),i(!0))})},e)}})};function Ig(t){var e,r=((e=t.entries[0])===null||e===void 0?void 0:e.startTime)||0;return performance.timeOrigin+r}function St(t,e){e===void 0&&(e=!1);var r={value:t.value,rating:t.rating,delta:t.delta,navigationType:t.navigationType,id:t.id,timestamp:Math.floor(Ig(t)),navigationStart:Math.floor(e?performance.timeOrigin+(t.navigationStartTime||0):performance.timeOrigin)};return e&&(r.navigationId=t.navigationId),r}var wg=function(){var t=null,e=z(),r=e?.document,n=e?.location,i=function(s,u){return I(void 0,void 0,void 0,function(){var l,c;return _(this,function(f){return r===void 0?[2]:(l=Se(n?.href||"",s.loggerProvider),c={"[Amplitude] Page Domain":n?.hostname||"","[Amplitude] Page Location":l,"[Amplitude] Page Path":Se(n?.pathname||"",s.loggerProvider),"[Amplitude] Page Title":typeof document<"u"&&document.title||"","[Amplitude] Page URL":Se(l.split("?")[0],s.loggerProvider)},Iu(function(d){c["[Amplitude] LCP"]=St(d)}),Ri(function(d){c["[Amplitude] FCP"]=St(d)}),_u(function(d){c["[Amplitude] INP"]=St(d)}),Eu(function(d){c["[Amplitude] CLS"]=St(d)}),wu(function(d){c["[Amplitude] TTFB"]=St(d)}),t=function(){r.visibilityState==="hidden"&&t&&(u.track(gu,c),r.removeEventListener("visibilitychange",t),t=null)},r.addEventListener("visibilitychange",t),[2])})})},o=function(s){return I(void 0,void 0,void 0,function(){return _(this,function(u){return[2,s]})})},a=function(){return I(void 0,void 0,void 0,function(){return _(this,function(s){return t&&r?.removeEventListener("visibilitychange",t),[2]})})};return{name:hu,type:"enrichment",setup:i,execute:o,teardown:a}},Cg=Object.values(Et);function Pg(t,e,r){var n="",i="";try{var o=new URL(t);n=o.hostname,i=o.pathname}catch(s){r.debug("Web vitals plugin is unable to parse page URL: ",s)}var a=Se(t,r);return{"[Amplitude] Page Domain":n,"[Amplitude] Page Location":a,"[Amplitude] Page Path":Se(i,r),"[Amplitude] Page Title":e,"[Amplitude] Page URL":Se(a.split("?")[0],r)}}function Ag(t){return Cg.some(function(e){return e in t})}var kg=function(){var t=null,e,r=z(),n=r?.document,i=r?.location,o=!1,a=new Set,s=function(c,f){return I(void 0,void 0,void 0,function(){var d,v,h,g,m,p,y,b;return _(this,function(E){return n===void 0?[2]:(o=!0,d=new Map,v=-1,h=function(S){var T=S.navigationId,w=d.get(T);return w||(w=Pg(S.navigationURL||i?.href||"",n.title||"",c.loggerProvider),d.set(T,w)),w},g=function(S){a.add(S);var T=d.get(S);T&&(d.delete(S),Ag(T)&&f.track(gu,T))},m=function(){var S,T;try{for(var w=L(Array.from(d.keys())),P=w.next();!P.done;P=w.next()){var A=P.value;g(A)}}catch(F){S={error:F}}finally{try{P&&!P.done&&(T=w.return)&&T.call(w)}finally{if(S)throw S.error}}},p=function(S){e!==void 0&&clearTimeout(e),e=setTimeout(function(){var T,w;e=void 0;try{for(var P=L(Array.from(d.keys())),A=P.next();!A.done;A=P.next()){var F=A.value;F<S&&g(F)}}catch(k){T={error:k}}finally{try{A&&!A.done&&(w=P.return)&&w.call(P)}finally{if(T)throw T.error}}},mg)},y=function(S){return function(T){!o||a.has(T.navigationId)||(h(T)[S]=St(T,!0),T.navigationId>v&&(v!==-1&&p(T.navigationId),v=T.navigationId))}},b={reportSoftNavs:!0},Iu(y(Et.LCP),b),Ri(y(Et.FCP),b),_u(y(Et.INP),b),Eu(y(Et.CLS),b),wu(y(Et.TTFB),b),t=function(){n.visibilityState==="hidden"&&t&&m(
12)},n.addEventListener("visibilitychange",t),[2])})})},u=function(c){return I(void 0,void 0,void 0,function(){return _(this,function(f){return[2,c]})})},l=function(){return I(void 0,void 0,void 0,function(){return _(this,function(c){return o=!1,e!==void 0&&(clearTimeout(e),e=void 0),t&&(n?.removeEventListener("visibilitychange",t),t=null),[2]})})};return{name:hu,type:"enrichment",setup:s,execute:u,teardown:l}},Rg=function(){var t=z();return t&&"PerformanceSoftNavigation"in t},Og=function(t){return t===void 0&&(t={}),t.reportSoftNav===!0&&Rg()?kg():wg()},ia=(function(){function t(e,r){var n;this.shouldTrackNewCampaign=!1,this.options=C({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:Ef(((n=r.cookieOptions)===null||n===void 0?void 0:n.domain)||r.topLevelDomain),optOut:r.optOut},e),this.storage=r.cookieStorage,this.storageKey=so(r.apiKey,"MKTG"),this.webExpStorageKey=so(r.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=Wr,this.sessionTimeout=r.sessionTimeout,this.lastEventTime=r.lastEventTime,this.logger=r.loggerProvider,this.topLevelDomain=r.topLevelDomain,r.loggerProvider.log("Installing web attribution tracking.")}return t.prototype.init=function(){return I(this,void 0,void 0,function(){var e,r;return _(this,function(n){switch(n.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return r=D.apply(void 0,[n.sent(),2]),this.currentCampaign=r[0],this.previousCampaign=r[1],e=this.lastEventTime?ts(this.sessionTimeout,this.lastEventTime):!0,pf(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.fetchCampaign=function(){return I(this,void 0,void 0,function(){var e;return _(this,function(r){switch(r.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return e=r.sent(),e?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[4,Promise.all([e||new Si().parse(),this.storage.get(this.storageKey)])];case 4:return[2,r.sent()]}})})},t.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var r=bf(this.currentCampaign,this.options);return e&&(r.event_id=e),r},t.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},t})(),Lg="[Amplitude] Attribution",Dg=new Set([Ae.IDENTIFY,Ae.GROUP_IDENTIFY]),xg=function(t){return ns(t)},Mg=function(t){var e;t===void 0&&(t={});var r=(e=t.fallbackAttributionEvent)!==null&&e!==void 0?e:!1,n=z(),i,o,a={},s=!1,u=!1,l,c,f,d,v=function(){return I(void 0,void 0,void 0,function(){var m;return _(this,function(p){switch(p.label){case 0:return[4,new Si().parse()];case 1:return m=p.sent(),a=xg(m),r&&(o?.log("Tracking attribution fallback event."),i?.track(Lg,a)),[2]}})})},h=function(){v()},g=function(m){return new Proxy(m,{apply:function(p,y,b){Reflect.apply(p,y,b),s&&h()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(m,p){return I(void 0,void 0,void 0,function(){return _(this,function(y){switch(y.label){case 0:return i=p,o=m.loggerProvider,s=!0,o.log("Installing event property attribution tracking."),[4,v()];case 1:if(y.sent(),!n)return[2];if(n.addEventListener("popstate",h),!u){if(l=Reflect.get(n.history,"pushState"),c=Reflect.get(n.history,"replaceState"),!l||!c)return[2];f=g(l),n.history.pushState=f,d=g(c),n.history.replaceState=d,u=!0}return[2]}})})},execute:function(m){return I(void 0,void 0,void 0,function(){return _(this,function(p){return Dg.has(m.event_type)?[2,m]:(m.event_properties=C(C({},a),m.event_properties),[2,m])})})},teardown:function(){return I(void 0,void 0,void 0,function(){var m,p;return _(this,function(y){return n&&(n.removeEventListener("popstate",h),m=Reflect.get(n.history,"pushState"),p=Reflect.get(n.history,"replaceState"),u&&m===f&&l&&(n.history.pushState=l),u&&p===d&&c&&(n.history.replaceState=c)),s=!1,u=!1,l=void 0,c=void 0,f=void 0,d=void 0,a={},[2]})})}}},vr="AMP_CURRENT_PAGE",hr="AMP_PREVIOUS_PAGE",gt="AMP_URL_INFO",$t;(function(t){t.Direct="direct",t.Internal="internal",t.External="external"})($t||($t={}));var Ng=new Set([Ae.IDENTIFY,Ae.GROUP_IDENTIFY,Ae.REVENUE]),Ug=function(t){var e={},r=e.internalDomains,n=r===void 0?[]:r,i=z(),o=void 0,a=!1,s=void 0,u=!1,l=!1,c=function(g){var m;try{var p=Se(g,s);m=new URL(p).hostname}catch(y){s?.error("Could not parse URL: ",y)}return m},f=function(g){var m=typeof location<"u"&&location.hostname||"",p=g?c(g):void 0;if(!p)return $t.Direct;var y=n.some(function(E){return m.indexOf(E)!==-1}),b=n.some(function(E){return p.indexOf(E)!==-1});return m===p||b&&y?$t.Internal:$t.External},d=function(){return I(void 0,void 0,void 0,function(){var g,m,p,y,b;return _(this,function(E){switch(E.label){case 0:return o&&a?[4,o.get(gt)]:[3,3];case 1:return g=E.sent(),m=Se(typeof location<"u"&&location.href||""),p=g?.[vr]||"",y=void 0,m===p?y=g?.[hr]||"":p?y=p:y=document.referrer||"",[4,o.set(gt,(b={},b[vr]=m,b[hr]=y,b))];case 2:E.sent(),E.label=3;case 3:return[2]}})})},v=function(){d()},h={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(g,m){return I(void 0,void 0,void 0,function(){var p,y,b,E,S,T,w,P,A;return _(this,function(F){switch(F.label){case 0:if(s=g.loggerProvider,s.log("Installing @amplitude/plugin-page-url-enrichment-browser"),l=!0,!i)return[3,7];try{o=new Hr(i.sessionStorage)}catch{s?.debug("sessionStorage is not available in this environment.")}return[4,o?.isEnabled()];case 1:return a=(A=F.sent())!==null&&A!==void 0?A:!1,o&&a?(p=typeof document<"u"&&document.referrer||"",y=p?c(p):void 0,b=typeof location<"u"&&location.hostname||"",E=Se(typeof location<"u"&&location.href||""),[4,o.get(gt)]):[3,6];case 2:return S=F.sent(),T=S?.[vr]||"",w=!!y&&y!==b&&T!==E,w?[4,o.set(gt,(P={},P[vr]=E,P[hr]=p,P))]:[3,4];case 3:return F.sent(),[3,6];case 4:return[4,d()];case 5:F.sent(),F.label=6;case 6:i.addEventListener("popstate",v),u||(i.history.pushState=new Proxy(i.history.pushState,{apply:function(k,x,R){var M=D(R,3),U=M[0],N=M[1],q=M[2];k.apply(x,[U,N,q]),l&&v()}}),i.history.replaceState=new Proxy(i.history.replaceState,{apply:function(k,x,R){var M=D(R,3),U=M[0],N=M[1],q=M[2];k.apply(x,[U,N,q]),l&&v()}}),u=!0),F.label=7;case 7:return[2]}})})},execute:function(g){return I(void 0,void 0,void 0,function(){var m,p,y;return _(this,function(b){switch(b.label){case 0:return m=Se(typeof location<"u"&&location.href||""),o&&a?[4,o.get(gt)]:[3,2];case 1:if(p=b.sent(),y=p?.[hr]||"",Ng.has(g.event_type))return[2,g];g.event_properties=C(C({},g.event_properties||{}),{"[Amplitude] Page Domain":qt(g,"[Amplitude] Page Domain",typeof location<"u"&&location.hostname||""),"[Amplitude] Page Location":qt(g,"[Amplitude] Page Location",m),"[Amplitude] Page Path":qt(g,"[Amplitude] Page Path",typeof location<"u"&&Se(location.pathname)||""),"[Amplitude] Page Title":qt(g,"[Amplitude] Page Title",_i(T
12i)),"[Amplitude] Page URL":qt(g,"[Amplitude] Page URL",m.split("?")[0]),"[Amplitude] Previous Page Location":y,"[Amplitude] Previous Page Type":f(y)}),b.label=2;case 2:return[2,g]}})})},teardown:function(){return I(void 0,void 0,void 0,function(){return _(this,function(g){switch(g.label){case 0:return i&&(i.removeEventListener("popstate",v),l=!1),o&&a?[4,o.set(gt,{})]:[3,2];case 1:g.sent(),g.label=2;case 2:return[2]}})})}};return h};function qt(t,e,r){return t.event_properties||(t.event_properties={}),t.event_properties[e]===void 0?r:t.event_properties[e]}var Fg=function(){var t,e,r;function n(a){return typeof a!="object"||a===null?!1:"body"in a&&typeof a.body=="string"}function i(a){if(a)try{var s=new Function("return "+a)();if(typeof s=="function")return s;t?.error("Custom enrichment body did not evaluate to a function")}catch(u){t?.error("Could not create custom enrichment function",u)}return function(u){return u}}var o={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(a,s){return I(void 0,void 0,void 0,function(){var u,l;return _(this,function(c){return t=a.loggerProvider,t?.log("Installing @amplitude/plugin-custom-enrichment-browser"),!((l=a.remoteConfig)===null||l===void 0)&&l.fetchRemoteConfig&&(a.remoteConfigClient?(u=a.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(f){f&&n(f)?r=i(f.body||""):r=i("")}),e=function(){var f;return(f=a.remoteConfigClient)===null||f===void 0?void 0:f.unsubscribe(u)}):t?.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(a){return I(void 0,void 0,void 0,function(){var s;return _(this,function(u){if(r)try{return[2,(s=r(a))!==null&&s!==void 0?s:null]}catch(l){return t?.error("Could not execute custom enrichment function",l),[2,a]}return[2,a]})})},teardown:function(){return I(void 0,void 0,void 0,function(){return _(this,function(a){return e&&e(),[2]})})}};return o},Oi="userProperty",Li="eventProperty",Bg=function(t){return t===Oi||t===Li},qg=[Oi,Li],Vg=function(t){var e=W([],D(new Set((Array.isArray(t)?t:[t]).filter(Bg))),!1);return e.length>0?e:W([],D(qg),!1)},Cu=function(t,e){return Vg(t.trackingMethod).includes(e)},oa=function(t){return Cu(t,Oi)},Wg=function(t){return Cu(t,Li)},_n=-1,Hg=(function(t){Le(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r._diagnosticsSampleRate=0,r}return e.prototype.init=function(r,n,i){r===void 0&&(r="");var o,a;return arguments.length>2?(o=n,a=i):typeof n=="string"?(o=n,a=void 0):(o=n?.userId,a=n),ye(this._init(C(C({},a),{userId:o,apiKey:r})))},e.prototype._init=function(r){var n,i,o,a,s,u,l,c;return I(this,void 0,void 0,function(){var f,d,v,h,g,m,p,y,b,E,S,T,w,P,A,F=this;return _(this,function(k){switch(k.label){case 0:return this.initializing?[2]:(this.initializing=!0,f=Cf(r),d=(n=r.loggerProvider)!==null&&n!==void 0?n:new mi,r.loggerProvider||d.enable((i=r.logLevel)!==null&&i!==void 0?i:Ee.Warn),v=(o=r.serverZone)!==null&&o!==void 0?o:Ps,g=this._diagnosticsSampleRate,m=(a=r.enableDiagnostics)!==null&&a!==void 0?a:!0,f?(h=new Wc(r.apiKey,d,v,(s=r.remoteConfig)===null||s===void 0?void 0:s.serverUrl),[4,new Promise(function(x){h?.subscribe("configs.diagnostics.browserSDK","all",function(R,M,U){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:R,source:M,lastFetch:U},null,2)),R){var N=R.sampleRate;typeof N=="number"&&!isNaN(N)&&(g=N);var q=R.enabled;typeof q=="boolean"&&(m=q)}x()})})]):[3,2]);case 1:k.sent(),k.label=2;case 2:return p=new xc(r.apiKey,d,v,{enabled:m,sampleRate:g}),p.setTag("library","".concat(Is,"/").concat(wi)),p.setTag("platform",ws),p.setTag("web_environment",Yd()),typeof navigator<"u"&&p.setTag("user_agent",navigator.userAgent),[4,If(r.apiKey,r,this,p,{loggerProvider:d,serverZone:v,enableDiagnostics:m,diagnosticsSampleRate:g})];case 3:return y=k.sent(),f&&h?[4,new Promise(function(x){h?.subscribe("configs.analyticsSDK.browserSDK","all",function(R,M,U){y.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:R,source:M,lastFetch:U},null,2)),R&&Nf(R,y),x()})})]:[3,5];case 4:k.sent(),k.label=5;case 5:return[4,t.prototype._init.call(this,y)];case 6:return k.sent(),this.logBrowserOptions(y),this.config.remoteConfigClient=h,b=Hd(this.config),jn(this.config.defaultTracking)&&oa(b)?(this.config.optOut&&this.timeline.addOptOutListener(function(x){return I(F,void 0,void 0,function(){return _(this,function(R){switch(R.label){case 0:return x?[3,2]:(this.webAttribution=new ia(b,this.config),[4,this.webAttribution.init()]);case 1:R.sent(),R.label=2;case 2:return[2]}})})}),this.webAttribution=new ia(b,this.config),[4,this.webAttribution.init()]):[3,8];case 7:k.sent(),k.label=8;case 8:return E=Lr(),S=E.ampTimestamp?Number(E.ampTimestamp):void 0,T=S?Date.now()<S:!0,w=T&&!Number.isNaN(Number(E.ampSessionId))?Number(E.ampSessionId):void 0,P=this.config.deferredSessionId,P===_n&&!this.config.optOut&&(P=Date.now()),this.setSessionId((c=(l=(u=r.sessionId)!==null&&u!==void 0?u:w)!==null&&l!==void 0?l:P)!==null&&c!==void 0?c:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(x){return I(F,void 0,void 0,function(){return _(this,function(R){return!x&&this.config.deferredSessionId&&(this.config.deferredSessionId===_n?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),A=Qt(this.config.instanceName),A.identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),this.config.offline===$c?[3,10]:[4,this.add(Mf()).promise];case 9:k.sent(),k.label=10;case 10:return[4,this.add(new ic({diagnosticsClient:p})).promise];case 11:return k.sent(),[4,this.add(new Jd).promise];case 12:return k.sent(),[4,this.add(new gc).promise];case 13:return k.sent(),xf(this.config),Dd(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(Df()).promise]):[3,15];case 14:k.sent(),k.label=15;case 15:return bs(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(Lf()).promise]):[3,17];case 16:k.sent(),k.label=17;case 17:return Es(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Po(So(this.config))).promise]):[3,20];case 18:return k.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(x){return I(F,void 0,void 0,function(){return _(this,function(R){switch(R.label){case 0:return x?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Po(So(this.config))).promise]);case 1:return R.sent(),[2]}})})}),k.label=20;case 20:return jn(this.config.defaultTracking)&&Wg(b)?(this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(Mg(b)).promise]):[3,22];case 21:k.sent(),k.label=22;case 22:return Ts(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(qh(qd(this.config),{diagnosticsClient:p})).promise]):[3,24];case 23:k.sent(),k.label=24;case 24:return _s(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(eg(Vd(this.config))).promise]):[3,26];
12case 25:k.sent(),k.label=26;case 26:return Ss(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(pg(Wd(this.config))).promise]):[3,28];case 27:k.sent(),k.label=28;case 28:return Md(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(Og(Nd(this.config))).promise]):[3,30];case 29:k.sent(),k.label=30;case 30:return Ud(this.config.autocapture)?(this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(ug(Fd(this.config))).promise]):[3,32];case 31:k.sent(),k.label=32;case 32:return xd(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(Ug()).promise]):[3,34];case 33:k.sent(),k.label=34;case 34:return Bd(this.config.customEnrichment)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(Fg()).promise]):[3,36];case 35:k.sent(),k.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return k.sent(),A.eventBridge.setEventReceiver(function(x){var R=x.eventProperties||{},M=R.time,U=at(R,["time"]),N=typeof M=="number"?{time:M}:void 0;F.track(x.eventType,U,N)}),[2]}})})},e.prototype.getUserId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.userId},e.prototype.setUserId=function(r){if(!this.config){this.q.push(this.setUserId.bind(this,r));return}this.config.loggerProvider.debug("function setUserId: ",r),(r!==this.config.userId||r===void 0)&&(this.config.userId=r,this.timeline.onIdentityChanged({userId:r}),vc(r,this.config.instanceName))},e.prototype.getDeviceId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.deviceId},e.prototype.setDeviceId=function(r){if(!this.config){this.q.push(this.setDeviceId.bind(this,r));return}this.config.loggerProvider.debug("function setDeviceId: ",r),r!==this.config.deviceId&&(this.config.deviceId=r,this.timeline.onIdentityChanged({deviceId:r}),hc(r,this.config.instanceName))},e.prototype.reset=function(){this.setDeviceId(Ue()),this.setUserId(void 0),this.timeline.onReset()},e.prototype.getIdentity=function(){var r,n;return{deviceId:(r=this.config)===null||r===void 0?void 0:r.deviceId,userId:(n=this.config)===null||n===void 0?void 0:n.userId,userProperties:this.userProperties}},e.prototype.setIdentity=function(r){var n,i,o;if("userId"in r&&this.setUserId(r.userId),"deviceId"in r&&r.deviceId&&this.setDeviceId(r.deviceId),"userProperties"in r){this.userProperties=r.userProperties;var a=new Tt,s=(o=r.userProperties)!==null&&o!==void 0?o:{};try{for(var u=L(Object.entries(s)),l=u.next();!l.done;l=u.next()){var c=D(l.value,2),f=c[0],d=c[1];a.set(f,d)}}catch(v){n={error:v}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}this.identify(a)}},e.prototype.getOptOut=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.optOut},e.prototype.getSessionId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.sessionId},e.prototype.setSessionId=function(r){var n,i=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,r)),ye(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=r??_n,ye(Promise.resolve());if(r===void 0&&(r=Date.now()),r===this.config.sessionId)return ye(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",r);var o=this.getSessionId();o!==r&&this.timeline.onSessionIdChanged(r);var a=this.config.lastEventTime,s=(n=this.config.lastEventId)!==null&&n!==void 0?n:-1;this.config.sessionId=r,this.config.lastEventTime=void 0,this.config.pageCounter=0,Eo(this.config.defaultTracking)&&(o&&a&&i.push(this.track(Io,void 0,{device_id:this.previousSessionDeviceId,event_id:++s,session_id:o,time:a+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var u=this.trackCampaignEventIfNeeded(++s,i);return this.config.identify&&i.push(this.track(pi(this.config.identify)).promise),Eo(this.config.defaultTracking)&&i.push(this.track(_o,void 0,{event_id:u?++s:s,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,ye(Promise.all(i))},e.prototype.extendSession=function(){if(!this.config){this.q.push(this.extendSession.bind(this));return}
12this.config.lastEventTime=Date.now()},e.prototype.setTransport=function(r){if(!this.config){this.q.push(this.setTransport.bind(this,r));return}this.config.transportProvider=Rs(r)},e.prototype.identify=function(r,n){if(cn(r)){var i=r._q;r._q=[],r=ln(new Tt,i)}return n?.user_id&&this.setUserId(n.user_id),n?.device_id&&this.setDeviceId(n.device_id),t.prototype.identify.call(this,r,n)},e.prototype.groupIdentify=function(r,n,i,o){if(cn(i)){var a=i._q;i._q=[],i=ln(new Tt,a)}return t.prototype.groupIdentify.call(this,r,n,i,o)},e.prototype.revenue=function(r,n){if(cn(r)){var i=r._q;r._q=[],r=ln(new Xl,i)}return t.prototype.revenue.call(this,r,n)},e.prototype.trackCampaignEventIfNeeded=function(r,n){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!oa(this.webAttribution.options))return!1;var i=this.webAttribution.generateCampaignEvent(r);return n?n.push(this.track(i).promise):this.track(i),this.config.loggerProvider.log("Tracking attribution."),!0},e.prototype.process=function(r){return I(this,void 0,void 0,function(){var n,i,o;return _(this,function(a){return n=Date.now(),i=ts(this.config.sessionTimeout,this.config.lastEventTime),o=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),r.event_type!==_o&&r.event_type!==Io&&(!r.session_id||r.session_id===this.getSessionId())&&(i||o?(this.setSessionId(n),o&&this.config.loggerProvider.log("Created a new session for new campaign.")):i||this.trackCampaignEventIfNeeded()),[2,t.prototype.process.call(this,r)]})})},e.prototype.logBrowserOptions=function(r){try{var n=C(C({},r),{apiKey:r.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",Ge(n))}catch(i){this.config.loggerProvider.error("Error logging browser config",i)}},e.prototype._setDiagnosticsSampleRate=function(r){if(!(r>1||r<0)&&!this.config){this._diagnosticsSampleRate=r;return}},e})(Kl),Gg=function(){var t=new Hg;return{init:de(t.init.bind(t),"init",le(t),ce(t,["config"])),add:de(t.add.bind(t),"add",le(t),ce(t,["config.apiKey","timeline.plugins"])),remove:de(t.remove.bind(t),"remove",le(t),ce(t,["config.apiKey","timeline.plugins"])),track:de(t.track.bind(t),"track",le(t),ce(t,["config.apiKey","timeline.queue.length"])),logEvent:de(t.logEvent.bind(t),"logEvent",le(t),ce(t,["config.apiKey","timeline.queue.length"])),identify:de(t.identify.bind(t),"identify",le(t),ce(t,["config.apiKey","timeline.queue.length"])),groupIdentify:de(t.groupIdentify.bind(t),"groupIdentify",le(t),ce(t,["config.apiKey","timeline.queue.length"])),setGroup:de(t.setGroup.bind(t),"setGroup",le(t),ce(t,["config.apiKey","timeline.queue.length"])),revenue:de(t.revenue.bind(t),"revenue",le(t),ce(t,["config.apiKey","timeline.queue.length"])),flush:de(t.flush.bind(t),"flush",le(t),ce(t,["config.apiKey","timeline.queue.length"])),getUserId:de(t.getUserId.bind(t),"getUserId",le(t),ce(t,["config","config.userId"])),setUserId:de(t.setUserId.bind(t),"setUserId",le(t),ce(t,["config","config.userId"])),getDeviceId:de(t.getDeviceId.bind(t),"getDeviceId",le(t),ce(t,["config","config.deviceId"])),setDeviceId:de(t.setDeviceId.bind(t),"setDeviceId",le(t),ce(t,["config","config.deviceId"])),reset:de(t.reset.bind(t),"reset",le(t),ce(t,["config","config.userId","config.deviceId"])),getSessionId:de(t.getSessionId.bind(t),"getSessionId",le(t),ce(t,["config"])),setSessionId:de(t.setSessionId.bind(t),"setSessionId",le(t),ce(t,["config"])),extendSession:de(t.extendSession.bind(t),"extendSession",le(t),ce(t,["config"])),setOptOut:de(t.setOptOut.bind(t),"setOptOut",le(t),ce(t,["config"])),setTransport:de(t.setTransport.bind(t),"setTransport",le(t),ce(t,["config"])),getIdentity:de(t.getIdentity.bind(t),"getIdentity",le(t),ce(t,["config"])),setIdentity:de(t.setIdentity.bind(t),"setIdentity",le(t),ce(t,["config","config.userId","config.deviceId"])),getOptOut:de(t.getOptOut.bind(t),"getOptOut",le(t),ce(t,["config"])),_setDiagnosticsSampleRate:de(t._setDiagnosticsSampleRate.bind(t),"_setDiagnosticsSampleRate",le(t),ce(t,["config"]))}};const ft=Gg();var aa=ft.add,jg=ft.getDeviceId,zg=ft.getSessionId,$g=ft.identify,Kg=ft.init,Xg=ft.setUserId,Pu=ft.track,sa;(function(t){t.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"})(sa||(sa={}));var er;(function(t){t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount"})(er||(er={}));var Au="$default_instance",ku="https://api2.amplitude.com/2/httpapi",Yg="https://api.eu.amplitude.com/2/httpapi",Qg="https://api2.amplitude.com/batch",Jg="https://api.eu.amplitude.com/batch",ve;(function(t){t.Unknown="unknown",t.Skipped="skipped",t.Success="success",t.RateLimit="rate_limit",t.PayloadTooLarge="payload_too_large",t.Invalid="invalid",t.Failed="failed",t.Timeout="Timeout",t.SystemError="SystemError"})(ve||(ve={}));var ue=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global},Zg=function(t){return t?(t^Math.random()*16>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Ru)},ua=W([],D(Array(256).keys()),!1).map(function(t){return t.toString(16).padStart(2,"0")}),Ru=function(t){var e,r=ue();if(!(!((e=r?.crypto)===null||e===void 0)&&e.getRandomValues))return Zg(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,W([],D(n.entries()),!1).map(function(i){var o=D(i,2),a=o[0],s=o[1];return[4,6,8,10].includes(a)?"-".concat(ua[s]):ua[s]}).join("")},ep=gi||Qa,In=function(t){return{promise:t||Promise.resolve()}},Pe;(function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Verbose=3]="Verbose",t[t.Debug=4]="Debug"})(Pe||(Pe={}));var gr="Amplitude Logger ",Fr=(function(){function t(){this.logLevel=Pe.None}return t.prototype.disable=function(){this.logLevel=Pe.None},t.prototype.enable=function(e){e===void 0&&(e=Pe.Warn),this.logLevel=e},t.prototype.log=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Pe.Verbose||console.log("".concat(gr,"[Log]: ").concat(e.join(" ")))},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Pe.Warn||console.warn("".concat(gr,"[Warn]: ").concat(e.join(" ")))},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Pe.Error||console.error("".concat(gr,"[Error]: ").concat(e.join(" ")))},t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<Pe.Debug||console.log("".concat(gr,"[Debug]: ").concat(e.join(" ")))},t})(),Ou=function(t){return t===void 0||t===""?Au:t},wr=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:Au,logLevel:Pe.Warn,loggerProvider:new Fr,offline:!1,optOut:!1,serverUrl:ku,serverZone:"US",useBatch:!1}},tp=(function(){function t(e){var r,n,i,o;this._optOut=!1;var a=wr();this.apiKey=e.apiKey,this.flushIntervalMillis=(r=e.flushIntervalMillis)!==null&&r!==void 0?r:a.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||a.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||a.flushQueueSize,this.instanceName=Ou(e.instanceName),this.loggerProvider=e.loggerProvider||a.loggerProvider,this.logLevel=(n=e.logLevel)!==null&&n!==void 0?n:a.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=e.offline!==void 0?e.offline:a.offline,this.optOut=(i=e.optOut)!==null&&i!==void 0?i:a.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||a.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=(o=e.useBatch)!==null&&o!==void 0?o:a.useBatch,this.loggerProvider.enable(this.logLevel);var s=np(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
12,enumerable:!1,configurable:!0}),t})(),rp=function(t,e){return t==="EU"?e?Jg:Yg:e?Qg:ku},np=function(t,e,r){if(t===void 0&&(t=""),e===void 0&&(e=wr().serverZone),r===void 0&&(r=wr().useBatch),t)return{serverUrl:t,serverZone:void 0};var n=["US","EU"].includes(e)?e:wr().serverZone;return{serverZone:n,serverUrl:rp(n,r)}};function ip(t){return t>=200&&t<300}var op=function(t){var e=new Error().stack||"";return e.split(`
13`).slice(2+t).map(function(r){return r.trim()})},qe=function(t,e,r,n,i){return i===void 0&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=r(),u=s.logger,l=s.logLevel;if(l&&l<Pe.Debug||!l||!u)return t.apply(i,o);var c={type:"invoke public method",name:e,args:o,stacktrace:op(1),time:{start:new Date().toISOString()},states:{}},f=t.apply(i,o);return f&&f.promise?f.promise.then(function(){c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))}):(c.time&&(c.time.end=new Date().toISOString()),u.debug(JSON.stringify(c,null,2))),f}};class ap{getApplicationContext(){return{versionName:this.versionName,language:sp(),platform:"Web",os:void 0,deviceModel:void 0}}}const sp=()=>typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]||navigator.language)||"";class up{constructor(){this.queue=[]}logEvent(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)}setEventReceiver(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(r=>{e(r)}),this.queue=[])}}const Cr=(t,e)=>{const r=["string","number","boolean","undefined"],n=typeof t;if(n!==typeof e)return!1;for(const s of r)if(s===n)return t===e;if(t==null&&e==null)return!0;if(t==null||e==null||t.length!==e.length)return!1;const o=Array.isArray(t),a=Array.isArray(e);if(o!==a)return!1;if(o&&a){for(let s=0;s<t.length;s++)if(!Cr(t[s],e[s]))return!1}else{const s=Object.keys(t).sort(),u=Object.keys(e).sort();if(!Cr(s,u))return!1;let l=!0;return Object.keys(t).forEach(c=>{Cr(t[c],e[c])||(l=!1)}),l}return!0},lp="$set",cp="$unset",dp="$clearAll";Object.entries||(Object.entries=function(t){const e=Object.keys(t);let r=e.length;const n=new Array(r);for(;r--;)n[r]=[e[r],t[e[r]]];return n});class fp{constructor(){this.identity={userProperties:{}},this.listeners=new Set}editIdentity(){const e=this,r=Object.assign({},this.identity.userProperties),n=Object.assign(Object.assign({},this.identity),{userProperties:r});return{setUserId:function(i){return n.userId=i,this},setDeviceId:function(i){return n.deviceId=i,this},setUserProperties:function(i){return n.userProperties=i,this},setOptOut(i){return n.optOut=i,this},updateUserProperties:function(i){let o=n.userProperties||{};for(const[a,s]of Object.entries(i))switch(a){case lp:for(const[u,l]of Object.entries(s))o[u]=l;break;case cp:for(const u of Object.keys(s))delete o[u];break;case dp:o={};break}return n.userProperties=o,this},commit:function(){return e.setIdentity(n),this}}}getIdentity(){return Object.assign({},this.identity)}setIdentity(e){const r=Object.assign({},this.identity);this.identity=Object.assign({},e),Cr(r,this.identity)||this.listeners.forEach(n=>{n(e)})}addIdentityListener(e){this.listeners.add(e)}removeIdentityListener(e){this.listeners.delete(e)}}const Vt=typeof globalThis<"u"?globalThis:typeof global<"u"?global:self;class Di{constructor(){this.identityStore=new fp,this.eventBridge=new up,this.applicationContextProvider=new ap}static getInstance(e){return Vt.analyticsConnectorInstances||(Vt.analyticsConnectorInstances={}),Vt.analyticsConnectorInstances[e]||(Vt.analyticsConnectorInstances[e]=new Di),Vt.analyticsConnectorInstances[e]}}var Lu=function(t){return Di.getInstance(Ou(t))},la=function(t){var e=0;if(t.length===0)return e;for(var r=0;r<t.length;r++){var n=t.charCodeAt(r);e=(e<<5)-e+n,e|=0}return e},Du=(function(){function t(){}return t.prototype.send=function(e,r,n){return Promise.resolve(null)},t.prototype.buildResponse=function(e){var r,n,i,o,a,s,u,l,c,f,d,v,h,g,m,p,y,b,E,S,T,w;if(typeof e!="object")return null;var P=e.code||0,A=this.buildStatus(P);switch(A){case ve.Success:return{status:A,statusCode:P,body:{eventsIngested:(r=e.events_ingested)!==null&&r!==void 0?r:0,payloadSizeBytes:(n=e.payload_size_bytes)!==null&&n!==void 0?n:0,serverUploadTime:(i=e.server_upload_time)!==null&&i!==void 0?i:0}};case ve.Invalid:return{status:A,statusCode:P,body:{error:(o=e.error)!==null&&o!==void 0?o:"",missingField:(a=e.missing_field)!==null&&a!==void 0?a:"",eventsWithInvalidFields:(s=e.events_with_invali
13d_fields)!==null&&s!==void 0?s:{},eventsWithMissingFields:(u=e.events_with_missing_fields)!==null&&u!==void 0?u:{},eventsWithInvalidIdLengths:(l=e.events_with_invalid_id_lengths)!==null&&l!==void 0?l:{},epsThreshold:(c=e.eps_threshold)!==null&&c!==void 0?c:0,exceededDailyQuotaDevices:(f=e.exceeded_daily_quota_devices)!==null&&f!==void 0?f:{},silencedDevices:(d=e.silenced_devices)!==null&&d!==void 0?d:[],silencedEvents:(v=e.silenced_events)!==null&&v!==void 0?v:[],throttledDevices:(h=e.throttled_devices)!==null&&h!==void 0?h:{},throttledEvents:(g=e.throttled_events)!==null&&g!==void 0?g:[]}};case ve.PayloadTooLarge:return{status:A,statusCode:P,body:{error:(m=e.error)!==null&&m!==void 0?m:""}};case ve.RateLimit:return{status:A,statusCode:P,body:{error:(p=e.error)!==null&&p!==void 0?p:"",epsThreshold:(y=e.eps_threshold)!==null&&y!==void 0?y:0,throttledDevices:(b=e.throttled_devices)!==null&&b!==void 0?b:{},throttledUsers:(E=e.throttled_users)!==null&&E!==void 0?E:{},exceededDailyQuotaDevices:(S=e.exceeded_daily_quota_devices)!==null&&S!==void 0?S:{},exceededDailyQuotaUsers:(T=e.exceeded_daily_quota_users)!==null&&T!==void 0?T:{},throttledEvents:(w=e.throttled_events)!==null&&w!==void 0?w:[]}};case ve.Timeout:default:return{status:A,statusCode:P}}},t.prototype.buildStatus=function(e){return ip(e)?ve.Success:e===429?ve.RateLimit:e===413?ve.PayloadTooLarge:e===408?ve.Timeout:e>=400&&e<500?ve.Invalid:e>=500?ve.Failed:ve.Unknown},t})(),vp=(function(t){Le(e,t);function e(r){r===void 0&&(r={});var n=t.call(this)||this;return n.customHeaders=r,n}return e.prototype.send=function(r,n){return I(this,void 0,void 0,function(){var i,o,a;return _(this,function(s){switch(s.label){case 0:if(typeof fetch>"u")throw new Error("FetchTransport is not supported");return i={headers:C({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(n),method:"POST"},[4,fetch(r,i)];case 1:return o=s.sent(),[4,o.text()];case 2:a=s.sent();try{return[2,this.buildResponse(JSON.parse(a))]}catch{return[2,this.buildResponse({code:o.status})]}return[2]}})})},e})(Du),hp=(function(){function t(e,r){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=r;try{this.isSupported=typeof localStorage<"u"}catch(n){this.logger.debug("Remote config localstorage failed to access: ",n),this.isSupported=!1}}return t.prototype.fetchConfig=function(){var e=null,r={remoteConfig:null,lastFetch:new Date};if(!this.isSupported)return Promise.resolve(r);try{e=localStorage.getItem(this.key)}catch(i){return this.logger.debug("Remote config localstorage failed to access: ",i),Promise.resolve(r)}if(e===null)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(r);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(ep(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(i){return this.logger.debug("Remote config localstorage failed to parse: ",i),localStorage.removeItem(this.key),Promise.resolve(r)}},t.prototype.setConfig=function(e){if(!this.isSupported)return Promise.resolve(!1);try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(r){this.logger.debug("Remote config localstorage failed to set: ",r)}return Promise.resolve(!1)},t})();function gp(t,e){return new Promise(function(r,n){var i=function(){var o=new Error("Remote config custom fetch aborted by timeout");o.name="AbortError",n(o)};e.addEventListener("abort",i,{once:!0}),t.then(function(o){e.removeEventListener("abort",i),r(o)},function(o){e.removeEventListener("abort",i),n(o)})})}var pp="https://sr-client-cfg.amplitude.com/config",mp="https://sr-client-cfg.eu.amplitude.com/config",yp=3,wn={INVALID_API_KEY:401,FORBIDDEN:403,RATE_LIMIT:429},bp=1e3,Ep=300*1e3,Sp=(function(){function t(e,r,n,i,o,a,s){n===void 0&&(n="US"),a===void 0&&(a=t.DEFAULT_CONFIG_GROUP),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvali
13dApiKey=!1,this.apiKey=e,this.configGroup=a,this.serverUrl=i||(n==="US"?pp:mp),this.logger=r,this.storage=s||new hp(e,r),this.customFetch=o}return t.prototype.subscribe=function(e,r,n){var i=Ru(),o={id:i,key:e,deliveryMode:r,callback:n};return this.callbackInfos.push(o),r==="all"?this.subscribeAll(o):this.subscribeWaitForRemote(o,r.timeout),i},t.prototype.unsubscribe=function(e){var r=this.callbackInfos.findIndex(function(n){return n.id===e});return r===-1?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(r,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},t.prototype.updateConfigs=function(){return I(this,void 0,void 0,function(){var e,r,n=this;return _(this,function(i){switch(i.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<Ep)?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return r=i.sent(),this.storage.setConfig(r),this.callbackInfos.forEach(function(o){n.sendCallback(o,r,"remote")}),[2]}})})},t.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?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.fetchPromise=this.fetch().then(function(r){return r.remoteConfig!==null&&(e.lastSuccessfulFetch=Date.now()),r}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},t.prototype.subscribeAll=function(e){return I(this,void 0,void 0,function(){var r,n,i,o=this;return _(this,function(a){switch(a.label){case 0:return r=this.getOrCreateFetchPromise().then(function(s){o.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(s))),o.sendCallback(e,s,"remote"),o.storage.setConfig(s)}),n=this.storage.fetchConfig().then(function(s){return s}),[4,Promise.race([r,n])];case 1:return i=a.sent(),i!==void 0&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(i))),i.remoteConfig!==null?this.sendCallback(e,i,"cache"):this.logger.debug("Remote config client skips sending c
13allback because cache is empty (first time user).")),[4,r];case 2:return a.sent(),[2]}})})},t.prototype.subscribeWaitForRemote=function(e,r){return I(this,void 0,void 0,function(){var n,i,i;return _(this,function(o){switch(o.label){case 0:n=new Promise(function(a,s){setTimeout(function(){s("Timeout exceeded")},r)}),o.label=1;case 1:return o.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return i=o.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,i,"remote"),this.storage.setConfig(i),[3,5];case 3:return o.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 i=o.sent(),i.remoteConfig!==null?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,i,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,i,"remote")),[3,5];case 5:return[2]}})})},t.prototype.sendCallback=function(e,r,n){e.lastCallback=new Date;var i;e.key?i=e.key.split(".").reduce(function(o,a){return o===null?o:a in o?o[a]:null},r.remoteConfig):i=r.remoteConfig,e.callback(i,n,r.lastFetch)},t.prototype.fetch=function(e,r){return e===void 0&&(e=yp),r===void 0&&(r=bp),I(this,void 0,void 0,function(){var n,i,o,a,s,u,l=this;return _(this,function(c){switch(c.label){case 0:n=r/e,i={remoteConfig:null,lastFetch:new Date},o=function(f){var d,v,h,g,m,p,y,b,E,S,T;return _(this,function(w){switch(w.label){case 0:d=!0,v=new AbortController,h=setTimeout(function(){return v.abort()},r),w.label=1;case 1:return w.trys.push([1,10,11,12]),g=a.getUrlParams(),m={Accept:"*/*"},a.customFetch?[4,gp(a.customFetch({url:g,method:"GET",headers:m,signal:v.signal}),v.signal)]:[3,3];case 2:return y=w.sent(),[3,5];case 3:return[4,fetch(g,{method:"GET",headers:m,signal:v.signal})];case 4:y=w.sent(),w.label=5;case 5:return p=y,b=p.ok||p.status>=200&&p.status<300,b?[3,7]:[4,p.text()];case 6:return E=w.sent(),a.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(p.status,": ").concat(E)),p.status===wn.INVALID_API_KEY||p.status===wn.FORBIDDEN?(a.logger.error("Remote config client fetch failed with ".concat(p.status,". Invalid API key; future fetches will be skipped.")),a.isLastFetchInvalidApiKey=!0,d=!1):p.status>=400&&p.status<500&&p.status!==wn.RATE_LIMIT&&(d=!1),[3,9];case 7:return[4,p.json()];case 8:return S=w.sent(),[2,{value:{remoteConfig:S,lastFetch:new Date}}];case 9:return[3,12];case 10:return T=w.sent(),T instanceof Error&&T.name==="AbortError"?a.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(r,"ms")):a.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),T),[3,12];case 11:return clearTimeout(h),[7];case 12:return d?f<e-1?[4,new Promise(function(P){return setTimeout(P,l.getJitterDelay(n))})]:[3,14]:[2,"break"];case 13:w.sent(),w.label=14;case 14:return[2]}})},a=this,s=0,c.label=1;case 1:return s<e?[5,o(s)]:[3,4];case 2:if(u=c.sent(),typeof u=="object")return[2,u.value];if(u==="break")return[3,4];c.label=3;case 3:return s++,[3,1];case 4:return[2,i]}})})},t.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},t.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),r=new URLSearchParams;return r.append("config_group",this.configGroup),"".concat(this.serverUrl,"/").concat(e,"?").concat(r.toString())},t.DEFAULT_CONFIG_GROUP="browser",t})(),Jn;(function(t){t.US="US",t.EU="EU",t.STAGING="STAGING"})(Jn||(Jn={}));var Zn="https://app.amplitude.com",Tp="https://app.eu.amplitude.com",_p="https://apps.stag2.amplitude.com",Ip={US:Zn,EU:Tp,STAGING:_p},wp="https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",Cp=function(t){var e=document.querySelector('script[src="'.concat(CSS.escape(t),'"]'));return e?Promise.resolve({status:!0}):new Promise(function(r,n){var i;try{var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=t,o.addEventListener("load",function(){r({status:!0})},{once:!0}),o.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(t)})}),(i=document.head)===null||i===void 0||i.appendChild(o)}catch(a){n(a)}})};function Pp(){return"".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9))}var xu,ei="__AMPLITUDE_MESSENGER_INSTANCE__",Br="__AMPLITUDE_MESSENGER__",Ap=(function(){function t(e){var r=e===void 0?{}:e,n=r.origin,i=n===void 0?Zn:n;this[xu]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=i}return t.prototype.notify=function(e){var r,n,i,o;(n=(r=this.logger)===null||r===void 0?void 0:r.debug)===null||n===void 0||n.call(r,"Message sent: ",JSON.stringify(e)),(o=(i=window.opener)===null||i===void 0?void 0:i.postMessage)===null||o===void 0||o.call(i,e,this.endpoint)},t.prototype.sendRequest=function(e,r,n){var i=this;n===void 0&&(n={timeout:15e3});var o=Pp(),a={id:o,action:e,args:r},s=new Promise(function(u,l){i.requestCallbacks[o]={resolve:u,reject:l},i.notify(a),n.timeout>0&&setTimeout(function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete i.requestCallbacks[o]},n.timeout)});return s},t.prototype.handleResponse=function(e){var r;if(!this.requestCallbacks[e.id]){(r=this.logger)===null||r===void 0||r.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},t.prototype.registerActionHandler=function(e,r){var n,i,o,a;this.actionHandlers.has(e)&&((a=(o=this.logger)===null||o===void 0?void 0:o.warn)===null||a===void 0||a.call(o,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,r);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var u=L(s),l=u.next();!l.done;l=u.next()){var c=l.value;r(c)}}catch(f){n={error:f}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}},t.prototype.loadScriptOnce=function(e){return I(this,void 0,void 0,function(){var r,n,i;return _(this,function(o){switch(o.label){case 0:if(r=this.scriptLoadPromises.get(e),r)return[2,r];n=Cp(e).then(function(){}),this.scriptLoadPromises.set(e,n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n];case 2:return o.sent(),[3,4];case 3:throw i=o.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},t.prototype.setup=function(e){var r=this,n,i,o=e===void 0?{}:e,a=o.logger,s=o.endpoint;a&&(this.logger=a),s&&this.endpoint===Zn&&(this.endpoint=s),!this.isSetup&&(this.isSetup=!0,(i=(n=this.logger)===null||n===void 0?void 0:n.debug)===null||i===void 0||i.call(n,"Setting up messenger"),this.messageHandler=function(u){var l,c,f,d,v;if((c=(l=r.logger)===null||l===void 0?void 0:l.debug)===null||c===void 0||c.c
13all(l,"Message received: ",JSON.stringify(u)),r.endpoint===u.origin){var h=u.data,g=h?.action;if(g)if("id"in h&&h.id)(d=(f=r.logger)===null||f===void 0?void 0:f.debug)===null||d===void 0||d.call(f,"Received Response to previous request: ",JSON.stringify(u)),r.handleResponse(h);else{if(g==="ping"){r.notify({action:"pong"});return}var m=r.actionHandlers.get(g);if(m)m(h.data);else{var p=(v=r.pendingMessages.get(g))!==null&&v!==void 0?v:[];p.push(h.data),r.pendingMessages.set(g,p)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},t.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=ue();e?.[Br]===this&&delete e[Br]},t})();xu=ei;function kp(t){return typeof t=="object"&&t!==null&&ei in t&&t[ei]===!0}function Rp(t){var e=ue(),r=e?.[Br];if(kp(r))return r;var n=new Ap(t);return e&&(e[Br]=n),n}var ca="__AMPLITUDE_BACKGROUND_CAPTURE__";function Op(t,e){var r,n=t;if(n[ca]!==!0){n[ca]=!0;var i=(r=void 0)!==null&&r!==void 0?r:wp,o=null,a=function(s,u){var l,c;s==="background-capture-complete"&&((c=(l=t.logger)===null||l===void 0?void 0:l.debug)===null||c===void 0||c.call(l,"Background capture complete"),t.notify({action:"background-capture-complete",data:u}))};t.registerActionHandler("initialize-background-capture",function(){var s,u;(u=(s=t.logger)===null||s===void 0?void 0:s.debug)===null||u===void 0||u.call(s,"Initializing background capture (external script)");var l=new URL(i,t.endpoint).toString();t.loadScriptOnce(l).then(function(){var c,f,d;(f=(c=t.logger)===null||c===void 0?void 0:c.debug)===null||f===void 0||f.call(c,"Background capture script loaded (external)"),o=(d=window?.amplitudeBackgroundCapture)===null||d===void 0?void 0:d.call(window,{messenger:t,onBackgroundCapture:a}),t.notify({action:"background-capture-loaded"})}).catch(function(){var c;(c=t.logger)===null||c===void 0||c.warn("Failed to initialize background capture")})}),t.registerActionHandler("close-background-capture",function(){var s;(s=o?.close)===null||s===void 0||s.call(o),o=null})}}var Mu="[Amplitude]",Lp="".concat(Mu," Session Replay ID"),Dp=0,xp=Jn.US,Mp={enabled:!0},xi=1e3,Np="".concat(Mu," Session Replay Debug"),Up="amp-block",Nu="amp-mask",Uu="amp-unmask",Fu="https://api-sr.amplitude.com/sessions/v2/track",Bu="https://api-sr.eu.amplitude.com/sessions/v2/track",qu="https://api-sr.stag2.amplitude.com/sessions/v2/track",Fp=2e6,Bp=6e6,Vu=9*1e6,qp=/payload.*exceed/i,Vp=3e4,Wp=6e4,ti=500,ri=10*1e3,Hp=1e3,Gp=10*1e3,ni=1024,jp=1e3,zp=64*1024,$p=1e4,da="X-Session-Replay-Event-Skipped",Kp="429",Xp="4004",Yp="4005",fa=6e4,Qp=2*Fp,Pr="amplitude-sr-iframe",We;(function(t){t.GET_SR_PROPS="get-sr-props",t.DEBUG_INFO="debug-info",t.FETCH_REQUEST="fetch-request",t.METADATA="metadata",t.TARGETING_DECISION="targeting-decision",t.REPLAY_GATE_DECISION="replay-gate-decision"})(We||(We={}));var ii=(function(){function t(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 t.prototype.getSafeMethod=function(e){var r;if(!this.logger)return(function(){});var n=this.logger[e];if(typeof n=="function"){var i=(r=n.__rrweb_original__)!==null&&r!==void 0?r:n;return i.bind(this.logger)}return(function(){})},t.prototype.enable=function(e){this.logger.enable(e)},t.prototype.disable=function(){this.logger.disable()},t})(),Mi="medium";function Jp(t){return t.toLowerCase()}function Zp(t){var e=t.type;return t.hasAttribute("data-rr-is-password")?"password":e?Jp(e):null}function Kt(t,e){return e||(t==="STAGING"?qu:t==="EU"?Bu:Fu)}var Wu=function(t,e,r){switch(e){case"light":{if(t!=="input")return!1;var n=r?Zp(r):"";return n?!!(["password","hidden","email","tel"].includes(n)||r.autocomplete.startsWith("cc-")):!1}case"medium":return t==="input";case"conservative":return!0;default:return Wu(t,Mi,r)}},Hu=function(t,e){var r,n,i;if(t&&e.urlMaskLevels)try{for(var o=L(e.urlMaskLevels),a=o.next();!a.done;a=o.next()){var s=a.value;if(ju(s.match).test(t))return s.maskLevel}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return(i=e.defaultMaskLevel)!==null&&i!==void 0?i:Mi},Gu=function(t,e,r,n){var i,o;if(e===void 0&&(e={defaultMaskLevel:Mi}),r){if(r.closest("."+Nu))return!0;var a=((i=e.maskSelector)!==null&&i!==void 0?i:[]).some(function(u){return r.closest(u)});if(a)return!0;
13if(r.closest("."+Uu))return!1;var s=((o=e.unmaskSelector)!==null&&o!==void 0?o:[]).some(function(u){return r.closest(u)});if(s)return!1}return Wu(t,Hu(n,e),r)},va=function(t,e,r){return function(n,i){return Gu(t,e,i,r?.())?n.replace(/[^\s]/g,"*"):n}},em=function(t,e){return function(r,n,i){var o;if(r==="style"||!((o=t?.maskAttributes)!==null&&o!==void 0?o:[]).includes(r))return n;var a=["INPUT","SELECT","TEXTAREA"].includes(i.tagName)?"input":"text";return Gu(a,t,i,e?.())?n.replace(/[^\s]/g,"*"):n}},oi=function(){var t=ue();return t?.location?t.location.href:""},tm=function(t,e){return"".concat(e,"/").concat(t)},rm=function(t){if(typeof t!="string"||t.trim()==="")return!1;var e=/^\/|^https?:\/\/[^\s]+$/;return!!e.test(t)},ha=new Map,ju=function(t){var e=ha.get(t);if(e)return e;var r="\0TRAIL\0",n="\0MID\0",i="\0DS\0",o="\0ST\0",a="\0QU\0",s=t;s=s.replace(/\/\*\*$/,r),s=s.replace(/\/\*\*\//g,n),s=s.replace(/\*\*/g,i),s=s.replace(/\*/g,o),s=s.replace(/\?/g,a),s=s.replace(/[.+^${}()|[\]\\]/g,"\\$&"),s=s.split(r).join("(/.*)?"),s=s.split(n).join("/(.*\\/)?"),s=s.split(i).join(".*"),s=s.split(o).join(".*"),s=s.split(a).join(".");var u=new RegExp("^".concat(s,"$"));return ha.set(t,u),u},nm=function(t){if(!t.every(function(e){return typeof e.selector=="string"&&typeof e.replacement=="string"}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!t.every(function(e){return rm(e.selector)}))throw new Error("ugcFilterRules must be an array of objects with valid globs")},$r=function(t,e){var r,n;try{for(var i=L(e),o=i.next();!o.done;o=i.next()){var a=o.value,s=ju(a.selector);if(s.test(t))return t.replace(s,a.replacement)}}catch(u){r={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t},zu=function(){return I(void 0,void 0,void 0,function(){var t,e,r,n,i,o,a;return _(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),t=ue(),t?[4,t.navigator.storage.estimate()]:[3,2];case 1:return e=s.sent(),r=e.usage,n=e.quota,i=e.usageDetails,o=r?Math.round(r/ni):0,a=r&&n?Math.round((r/n+Number.EPSILON)*1e3)/1e3:0,[2,{totalStorageSize:o,percentOfQuota:a,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return s.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},$u=function(t){var e=C({},t),r=e.apiKey;return e.apiKey="****".concat(r.substring(r.length-4)),e},Ku=function(){return{flushMaxRetries:2,logLevel:Pe.Warn,loggerProvider:new Fr,transportProvider:new vp}},im=(function(t){Le(e,t);function e(r,n){var i=this,o,a,s,u,l,c,f,d,v,h,g,m,p,y,b=Ku();i=t.call(this,C(C({transportProvider:b.transportProvider,loggerProvider:new ii(n.loggerProvider||b.loggerProvider)},n),{apiKey:r}))||this,i.flushMaxRetries=n.flushMaxRetries!==void 0&&n.flushMaxRetries<=b.flushMaxRetries?n.flushMaxRetries:b.flushMaxRetries,i.apiKey=r,i.sampleRate=n.sampleRate||Dp,i.serverZone=n.serverZone||xp,i.configServerUrl=n.configServerUrl,i.trackServerUrl=n.trackServerUrl,i.shouldInlineStylesheet=n.shouldInlineStylesheet,i.inlineImages=n.inlineImages,i.version=n.version,i.performanceConfig=n.performanceConfig||Mp,i.storeType=(o=n.storeType)!==null&&o!==void 0?o:"memory",i.applyBackgroundColorToBlockedElements=(a=n.applyBackgroundColorToBlockedElements)!==null&&a!==void 0?a:!1,i.enableUrlChangePolling=(s=n.enableUrlChangePolling)!==null&&s!==void 0?s:!1,i.urlChangePollingInterval=(u=n.urlChangePollingInterval)!==null&&u!==void 0?u:xi,i.captureDocumentTitle=(l=n.captureDocumentTitle)!==null&&l!==void 0?l:!1,n.fullSnapshotIntervalMs!==void 0&&(i.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),n.eagerFullSnapshotSend!==void 0&&(i.eagerFullSnapshotSend=n.eagerFullSnapshotSend),i.captureFullSnapshotOnFocus=(c=n.captureFullSnapshotOnFocus)!==null&&c!==void 0?c:!1,n.maxPersistedEventsSizeBytes!==void 0&&(i.maxPersistedEventsSizeBytes=pa(n.maxPersistedEventsSizeBytes,ga,om,"maxPersistedEventsSizeBytes",i.loggerProvider)),n.maxSingleEventSizeBytes!==void 0&&(i.maxSingleEventSizeBytes=pa(n.maxSingleEventSizeBytes,ga,am,"maxSingleEventSizeBytes",i.loggerProvider)),i.privacyConfig=C(C({},(f=n.privacyConfig)!==null&&f!==void 0?f:{}),{unmaskSelector:Array.from(new Set(W([".".concat(Uu)],D((v=(d=n.privacyConfig)===null||d===void 0?void 0:d.unmaskSelector)!==null&&v!==void 0?v:[]),!1)))}),n.interactionConfig&&(i.interactionConfig=n.interactionConfig,i.interactionConfig.ugcFilterRules&&nm(i.interactionConfig.ugcFilterRules)),n.debugMode&&(i.debugMode=n.debugMode);var E=n;return i.useWebWorker=(m=(h=n.useWebWorker)!==null&&h!==void 0?h:(g=E.experimental)===null||g===void 0?void 0:g.useWebWorker)!==null&&m!==void 0?m:!0,i.enableTransportCompression=(p=n.enableTransportCompression)!==null&&p!==void 0?p:!0,i.sendTimeoutMs=n.sendTimeoutMs,i.captureAdoptedStyleSheets=(y=n.captureAdoptedStyleSheets)!==null&&y!==void 0?y:!0,n.crossOriginIframes&&(i.crossOriginIframes=n.crossOriginIframes),n.flushIntervalConfig?i.flushIntervalConfig=sm(n.flushIntervalConfig,i.loggerProvider):i.flushIntervalConfig={minIntervalMs:Hp,maxIntervalMs:Gp},i.handleSendEvents=n.handleSendEvents,i.handleFetchConfig=n.handleFetchConfig,i}return e})(tp),pt=100,ga=1e3,om=8e6,am=1e7;function pa(t,e,r,n,i){if(!Number.isFinite(t)){i.warn("".concat(n," value is not a finite number (got ").concat(String(t),"); ignoring."));return}return t<e?(i.warn("".concat(n," ").concat(t," is below floor ").concat(e,"; clamping.")),e):t>r?(i.warn("".concat(n," ").concat(t," exceeds ceiling ").concat(r,"; clamping.")),r):t}function sm(t,e){var r,n,i={};if(t.minIntervalMs!==void 0&&(!Number.isFinite(t.minIntervalMs)||t.minIntervalMs<pt?(e.warn("flushIntervalConfig.minIntervalMs ".concat(t.minIntervalMs," is below floor ").concat(pt,"ms; clamping.")),i.minIntervalMs=pt):i.minIntervalMs=t.minIntervalMs),t.maxIntervalMs!==void 0&&(Number.isNaN(t.maxIntervalMs)||t.maxIntervalMs<pt?(e.warn("flushIntervalConfig.maxIntervalMs ".concat(t.maxIntervalMs," is below floor ").concat(pt,"ms; clamping.")),i.maxIntervalMs=pt):i.maxIntervalMs=t.maxIntervalMs),i.minIntervalMs!==void 0||i.maxIntervalMs!==void 0){var o=(r=i.minIntervalMs)!==null&&r!==void 0?r:ti,a=(n=i.maxIntervalMs)!==null&&n!==void 0?n:ri;a<o&&(i.maxIntervalMs===void 0?(e.warn("flushIntervalConfig.minIntervalMs (".concat(o,") exceeds the default maxIntervalMs (").concat(ri,"); raising max to match min.")),i.maxIntervalMs=o):i.minIntervalMs===void 0?(e.warn("flushIntervalConfig.maxIntervalMs (".concat(a,") is below the default minIntervalMs (").concat(ti,");
13 lowering min to match max.")),i.minIntervalMs=a):(e.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}var Kr=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Kr||{}),Ni=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(Ni||{}),Xu=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(Xu||{}),um=1500,lm=function(t,e){var r=document.createDocumentFragment(),n=function(i){if(i===void 0&&(i=[]),typeof i=="string"&&(i=[i]),i=i.filter(function(o){try{r.querySelector(o)}catch{return e.warn('[session-replay-browser] omitting selector "'.concat(o,'" because it is invalid')),!1}return!0}),i.length!==0)return i};return t.blockSelector=n(t.blockSelector),t.maskSelector=n(t.maskSelector),t.unmaskSelector=n(t.unmaskSelector),t},cm=(function(){function t(e,r){this.localConfig=r,this.remoteConfigClient=e}return t.prototype.generateJoinedConfig=function(){var e,r,n,i,o,a,s;return I(this,void 0,void 0,function(){var u,l,c,f,d,v,h,g,m,p,y,b,E,S,T,w,P,A=this;return _(this,function(F){switch(F.label){case 0:u=C({},this.localConfig),u.optOut=this.localConfig.optOut,u.captureEnabled=!0,F.label=1;case 1:return F.trys.push([1,3,,4]),[4,new Promise(function(k,x){A.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:um},function(R,M){var U;if(A.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(M,":"),JSON.stringify(R,null,2)),!R){x(new Error("No remote config received"));return}var N=R,q=N.sr_sampling_config,$=N.sr_privacy_config,H=N.sr_targeting_config,j=(U=u.interactionConfig)===null||U===void 0?void 0:U.ugcFilterRules;u.interactionConfig=N.sr_interaction_config,u.interactionConfig&&j&&(u.interactionConfig.ugcFilterRules=j),u.loggingConfig=N.sr_logging_config,(q||$||H)&&(l={},q&&(l.sr_sampling_config=q),$&&(l.sr_privacy_config=$),H&&(l.sr_targeting_config=H)),k()})})];case 2:return F.sent(),[3,4];case 3:return c=F.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",c),u.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:void 0}];case 4:if(!l)return[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:l}];if(f=l.sr_sampling_config,d=l.sr_privacy_config,v=l.sr_targeting_config,f&&Object.keys(f).length>0?(Object.prototype.hasOwnProperty.call(f,"capture_enabled")?u.captureEnabled=f.capture_enabled:u.captureEnabled=!1,Object.prototype.hasOwnProperty.call(f,"sample_rate")&&(u.sampleRate=f.sample_rate),Object.prototype.hasOwnProperty.call(f,"min_session_duration_ms")&&(u.minSessionDurationMs=this.sanitizeMinSessionDurationMs(f.min_session_duration_ms))):(u.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){h=(e=u.privacyConfig)!==null&&e!==void 0?e:{},g={defaultMaskLevel:(n=(r=d.defaultMaskLevel)!==null&&r!==void 0?r:h.defaultMaskLevel)!==null&&n!==void 0?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:W([],D(new Set(W(W([],D((i=h.maskAttributes)!==null&&i!==void 0?i:[]),!1),D((o=d.maskAttributes)!==null&&o!==void 0?o:[]),!1))),!1),urlMaskLevels:W(W([],D((a=d.urlMaskLevels)!==null&&a!==void 0?a:[]),!1),D((s=h.urlMaskLevels)!==null&&s!==void 0?s:[]),!1)}
13,m=function(k){var x,R,M,U,N,q,$,H,j,O={};typeof k.blockSelector=="string"&&(k.blockSelector=[k.blockSelector]);try{for(var G=L(($=k.blockSelector)!==null&&$!==void 0?$:[]),V=G.next();!V.done;V=G.next()){var X=V.value;O[X]="block"}}catch(ee){x={error:ee}}finally{try{V&&!V.done&&(R=G.return)&&R.call(G)}finally{if(x)throw x.error}}try{for(var Y=L((H=k.maskSelector)!==null&&H!==void 0?H:[]),J=Y.next();!J.done;J=Y.next()){var X=J.value;O[X]="mask"}}catch(ee){M={error:ee}}finally{try{J&&!J.done&&(U=Y.return)&&U.call(Y)}finally{if(M)throw M.error}}try{for(var Q=L((j=k.unmaskSelector)!==null&&j!==void 0?j:[]),re=Q.next();!re.done;re=Q.next()){var X=re.value;O[X]="unmask"}}catch(ee){N={error:ee}}finally{try{re&&!re.done&&(q=Q.return)&&q.call(Q)}finally{if(N)throw N.error}}return O},p=C(C({},m(h)),m(d));try{for(y=L(Object.entries(p)),b=y.next();!b.done;b=y.next())E=D(b.value,2),S=E[0],T=E[1],T==="mask"?g.maskSelector.push(S):T==="block"?g.blockSelector.push(S):T==="unmask"&&g.unmaskSelector.push(S)}catch(k){w={error:k}}finally{try{b&&!b.done&&(P=y.return)&&P.call(y)}finally{if(w)throw w.error}}u.privacyConfig=lm(g,this.localConfig.loggerProvider)}return v&&Object.keys(v).length>0&&(u.targetingConfig=v),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:$u(u)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:l}]}})})},t.prototype.sanitizeMinSessionDurationMs=function(e){if(typeof e!="number"||!Number.isFinite(e)){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."));return}if(e<0){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring."));return}return e>Cn?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(Cn,"ms ceiling; clamping.")),Cn):e},t})(),Cn=6e4,dm=function(t,e){return I(void 0,void 0,void 0,function(){var r,n;return _(this,function(i){return r=new im(t,e),n=new Sp(t,r.loggerProvider,r.serverZone,e.configServerUrl,e.handleFetchConfig),[2,new cm(n,r)]})})};function ma(t){if(t.type!==Kr.IncrementalSnapshot)return!1;var e=t.data;return e.source===Ni.Mutation&&!e.isAttachIframe}function fm(t){return typeof t=="object"&&t!==null}function vm(t){var e,r,n,i,o={};try{for(var a=L(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var l=(n=void 0,L(Object.keys(u))),c=l.next();!c.done;c=l.next()){var f=c.value;o[f]=u[f]}}catch(d){n={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}}}catch(d){e={error:d}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o}function hm(t){var e,r,n=new Map;if(t.forEach(function(d,v){if(d.attributes&&"style"in d.attributes){var h=n.get(d.id);h?h.push(v):n.set(d.id,[v])}}),n.size===0)return t;var i=function(d){return t[d].attributes.style},o=new Set,a=new Map,s=function(d){if(d.length===1)return"continue";var v=-1;d.forEach(function(p,y){fm(i(p))||(v=y)});var h=[];if(d.forEach(function(p,y){y!==v&&(o.add(p),y>v&&h.push(p))}),h.length>0){var g=h[h.length-1],m=vm(h.map(function(p){return i(p)}));o.delete(g),a.set(g,m)}};try{for(var u=L(n.values()),l=u.next();!l.done;l=u.next()){var c=l.value;s(c)}}catch(d){e={error:d}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}if(o.size===0&&a.size===0)return t;var f=[];return t.forEach(function(d,v){var h=a.get(v);if(h!==void 0){f.push(C(C({},d),{attributes:C(C({},d.attributes),{style:h})}));return}if(!o.has(v)){f.push(d);return}var g=C({},d.attributes);delete g.style,Object.keys(g).length>0&&f.push(C(C({},d),{attributes:g}))}),f}function gm(t){var e,r,n,i,o=t[0],a=new Map,s=new Map,u=new Map,l=new Map,c=new Map;t.forEach(function(O,G){var V,X,Y,J,Q=O.data;try{for(var re=L(Q.adds),ee=re.next();!ee.done;ee=re.next()){var B=ee.value;a.has(B.node.id)||a.set(B.node.id,G),s.set(B.node.id,G),c.set(B.node.id,B.parentId)}}catch(K){V={error:K}}finally{try{ee&&!ee.done&&(X=re.return)&&X.call(re)}finally{if(V)throw V.error}}try{for(var ie=L(Q.removes),oe=ie.next();!oe.done;oe=ie.next()){var se=oe.value;u.has(se.id)||u.set(se.id,G),l.set(se.id,G)}}catch(K){Y={error:K}
13}finally{try{oe&&!oe.done&&(J=ie.return)&&J.call(ie)}finally{if(Y)throw Y.error}}});var f=new Set,d=new Set;try{for(var v=L(a),h=v.next();!h.done;h=v.next()){var g=D(h.value,2),m=g[0],p=g[1],y=u.get(m);if(y!==void 0){var b=s.get(m),E=l.get(m);b>=E||(p<y?f.add(m):y<p&&d.add(m))}}}catch(O){e={error:O}}finally{try{h&&!h.done&&(r=v.return)&&r.call(v)}finally{if(e)throw e.error}}var S=new Set;if(f.size>0||d.size>0)for(var T=!0;T;){T=!1;try{for(var w=(n=void 0,L(c)),P=w.next();!P.done;P=w.next()){var A=D(P.value,2),F=A[0],k=A[1];if(!f.has(F)&&!d.has(F)&&!S.has(F)&&(f.has(k)||d.has(k)||S.has(k))){var x=u.get(F),R=a.get(F);x!==void 0&&R!==void 0&&x<R?d.add(F):x!==void 0&&R!==void 0&&x===R?S.add(F):f.add(F),T=!0}}}catch(O){n={error:O}}finally{try{P&&!P.done&&(i=w.return)&&i.call(w)}finally{if(n)throw n.error}}}var M=f.size>0||d.size>0||S.size>0,U=[];t.forEach(function(O,G){var V,X;try{for(var Y=L(O.data.removes),J=Y.next();!J.done;J=Y.next()){var Q=J.value;f.has(Q.id)||d.has(Q.id)&&G>=a.get(Q.id)||S.has(Q.id)&&(f.has(Q.parentId)||d.has(Q.parentId)||S.has(Q.parentId))||U.push(Q)}}catch(re){V={error:re}}finally{try{J&&!J.done&&(X=Y.return)&&X.call(Y)}finally{if(V)throw V.error}}});var N=t.flatMap(function(O){return O.data.adds}),q=t.flatMap(function(O){return O.data.texts}),$=t.flatMap(function(O){return O.data.attributes}),H=M?$.filter(function(O){return!f.has(O.id)&&!d.has(O.id)&&!S.has(O.id)}):$,j={source:Ni.Mutation,removes:U,adds:M?N.filter(function(O){return!f.has(O.node.id)&&!d.has(O.node.id)&&!S.has(O.node.id)}):N,texts:M?q.filter(function(O){return!f.has(O.id)&&!d.has(O.id)&&!S.has(O.id)}):q,attributes:hm(H)};return C(C({},o),{data:j})}function pm(t){if(t.length<=1)return t;for(var e=[],r=0;r<t.length;){if(!ma(t[r])){e.push(t[r]),r++;continue}for(var n=r+1;n<t.length&&ma(t[n]);)n++;e.push(n>r+1?gm(t.slice(r,n)):t[r]),r=n}return e}var mm=2e3,ym=(function(){function t(e,r,n,i,o){var a=this,s;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(d){var v=d,h=v.type,g=v.timestamp,m=v.delay,p=v.data;return m!=null?JSON.stringify({type:h,timestamp:g,delay:m,data:p}):JSON.stringify({type:h,timestamp:g,data:p})},this.addCompressedEventToManager=function(d,v){var h,g=new Blob([d]).size;if(g>((h=a.config.maxSingleEventSizeBytes)!==null&&h!==void 0?h:Vu)){a.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(g/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."));return}a.eventsManager&&a.deviceId&&a.eventsManager.addEvent({event:{type:"replay",data:d},sessionId:v,deviceId:a.deviceId})},this.addCompressedEvent=function(d,v){if(a.worker)try{a.worker.postMessage({event:d,sessionId:v})}catch(g){g.name==="DataCloneError"?a.worker.postMessage(JSON.stringify({event:d,sessionId:v})):a.config.loggerProvider.warn("Unexpected error while posting message to worker:",g)}else{var h=a.compressEvent(d);a.addCompressedEventToManager(h,v)}},this.flushQueue=function(){var d;for(a.pendingQueue.length>0&&(d=a.taskQueue).push.apply(d,W([],D(a.mergeMutationTasks(a.pendingQueue.splice(0))),!1));a.taskQueue.length>0;){var v=a.taskQueue.shift();if(v){var h=v.event,g=v.sessionId,m=a.compressEvent(h);a.addCompressedEventToManager(m,g)}}a.isProcessing=!1},this.terminate=function(){var d;(d=a.worker)===null||d===void 0||d.terminate()};var u=ue();if(this.canUseIdleCallback=u&&"requestIdleCallback"in u,this.eventsManager=e,this.config=r,this.deviceId=n,this.timeout=((s=r.performanceConfig)===null||s===void 0?void 0:s.timeout)||mm,this.onFullSnapshotProcessed=o,i){r.loggerProvider.log("Enabling web worker for compression");try{var l=new Blob([i],{type:"application/javascript"}),c=URL.createObjectURL(l),f=new Worker(c);f.onerror=function(d){d.preventDefault(),r.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(d.message," (").concat(d.filename,":").concat(d.lineno,")")),f.terminate(),a.worker=void 0},f.onmessage=function(d){var v=d.data,h=v.compressedEvent,g=v.sessionId;a.addCompressedEventToManager(h,g)},this.worker=f}catch(d){r.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",d)}}}return t.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(r){e.processQueue(r)},{timeout:this.timeout}))},t.prototype.enqueueEvent=function(e,r){var n,i,o,a;if(e.type===Kr.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var s=W(W([],D(this.taskQueue.splice(0)),!1),D(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var u=L(s),l=u.next();!l.done;l=u.next()){var c=l.value,f=this.compressEvent(c.event);this.addCompressedEventToManager(f,c.sessionId)}}catch(v){n={error:v}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,r),(o=this.onFullSnapshotProcessed)===null||o===void 0||o.call(this);return}this.canUseIdleCallback&&(!((a=this.config.performanceConfig)===null||a===void 0)&&a.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:r}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,r))},t.prototype.processQueue=function(e){var r,n=this;for(this.pendingQueue.length>0&&(r=this.taskQueue).push.apply(r,W([],D(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var i=this.taskQueue.shift();if(i){var o=i.event,a=i.sessionId;this.addCompressedEvent(o,a)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(s){n.processQueue(s)},{timeout:this.timeout}):this.isProcessing=!1},t.prototype.mergeMutationTasks=function(e){var r,n,i;if(((i=this.config.performanceConfig)===null||i===void 0?void 0:i.mergeMutations)===!1||e.length<=1)return e;for(var o=[],a=0;a<e.length;){for(var s=e[a].sessionId,u=a+1;u<e.length&&e[u].sessionId===s;)u++;var l=pm(e.slice(a,u).map(function(v){return v.event}));try{for(var c=(r=void 0,L(l)),f=c.next();!f.done;f=c.next()){var d=f.value;o.push({event:d,sessionId:s})}}catch(v){r={error:v}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}a=u}return o},t})(),bm="Unexpected error occurred",Em="Network error occurred, event batch rejected",ya="Session replay event batch rejected due to exceeded retry count",Ie="Failed to store session replay events in IndexedDB",Sm="Session replay event batch not sent due to missing device ID",Tm="Session replay event batch not sent due to missing api key",Pn="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",qr="1.50.2";function _m(t,e){return I(this,void 0,void 0,function(){var r,n,i,o,a,s,u,l,c,f,d,v,h,g,m=this;return _(this,function(p){switch(p.label){case 0:return p.trys.push([0,4,,5]),r=e.CompressionStream,n=new r("gzip"),i=n.writable.getWriter(),o=n.readable.getReader(),a=[],s=(function(){return I(m,void 0,void 0,function(){var y,b,E;return _(this,function(S){switch(S.label){case 0:return[4,o.read()];case 1:if(y=S.sent(),b=y.done,E=y.value,b)return[3,3];a.push(E),S.label=2;case 2:return[3,0];case 3:return[2]}})})})(),[4,i.write(new TextEncoder().encode(t))];case 1:return p.sent(),[4,i.close()];case 2:return p.sent(),[4,s];case 3:p.sent(),u=a.reduce(function(y,b){return y+b.length},0),l=new Uint8Array(u),c=0;try{for(f=L(a),d=f.next();!d.done;d=f.next())v=d.value,l.set(v,c),c+=v.length}catch(y){h={error:y}}finally{try{d&&!d.done&&(g=f.return)&&g.call(f)}finally{if(h)throw h.error}}return[2,l];case 4:return p.sent(),[2,null];case 5:return[2]}})})}var Im=256,wm=256;function Cm(t,e){return new Promise(function(r,n){var i=function(){var o=new Error("Custom session replay transport aborted by send timeout");o.name="AbortError",n(o)};e.addEventListener("abort",i,{once:!0}),t.then(function(o){e.removeEventListener("abort",i),r(o)},function(o){e.removeEventListener("abort",i),n(o)})})}var Pm=(function(){function t(e){var r=e.trackServerUrl,n=e.loggerProvider,i=e.payloadBatcher,o=e.workerScript,a=e.enableTransportCompression,s=e.sendTimeoutMs,u=e.handleSendEvents,l=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=i||function(v){return v},this.trackServerUrl=r,this.enableTransportCompression=a??!0,this.sendTimeoutMs=s??$p,this.handleSendEvents=u,o)try{var c=new Blob([o],{type:"application/javascript"}),f=URL.createObjectURL(c),d=new Worker(f);d.onerror=function(v){var h,g;v.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(v.message," (").concat(v.filename,":").concat(v.lineno,")")),d.terminate(),l.worker=void 0;try{for(var m=L(l.pendingWorkerRequests),p=m.next();!p.done;p=m.next()){var y=D(p.value,2),b=y[1];b.timeout&&clearTimeout(b.timeout),n.warn("Session replay event send failed due to worker crash: ".concat(v.message)),b.resolve()}}catch(E){h={error:E}}finally{try{p&&!p.done&&(g=m.return)&&g.call(m)}finally{if(h)throw h.error}}l.pendingWorkerRequests.clear(),l.timedOutWorkerRequests.clear()},d.onmessage=function(v){var h=v.data;if(h.type==="log")n.log(h.message);else if(h.type==="warn")n.warn(h.message);else if(h.type==="payload_too_large"){var g=l.pendingWorkerRequests.get(h.id);if(g)g.timeout&&clearTimeout(g.timeout),l.handlePayloadTooLargeResponse(g.context,h.isWaf),g.resolve(),l.pendingWorkerRequests.delete(h.id);else{var m=l.timedOutWorkerRequests.get(h.id);m&&(l.timedOutWorkerRequests.delete(h.id),l.handlePayloadTooLargeResponse(m,h.isWaf))}}else if(h.type==="complete"){var p=l.pendingWorkerRequests.get(h.id);if(p)p.timeout&&clearTimeout(p.timeout),h.skipCode!==void 0&&l.applyServerDirective(p.context.sessionId,h.skipCode),l.completeRequest({context:p.context}),p.resolve(),l.pendingWorkerRequests.delete(h.id);else{var m=l.timedOutWorkerRequests.get(h.id);m&&(l.timedOutWorkerRequests.delete(h.id),h.skipCode!==void 0&&l.applyServerDirective(m.sessionId,h.skipCode),l.completeRequest({context:m}))}}else h.type==="fetch-request"&&l.handleDelegatedFetch(d,h).catch(function(y){n.warn("Failed to handle delegated session replay fetch:",y)})},this.worker=d}catch(v){n.error("Failed to create track destination worker, falling back to main-thread sending:",v)}}return t.prototype.sendEventsList=function(e){this.addToQueue(C(C({},e),{attempts:0,timeout:0}))},t.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},t.prototype.sendBeacon=function(e){var r=this,n,i,o=e.events,a=e.sessionId,s=e.deviceId,u=e.apiKey,l=e.serverZone,c=64*1024,f=function(A){return new Blob([A]).size},d=o,v=JSON.stringify({version:2,events:d});if(f(v)>c){for(var h=0,g=d.length;h<g;){var m=Math.floor((h+g+1)/2);f(JSON.stringify({version:2,events:d.slice(0,m)}))<=c?h=m:g=m-1}d=d.slice(0,h),v=JSON.stringify({version:2,events:d}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(o.length," to ").concat(d.length," events"))}if(d.length!==0){if(this.handleSendEvents){var p=new URLSearchParams({device_id:s,session_id:String(a),type:"replay"}),y="".concat(Kt(l,this.trackServerUrl),"?").concat(p.toString()),b={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(u)};this.loggerProvider.debug("Routing session replay exit batch (".concat(d.length," events) through custom transport for session id ").concat(a,"."));try{this.handleSendEvents({url:y,method:"POST",headers:b,body:v,keepalive:!0}
13).catch(function(A){r.loggerProvider.warn("Custom transport failed to send session replay exit batch:",A)})}catch(A){this.loggerProvider.warn("Custom transport threw while sending session replay exit batch:",A)}return}var E=new URLSearchParams({device_id:s,session_id:String(a),type:"replay",api_key:u}),S="".concat(Kt(l,this.trackServerUrl),"?").concat(E.toString()),T=ue();try{var w=new Blob([v],{type:"application/json"}),P=(i=(n=T?.navigator)===null||n===void 0?void 0:n.sendBeacon)===null||i===void 0?void 0:i.call(n,S,w);P===!1&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch{}}},t.prototype.addToQueue=function(){for(var e=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=r.filter(function(o){return e.killedSessions.has(o.sessionId)?(e.completeRequest({context:o,err:Pn}),!1):o.attempts<(o.flushMaxRetries||0)?(o.attempts+=1,!0):(e.completeRequest({context:o,err:ya}),!1)});i.forEach(function(o){e.queue=e.queue.concat(o),e.schedule(0)})},t.prototype.schedule=function(e){var r=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),i=n>0,o=n>e?n:e;i&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){r.flush(!0).then(function(){r.queue.length>0&&r.schedule(e)})},o)}},t.prototype.flush=function(e){return e===void 0&&(e=!1),I(this,void 0,void 0,function(){var r,n,i,o,a,s,u;return _(this,function(l){switch(l.label){case 0:r=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,r=this.mergeQueueAfterThrottle(r)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,r=this.mergeDrainBacklog(r)),l.label=1;case 1:l.trys.push([1,6,7,8]),n=L(r),i=n.next(),l.label=2;case 2:return i.done?[3,5]:(o=i.value,[4,this.send(o,e)]);case 3:l.sent(),l.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=l.sent(),s={error:a},[3,8];case 7:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 8:return[2]}})})},t.prototype.mergeQueueAfterThrottle=function(e){var r=this.coalesceByIdentity(e);return r.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(r.length," request(s)"))),r},t.prototype.mergeDrainBacklog=function(e){var r=this.coalesceByIdentity(e);return r.length<e.length&&this.loggerProvider.log("Session replay coalesced ".concat(e.length," persisted page-load backlog batches into ").concat(r.length," request(s)")),r},t.prototype.coalesceByIdentity=function(e){var r,n,i,o,a=this,s,u,l,c,f,d,v;if(e.length<=1)return e;var h=new Map;try{for(var g=L(e),m=g.next();!m.done;m=g.next()){var p=m.value,y=[p.sessionId,(s=p.deviceId)!==null&&s!==void 0?s:"",(u=p.apiKey)!==null&&u!==void 0?u:"",p.type,(l=p.serverZone)!==null&&l!==void 0?l:"",p.sampleRate,(f=(c=p.version)===null||c===void 0?void 0:c.type)!==null&&f!==void 0?f:"",(v=(d=p.version)===null||d===void 0?void 0:d.version)!==null&&v!==void 0?v:""].join("|"),b=h.get(y);b?b.push(p):h.set(y,[p])}}catch(A){r={error:A}}finally{try{m&&!m.done&&(n=g.return)&&n.call(g)}finally{if(r)throw r.error}}var E=[],S=function(A){var F,k;if(A.length===1)return E.push(A[0]),"continue";var x=null,R=0,M=function(){x&&E.push(x),x=null,R=0},U=function(H){var j=H.events.reduce(function(V,X){return V+new Blob([X]).size},0);if(x===null)return x=C(C({},H),{events:W([],D(H.events),!1),attempts:0}),R=j,"continue";if(R+j>Qp)return M(),x=C(C({},H),{events:W([],D(H.events),!1),attempts:0}),R=j,"continue";var O=x.onComplete,G=H.onComplete;x.events=x.events.concat(H.events),R+=j,x.onComplete=function(){return I(a,void 0,void 0,function(){return _(this,function(V){switch(V.label){case 0:return[4,Promise.allSettled([O(),G()])];case 1:return V.sent(),[2]}})})}};try{for(var N=(F=void 0,L(A)),q=N.next();!q.done;q=N.next()){var $=q.value;U($)}}catch(H){F={error:H}}finally{try{q&&!q.done&&(k=N.return)&&k.call(N)}finally{if(F)throw F.error}}M()};try{for(var T=L(h.values()),w=T.next();!w.done;w=T.next()){var P=w.value;S(P)}}catch(A){i={error:A}}
13finally{try{w&&!w.done&&(o=T.return)&&o.call(T)}finally{if(i)throw i.error}}return E},t.prototype.send=function(e,r){return r===void 0&&(r=!0),I(this,void 0,void 0,function(){var n,i,o,a;return _(this,function(s){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:Pn})]:(n=e.apiKey,n?(i=e.deviceId,i?(o=this.payloadBatcher({version:1,events:e.events}),o.events.length===0?(this.completeRequest({context:e}),[2]):(a=this.worker,a?[2,this.sendViaWorker(a,e,o,r)]:[2,this.sendOnMainThread(n,i,e,o,r)])):[2,this.completeRequest({context:e,err:Sm})]):[2,this.completeRequest({context:e,err:Tm})])})})},t.prototype.sendViaWorker=function(e,r,n,i){return I(this,void 0,void 0,function(){var o,a=this;return _(this,function(s){return o="".concat(++this.sendIdCounter),[2,new Promise(function(u){var l,c=a.sendTimeoutMs>0?setTimeout(function(){var f=a.pendingWorkerRequests.get(o);f&&(a.pendingWorkerRequests.delete(o),a.rememberTimedOutRequest(o,f.context),a.loggerProvider.warn("Session replay worker send timed out after ".concat(a.sendTimeoutMs,"ms; leaving events for retry")),f.resolve())},a.sendTimeoutMs):void 0;a.pendingWorkerRequests.set(o,{context:r,resolve:u,timeout:c}),e.postMessage({type:"send",id:o,payload:n,useRetry:i,useCustomTransport:!!a.handleSendEvents,context:{apiKey:r.apiKey,deviceId:r.deviceId,sessionId:r.sessionId,events:r.events,eventType:r.type,flushMaxRetries:(l=r.flushMaxRetries)!==null&&l!==void 0?l:0,sampleRate:r.sampleRate,serverZone:r.serverZone,trackServerUrl:a.trackServerUrl,version:r.version,currentUrl:oi(),sdkVersion:qr,enableTransportCompression:a.enableTransportCompression,sendTimeoutMs:a.sendTimeoutMs}})})]})})},t.prototype.rememberTimedOutRequest=function(e,r){var n,i;if(this.timedOutWorkerRequests.set(e,r),this.timedOutWorkerRequests.size>wm)try{for(var o=L(this.timedOutWorkerRequests.keys()),a=o.next();!a.done;a=o.next()){var s=a.value;this.timedOutWorkerRequests.delete(s);break}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},t.prototype.handleDelegatedFetch=function(e,r){var n,i,o;return I(this,void 0,void 0,function(){var a,s,u,l,c,f,d,v,h,g,m;return _(this,function(p){switch(p.label){case 0:a=r.requestId,s=r.url,u=r.method,l=r.headers,c=r.body,f=r.keepalive,p.label=1;case 1:return p.trys.push([1,10,,11]),d=void 0,this.handleSendEvents?[4,this.handleSendEvents({url:s,method:u,headers:l,body:c,keepalive:f})]:[3,3];case 2:return d=p.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:u,headers:l,body:c,keepalive:f})];case 4:d=p.sent(),p.label=5;case 5:if(v=d.status,h=null,g="",v>=200&&v<300&&(h=(o=(i=(n=d.headers)===null||n===void 0?void 0:n.get)===null||i===void 0?void 0:i.call(n,da))!==null&&o!==void 0?o:null),v!==413)return[3,9];p.label=6;case 6:return p.trys.push([6,8,,9]),[4,d.text()];case 7:return g=p.sent(),[3,9];case 8:return p.sent(),[3,9];case 9:return this.loggerProvider.debug("Delegated session replay fetch (request ".concat(a,") returned status ").concat(v,".")),e.postMessage({type:"fetch-response",requestId:a,status:v,skipHeader:h,body:g}),[3,11];case 10:return m=p.sent(),this.loggerProvider.debug("Delegated session replay fetch (request ".concat(a,") failed:"),m),e.postMessage({type:"fetch-response",requestId:a,status:0,skipHeader:null,body:String(m),error:!0}),[3,11];case 11:return[2]}})})},t.prototype.sendOnMainThread=function(e,r,n,i,o){var a,s,u,l,c,f,d;return I(this,void 0,void 0,function(){var v,h,g,m,p,y,b,E,S,T,w,P,A,F,k,x,R,M,U,N,q,q,$,H;return _(this,function(j){switch(j.label){case 0:v=oi(),h=qr,g=n.sampleRate,m=new URLSearchParams({device_id:r,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),p="".concat((s=(a=n.version)===null||a===void 0?void 0:a.type)!==null&&s!==void 0?s:"standalone","/").concat((l=(u=n.version)===null||u===void 0?void 0:u.version)!==null&&l!==void 0?l:h),j.label=1;case 1:return j.trys.push([1,19,,23]),y=JSON.stringify(i),b=ue(),this.enableTransportCompression&&b&&"CompressionStream"in b?[4,_m(y,b)]:[3,3];case 2:return S=j.sent(),[3,4];case 3:S=null,j.label=4;case 4:if(E=S,T=E?E.byteLength:new Blob([y]).size,w=new AbortController,P=C({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":h,"X-Client-Library":p,"X-Client-Url":v.substring(0,jp),"X-Client-Sample-Rate":"".concat(g),"X-Sampling-Hash-Alg":"xxhash32"},E?{"Content-Encoding":"gzip"}:{}),A=E??y,F=T<=zp,k={headers:P,body:A,method:"POST",keepalive:F,signal:w.signal},x="".concat(Kt(n.serverZone,this.trackServerUrl),"?").concat(m.toString()),i.events.length===0)return this.completeRequest({context:n}),[2];R=this.sendTimeoutMs>0?setTimeout(function(){w.abort()},this.sendTimeoutMs):void 0,M=void 0,j.label=5;case 5:return j.trys.push([5,,10,11]),this.handleSendEvents?[4,Cm(this.handleSendEvents({url:x,method:"POST",headers:P,body:A,keepalive:F}),w.signal)]:[3,7];case 6:return U=j.sent(),[3,9];case 7:return[4,fetch(x,k)];case 8:U=j.sent(),j.label=9;case 9:return M=U,[3,11];case 10:return R&&clearTimeout(R),[7];case 11:if(M===null)return this.completeRequest({context:n,err:bm}),[2];if(M.status>=200&&M.status<300&&(N=(d=(f=(c=M.headers)===null||c===void 0?void 0:c.get)===null||f===void 0?void 0:f.call(c,da))!==null&&d!==void 0?d:null,this.applyServerDirective(n.sessionId,N)),o)return[3,12];q="";try{q=JSON.stringify(M.body,null,2)}catch{}return this.completeRequest({context:n,success:"".concat(M.status,": ").concat(q)}),[3,18];
13case 12:if(q="",M.status!==413)return[3,16];j.label=13;case 13:return j.trys.push([13,15,,16]),[4,M.text()];case 14:return q=j.sent(),[3,16];case 15:return j.sent(),[3,16];case 16:return[4,this.handleReponse(M.status,n,q)];case 17:j.sent(),j.label=18;case 18:return[3,23];case 19:return $=j.sent(),H=!!$&&typeof $=="object"&&$.name==="AbortError",H&&o?[4,this.handleOtherResponse(n)]:[3,21];case 20:return j.sent(),[3,22];case 21:this.completeRequest({context:n,err:$}),j.label=22;case 22:return[3,23];case 23:return[2]}})})},t.prototype.handleReponse=function(e,r,n){return n===void 0&&(n=""),I(this,void 0,void 0,function(){var i,o;return _(this,function(a){switch(a.label){case 0:switch(i=new Du().buildStatus(e),o=i,o){case ve.Success:return[3,1];case ve.Failed:return[3,2];case ve.Timeout:return[3,2];case ve.RateLimit:return[3,2];case ve.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(r),[3,8];case 2:return[4,this.handleOtherResponse(r)];case 3:return a.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(r,qp.test(n)),[3,8];case 5:return e!==499?[3,7]:[4,this.handleOtherResponse(r)];case 6:return a.sent(),[3,8];case 7:this.completeRequest({context:r,err:Em}),a.label=8;case 8:return[2]}})})},t.prototype.handlePayloadTooLargeResponse=function(e,r){var n=r?"WAF (compressed payload too large)":"server (event too large)",i=Math.round(e.events.reduce(function(s,u){return s+u.length},0)/ni);if(!r){this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(i," KB) — not retrying non-WAF 413")});return}if(e.events.length===1){this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(i," KB, 1 event) rejected by ").concat(n," — cannot split further")});return}this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(i," KB total) — splitting and retrying")),e.onComplete();var o=function(){return Promise.resolve()},a=Math.floor(e.events.length/2);this.sendEventsList(C(C({},e),{events:e.events.slice(0,a),onComplete:o})),this.sendEventsList(C(C({},e),{events:e.events.slice(a),onComplete:o}))},t.prototype.handleSuccessResponse=function(e){var r=Math.round(new Blob(e.events).size/ni);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(r," KB")})},t.prototype.handleOtherResponse=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return r=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:ya}),[2]):[4,new Promise(function(i){return setTimeout(i,r)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},t.prototype.completeRequest=function(e){var r=e.context,n=e.err,i=e.success;r.onComplete(),n?this.loggerProvider.warn(n):i&&this.loggerProvider.log(i)},t.prototype.applyServerDirective=function(e,r){if(r===null){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if(r===Kp){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+fa,n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(fa/1e3,"s"));return}(r===Yp||r===Xp)&&this.killSession(e,r)},t.prototype.killSession=function(e,r){var n,i,o,a;if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>Im)try{for(var s=L(this.killedSessions),u=s.next();!u.done;u=s.next()){var l=u.value;this.killedSessions.delete(l);break}}catch(h){n={error:h}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(r,"; remaining events will be dropped"));var c=[];try{for(var f=L(this.queue),d=f.next();!d.done;d=f.next()){var v=d.value;v.sessionId===e?this.completeRequest({context:v,err:Pn}):c.push(v)}}catch(h){o={error:h}}finally{try{d&&!d.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}this.queue=c}},t})();const ai=(t,e)=>e.some(r=>t instanceof r);let ba,Ea;function Am(){return ba||(ba=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function km(){return Ea||(Ea=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const si=new WeakMap,An=new WeakMap,Xr=new WeakMap;function Rm(t){const e=new Promise((r,n)=>{const i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",a)},o=()=>{r(ut(t.result)),i()},a=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",a)});return Xr.set(e,t),e}
vendor: 1,757 bytes, line 13
13function Om(t){if(si.has(t))return;const e=new Promise((r,n)=>{const i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",a),t.removeEventListener("abort",a)},o=()=>{r(),i()},a=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",a),t.addEventListener("abort",a)});si.set(t,e)}let ui={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return si.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ut(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Yu(t){ui=t(ui)}function Lm(t){return km().includes(t)?function(...e){return t.apply(li(this),e),ut(this.request)}:function(...e){return ut(t.apply(li(this),e))}}function Dm(t){return typeof t=="function"?Lm(t):(t instanceof IDBTransaction&&Om(t),ai(t,Am())?new Proxy(t,ui):t)}function ut(t){if(t instanceof IDBRequest)return Rm(t);if(An.has(t))return An.get(t);const e=Dm(t);return e!==t&&(An.set(t,e),Xr.set(e,t)),e}const li=t=>Xr.get(t);function Qu(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){const a=indexedDB.open(t,e),s=ut(a);return n&&a.addEventListener("upgradeneeded",u=>{n(ut(a.result),u.oldVersion,u.newVersion,ut(a.transaction),u)}),r&&a.addEventListener("blocked",u=>r(u.oldVersion,u.newVersion,u)),s.then(u=>{o&&u.addEventListener("close",()=>o()),i&&u.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),s}const xm=["get","getKey","getAll","getAllKeys","count"],Mm=["put","add","delete","clear"],kn=new Map;function Sa(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(kn.get(e))return kn.get(e);
13const r=e.replace(/FromIndex$/,""),n=e!==r,i=Mm.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||xm.includes(r)))return;const o=async function(a,...s){const u=this.transaction(a,i?"readwrite":"readonly");let l=u.store;return n&&(l=l.index(s.shift())),(await Promise.all([l[r](...s),i&&u.done]))[0]};return kn.set(e,o),o}Yu(t=>({...t,get:(e,r,n)=>Sa(e,r)||t.get(e,r,n),has:(e,r)=>!!Sa(e,r)||t.has(e,r)}));const Nm=["continue","continuePrimaryKey","advance"],Ta={},ci=new WeakMap,Ju=new WeakMap,Um={get(t,e){if(!Nm.includes(e))return t[e];let r=Ta[e];return r||(r=Ta[e]=function(...n){ci.set(this,Ju.get(this)[e](...n))}),r}};async function*Fm(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const r=new Proxy(e,Um);for(Ju.set(r,e),Xr.set(r,li(e));e;)yield r,e=await(ci.get(r)||e.continue()),ci.delete(r)}function _a(t,e){return e===Symbol.asyncIterator&&ai(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&ai(t,[IDBIndex,IDBObjectStore])}Yu(t=>({...t,get(e,r,n){return _a(e,r)?Fm:t.get(e,r,n)},has(e,r){return _a(e,r)||t.has(e,r)}}));var Zu=(function(){function t(e){var r=this,n,i,o;this.minInterval=ti,this.maxInterval=ri,this.maxPersistedEventsSize=Bp,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(a,s){var u=r.getStringSize(s),l=r.getEventsArraySize(a);return l+u>=r.maxPersistedEventsSize?!0:Date.now()-r.timeAtLastSplit>r.interval&&a.length?(r.interval=Math.min(r.maxInterval,r.interval+r.minInterval),r._timeAtLastSplit=Date.now(),!0):!1},this.loggerProvider=e.loggerProvider,this.minInterval=(n=e.minInterval)!==null&&n!==void 0?n:this.minInterval,this.maxInterval=(i=e.maxInterval)!==null&&i!==void 0?i:this.maxInterval,this.maxPersistedEventsSize=(o=e.maxPersistedEventsSize)!==null&&o!==void 0?o:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(t.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),t.prototype.getStringSize=function(e){for(var r=0,n=0;n<e.length;n++){var i=e.charCodeAt(n);if(i<=127)r++;else if(i<=2047)r+=2;else if(i>=55296&&i<=56319){var o=n+1<e.length?e.charCodeAt(n+1):NaN;o>=56320&&o<=57343?(r+=4,n++):r+=3}else i>=56320&&i<=57343,r+=3}return r},t.prototype.getEventsArraySize=function(e){var r,n,i=0;try{for(var o=L(e),a=o.next();!a.done;a=o.next()){var s=a.value;i+=this.getStringSize(s)}}catch(l){r={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}var u=2+Math.max(0,e.length-1)+e.length*2;return i+u},t})(),Bm=function(t){return typeof t=="object"&&t!==null&&t.name==="AbortError"},me=function(t,e,r){Bm(r)?t.debug(e):t.warn(e)};function qm(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}}var we="sessionCurrentSequence",He="sequencesToSend",Vm=2e3,Rn=5e3;function Wm(t,e,r){return new Promise(function(n,i){var o=setTimeout(function(){return i(new Error("".concat(r," after ").concat(e,"ms")))},e);t.then(function(a){clearTimeout(o),n(a)},function(a){clearTimeout(o),i(a)})})}function On(t,e,r){var n=setTimeout(r,e);return t.then(function(){return clearTimeout(n)},function(){return clearTimeout(n)}),function(){return clearTimeout(n)}}var Hm=function(t){var e,r;return t.objectStoreNames.contains(we)||(r=t.createObjectStore(we,{keyPath:"sessionId"})),t.objectStoreNames.contains(He)||(e=t.createObjectStore(He,{keyPath:"sequenceId",autoIncrement:!0}),e.createIndex("sessionId","sessionId")),{sequencesStore:e,currentSequenceStore:r}},Gm=function(t){return I(void 0,void 0,void 0,function(){return _(this,function(e){switch(e.label){case 0:return[4,Wm(Qu(t,1,{upgrade:Hm}),Vm,"IDB openDB timed out")];case 1:return[2,e.sent()]}})})},jm=(function(t){Le(e,t);function e(r){var n=this,i;return n=t.call(this,r)||this,n.consecutiveFailures=0,n.hasTriggeredFallback=!1,n.emptyFilteredCount=0,n.getSequencesToSend=function(){return I(n,void 0,void 0,function(){var o,a,s,u,l,c,f,d,v,h,g=this;return _(this,function(m){switch(m.label){case 0:o=!1,a=!1,m.label=1;case 1:return m.trys.push([1,9,,10]),s=[],u=this.db.transaction("sequencesToSend","readwrite"),u.done.catch(function(p){!o&&!a&&(me(g.loggerProvider,"".concat(Ie,": ").concat(p),p),g.recordFailure())}),l=On(u.done,Rn,function(){!o&&!a&&(a=!0,me(g.loggerProvider,"".concat(Ie,": transaction timed out")),g.recordFailure())}),[4,u.store.openCursor()];case 2:c=m.sent(),m.label=3;case 3:return c?(f=c.value,d=f.sessionId,v=f.events,v.length!==0?[3,5]:(this.maybeLogEmptyFiltered("getSequencesToSend"),[4,c.delete()])):[3,8];case 4:return m.sent(),[3,6];case 5:s.push({events:v,sequenceId:c.key,sessionId:d}),m.label=6;case 6:return[4,c.continue()];case 7:return c=m.sent(),[3,3];case 8:return this.recordSuccess(),l(),[2,s];case 9:return h=m.sent(),a||(o=!0,me(this.loggerProvider,"".concat(Ie,": ").concat(h),h),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},n.storeCurrentSequence=function(o){return I(n,void 0,void 0,function(){var a,s,u,l,c,f,d,v,h=this;return _(this,function(g){switch(g.label){case 0:a=!1,s=!1,g.label=1;case 1:return g.trys.push([1,5,,6]),u=this.db.transaction([we,He],"readwrite"),u.done.catch(function(m){!a&&!s&&(me(h.loggerProvider,"".concat(Ie,": ").concat(m),m),h.recordFailure())}),l=On(u.done,Rn,function(){!a&&!s&&(s=!0,me(h.loggerProvider,"".concat(Ie,": transaction timed out")),h.recordFailure())}),[4,u.objectStore(we).get(o)];case 2:return c=g.sent(),!c||c.tabId&&c.tabId!==this.tabId?(l(),[2,void 0]):c.events.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),l(),[2,void 0]):[4,u.objectStore(He).put({sessionId:o,events:c.events,tabId:this.tabId})];case 3:return f=g.sent(),[4,u.objectStore(we).put({sessionId:o,events:[],tabId:this.tabId})];case 4:return g.sent(),this.recordSuccess(),l(),c.tabId,d=at(c,["tabId"]),[2,C(C({},d),{sessionId:o,sequenceId:f})];case 5:return v=g.sent(),s||(a=!0,me(this.loggerProvider,"".concat(Ie,": ").concat(v),v),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},n.addEventToCurrentSequence=function(o,a){return I(n,void 0,void 0,function(){var s,u,l,c,f,d,v,h,g,m=this;return _(this,function(p){switch(p.label){case 0:s=!1,u=!1,p.label=1;case 1:return p.trys.push([1,15,,16]),l=this.db.transaction([we,He],"readwrite"),l.done.catch(function(y){!s&&!u&&(me(m.loggerProvider,"".concat(Ie,": ").concat(y),y),m.recordFailure())}),c=On(l.done,Rn,function(){!s&&!u&&(u=!0,me(m.loggerProvider,"".concat(Ie,": transaction timed out")),m.recordFailure())}),[4,l.objectStore(we).get(o)];case 2:return f=p.sent(),f?.tabId&&f.tabId!==this.tabId?f.events.length>0?[4,l.objectStore(He).put({sessionId:o,events:f.events,tabId:f.tabId})]:[3,4]:[3,6];case 3:p.sent(),p.label=4;case 4:return[4,l.objectStore(we).put({sessionId:o,events:[a],tabId:this.tabId})];case 5:return p.sent(),this.recordSuccess(),c(),[2,void 0];case 6:return d=f,d?[3,8]:[4,l.objectStore(we).put({sessionId:o,events:[a],tabId:this.tabId})];case 7:return p.sent(),this.recordSuccess(),c(),[2,void 0];case 8:return this.shouldSplitEventsList(d.events,a)?[3,10]:[4,l.objectStore(we).put({sessionId:o,events:d.events.concat(a),tabId:this.tabId})];case 9:return p.sent(),this.recordSuccess(),c(),[2,void 0];case 10:return v=d.events,v.length!==0?[3,12]:(this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,l.objectStore(we).put({sessionId:o,events:[a],tabId:this.tabId})]);case 11:return p.sent(),this.recordSuccess(),c(),[2,void 0];case 12:return[4,l.objectStore(we).put({sessionId:o,events:[a],tabId:this.tabId})];case 13:return p.sent(),[4,l.objectStore(He).put({sessionId:o,events:v,tabId:this.tabId})];case 14:return h=p.sent(),this.recordSuccess(),c(),[2,{events:v,sessionId:o,sequenceId:h}];case 15:return g=p.sent(),u||(s=!0,me(this.loggerProvider,"".concat(Ie,": ").concat(g),g),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},n.storeSendingEvents=function(o,a){return I(n,void 0,void 0,function(){var s,u;return _(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),[4,this.db.put(He,{sessionId:o,events:a,tabId:this.tabId})];case 1:return s=l.sent(),this.recordSuccess(),[2,s];case 2:return u=l.sent(),me(this.loggerProvider,"".concat(Ie,": ").concat(u),u),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(o,a){return I(n,void 0,void 0,function(){var s;return _(this,function(u){switch(u.label){case 0:if(!a)return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.db.delete(He,a)];case 2:return u.sent(),this.recordSuccess(),[3,4];case 3:return s=u.sent(),me(this.loggerProvider,"".concat(Ie,": ").concat(s),s),this.recordFailure(),[3,4];case 4:return[2]}})})},n.db=r.db,n.tabId=r.tabId,n.onPersistentFailure=r.onPersistentFailure,n.consecutiveFailureThreshold=(i=r.consecutiveFailureThreshold)!==null&&i!==void 0?i:1,n}return e.prototype.maybeLogEmptyFiltered=function(r){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(r," (idb store)"))},e.prototype.recordFailure=function(){var r;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,(r=this.onPersistentFailure)===null||r===void 0||r.call(this))},e.prototype.recordSuccess=function(){this.consecutiveFailures=0},e.new=function(r,n){var i;return I(this,void 0,void 0,function(){var o,a,s,u,l;return _(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),o=r==="replay"?"":"_".concat(r),a="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(o),[4,Gm(a)];case 1:return s=c.sent(),u=(i=n.tabId)!==null&&i!==void 0?i:qm(),[2,new e(C(C({},n),{db:s,tabId:u}))];case 2:return l=c.sent(),me(n.loggerProvider,"".concat(Ie,": ").concat(l),l),[3,3];case 3:return[2]}})})},e.prototype.getCurrentSequenceEvents=function(r){return I(this,void 0,void 0,function(){var a,s,n,i,o,a,s,u,l,c;return _(this,function(f){switch(f.label){case 0:return r?[4,this.db.get("sessionCurrentSequence",r)]:[3,2];case 1:return a=f.sent(),a?a.tabId&&a.tabId!==this.tabId?[2,void 0]:(a.tabId,s=at(a,["tabId"]),[2,[s]]):[2,void 0];case 2:n=[],f.label=3;case 3:return f.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:i=L.apply(void 0,[f.sent()]),o=i.next(),f.label=5;case 5:if(o.done)return[3,7];if(a=o.value,a.tabId&&a.tabId!==this.tabId)return[3,6];a.tabId,s=at(a,["tabId"]),n.push(s),f.label=6;case 6:return o=i.next(),[3,5];case 7:return[3,10];case 8:return u=f.sent(),l={error:u},[3,10];case 9:try{o&&!o.done&&(c=i.return)&&c.call(i)}finally{if(l)throw l.error}
13return[7];case 10:return[2,n]}})})},e})(Zu),zm=(function(t){Le(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.finalizedSequences={},r.sequences={},r.sequenceId=0,r.emptyFilteredCount=0,r}return e.prototype.resetCurrentSequence=function(r){this.sequences[r]=[]},e.prototype.addSequence=function(r){var n=this.sequenceId++,i=W([],D(this.sequences[r]),!1);return this.finalizedSequences[n]={sessionId:r,events:i},this.resetCurrentSequence(r),{sequenceId:n,events:i,sessionId:r}},e.prototype.maybeLogEmptyFiltered=function(r){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(r," (in-memory store)"))},e.prototype.getSequencesToSend=function(){return I(this,void 0,void 0,function(){var r,n,i,o,a,s,u,l,c,f;return _(this,function(d){r=[];try{for(n=L(Object.entries(this.finalizedSequences)),i=n.next();!i.done;i=n.next()){if(o=D(i.value,2),a=o[0],s=o[1],u=s.sessionId,l=s.events,l.length===0){this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(a)];continue}r.push({sequenceId:Number(a),sessionId:u,events:l})}}catch(v){c={error:v}}finally{try{i&&!i.done&&(f=n.return)&&f.call(n)}finally{if(c)throw c.error}}return[2,r]})})},e.prototype.storeCurrentSequence=function(r){return I(this,void 0,void 0,function(){var n;return _(this,function(i){return n=this.sequences[r],n?n.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(r)]:[2,void 0]})})},e.prototype.addEventToCurrentSequence=function(r,n){return I(this,void 0,void 0,function(){var i;return _(this,function(o){return this.sequences[r]||this.resetCurrentSequence(r),this.shouldSplitEventsList(this.sequences[r],n)&&(this.sequences[r].length===0?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):i=this.addSequence(r)),this.sequences[r].push(n),[2,i]})})},e.prototype.storeSendingEvents=function(r,n){return I(this,void 0,void 0,function(){return _(this,function(i){return this.finalizedSequences[this.sequenceId]={sessionId:r,events:n},[2,this.sequenceId++]})})},e.prototype.cleanUpSessionEventsStore=function(r,n){return I(this,void 0,void 0,function(){return _(this,function(i){return n!==void 0&&delete this.finalizedSequences[n],[2]})})},e})(Zu),Ia=function(t){var e=t.config,r=t.minInterval,n=t.maxInterval,i=t.maxPersistedEventsSize,o=t.type,a=t.payloadBatcher,s=t.storeType,u=t.trackDestinationWorkerScript,l=t.shouldSend;return I(void 0,void 0,void 0,function(){function c(M){return M===void 0&&(M=!1),I(this,void 0,void 0,function(){return _(this,function(U){return[2,d.flush(M)]})})}var f,d,v,h,g,m,p,y,b,E,S,T,w,P,A,F,k,x,R;return _(this,function(M){switch(M.label){case 0:return f=(R=e.maxSingleEventSizeBytes)!==null&&R!==void 0?R:Vu,d=new Pm(C(C({},e),{loggerProvider:e.loggerProvider,payloadBatcher:a,workerScript:u})),v=function(){return new zm({loggerProvider:e.loggerProvider,maxInterval:n,minInterval:r,maxPersistedEventsSize:i})},g=!1,p=function(){return I(void 0,void 0,void 0,function(){var U,N,q;return _(this,function($){switch($.label){case 0:return g?(g=!1,e.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),h?[4,m.getSequencesToSend()]:[3,2]):[2];case 1:return N=$.sent(),[3,3];case 2:N=void 0,$.label=3;case 3:return U=N,m=v(),U&&h&&(q=h,U.forEach(function(H){w({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:q})})),[2]}})})},y=function(){return I(void 0,void 0,void 0,function(){var U;return _(this,function(N){switch(N.label){case 0:return[4,jm.new(o,{loggerProvider:e.loggerProvider,minInterval:r,maxInterval:n,maxPersistedEventsSize:i,apiKey:e.apiKey,onPersistentFailure:function(){p()}})];case 1:return U=N.sent(),U?(g=!0,[2,U]):(e.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,v()])}})})},s!=="idb"?[3,2]:[4,y()];case 1:return b=M.sent(),[3,3];case 2:b=v(),M.label=3;case 3:return m=b,E=[],S=0,T=function(U){if(!(U<=S)){var N=Math.min(U-S,E.length);N>0&&(E.splice(0,N),S=U)}},w=function(U){var N=U.events,q=U.sessionId,$=U.deviceId,H=U.sequenceId,j=N.map(function(V){return{event:V,bytes:new Blob([V]).size}}
13),O=j.filter(function(V){return V.bytes>f});O.length>0&&e.loggerProvider.warn("Dropping ".concat(O.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(O.map(function(V){return"".concat(Math.round(V.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 G=O.length>0?j.filter(function(V){return V.bytes<=f}).map(function(V){return V.event}):N;if(G.length===0){m.cleanUpSessionEventsStore(q,H).catch(function(V){e.loggerProvider.warn("Failed to clean up session replay events store:",V)});return}e.debugMode&&zu().then(function(V){var X=V.totalStorageSize,Y=V.percentOfQuota,J=V.usageDetails;e.loggerProvider.debug("Total storage size: ".concat(X," KB, percentage of quota: ").concat(Y,"%, usage details: ").concat(J))}).catch(function(){}),d.sendEventsList({events:G,sessionId:q,flushMaxRetries:e.flushMaxRetries,apiKey:e.apiKey,deviceId:$,sampleRate:e.sampleRate,serverZone:e.serverZone,version:e.version,type:o,onComplete:function(){return I(void 0,void 0,void 0,function(){return _(this,function(V){switch(V.label){case 0:return[4,m.cleanUpSessionEventsStore(q,H)];case 1:return V.sent(),[2]}})})}})},P=function(U){var N=U.sessionId,q=U.deviceId;if(h=q,!(l&&!l())){var $=S+E.length;m.storeCurrentSequence(N).then(function(H){H&&(T($),w({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:q}))}).catch(function(H){e.loggerProvider.warn("Failed to get current sequence of session replay events for session:",H)})}},A=function(U){var N=U.deviceId;return I(void 0,void 0,void 0,function(){var q;return _(this,function($){switch($.label){case 0:return h=N,[4,m.getSequencesToSend()];case 1:return q=$.sent(),q?.length?(e.loggerProvider.log("Draining ".concat(q.length," stored sequence(s) from previous session.")),q.length>1&&d.markCoalesceNextFlush(),q.forEach(function(H){w({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:N})}),[2]):[2]}})})},F=function(U){var N=U.event,q=U.sessionId,$=U.deviceId;h=$;var H=!l||l(),j=S+E.length;E.push(N.data),m.addEventToCurrentSequence(q,N.data).then(function(O){if(O){if(!H){m.cleanUpSessionEventsStore(O.sessionId,O.sequenceId).catch(function(G){e.loggerProvider.warn("Failed to clean up dropped session replay sequence:",G)}),T(j);return}T(j),w({sequenceId:O.sequenceId,events:O.events,sessionId:O.sessionId,deviceId:$})}}).catch(function(O){e.loggerProvider.warn("Failed to add event to session replay capture:",O)})},k=function(){return W([],D(E),!1)},x=function(){T(S+E.length)},[2,{sendCurrentSequenceEvents:P,addEvent:F,sendStoredEvents:A,flush:c,getBeaconEvents:k,dropPendingBeaconEvents:x,trackDestination:d}]}})})},wa=(function(){function t(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=new Map;e.forEach(function(i){n.set(i.name,i.manager)}),this.managers=n}return t.prototype.sendStoredEvents=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return r=[],this.managers.forEach(function(i){r.push(i.sendStoredEvents(e))}),[4,Promise.all(r)];case 1:return n.sent(),[2]}})})},t.prototype.addEvent=function(e){var r,n=e.sessionId,i=e.event,o=e.deviceId;(r=this.managers.get(i.type))===null||r===void 0||r.addEvent({sessionId:n,event:i,deviceId:o})},t.prototype.sendCurrentSequenceEvents=function(e){var r=e.sessionId,n=e.deviceId;this.managers.forEach(function(i){i.sendCurrentSequenceEvents({sessionId:r,deviceId:n})})},t.prototype.flush=function(e){return I(this,void 0,void 0,function(){var r;return _(this,function(n){switch(n.label){case 0:return r=[],this.managers.forEach(function(i){r.push(i.flush(e))}),[4,Promise.all(r)];case 1:return n.sent(),[2]}})})},t})(),Re,Ui,el;function $m(t,e){if(el=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";var r={root:document.body,idName:function(o){return!0},className:function(o){return!0},tagName:function(o){return!0},attr:function(o,a){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};Re=C(C({},r),e),Ui=Km(Re.root,r);var n=pr(t,"all",function(){return pr(t,"two",function(){return pr(t,"one",function(){return pr(t,"none")})})});if(n){var i=nl(il(n,t));return i.length>0&&(n=i[0]),Yr(n)}else throw new Error("Selector was not found.")}function Km(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function pr(t,e,r){for(var n=null,i=[],o=t,a=0,s=function(){var l,c,f=new Date().getTime()-el.getTime();if(Re.timeoutMs!==void 0&&f>Re.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(f,"ms"));var d=yr(Xm(o))||yr.apply(void 0,W([],D(Ym(o)),!1))||yr.apply(void 0,W([],D(Qm(o)),!1))||yr(Jm(o))||[Aa()],v=Zm(o);if(e=="all")v&&(d=d.concat(d.filter(Ln).map(function(y){return mr(y,v)})));else if(e=="two")d=d.slice(0,1),v&&(d=d.concat(d.filter(Ln).map(function(y){return mr(y,v)})));else if(e=="one"){var h=D(d=d.slice(0,1),1),g=h[0];v&&Ln(g)&&(d=[mr(g,v)])}else e=="none"&&(d=[Aa()],v&&(d=[mr(d[0],v)]));try{for(var m=(l=void 0,L(d)),p=m.next();!p.done;p=m.next()){var g=p.value;g.level=a}}catch(y){l={error:y}}finally{try{p&&!p.done&&(c=m.return)&&c.call(m)}finally{if(l)throw l.error}}if(i.push(d),i.length>=Re.seedMinLength&&(n=Ca(i,r),n))return"break";o=o.parentElement,a++};o;){var u=s();if(u==="break")break}return n||(n=Ca(i,r)),!n&&r?r():n}function Ca(t,e){var r,n,i=nl(rl(t));if(i.length>Re.threshold)return e?e():null;try{for(var o=L(i),a=o.next();!a.done;a=o.next()){var s=a.value;if(tl(s))return s}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return null}function Yr(t){for(var e=t[0],r=e.name,n=1;n<t.length;n++){var i=t[n].level||0;e.level===i-1?r="".concat(t[n].name," > ").concat(r):r="".concat(t[n].name," ").concat(r),e=t[n]}return r}function Pa(t){return t.map(function(e){return e.penalty}).reduce(function(e,r){return e+r},0)}function tl(t){var e=Yr(t);switch(Ui.querySelectorAll(e).length){case 0:throw new Error("Can't select any node with this selector: ".concat(e));case 1:return!0;default:return!1}}function Xm(t){var e=t.getAttribute("id");return e&&Re.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Ym(t){var e=Array.from(t.attributes).filter(function(r){return Re.attr(r.name,r.value)});return e.map(function(r){return{name:"[".concat(CSS.escape(r.name),'="').concat(CSS.escape(r.value),'"]'),penalty:.5}})}function Qm(t){var e=Array.from(t.classList).filter(Re.className);return e.map(function(r){return{name:"."+CSS.escape(r),penalty:1}})}function Jm(t){var e=t.tagName.toLowerCase();return Re.tagName(e)?{name:e,penalty:2}:null}function Aa(){return{name:"*",penalty:3}}function Zm(t){var e=t.parentNode;if(!e)return null;var r=e.firstChild;if(!r)return null;for(var n=0;r&&(r.nodeType===Node.ELEMENT_NODE&&n++,r!==t);)r=r.nextSibling;return n}function mr(t,e){return{name:t.name+":nth-child(".concat(e,")"),penalty:t.penalty+1}}function Ln(t){return t.name!=="html"&&!t.name.startsWith("#")}function yr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.filter(e0);return r.length>0?r:null}function e0(t){return t!=null}function rl(t,e){var r,n,i,o,a,s;return e===void 0&&(e=[]),_(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]),r=L(t[0]),n=r.next(),u.label=2;case 2:return n.done?[3,5]:(i=n.value,[5,L(rl(t.slice(1,t.length),e.concat(i)))]);case 3:u.sent(),u.label=4;case 4:return n=r.next(),[3,2];case 5:return[3,8];case 6:return o=u.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(a)throw a.error}
13return[7];case 8:return[3,11];case 9:return[4,e];case 10:u.sent(),u.label=11;case 11:return[2]}})}function nl(t){return W([],D(t),!1).sort(function(e,r){return Pa(e)-Pa(r)})}function il(t,e,r){var n,i,o;return r===void 0&&(r={counter:0,visited:new Map}),_(this,function(a){switch(a.label){case 0:if(!(t.length>2&&t.length>Re.optimizedMinLength))return[3,5];n=1,a.label=1;case 1:return n<t.length-1?r.counter>Re.maxNumberOfTries?[2]:(r.counter+=1,i=W([],D(t),!1),i.splice(n,1),o=Yr(i),r.visited.has(o)?[2]:tl(i)&&t0(i,e)?[4,i]:[3,4]):[3,5];case 2:return a.sent(),r.visited.set(o,!0),[5,L(il(i,e,r))];case 3:a.sent(),a.label=4;case 4:return n++,[3,1];case 5:return[2]}})}function t0(t,e){return Ui.querySelector(Yr(t))===e}var r0=36e5,n0=function(t){var e=t.version,r=t.events,n=[];return r.forEach(function(i){var o=JSON.parse(i);o.count=1,o.type==="click"&&n.push(o)}),{version:e,events:n}},i0=function(t){var e=t.version,r=t.events,n=[];r.forEach(function(o){var a=JSON.parse(o);a.type==="click"&&n.push(a)});var i=n.reduce(function(o,a){var s=a.x,u=a.y,l=a.selector,c=a.timestamp,f=c-c%r0,d="".concat(s,":").concat(u,":").concat(l??"",":").concat(f);return o[d]?o[d].count+=1:o[d]=C(C({},a),{timestamp:f,count:1}),o},{});return{version:e,events:Object.values(i)}},o0=(function(){function t(e,r){var n=this;this.createHook=function(i){var o=i.eventsManager,a=i.sessionId,s=i.deviceIdFn,u=i.mirror,l=i.ugcFilterRules,c=i.performanceOptions;return function(f){if(f.type===Xu.Click){var d=ue();if(d){var v=d.location,h=d.innerHeight,g=d.innerWidth;if(v){var m=f.x,p=f.y;if(!(m===void 0||p===void 0)){var y=u.getNode(f.id),b;if(y)try{b=$m(y,c)}catch{n.logger.debug("error resolving selector from finder")}var E=$r(v.href,l),S={x:m+n.scrollWatcher.currentScrollX,y:p+n.scrollWatcher.currentScrollY,selector:b,viewportHeight:h,viewportWidth:g,pageUrl:E,timestamp:Date.now(),type:"click"},T=s();T&&o.addEvent({sessionId:a,event:{type:"interaction",data:JSON.stringify(S)},deviceId:T})}}}}}},this.logger=e,this.scrollWatcher=r}return t})();function Dn(){var t=ue();return t?.innerHeight||document.documentElement&&document.documentElement.clientHeight||0}function xn(){var t=ue();return t?.innerWidth||document.documentElement&&document.documentElement.clientWidth||0}var a0=(function(){function t(e,r){var n=ue();n&&n.navigator&&typeof n.navigator.sendBeacon=="function"?this.sendBeacon=function(i,o){try{if(n.navigator.sendBeacon(i,JSON.stringify(o)))return!0}catch{}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(i,o){var a=new XMLHttpRequest;return a.open("POST",i,!0),a.setRequestHeader("Accept","*/*"),a.send(JSON.stringify(o)),!0},this.basePageUrl=Kt(r.serverZone,r.trackServerUrl),this.apiKey=r.apiKey,this.context=e,this.handleSendEvents=r.handleSendEvents,this.loggerProvider=r.loggerProvider}return t.prototype.send=function(e,r){var n=this,i,o=this.context,a=o.sessionId,s=o.type;if(this.handleSendEvents){var u=new URLSearchParams({device_id:e,session_id:String(a),type:String(s)}),l="".concat(this.basePageUrl,"?").concat(u.toString()),c={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(this.apiKey)};try{this.handleSendEvents({url:l,method:"POST",headers:c,body:JSON.stringify(r),keepalive:!0}).catch(function(v){var h;(h=n.loggerProvider)===null||h===void 0||h.warn("Custom transport failed to send session replay interaction beacon:",v)})}catch(v){(i=this.loggerProvider)===null||i===void 0||i.warn("Custom transport threw while sending session replay interaction beacon:",v)}return}var f=new URLSearchParams({device_id:e,session_id:String(a),type:String(s),api_key:this.apiKey}),d="".concat(this.basePageUrl,"?").concat(f.toString());this.sendBeacon(d,r)||this.sendXhr(d,r)},t})(),s0=(function(){function t(e,r){var n=this;this.timestamp=Date.now(),this.hook=function(i){n.update(i)},this.send=function(i){return function(o){var a,s,u,l,c=i(),f=ue();if(f&&c){var d=(a=f.scrollX)!==null&&a!==void 0?a:0,v=(s=f.scrollY)!==null&&s!==void 0?s:0;(d>0||v>0)&&n.update({id:1,x:d,y:v}),n.transport.send(c,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHe
13ight:Dn(),viewportWidth:xn(),pageUrl:$r(f.location.href,(l=(u=n.config.interactionConfig)===null||u===void 0?void 0:u.ugcFilterRules)!==null&&l!==void 0?l:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=xn(),this._maxScrollHeight=Dn(),this.config=r,this.transport=e}return t.default=function(e,r){return new t(new a0(e,r),r)},Object.defineProperty(t.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),t.prototype.update=function(e){var r=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=xn();this._maxScrollX=e.x;var i=e.x+n;i>this._maxScrollWidth&&(this._maxScrollWidth=i),this.timestamp=r}if(e.y>this._maxScrollY){var o=Dn();this._maxScrollY=e.y;var a=e.y+o;a>this._maxScrollHeight&&(this._maxScrollHeight=a),this.timestamp=r}},t})(),ka=(function(){function t(e){var r=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=r,r&&n&&(this.sessionReplayId=tm(r,n))}return t})(),u0="AMP_SR_START_",l0=10,ol=1440*60*1e3,al=function(t){return"".concat(u0).concat(t.substring(0,l0),"_")},Fi=function(t,e){return"".concat(al(t)).concat(e)},Qr=function(){try{var t=ue();return t?.localStorage}catch{return}},c0=function(t,e,r,n){var i=Qr();if(i){var o=Fi(t,e);try{var a=i.getItem(o);if(a!==null){var s=Number(a);if(Number.isFinite(s)&&s>0&&s<=r&&r-s<ol)return s}return i.setItem(o,String(r)),r}catch(u){n?.debug("Failed to read/write replay start time from storage: ".concat(String(u)));return}}},d0=function(t,e,r,n){var i=Qr();if(i)try{i.setItem(Fi(t,e),String(r))}catch(o){n?.debug("Failed to write replay start time to storage: ".concat(String(o)))}},f0=function(t,e,r){var n=Qr();if(n)try{n.removeItem(Fi(t,e))}catch(i){r?.debug("Failed to remove replay start time from storage: ".concat(String(i)))}},v0=function(t,e,r){var n,i,o=Qr();if(o){var a=al(t);try{for(var s=[],u=0;u<o.length;u++){var l=o.key(u);if(!(!l||!l.startsWith(a))){var c=o.getItem(l);if(c!==null){var f=Number(c);(!Number.isFinite(f)||f<=0||e-f>=ol)&&s.push(l)}}}try{for(var d=L(s),v=d.next();!v.done;v=d.next()){var l=v.value;o.removeItem(l)}}catch(h){n={error:h}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}catch(h){r?.debug("Failed to prune stale replay start times: ".concat(String(h)))}}},h0=1e3*60*60*24*2,g0=(function(){function t(){var e=this;this.dbs={},this.createStore=function(r){return I(e,void 0,void 0,function(){return _(this,function(n){switch(n.label){case 0:return[4,Qu(r,1,{upgrade:function(i){i.objectStoreNames.contains("sessionTargetingMatch")||i.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,n.sent()]}})})},this.openOrCreateDB=function(r){return I(e,void 0,void 0,function(){var n,i;return _(this,function(o){switch(o.label){case 0:return this.dbs&&this.dbs[r]?[2,this.dbs[r]]:(n="".concat(r.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(n)]);case 1:return i=o.sent(),this.dbs[r]=i,[2,i]}})})},this.getTargetingMatchForSession=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.sessionId;return I(e,void 0,void 0,function(){var a,s,u,l;return _(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return a=c.sent(),s=String(o),[4,a.get("sessionTargetingMatch",s)];case 2:return u=c.sent(),[2,u?.targetingMatch];case 3:return l=c.sent(),me(n,"Failed to get targeting match for session id ".concat(o,": ").concat(l),l),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.sessionId,a=r.targetingMatch;return I(e,void 0,void 0,function(){var s,u,l,c;return _(this,function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return s=f.sent(),u=String(o),[4,s.put("sessionTargetingMatch",{targetingMatch:a,sessionId:u,lastUpdated:Date.now()})];case 2:return l=f.sent(),[2,l];case 3:return c=f.sent(),me(n,"Failed to store targeting match for session id ".concat(o,": ").concat(c),c),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.currentSessionId;return I(e,void 0,void 0,function(){var a,s,u,l,c,f,d,v;return _(this,function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.openOrCreateDB(i)];case 1:return a=h.sent(),s=String(o),u=a.transaction("sessionTargetingMatch","readwrite"),[4,u.store.getAll()];case 2:l=h.sent(),c=0,h.label=3;case 3:return c<l.length?(f=l[c],d=Date.now()-f.lastUpdated,f.sessionId!==s&&d>h0?[4,u.store.delete(f.sessionId)]:[3,5]):[3,6];case 4:h.sent(),h.label=5;case 5:return c++,[3,3];case 6:return[4,u.done];case 7:return h.sent(),[3,9];case 8:return v=h.sent(),me(n,"Failed to clear old targeting matches for sessions: ".concat(v),v),[3,9];case 9:return[2]}})})}}return t})(),Mn=new g0,p0=function(t){var e=t.sessionId,r=t.targetingConfig,n=t.loggerProvider,i=t.apiKey,o=t.targetingParams,a=t.urlChange,s=a===void 0?!1:a;return I(void 0,void 0,void 0,function(){var u,l,c,f,d,v,h;return _(this,function(g){switch(g.label){case 0:return[4,Mn.clearStoreOfOldSessions({loggerProvider:n,apiKey:i,currentSessionId:e})];case 1:return g.sent(),[4,Mn.getTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e})];
13case 2:if(u=g.sent(),u===!0&&!s)return[2,!0];l=!0,g.label=3;case 3:return g.trys.push([3,6,,7]),[4,Ht(()=>import("./index.OMs6UZrZ.js"),__vite__mapDeps([0,1,2,3]))];case 4:return c=g.sent().evaluateTargeting,f=C(C({},o),{flag:r,sessionId:typeof e=="string"?parseInt(e,10):e,apiKey:i,loggerProvider:n}),[4,c(f)];case 5:return d=g.sent(),d&&d.sr_targeting_config&&(l=d.sr_targeting_config.key==="on"),Mn.storeTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e,targetingMatch:l}),[3,7];case 6:return v=g.sent(),h=v,n.warn(h.message),[3,7];case 7:return[2,l]}})})},Ar=2654435761,kr=2246822519,Ra=3266489917,m0=668265263,Oa=374761393;function rt(t,e){return(t<<e|t>>>32-e)>>>0}function br(t,e){return t=t+Math.imul(e,kr)>>>0,t=rt(t,13),t=Math.imul(t,Ar)>>>0,t}function Wt(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function y0(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);if(n>=55296&&n<=56319&&r+1<t.length){var i=t.charCodeAt(r+1);i>=56320&&i<=57343&&(n=(n-55296<<10)+(i-56320)+65536,r++)}n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<65536?e.push(224|n>>12,128|n>>6&63,128|n&63):e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63)}return new Uint8Array(e)}function b0(t,e){e===void 0&&(e=0);var r=y0(t),n=r.length,i,o=0;if(n>=16){for(var a=e+Ar+kr>>>0,s=e+kr>>>0,u=e>>>0,l=e-Ar>>>0;o<=n-16;)a=br(a,Wt(r,o)),o+=4,s=br(s,Wt(r,o)),o+=4,u=br(u,Wt(r,o)),o+=4,l=br(l,Wt(r,o)),o+=4;i=rt(a,1)+rt(s,7)+rt(u,12)+rt(l,18)>>>0}else i=e+Oa>>>0;for(i=i+n>>>0;o<=n-4;)i=i+Math.imul(Wt(r,o),Ra)>>>0,i=Math.imul(rt(i,17),m0)>>>0,o+=4;for(;o<n;)i=i+Math.imul(r[o],Oa)>>>0,i=Math.imul(rt(i,11),Ar)>>>0,o++;return i^=i>>>15,i=Math.imul(i,kr)>>>0,i^=i>>>13,i=Math.imul(i,Ra)>>>0,i^=i>>>16,i>>>0}function E0(t,e){var r=b0(t.toString()),n=r%1e6;return n/1e6<e}var Nn="__amplitude_url_tracking_patched__",La=new WeakMap;function sl(t,e,r){if(r===void 0&&(r={}),!t?.location)return function(){};var n=r.enablePolling,i=n===void 0?!1:n,o=r.pollingInterval,a=o===void 0?xi:o;if(i){var s=function(){var E;return(E=t.location.href)!==null&&E!==void 0?E:""},u=s(),l=t.setInterval(function(){var E=s();E!==u&&(u=E,e(E))},a);return function(){l!=null&&t.clearInterval(l)}}var c=La.get(t);if(!c){var f=void 0,d=new Set,v=function(){var E;return(E=t.location.href)!==null&&E!==void 0?E:""},h=function(){var E=v();f!==void 0&&E===f||(f=E,d.forEach(function(S){return S(E)}))},g=function(E){var S=function(){for(var T=[],w=0;w<arguments.length;w++)T[w]=arguments[w];var P=E.apply(this,T);return h(),P};return S[Nn]=!0,S},m=t.history;if(m?.pushState){var p=Reflect.get(m,"pushState");p[Nn]||(m.pushState=g(p))}if(m?.replaceState){var y=Reflect.get(m,"replaceState");y[Nn]||(m.replaceState=g(y))}c={callbacks:d,notify:h,onPopStateOrHashChange:function(){return h()},listenersAttached:!1},La.set(t,c)}var b=c;return b.listenersAttached||(t.addEventListener("popstate",b.onPopStateOrHashChange),t.addEventListener("hashchange",b.onPopStateOrHashChange),b.listenersAttached=!0),b.callbacks.add(e),function(){b.callbacks.delete(e),b.callbacks.size===0&&b.listenersAttached&&(t.removeEventListener("popstate",b.onPopStateOrHashChange),t.removeEventListener("hashchange",b.onPopStateOrHashChange),b.listenersAttached=!1)}}function ul(t){return t===void 0&&(t={}),{name:"amplitude/url-tracking@1",observer:function(e,r,n){var i,o,a,s=C(C({},t),n),u=s.ugcFilterRules||[],l=(i=s.enablePolling)!==null&&i!==void 0?i:!1,c=(o=s.pollingInterval)!==null&&o!==void 0?o:xi,f=(a=s.captureDocumentTitle)!==null&&a!==void 0?a:!1;if(!r)return function(){};var d=void 0,v=function(){return r.location&&r.location.href||""},h=function(){var p=r.innerHeight,y=r.innerWidth,b=r.document,E=v(),S="";f&&(S=b?.title||"");var T=u.length>0?$r(E,u):E;return{href:T,title:S,viewportHeight:p,viewportWidth:y,type:"url-change-event"}},g=function(){var p=v();if(d===void 0||p!==d){d=p;var y=h();e(y)}},m=sl(r,function(){return g()},l?{enablePolling:!0,pollingInterval:c}:{});return g(),function(){return m()}},options:t}}ul();function S0(){try{var t=ue();return t?t.parent!==t:!1}catch{return!0}}var T0=(function(){function t(){this.pendingLoadListeners=new Map}return t.prototype.start=function(){var e=this,r;(r=this.mutationObserver)===null||r===void 0||r.disconnect();var n=ue();n&&(this.sendToAllIframes({type:Pr,action:"start"}),this.mutationObserver=new MutationObserver(function(i){var o,a,s,u,l,c;try{for(var f=L(i),d=f.next();!d.done;d=f.next()){var v=d.value;try{for(var h=(s=void 0,L(Array.from(v.addedNodes))),g=h.next();!g.done;g=h.next()){var m=g.value;m instanceof HTMLIFrameElement?e.sendToIframeAfterLoad(m):m instanceof Element&&m.querySelectorAll("iframe").forEach(function(E){e.sendToIframeAfterLoad(E)})}}catch(E){s={error:E}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(s)throw s.error}}
13try{for(var p=(l=void 0,L(Array.from(v.removedNodes))),y=p.next();!y.done;y=p.next()){var m=y.value;if(m instanceof HTMLIFrameElement){var b=e.pendingLoadListeners.get(m);b&&(m.removeEventListener("load",b),e.pendingLoadListeners.delete(m))}}}catch(E){l={error:E}}finally{try{y&&!y.done&&(c=p.return)&&c.call(p)}finally{if(l)throw l.error}}}}catch(E){o={error:E}}finally{try{d&&!d.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},t.prototype.stop=function(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(r,n){n.removeEventListener("load",r)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:Pr,action:"stop"})},t.prototype.sendToIframeAfterLoad=function(e){var r=this,n=function(){r.pendingLoadListeners.delete(e),r.sendToIframe(e,{type:Pr,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},t.prototype.sendToAllIframes=function(e){var r=this,n=document.querySelectorAll("iframe");n.forEach(function(i){return r.sendToIframe(i,e)})},t.prototype.sendToIframe=function(e,r){var n;try{(n=e.contentWindow)===null||n===void 0||n.postMessage(r,"*")}catch{}},t})();function _0(t){var e=ue();if(!e)return function(){};var r=e.parent;function n(i){if(i.source===r){var o=i.data;o?.type===Pr&&(o.action==="start"?t.onStart():o.action==="stop"&&t.onStop())}}return e.addEventListener("message",n),function(){return e.removeEventListener("message",n)}}var I0=(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.recordingEnabled=!0,this.recordingGeneration=0,this.startChildRecordingOnSetup=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeCoordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(r){var n=ue();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!r&&n.addEventListener("blur",e.blurListener),!r&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!r&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!r&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){var r;if(e.recordingEnabled)if(e.recordCancelCallback&&e.recordFunction){if(((r=e.config)===null||r===void 0?void 0:r.captureFullSnapshotOnFocus)===!1)return;try{e.recordFunction.takeFullSnapshot(!0)}catch(n){e.loggerProvider.warn("Failed to take full snapshot on focus:",n)}}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(r){var n;(n=e.eventCompressor)===null||n===void 0||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(i){i(r)})},this.evaluateTargetingAndCapture=function(r,n,i,o){return n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1),I(e,void 0,void 0,function(){var a,s,u,l,c,f,d,v,h,g,m,p,y;return _(this,function(b){switch(b.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)this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");else return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];return this.lastTargetingParams=r,a=this.config.targetingConfig,s=a&&
13!this.sessionTargetingMatch,s?(u=o?this.latestUrlChangeTargetingEvaluationId:void 0,l=r.event,l&&Object.values(er).includes(l.event_type)&&(l=void 0),c=(p=(h=(v=r.page)===null||v===void 0?void 0:v.url)!==null&&h!==void 0?h:(m=(g=ue())===null||g===void 0?void 0:g.location)===null||m===void 0?void 0:m.href)!==null&&p!==void 0?p:"",f=(y=r.page)!==null&&y!==void 0?y:c!==""?{url:c}:void 0,[4,p0({sessionId:this.identifiers.sessionId,targetingConfig:a,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:r.userProperties,event:l,page:f},urlChange:o})]):[3,2];case 1:if(d=b.sent(),o&&u!==void 0&&u!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(u,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||d,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:l,targetingParams:r},null,2)),b.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return i||!this.recordCancelCallback?(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]):[3,5];case 4:b.sent(),b.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(r,n,i){return n===void 0&&(n={}),i===void 0&&(i=!0),I(e,void 0,void 0,function(){var o,a,s,u;return _(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),o=void 0,a=this.config,a&&r!==We.METADATA?(o={config:$u(a),version:qr},i?[4,zu()]:[3,2]):[3,2];case 1:s=l.sent(),o=C(C({},s),o),l.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(r,C(C({},n),o)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(r," due to no ongoing recording.")),[3,4];case 3:return u=l.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",u),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var r,n,i;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,(r=e.networkObservers)===null||r===void 0||r.stop(),(n=e.crossOriginIframeCoordinator)===null||n===void 0||n.stop(),e.crossOriginIframeCoordinator=null,(i=e.crossOriginParentSignalCleanup)===null||i===void 0||i.call(e),e.crossOriginParentSignalCleanup=null}catch(a){var o=a;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(o.toString()))}},this.loggerProvider=new ii(new Fr)}return t.prototype.init=function(e,r){return In(this._init(e,r))},t.prototype.setupUrlChangeListener=function(){var e=this,r,n;(r=this.urlChangeCleanup)===null||r===void 0||r.call(this);var i=ue();if(i?.location){var o=!!(!((n=this.config)===null||n===void 0)&&n.targetingConfig),a=function(u){if(e.currentPageUrl=u,o){var l=++e.latestUrlChangeTargetingEvaluationId;e.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:u}},!1,!1,!0),e.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(l," for ").concat(u,"."))}},s=sl(i,a);this.urlChangeCleanup=function(){s(),e.urlChangeCleanup=null}}},t.prototype.isBelowMinSessionDuration=function(){var e,r=(e=this.config)===null||e===void 0?void 0:e.minSessionDurationMs;return r===void 0||this.sessionStartTime===void 0?!1:Date.now()-this.sessionStartTime<r},t.prototype.getCurrentPageForTargeting=function(){var e,r,n=(r=(e=ue())===null||e===void 0?void 0:e.location)===null||r===void 0?void 0:r.href;return n!=null?{url:n}:void 0},t.prototype._init=function(e,r){var n,i,o,a,s,u,l,c,f,d,v,h,g,m;return I(this,void 0,void 0,function(){var p,y,b,E,S,T,w,P,A,F,k,x,R,M,U,N,q,O,$,H,j,O,G,V,X,Y,J,Q,re,ee,B,ie,oe,se=this;return _(this,function(K){switch(K.label){case 0:return(n=this.urlChangeCleanup)===null||n===void 0||n.call(this),this.recordingEnabled=!0,this.startChildRecordingOnSetup=!1,this.loggerProvider=new ii(r.loggerProvider||new Fr),Object.prototype.hasOwnProperty.call(r,"logLevel")&&this.loggerProvider.enable(r.logLevel),this.currentPageUrl=oi(),this.identifiers=new ka({sessionId:r.sessionId,deviceId:r.deviceId}),p=Date.now(),v0(e,p,this.loggerProvider),this.sessionStartTime=r.sessionId!==void 0&&(i=c0(e,r.sessionId,p,this.loggerProvider))!==null&&i!==void 0?i:p,y=this,[4,dm(e,r)];case 1:return y.joinedConfigGenerator=K.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return b=K.sent(),E=b.joinedConfig,S=b.localConfig,T=b.remoteConfig,this.config=E,this.setMetadata(r.sessionId,E,S,T,(o=r.version)===null||o===void 0?void 0:o.version,qr,(a=r.version)===null||a===void 0?void 0:a.type),this.pageLeaveFns=[],r.sessionId&&(!((s=this.config.interactionConfig)===null||s===void 0)&&s.enabled)&&(w=s0.default({sessionId:r.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[w.send(this.getDeviceId.bind(this)).bind(w)],this.scrollHook=w.hook.bind(w),this.clickHandler=new o0(this.loggerProvider,w)),P=[],A=this.config.storeType,A==="idb"&&!(!((u=ue())===null||u===void 0)&&u.indexedDB)&&(A="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(A," for event storage.")),x=ue(),this.config.useWebWorker&&x&&x.Worker?[4,Ht(()=>import("./index.BKE8_Mt3.js"),[])]:[3,4];case 3:R=K.sent(),M=R.compressionScript,U=R.trackDestinationScript,F=M,k=U,K.label=4;case 4:return K.trys.push([4,6,,7]),[4,Ia({config:this.config,type:"replay",minInterval:(l=this.config.flushIntervalConfig)===null||l===void 0?void 0:l.minIntervalMs,maxInterval:(c=this.config.flushIntervalConfig)===null||c===void 0?void 0:c.maxIntervalMs,maxPer
13sistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:A,trackDestinationWorkerScript:k,shouldSend:function(){return!se.isBelowMinSessionDuration()}})];case 5:return N=K.sent(),this.rrwebEventManager=N,P.push({name:"replay",manager:N}),[3,7];case 6:return q=K.sent(),O=q,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(O.toString())),[3,7];case 7:if(!(!((f=this.config.interactionConfig)===null||f===void 0)&&f.enabled))return[3,11];$=this.config.interactionConfig.batch?i0:n0,K.label=8;case 8:return K.trys.push([8,10,,11]),[4,Ia({config:this.config,type:"interaction",minInterval:(d=this.config.interactionConfig.trackEveryNms)!==null&&d!==void 0?d:Vp,maxInterval:Wp,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:$,storeType:A,trackDestinationWorkerScript:k})];case 9:return H=K.sent(),P.push({name:"interaction",manager:H}),[3,11];case 10:return j=K.sent(),O=j,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(O.toString())),[3,11];case 11:if(this.eventsManager=new(wa.bind.apply(wa,W([void 0],D(P),!1))),this.eventCompressor&&this.eventCompressor.terminate(),G=this.config.eagerFullSnapshotSend===!0?function(){return se.sendEvents()}:void 0,this.eventCompressor=new ym(this.eventsManager,this.config,this.getDeviceId(),F,G),this.pendingEmitEvents.length>0){V=this.pendingEmitEvents.splice(0);try{for(X=L(V),Y=X.next();!Y.done;Y=X.next())J=Y.value,Q=J.event,re=J.sessionId,this.eventCompressor.enqueueEvent(Q,re)}catch(ge){ie={error:ge}}finally{try{Y&&!Y.done&&(oe=X.return)&&oe.call(X)}finally{if(ie)throw ie.error}}}return this.pageLeaveFns=W(W([],D(this.pageLeaveFns),!1),[function(){var ge;if(!(!se.config||!(!((ge=se.identifiers)===null||ge===void 0)&&ge.sessionId)||!N)){var be=N.getBeaconEvents();if(be.length){var Te=se.getDeviceId();Te&&(se.isBelowMinSessionDuration()||N.trackDestination.sendBeacon({events:be,sessionId:se.identifiers.sessionId,deviceId:Te,apiKey:se.config.apiKey,serverZone:se.config.serverZone}))}}}],!1),[4,this.initializeNetworkObservers()];case 12:return K.sent(),!((v=ue())===null||v===void 0)&&v.opener&&(ee=Rp(),Op(ee),ee.setup(C({logger:this.loggerProvider},this.config.serverZone&&{endpoint:Ip[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:r.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return K.sent(),B=this.config.targetingConfig||((m=(g=(h=this.config.privacyConfig)===null||h===void 0?void 0:h.urlMaskLevels)===null||g===void 0?void 0:g.length)!==null&&m!==void 0?m:0)>0,B&&this.setupUrlChangeListener(),[2]}})})},t.prototype.setSessionId=function(e,r){return In(this.asyncSetSessionId(e,r))},t.prototype.asyncSetSessionId=function(e,r,n){var i,o,a,s;return I(this,void 0,void 0,function(){var u,l,c,f,d;return _(this,function(v){switch(v.label){case 0:return u=(i=this.identifiers)===null||i===void 0?void 0:i.sessionId,l=this.getDeviceId(),u!==void 0&&u===e&&(r===void 0||r===l)&&(n?.userProperties===void 0||Object.keys(n.userProperties).length===0)?[2]:(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,u&&this.sendEvents(u),c=u!==e,c&&((o=this.rrwebEventManager)===null||o===void 0||o.dropPendingBeaconEvents()),f=r||this.getDeviceId(),this.identifiers=new ka({sessionId:e,deviceId:f}),c&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,!((a=this.config)===null||a===void 0)&&a.apiKey&&(d0(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),u!==void 0&&f0(this.config.apiKey,u,this.loggerProvider))),this.joinedConfigGenerator&&u?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2]);case 1:d=v.sent().joinedConfig,this.config=d,v.label=2;case 2:return!((s=this.config)===null||s===void 0)&&s.targetingConfig?[4,this.evaluateTargetingAndCapture({userProperties:n?.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return v.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:v.sent(),v.label=6;case 6:return[2]}})})},t.prototype.getSessionReplayProperties=function(){var e,r=this.config,n=this.identifiers;if(!r||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var i=this.getShouldRecord(),o={};return i&&(o=(e={},e[Lp]=n.sessionReplayId?n.sessionReplayId:null,e),r.debugMode&&(o[Np]=JSON.stringify({appHash:la(r.apiKey).toString()}))),this.addCustomRRWebEvent(We.GET_SR_PROPS,{shouldRecord:i,eventProperties:o},this.eventCount===10),this.eventCount===10&&(this.eventCount=0),this.eventCount++,o},t.prototype.sendEvents=function(e){var r,n,i=e||((r=this.identifiers)===null||r===void 0?void 0:r.sessionId),o=this.getDeviceId();if(this.eventsManager&&i&&o){if(this.isBelowMinSessionDuration()){var a=this.sessionStartTime,s=this.config.minSessionDurationMs;this.loggerProvider.log("Session ".concat(i," not sent: duration ").concat(Date.now()-a,"ms is below minimum ").concat(s,"ms.")),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&((n=this.config)===null||n===void 0?void 0:n.minSessionDurationMs)!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var u=this.sessionStartTime!==void 0?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent(We.REPLAY_GATE_DECISION,{sessionId:i,suppressedSendCount:this.suppressedSendCount,elapsedMs:u,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:i,deviceId:o})}},t.prototype.initialize=function(e){var r;return e===void 0&&(e=!1),I(this,void 0,void 0,function(){var n;return _(this,function(i){return!((r=this.identifiers)===null||r===void 0)&&r.sessionId?(n=this.getDeviceId(),n?(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(){var e,r,n;if(!((e=this.config)===null||e===void 0)&&e.instanceName){var i=Lu(this.config.instanceName).identityStore;n=i.getIdentity().optOut}return n!==void 0?n:(r=this.config)===null||r===void 0?void 0:r.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.recordingEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured because recording was stopped.")),!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=!1,r="",n=!1;if(this.config.targetingConfig)this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),e=!0,n=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),e=!1,n=!1);else{var i=E0(this.identifiers.sessionId,this.config.sampleRate);i?(e=!0,n=!0):(r="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(r),e=!1,n=!1)}return this.lastShouldRecordDecision!==e&&this.config.targetingConfig&&(this.addCustomRRWebEvent(We.TARGETING_DECISION,{message:r,sessionId:this.identifiers.sessionId,matched:n,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=e),e},t.prototype.getBlockSelectors=function(){var e,r,n,i=(n=(r=(e=this.config)===null||e===void 0?void 0:e.privacyConfig)===null||r===void 0?void 0:r.blockSelector)!==null&&n!==void 0?n:[];if(i.length!==0)return i},t.prototype.getMaskTextSelectors=function(){var e,r,n=(e=this.config)===null||e===void 0?void 0:e.privacyConfig,i=n?Hu(this.currentPageUrl,n):void 0;if(i==="conservative"||!((r=n?.urlMaskLevels)===null||r===void 0)&&r.some(function(s){return s.maskLevel==="conservative"}))return"*";var o=n?.urlMaskLevels;if(n?.defaultMaskLevel==="conservative"&&o&&o.length>0)return"*";var a=n?.maskSelector;if(a)return a},t.prototype.getRecordingPlugins=function(e){var r,n,i,o,a,s;return I(this,void 0,void 0,function(){var u,l,c,f;return _(this,function(d){switch(d.label){case 0:u=[];try{l=ul({ugcFilterRules:((n=(r=this.config)===null||r===void 0?void 0:r.interactionConfig)===null||n===void 0?void 0:n.ugcFilterRules)||[],enablePolling:((i=this.config)===null||i===void 0?void 0:i.enableUrlChangePolling)||!1,pollingInterval:(o=this.config)===null||o===void 0?void 0:o.urlChangePollingInterval,captureDocumentTitle:(a=this.config)===null||a===void 0?void 0:a.captureDocumentTitle}),u.push(l)}catch(v){this.loggerProvider.warn("Failed to create URL tracking plugin:",v)}if(!(!((s=e?.console)===null||s===void 0)&&s.enabled))return[3,4];d.label=1;case 1:return d.trys.push([1,3,,4]),[4,Ht(()=>import("./rrweb-plugin-console-record.CXlla3dY.js"),[])];case 2:return c=d.sent().getRecordConsolePlugin,u.push(c({level:e.console.levels})),[3,4];case 3:return f=d.sent(),this.loggerProvider.warn("Failed to load console plugin:",f),[3,4];case 4:return[2,u.length>0?u:void 0]}})})},t.prototype.getRecordFunction=function(){return I(this,void 0,void 0,function(){var e,r;return _(this,function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,Ht(()=>import("./rrweb-record.C27dNwRI.js"),[])];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];case 3:return r=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",r),[2,null];case 4:return[2]}})})},t.prototype.recordEvents=function(e){return e===void 0&&(e=!0),I(this,void 0,void 0,function(){var r;return _(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:return this.recordEventsPendingShouldLogMetadata===null?[3,5]:(r=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(r)]);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.shouldAbandonRecordStart=function(e){return!this.recordingEnabled||e!==this.recordingGeneration},t.prototype._recordEvents=function(e){var r,n,i,o,a,s,u,l;return e===void 0&&(e=!0),I(this,void 0,void 0,function(){var c,f,d,v,h,g,m,p,y,b,E,S,T,w,P,A,F,k=this;return _(this,function(x){switch(x.label){case 0:return c=this.config,f=this.getShouldRecord(),d=(r=this.identifiers)===null||r===void 0?void 0:r.sessionId,!f||!d||!c?[2]:(this.stopRecordingEvents(),v=this.recordingGeneration,[4,this.getRecordFunction()]);case 1:return h=x.sent(),!h||this.shouldAbandonRecordStart(v)?[2]:[4,this.initializeNetworkObservers()];case 2:if(x.sent(),this.shouldAbandonRecordStart(v))return[2];g=(n=c.loggingConfig)===null||n===void 0?void 0:n.network,m=Kt(c.serverZone,c.trackServerUrl),p=[Fu,Bu,qu,m],(i=this.networkObservers)===null||i===void 0||i.start(function(R){p.some(function(M){return R.url.startsWith(M)})||k.addCustomRRWebEvent(We.FETCH_REQUEST,R)},g),y=c.interactionConfig,b=c.loggingConfig,E=y?.enabled?{mouseInteraction:this.eventsManager&&((o=this.clickHandler)===null||o===void 0?void 0:o.createHook({eventsManager:this.eventsManager,sessionId:d,deviceIdFn:this.getDeviceId.bind(this),mirror:h.mirror,ugcFilterRules:(a=y.ugcFilterRules)!==null&&a!==void 0?a:[],performanceOptions:(s=c.performanceConfig)===null||s===void 0?void 0:s.interaction})),scroll:this.scrollHook}:{},S=y?.enabled&&y.ugcFilterRules?y.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(d,".")),x.label=3;case 3:return x.trys.push([3,5,,6]),T=!!(!((u=c.crossOriginIframes)===null||u===void 0)&&u.enabled),w=((l=c.crossOriginIframes)===null||l===void 0?void 0:l.coordinateChildren)!==!1,P=T&&S0(),P&&w?(this.crossOriginParentSignalCleanup=_0({onStart:function(){k.recordingEnabled&&k._recordEventsInChildMode(h,d,c,E)},onStop:function(){try{k.recordCancelCallback&&k.recordCancelCallback(),k.recordCancelCallback=null}catch(M){var R=M;k.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(R.toString()))}}}),this.startChildRecordingOnSetup&&(this.startChildRecordingOnSetup=!1,this._recordEventsInChildMode(h,d,c,E)
13),[2]):(this.startChildRecordingOnSetup=!1,[4,this.getRecordingPlugins(b)]);case 4:return A=x.sent(),this.shouldAbandonRecordStart(v)?[2]:(this.recordCancelCallback=h(C(C({},this.buildRRWebRecordOptions(c,E,function(R){if(k.shouldOptOut()||!k.recordingEnabled){k.loggerProvider.log(k.shouldOptOut()?"Opting session ".concat(d," out of recording due to optOut config."):"Session Replay capture stopping for ".concat(d,".")),k.stopRecordingEvents(),k.sendEvents();return}R.type===Kr.Meta&&(R.data.href=$r(R.data.href,S)),k.eventCompressor?k.eventCompressor.enqueueEvent(R,d):k.pendingEmitEvents.push({event:R,sessionId:d})},"Error while capturing replay: ")),{plugins:A,recordCrossOriginIframes:T})),T&&!P&&w&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new T0),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(We.DEBUG_INFO),e&&this.addCustomRRWebEvent(We.METADATA,this.metadata),[3,6]);case 5:return F=x.sent(),this.loggerProvider.warn("Failed to initialize session replay:",F),[3,6];case 6:return[2]}})})},t.prototype.buildRRWebRecordOptions=function(e,r,n,i){var o=this,a=e.privacyConfig;return C(C({emit:n,inlineStylesheet:e.shouldInlineStylesheet,inlineImages:e.inlineImages,hooks:r,maskAllInputs:!0,maskTextClass:Nu,blockClass:Up,blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:va("input",a,function(){return o.currentPageUrl}),maskTextFn:va("text",a,function(){return o.currentPageUrl}),maskAttributeFn:em(a,function(){return o.currentPageUrl}),maskTextSelector:this.getMaskTextSelectors()},e.fullSnapshotIntervalMs!==void 0&&{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(s){var u=s;if(u.message.includes("insertRule")&&u.message.includes("CSSStyleSheet")||u._external_)throw u;return o.loggerProvider.warn(i,u.toString()),!0}})},t.prototype._recordEventsInChildMode=function(e,r,n,i){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e(C(C({},this.buildRRWebRecordOptions(n,i,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(r,"."))}catch(o){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",o)}},t.prototype.getDeviceId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.deviceId},t.prototype.getSessionId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.sessionId},t.prototype.start=function(){return In(this._start())},t.prototype._start=function(){return I(this,void 0,void 0,function(){return _(this,function(e){switch(e.label){case 0:return this.recordingEnabled=!0,this.startChildRecordingOnSetup=!0,[4,this.recordEvents()];case 1:return e.sent(),[2]}})})},t.prototype.stop=function(){this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,this.stopRecordingEvents(),this.sendEvents()},t.prototype.flush=function(e){var r;return e===void 0&&(e=!1),I(this,void 0,void 0,function(){return _(this,function(n){return[2,(r=this.eventsManager)===null||r===void 0?void 0:r.flush(e)]})})},t.prototype.shutdown=function(){var e,r;this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,(e=this.urlChangeCleanup)===null||e===void 0||e.call(this),(r=this.crossOriginParentSignalCleanup)===null||r===void 0||r.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},t.prototype.mapSDKType=function(e){return e==="plugin"?"@amplitude/plugin-session-replay-browser":e==="segment"?"@amplitude/segment-session-replay-plugin":null},t.prototype.setMetadata=function(e,r,n,i,o,a,s){var u=e?.toString()?la(e.toString()):void 0;this.metadata={joinedConfig:r,localConfig:n,remoteConfig:i,sessionId:e,hashValue:u,sampleRate:r.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:o,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:a}},t.prototype.initializeNetworkObservers=function(){var e,r,n;return I(this,void 0,void 0,function(){var i,o;return _(this,function(a){switch(a.label){case 0:if(!(!((n=(r=(e=this.config)===null||e===void 0?void 0:e.loggingConfig)===null||r===void 0?void 0:r.network)===null||n===void 0)&&n.enabled&&!this.networkObservers))return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Ht(()=>import("./observers.DB9d6_ST.js"),__vite__mapDeps([4,1,2,3]))];case 2:return i=a.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return o=a.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},t})(),Ve=function(t){return function(){var e=t.config,r=e||Ku(),n=r.loggerProvider,i=r.logLevel;return{logger:n,logLevel:i}}},w0=function(){var t=new I0;return{init:qe(t.init.bind(t),"init",Ve(t)),evaluateTargetingAndCapture:qe(t.evaluateTargetingAndCapture.bind(t),"evaluateTargetingAndRecord",Ve(t)),setSessionId:qe(t.setSessionId.bind(t),"setSessionId",Ve(t)),getSessionId:qe(t.getSessionId.bind(t),"getSessionId",Ve(t)),getSessionReplayProperties:qe(t.getSessionReplayProperties.bind(t),"getSessionReplayProperties",Ve(t)),flush:qe(t.flush.bind(t),"flush",Ve(t)),start:qe(t.start.bind(t),"start",Ve(t)),stop:qe(t.stop.bind(t),"stop",Ve(t)),shutdown:qe(t.shutdown.bind(t),"shutdown",Ve(t))}};const ze=w0();var C0=ze.init,P0=ze.setSessionId,A0=ze.getSessionId,k0=ze.getSessionReplayProperties,R0=ze.flush,O0=ze.start,L0=ze.stop,D0=ze.shutdown,x0=ze.evaluateTargetingAndCapture,$e;(function(t){t.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"})($e||($e={}));var Da;(function(t){t.REVENUE_PRODUCT_ID="$productId",t.REVENUE_QUANTITY="$quantity",t.REVENUE_PRICE="$price",t.REVENUE_TYPE="$revenueType",t.REVENUE_CURRENCY="$currency",t.REVENUE="$revenue"})(Da||(Da={}));var xa;(function(t){t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount"})(xa||(xa={}));var M0=[$e.SET,$e.SET_ONCE,$e.ADD,$e.APPEND,$e.PREPEND,$e.POSTINSERT],N0=function(t){if(t.user_properties){var e={},r=Object.keys(t.user_properties);return r.forEach(function(n){if(M0.includes(n)){var i=t.user_properties&&t.user_properties[n];e=C(C({},e),i)}}),e}},Ma="1.35.2",U0="[Amplitude]",F0="".concat(U0," Session Replay ID"),B0=(function(){function t(e){this.name=t.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:R0,getSessionId:A0,getSessionReplayProperties:k0,init:C0,setSessionId:P0,start:O0,stop:L0,shutdown:D0,evaluateTargetingAndCapture:x0},this.options=C({forceSessionTracking:!1},e),this.srInitOptions=this.options}return t.prototype.setup=function(e,r){var n,i,o,a,s,u,l,c;return I(this,void 0,void 0,function(){var f,d,v;return _(this,function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),e?.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(Ma,".")),this.config=e,this.options.forceSessionTracking&&(typeof e.defaultTracking=="boolean"?e.defaultTracking===!1&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=C(C({},e.defaultTracking),{sessions:!0})),f=Lu(this.config.instanceName).identityStore,d=f.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:(n=this.options.deviceId)!==null&&n!==void 0?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||((i=this.config.remoteConfig)===null||i===void 0?void 0:i.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:(o=this.options.privacyConfig)===null||o===void 0?void 0:o.blockSelector,maskSelector:(a=this.options.privacyConfig)===null||a===void 0?void 0:a.maskSelector,unmaskSelector:(s=this.options.privacyConfig)===null||s===void 0?void 0:s.unmaskSelector,defaultMaskLevel:(u=this.options.privacyConfig)===null||u===void 0?void 0:u.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,inlineImages:this.options.inlineImages,version:{type:"plugin",version:Ma},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:(l=this.options.useWebWorker)!==null&&l!==void 0?l:(c=this.options.experimental)===null||c===void 0?void 0:c.useWebWorker,userProperties:d,applyBackgroun
13dColorToBlockedElements: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 h.sent(),[3,3];case 2:return v=h.sent(),e?.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(v.message)),[3,3];case 3:return[2]}})})},t.prototype.onSessionIdChanged=function(e){var r;return I(this,void 0,void 0,function(){return _(this,function(n){switch(n.label){case 0:return(r=this.config)===null||r===void 0||r.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]}})})},t.prototype.onOptOutChanged=function(e){var r;return I(this,void 0,void 0,function(){var n;return _(this,function(i){switch(i.label){case 0:return(r=this.config)===null||r===void 0||r.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),e?(this.sessionReplay.shutdown(),[3,4]):[3,1];case 1:return n=this.config!=null,n?[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise]:[3,3];case 2:n=i.sent(),i.label=3;case 3:i.label=4;case 4:return[2]}})})},t.prototype.execute=function(e){var r,n,i;return I(this,void 0,void 0,function(){var o,u,o,a,s,u,l;return _(this,function(c){switch(c.label){case 0:return c.trys.push([0,9,,10]),this.options.customSessionId?(o=this.options.customSessionId(e),o?o===this.sessionReplay.getSessionId()?[3,2]:[4,this.sessionReplay.setSessionId(o).promise]:[3,3]):[3,4];case 1:c.sent(),c.label=2;case 2:u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=C(C({},e.event_properties),u),c.label=3;case 3:return[3,8];case 4:return o=(r=this.config)===null||r===void 0?void 0:r.sessionId,o&&o!==this.sessionReplay.getSessionId()?[4,this.sessionReplay.setSessionId(o).promise]:[3,6];case 5:c.sent(),c.label=6;case 6:return o&&o===e.session_id?(a=void 0,e.event_type===er.IDENTIFY&&(a=N0(e)),s=ue(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:a,page:((n=s?.location)===null||n===void 0?void 0:n.href)!=null?{url:s.location.href}:void 0})]):[3,8];case 7:c.sent(),u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=C(C({},e.event_properties),u),c.label=8;case 8:return e.event_type===er.IDENTIFY&&e.event_properties&&delete e.event_properties[F0],[2,Promise.resolve(e)];case 9:return l=c.sent(),(i=this.config)===null||i===void 0||i.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(l.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},t.prototype.teardown=function(){var e;return I(this,void 0,void 0,function(){return _(this,function(r){try{this.sessionReplay.shutdown(),this.config=null}catch(n){(e=this.config)===null||e===void 0||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(n.message))}return[2]})})},t.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},t.prototype.start=function(){return I(this,void 0,void 0,function(){return _(this,function(e){switch(e.label){case 0:return[4,this.sessionReplay.start().promise];case 1:return e.sent(),[2]}})})},t.prototype.stop=function(){this.sessionReplay.stop()},t.pluginName="@amplitude/plugin-session-replay-browser",t})(),q0=function(t){return new B0(t)};const Un="dataLayer",Na=t=>{const e=window,r=e[t];return Array.isArray(r)||(e[t]=[]),e[t]};class ll{name="google-tag-manager";type="destination";config;constructor(e={}){this.config=e}async setup(){const e=this.config.dataLayerName||Un,r=Na(e),n=this.config.injectScript!==!1,i=this.config.containerId?.trim();if(!n||!i||document.querySelector(`script[data-gtm-container-id="${i}"]`))return;r.push({"gtm.start":Date.now(),event:"gtm.js"});const a=document.createElement("script");a.async=!0,a.setAttribute("data-gtm-container-id",i),a.src=`https://www.googletagmanager.com/gtm.js?id=${i}${e!==Un?`&l=${e}`:""}`,document.head.appendChild(a)}async execute(e){const r=this.config.dataLayerName||Un;return Na(r).push({...e,event:e.event_type}),{code:200,event:e,message:"Event pushed onto GTM Data Layer"}}}function V0(t){const e={};return t.sampleRate!==void 0&&(e.sampleRate=t.sampleRate),t.privacyConfig&&(e.privacyConfig={},t.privacyConfig.mask&&(e.privacyConfig.maskSelector=t.privacyConfig.mask),t.privacyConfig.block&&(e.privacyConfig.blockSelector=t.privacyConfig.block)),t.applyBackgroun
13dColorToBlockedElements!==void 0&&(e.applyBackgroundColorToBlockedElements=t.applyBackgroundColorToBlockedElements),t.debugMode!==void 0&&(e.debugMode=t.debugMode),e}const mt=()=>typeof window<"u",Ce={initialized:!1,pendingEvents:[]};function W0(){if(!Ce.initialized||Ce.pendingEvents.length===0)return;const t=Ce.pendingEvents.splice(0,Ce.pendingEvents.length);for(const{eventName:e,properties:r}of t)try{Pu(e,r)}catch(n){console.error("Failed to track queued Amplitude event:",n)}}const cl={init:(t,e,r,n,i)=>{if(!mt())return console.warn("Amplitude can only be initialized in the browser"),Promise.resolve();if(Ce.initialized)return console.log("Amplitude already initialized"),Promise.resolve();try{const o={defaultTracking:{sessions:!0,pageViews:!0,formInteractions:!1,fileDownloads:!1,attribution:!1},serverZone:e,identityStorage:"localStorage",...r};if(n&&(n.sampleRate??0)>0)try{const s=V0(n),u=q0(s);aa(u)}catch(s){console.error("Failed to add Session Replay plugin:",s)}if(i)try{aa(new ll(i))}catch(s){console.error("Failed to add GTM destination plugin:",s)}const a=Kg(t,o);return Ce.initialized=!0,W0(),Promise.resolve(a.promise).then(()=>{})}catch(o){return console.error("Failed to initialize Amplitude:",o),Promise.resolve()}},logEvent:(t,e)=>{if(!mt()){console.warn("Amplitude events can only be tracked in the browser");return}if(!Ce.initialized){Ce.pendingEvents.push({eventName:t,properties:e});return}try{Pu(t,e)}catch(r){console.error("Failed to track Amplitude event:",r)}},getDeviceId:()=>{if(!(!mt()||!Ce.initialized))try{return jg()}catch(t){console.error("Failed to get device ID:",t);return}},getSessionId:()=>{if(!(!mt()||!Ce.initialized))try{return zg()}catch(t){console.error("Failed to get session ID:",t);return}},setUserId:t=>{if(!mt()){console.warn("Amplitude setUserId can only be called in the browser");return}if(!Ce.initialized){console.warn("Amplitude setUserId not called - Amplitude not initialized yet");return}try{Xg(t===null?void 0:String(t))}catch(e){console.error("Failed to set user ID:",e)}},identify:t=>{if(!mt()){console.warn("Amplitude identify can only be called in the browser");return}if(!Ce.initialized){console.warn("Amplitude identify not called - Amplitude not initialized yet");return}try{const e=new Tt;for(const[r,n]of Object.entries(t))e.set(r,n);$g(e)}catch(e){console.error("Failed to identify user:",e)}}},wt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Fe=globalThis,Xt="10.75.0";function dl(){return Bi(Fe),Fe}function Bi(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||Xt,e[Xt]=e[Xt]||{}}function qi(t,e,r=Fe){const n=r.__SENTRY__=r.__SENTRY__||{},i=n[Xt]=n[Xt]||{};return i[t]||(i[t]=e())}const H0="Sentry Logger ",Ua={};function G0(t){if(!("console"in Fe))return t();const e=Fe.console,r={},n=Object.keys(Ua);n.forEach(i=>{const o=Ua[i];r[i]=e[i],e[i]=o});try{return t()}finally{n.forEach(i=>{e[i]=r[i]})}}function j0(){Wi().enabled=!0}function z0(){Wi().enabled=!1}function fl(){return Wi().enabled}function $0(...t){Vi("log",...t)}function K0(...t){Vi("warn",...t)}function X0(...t){Vi("error",...t)}function Vi(t,...e){wt&&fl()&&G0(()=>{Fe.console[t](`${H0}[${t}]:`,...e)})}function Wi(){return wt?qi("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Rr={enable:j0,disable:z0,isEnabled:fl,log:$0,warn:K0,error:X0},Y0=Object.prototype.toString;function Q0(t,e){return Y0.call(t)===`[object ${e}]`}function J0(t){return Q0(t,"Object")}function Z0(t){return!!(t?.then&&typeof t.then=="function")}function ey(t,e,r){try{Object.defineProperty(t,e,{value:r,writable:!0,configurable:!0})}catch{wt&&Rr.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}let yt;function Jr(t){if(yt!==void 0)return yt?yt(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),r=Fe;return e in r&&typeof r[e]=="function"?(yt=r[e],yt(t)):(yt=null,t())}function di(){return Jr(()=>Math.random())}function ty(){return Jr(()=>Date.now())}function ry(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function ny(){const t=Fe;return t.crypto||t.msCrypto}let Fn;function iy(){return di()*16}function Yt(t=ny()){try{if(t?.randomUUID)return Jr(()=>t.randomUUID()).replace(/-/g,"")}catch{}return Fn||(Fn="10000000100040008000"+1e11),Fn.replace(/[018]/g,e=>(e^(iy()&15)>>e/4).toString(16))}const vl=1e3;function hl(){return ty()/vl}function oy(){const{performance:t}=Fe;if(!t?.now||!t.timeOrigin)return hl;const e=t.timeOrigin;return()=>(e+Jr(()=>t.now()))/vl}let Fa;function ay(){return(Fa??(Fa=oy()))()}function sy(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||ay(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:Yt()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{const r=t.timestamp-t.started;t.duration=r>=0?r:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),t
13ypeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function gl(t,e,r=2){if(!e||typeof e!="object"||r<=0)return e;if(t&&Object.keys(e).length===0)return t;const n={...t};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=gl(n[i],e[i],r-1));return n}function Ba(){return Yt()}function uy(t){try{const e=Fe.WeakRef;if(typeof e=="function")return new e(t)}catch{}return t}function ly(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch{return}return t}}const fi="_sentrySpan";function qa(t,e){e?ey(t,fi,uy(e)):delete t[fi]}function Va(t){return ly(t[fi])}const cy=100;class Qe{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Ba(),sampleRand:di()}}clone(){const e=new Qe;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._attributes={...this._attributes},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,qa(e,Va(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&sy(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,r){return this.setTags({[e]:r})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,r){return this.setAttributes({[e]:r})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,r){return this._extra={...this._extra,[e]:r},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,r){return r===null?delete this._contexts[e]:this._contexts[e]=r,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const r=typeof e=="function"?e(this):e,n=r instanceof Qe?r.getScopeData():J0(r)?e:void 0,{tags:i,attributes:o,extra:a,user:s,contexts:u,level:l,fingerprint:c=[],propagationContext:f,conversationId:d}=n||{};return this._tags={...this._tags,...i},this._attributes={...this._attributes,...o},this._extra={...this._extra,...a},this._contexts={...this._contexts,...u},s&&Object.keys(s).length&&(this._user=s),l&&(this._level=l),c.length&&(this._fingerprint=c),f&&(this._propagationContext=f),d&&(this._conversationId=d),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,qa(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Ba(),sampleRand:di()}),this._notifyScopeListeners(),this}addBreadcrumb(e,r){const n=typeof r=="number"?r:cy;if(n<=0)return this;const i={timestamp:hl(),...e,message:e.message?ry(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n),this._client?.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Va(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=gl(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,r){const n=r?.event_id||Yt();if(!this._client)return wt&&Rr.warn("No client configured on scope - will not capture exception!"),n;const i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...r,event_id:n},this),n}captureMessage(e,r,n){const i=n?.event_id||Yt();if(!this._client)return wt&&Rr.warn("No client configured on scope - will not capture message!"),i;const o=n?.syntheticException??new Error(e);return this._client.captureMessage(e,r,{originalException:e,syntheticException:o,...n,event_id:i},this),i}captureEvent(e,r){const n=e.event_id||r?.event_id||Yt();return this._client?(this._client.captureEvent(e,{...r,event_id:n},this),n):(wt&&Rr.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEac
13h(e=>{e(this)}),this._notifyingListeners=!1)}}function dy(){return qi("defaultCurrentScope",()=>new Qe)}function fy(){return qi("defaultIsolationScope",()=>new Qe)}const Wa=t=>t instanceof Promise&&!t[pl],pl=Symbol("chained PromiseLike"),vy=(t,e,r)=>{const n=t.then(i=>(e(i),i),i=>{throw r(i),i});return Wa(n)&&Wa(t)?n:hy(t,n)},hy=(t,e)=>{if(!e)return t;let r=!1;for(const n in t){if(n in e)continue;r=!0;const i=t[n];typeof i=="function"?Object.defineProperty(e,n,{value:(...o)=>i.apply(t,o),enumerable:!0,configurable:!0,writable:!0}):e[n]=i}return r&&Object.assign(e,{[pl]:!0}),e};class gy{constructor(e,r){let n;e?n=e:n=new Qe;let i;r?i=r:i=new Qe,this._stack=[{scope:n}],this._isolationScope=i}withScope(e){const r=this._pushScope();let n;try{n=e(r)}catch(i){throw this._popScope(),i}return Z0(n)?vy(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function Pt(){const t=dl(),e=Bi(t);return e.stack=e.stack||new gy(dy(),fy())}function py(t){return Pt().withScope(t)}function my(t,e){const r=Pt();return r.withScope(()=>(r.getStackTop().scope=t,e(t)))}function Ha(t){return Pt().withScope(()=>t(Pt().getIsolationScope()))}function yy(){return{withIsolationScope:Ha,withScope:py,withSetScope:my,withSetIsolationScope:(t,e)=>Ha(e),getCurrentScope:()=>Pt().getScope(),getIsolationScope:()=>Pt().getIsolationScope()}}function by(t){const e=Bi(t);return e.acs?e.acs:yy()}function ml(){const t=dl();return by(t).getCurrentScope()}function Ey(){return ml().getClient()}function Sy(t){if(t)return Ty(t)?{captureContext:t}:Iy(t)?{captureContext:t}:t}function Ty(t){return t instanceof Qe||typeof t=="function"}const _y=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Iy(t){return Object.keys(t).some(e=>_y.includes(e))}function wy(t,e){return ml().captureException(t,Sy(e))}function Cy(t,e){try{return Ey()?wy(t,{extra:e?.extra,tags:e?.tags,fingerprint:e?.fingerprint,level:e?.level}):void 0}catch{return}}const yl=new Set(["Error Occurred","Plan Payment Failed","Plan Purchase Failed","Topup Failed","Recharge Failed","Payment Method Enrollment Failed"]),Py="system error";function Ay(t,e){if(yl.has(t)||/ Failed$/i.test(t))return!0;if(!e)return!1;const r=e.error_message!=null&&e.error_message!=="",n=e.error_code!=null&&e.error_code!=="";return r||n}function ky(t){return String(t?.error_type??"").toLowerCase().trim()===Py}function Ry(t){const e={};if(!t)return e;for(const[r,n]of Object.entries(t))n!=null&&(e[r]=String(n));return e}function bl(t,e){try{if(!Ay(t,e)||!ky(e))return;const r=Ry(e);r.amplitude_event=t;const n=typeof e?.error_message=="string"&&e.error_message||typeof e?.errorMessage=="string"&&e.errorMessage||t,i=e?.error_code!=null&&String(e.error_code)||e?.errorCode!=null&&String(e.errorCode)||void 0,o=["amplitude-failure",t,i??"unknown"].filter(Boolean),a=new Error(`[Amplitude] ${t}: ${n}`);a.name="AmplitudeFailureEvent",Cy(a,{tags:r,fingerprint:o,level:"error",extra:{amplitude_event:t,properties:e}})}catch{}}const El={esim:"eSIM",id:"ID",sim:"SIM",cta:"CTA"};function Oy(t){return t.trim().split(/\s+/).map(e=>{const r=El[e.toLowerCase()];return r!==void 0?r:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" ")}function Ly(t){const e=t.trim().split(/\s+/),r=/^[A-Z][a-z]*$/,n=i=>i.toLowerCase()in El;return e.length>0&&e.every(i=>r.test(i)||n(i))}function Sl(t){return t.replace(/([A-Z])/g,"_$1").replace(/[\s-]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase()}function vi(t){return typeof t=="number"||typeof t=="boolean"?String(t).toLowerCase():t.trim().replace(/[_-]+/g," ").replace(/\s+/g," ").toLowerCase()}const Dy={plan_name:!0,plan_validity:!0,plan_id:!0,order_id:!0};function Tl(t){const e={};for(const[r,n]of Object.entries(t)){const i=r.startsWith("$");if(n!=null)if(i)e[r]=n;else{const o=Sl(r),a=o in Dy;typeof n=="string"?e[o]=a?n:vi(n):typeof n=="number"||typeof n=="boolean"?e[o]=n:Array.isArray(n)?e[o]=n.map(s=>typeof s=="string"?a?s:vi(s):String(s)).join(", "):typeof n=="object"?e[o]=JSON.stringify(n):e[o]=String(n)}}return e}function xy(t,e){const r=Oy(t);Ly(r)||console.warn(`Event name "${t}" does not follow Title Case format. Normalized to "${r}".`);const n=e?Tl(e):void 0;cl.logEvent(r,n),bl(r,n)}const Wy=Object.freeze(Object.defineProperty({__proto__:null,AMPLITUDE_FAILURE_EVENTS:yl,GTMPlugin:ll,analytics:cl,dualWriteFailureToSentry:bl,normalizeProperties:Tl,normalizePropertyValue:vi,toSnakeCase:Sl,trackEvent:xy},Symbol.toStringTag,{value:"Module"}));
13export{cl as a,Cy as c,ue as g,Wy as i,Qu as o,xy as t};

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.