PageSourceSearch

https://vaktex.com/_app/immutable/chunks/C4PZ0-G2.js

js vaktex.com collected 2026-10-09 22:55:40 UTC 414,812 bytes, 12 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/_app/immutable/chunks/DKluN0jK.js","/_app/immutable/chunks/C53aWnzr.js","/_app/immutable/chunks/GFFeWM2w.js"])))=>i.map(i=>d[i]);
2(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`d3d7f33885ffe420ffaed73d5934e4a2be1856ef`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`2644faf6-9fd2-471c-81e5-cdeb5a1cf8be`,e._sentryDebugIdIdentifier=`sentry-dbid-2644faf6-9fd2-471c-81e5-cdeb5a1cf8be`)}catch{}})();import{t as e}from"./DEFapqXe.js";import{a as t,c as n,i as r,n as i,o as a,r as o,s,t as c}from"./C53aWnzr.js";var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),g=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e},v=(e,t,n)=>(n=e==null?{}:l(p(e)),_(t||!e||!e.__esModule||!m.call(e,`default`)?u(n,`default`,{value:e,enumerable:!0}):n,e)),y;(function(e){e.SET=`$set`,e.SET_ONCE=`$setOnce`,e.ADD=`$add`,e.APPEND=`$append`,e.PREPEND=`$prepend`,e.REMOVE=`$remove`,e.PREINSERT=`$preInsert`,e.POSTINSERT=`$postInsert`,e.UNSET=`$unset`,e.CLEAR_ALL=`$clearAll`})(y||={});var b;(function(e){e.IDENTIFY=`$identify`,e.GROUP_IDENTIFY=`$groupidentify`,e.REVENUE=`revenue_amount`})(b||={});var x=`AMP_unsent`,S=`$default_instance`,C=`https://api2.amplitude.com/2/httpapi`,w=`https://api.eu.amplitude.com/2/httpapi`,T=`https://api2.amplitude.com/batch`,E=`https://api.eu.amplitude.com/batch`,D=`utm_campaign`,O=`utm_content`,k=`utm_id`,A=`utm_medium`,j=`utm_source`,M=`utm_term`,N=`dclid`,ee=`fbclid`,P=`gbraid`,F=`gclid`,te=`ko_click_id`,ne=`li_fat_id`,re=`msclkid`,ie=`rdt_cid`,I=`ttclid`,ae=`twclid`,oe=`wbraid`,se={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},L=`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`.split(`.`),ce=[`authorization`,`cookie`,`set-cookie`],le=1e3,ue=function(e){if(Object.keys(e).length>le)return!1;for(var t in e){var n=e[t];if(!de(t,n))return!1}return!0},de=function(e,t){var r,i;if(typeof e!=`string`)return!1;if(Array.isArray(t)){var a=!0;try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var c=s.value;if(Array.isArray(c))return!1;if(typeof c==`object`)a&&=ue(c);else if(![`number`,`string`].includes(typeof c))return!1;if(!a)return!1}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}else if(t==null)return!1;else if(typeof t==`object`)return ue(t);else if(![`number`,`string`,`boolean`].includes(typeof t))return!1;return!0},fe=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return c({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(R.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(R.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(R.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(R.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(R.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(R.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(R.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(R.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(R.UNSET,e,`-`),this},e.prototype.clearAll=function(){return this._properties={},this._properties[R.CLEAR_ALL]=`-`,this}
2,e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return r===void 0&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return this._properties[R.CLEAR_ALL]!==void 0||this._propertySet.has(t)?!1:e===R.ADD?typeof n==`number`:e!==R.UNSET&&e!==R.REMOVE?de(t,n):!0},e}(),R;(function(e){e.SET=`$set`,e.SET_ONCE=`$setOnce`,e.ADD=`$add`,e.APPEND=`$append`,e.PREPEND=`$prepend`,e.REMOVE=`$remove`,e.PREINSERT=`$preInsert`,e.POSTINSERT=`$postInsert`,e.UNSET=`$unset`,e.CLEAR_ALL=`$clearAll`})(R||={});var pe=[R.CLEAR_ALL,R.UNSET,R.SET,R.SET_ONCE,R.ADD,R.APPEND,R.PREPEND,R.PREINSERT,R.POSTINSERT,R.REMOVE],me=`Event tracked successfully`,he=`Unexpected error occurred`,ge=`Event rejected due to exceeded retry count`,_e=`Event skipped due to optOut config`,ve=`Event skipped due to empty event type`,ye=`Event rejected due to missing API key`,be=`Client not initialized`,z;(function(e){e.Unknown=`unknown`,e.Skipped=`skipped`,e.Success=`success`,e.RateLimit=`rate_limit`,e.PayloadTooLarge=`payload_too_large`,e.Invalid=`invalid`,e.Failed=`failed`,e.Timeout=`Timeout`,e.SystemError=`SystemError`})(z||={});var xe=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=z.Unknown),{event:e,code:t,message:n}},B=function(){var e=`ampIntegrationContext`;if(typeof globalThis<`u`&&globalThis[e]!==void 0)return globalThis[e];if(typeof globalThis<`u`)return globalThis;if(typeof window<`u`)return window;if(typeof self<`u`)return self;if(typeof global<`u`)return global},Se=function(e){return e?(e^Math.random()*16>>e/4).toString(16):`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,we)},Ce=s([],t(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,`0`)}),we=function(e){var n=B();if(!n?.crypto?.getRandomValues)return Se(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,s([],t(r.entries()),!1).map(function(e){var n=t(e,2),r=n[0],i=n[1];return[4,6,8,10].includes(r)?`-${Ce[i]}`:Ce[i]}).join(``)},Te=v(h(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e){return`[Throws: `+(e?e.message:`?`)+`]`}function i(e,t){if(n.call(e,t))try{return e[t]}catch(e){return r(e)}return e[t]}function a(e){var t=[];function n(e){if(typeof e!=`object`||!e)return e;if(t.indexOf(e)!==-1)return`[Circular]`;if(t.push(e),typeof e.toJSON==`function`)try{var a=n(e.toJSON());return t.pop(),a}catch(e){return r(e)}if(Array.isArray(e)){var o=e.map(n);return t.pop(),o}var s=Object.keys(e).reduce(function(t,r){return t[r]=n(i(e,r)),t},{});return t.pop(),s}return n(e)}t.exports=function(e,t,n){return JSON.stringify(a(e),t,n)},t.exports.ensureProperties=a}))()),Ee=Te.default||Te,De=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return e.prototype.register=function(e,t){return i(this,void 0,void 0,function(){var n;return r(this,function(r){switch(r.label){case 0:return e.name===void 0&&(e.name=we(),this.loggerProvider.warn(`Plugin name is undefined.
3      Generating a random UUID for plugin name: ${e.name}.
4      Set a name for the plugin to prevent it from being added multiple times.`)),n=e.name,this.pluginStatus.has(n)?(this.loggerProvider.warn(`Plugin with name ${n} already exists, skipping registration`),[2]):(e.type=e.type??`enrichment`,this.pluginStatus.set(n,`locked`),[4,e.setup?.call(e,t,this.client)]);case 1:return r.sent(),this.pluginStatus.get(n)===`locked`?(this.plugins.push(e),this.pluginStatus.set(n,`installed`),[2]):[2]}})})},e.prototype.deregister=function(e,t){return i(this,void 0,void 0,function(){var n,i;return r(this,function(r){switch(r.label){case 0:return this.pluginStatus.delete(e),n=this.plugins.findIndex(function(t){return t.name===e}),n===-1?(t.loggerProvider.warn(`Plugin with name ${e} does not exist, skipping deregistration`),[2]):(i=this.plugins[n],this.plugins.splice(n,1),[4,i.teardown?.call(i)]);case 1:return r.sent(),[2]}})})},e.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1,this.plugins.map(function(e){return e.teardown?.call(e)}),this.plugins=[],this.pluginStatus.clear(),this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(n){t.queue.push([e,n]),t.scheduleApply(0)})},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout(function(){t.apply(t.queue.shift()).then(function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)})},e))},e.prototype.apply=function(e){return i(this,void 0,void 0,function(){var i,a,o,s,l,u,d,f,p,m,h,g,_,f,p,v,y,b,x,S,C,w;return r(this,function(r){switch(r.label){case 0:if(!e)return[2];i=t(e,1),a=i[0],o=t(e,2),s=o[1],this.loggerProvider.log(`Timeline.apply: Initial event`,a),l=this.plugins.filter(function(e){return e.type===`before`}),r.label=1;case 1:r.trys.push([1,6,7,8]),u=n(l),d=u.next(),r.label=2;case 2:return d.done?[3,5]:(f=d.value,f.execute?[4,f.execute(c({},a))]:[3,4]);case 3:if(p=r.sent(),p===null)return this.loggerProvider.log(`Timeline.apply: Event filtered out by before plugin '${String(f.name)}', event: ${Ee(a)}`),s({event:a,code:0,message:``}),[2];a=p,this.loggerProvider.log(`Timeline.apply: Event after before plugin '${String(f.name)}', event: ${Ee(a)}`),r.label=4;case 4:return d=u.next(),[3,2];case 5:return[3,8];case 6:return m=r.sent(),x={error:m},[3,8];case 7:try{d&&!d.done&&(S=u.return)&&S.call(u)}finally{if(x)throw x.error}
4return[7];case 8:h=this.plugins.filter(function(e){return e.type===`enrichment`||e.type===void 0}),r.label=9;case 9:r.trys.push([9,14,15,16]),g=n(h),_=g.next(),r.label=10;case 10:return _.done?[3,13]:(f=_.value,f.execute?[4,f.execute(c({},a))]:[3,12]);case 11:if(p=r.sent(),p===null)return this.loggerProvider.log(`Timeline.apply: Event filtered out by enrichment plugin '${String(f.name)}', event: ${Ee(a)}`),s({event:a,code:0,message:``}),[2];a=p,this.loggerProvider.log(`Timeline.apply: Event after enrichment plugin '${String(f.name)}', event: ${Ee(a)}`),r.label=12;case 12:return _=g.next(),[3,10];case 13:return[3,16];case 14:return v=r.sent(),C={error:v},[3,16];case 15:try{_&&!_.done&&(w=g.return)&&w.call(g)}finally{if(C)throw C.error}return[7];case 16:return y=this.plugins.filter(function(e){return e.type===`destination`}),this.loggerProvider.log(`Timeline.apply: Final event before destinations, event: ${Ee(a)}`),b=y.map(function(e){var t=c({},a);return e.execute(t).catch(function(e){return xe(t,0,String(e))})}),Promise.all(b).then(function(e){var n=t(e,1)[0]||xe(a,100,`Event not tracked, no destination plugins on the instance`);s(n)}),[2]}})})},e.prototype.flush=function(){return i(this,void 0,void 0,function(){var e,t,n,i=this;return r(this,function(r){switch(r.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return i.apply(e)}))];case 1:return r.sent(),t=this.plugins.filter(function(e){return e.type===`destination`}),n=t.map(function(e){return e.flush&&e.flush()}),[4,Promise.all(n)];case 2:return r.sent(),[2]}})})},e.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},e.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(t){var n;(n=t.onIdentityChanged)==null||n.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var n;(n=t.onSessionIdChanged)==null||n.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var n;(n=t.onOptOutChanged)==null||n.call(t,e)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return i(this,void 0,void 0,function(){var t,i,a,o,s,c,l;return r(this,function(r){switch(r.label){case 0:r.trys.push([0,7,8,9]),t=n(this._optOutListeners),i=t.next(),r.label=1;case 1:if(i.done)return[3,6];a=i.value,r.label=2;case 2:return r.trys.push([2,4,,5]),[4,a(e)];case 3:return r.sent(),[3,5];case 4:return o=r.sent(),this.loggerProvider.error(`Error calling optOut listener`,o),[3,5];case 5:return i=t.next(),[3,1];case 6:return[3,9];case 7:return s=r.sent(),c={error:s},[3,9];case 8:try{i&&!i.done&&(l=t.return)&&l.call(t)}finally{if(c)throw c.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;(t=e.onReset)==null||t.call(e)})},e}(),Oe=function(e,t,n){return c(c(c({},typeof e==`string`?{event_type:e}:e),n),t&&{event_properties:t})},ke=function(e,t){return c(c({},t),{event_type:b.IDENTIFY,user_properties:e.getUserProperties()})},Ae=function(e,t,n,r){var i;return c(c({},r),{event_type:b.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})},je=function(e,t,n){var r,i=new fe;return i.set(e,t),c(c({},n),{event_type:b.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})},Me=function(e,t){return c(c({},t),{event_type:b.REVENUE,event_properties:e.getEventProperties()})},V=function(e){return{promise:e||Promise.resolve()}},Ne=function(){function e(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 De(this),this.name=e}return e.prototype._init=function(e){return i(this,void 0,void 0,function(){var t=this;return r(this,function(n){switch(n.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions(`q`,function(){return t.isReady=!0})];case 1:return n.sent(),[2]}})})},e.prototype.runQueuedFunctions=function(e,t){return i(this,void 0,void 0,function(){var i,a,o,s,c,l,u,d;return r(this,function(r){switch(r.label){case 0:i=this[e],this[e]=[],r.label=1;case 1:r.trys.push([1,8,9,10]),a=n(i),o=a.next(),r.label=2;case 2:return o.done?[3,7]:(s=o.value,c=s(),c&&`promise`in c?[4,c.promise]:[3,4]);case 3:return r.sent(),[3,6];case 4:return[4,c];case 5:r.sent(),r.label=6;case 6:return o=a.next(),[3,2];case 7:return[3,10];case 8:return l=r.sent(),u={error:l},[3,10];case 9:try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(u)throw u.error}
4return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e,t)]:[3,12];case 11:return r.sent(),[3,13];case 12:t?.(),r.label=13;case 13:return[2]}})})},e.prototype.track=function(e,t,n){var r=Oe(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),V(this.dispatch(r))},e.prototype.identify=function(e,t){var n=ke(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),V(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=Ae(e,t,n,r);return V(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=je(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),V(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=Me(e,t);return V(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),V())},e.prototype._addPlugin=function(e){return V(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),V())},e.prototype._removePlugin=function(e){return V(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(xe(e,0,be));this.process(e).then(t)},e.prototype.dispatch=function(e){return i(this,void 0,void 0,function(){var t=this;return r(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))})]})})},e.prototype.getOperationAppliedUserProperties=function(e){var t=this.userProperties??{},n=c({},t);if(e===void 0)return n;var r={};return Object.keys(e).forEach(function(t){Object.values(y).includes(t)||(r[t]=e[t])}),pe.forEach(function(t){if(Object.keys(e).includes(t)){var r=e[t];switch(t){case y.CLEAR_ALL:Object.keys(n).forEach(function(e){delete n[e]});break;case y.UNSET:Object.keys(r).forEach(function(e){delete n[e]});break;case y.SET:Object.assign(n,r)}}}),Object.assign(n,r),n},e.prototype.process=function(e){return i(this,void 0,void 0,function(){var t,n,i,a,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.config.optOut?[2,xe(e,0,_e)]:(t=e.event_type,typeof t!=`string`||t.trim().length===0?(this.config.loggerProvider.error(ve),[2,xe(e,0,ve)]):(e.event_type===b.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]));case 1:return n=r.sent(),n.code===200?this.config.loggerProvider.log(n.message):n.code===100?this.config.loggerProvider.warn(n.message):this.config.loggerProvider.error(n.message),[2,n];case 2:return i=r.sent(),a=String(i),this.config.loggerProvider.error(a),n=xe(e,0,a),[2,n];case 3:return[2]}})})},e.prototype.setOptOut=function(e){if(!this.isReady){this.q.push(this._setOptOut.bind(this,!!e));return}this._setOptOut(e)},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=!!e,this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return V(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find(function(t){return t.name===e});if(t===void 0){this.config.loggerProvider.debug(`Cannot find plugin with name ${e}`);return}return t},e.prototype.plugins=function(e){return this.timeline.plugins.filter(function(t){return t instanceof e})},e}(),Pe=function(){function e(){this.productId=``,this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){try{var t=JSON.parse(JSON.stringify(e));ue(t)&&(this.properties=t)}catch{}return this},e.prototype.getEventProperties=function(){var e=this.properties?c({},this.properties):{};return e[Fe.REVENUE_PRODUCT_ID]=this.productId,e[Fe.REVENUE_QUANTITY]=this.quantity,e[Fe.REVENUE_PRICE]=this.price,e[Fe.REVENUE_TYPE]=this.revenueType,e[Fe.REVENUE_CURRENCY]=this.currency,e[Fe.REVENUE]=this.revenue,e[Fe.RECEIPT]=this.receipt,e[Fe.RECEIPT_SIG]=this.receiptSig,e},e}(),Fe;(function(e){e.REVENUE_PRODUCT_ID=`$productId`,e.REVENUE_QUANTITY=`$quantity`,e.REVENUE_PRICE=`$price`,e.REVENUE_TYPE=`$revenueType`,e.REVENUE_CURRENCY=`$currency`,e.REVENUE=`$revenue`,e.RECEIPT=`$receipt`,e.RECEIPT_SIG=`$receiptSig`})(Fe||={});var Ie=function(e,t){var n=Math.max(t,1);return e.reduce(function(e,t,r){var i=Math.floor(r/n);return e[i]||(e[i]=[]),e[i].push(t),e},[])},Le;(function(e){e[e.None=0]=`None`,e[e.Error=1]=`Error`,e[e.Warn=2]=`Warn`,e[e.Verbose=3]=`Verbose`,e[e.Debug=4]=`Debug`})(Le||={});var Re=`Amplitude Logger `,ze=function(){function e(){this.logLevel=Le.None}return e.prototype.disable=function(){this.logLevel=Le.None},e.prototype.enable=function(e){e===void 0&&(e=Le.Warn),this.logLevel=e},e.prototype.log=function(){var e=[...arguments];this.logLevel<Le.Verbose||console.log(`${Re}[Log]: ${e.join(` `)}`)},e.prototype.warn=function(){var e=[...arguments];this.logLevel<Le.Warn||console.warn(`${Re}[Warn]: ${e.join(` `)}`)},e.prototype.error=function(){var e=[...arguments];this.logLevel<Le.Error||console.error(`${Re}[Error]: ${e.join(` `)}`)},e.prototype.debug=function(){var e=[...arguments];this.logLevel<Le.Debug||console.log(`${Re}[Debug]: ${e.join(` `)}`)},e}(),Be=function(e){return e===void 0||e===``?S:e},Ve=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:S,logLevel:Le.Warn,loggerProvider:new ze,offline:!1,optOut:!1,serverUrl:C,serverZone:`US`,useBatch:!1}},He=function(){function e(e){this._optOut=!1;var t=Ve();this.apiKey=e.apiKey,this.flushIntervalMillis=e.flushIntervalMillis??t.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||t.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||t.flushQueueSize,this.instanceName=Be(e.instanceName),this.loggerProvider=e.loggerProvider||t.loggerProvider,this.logLevel=e.logLevel??t.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=e.offline===void 0?t.offline:e.offline,this.optOut=e.optOut??t.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||t.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=e.useBatch??t.useBatch,this.loggerProvider.enable(this.logLevel);var n=We(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=n.serverZone,this.serverUrl=n.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
4,enumerable:!1,configurable:!0}),e}(),Ue=function(e,t){return e===`EU`?t?E:w:t?T:C},We=function(e,t,n){if(e===void 0&&(e=``),t===void 0&&(t=Ve().serverZone),n===void 0&&(n=Ve().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=[`US`,`EU`].includes(t)?t:Ve().serverZone;return{serverZone:r,serverUrl:Ue(r,n)}},Ge=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function Ke(e){return e>=200&&e<300}var qe=function(e){return e===void 0&&(e=0),(Error().stack||``).split(`
5`).slice(2+e).map(function(e){return e.trim()})},H=function(e){return function(){var t=c({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},Je=function(e,t){var r,i;t=t.replace(/\[(\w+)\]/g,`.$1`),t=t.replace(/^\./,``);try{for(var a=n(t.split(`.`)),o=a.next();!o.done;o=a.next()){var s=o.value;if(s in e)e=e[s];else return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e},U=function(e,t){return function(){var r,i,a={};try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var c=s.value;a[c]=Je(e,c)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}},W=function(e,t,n,r,i){return i===void 0&&(i=null),function(){var a=[...arguments],o=n(),s=o.logger,c=o.logLevel;if(c&&c<Le.Debug||!c||!s)return e.apply(i,a);var l={type:`invoke public method`,name:t,args:a,stacktrace:qe(1),time:{start:new Date().toISOString()},states:{}};r&&l.states&&(l.states.before=r());var u=e.apply(i,a);return u&&u.promise?u.promise.then(function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=new Date().toISOString()),s.debug(JSON.stringify(l,null,2))}):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=new Date().toISOString()),s.debug(JSON.stringify(l,null,2))),u}},Ye=new Set([C,w,T,E]),Xe=function(e,t){return t===void 0&&(t=!1),Ye.has(e)?!0:t};function Ze(e){return e instanceof Error?e.message:String(e)}function Qe(e){var t=``;try{`body`in e&&(t=JSON.stringify(e.body,null,2))}catch{}return t}var $e=function(){function e(e){this.name=`amplitude`,this.type=`destination`,this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey=``,this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=e?.diagnosticsClient}return e.prototype.setup=function(e){return i(this,void 0,void 0,function(){var t,n=this;return r(this,function(r){switch(r.label){case 0:return this.config=e,this.storageKey=`${x}_${this.config.apiKey.substring(0,10)}`,[4,this.config.storageProvider?.get(this.storageKey)];case 1:return t=r.sent(),t&&t.length>0&&Promise.all(t.map(function(e){return n.execute(e)})).catch(),[2,Promise.resolve(void 0)]}})})},e.prototype.execute=function(e){var t=this;return e.insert_id||=we(),new Promise(function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter(function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,ge),!1)})},e.prototype.scheduleEvents=function(e){var t=this;e.forEach(function(e){t.schedule(e.timeout===0?t.config.flushIntervalMillis:e.timeout)})},e.prototype.schedule=function(e){var t=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(){t.queue=t.queue.map(function(e){return e.timeout=0,e}),t.flush(!0)},e);return}},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return e===void 0&&(e=!1),i(this,void 0,void 0,function(){var t,n,a,o=this;return r(this,function(s){switch(s.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(),t=[],n=[],this.queue.forEach(function(e){return e.timeout===0?t.push(e):n.push(e)}),a=Ie(t,this.config.flushQueueSize),[4,a.reduce(function(t,n){return i(o,void 0,void 0,function(){return r(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}})})},Promise.resolve())]);case 1:return s.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},e.prototype.send=function(e,t){var n;return t===void 0&&(t=!0),i(this,void 0,void 0,function(){var i,o,s,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,ye)];i={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,a(t,[`extra`])}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new Ge,r.label=1;case 1:return r.trys.push([1,3,,4]),o=We(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,s=Xe(o,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(o,i,s)];case 2:return c=r.sent(),c===null?(this.fulfillRequest(e,0,he),[2]):t?(this.handleResponse(c,e),[3,4]):(`body`in c?this.fulfillRequest(e,c.statusCode,`${c.status}: ${Qe(c)}`):this.fulfillRequest(e,c.statusCode,c.status),[2]);case 3:return l=r.sent(),u=Ze(l),this.config.loggerProvider.error(u),(n=this.diagnosticsClient)==null||n.recordEvent(`anal
5ytics.events.unsuccessful.from.catch.error`,{events:e.map(function(e){return e.event.event_type}),message:u,stack_trace:qe()}),this.handleResponse({status:z.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},e.prototype.handleResponse=function(e,t){var n;Ke(e.statusCode)||(n=this.diagnosticsClient)==null||n.recordEvent(`analytics.events.unsuccessful`,{events:t.map(function(e){return e.event.event_type}),code:e.statusCode,status:e.status,body:Qe(e),stack_trace:qe()});var r=e.status;switch(r){case z.Success:this.handleSuccessResponse(e,t);break;case z.Invalid:this.handleInvalidResponse(e,t);break;case z.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case z.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn(`{code: 0, error: "Status '${r}' provided for ${t.length} events"}`),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,me)},e.prototype.handleInvalidResponse=function(e,n){var r=this;if(e.body.missingField||e.body.error.startsWith(`Invalid API key`)){this.fulfillRequest(n,e.statusCode,e.body.error);return}var i=s(s(s(s([],t(Object.values(e.body.eventsWithInvalidFields)),!1),t(Object.values(e.body.eventsWithMissingFields)),!1),t(Object.values(e.body.eventsWithInvalidIdLengths)),!1),t(e.body.silencedEvents),!1).flat(),a=new Set(i),o=n.filter(function(t,n){if(a.has(n)){r.fulfillRequest([t],e.statusCode,e.body.error);return}return!0});o.length>0&&this.config.loggerProvider.warn(Qe(e));var c=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(c)},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(t.length===1){this.fulfillRequest(t,e.statusCode,e.body.error);return}this.config.loggerProvider.warn(Qe(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),a=e.body.throttledEvents,o=new Set(r),s=new Set(i),c=new Set(a),l=t.filter(function(t,r){if(t.event.user_id&&o.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)){n.fulfillRequest([t],e.statusCode,e.body.error);return}return c.has(r)&&(t.timeout=n.throttleTimeout),!0});l.length>0&&this.config.loggerProvider.warn(Qe(e));var u=this.removeEventsExceedFlushMaxRetries(l);this.scheduleEvents(u)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map(function(e){return e.timeout=e.attempts*t.retryTimeout,e}),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,a;Ke(t)?(a=this.diagnosticsClient)==null||a.increment(`analytics.events.sent`,e.length):((r=this.diagnosticsClient)==null||r.increment(`analytics.events.dropped`,e.length),(i=this.diagnosticsClient)==null||i.recordEvent(`analytics.events.dropped`,{events:e.map(function(e){return e.event.event_type}),code:t,message:n,stack_trace:qe()})),this.removeEvents(e),e.forEach(function(e){return e.callback(xe(e.event,t,n))})},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(e){return e.event});this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(t){return!e.some(function(e){return e.event.insert_id===t.event.insert_id})}),this.saveEvents()},e}(),et=class{getApplicationContext(){return{versionName:this.versionName,language:tt(),platform:`Web`,os:void 0,deviceModel:void 0}}},tt=()=>typeof navigator<`u`&&(navigator.languages&&navigator.languages[0]||navigator.language)||``,nt=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(t=>{e(t)}),this.queue=[])}},rt=(e,t)=>{let n=[`string`,`number`,`boolean`,`undefined`],r=typeof e;if(r!==typeof t)return!1;for(let i of n)if(i===r)return e===t;if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;let i=Array.isArray(e),a=Array.isArray(t);if(i!==a)return!1;if(i&&a){for(let n=0;n<e.length;n++)if(!rt(e[n],t[n]))return!1}else{if(!rt(Object.keys(e).sort(),Object.keys(t).sort()))return!1;let n=!0;return Object.keys(e).forEach(r=>{rt(e[r],t[r])||(n=!1)}),n}return!0},it=`$set`,at=`$unset`,ot=`$clearAll`;Object.entries||(Object.entries=function(e){let t=Object.keys(e),n=t.length,r=Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r});var st=class{constructor(){this.identity={userProperties:{}},this.listeners=new Set}editIdentity(){let e=this,t=Object.assign({},this.identity.userProperties),n=Object.assign(Object.assign({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut(e){return n.optOut=e,this},updateUserProperties:function(e){let t=n.userProperties||{};for(let[n,r]of Object.entries(e))switch(n){case it:for(let[e,n]of Object.entries(r))t[e]=n;break;case at:for(let e of Object.keys(r))delete t[e];break;case ot:t={}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}}getIdentity(){return Object.assign({},this.identity)}setIdentity(e){let t=Object.assign({},this.identity);this.identity=Object.assign({}
5,e),rt(t,this.identity)||this.listeners.forEach(t=>{t(e)})}addIdentityListener(e){this.listeners.add(e)}removeIdentityListener(e){this.listeners.delete(e)}},ct=typeof globalThis<`u`?globalThis:typeof global<`u`?global:self,lt=class e{constructor(){this.identityStore=new st,this.eventBridge=new nt,this.applicationContextProvider=new et}static getInstance(t){return ct.analyticsConnectorInstances||={},ct.analyticsConnectorInstances[t]||(ct.analyticsConnectorInstances[t]=new e),ct.analyticsConnectorInstances[t]}},ut=function(e){return lt.getInstance(Be(e))},dt=function(e,t){ut(t).identityStore.editIdentity().setUserId(e).commit()},ft=function(e,t){ut(t).identityStore.editIdentity().setDeviceId(e).commit()},pt=function(){function e(){this.name=`identity`,this.type=`before`,this.identityStore=ut().identityStore}return e.prototype.execute=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){return t=e.user_properties,t&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return i(this,void 0,void 0,function(){return r(this,function(t){return e.instanceName&&(this.identityStore=ut(e.instanceName).identityStore),[2]})})},e}(),mt=function(e,t){return t===void 0&&(t=Date.now()),Date.now()-t>e},ht=function(e,t,n){return t===void 0&&(t=``),n===void 0&&(n=10),[`AMP`,t,e.substring(0,n)].filter(Boolean).join(`_`)},gt=function(e){return`amp_${e.substring(0,6)}`},_t=function(){if(typeof navigator>`u`)return``;var e=navigator.userLanguage;return navigator.languages?.[0]??navigator.language??e??``},vt=function(){var e=B();return e?.location?.search?e.location.search.substring(1).split(`&`).filter(Boolean).reduce(function(e,t){var n=t.split(`=`,2),r=yt(n[0]),i=yt(n[1]);return i&&(e[r]=i),e},{}):{}},yt=function(e){e===void 0&&(e=``);try{return decodeURIComponent(e)}catch{return``}},bt=function(e,t){return!t||!t.length||t.some(function(t){return typeof t==`string`?e===t:e.match(t)})},xt=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){t?.error(`Malformed URI sequence: `,e)}return n},St=function(e){var t=0;if(e.length===0)return t;for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);t=(t<<5)-t+r,t|=0}return t},Ct=function(e,t){var n=St(e.toString());return Math.abs(n)*31%1e5/1e5<t},wt=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Tt=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return i(this,void 0,void 0,function(){return r(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return t=n.sent(),[2,t?JSON.stringify(t):void 0]}})})},e.prototype.set=function(e,t){return i(this,void 0,void 0,function(){return r(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return i(this,void 0,void 0,function(){return r(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),Et=function(){return B()?.navigator?.locks},Dt=function(){function e(e,t){t===void 0&&(t={}),this.options=c({},e),this.config=t}return e.prototype.isEnabled=function(){return i(this,void 0,void 0,function(){var t,n,i,a,o=this;return r(this,function(r){switch(r.label){case 0:return t=`AMP_TEST`,n=c({},this.options),i=new e(n),a=String(Date.now()),[4,i.transaction(t,function(e){var n,r;try{e.set(a);var i=e.get()===a;return!i&&o.config.diagnosticsClient&&((n=o.config.diagnosticsClient)==null||n.recordEvent(`cookies.isEnabled.failure`,{reason:`Test Value mismatch`,testKey:t,testValue:a,sync:!0})),i}catch(e){if(o.config.diagnosticsClient){var s=e instanceof Error?e.message:String(e);(r=o.config.diagnosticsClient)==null||r.recordEvent(`cookies.isEnabled.failure`,{reason:`Cookie getter/setter failed`,testKey:t,testValue:a,error:s,sync:!0})}return!1}
5finally{e.set(null)}})];case 1:return[2,r.sent()]}})})},e.prototype.get=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}})})},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=At(t);if(n===void 0){console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${e}, value: ${t}`);return}return JSON.parse(n)}catch{console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${e}, value: ${t}`);return}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,a;return i(this,void 0,void 0,function(){var i,o,s,c,l,u,d,f,p;return r(this,function(r){switch(r.label){case 0:i=B(),o=i,r.label=1;case 1:return r.trys.push([1,4,,5]),s=o?.cookieStore,s?[4,s.getAll(e)]:[3,3];case 2:if(c=r.sent(),c){c.length>1&&((t=this.config.diagnosticsClient)==null||t.recordEvent(`cookies.duplicate`,{cookies:c.map(function(e){return e.domain})}),(a=this.config.diagnosticsClient)==null||a.increment(`cookies.duplicate.occurrence.cookieStore`));try{for(l=n(c),u=l.next();!u.done;u=l.next())if(d=u.value,jt(d.domain,this.options.domain))return[2,d.value]}catch(e){f={error:e}}finally{try{u&&!u.done&&(p=l.return)&&p.call(l)}finally{if(f)throw f.error}}}r.label=3;case 3:return[3,5];case 4:return r.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t=this,n=((B()?.document)?.cookie.split(`; `)??[]).filter(function(t){return t.indexOf(e+`=`)===0}),r=void 0,i=this.config.duplicateResolverFn;if(typeof i==`function`&&n.length>1&&(r=n.find(function(n){var r;try{var a=i(n.substring(e.length+1));return a||(r=t.config.diagnosticsClient)==null||r.increment(`cookies.duplicate.occurrence.document.cookie`),a}catch{return!1}})),r||=n[0],r)return r.substring(e.length+1)},e.prototype.set=function(e,t){return i(this,void 0,void 0,function(){return r(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){try{var n=B();if(!n||!n.document||typeof n.btoa!=`function`||typeof n.encodeURIComponent!=`function`)return;var r=this.options.expirationDays??0,i=t===null?-1:r,a=void 0;if(i){var o=new Date;o.setTime(o.getTime()+i*24*60*60*1e3),a=o}var s=`${e}=${n.btoa(n.encodeURIComponent(JSON.stringify(t)))}`;a&&(s+=`; expires=${a.toUTCString()}`),s+=`; path=/`,this.options.domain&&(s+=`; domain=${this.options.domain}`),this.options.secure&&(s+=`; Secure`),this.options.sameSite&&(s+=`; SameSite=${this.options.sameSite}`),n.document.cookie=s}catch(t){var c=t instanceof Error?t.message:String(t);console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${e}. Error: ${c}`)}},e.prototype.remove=function(e){return i(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}})})},e.prototype.reset=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return[2]})})},e.isDomainWritable=function(t){return i(this,void 0,void 0,function(){var n,i,a,o;return r(this,function(r){switch(r.label){case 0:if(e.cachedTlds[t])return[2,!0];n={domain:`.`+t},i=`AMP_TLDTEST`,a=new e(n),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,a.transaction(i,function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}})];case 2:return o=r.sent(),[2,!!o];case 3:return r.sent(),[2,!1];case 4:return[2]}})})},e.prototype.transaction=function(e,t){return i(this,void 0,void 0,function(){var n,i,a=this;return r(this,function(r){switch(r.label){case 0:if(n=Et(),i=function(){return t({get:function(){return a.getSync(e)},set:function(t){return a.setSync(e,t)}})},!n)return[2,i()];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.request(`com.amplitude:cookie-lock:${e}`,i)];case 2:return[2,r.sent()];case 3:return r.sent(),[2,i()];case 4:return[2]}})})},e.cachedTlds={},e}(),Ot=function(e){try{return decodeURIComponent(atob(e))}catch{return}},kt=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch{return}},At=function(e){return Ot(e)??kt(e)},jt=function(e,t){if(e===``&&t===``)return!0;
5if(!e||!t)return!1;var n=e.startsWith(`.`)?e.substring(1):e,r=t.startsWith(`.`)?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},Mt=function(e,t,n){return t===void 0&&(t=``),n===void 0&&(n=10),[`AMP`,t,e.substring(0,n)].filter(Boolean).join(`_`)},Nt=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return i(this,void 0,void 0,function(){var t,n,i,a;return r(this,function(r){switch(r.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),i=`AMP_TEST`,r.label=1;case 1:return r.trys.push([1,4,5,7]),[4,n.set(i,t)];case 2:return r.sent(),[4,n.get(i)];case 3:return a=r.sent(),[2,a===t];case 4:return r.sent(),[2,!1];case 5:return[4,n.remove(i)];case 6:return r.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return t=n.sent(),t?[2,JSON.parse(t)]:[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]}})})},e.prototype.getRaw=function(e){return i(this,void 0,void 0,function(){return r(this,function(t){return[2,this.storage?.getItem(e)||void 0]})})},e.prototype.set=function(e,t){var n;return i(this,void 0,void 0,function(){return r(this,function(r){try{(n=this.storage)==null||n.setItem(e,JSON.stringify(t))}catch{}return[2]})})},e.prototype.remove=function(e){var t;return i(this,void 0,void 0,function(){return r(this,function(n){try{(t=this.storage)==null||t.removeItem(e)}catch{}return[2]})})},e.prototype.reset=function(){var e;return i(this,void 0,void 0,function(){return r(this,function(t){try{(e=this.storage)==null||e.clear()}catch{}return[2]})})},e}(),Pt=10,Ft=1,G={TAGS:`tags`,COUNTERS:`counters`,HISTOGRAMS:`histograms`,EVENTS:`events`,INTERNAL:`internal`},It={LAST_FLUSH_TIMESTAMP:`last_flush_timestamp`},Lt=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName=`AMP_diagnostics_${e.substring(0,10)}`}return e.isSupported=function(){return B()?.indexedDB!==void 0},e.prototype.getDB=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return this.dbPromise||=this.openDB(),[2,this.dbPromise]})})},e.prototype.openDB=function(){var e=this;return new Promise(function(t,n){var r=indexedDB.open(e.dbName,Ft);r.onerror=function(){e.dbPromise=null,n(Error(`Failed to open IndexedDB`))},r.onsuccess=function(){var n=r.result;
5n.onclose=function(){e.dbPromise=null,e.logger.debug(`DiagnosticsStorage: DB connection closed.`)},n.onerror=function(t){e.logger.debug(`DiagnosticsStorage: A global database error occurred.`,t),n.close()},t(n)},r.onupgradeneeded=function(){var t=r.result;if(!t){e.logger.debug(`DiagnosticsStorage: Missing DB during upgrade.`);return}e.createTables(t)}})},e.prototype.createTables=function(e){e.objectStoreNames.contains(G.TAGS)||e.createObjectStore(G.TAGS,{keyPath:`key`}),e.objectStoreNames.contains(G.COUNTERS)||e.createObjectStore(G.COUNTERS,{keyPath:`key`}),e.objectStoreNames.contains(G.HISTOGRAMS)||e.createObjectStore(G.HISTOGRAMS,{keyPath:`key`}),e.objectStoreNames.contains(G.EVENTS)||e.createObjectStore(G.EVENTS,{keyPath:`id`,autoIncrement:!0}).createIndex(`time_idx`,`time`,{unique:!1}),e.objectStoreNames.contains(G.INTERNAL)||e.createObjectStore(G.INTERNAL,{keyPath:`key`})},e.prototype.setTags=function(e){return i(this,void 0,void 0,function(){var n,i,a,o,s=this;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return n=r.sent(),i=n.transaction([G.TAGS],`readwrite`),a=i.objectStore(G.TAGS),[2,new Promise(function(n){var r=Object.entries(e);i.oncomplete=function(){n()},i.onabort=function(e){s.logger.debug(`DiagnosticsStorage: Failed to set tags`,e),n()},r.forEach(function(e){var n=t(e,2),r=n[0],i=n[1],o=a.put({key:r,value:i});o.onerror=function(e){s.logger.debug(`DiagnosticsStorage: Failed to set tag`,r,i,e)}})})];case 2:return o=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set tags`,o),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return i(this,void 0,void 0,function(){var n,i,a,o,s=this;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return n=r.sent(),i=n.transaction([G.COUNTERS],`readwrite`),a=i.objectStore(G.COUNTERS),[2,new Promise(function(n){var r=Object.entries(e);i.oncomplete=function(){n()},i.onabort=function(e){s.logger.debug(`DiagnosticsStorage: Failed to increment counters`,e),n()},r.forEach(function(e){var n=t(e,2),r=n[0],i=n[1],o=a.get(r);o.onsuccess=function(){var e=o.result,t=e?e.value:0,n=a.put({key:r,value:t+i});n.onerror=function(e){s.logger.debug(`DiagnosticsStorage: Failed to update counter`,r,e)}},o.onerror=function(e){s.logger.debug(`DiagnosticsStorage: Failed to read existing counter`,r,e)}})})];case 2:return o=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to increment counters`,o),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return i(this,void 0,void 0,function(){var n,i,a,o,s=this;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return n=r.sent(),i=n.transaction([G.HISTOGRAMS],`readwrite`),a=i.objectStore(G.HISTOGRAMS),[2,new Promise(function(n){var r=Object.entries(e);i.oncomplete=function(){n()},i.onabort=function(e){s.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,e),n()},r.forEach(function(e){var n=t(e,2),r=n[0],i=n[1],o=a.get(r);o.onsuccess=function(){var e=o.result,t=e?{key:r,count:e.count+i.count,min:Math.min(e.min,i.min),max:Math.max(e.max,i.max),sum:e.sum+i.sum}:{key:r,count:i.count,min:i.min,max:i.max,sum:i.sum},n=a.put(t);n.onerror=function(e){s.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,r,e)}},o.onerror=function(e){s.logger.debug(`DiagnosticsStorage: Failed to read existing histogram stats`,r,e)}})})];case 2:return o=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,o),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return i(this,void 0,void 0,function(){var t,n,i,a,o=this;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e.length===0?[2]:[4,this.getDB()];case 1:return t=r.sent(),n=t.transaction([G.EVENTS],`readwrite`),i=n.objectStore(G.EVENTS),[2,new Promise(function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug(`DiagnosticsStorage: Failed to add event records`,e),t()};var r=i.count();r.onsuccess=function(){var t=r.result,n=Math.max(0,Pt-t);n<e.length&&o.logger.debug(`DiagnosticsStorage: Only added ${n} of ${e.length}
5 events due to storage limit`),e.slice(0,n).forEach(function(e){var t=i.add(e);t.onerror=function(e){o.logger.debug(`DiagnosticsStorage: Failed to add event record`,e)}})},r.onerror=function(e){o.logger.debug(`DiagnosticsStorage: Failed to count existing events`,e)}})];case 2:return a=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to add event records`,a),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return i(this,void 0,void 0,function(){var n,i,a,o;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=r.sent(),i=n.transaction([G.INTERNAL],`readwrite`),a=i.objectStore(G.INTERNAL),[2,new Promise(function(n,r){i.onabort=function(){return r(Error(`Failed to set internal value`))};var o=a.put({key:e,value:t});o.onsuccess=function(){return n()},o.onerror=function(){return r(Error(`Failed to set internal value`))}})];case 2:return o=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set internal value`,o),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return i(this,void 0,void 0,function(){var t,n,i,a;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=r.sent(),n=t.transaction([G.INTERNAL],`readonly`),i=n.objectStore(G.INTERNAL),[2,new Promise(function(t,r){n.onabort=function(){return r(Error(`Failed to get internal value`))};var a=i.get(e);a.onsuccess=function(){return t(a.result)},a.onerror=function(){return r(Error(`Failed to get internal value`))}})];case 2:return a=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to get internal value`,a),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return i(this,void 0,void 0,function(){var e,t;return r(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(It.LAST_FLUSH_TIMESTAMP)];case 1:return e=n.sent(),[2,e?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug(`DiagnosticsStorage: Failed to get last flush timestamp`,t),[2,void 0];case 3:return[2]}})})},e.prototype.setLastFlushTimestamp=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(It.LAST_FLUSH_TIMESTAMP,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set last flush timestamp`,t),[3,3];case 3:return[2]}})})},e.prototype.clearTable=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(Error(`Failed to clear table ${t}`))}})},e.prototype.getAllAndClear=function(){return i(this,void 0,void 0,function(){var e,n,i,a,o,s,c,l;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=r.sent(),n=e.transaction([G.TAGS,G.COUNTERS,G.HISTOGRAMS,G.EVENTS],`readwrite`),[4,Promise.all([this.getAllFromStore(n,G.TAGS),this.getAllFromStore(n,G.COUNTERS),this.getAllFromStore(n,G.HISTOGRAMS),this.getAllFromStore(n,G.EVENTS)])];case 2:return i=t.apply(void 0,[r.sent(),4]),a=i[0],o=i[1],s=i[2],c=i[3],[4,Promise.all([this.clearTable(n,G.COUNTERS),this.clearTable(n,G.HISTOGRAMS),this.clearTable(n,G.EVENTS)])];case 3:return r.sent(),[2,{tags:a,counters:o,histogramStats:s,events:c}];case 4:return l=r.sent(),this.logger.debug(`DiagnosticsStorage: Failed to get all and clear data`,l),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(Error(`Failed to get all from ${t}`))}})},e}(),Rt=`__AMPLITUDE_SCRIPT_URL__`,zt=`sdk.error.uncaught`,Bt=function(){var e=B();if(!e)return[];var t=e[Rt];return Array.isArray(t)?t:typeof t==`string`?[t]:[]},Vt=function(e){var t=B();if(t&&typeof t.addEventListener==`function`){var n=function(e){var t=e.error instanceof Error?e.error:void 0,n=t?.stack,r=Ht({filename:e.filename,stack:n});r&&i({type:`error`,message:e.message,stack:n,filename:e.filename,errorName:t?.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:r}})},r=function(e){var t=e.reason instanceof Error?e.reason:void 0,n=t?.stack,r=Ut(n),a=Ht({filename:r,stack:n});a&&i({type:`unhandledrejection`,message:t?.message??Wt(e.reason),stack:n,filename:r,errorName:t?.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})},i=function(t){e.recordEvent(zt,c({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};
5t.addEventListener(`error`,n,!0),t.addEventListener(`unhandledrejection`,r,!0)}},Ht=function(e){var t,r,i=Bt();if(i.length!==0)try{for(var a=n(i),o=a.next();!o.done;o=a.next()){var s=o.value;if(e.filename&&e.filename.includes(s))return`filename`;if(e.stack&&e.stack.includes(s))return`stack`}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}},Ut=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},Wt=function(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return`[object Object]`}},Gt=1e3,Kt=3e5,qt=`https://diagnostics.prod.us-west-2.amplitude.com/v1/capture`,Jt=`https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture`,Yt=function(){function e(e,t,n,r,i){n===void 0&&(n=`US`),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl=n===`US`?qt:Jt,this.logger.debug(`DiagnosticsClient: Initializing with options`,JSON.stringify(r,null,2)),this.config=c({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Ct(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,i?this.storage=i:Lt.isSupported()?this.storage=new Lt(e,t):this.logger.debug(`DiagnosticsClient: IndexedDB is not supported`),this.initializeFlushInterval(),this.shouldTrack&&(this.increment(`sdk.diagnostics.sampled.in.and.enabled`),Vt(this))}return e.prototype.isStorageAndTrackEnabled=function(){return!!this.storage&&!!this.shouldTrack},e.prototype.setTag=function(e,t){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryTags).length>=1e4){this.logger.debug(`DiagnosticsClient: Early return setTags as reaching memory limit`);return}this.inMemoryTags[e]=t,this.startTimersIfNeeded()}},e.prototype.increment=function(e,t){if(t===void 0&&(t=1),this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryCounters).length>=1e4){this.logger.debug(`DiagnosticsClient: Early return increment as reaching memory limit`);return}this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()}},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryHistograms).length>=1e4){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,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){if(this.isStorageAndTrackEnabled()){if(this.inMemoryEvents.length>=10){this.logger.debug(`DiagnosticsClient: Early return recordEvent as reaching memory limit`);return}this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()}},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||=setTimeout(function(){e.saveAllDataToStorage().catch(function(t){e.logger.debug(`DiagnosticsClient: Failed to save all data to storage`,t)}).finally(function(){e.saveTimer=null})},Gt),this.flushTimer||=setTimeout(function(){e._flush().catch(function(t){e.logger.debug(`DiagnosticsClient: Failed to flush`,t)}).finally(function(){e.flushTimer=null})},Kt)},e.prototype.saveAllDataToStorage=function(){return i(this,void 0,void 0,function(){var e,n,i,a;return r(this,function(r){switch(r.label){case 0:return this.storage?(e=c({},this.inMemoryTags),n=c({},this.inMemoryCounters),i=c({},this.inMemoryHistograms),a=s([],t(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(n),this.storage.setHistogramStats(i),this.storage.addEventRecords(a)])]):[2];case 1:return r.sent(),[2]}})})},e.prototype._flush=function(){return i(this,void 0,void 0,function(){var e,t,n,i,a,o,s,c,l,u;return r(this,function(r){switch(r.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return r.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=r.sent(),t=e.tags,n=e.counters,i=e.histogramStats,a=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={}
5,n.forEach(function(e){s[e.key]=e.value}),c={},i.forEach(function(e){c[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),l=a.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),Object.keys(s).length===0&&Object.keys(c).length===0&&l.length===0?[2]:(u={tags:o,histogram:c,counters:s,events:l},this.fetch(u),[2])}})})},e.prototype.fetch=function(e){return i(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),!B())throw Error(`DiagnosticsClient: Fetch is not supported`);return[4,fetch(this.serverUrl,{method:`POST`,headers:{"X-ApiKey":this.apiKey,"Content-Type":`application/json`},body:JSON.stringify(e)})];case 1:return t=r.sent(),t.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=r.sent(),this.logger.debug(`DiagnosticsClient: Failed to send diagnostics data. `,n),[3,3];case 3:return[2]}})})},e.prototype.initializeFlushInterval=function(){return i(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return t=r.sent()||-1,t===-1?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(Kt),[2]):(n=e-t,n>=3e5?(this._flush(),[2]):(this._setFlushTimer(Kt-n),[2]))}})})},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout(function(){t._flush().catch(function(e){t.logger.debug(`DiagnosticsClient: Failed to flush`,e)}).finally(function(){t.flushTimer=null})},e)},e.prototype._setSampleRate=function(e){this.logger.debug(`DiagnosticsClient: Setting sample rate to`,e),this.config.sampleRate=e,this.shouldTrack=Ct(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug(`DiagnosticsClient: Should track is`,this.shouldTrack)},e}(),Xt=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){if(typeof e!=`object`)return null;var t=e.code||0,n=this.buildStatus(t);switch(n){case z.Success:return{status:n,statusCode:t,body:{eventsIngested:e.events_ingested??0,payloadSizeBytes:e.payload_size_bytes??0,serverUploadTime:e.server_upload_time??0}};case z.Invalid:return{status:n,statusCode:t,body:{error:e.error??``,missingField:e.missing_field??``,eventsWithInvalidFields:e.events_with_invalid_fields??{},eventsWithMissingFields:e.events_with_missing_fields??{},eventsWithInvalidIdLengths:e.events_with_invalid_id_lengths??{},epsThreshold:e.eps_threshold??0,exceededDailyQuotaDevices:e.exceeded_daily_quota_devices??{},silencedDevices:e.silenced_devices??[],silencedEvents:e.silenced_events??[],throttledDevices:e.throttled_devices??{},throttledEvents:e.throttled_events??[]}};case z.PayloadTooLarge:return{status:n,statusCode:t,body:{error:e.error??``}};case z.RateLimit:return{status:n,statusCode:t,body:{error:e.error??``,epsThreshold:e.eps_threshold??0,throttledDevices:e.throttled_devices??{},throttledUsers:e.throttled_users??{},exceededDailyQuotaDevices:e.exceeded_daily_quota_devices??{},exceededDailyQuotaUsers:e.exceeded_daily_quota_users??{},throttledEvents:e.throttled_events??[]}};case z.Timeout:default:return{status:n,statusCode:t}}},e.prototype.buildStatus=function(e){return Ke(e)?z.Success:e===429?z.RateLimit:e===413?z.PayloadTooLarge:e===408?z.Timeout:e>=400&&e<500?z.Invalid:e>=500?z.Failed:z.Unknown},e}(),Zt=function(e){o(t,e);function t(t){t===void 0&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return t.prototype.send=function(e,t){return i(this,void 0,void 0,function(){var n,i,a;return r(this,function(r){switch(r.label){case 0:if(typeof fetch>`u`)throw Error(`FetchTransport is not supported`);return n={headers:c({"Content-Type":`application/json`,Accept:`*/*`},this.customHeaders),body:JSON.stringify(t),method:`POST`},[4,fetch(e,n)];case 1:return i=r.sent(),[4,i.text()];case 2:a=r.sent();try{return[2,this.buildResponse(JSON.parse(a))]}catch{return[2,this.buildResponse({code:i.status})]}}})})},t}(Xt);function Qt(){return typeof CompressionStream<`u`}function $t(e){return i(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(t=CompressionStream,t===void 0)return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),n=new Blob([e]).stream().pipeThrough(new t(`gzip`)),[4,new Response(n).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}})})}var en=function(){function e(e,t){this.key=`AMP_remote_config_${e.substring(0,10)}`,this.logger=t;try{this.isSupported=typeof localStorage<`u`}catch(e){this.logger.debug(`Remote config localstorage failed to access: `,e),this.isSupported=!1}}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};if(!this.isSupported)return Promise.resolve(t);try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug(`Remote config localstorage failed to access: `,e),Promise.resolve(t)}if(e===null)return this.logger.debug(`Remote config localstorage gets null because the key does not exist`),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug(`Remote config localstorage parsed successfully: ${Ee(n)}`),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug(`Remote config localstorage failed to parse: `,e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){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(e){this.logger.debug(`Remote config localstorage failed to set: `,e)}return Promise.resolve(!1)},e}();function tn(e,t){return new Promise(function(n,r){var i=function(){var e=Error(`Remote config custom fetch aborted by timeout`);e.name=`AbortError`,r(e)};t.addEventListener(`abort`,i,{once:!0}),e.then(function(e){t.removeEventListener(`abort`,i),n(e)},function(e){t.removeEventListener(`abort`,i),r(e)})})}
5var nn={INVALID_API_KEY:401,FORBIDDEN:403,RATE_LIMIT:429},rn=1e3,an=3e5,on=function(){function e(t,n,r,i,a,o,s){r===void 0&&(r=`US`),o===void 0&&(o=e.DEFAULT_CONFIG_GROUP),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=t,this.configGroup=o,this.serverUrl=i||(r===`US`?`https://sr-client-cfg.amplitude.com/config`:`https://sr-client-cfg.eu.amplitude.com/config`),this.logger=n,this.storage=s||new en(t,n),this.customFetch=a}return e.prototype.subscribe=function(e,t,n){var r=we(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),t===`all`?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return t===-1?(this.logger.debug(`Remote config client unsubscribe failed because callback with id ${e} doesn't exist.`),!1):(this.callbackInfos.splice(t,1),this.logger.debug(`Remote config client unsubscribe succeeded removing callback with id ${e}.`),!0)},e.prototype.updateConfigs=function(){return i(this,void 0,void 0,function(){var e,t,n=this;return r(this,function(r){switch(r.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<an)?(this.logger.debug(`Remote config client skipping updateConfigs: Too recent`),[2]):[4,this.getOrCreateFetchPromise()];case 1:return t=r.sent(),this.storage.setConfig(t),this.callbackInfos.forEach(function(e){n.sendCallback(e,t,`remote`)}),[2]}})})},e.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(t){return t.remoteConfig!==null&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},e.prototype.subscribeAll=function(e){return i(this,void 0,void 0,function(){var t,n,i,a=this;return r(this,function(r){switch(r.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){a.logger.debug(`Remote config client subscription all mode fetched from remote: ${JSON.stringify(t)}`),a.sendCallback(e,t,`remote`),a.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return i=r.sent(),i!==void 0&&(this.logger.debug(`Remote config client subscription all mode fetched from cache: ${JSON.stringify(i)}`),i.remoteConfig===null?this.logger.debug(`Remote config client skips sending c
5allback because cache is empty (first time user).`):this.sendCallback(e,i,`cache`)),[4,t];case 2:return r.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return i(this,void 0,void 0,function(){var n,i,i;return r(this,function(r){switch(r.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n(`Timeout exceeded`)},t)}),r.label=1;case 1:return r.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return i=r.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 r.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=r.sent(),i.remoteConfig===null?(this.logger.debug(`Remote config client subscription wait for remote mode failed to fetch cache.`),this.sendCallback(e,i,`remote`)):(this.logger.debug(`Remote config client subscription wait for remote mode returns a cached copy.`),this.sendCallback(e,i,`cache`)),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){e.lastCallback=new Date;var r=e.key?e.key.split(`.`).reduce(function(e,t){return e===null?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig;e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return e===void 0&&(e=3),t===void 0&&(t=rn),i(this,void 0,void 0,function(){var n,i,a,o,s,c,l=this;return r(this,function(u){switch(u.label){case 0:n=t/e,i={remoteConfig:null,lastFetch:new Date},a=function(i){var a,s,c,u,d,f,p,m,h,g,_;return r(this,function(r){switch(r.label){case 0:a=!0,s=new AbortController,c=setTimeout(function(){return s.abort()},t),r.label=1;case 1:return r.trys.push([1,10,11,12]),u=o.getUrlParams(),d={Accept:`*/*`},o.customFetch?[4,tn(o.customFetch({url:u,method:`GET`,headers:d,signal:s.signal}),s.signal)]:[3,3];case 2:return p=r.sent(),[3,5];case 3:return[4,fetch(u,{method:`GET`,headers:d,signal:s.signal})];case 4:p=r.sent(),r.label=5;case 5:return f=p,m=f.ok||f.status>=200&&f.status<300,m?[3,7]:[4,f.text()];case 6:return h=r.sent(),o.logger.debug(`Remote config client fetch with retry time ${e} failed with ${f.status}: ${h}`),f.status===nn.INVALID_API_KEY||f.status===nn.FORBIDDEN?(o.logger.error(`Remote config client fetch failed with ${f.status}. Invalid API key; future fetches will be skipped.`),o.isLastFetchInvalidApiKey=!0,a=!1):f.status>=400&&f.status<500&&f.status!==nn.RATE_LIMIT&&(a=!1),[3,9];case 7:return[4,f.json()];case 8:return g=r.sent(),[2,{value:{remoteConfig:g,lastFetch:new Date}}];case 9:return[3,12];case 10:return _=r.sent(),_ instanceof Error&&_.name===`AbortError`?o.logger.debug(`Remote config client fetch with retry time ${e} timed out after ${t}ms`):o.logger.debug(`Remote config client fetch with retry time ${e} is rejected because: `,_),[3,12];case 11:return clearTimeout(c),[7];case 12:return a?i<e-1?[4,new Promise(function(e){return setTimeout(e,l.getJitterDelay(n))})]:[3,14]:[2,`break`];case 13:r.sent(),r.label=14;case 14:return[2]}})},o=this,s=0,u.label=1;case 1:return s<e?[5,a(s)]:[3,4];case 2:if(c=u.sent(),typeof c==`object`)return[2,c.value];if(c===`break`)return[3,4];u.label=3;case 3:return s++,[3,1];case 4:return[2,i]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),t=new URLSearchParams;return t.append(`config_group`,this.configGroup),`${this.serverUrl}/${e}?${t.toString()}`},e.DEFAULT_CONFIG_GROUP=`browser`,e}(),sn=B()?.console,cn={},ln={},un=!1;function dn(e){return!sn||typeof sn[e]!=`function`?!1:ln[e]?!0:(ln[e]=sn[e],sn[e]=function(){var t=[...arguments];try{if(cn[e]&&!un){un=!0;var n=cn[e];n&&n.forEach(function(n){try{n(e,t)}catch{}})}}catch{}return un=!1,ln[e].apply(sn,t)},!0)}function fn(e,t){if(!dn(e))return Error(`Console override failed`);cn[e]?cn[e].push(t):cn[e]=[t]}function pn(e){var t,r;try{for(var i=n(Object.values(cn)),a=i.next();!a.done;a=i.next())for(var o=a.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}function mn(){var e,r;try{for(var i=n(Object.entries(ln)),a=i.next();!a.done;a=i.next()){var o=t(a.value,2),s=o[0],c=o[1];c&&(sn[s]=c)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}ln={},cn={}}var hn={addListener:fn,removeListener:pn,_restoreConsole:mn},gn;(function(e){e.US=`US`,e.EU=`EU`,e.STAGING=`STAGING`})(gn||={});var _n=[`a`,`button`,`input`,`select`,`textarea`,`label`,`video`,`audio`,`[contenteditable="true" i]`,`[data-amp-default-track]`,`.amp-default-track`],vn=`data-amp-track-`,yn=[`div`,`span`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],bn=s([`input[type="button"]`,`input[type="submit"]`,`input[type="reset"]`,`input[type="image"]`,`input[type="file"]`],t([`a`,`button`,`[role="button"]`,`[role="link"]`,`[role="menuitem"]`,`[role="menuitemcheckbox"]`,`[role="menuitemradio"]`,`[role="option"]`,`[role="tab"]`,`[role="treeitem"]`,`[contenteditable="true" i]`]),!1),xn=bn,Sn=bn,Cn=[`*`],wn=1e3;function Tn(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e==null}function En(e,t,n){e&&Dn({json:e,allowlist:t.map(On),excludelist:n.map(On),ancestors:[]})}function Dn(e){var r,i,a=e.json,o=e.targetObject,c=e.allowlist,l=e.excludelist,u=e.ancestors,d=e.parentObject,f=e.targetKey;o||=a;var p=Object.keys(o);try{for(var m=n(p),h=m.next();!h.done;h=m.next()){var g=h.value,_=s(s([],t(u),!1),[g],!1);Tn(o[g])?(!An(_,c)||An(_,l))&&delete o[g]:Dn({json:a,targetObject:o[g],allowlist:c,excludelist:l,ancestors:_,parentObject:o,targetKey:g})}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}Object.keys(o).length===0&&d&&f&&delete d[f]}function On(e){return e.startsWith(`/`)&&(e=e.slice(1)),e.split(`/`).map(function(e){return e.replace(/~0/g,`~`).replace(/~1/g,`/`)})}function kn(e,t,n,r){if(n===void 0&&(n=0),r===void 0&&(r=0),r===t.length)return n===e.length;if(n===e.length){for(;r<t.length&&t[r]===`**`;)r++;return r===t.length}var i=t[r];
5if(i===`**`){if(r+1===t.length)return!0;for(var a=n;a<=e.length;a++)if(kn(e,t,a,r+1))return!0;return!1}return i===`*`||i===e[n]?kn(e,t,n+1,r+1):!1}function An(e,t){return t.some(function(t){return kn(e,t)})}var jn=500,Mn=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var r,i;e===void 0&&(e=[]);var a=this.request.headers,o={};if(Array.isArray(a))a.forEach(function(e){var n=t(e,2),r=n[0];o[r]=n[1]});else if(a instanceof Headers)a.forEach(function(e,t){o[t]=e});else if(typeof a==`object`&&a)try{for(var s=n(Object.entries(a)),c=s.next();!c.done;c=s.next()){var l=t(c.value,2),u=l[0];o[u]=l[1]}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return Bn(o,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if(typeof this._bodySize==`number`)return this._bodySize;if(B()?.TextEncoder){var e=this.request.body;return this._bodySize=Pn(e,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return typeof this.request.body==`string`?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=[]),i(this,void 0,void 0,function(){var n;return r(this,function(r){return e.length===0?[2,null]:(n=this.body,[2,Ln(n,e,t)])})})},e}(),Nn=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return e===void 0&&(e=[]),Bn(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return Pn(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return typeof this.bodyRaw==`string`?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=[]),i(this,void 0,void 0,function(){var n;return r(this,function(r){return e.length===0?[2,null]:(n=this.body,[2,Ln(n,e,t)])})})},e}();function Pn(e,r){var i,a,o,s=B()?.TextEncoder;if(s&&e!=null){var c;if(typeof e==`string`)c=e,o=new s().encode(c).length;else if(typeof Blob<`u`&&e instanceof Blob)c=e,o=c.size;else if(typeof URLSearchParams<`u`&&e instanceof URLSearchParams)c=e,o=new s().encode(c.toString()).length;else if(ArrayBuffer.isView(e))c=e,o=c.byteLength;else if(e instanceof ArrayBuffer)c=e,o=c.byteLength;else if(typeof FormData<`u`&&e instanceof FormData){var l=e,u=0,d=0;try{for(var f=n(l.entries()),p=f.next();!p.done;p=f.next()){var m=t(p.value,2),h=m[0],g=m[1];if(u+=h.length,typeof g==`string`)u+=new s().encode(g).length;else if(typeof Blob<`u`&&g instanceof Blob)u+=g.size;else return;if(++d>=r)return}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}o=u}else if(typeof ReadableStream<`u`&&e instanceof ReadableStream){c=e;return}return o}}var Fn=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(e===void 0&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return(t=n?.forEach)==null||t.call(n,function(e,t){r[t]=e}),Bn(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e;if(this._bodySize!==void 0)return this._bodySize;var t=((e=this.response.headers)?.get)?.call(e,`content-length`),n=t?parseInt(t,10):void 0;return this._bodySize=n,n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return i(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:this.clonedResponse||=this.response.clone(),r.label=1;case 1:return r.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise(function(e){return setTimeout(function(){return e(null)},jn)}),[4,Promise.race([e,t])];case 2:return n=r.sent(),[2,n];case 3:return r.sent(),[2,null];case 4:return[2]}})})},e.prototype.json=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=[]),i(this,void 0,void 0,function(){var n;return r(this,function(r){switch(r.label){case 0:return e.length===0?[2,null]:[4,this.text()];case 1:return n=r.sent(),[2,Ln(n,e,t)]}})})},e}(),In=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size}
5,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var r,i;if(e===void 0&&(e=[]),!this.headersString)return{};var a={},o=this.headersString.split(`\r
6`);try{for(var s=n(o),c=s.next();!c.done;c=s.next()){var l=c.value,u=t(l.split(`: `),2),d=u[0],f=u[1];d&&f&&(a[d]=f)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return Bn(a,{allow:e})},e.prototype.json=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=[]),i(this,void 0,void 0,function(){var n;return r(this,function(r){return e.length===0?[2,null]:(n=this.getJson(),n?(En(n,e,t),[2,n]):[2,null])})})},e}();function Ln(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return En(r,t,n),r}catch{return null}}var Rn;(function(e){e.REDACT=`redact`,e.REMOVE=`remove`})(Rn||={});var zn=`[REDACTED]`,Bn=function(e,r){var i,a,o=r.allow,c=o===void 0?[]:o,l=r.strategy,u=l===void 0?Rn.REMOVE:l,d=s([],t(ce),!1),f={},p=function(t){var n=t.toLowerCase();d.find(function(e){return e.toLowerCase()===n})?u===Rn.REDACT&&(f[t]=zn):c.find(function(e){return e.toLowerCase()===n})?f[t]=e[t]:u===Rn.REDACT&&(f[t]=zn)};try{for(var m=n(Object.keys(e)),h=m.next();!h.done;h=m.next()){var g=h.value;p(g)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}return f},Vn=function(){function e(e,t,n,r,i,a,o,s,c,l,u){o===void 0&&(o=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=a,this.status=o,this.duration=s,this.responseWrapper=c,this.error=l,this.endTime=u}return e.prototype.toSerializable=function(){var e={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:this.requestWrapper?.headers(s([],t(L),!1)),requestBodySize:this.requestWrapper?.bodySize,responseHeaders:this.responseWrapper?.headers(s([],t(L),!1)),responseBodySize:this.responseWrapper?.bodySize};return Object.fromEntries(Object.entries(e).filter(function(e){var n=t(e,2);return n[0],n[1]!==void 0}))},e}();function Hn(e){return typeof e==`object`&&!!e&&`url`in e&&`method`in e}var Un=function(){function e(e,t){t===void 0&&(t=we()),this.callback=e,this.id=t}return e}();function Wn(e){try{e()}catch{}}var Gn=new(function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=B();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=B();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){if(this.logger||=t,this.eventCallbacks.set(e.id,e),!this.isObserving){var n=this.globalScope?.XMLHttpRequest?.prototype?.open,r=this.globalScope?.XMLHttpRequest?.prototype?.send,i=this.globalScope?.XMLHttpRequest?.prototype?.setRequestHeader;n&&r&&i&&this.observeXhr(n,r,i);var a=this.globalScope?.fetch;a&&this.observeFetch(a),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach(function(n){try{n.callback(e)}catch(e){Wn(function(){var n;(n=t.logger)==null||n.debug(`an unexpected error occurred while triggering event callbacks`,e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,a,o){if(a!==void 0&&o!==void 0){var s,c=`GET`;if(Hn(t)?(s=t.url,c=t.method):s=(t?.toString)?.call(t),s)try{var l=new URL(s);s=`${l.protocol}//${l.host}${l.pathname}${l.search}${l.hash}`}catch{}c=n?.method||c;var u,d;r&&(u=r.status),i&&(d={name:i.name||`UnknownError`,message:i.message||`An unknown error occurred`},u=0);var f=Math.floor(performance.now()-o),p=Math.floor(a+f),m=new Vn(e,c,a,a,s,n,u,f,r,d,p);this.triggerEventCallbacks(m)}},e.prototype.getTimestamps=function(){return{startTime:Date.now?.call(Date),durationStart:(performance==null?void 0:performance.now)?.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,a){return i(t,void 0,void 0,function(){var t,i,o,s,c=this;return r(this,function(r){switch(r.label){case 0:try{t=this.getTimestamps()}catch(e){Wn(function(){return c.logger?.debug(`an unexpected error occurred while retrieving timestamps`,e)})}r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e(n,a)];case 2:return i=r.sent(),[3,4];case 3:return s=r.sent(),o=s,[3,4];case 4:try{this.handleNetworkRequestEvent(`fetch`,n,a?new Mn(a):void 0,i?new Fn(i):void 0,o,t?.startTime,t?.durationStart)}catch(e){Wn(function(){return c.logger?.debug(`an unexpected error occurred while handling fetch`,e)})}if(i)return[2,i];throw o}})})})},e.createXhrJsonParser=function(e,t){return function(){try{if(e.responseType===`json`){if(t.globalScope?.structuredClone)return t.globalScope.structuredClone(e.response)}else if([`text`,``].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&n.name===`InvalidStateError`&&Wn(function(){return t.logger?.debug(`unexpected error when retrieving responseText. responseType='${e.responseType}'`)}),null}return null}},e.prototype.observeXhr=function(n,r,i){if(this.globalScope&&n&&r){var a=this.globalScope.XMLHttpRequest.prototype,o=this;a.open=function(){var e=[...arguments],r=this,i=t(e,2),a=i[0],s=i[1];try{r.$$AmplitudeAnalyticsEvent=c({method:a,url:(s?.toString)?.call(s),headers:{}},o.getTimestamps())}catch(e){Wn(function(){return o.logger?.debug(`an unexpected error occurred while calling xhr open`,e)})}return n.apply(r,e)},a.send=function(){var t=[...arguments],n=this,i=n,a=e.createXhrJsonParser(n,o),s=t[0],c=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener(`loadend`,function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader(`content-length`),n=new In(i.status,e,t?parseInt(t,10):void 0,a),r=i.$$AmplitudeAnalyticsEvent.headers,l=new Nn(s,r);c.status=i.status,o.handleNetworkRequestEvent(`xhr`,{url:c.url,method:c.method},l,n,void 0,c.startTime,c.durationStart)}catch(e){Wn(function(){return o.logger?.debug(`an unexpected error occurred while handling xhr send`,e)}
6)}}),r.apply(i,t)},a.setRequestHeader=function(e,t){var n=this;try{var r=n.$$AmplitudeAnalyticsEvent;r&&(r.headers[e]=t)}catch(e){Wn(function(){return o.logger?.debug(`an unexpected error occurred while calling xhr setRequestHeader`,e)})}i.apply(n,[e,t])}}},e}()),Kn=function(e,t){return e?.map(function(e){if(e.urls?.length&&e.hosts?.length){var n=JSON.stringify(e.hosts),r=JSON.stringify(e.urls);return t?.warn(`Found network capture rule with both urls='${r}' and hosts='${n}' set. Definition of urls takes precedence over hosts, so ignoring hosts.`),c(c({},e),{hosts:void 0})}return e})},qn=function(){function e(){}return e.prototype.parse=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return[2,c(c(c(c({},se),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=vt();return{utm_campaign:e[D],utm_content:e[O],utm_id:e[k],utm_medium:e[A],utm_source:e[j],utm_term:e[M]}},e.prototype.getReferrer=function(){var e={referrer:void 0,referring_domain:void 0};try{e.referrer=document.referrer||void 0,e.referring_domain=e.referrer?.split(`/`)[2]??void 0}catch{}return e},e.prototype.getClickIds=function(){var e,t=vt();return e={},e[N]=t[N],e[ee]=t[ee],e[P]=t[P],e[F]=t[F],e[te]=t[te],e[ne]=t[ne],e[re]=t[re],e[ie]=t[ie],e[I]=t[I],e[ae]=t[ae],e[oe]=t[oe],e},e}(),Jn=`data-amp-mask`,Yn=`*****`,Xn=/\b(?:\d[ -]*?){13,16}\b/,Zn=/(\d{3}-?\d{2}-?\d{4})/g,Qn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,$n=function(e,t){var r,i;if(t===void 0&&(t=[]),typeof e!=`string`)return``;var a=e;a=a.replace(Xn,Yn),a=a.replace(Zn,Yn),a=a.replace(Qn,Yn);try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var c=s.value;try{a=a.replace(c,Yn)}catch{}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a},er=function(e){if(typeof document>`u`||!document.title)return``;var t=document.querySelector(`title`);return t&&t.hasAttribute(`data-amp-mask`)?Yn:e?e(document.title):document.title},tr=h((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Observable=void 0;var t=e=>!!Symbol[e],n=e=>t(e)?Symbol[e]:`@@`+e,r=n(`iterator`),i=n(`observable`),a=n(`species`);function o(e,t){let n=e[t];if(n!=null){if(typeof n!=`function`)throw TypeError(n+` is not a function`);return n}}function s(e){let t=e.constructor;return t!==void 0&&(t=t[a],t===null&&(t=void 0)),t===void 0?_:t}function c(e){return e instanceof _}function l(e){l.log?l.log(e):setTimeout(()=>{throw e})}function u(e){Promise.resolve().then(()=>{try{e()}catch(e){l(e)}})}function d(e){let t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,t))try{if(typeof t==`function`)t();else{let e=o(t,`unsubscribe`);e&&e.call(t)}}catch(e){l(e)}}function f(e){e._observer=void 0,e._queue=void 0,e._state=`closed`}function p(e){let t=e._queue;if(t){e._queue=void 0,e._state=`ready`;for(let n=0;n<t.length&&(m(e,t[n].type,t[n].value),e._state!==`closed`);++n);}}function m(e,t,n){e._state=`running`;let r=e._observer;try{let i=o(r,t);switch(t){case`next`:i&&i.call(r,n);break;case`error`:if(f(e),i)i.call(r,n);else throw n;break;case`complete`:f(e),i&&i.call(r)}}catch(e){l(e)}e._state===`closed`?d(e):e._state===`running`&&(e._state=`ready`)}function h(e,t,n){if(e._state!==`closed`){if(e._state===`buffering`){e._queue.push({type:t,value:n});return}if(e._state!==`ready`){e._state=`buffering`,e._queue=[{type:t,value:n}],u(()=>p(e));return}m(e,t,n)}}var g=class{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state=`initializing`;let n=this,r={get closed(){return n._state===`closed`},next(e){h(n,`next`,e)},error(e){h(n,`error`,e)},complete(){h(n,`complete`)}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}this._state===`initializing`&&(this._state=`ready`)}get closed(){return this._state===`closed`}unsubscribe(){this._state!==`closed`&&(f(this),d(this))}},_=class e{constructor(t){if(!(this instanceof e))throw TypeError(`Observable cannot be called as a function`);if(typeof t!=`function`)throw TypeError(`Observable initializer must be a function`);this._subscriber=t}subscribe(e){return(typeof e!=`object`||!e)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new g(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if(typeof e!=`function`){n(TypeError(e+` is not a function`));return}function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(s(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(s(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if(typeof e!=`function`)throw TypeError(e+` is not a function`);let t=s(this),n=arguments.length>1,r=!1,i=arguments[1];return new t(t=>this.subscribe({next(a){let o=!r;if(r=!0,!o||n)try{i=e(i,a)}catch(e){return t.error(e)}else i=a},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(TypeError(`Cannot reduce an empty sequence`));t.next(i),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=s(this);return new t(n=>{let r,i=0;function a(o){r=o.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):a(t.from(e[i++]))}})}return a(this),()=>{r&&=(r.unsubscribe(),void 0)}})}flatMap(e){if(typeof e!=`function`)throw TypeError(e+` is not a function`);let t=s(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let o=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(o);e>=0&&r.splice(e,1),a()}});r.push(o)},error(e){n.error(e)},complete(){a()}});function a(){i.closed&&r.length===0&&n.complete()}return()=>
6{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[i](){return this}static from(n){let a=typeof this==`function`?this:e;if(n==null)throw TypeError(n+` is not an object`);let s=o(n,i);if(s){let e=s.call(n);if(Object(e)!==e)throw TypeError(e+` is not an object`);return c(e)&&e.constructor===a?e:new a(t=>e.subscribe(t))}if(t(`iterator`)&&(s=o(n,r),s))return new a(e=>{u(()=>{if(!e.closed){for(let t of s.call(n))if(e.next(t),e.closed)return;e.complete()}})});if(Array.isArray(n))return new a(e=>{u(()=>{if(!e.closed){for(let t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}})});throw TypeError(n+` is not observable`)}static of(...t){return new(typeof this==`function`?this:e)(e=>{u(()=>{if(!e.closed){for(let n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})})}static get[a](){return this}};e.Observable=_,Object.defineProperty(_,Symbol(`extensions`),{value:{symbol:i,hostReportError:l},configurable:!0})})),K=v(h(((e,t)=>{t.exports=tr().Observable}))());function nr(e,t){return new K.default(function(n){e.subscribe({next:function(e){t(e).then(function(e){return n.next(e)}).catch(function(e){return n.error(e)})},error:function(e){n.error(e)},complete:function(){n.complete()}})})}function rr(e,t){return new K.default(function(r){var i=!1,a=new Set,o=function(){var e,t;i=!0;try{for(var r=n(a),o=r.next();!o.done;o=r.next()){var s=o.value;try{s.unsubscribe()}catch{}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}a.clear()},s=function(e){var t=e.subscribe({next:function(e){i||r.next(e)},error:function(e){i||(i=!0,r.error(e),o())},complete:function(){a.delete(t),!i&&a.size===0&&(r.complete(),o(),i=!0)}});a.add(t)};return s(e),s(t),o})}function ir(e){var t=new Set,r=null;function i(){r?.unsubscribe(),r=null,t.clear()}return new K.default(function(a){return t.add(a),r===null&&(r=e.subscribe({next:function(e){var r,i,a;try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var c=s.value;(a=c.next)==null||a.call(c,e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},error:function(e){var r,a,o;try{for(var s=n(t),c=s.next();!c.done;c=s.next()){var l=c.value;(o=l.error)==null||o.call(l,e)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}i()},complete:function(){var e,r,a;try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var c=s.value;(a=c.complete)==null||a.call(c)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}i()}})),function(){t.delete(a),t.size===0&&r&&(r.unsubscribe(),r=null)}})}var ar=`https://app.amplitude.com`,or={US:ar,EU:`https://app.eu.amplitude.com`,STAGING:`https://apps.stag2.amplitude.com`},sr=`https://cdn.amplitude.com/libs/background-capture-1.1.0.js.gz`,cr=function(e){return document.querySelector(`script[src="${CSS.escape(e)}"]`)?Promise.resolve({status:!0}):new Promise(function(t,n){var r;try{var i=document.createElement(`script`);i.type=`text/javascript`,i.async=!0,i.src=e,i.addEventListener(`load`,function(){t({status:!0})},{once:!0}),i.addEventListener(`error`,function(){n({status:!1,message:`Failed to load the script ${e}`})}),(r=document.head)==null||r.appendChild(i)}catch(e){n(e)}})};function lr(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}var ur,dr=`__AMPLITUDE_MESSENGER_INSTANCE__`,fr=`__AMPLITUDE_MESSENGER__`,pr=function(){function e(e){var t=(e===void 0?{}:e).origin,n=t===void 0?ar:t;this[ur]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;(n=(t=this.logger)?.debug)==null||n.call(t,`Message sent: `,JSON.stringify(e)),(i=(r=window.opener)?.postMessage)==null||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;n===void 0&&(n={timeout:15e3});var i=lr(),a={id:i,action:e,args:t};return new Promise(function(t,o){r.requestCallbacks[i]={resolve:t,reject:o},r.notify(a),n.timeout>0&&setTimeout(function(){o(Error(`${e} timed out (id: ${i})`)),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;if(!this.requestCallbacks[e.id]){(t=this.logger)==null||t.warn(`No callback found for request id: ${e.id}`);return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},e.prototype.registerActionHandler=function(e,t){var r,i,a,o;this.actionHandlers.has(e)&&((o=(a=this.logger)?.warn)==null||o.call(a,`Overwriting existing action handler for: ${e}`)),this.actionHandlers.set(e,t);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var c=n(s),l=c.next();!l.done;l=c.next()){var u=l.value;t(u)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}},e.prototype.loadScriptOnce=function(e){return i(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(t=this.scriptLoadPromises.get(e),t)return[2,t];n=cr(e).then(function(){}),this.scriptLoadPromises.set(e,n),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n];case 2:return r.sent(),[3,4];case 3:throw i=r.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},e.prototype.setup=function(e){var t=this,n,r,i=e===void 0?{}:e,a=i.logger,o=i.endpoint;a&&(this.logger=a),o&&this.endpoint===`https://app.amplitude.com`&&(this.endpoint=o
6),!this.isSetup&&(this.isSetup=!0,(r=(n=this.logger)?.debug)==null||r.call(n,`Setting up messenger`),this.messageHandler=function(e){var n,r,i,a;if((r=(n=t.logger)?.debug)==null||r.call(n,`Message received: `,JSON.stringify(e)),t.endpoint===e.origin){var o=e.data,s=o?.action;if(s){if(`id`in o&&o.id)(a=(i=t.logger)?.debug)==null||a.call(i,`Received Response to previous request: `,JSON.stringify(e)),t.handleResponse(o);else{if(s===`ping`){t.notify({action:`pong`});return}var c=t.actionHandlers.get(s);if(c)c(o.data);else{var l=t.pendingMessages.get(s)??[];l.push(o.data),t.pendingMessages.set(s,l)}}}}},window.addEventListener(`message`,this.messageHandler),this.notify({action:`page-loaded`}))},e.prototype.destroy=function(){this.messageHandler&&=(window.removeEventListener(`message`,this.messageHandler),null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=B();e?.[fr]===this&&delete e[fr]},e}();ur=dr;function mr(e){return typeof e==`object`&&!!e&&dr in e&&e[dr]===!0}function hr(e){var t=B(),n=t?.[fr];if(mr(n))return n;var r=new pr(e);return t&&(t[fr]=r),r}var gr=[`desktop`,`tablet`,`mobile`],_r=function(e){if(typeof e==`string`)return gr.includes(e)?e:void 0},vr=`__AMPLITUDE_BACKGROUND_CAPTURE__`;function yr(e,t){var n=e;if(n[vr]!==!0){n[vr]=!0;var r=t?.scriptUrl??sr,i=null,a=function(t,n){var r,i;t===`background-capture-complete`&&((i=(r=e.logger)?.debug)==null||i.call(r,`Background capture complete`),e.notify({action:`background-capture-complete`,data:n}))};e.registerActionHandler(`initialize-background-capture`,function(t){var n,o;(o=(n=e.logger)?.debug)==null||o.call(n,`Initializing background capture (external script)`);var s=new URL(r,e.endpoint).toString(),l=t&&typeof t==`object`?_r(t.deviceMode):void 0;e.loadScriptOnce(s).then(function(){var t,n;(n=(t=e.logger)?.debug)==null||n.call(t,`Background capture script loaded (external)`),i=(window==null?void 0:window.amplitudeBackgroundCapture)?.call(window,c({messenger:e,onBackgroundCapture:a},l===void 0?{}:{initialDeviceMode:l})),e.notify({action:`background-capture-loaded`})}).catch(function(){var t;(t=e.logger)==null||t.warn(`Failed to initialize background capture`)})}),e.registerActionHandler(`close-background-capture`,function(){var e;(e=i?.close)==null||e.call(i),i=null})}}var br={always:`always`,ifEmptyCampaign:`ifEmptyCampaign`};function xr(){return typeof B()?.chrome?.runtime?.id==`string`}function Sr(){return B()?.navigator?.product===`ReactNative`}function Cr(e,t,r){var i,a,o=[];try{for(var s=n(t??[]),c=s.next();!c.done;c=s.next()){var l=c.value;try{o.push(new RegExp(l))}catch(e){r.warn(`Invalid regex pattern: ${l}`,e)}}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return e.concat(o)}function wr(e,t){var r,i;if(typeof e==`object`&&e&&e.captureRules?.length){var a=c({},e),o=a.captureRules??[];try{for(var s=n(o),l=s.next();!l.done;l=s.next()){var u=l.value;u.urls=Cr(u.urls??[],u.urlsRegex,t),delete u.urlsRegex}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return a}}function Tr(e){var r,i,a,o,c,l;if(typeof e==`object`&&e&&!Array.isArray(e)){var u=Object.keys(e);try{for(var d=n(u),f=d.next();!f.done;f=d.next()){var p=f.value;try{var m=e[p];typeof m?.enabled==`boolean`&&(m.enabled?(delete m.enabled,Object.keys(m).length===0&&(e[p]=!0)):e[p]=!1),Tr(m)}catch{}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}try{if(e.autocapture?.networkTracking?.captureRules?.length)try{for(var h=n(e.autocapture.networkTracking.captureRules),g=h.next();!g.done;g=h.next()){var _=g.value;try{for(var v=(c=void 0,n([`responseHeaders`,`requestHeaders`])),y=v.next();!y.done;y=v.next()){var b=y.value,x=_[b]??{},S=x.captureSafeHeaders,C=x.allowlist;if(S||C){if(C!==void 0&&!Array.isArray(C)){delete _[b];continue}_[b]=s(s([],t(S?L:[]),!1),t(C??[]),!1)}}}catch(e){c={error:e}}finally{try{y&&!y.done&&(l=v.return)&&l.call(v)}finally{if(c)throw c.error}}}}catch(e){a={error:e}}finally{try{g&&!g.done&&(o=h.return)&&o.call(h)}finally{if(a)throw a.error}}}catch{}e.autocapture?.pageViews!==void 0&&(e.autocapture.screenViews=e.autocapture.pageViews);var w=e.autocapture?.frustrationInteractions;
6w&&(w.rageClick&&(w.rageClicks=w.rageClick,delete w.rageClick),w.deadClick&&(w.deadClicks=w.deadClick,delete w.deadClick));try{var T=e.autocapture?.elementInteractions;if(T&&typeof T==`object`&&(T.viewportContentUpdated===!0&&(T.viewportContentUpdated={}),T.viewportContentUpdated===!1&&(T.viewportContentUpdated={enabled:!1}),T.exposureDuration!==void 0)){var E=T.viewportContentUpdated;E===void 0?T.viewportContentUpdated={exposureDuration:T.exposureDuration}:typeof E==`object`&&E.exposureDuration===void 0&&E.enabled!==!1&&(E.exposureDuration=T.exposureDuration),delete T.exposureDuration}}catch{}}}var Er=function(e,t){return typeof e==`boolean`?e:e?.[t]===!1?!1:!xr()||!!e?.[t]},Dr=function(e){return Er(e,`attribution`)},Or=function(e){return Er(e,`fileDownloads`)},kr=function(e){return Er(e,`formInteractions`)},Ar=function(e){return Er(e,`pageViews`)},jr=function(e){return Er(e,`sessions`)},Mr=function(e){return Er(e,`pageUrlEnrichment`)},Nr=function(e){return typeof e==`boolean`?e:!(typeof e!=`object`||e.networkTracking!==!0&&typeof e.networkTracking!=`object`)},Pr=function(e){return typeof e==`boolean`?e:!(typeof e!=`object`||e.elementInteractions!==!0&&typeof e.elementInteractions!=`object`)},Fr=function(e){return typeof e==`boolean`?e:typeof e==`object`&&(e.webVitals===!0||typeof e.webVitals==`object`&&e.webVitals!==null)},Ir=function(e){if(typeof e.autocapture==`object`){var t=e.autocapture.webVitals;if(typeof t==`object`&&t)return t}},Lr=function(e){return typeof e==`boolean`?e:!(typeof e!=`object`||e.frustrationInteractions!==!0&&typeof e.frustrationInteractions!=`object`)},Rr=function(e){return!(typeof e!=`object`||e.performanceTracking!==!0&&typeof e.performanceTracking!=`object`)},zr=function(e){if(typeof e.autocapture==`object`){var t=e.autocapture.performanceTracking;if(t===!0)return{mainThreadBlock:!0};if(typeof t==`object`&&t)return t}},Br=function(e){return typeof e==`boolean`?e:!!(typeof e==`object`&&e&&e.enabled!==!1)},Vr=function(e){if(Pr(e.autocapture)&&typeof e.autocapture==`object`&&typeof e.autocapture.elementInteractions==`object`)return e.autocapture.elementInteractions},Hr=function(e){if(Lr(e.autocapture)&&typeof e.autocapture==`object`&&typeof e.autocapture.frustrationInteractions==`object`)return e.autocapture.frustrationInteractions},Ur=function(e){if(Nr(e.autocapture)){var t=void 0;return typeof e.autocapture==`object`&&typeof e.autocapture.networkTracking==`object`?t=e.autocapture.networkTracking:e.networkTrackingOptions&&(t=e.networkTrackingOptions),c(c({},t),{captureRules:Kn(t?.captureRules,e.loggerProvider)})}},Wr=function(e){var t=function(){return!1},n=void 0,r,i=e.pageCounter;return Ar(e.defaultTracking)&&(t=void 0,r=void 0,e.defaultTracking&&typeof e.defaultTracking==`object`&&e.defaultTracking.pageViews&&typeof e.defaultTracking.pageViews==`object`&&(`trackOn`in e.defaultTracking.pageViews&&(t=e.defaultTracking.pageViews.trackOn),`trackHistoryChanges`in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackHistoryChanges),`eventType`in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(r=e.defaultTracking.pageViews.eventType))),{trackOn:t,trackHistoryChanges:n,eventType:r,pageCounter:i}},Gr=function(e){return Dr(e.defaultTracking)&&e.defaultTracking&&typeof e.defaultTracking==`object`&&e.defaultTracking.attribution&&typeof e.defaultTracking.attribution==`object`?c({},e.defaultTracking.attribution):{}},Kr=function(e){if(kr(e.defaultTracking)&&e.defaultTracking&&typeof e.defaultTracking==`object`&&typeof e.defaultTracking.formInteractions==`object`)return e.defaultTracking.formInteractions},qr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,a=r.args,o=r.resolve,s=e&&e[i];if(typeof s==`function`){var c=s.apply(e,a);typeof o==`function`&&o(c?.promise)}}return e},Jr=function(e){var t=e;return t&&t._q!==void 0},Yr=function(e){return typeof e.chrome?.runtime?.id==`string`},Xr=function(e){var t=e.ServiceWorkerGlobalScope;return typeof t==`function`&&e instanceof t},Zr=function(e){var t=e.WorkerGlobalScope;return typeof t==`function`&&e instanceof t},Qr=function(e){return e.document!==void 0}
6,$r=function(e){return typeof e.process?.versions?.node==`string`};function ei(){var e=B();if(!e)return`unknown`;var t=Yr(e);return Xr(e)?t?`chrome_extension_service_worker`:`service_worker`:Zr(e)?`web_worker`:Qr(e)?t?`chrome_extension`:`browser`:$r(e)?`node`:`unknown`}var ti=`2.47.2`,ni=`amplitude-ts`,ri=`$remote`,ii=function(){function e(){this.name=`@amplitude/plugin-context-browser`,this.type=`before`,this.library=`${ni}/${ti}`,typeof navigator<`u`&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){return i(this,void 0,void 0,function(){var t,n,i,a;return r(this,function(r){return t=new Date().getTime(),n=this.config.lastEventId??-1,i=e.event_id??n+1,this.config.lastEventId=i,e.time||(this.config.lastEventTime=t),a=c(c(c(c(c(c(c(c({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:t},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:`Web`}),this.config.trackingOptions.language&&{language:_t()}),this.config.trackingOptions.ipAddress&&{ip:ri}),{insert_id:we(),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:i,library:this.library,user_agent:this.userAgent}),[2,a]})})},e}(),ai=1e3,oi=function(e){o(t,e);function t(t){var n=this,r,i;try{i=B()?.localStorage}catch(e){(r=t?.loggerProvider)==null||r.debug(`Failed to access localStorage. error=${JSON.stringify(e)}`),i=void 0}return n=e.call(this,i)||this,n.loggerProvider=t?.loggerProvider,n}return t.prototype.set=function(t,n){var a;return i(this,void 0,void 0,function(){var i;return r(this,function(r){switch(r.label){case 0:return Array.isArray(n)&&n.length>ai?(i=n.length-ai,[4,e.prototype.set.call(this,t,n.slice(0,ai))]):[3,2];case 1:return r.sent(),(a=this.loggerProvider)==null||a.error(`Failed to save ${i} events because the queue length exceeded ${ai}.`),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:r.sent(),r.label=4;case 4:return[2]}})})},t}(Nt),si=function(e){o(t,e);function t(){return e.call(this,B()?.sessionStorage)||this}return t}(Nt),ci=function(e){o(a,e);function a(t){t===void 0&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return a.prototype.send=function(e,a,o){return o===void 0&&(o=!1),i(this,void 0,void 0,function(){var s=this;return r(this,function(l){return[2,new Promise(function(l,u){typeof XMLHttpRequest>`u`&&u(Error(`XHRTransport is not supported.`));var d=new XMLHttpRequest;d.open(`POST`,e,!0),d.onreadystatechange=function(){if(d.readyState===s.state.done){var e=d.responseText;try{l(s.buildResponse(JSON.parse(e)))}catch{l(s.buildResponse({code:d.status}))}}};var f={"Content-Type":`application/json`,Accept:`*/*`},p=JSON.stringify(a),m=o&&p.length>=2048&&Qt(),h=function(e){var r,i;f=c(c({},s.customHeaders),f);try{for(var a=n(Object.entries(f)),o=a.next();!o.done;o=a.next()){var l=t(o.value,2),u=l[0],p=l[1];d.setRequestHeader(u,p)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}d.send(e)};(function(){return i(s,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return m?[4,$t(p)]:[3,2];case 1:return e=t.sent(),e?(f[`Content-Encoding`]=`gzip`,h(e)):h(p),[3,3];case 2:h(p),t.label=3;case 3:return[2]}})})})().catch(u)})]})})},a}(Xt),li=function(e){o(t,e);function t(t,n,r){t===void 0&&(t={});var i=e.call(this)||this;return i.customHeaders=t,i.enableKeepalive=n!==!1,i.referrerPolicy=r,i}return t.prototype.send=function(e,t,n){return n===void 0&&(n=!1),i(this,void 0,void 0,function(){var i,a,o,s,l,u,d,f,p;return r(this,function(r){switch(r.label){case 0:if(typeof fetch>`u`)throw Error(`FetchTransport is not supported`);return i=JSON.stringify(t),a=n&&i.length>=2048&&Qt(),o=i,s={"Content-Type":`application/json`,Accept:`*/*`},a?[4,$t(i)]:[3,2];case 1:l=r.sent(),l&&(s[`Content-Encoding`]=`gzip`,o=l),r.label=2;case 2:return s=c(c({},this.customHeaders),s),u=typeof o==`string`?o.length:o.byteLength,d={headers:s,body:o,method:`POST`,keepalive:this.enableKeepalive&&u<=16384},this.referrerPolicy&&(d.referrerPolicy=this.referrerPolicy),[4,fetch(e,d)];case 3:return f=r.sent(),[4,f.text()];case 4:p=r.sent();try{return[2,this.buildResponse(JSON.parse(p))]}catch{return[2,this.buildResponse({code:f.status})]}}})})},t}(Xt),ui=function(e){o(t,e);function t(){return e.call(this)||this}return t.prototype.send=function(e,t,n){return n===void 0&&(n=!1),i(this,void 0,void 0,function(){var n=this;return r(this,function(r){return[2,new Promise(function(r,i){var a=B();if(!a?.navigator.sendBeacon)throw Error(`SendBeaconTransport is not supported`);try{var o=JSON.stringify(t);return a.navigator.sendBeacon(e,o)?r(n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:o.length,server_upload_time:Date.now()})):r(n.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(Xt),di=function(e,n,a){return a===void 0&&(a=!0),i(void 0,void 0,void 0,function(){var i,o,s,c,l,u,d,f,p;return r(this,function(r){switch(r.label){case 0:return i=gt(e),[4,n.getRaw(i)];case 1:return o=r.sent(),o?a?[4,n.remove(i)]:[3,3]:[2,{optOut:!1}];case 2:r.sent(),r.label=3;case 3:return s=t(o.split(`.`),6),c=s[0],l=s[1],u=s[2],d=s[3],f=s[4],p=s[5],[2,{deviceId:c,userId:pi(l),sessionId:fi(d),lastEventId:fi(p),lastEventTime:fi(f),optOut:!!u}]}})})},fi=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},pi=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch{return}},mi=`[Amplitude]`;`${mi}`;var hi=`${mi} Form Started`,gi=`${mi} Form Submitted`,_i=`${mi}
6 File Downloaded`,vi=`session_start`,yi=`session_end`,bi=`${mi} File Extension`,xi=`${mi} File Name`,Si=`${mi} Link ID`,Ci=`${mi} Link Text`,wi=`${mi} Link URL`,Ti=`${mi} Form ID`,Ei=`${mi} Form Name`,Di=`${mi} Form Destination`,Oi=`cookie`,ki=g({DEFAULT_ACTION_CLICK_ALLOWLIST:()=>yn,DEFAULT_CSS_SELECTOR_ALLOWLIST:()=>_n,DEFAULT_DATA_ATTRIBUTE_PREFIX:()=>vn,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:()=>br,IdentifyOperation:()=>y,LogLevel:()=>Le,OfflineDisabled:()=>null,RevenueProperty:()=>Fe,ServerZone:()=>gn,SpecialEventType:()=>b}),Ai=function(e){var t=e.split(`.`);return t.length<=2?e:t.slice(t.length-2,t.length).join(`.`)},ji=function(e){return Object.values(e).every(function(e){return!e})},Mi=function(e){var t=c(c({},e),{referring_domain:void 0,referrer:void 0});return Object.values(t).every(function(e){return!e})},Ni=function(e,t,n,r,i,o){i===void 0&&(i=!0),e.referrer;var s=e.referring_domain,c=a(e,[`referrer`,`referring_domain`]),l=t||{};l.referrer;var u=l.referring_domain,d=a(l,[`referrer`,`referring_domain`]),f=n.excludeInternalReferrers;if(f){var p=Ri(f,r);if(!(p instanceof TypeError)&&e.referring_domain&&Hi(e.referring_domain,o)&&(p===`always`||p===`ifEmptyCampaign`&&Mi(e)))return zi(p,e.referring_domain,r),!1}if(Pi(n.excludeReferrers,e.referring_domain))return r.debug(`This is not a new campaign because ${e.referring_domain} is in the exclude referrer list.`),!1;if(!i&&ji(e)&&t)return r.debug(`This is not a new campaign because this is a direct traffic in the same session.`),!1;var m=JSON.stringify(c)!==JSON.stringify(d),h=Ai(s||``)!==Ai(u||``),g=!t||m||h;return g?r.debug(`This is a new campaign. An $identify event will be sent.`):r.debug(`This is not a new campaign because it's the same as the previous one.`),g},Pi=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=``),e.some(function(e){return e instanceof RegExp?e.test(t):e===t})},Fi=function(e,t){var n=t.startsWith(`.`)?t:`.${t}`;return!!(e.startsWith(`.`)?e:`.${e}`).endsWith(n)},Ii=function(e,n){var r=c(c({},se),e);return ke(Object.entries(r).reduce(function(e,r){var i=t(r,2),a=i[0],o=i[1];return e.setOnce(`initial_${a}`,o??n.initialEmptyValue??`EMPTY`),o?e.set(a,o):e.unset(a)},new fe))},Li=function(e){var t=e;return t?(t.startsWith(`.`)&&(t=t.substring(1)),[RegExp(`${t.replace(`.`,`\\.`)}$`)]):[]},Ri=function(e,t){if(e===!0)return br.always;if(typeof e==`object`){var n=e.condition;if(typeof n==`string`&&Object.keys(br).includes(n))return n;if(n===void 0)return br.always}var r=`Invalid configuration provided for attribution.excludeInternalReferrers: ${JSON.stringify(e)}`;return t.error(r),TypeError(r)};function zi(e,t,n){var r=`This is not a new campaign because referring_domain=${t} is on the same domain as the current page and it is configured to exclude internal referrers`;e===`always`?n.debug(r):e===`ifEmptyCampaign`&&n.debug(`${r} with empty campaign parameters`)}var Bi=`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`.split(`,`),Vi=function(e){var t=e||B()?.location?.hostname;if(!t)return``;var n=t.split(`.`),r=n[n.length-1],i=n[n.length-2];return Bi.find(function(e){return t.endsWith(`.${e}`)})&&(r=n[n.length-2]+`.`+n[n.length-1],i=n[n.length-3]),i?`${i}.${r}`:r},Hi=function(e,t){var n=B();return n?Fi(e,(t||``).trim()||Vi(n.location.hostname)):!1},Ui=function(e){o(t,e);function t(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,ee,P,F,te,ne,re,ie,I,ae,oe,se){r===void 0&&(r=new Tt),i===void 0&&(i={domain:``,expiration:365,sameSite:`Lax`,secure:!1,upgrade:!0}),c===void 0&&(c=1e3),l===void 0&&(l=5),u===void 0&&(u=30),d===void 0&&(d=Oi),g===void 0&&(g=new ze),_===void 0&&(_=Le.Warn),y===void 0&&(y=!1),b===void 0&&(b=!1),C===void 0&&(C=``),w===void 0&&(w=`US`),D===void 0&&(D=18e5),O===void 0&&(O=new oi({loggerProvider:g})),k===void 0&&(k={ipAddress:!0,language:!0,platform:!0}),A===void 0&&(A=`fetch`),j===void 0&&(j=!1),M===void 0&&(M=!0),ne===void 0&&(ne=!0),re===void 0&&(re=0),oe===void 0&&(oe=!1);var L=this;L=e.call(this,{apiKey:t,instanceName:p,storageProvider:O,transportProvider:qi(A)})||this,L.apiKey=t,L.appVersion=n,L.cookieOptions=i,L.defaultTracking=a,L.autocapture=o,L.flushIntervalMillis=c,L.flushMaxRetries=l,L.flushQueueSize=u,L.identityStorage=d,L.ingestionMetadata=f,L.loggerProvider=g,L.logLevel=_,L.minIdLength=v,L.offline=y,L.partnerId=x,L.plan=S,L.serverUrl=C,L.serverZone=w,L.sessionTimeout=D,L.storageProvider=O,L.trackingOptions=k,L.transport=A,L.useBatch=j,L.fetchRemoteConfig=M,L.networkTrackingOptions=F,L.identify=te,L.enableDiagnostics=ne,L.diagnosticsSampleRate=re,L.diagnosticsClient=ie,L.remoteConfig=I,L.topLevelDomain=ae,L.enableRequestBodyCompression=oe,L.customEnrichment=se,L.version=ti,L._optOut=!1,L._cookieStorage=r,L.deviceId=s,L.lastEventId=m,L.lastEventTime=h,L.optOut=b,L.deferredSessionId=E,L.sessionId=T,L.pageCounter=ee,L.userId=N,L.debugLogsEnabled=P,L.loggerProvider.enable(P?Le.Debug:L.logLevel),L.networkTrackingOptions=F,L.identify=te,L.enableDiagnostics=ne,L.diagnosticsSampleRate=re,L.diagnosticsClient=ie;var ce=I?.fetchRemoteConfig??M;return L.remoteConfig=L.remoteConfig||{},L.remoteConfig.fetchRemoteConfig=ce,L.fetchRemoteConfig=ce,L.topLevelDomain=ae||Vi(),L}return Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())}
6,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,e!==void 0&&this._deferredSessionId!==void 0&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof Dt&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(ht(this.apiKey),e)},t}(He),Wi=function(e,t,n,a,o){return t===void 0&&(t={}),i(void 0,void 0,void 0,function(){var i,s,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D;return r(this,function(r){switch(r.label){case 0:return i=t.identityStorage||`cookie`,s=``,i!==`cookie`||t.cookieOptions?.domain||t.cookieOptions?.domain===``?[3,2]:[4,Ji(void 0,a)];case 1:s=r.sent(),r.label=2;case 2:return l=c({domain:t.cookieOptions?.domain??s,expiration:365,sameSite:`Lax`,secure:!1,upgrade:!0},t.cookieOptions),u={duplicateResolverFn:function(e){var t=At(e);return t?jt(JSON.parse(t).cookieDomain,l.domain):!1},diagnosticsClient:a},d=Gi(t.identityStorage,l,u),[4,di(e,d,t.cookieOptions?.upgrade??!0)];case 3:return f=r.sent(),[4,d.get(ht(e))];case 4:return p=r.sent(),m=vt(),h=m.ampTimestamp?Number(m.ampTimestamp):void 0,g=!h||Date.now()<h,_=t.deviceId??(g?m.ampDeviceId??m.deviceId:void 0)??p?.deviceId??f.deviceId??we(),v=p?.lastEventId??f.lastEventId,y=p?.lastEventTime??f.lastEventTime,b=t.optOut??p?.optOut??f.optOut,x=p?.sessionId??f.sessionId,S=p?.deferredSessionId,C=t.userId??p?.userId??f.userId,n.previousSessionDeviceId=p?.deviceId??f.deviceId,n.previousSessionUserId=p?.userId??f.userId,w={ipAddress:t.trackingOptions?.ipAddress??!0,language:t.trackingOptions?.language??!0,platform:t.trackingOptions?.platform??!0},T=p?.pageCounter,E=p?.debugLogsEnabled,t.autocapture!==void 0&&(t.defaultTracking=t.autocapture),D=new Ui(e,t.appVersion,d,l,t.defaultTracking,t.autocapture,_,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,i,t.ingestionMetadata,t.instanceName,v,y,o?.loggerProvider??t.loggerProvider,t.logLevel,t.minIdLength,t.offline,b,t.partnerId,t.plan,t.serverUrl,o?.serverZone??t.serverZone,x,S,t.sessionTimeout,t.storageProvider,w,t.transport,t.useBatch,t.fetchRemoteConfig,C,T,E,t.networkTrackingOptions,t.identify,o?.enableDiagnostics??t.enableDiagnostics,o?.diagnosticsSampleRate??n._diagnosticsSampleRate,a,t.remoteConfig,s,t.enableRequestBodyCompression,t.customEnrichment),[4,D.storageProvider.isEnabled()];case 5:return r.sent()||(D.loggerProvider.warn(`Storage provider ${D.storageProvider.constructor.name} is not enabled. Falling back to MemoryStorage.`),D.storageProvider=new Tt),[2,D]}})})},Gi=function(e,t,n){switch(e===void 0&&(e=Oi),t===void 0&&(t={}),e){case`localStorage`:return new oi;case`sessionStorage`:return new si;case`none`:return new Tt;default:return new Dt(c(c({},t),{expirationDays:t.expiration}),n)}},Ki=function(e){return e===void 0&&(e={}),e.remoteConfig?.fetchRemoteConfig===!0||e.remoteConfig?.fetchRemoteConfig!==!1&&e.fetchRemoteConfig!==!1},qi=function(e){var t=typeof e==`object`?e.type:e,n=typeof e==`object`?e.headers:void 0,r=typeof e==`object`?e.enableKeepalive:void 0,i=typeof e==`object`?e.referrerPolicy:void 0;return t===`xhr`?new ci(n):t===`beacon`?new ui:new li(n,r,i)},Ji=function(e,t){return i(void 0,void 0,void 0,function(){var n,i,a,o,s,s,c,l,u;return r(this,function(r){switch(r.label){case 0:return[4,new Dt(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!r.sent()||!e&&(typeof location>`u`||!location.hostname)||(n=e??location.hostname,i=n.split(`.`),i.length===1))return[2,``];for(a=[],o=1,Bi.find(function(e){return n.endsWith(`.${e}`)})&&(o=2),s=i.length-o-1;s>=0;--s)a.push(i.slice(s).join(`.`));s=0,r.label=2;case 2:if(!(s<a.length))return[3,7];c=a[s],r.label=3;case 3:return r.trys.push([3,5,,6]),[4,Dt.isDomainWritable(c)];case 4:return l=r.sent(),l?[2,`.`+c]:[3,6];case 5:return u=r.sent(),t&&t.recordEvent(`cookies.tld.failure`,{reason:`Unexpected exception checking domain is writable: ${c}`,error:u instanceof Error?u.message:String(u)}),[3,6];case 6:return s++,[3,2];case 7:return t&&t.recordEvent(`cookies.tld.failure`,{reason:`Could not determine TLD for host ${n}`}),[2,``]}})})},Yi=`[Amplitude] Page Viewed`,Xi=`AMP_PAGE_VIEW`,Zi=function(e){e===void 0&&(e={});var n,a=B(),o=void 0,s=!1,l,u,d=e.trackOn,f=e.trackHistoryChanges,p=e.eventType,m=p===void 0?Yi:p,h=function(e){var t=e;try{t=decodeURI(e)}catch(e){o?.error(`Malformed URI sequence: `,e)}return t},g=function(e){return i(void 0,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=h(typeof location<`u`&&location.href||``),i={event_type:m},n=[{}],[4,Qi()];case 1:return[2,(i.event_properties=c.apply(void 0,[c.apply(void 0,n.concat([r.sent()])),{"[Amplitude] Page Domain":typeof location<`u`&&location.hostname||``,"[Amplitude] Page Location":t,"[Amplitude] Page Path":typeof location<`u`&&h(location.pathname)||``,"[Amplitude] Page Title":er($n),"[Amplitude] Page URL":t.split(`?`)[0],"[Amplitude] Page View ID":e}]),i)]}})})},_=function(){return d===void 0||typeof d==`function`&&d()},v=typeof location<`u`?location.href:null,y=function(){return i(void 0,void 0,void 0,function(){var e,t,i,a,s;return r(this,function(r){switch(r.label){case 0:return e=location.href,t=ea(f,e,v||``)&&_(),v=e,t?(i=void 0,u&&(i=we(),u.set(Xi,{pageViewId:i})),o?.log(`Tracking page view event`),n==null?[3,3]:[3,1]):[3,4];case 1:return s=(a=n).track,[4,g(i)];case 2:s.apply(a,[r.sent()]),r.label=3;case 3:r.label=4;case 4:return[2]}})})},b=function(){y()};return{name:`@amplitude/plugin-page-view-tracking-browser`,type:`enrichment`,setup:function(e,c){return i(void 0,void 0,void 0,function(){var i,d,f;return r(this,function(r){switch(r.label){case 0:if(n=c,l=e,o=e.loggerProvider,o.log(`Installing @amplitude/plugin-page-view-tracking-browser`),s=!0,a){try{u=new Nt(a.sessionStorage)}catch{o?.debug(`sessionStorage is not available in this environment.`)}a.addEventListener(`popstate`,b),a.history.pushState=new Proxy(a.history.pushState,{apply:function(e,n,r){var i=t(r,3),a=i[0],o=i[1],c=i[2];e.apply(n,[a,o,c]),s&&b()}})}return _()?(o.log(`Tracking page view event`),i=void 0,u&&(i=we(),u.set(Xi,{pageViewId:i})),f=(d=n).track,[4,g(i)]):[3,2];case 1:f.apply(d,[r.sent()]),r.label=2;case 2:return[2]}})})},execute:function(e){return i(void 0,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return d===`attribution`&&$i(e)?(o?.log(`Enriching c
6ampaign event to page view event with campaign parameters`),t=void 0,u?[4,u.get(Xi)]:[3,2]):[3,4];case 1:n=r.sent(),t=n?.pageViewId,r.label=2;case 2:return[4,g(t)];case 3:i=r.sent(),e.event_type=i.event_type,e.event_properties=c(c({},e.event_properties),i.event_properties),r.label=4;case 4:return l&&e.event_type===m&&(l.pageCounter=l.pageCounter?l.pageCounter+1:1,e.event_properties=c(c({},e.event_properties),{"[Amplitude] Page Counter":l.pageCounter})),[2,e]}})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){return a&&(a.removeEventListener(`popstate`,b),s=!1),[2]})})}}},Qi=function(){return i(void 0,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return e=wt,[4,new qn().parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},$i=function(e){if(e.event_type===`$identify`&&e.user_properties){var n=e.user_properties,r=n[y.SET]||{},i=n[y.UNSET]||{},a=s(s([],t(Object.keys(r)),!1),t(Object.keys(i)),!1);return Object.keys(se).every(function(e){return a.includes(e)})}return!1},ea=function(e,t,n){switch(e){case`pathOnly`:if(n==``)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname;default:return t!==n}},ta=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},a=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;t?.removeEventListener(n,r)}),t=[]},o;return{name:`@amplitude/plugin-form-interaction-tracking-browser`,type:`enrichment`,setup:function(t,a){return i(void 0,void 0,void 0,function(){var i,s;return r(this,function(r){return o=Kr(t),i=function(){if(!a){t.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 r=new WeakSet,i=function(e){if(!r.has(e)){r.add(e);var i=!1;n(e,`change`,function(){var t,n=ra(e);i||a.track(hi,(t={},t[Ti]=na(e.id),t[Ei]=na(e.name),t[Di]=n,t)),i=!0}),n(e,`submit`,function(n){var r,s,c=ra(e);if(i||a.track(hi,(r={},r[Ti]=na(e.id),r[Ei]=na(e.name),r[Di]=c,r)),i=!0,o?.shouldTrackSubmit!==void 0){if(typeof o.shouldTrackSubmit==`function`&&typeof SubmitEvent<`u`&&n instanceof SubmitEvent)try{if(!o.shouldTrackSubmit(n))return}catch{t.loggerProvider.warn(`shouldTrackSubmit callback threw an error, proceeding with tracking.`)}else t.loggerProvider.warn(`shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.`)}a.track(gi,(s={},s[Ti]=na(e.id),s[Ei]=na(e.name),s[Di]=c,s)),i=!1})}};Array.from(document.getElementsByTagName(`form`)).forEach(i),typeof MutationObserver<`u`&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){try{e.nodeName===`FORM`&&i(e),`querySelectorAll`in e&&typeof e.querySelectorAll==`function`&&e.querySelectorAll(`form`)?.forEach(i)}catch(e){t.loggerProvider.warn(`Failed to track form interactions for an added node: ${String(e)}`)}})})}),e.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState===`complete`?i():(s=B(),s?s.addEventListener(`load`,i):t.loggerProvider.debug(`Form interaction tracking is not installed because global is undefined.`)),[2]})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(t){return e?.disconnect(),a(),[2]})})}}},na=function(e){if(typeof e==`string`)return e},ra=function(e){var t=e.getAttribute(`action`);try{t=new URL(encodeURI(t??``),window.location.href).href}catch{}return t},ia=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},a=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;t?.removeEventListener(n,r)}),t=[]};return{name:`@amplitude/plugin-file-download-tracking-browser`,type:`enrichment`,setup:function(t,a){return i(void 0,void 0,void 0,function(){var i,o;return r(this,function(r){return i=function(){if(!a){t.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 r=function(e){var t;try{t=new URL(e.href,window.location.href)}catch{return}var r=i.exec(t.href)?.[1];r&&n(e,`click`,function(){var n;r&&a.track(_i,(n={},n[bi]=r,n[xi]=t.pathname,n[Si]=e.id,n[Ci]=e.text,n[wi]=e.href,n))})},i=/\.(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)(\?.+)?$/;
6Array.from(document.getElementsByTagName(`a`)).forEach(r),typeof MutationObserver<`u`&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){try{e.nodeName===`A`&&r(e),`querySelectorAll`in e&&typeof e.querySelectorAll==`function`&&e.querySelectorAll(`a`)?.forEach(r)}catch(e){t.loggerProvider.warn(`Failed to track file downloads for an added node: ${String(e)}`)}})})}),e.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState===`complete`?i():(o=B(),o?o.addEventListener(`load`,i):t.loggerProvider.debug(`File download tracking is not installed because global is undefined.`)),[2]})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(t){return e?.disconnect(),a(),[2]})})}}},aa=!1,oa=function(e){aa||e.defaultTracking!==void 0||(e.loggerProvider.warn(`\`options.defaultTracking\` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to \`options.defaultTracking\`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:
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.`),aa=!0)},sa=function(){var e=`@amplitude/plugin-network-checker-browser`,t=`before`,n=B(),a=[],o=function(e,t){n?.addEventListener&&(n?.addEventListener(e,t),a.push({type:e,handler:t}))},s=function(){a.forEach(function(e){var t=e.type,r=e.handler;n?.removeEventListener(t,r)}),a=[]};return{name:e,type:t,setup:function(e,t){return i(void 0,void 0,void 0,function(){return r(this,function(n){return typeof navigator>`u`?(e.loggerProvider.debug(`Network connectivity checker plugin is disabled because navigator is not available.`),e.offline=!1,[2]):(e.offline=!navigator.onLine,o(`online`,function(){e.offline!==!1&&(e.loggerProvider.debug(`Network connectivity changed to online.`),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis))}),o(`offline`,function(){e.loggerProvider.debug(`Network connectivity changed to offline.`),e.offline=!0}),[2])})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){return s(),[2]})})}}};function ca(e,t){if(e){Tr(e);try{t.loggerProvider.debug(`Update browser config with remote configuration:`,Ee(e));var n=e;if(n&&`autocapture`in n){if(typeof n.autocapture==`boolean`&&(t.autocapture=n.autocapture),typeof n.autocapture==`object`&&n.autocapture!==null){var r=c({},n.autocapture);if(t.autocapture===void 0&&(t.autocapture=n.autocapture),typeof n.autocapture.elementInteractions==`object`&&n.autocapture.elementInteractions!==null&&n.autocapture.elementInteractions.pageUrlAllowlistRegex?.length){r.elementInteractions=c({},n.autocapture.elementInteractions);var i=r.elementInteractions,a=i.pageUrlAllowlist??[],o=n.autocapture.elementInteractions.pageUrlAllowlistRegex;i.pageUrlAllowlist=Cr(a,o,t.loggerProvider),delete i.pageUrlAllowlistRegex}var s=wr(n.autocapture.networkTracking,t.loggerProvider);s&&(r.networkTracking=s),typeof t.autocapture==`boolean`&&(t.autocapture=c({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},r)),typeof t.autocapture==`object`&&(t.autocapture=c(c({},t.autocapture),r))}t.defaultTracking=t.autocapture}`customEnrichment`in n&&n.customEnrichment!==null&&t.customEnrichment!==!1&&(t.customEnrichment=n.customEnrichment),t.loggerProvider.debug(`Browser config after remote config update:`,Ee(t))}catch(e){t.loggerProvider.error(`Failed to apply remote configuration because of error: `,e)}}}var la=`1.29.5`,ua=`@amplitude/plugin-autocapture-browser`,da=`@amplitude/plugin-frustration-browser`,fa=`@amplitude/plugin-performance-browser`,pa=`[Amplitude] Dead Click`,ma=`[Amplitude] Rage Click`,ha=`[Amplitude] Error Click`,ga=`[Amplitude] Thrashed Cursor`,_a=`[Amplitude] Main Thread Block`,va=`[Amplitude] Element ID`,ya=`[Amplitude] Element Class`,ba=`[Amplitude] Element Tag`,xa=`[Amplitude] Element Text`,Sa=`[Amplitude] Element Hierarchy`,Ca=`[Amplitude] Element Href`,wa=`[Amplitude] Element Position Left`,Ta=`[Amplitude] Element Position Top`,Ea=`[Amplitude] Element Aria Label`,Da=`[Amplitude] Element Attributes`,Oa=`[Amplitude] Element Path`,ka=`[Amplitude] Element Parent Label`,Aa=`[Amplitude] Page URL`,ja=`[Amplitude] Page Title`,Ma=`[Amplitude] Viewport Height`,Na=`[Amplitude] Viewport Width`,Pa=`[Amplitude] Max Page X`,Fa=`[Amplitude] Max Page Y`,Ia=`[Amplitude] Page View ID`,La=`https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz`,Ra=`amp-visual-tagging-selector-highlight`,za=`data-amp-mask-attributes`,Ba=`data-amp-internal-shadow`,Va=`AMP_PAGE_VIEW`,Ha=.5,Ua=4e3,Wa=[/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/];function Ga(e,t){var r,i,a=[];try{for(var o=n(e),s=o.next();!s.done;s=o.next()){var c=s.value;try{a.push(new RegExp(c))}catch(e){var l=e instanceof Error?e.message:String(e);t?.warn(`@amplitude/element-selector: ignoring invalid autogenerated-id pattern "${c}" (${l})`)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}function Ka(e,t){var r,i;if(e==null||e===``)return!1;try{for(var a=n(t),o=a.next();!o.done;o=a.next())if(o.value.test(e))return!1}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return!0}var qa=[/^(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 Ja(e,t){var r,i,a=[];try{for(var o=n(e),s=o.next();!s.done;s=o.next()){var c=s.value;try{a.push(new RegExp(c))}catch(e){var l=e instanceof Error?e.message:String(e);t?.warn(`@amplitude/element-selector: ignoring invalid unstable-class pattern "${c}" (${l})`)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}function Ya(e,t){var n=e.getAttribute(t.explicitTrackingAttribute);if(n!==null&&n===``)return null;var r=e.getAttribute(`id`);return r===null||r===``||!Ka(r,t.autogeneratedIdPatterns)?null:r}function Xa(e,t){return t.map(Za).join(` > `)}function Za(e){var t=e.tagName.toLowerCase(),n=e.parentElement;return n===null?t:`${t}
12:nth-of-type(${Qa(e,n)})`}function Qa(e,t){for(var n=0,r=0;r<t.children.length;r++){var i=t.children[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}var $a=` >>> `,eo=`:scope > `;function to(e){return typeof ShadowRoot<`u`&&e instanceof ShadowRoot}function no(e,t,n){return e&&n&&to(t)?`${eo}${e}`:e}function ro(e){for(var t=e;t!==null;t=t.parentElement)if(t.getAttribute(`id`))return!1;return!0}function io(e){var t=e.getRootNode();return to(t)?t:e.ownerDocument??document}function ao(e){if(e.parentElement)return e.parentElement;var t=e.getRootNode();return to(t)?t.host:null}function oo(e,t){var n,i,a,o;return r(this,function(r){switch(r.label){case 0:n=e,i=0,a=0,r.label=1;case 1:return n!==null&&a<1024?(a+=1,[4,n]):[3,3];case 2:return r.sent(),n.parentElement?(n=n.parentElement,[3,1]):i<t&&typeof n.getRootNode==`function`&&(o=ao(n),o&&o!==n)?(i+=1,n=o,[3,1]):[3,3];case 3:return[2]}})}function so(e,n){var r=[];if(n<=0)return r;for(var i=[[e,0]],a=0;i.length&&a<5e4;){a+=1;var o=t(i.pop(),2),s=o[0],c=o[1],l=s.shadowRoot;if(l&&c+1<=n){r.push({root:l,depth:c+1});for(var u=l.children,d=0;d<u.length;d++)i.push([u[d],c+1])}for(var f=s.children,d=0;d<f.length;d++)i.push([f[d],c])}return r}function co(e,t){for(var n=[],r=e,i=0;r!==null&&i<1024;){i+=1;var a=io(r);n.push({root:a,target:r});var o=r.getRootNode();if(!to(o))break;r=o.host}var s=n.length-1,c=!1,l=n;return s>t&&(l=n.slice(s-t),c=!0),{segments:l.reverse(),truncated:c}}function lo(e,t){var n=e.tagName.toLowerCase(),r=e.parentElement;if(r===null){var i=e.getRootNode();return t&&to(i)?`${n}:nth-of-type(${uo(e,i.children)})`:n}return`${n}:nth-of-type(${uo(e,r.children)})`}function uo(e,t){for(var n=0,r=0;r<t.length;r++){var i=t[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}var fo={name:`explicitTrackingAttribute`,try:function(e,t){var n=t.config.explicitTrackingAttribute,r=e.getAttribute(n);return r===null||r===``?null:`[${n}=${JSON.stringify(r)}]`}};function po(e){var t=globalThis.CSS;if(t&&typeof t.escape==`function`)return t.escape(e);for(var n=String(e),r=n.length,i=``,a=0;a<r;a++){var o=n.charCodeAt(a);if(o===0){i+=`�`;continue}if(o>=1&&o<=31||o===127||a===0&&o>=48&&o<=57||a===1&&o>=48&&o<=57&&n.charCodeAt(0)===45){i+=`\\${o.toString(16)} `;continue}if(a===0&&r===1&&o===45){i+=`\\-`;continue}if(o>=128||o===45||o===95||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122){i+=n.charAt(a);continue}i+=`\\${n.charAt(a)}`}return i}function mo(e){return po(e)}var ho={name:`stableId`,try:function(e,t){var n=Ya(e,t.config);return n===null?null:`${e.tagName.toLowerCase()}#${mo(n)}`}},go=Object.freeze({enabled:!1,explicitTrackingAttribute:`data-amp-track-id`,autogeneratedIdPatterns:s([],t(Wa),!1),unstableClassPatterns:s([],t(qa),!1),maxAncestorWalkDepth:void 0,shadowDomEnabled:!1,maxShadowDomDepth:1});function _o(e){return c(c({},e),{shadowDomEnabled:e.shadowDomEnabled??!1,maxShadowDomDepth:bo(e.maxShadowDomDepth)})}function vo(e,t){if(!e)return xo();var n=xo();return typeof e.enabled==`boolean`&&(n.enabled=e.enabled),typeof e.explicitTrackingAttribute==`string`&&e.explicitTrackingAttribute!==``&&(n.explicitTrackingAttribute=e.explicitTrackingAttribute),Array.isArray(e.autogeneratedIdPatterns)&&(n.autogeneratedIdPatterns=Ga(e.autogeneratedIdPatterns,t)),Array.isArray(e.unstableClassPatterns)&&(n.unstableClassPatterns=Ja(e.unstableClassPatterns,t)),n.maxAncestorWalkDepth=yo(e.maxAncestorWalkDepth),typeof e.shadowDomEnabled==`boolean`&&(n.shadowDomEnabled=e.shadowDomEnabled),n.maxShadowDomDepth=bo(e.maxShadowDomDepth),_o(n)}function yo(e){if(typeof e==`number`&&Number.isFinite(e)&&!(e<=0))return Math.floor(e)}function bo(e){return typeof e!=`number`||!Number.isFinite(e)?1:Math.min(Math.max(Math.floor(e),1),10)}function xo(){return{enabled:go.enabled,explicitTrackingAttribute:go.explicitTrackingAttribute,autogeneratedIdPatterns:s([],t(go.autogeneratedIdPatterns),!1),unstableClassPatterns:s([],t(go.unstableClassPatterns),!1),maxAncestorWalkDepth:go.maxAncestorWalkDepth,shadowDomEnabled:go.shadowDomEnabled,maxShadowDomDepth:go.maxShadowDomDepth}}var So=[fo,ho];function Co(e,t,r){var i,a;r===void 0&&(r={});var o=_o(t),s=r.strategies??So,c=r.scope??e.ownerDocument??document,l={scope:c,config:o},u=wo(e,o.maxAncestorWalkDepth);try{for(var d=n(s),f=d.next();!f.done;f=d.next())for(var p=f.value,m=0;m<u.length;m++){var h=u[m],g=p.try(h,l);if(g!==null){if(m===0){if(To(c,g,e,p.name,r.logger))return g;continue}var _=`${g} > ${Xa(h,u.slice(0,m).reverse())}`;if(To(c,_,e,p.name,r.logger))return _}}}catch(e){i={error:e}}
12finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(i)throw i.error}}return null}function wo(e,t){for(var n=[],r=e;r!==null&&(n.push(r),!(t!==void 0&&n.length>t));)r=r.parentElement;return n}function To(e,t,n,r,i){var a;try{a=e.querySelectorAll(t)}catch(e){var o=e instanceof Error?e.message:String(e);return i?.debug(`@amplitude/element-selector: strategy "${r}" emitted a malformed selector "${t}" (${o})`),!1}return a.length===1&&a[0]===n}function Eo(e,n,r){r===void 0&&(r={});for(var i=_o(n),a=r.scope??e.ownerDocument??document,o=to(a),c=[],l=e,u=0,d=!(i.shadowDomEnabled&&o);l!==null&&!(d&&i.maxAncestorWalkDepth!==void 0&&u>i.maxAncestorWalkDepth);){var f=Ya(l,i);if(f!==null){var p=`${l.tagName.toLowerCase()}#${mo(f)}`,m=s([p],t(c),!1).join(` > `);if(Do(a,m,e))return m}c.unshift(lo(l,i.shadowDomEnabled)),l=l.parentElement,u+=1}var h=c.join(` > `);return i.shadowDomEnabled&&o&&l===null?`${eo}${h}`:h}function Do(e,t,n){var r;try{r=e.querySelectorAll(t)}catch{return!1}return r.length===1&&r[0]===n}var Oo=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),ko=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return``;for(var n=[],r=e;r;){var i=Ao(r,!!t,r===e);if(!i||(n.push(i),i.optimized))break;r=r.parentElement}return n.reverse(),n.join(` > `)},Ao=function(e,t,r){var i,a;if(e.nodeType!==Node.ELEMENT_NODE)return null;var o=e.getAttribute(`id`);if(t){if(o)return new Oo(Mo(o),!0);var s=e.tagName.toLowerCase();if(s===`body`||s===`head`||s===`html`)return new Oo(s,!0)}var c=e.tagName.toLowerCase();if(o)return new Oo(c+Mo(o),!0);var l=e.parentNode;if(!l||l.nodeType===Node.DOCUMENT_NODE)return new Oo(c,!0);for(var u=jo(e),d=!1,f=!1,p=-1,m=-1,h=l.children,g=0;h&&(p===-1||!f)&&g<h.length;++g){var _=h[g];if(_.nodeType===Node.ELEMENT_NODE){if(m+=1,_===e){p=m;continue}if(!f&&_.tagName.toLowerCase()===c){d=!0;var v=new Set(u);if(!v.size){f=!0;continue}for(var y=jo(_),b=0;b<y.length;++b){var x=y[b];if(v.has(x)&&(v.delete(x),!v.size)){f=!0;break}}}}}var S=c;if(r&&c.toLowerCase()===`input`&&e.getAttribute(`type`)&&!e.getAttribute(`id`)&&!e.getAttribute(`class`)&&(S+=`[type=`+po(e.getAttribute(`type`)||``)+`]`),f)S+=`:nth-child(`+String(p+1)+`)`;else if(d)try{for(var C=n(u),w=C.next();!w.done;w=C.next()){var T=w.value;S+=`.`+po(T.slice(1))}}catch(e){i={error:e}}finally{try{w&&!w.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}return new Oo(S,!1)},jo=function(e){var t=e.getAttribute(`class`);return t?t.split(/\s+/g).filter(Boolean).map(function(e){return`$`+e}):[]},Mo=function(e){return`#`+po(e)};function No(e,t){try{return ko(e)}catch(e){var n=e instanceof Error?e.message:String(e);return t?.warn(`@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ${n}`),``}}function Po(e,t){t===void 0&&(t={});var r=_o(e),i=new Set,a=t.logger,o=function(e){return No(e,a)},s=function(e,n){return Co(e,r,{strategies:t.strategies,scope:n,logger:a})??Eo(e,r,{scope:n})},c=function(e,t){return no(o(e,t),t,ro(e))};function l(e,t){var n=co(e,r.maxShadowDomDepth),i=n.segments;return n.truncated&&a?.debug(`@amplitude/element-selector: target is nested deeper than maxShadowDomDepth (${r.maxShadowDomDepth}) — emitting a best-effort selector for the outermost in-budget shadow host`),i.map(function(e){var n=e.target,r=e.root;return t(n,r)}).join($a)}return{generate:function(e){try{return r.shadowDomEnabled?l(e,r.enabled?s:c):(r.enabled?s:o)(e,t.scope??e.ownerDocument??document)}catch(t){var n=t instanceof Error?t.message:String(t);return a?.warn(`@amplitude/element-selector: selector generation threw — falling back to legacy cssPath: ${n}`),No(e,a)}},getConfig:function(){return r},updateConfig:function(e){var t,o;r=_o(e);try{for(var s=n(i),c=s.next();!c.done;c=s.next()){var l=c.value;try{l(r)}catch(e){var u=e instanceof Error?e.message:String(e);a?.warn(`@amplitude/element-selector: onConfigChange subscriber threw — ${u}`)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(t)throw t.error}}},onConfigChange:function(e){return i.add(e),function(){i.delete(e)}}}}var Fo=1,Io=Object.freeze({enabled:!1,maxDepth:0}),Lo=function(e){var t=e.maxShadowDomDepth??Fo;return!e.shadowDomEnabled||t<=0?Io:Object.freeze({enabled:!0,maxDepth:t})},Ro=function(){var e=Io,r=new Set,i=function(e){var i,a;try{for(var o=n(s([],t(r),!1)),c=o.next();!c.done;c=o.next()){var l=c.value;try{l(e)}catch{}}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=o.return)&&a.call(o)}finally{if(i)throw i.error}}r.clear()};return{get:function(){return e},arm:function(t){return e.enabled||!t.enabled?e:(e=t,i(t),e)},onArm:function(t){if(e.enabled){var n=e;try{t(n)}catch{}return function(){}}return r.add(t),function(){r.delete(t)}}}},zo,Bo=function(){return zo||=Ro(),zo},Vo=[`input`,`select`,`textarea`],Ho=function(e,t){return((window==null?void 0:window.getComputedStyle)?.call(window,e))?.getPropertyValue(`cursor`)===`pointer`&&t===`click`},Uo=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&bt(window.location.href,n)||!bt(window.location.href,t))},Wo=function(e,t){return function(n,r){var i,a=e.shouldTrackEventResolver,o=((i=r?.tagName)?.toLowerCase)?.call(i);if(!o)return!1;if(a)return a(n,r);if(!Uo(e))return!1;var s=String(r?.getAttribute(`type`))||``;if(typeof s==`string`)switch(s.toLowerCase()){case`hidden`:return!1;case`password`:return!1}if(t&&!t.some(function(e){return!!(r?.matches)?.call(r,e)}))return!1;switch(o){case`input`:case`select`:case`textarea`:return n===`change`||n===`click`;default:return n===`click`}}},Go=function(e){var t,n=((t=e?.tagName)?.toLowerCase)?.call(t),r=e instanceof HTMLElement&&e.getAttribute(`contenteditable`)?.toLowerCase()===`true`;return!Vo.includes(n)&&!r},Ko=function(e){return e?e.split(`,`).map(function(e){return e.trim()}).filter(function(e){return e.length>0&&e!==`id`&&e!==`class`}):[]},qo=function(e,n){return Object.entries(e).reduce(function(e,r){var i=t(r,2),a=i[0],o=i[1];if(a.startsWith(n)){var s=a.replace(n,``);s&&(e[s]=o||``)}return e},{})},Jo=function(e){return e==null||typeof e==`object`&&Object.keys(e).length===0||typeof e==`string`&&e.trim().length===0},Yo=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return Jo(r)||(t[n]=r),t},{})},Xo=function(){try{var e=(B()?.sessionStorage)?.getItem(Va);if(!e)return;var t=JSON.parse(e);if(typeof t.pageViewId==`string`)return t.pageViewId}catch{}},Zo=function(e,t,n){return n===void 0&&(n=Io),n.enabled?$o(e,t,n.maxDepth):Qo(e,t)},Qo=function(e,t){return e?t.some(function(t){return(e?.matches)?.call(e,t)})?e:Qo(e?.parentElement,t):null},$o=function(e,t,r){var i,a;if(!e)return null;var o=function(e){if(t.some(function(t){return(e?.matches)?.call(e,t)}))return{value:e}};try{for(var s=n(oo(e,r)),c=s.next();!c.done;c=s.next()){var l=c.value,u=o(l);if(typeof u==`object`)return u.value}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return null},es=function(e,t,n){return n===void 0&&(n=Io),n.enabled?ns(e,t,n.maxDepth):ts(e,t)},ts=function(e,t){var n=[];return t&&e.querySelectorAll(t).forEach(function(e){return n.push(e)}),n},ns=function(e,t,n){var r=ts(e,t),i=e instanceof Document?e.documentElement:e;
12return i&&so(i,n).forEach(function(e){e.root.querySelectorAll(t).forEach(function(e){return r.push(e)})}),r},rs=function(e,t){if(t===void 0&&(t=Io),!t.enabled)return e.target;var n=e.composedPath?.call(e),r=e.target??null;if(!n||n.length===0)return r;var i=n[0];if(!(i instanceof Element))return i??r;var a=co(i,t.maxDepth),o=a.segments;return a.truncated&&o.length>0?o[o.length-1].target:i},is=function(e){return!(e.event.target===null||!e.closestTrackedAncestor)};function as(e){return e.type===`click`||e.type===`change`}function os(e){if(!e)return``;try{var t=new URL(e);return t.search=``,xt(t.href)}catch{return xt(e)}}function ss(e){return e===void 0&&(e=B()),os(e?.location?.href??``)}function cs(e,t){if(t===void 0&&(t=B()),e==null||e===``)return ss(t);var n=t?.location?.href||`http://localhost/`;try{return os(new URL(e,n).href)}catch{return ss(t)}}var ls;(function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]=`LEFT_OR_TOUCH_CONTACT`,e[e.MIDDLE=1]=`MIDDLE`,e[e.RIGHT=2]=`RIGHT`})(ls||={});var us=`__AMPLITUDE_VISUAL_TAGGING__`;function ds(e,t){var n=e;if(n[us]!==!0){n[us]=!0;var r=t.dataExtractor,i=t.isElementSelectable,a=t.cssSelectorAllowlist,o=t.actionClickAllowlist,s=null,c=function(t){e.notify({action:`element-selected`,data:t})},l=function(t,n){t===`selector-mode-changed`?e.notify({action:`track-selector-mode-changed`,data:n}):t===`selector-moved`&&e.notify({action:`track-selector-moved`,data:n})};e.registerActionHandler(`initialize-visual-tagging-selector`,function(t){e.loadScriptOnce(La).then(function(){s=(window==null?void 0:window.amplitudeVisualTaggingSelector)?.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i(t?.actionType||`click`,e)},onTrack:l,onSelect:c,visualHighlightClass:Ra,messenger:e,cssSelectorAllowlist:a,actionClickAllowlist:o,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:la}}}),e.notify({action:`selector-loaded`})}).catch(function(){var t;(t=e.logger)==null||t.warn(`Failed to initialize visual tagging selector`)})}),e.registerActionHandler(`close-visual-tagging-selector`,function(){var e;(e=s?.close)==null||e.call(s)})}}function fs(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(is).filter(function(e){return r(`click`,e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){t?.track(`[Amplitude] Element Clicked`,e.targetElementProperties)})}function ps(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,a=e.evaluateTriggers;return n.changeObservable.filter(is).filter(function(e){return i(`change`,e.closestTrackedAncestor)}).map(function(e){return a(e)}).subscribe(function(e){t?.track(`[Amplitude] Element Changed`,r(`change`,e.closestTrackedAncestor))})}function ms(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,a=e.shouldTrackEvent,o=e.shouldTrackActionClick,s=n.clickObservable,c=n.mutationObservable,l=n.navigateObservable,u=rr(s.filter(function(e){return!a(`click`,e.closestTrackedAncestor)}).map(function(e){return e.closestTrackedAncestor=Zo(e.event.target,r.actionClickAllowlist),e.closestTrackedAncestor!==null&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(is).filter(function(e){return o(`click`,e.closestTrackedAncestor)}),l?rr(c,l):c),d=null,f=null;return nr(u,function(e){if(d&&=(clearTimeout(d),null),e.type===`click`)return f=e,d=setTimeout(function(){d=null,f=null},500),Promise.resolve(null);if(f){var t=f;return f=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&t?.track(`[Amplitude] Element Clicked`,i(`click`,e.closestTrackedAncestor))})}function hs(e){e.amplitude;var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe(function(){var e=B(),t=Math.floor(e?.scrollX??e?.pageXOffset??0),r=Math.floor(e?.scrollY??e?.pageYOffset??0);n.maxX=Math.max(n.maxX,t),n.maxY=Math.max(n.maxY,r)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}var gs=B(),_s=function(e){return e.get()},vs={childList:!0,attributes:!0,characterData:!0,subtree:!0},ys=function(e){return e?new K.default(function(t){var r=new WeakSet,i=new WeakMap,a=function(e,t){r.has(e)||(r.add(e),to(e)&&i.set(e,t),c.observe(e,vs))},o=function(e,t,n){var r=n-t;r<=0||so(e,r).forEach(function(e){var n=e.root,r=e.depth;return a(n,t+r)})},s=function(e){var t=e.getRootNode();return to(t)?i.get(t)??0:0},c=new MutationObserver(function(r){var i,a;t.next(r);try{var c=_s(e);if(!c.enabled)return;var l=function(e){var t=s(e.target);
12e.addedNodes.forEach(function(e){e instanceof Element&&o(e,t,c.maxDepth)})};try{for(var u=n(r),d=u.next();!d.done;d=u.next()){var f=d.value;l(f)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}}catch{}}),l;if(document.body){var u=document.body;a(u,0),l=e.onArm(function(e){o(u,0,e.maxDepth)})}return function(){l?.(),c.disconnect()}}):new K.default(function(e){var t=new MutationObserver(function(t){e.next(t)});return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}})},bs=function(e){return e===void 0&&(e=`click`),new K.default(function(t){var n,r=function(e){t.next(e)};return(n=B())==null||n.document.addEventListener(e,r,{capture:!0}),function(){var t;(t=B())==null||t.document.removeEventListener(e,r,{capture:!0})}})},xs=function(){return new K.default(function(e){var t,n,r=function(t){e.next(t)};return(t=B())==null||t.addEventListener(`scroll`,r,{capture:!0,passive:!0}),(n=B())==null||n.addEventListener(`resize`,r,{passive:!0}),function(){var e,t;(e=B())==null||e.removeEventListener(`scroll`,r,{capture:!0}),(t=B())==null||t.removeEventListener(`resize`,r)}})},Ss=function(){return new K.default(function(e){var t=function(t){var n=[...arguments].slice(1),r=void 0;Array.isArray(n[0])&&typeof n[0][0]==`string`&&(r=n[0][0]),e.next({kind:`console`,message:r})};return hn.addListener(`error`,t),function(){hn.removeListener(t)}})},Cs=function(e,t,n,r){var i=typeof n==`function`?n:void 0,a=typeof n==`function`?r:n;return new K.default(function(n){var r=B();if(!r?.IntersectionObserver)return function(){};var o=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:`0px`,threshold:0}),s=t.join(`,`),c=function(e){e instanceof Element&&e.matches(s)&&o.observe(e),e.querySelectorAll(s).forEach(function(e){o.observe(e)})},l=function(e){if(a)try{es(e,s,_s(a)).forEach(function(e){o.observe(e)})}catch{}},u=function(){var e=r?.document;if(e){var t=[];try{t=a&&_s(a).enabled?es(e,s,_s(a)):e.querySelectorAll(s)}catch{return}Array.from(t).forEach(function(e){o.unobserve(e),o.observe(e)})}};i?.(u),u();var d=a?.onArm(function(){r?.document&&l(r.document)}),f=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){if(e instanceof DocumentFragment){c(e);return}if(e instanceof Element){if(!a||!_s(a).enabled){c(e);return}try{e.matches(s)&&o.observe(e)}catch{}l(e)}})})});return function(){i?.(void 0),d?.(),f.unsubscribe(),o.disconnect()}})},ws=function(){return new K.default(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:`error`};t.error instanceof Error||t.error instanceof DOMException?n=c(c({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):typeof t.error==`string`&&(n.message=t.error),e.next(n)}};return gs.addEventListener(`error`,t),function(){gs.removeEventListener(`error`,t)}})},Ts=function(){return new K.default(function(e){var t=function(t){var n={kind:`unhandledrejection`};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):typeof t.reason==`string`&&(n.message=t.reason),e.next(n)};return gs.addEventListener(`unhandledrejection`,t),function(){gs.removeEventListener(`unhandledrejection`,t)}})},Es=function(){return rr(rr(ws(),Ts()),Ss())},Ds=function(){return new K.default(function(e){var t=function(t){e.next(t)},n={capture:!0};return gs.document.addEventListener(`mousemove`,t,n),function(){gs.document.removeEventListener(`mousemove`,t,n)}})},Os=function(e,t){try{if(t.subprop_key===`[Amplitude] Element Text`)return t.subprop_op===`is`&&t.subprop_value.includes(e.targetElementProperties[`[Amplitude] Element Text`]);if(t.subprop_key===`[Amplitude] Element Hierarchy`)return t.subprop_op===`autotrack css match`&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error(`Error matching event to filter`,e),!1}return!1},ks=function(e,t){try{if(e.sourceType===`DOM_ELEMENT`){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch{return}},As=function(e,t,n){e.forEach(function(e){if(typeof e!=`string`&&e.actionType===`ATTACH_EVENT_PROPERTY`){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}})},js={"[Amplitude] Element Clicked":`click`,"[Amplitude] Element Changed":`change`},Ms=function(e){var t,r,i,a,o=Object.values(js).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var s=n(e),c=s.next();!c.done;c=s.next()){var l=c.value;try{try{for(var u=(i=void 0,n(l.definition)),d=u.next();!d.done;d=u.next()){var f=js[d.value.event_type];f&&o[f].add(l.id)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}}catch(e){console.warn(`Skipping Labeled Event due to malformed definition`,l?.id,e)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o},Ns=function(e){var t,r,i,a,o=new Map;try{for(var s=n(e),c=s.next();!c.done;c=s.next()){var l=c.value;try{for(var u=(i=void 0,n(l.conditions)),d=u.next();!d.done;d=u.next()){var f=d.value;if(f.type===`LABELED_EVENT`){var p=f.match.eventId,m=o.get(p);m||(m=[],o.set(p,m)),m.push(l)}}}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o},Ps=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return js[t.event_type]===e.type&&t.filters.every(function(t){return Os(e,t)})})})},Fs=function(e,t){var r,i,a,o,s=new Set;try{for(var c=n(e),l=c.next();!l.done;l=c.next()){var u=l.value,d=t.get(u.id);if(d)try{for(var f=(a=void 0,n(d)),p=f.next();!p.done;p=f.next()){var m=p.value;s.add(m)}}catch(e){a={error:e}}
12finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(a)throw a.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return Array.from(s)},Is=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,r,i=this.options.pageActions;if(!i)return e;var a=Fs(Ps(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return i.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var o=n(a),s=o.next();!s.done;s=o.next()){var c=s.value;As(c.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}(),Ls=function(e,t,n,r){return new Is(e,t,n,r)},Rs=new Set([`id`,`class`,`style`,`value`,`onclick`,`onchange`,`oninput`,`onblur`,`onsubmit`,`onfocus`,`onkeydown`,`onkeyup`,`onkeypress`,`data-reactid`,`data-react-checksum`,`data-reactroot`,za,Jn,Ba]),zs=[`type`],Bs=[`svg`,`path`,`g`],Vs=[`password`,`hidden`];function Hs(e,t){if(e.parentElement)return e.parentElement.children;var n=e.getRootNode();return t&&to(n)?n.children:[]}function Us(e,t,r){var i,a,o;if(r===void 0&&(r=Io),e===null)return null;var s=String(e.tagName).toLowerCase(),l={tag:s},u=Array.from(Hs(e,r.enabled));u.length&&(l.index=u.indexOf(e),l.indexOfType=u.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var d=(e.previousElementSibling?.tagName)?.toLowerCase();d&&(l.prevSib=String(d));var f=e.getAttribute(`id`);f&&(l.id=String(f));var p=Array.from(e.classList);p.length&&(l.classes=p);var m={},h=Array.from(e.attributes).filter(function(e){return!Rs.has(e.name)}),g=!Go(e);if(!Vs.includes(String(e.getAttribute(`type`)))&&!Bs.includes(s))try{for(var _=n(h),v=_.next();!v.done;v=_.next()){var y=v.value;if(!g||zs.includes(y.name)){if(t.has(y.name)){m[y.name]=Yn;continue}m[y.name]=String(y.value).substring(0,128)}}}catch(e){i={error:e}}finally{try{v&&!v.done&&(a=_.return)&&a.call(_)}finally{if(i)throw i.error}}return Object.keys(m).length&&(l.attrs=m),e.shadowRoot&&(l.attrs=c(c({},l.attrs||{}),(o={},o[Ba]=`true`,o)),l.shadow=!0),l}function Ws(e,t){return t===void 0&&(t=Io),e?t.enabled?Ks(e,t.maxDepth):Gs(e):[]}function Gs(e){var t=[];t.push(e);for(var n=e.parentElement;n&&n.tagName!==`HTML`;)t.push(n),n=n.parentElement;return t}function Ks(e,t){var r,i,a=[];try{for(var o=n(oo(e,t)),s=o.next();!s.done;s=o.next()){var c=s.value;if(c.tagName===`HTML`)break;a.push(c)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}var qs=function(e){return e.closest(`[${Jn}]`)!==null},Js=function(e,t){return Ws(e,t).some(function(e){return e.hasAttribute(`data-amp-mask`)})?!0:document.documentElement?.hasAttribute(`data-amp-mask`)??!1},Ys;function Xs(){return Ys||=Po(vo()),Ys}var Zs=function(){function e(e,r){var i,a,o=this;this.replaceSensitiveString=function(e){return $n(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var r,i,a,c=performance.now(),l=[];if(!e)return[];for(var u=o.getShadowMode(),d=Ws(e,u),f=new Map,p=d.length-1;p>=0;p--){var m=d[p];if(m){var h=Ko(m.getAttribute(za)),g=p===d.length-1?[]:f.get(d[p+1])??new Set,_=new Set(s(s([],t(g),!1),t(h),!1));f.set(m,_)}}l=d.map(function(e){return Us(e,f.get(e)??new Set,u)});var v=function(e){e?.attrs&&Object.entries(e.attrs).forEach(function(n){var r=t(n,2),i=r[0],a=r[1];e.attrs&&(e.attrs[i]=o.replaceSensitiveString(a))})};try{for(var y=n(l),b=y.next();!b.done;b=y.next()){var x=b.value;v(x)}}catch(e){r={error:e}}finally{try{b&&!b.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}var S=performance.now();return(a=o.diagnosticsClient)==null||a.recordHistogram(`autocapturePlugin.getHierarchy`,S-c),l},this.getNearestLabel=function(e){var t=e.parentElement;if(!t)return``;var n;try{n=t.querySelector(`:scope>span,h1,h2,h3,h4,h5,h6`)}catch{n=null}return n?o.getText(n):o.getNearestLabel(t)},this.getElementPath=function(e){var t;if(!e)return``;var n=performance.now(),r=o.selectorEngine.generate(e),i=performance.now();return(t=o.diagnosticsClient)==null||t.recordHistogram(`autocapturePlugin.getElementPath`,i-n),r},this.updateSelectorConfig=function(e,t){var n;if(e!=null){var r=typeof e.enabled==`boolean`,i=typeof e.shadowDomEnabled==`boolean`;if(!r&&!i){t?.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` or `shadowDomEnabled` flag — keeping current engine state.");return}var a=vo(e,t),s=o.selectorEngine.getConfig().enabled,l=o.shadowGate.get().enabled,u=o.shadowGate.arm(Lo(a));o.selectorEngine.updateConfig(c(c(c({},r?a:o.selectorEngine.getConfig()),{shadowDomEnabled:u.enabled}),u.enabled&&{maxShadowDomDepth:u.maxDepth})),r&&s!==a.enabled&&t?.debug(a.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.`),!l&&u.enabled&&((n=o.diagnosticsClient)==null||n.setTag(`plugin.autocapture.shadowDom`,`enabled:${u.maxDepth}`))}}
12,this.getShadowMode=function(){return o.shadowGate.get()},this.getEventProperties=function(e,t,n){var r,i,a=((i=t?.tagName)?.toLowerCase)?.call(i),s=typeof t.getBoundingClientRect==`function`?t.getBoundingClientRect():{left:null,top:null},c=o.getHierarchy(t),l=c[0]?.attrs,u=o.getNearestLabel(t),d=qo(l??{},n),f=(r={},r[Sa]=c,r[ba]=a,r[xa]=o.getText(t),r[wa]=s.left==null?null:Math.round(s.left),r[Ta]=s.top==null?null:Math.round(s.top),r[Da]=d,r[Oa]=o.getElementPath(t),r[ka]=u,r[Aa]=xt(window.location.href.split(`?`)[0]),r[ja]=er(o.replaceSensitiveString),r[Ma]=window.innerHeight,r[Na]=window.innerWidth,r),p=Xo();if(p&&(f[Ia]=p),f[va]=t.getAttribute(`id`)||``,f[ya]=t.getAttribute(`class`),f[Ea]=l?.[`aria-label`],a===`a`&&e===`click`&&t instanceof HTMLAnchorElement){var m=t.href.substring(0,128);f[Ca]=o.replaceSensitiveString(m)}return Yo(f)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){i===void 0&&(i=!1);var a=o.addTypeAndTimestamp(e,t);try{if(as(a)&&a.event.target!==null){var s=o.getShadowMode(),c=rs(a.event,s);if(i&&Ho(c,a.type))return a.closestTrackedAncestor=c,a.targetElementProperties=o.getEventProperties(a.type,a.closestTrackedAncestor,r),a;var l=Zo(c,n,s);l&&(a.closestTrackedAncestor=l,a.targetElementProperties=o.getEventProperties(a.type,l,r))}}catch{}return a},this.extractDataFromDataSource=function(e,t){if(e.sourceType===`DOM_ELEMENT`){var n=ks(e,t);return n?e.elementExtractType===`TEXT`?o.getText(n):e.elementExtractType===`ATTRIBUTE`&&e.attribute?n.getAttribute(e.attribute):void 0:void 0}},this.getTextWithMaskedDescendants=function(e){var t,r,i=`[${Jn}], [contenteditable]`;if(!e.querySelector(i))return e.innerText;var a=``,s=Array.from(e.childNodes);try{for(var c=n(s),l=c.next();!l.done;l=c.next()){var u=l.value;if(u.nodeType===Node.TEXT_NODE){a+=u.textContent||``;continue}if(u instanceof Element){if(u.hasAttribute(`data-amp-mask`)||u.hasAttribute(`contenteditable`)){a+=Yn;continue}a+=o.getTextWithMaskedDescendants(u)}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return a},this.hasMaskedAncestor=function(e){var t=o.getShadowMode();return t.enabled?Js(e,t):qs(e)},this.getText=function(e){if(o.hasMaskedAncestor(e))return Yn;var t=``;return t=e.querySelector(`[data-amp-mask], [contenteditable]`)?o.getTextWithMaskedDescendants(e):e.innerText||``,o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g,` `).trim()},this.getEventTagProps=function(e){var t,n;if(!e)return{};var r=((n=e?.tagName)?.toLowerCase)?.call(n);return Yo((t={},t[ba]=r,t[xa]=o.getText(e),t[Aa]=window.location.href.split(`?`)[0],t))},this.diagnosticsClient=r?.diagnosticsClient,this.selectorEngine=Xs(),this.shadowGate=Bo();var l=e.maskTextRegex??[],u=[];try{for(var d=n(l),f=d.next();!f.done;f=d.next()){var p=f.value;if(u.length>=25)break;if(p instanceof RegExp)u.push(p);else if(`pattern`in p&&typeof p.pattern==`string`)try{u.push(new RegExp(p.pattern,`i`))}catch{}}}catch(e){i={error:e}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(i)throw i.error}}this.additionalMaskTextPatterns=u}return e}(),Qs=`configs.analyticsSDK.browserSDK.autocapture.elementSelector`;function $s(e,t){var n=e.remoteConfigClient;if(e.fetchRemoteConfig&&n){var r=n.subscribe(Qs,`all`,function(n,r){e.loggerProvider.debug(`@amplitude/element-selector: remote-config delivery (source=${String(r)}) ${JSON.stringify(n)}`),t.updateSelectorConfig(n,e.loggerProvider)});return function(){n.unsubscribe(r)}}}var ec=1,tc=function(e){return e.assignedSlot||e.parentElement||e.parentNode?.host||null},nc=function(e,t){return(t===`fixed`||t===`absolute`)&&e instanceof HTMLElement?e.offsetParent:tc(e)},rc=function(e){var t=B(),n=t.document.documentElement.clientHeight||t.innerHeight,r=t.document.documentElement.clientWidth||t.innerWidth,i=e.getBoundingClientRect(),a=i.top+i.height*Ha,o=Math.max(i.left,0),s=Math.min(i.right,r);if(a<-ec||a>n+ec||o>=s||i.width<=0)return!1;for(var c=nc(e,t.getComputedStyle(e).position);c;){var l=t.getComputedStyle(c),u=l.overflowY&&l.overflowY!==`visible`,d=l.overflowX&&l.overflowX!==`visible`;if(u||d){var f=c.getBoundingClientRect();if(u&&(a<f.top-ec||a>f.bottom+ec)||d&&(o=Math.max(o,f.left),s=Math.min(s,f.right),o>=s))return!1}c=nc(c,l.position)}return!0};function ic(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,a=i===void 0?150:i,o=new Map,s=new Map,c=new Set,l=function(e){var t=s.get(e);t&&(clearTimeout(t),s.set(e,null))},u=function(e){if(!rc(e)){l(e);return}if(!(o.get(e)||s.get(e))){var t=setTimeout(function(){o.set(e,!0),n(r.getElementPath(e)),s.set(e,null)},a);s.set(e,t)}},d=t.exposureObservable,f=t.scrollObservable,p=d.subscribe(function(e){var t=e,n=t.target;t.isIntersecting?(c.add(n),u(n)):(c.delete(n),l(n))}
12),m=f.subscribe(function(){c.forEach(u)}),h=function(){s.forEach(function(e){e&&clearTimeout(e)}),s.clear(),o.clear()};return{unsubscribe:function(){p.unsubscribe(),m.unsubscribe(),h(),c.clear()},reset:function(){h(),c.forEach(u)}}}function ac(e){var t,n=e.amplitude,r=e.scrollTracker,i=e.currentElementExposed,a=e.elementExposedForPage,o=e.elementExposedInSentEvents,s=e.exposureTracker,c=e.isPageEnd,l=e.lastScroll,u=r.getState(),d=B(),f=d?.innerWidth??0,p=d?.innerHeight??0,m=Array.from(i).filter(function(e){return!o.has(e)}),h=(t={},t[Aa]=ss(d),t[Pa]=u.maxX+f,t[Fa]=u.maxY+p,t[Ma]=p,t[Na]=f,t[`[Amplitude] Element Exposed`]=m,t),g=Xo();g&&(h[Ia]=g);var _=function(){r.reset();var e=r.getState();l.maxX=e.maxX,l.maxY=e.maxY,a.clear(),o.clear(),s?.reset()};if(m.length===0&&u.maxX===l.maxX&&u.maxY===l.maxY){c&&_();return}n?.track(`[Amplitude] Viewport Content Updated`,h),l.maxX=u.maxX,l.maxY=u.maxY,m.forEach(function(e){o.add(e)}),i.clear(),c&&_()}function oc(e,t,n,r,i){if(!(t.has(e)||n.has(e))){t.add(e),r.add(e);var a=Array.from(r);JSON.stringify(a).length>=18e3&&i(!1)}}function sc(e){var t=e.mutationObservable,n=e.onRescan,r=e.onFlush,i=e.exposureDuration,a=e.quietMs,o=a===void 0?150:a,s=e.maxWaitMs,c=s===void 0?Ua:s,l=!1,u,d,f,p,m,h=function(){u&&=(clearTimeout(u),void 0),d&&=(clearTimeout(d),void 0),f&&=(clearTimeout(f),void 0)},g=function(){m&&=(document.removeEventListener(`DOMContentLoaded`,m),void 0)},_=function(){return typeof document<`u`&&document.readyState!==`loading`},v=function(){if(!l){if(!_()){m||(m=function(){m=void 0,y()},document.addEventListener(`DOMContentLoaded`,m));return}l=!0,h(),g(),n(),f=setTimeout(function(){f=void 0,r()},i+50)}},y=function(){l||(u&&clearTimeout(u),u=setTimeout(v,o))},b=function(){h(),g(),l=!1,y(),d=setTimeout(v,c)};return{start:function(){p||(p=t.subscribe(function(){y()}),b())},reset:function(){b()},stop:function(){p?.unsubscribe(),p=void 0,h(),g()}}}var q;(function(e){e.ClickObservable=`clickObservable`,e.PointerDownObservable=`pointerDownObservable`,e.ChangeObservable=`changeObservable`,e.NavigateObservable=`navigateObservable`,e.MutationObservable=`mutationObservable`,e.ScrollObservable=`scrollObservable`,e.ExposureObservable=`exposureObservable`,e.BrowserErrorObservable=`browserErrorObservable`,e.SelectionObservable=`selectionObservable`,e.MouseMoveObservable=`mouseMoveObservable`})(q||={});var cc=function(e,a){e===void 0&&(e={}),a?.diagnosticsClient.setTag(`plugin.autocapture.version`,`1.29.5`);var o=e.dataAttributePrefix,l=o===void 0?vn:o,u=e.visualTaggingOptions,d=u===void 0?{enabled:!0}:u;e.cssSelectorAllowlist=e.cssSelectorAllowlist??_n,e.actionClickAllowlist=e.actionClickAllowlist??yn,e.debounceTime=e.debounceTime??0;var f=e.viewportContentUpdated?.enabled!==!1,p=e.viewportContentUpdated?.exposureDuration??e.exposureDuration??150;e.viewportContentUpdated=c(c({},e.viewportContentUpdated),{exposureDuration:p}),e.pageUrlExcludelist=e.pageUrlExcludelist?.reduce(function(e,t){if(typeof t==`string`&&e.push(t),t instanceof RegExp&&e.push(t),typeof t==`object`&&t&&`pattern`in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn(`Invalid regex pattern: ${t.pattern}`,n),e}return e},[]);var m=ua,h=`enrichment`,g=[],_=new Zs(e,a),v=new Set,y=new Set,b=new Set,x,S,C=function(){var t,n=ir(bs().map(function(t){return _.addAdditionalEventProperties(t,`click`,e.cssSelectorAllowlist,l)})),r=ir(new K.default(function(t){var n,r=function(n){var r=_.addAdditionalEventProperties(n,`change`,e.cssSelectorAllowlist,l);t.next(r)};return(n=B())==null||n.document.addEventListener(`change`,r,{capture:!0}),function(){return B()?.document.removeEventListener(`change`,r)}})),i;window.navigation&&(i=ir(new K.default(function(t){var n=function(n){var r=_.addAdditionalEventProperties(n,`navigate`,e.cssSelectorAllowlist,l);t.next(r)};return window.navigation.addEventListener(`navigate`,n),function(){window.navigation.removeEventListener(`navigate`,n)}})));var a=_.shadowGate,o=ir(ys(a).map(function(t){return _.addAdditionalEventProperties(t,`mutation`,e.cssSelectorAllowlist,l)}
12)),s=xs(),c=Cs(o,e.cssSelectorAllowlist,function(e){S=e},a);return t={},t[q.ChangeObservable]=r,t[q.ClickObservable]=n,t[q.MutationObservable]=o,t[q.NavigateObservable]=i,t[q.ScrollObservable]=s,t[q.ExposureObservable]=c,t},w=Ms(Object.values(e.pageActions?.labeledEvents??{})),T=Ns(e.pageActions?.triggers??[]),E=Ls(w,T,_,e),D=function(t){t&&(e.pageActions=c(c({},e.pageActions),t),w=Ms(Object.values(e.pageActions.labeledEvents??{})),T=Ns(e.pageActions.triggers??[]),E.update(w,T,e))};return{name:m,type:h,setup:function(n,a){return i(void 0,void 0,void 0,function(){var i,o,u,h,w,T,O,k,A,j,M,N,ee,P,F,te,ne,re,ie,I,ae,oe,se,L,ce,le,ue;return r(this,function(r){return typeof document>`u`?[2]:(i=!1,n.fetchRemoteConfig&&(n.remoteConfigClient?n.remoteConfigClient.subscribe(`configs.analyticsSDK.pageActions`,`all`,function(e){D(e)}):n.loggerProvider.debug(`Remote config client is not provided, skipping remote config fetch`)),o=$s(n,_),o&&g.push({unsubscribe:o}),u=Wo(e,e.cssSelectorAllowlist),h=Wo(e,e.actionClickAllowlist),w=C(),T=fs({allObservables:w,amplitude:a,shouldTrackEvent:u,evaluateTriggers:E.evaluate.bind(E)}),g.push(T),O=ps({allObservables:w,getEventProperties:function(){var e=[...arguments];return _.getEventProperties.apply(_,s(s([],t(e),!1),[l],!1))},amplitude:a,shouldTrackEvent:u,evaluateTriggers:E.evaluate.bind(E)}),g.push(O),k=ms({allObservables:w,options:e,getEventProperties:function(){var e=[...arguments];return _.getEventProperties.apply(_,s(s([],t(e),!1),[l],!1))},amplitude:a,shouldTrackEvent:u,shouldTrackActionClick:h}),k&&g.push(k),A=hs({allObservables:w,amplitude:a}),g.push(A),j=c({},A.getState()),M={},N=B(),P=function(e){e&&ee?.reset(),!(e&&i)&&(e&&(i=!0,setTimeout(function(){i=!1},100)),ac({amplitude:a,scrollTracker:A,currentElementExposed:b,elementExposedForPage:v,elementExposedInSentEvents:y,exposureTracker:M.exposure,isPageEnd:e,lastScroll:j}))},F=ss(N),te=function(){var e=ss(N);e!==F&&(F=e,P(!0))},ne=function(e,t){var n=ss(N),r=cs(t,N);if(n===r){e();return}F=r,P(!0),e()},re=function(e){oc(e,v,y,b,P)},f&&(M.exposure=ic({allObservables:w,onExposure:re,dataExtractor:_,exposureDuration:p}),M.exposure&&g.push(M.exposure),ee=sc({mutationObservable:w[q.MutationObservable],onRescan:function(){var e,t;(t=(e=n.loggerProvider)?.debug)==null||t.call(e,`@amplitude/plugin-autocapture-browser: initial exposure snapshot — rescanning DOM`),S?.()},onFlush:function(){var e,t;(t=(e=n.loggerProvider)?.debug)==null||t.call(e,`@amplitude/plugin-autocapture-browser: initial exposure snapshot — flushing viewport content updated`),P(!1)},exposureDuration:p}),ee.start(),g.push({unsubscribe:function(){ee?.stop()}}),ie=function(){P(!0)},N?.addEventListener(`beforeunload`,ie),x=function(){N?.removeEventListener(`beforeunload`,ie)},g.push({unsubscribe:function(){return x()}}),I=w[q.NavigateObservable],I?g.push(I.subscribe(function(e){var t=e.event?.destination?.url;if(t){var n=os(t);if(n===F)return;F=n,P(!0);return}te()})):N&&(ae=function(){te()},N.addEventListener(`popstate`,ae),oe=N.history.pushState,se=N.history.replaceState,N.history&&oe&&(N.history.pushState=new Proxy(oe,{apply:function(e,t,n){ne(function(){e.apply(t,n)},n[2])}})),N.history&&se&&(N.history.replaceState=new Proxy(se,{apply:function(e,t,n){ne(function(){e.apply(t,n)},n[2])}})),g.push({unsubscribe:function(){N.removeEventListener(`popstate`,ae),N.history&&oe&&(N.history.pushState=oe),N.history&&se&&(N.history.replaceState=se)}}))),(ue=n?.loggerProvider)==null||ue.log(`${m} has been successfully added.`),window.opener&&d.enabled&&(L=e.cssSelectorAllowlist,ce=e.actionClickAllowlist,le=hr(),ds(le,{dataExtractor:_,isElementSelectable:Wo(e,s(s([],t(L),!1),t(ce),!1)),cssSelectorAllowlist:L,actionClickAllowlist:ce}),yr(le),le.setup(c({logger:n?.loggerProvider},n?.serverZone&&{endpoint:or[n.serverZone]}))),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){var e,t,i,a,o;return r(this,function(r){try{for(e=n(g),t=e.next();!t.done;t=e.next())i=t.value,i.unsubscribe()}catch(e){a={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]})})}}},lc=3e3,uc=[`mutation`,`navigate`];function dc(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,a=n.clickObservable,o=n.mutationObservable,s=n.navigateObservable,l=rr(a.filter(function(e){return is(e)&&i(`click`,e.closestTrackedAncestor)&&e.event.target instanceof Element&&e.event.target.closest(`a[target="_blank"]`)===null&&e.event.button===ls.LEFT_OR_TOUCH_CONTACT}),s?rr(o,s):o),u=null;return nr(l,function(e){return u&&uc.includes(e.type)?(clearTimeout(u),u=null,Promise.resolve(null)):e.type===`click`?u?Promise.resolve(null):new Promise(function(t){u=setTimeout(function(){t(e),u=null},lc)}):Promise.resolve(null)}).subscribe(function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track(pa,c(c({},r(`click`,e.closestTrackedAncestor)),n),{time:e.timestamp})}})}var fc=4,pc=wn,mc=50;function hc(e,t){var n=t.event,r=n.pageX,i=n.pageY;e.yMin=Math.min(e.yMin??i,i),e.yMax=Math.max(e.yMax??i,i),e.xMin=Math.min(e.xMin??r,r),e.xMax=Math.max(e.xMax??r,r),e.isOutOfBounds=e.yMax-e.yMin>mc||e.xMax-e.xMin>mc}function gc(e){if(e.length===0)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:c({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function _c(e,t){var n=e[Math.max(0,e.length-fc+1)];return t.timestamp-n.timestamp>=pc}function vc(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}function yc(e){var t=this,n=e.amplitude,a=e.allObservables,o=e.shouldTrackRageClick,s=a.pointerDownObservable,c=a.selectionObservable,l=[],u={},d=null;function f(e){l=[],u={},e&&(hc(u,e),l.push(e))}var p=nr(s.filter(function(e){return o(`click`,e.closestTrackedAncestor)}),function(e){return i(t,void 0,void 0,function(){var t;return r(this,function(n){return hc(u,e),t=null,l.length===0||vc(l,e)||_c(l,e)||u.isOutOfBounds?(d&&(t=gc(l)),f(e)):l.push(e),d&&=(clearTimeout(d.timerId),d.resolve(t),null),l.length>=fc?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(gc(l))},pc)}})]:[2,null]})})}),m=c?.subscribe(function(){f()}),h=p.subscribe(function(e){e!==null&&n.track(ma,e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){h.unsubscribe(),m?.unsubscribe()}}}var bc=2e3;function xc(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.pointerDownObservable,a=n.browserErrorObservable,o=i.filter(function(e){return is(e)&&r(`click`,e.closestTrackedAncestor)&&e.event.target instanceof Element&&e.event.target.closest(`a[target="_blank"]`)===null&&e.event.button===ls.LEFT_OR_TOUCH_CONTACT}),s=null,l=null,u=function(){s!==null&&(clearTimeout(s),s=null),l=null};return rr(o,a).subscribe(function(e){var n;if(e.type===`click`){u(),l=e,s=setTimeout(u,bc);return}e.type===`error`&&l&&(t.track(ha,c((n={},n[`[Amplitude] Kind`]=e.event.kind,n[`[Amplitude] Message`]=e.event.message,n[`[Amplitude] Stack`]=e.event.stack,n[`[Amplitude] Filename`]=e.event.filename,n[`[Amplitude] Line Number`]=e.event.lineNumber,n[`[Amplitude] Column Number`]=e.event.columnNumber,n),l.targetElementProperties)),u())})}var Sc;(function(e){e.INCREASING=`increasing`,e.DECREASING=`decreasing`})(Sc||={});var Cc;(function(e){e.X=`x`,e.Y=`y`})(Cc||={});var wc=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new K.default(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var a={x:t.clientX,y:t.clientY};if(n===null){n=a;return}a.x>n.x?(r===Sc.DECREASING&&e.next(Cc.X),r=Sc.INCREASING):a.x<n.x&&(r===Sc.INCREASING&&e.next(Cc.X),r=Sc.DECREASING),a.y>n.y?(i===Sc.DECREASING&&e.next(Cc.Y),i=Sc.INCREASING):a.y<n.y&&(i===Sc.INCREASING&&e.next(Cc.Y),i=Sc.DECREASING),n=a})})};function Tc(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}function Ec(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return t.length<n?!1:t[t.length-1]-t[0]<r}function Dc(e){e.changes=[],e.startTime=void 0}function Oc(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length&&!(i-t[r]<n);r++);r!==0&&(e.startTime=t[r],e.changes.splice(0,r))}function kc(e,t){var n=void 0;if(Ec(e)&&(n=e.startTime),Ec(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}var Ac=20,jc=2e3,Mc=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=n===void 0?Ac:n,i=e.thresholdMs,a=i===void 0?jc:i;return new K.default(function(e){var n={changes:[],changesThreshold:r,thresholdMs:a},i={changes:[],changesThreshold:r,thresholdMs:a},o=void 0,s=null;function c(){o!==void 0&&(e.next(o),o=void 0,s!==null&&clearTimeout(s),Dc(n),Dc(i))}return t.subscribe(function(e){s!==null&&clearTimeout(s),Tc(e===Cc.X?n:i);var t=kc(n,i);return t?(o||=t,s=setTimeout(function(){c(),s=null},a)):c(),Oc(n),Oc(i),function(){s!==null&&(clearTimeout(s),s=null)}})})},Nc=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,a=i===void 0?Ac:i,o=e.thresholdMs,s=o===void 0?jc:o;return Mc({mouseDirectionChangeObservable:wc({allWindowObservables:r}),directionChanges:a,thresholdMs:s}).subscribe(function(e){Uo(n)&&t.track(ga,void 0,{time:e})})};function Pc(e,t,n,r){if(!r)return[];var i=e[t];return typeof i==`object`&&i&&`cssSelectorAllowlist`in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var Fc=5,Ic=4e3,Lc=function(e){e===void 0&&(e={});var a=da,o=`enrichment`,l=[],u=e.errorClicks!==!1;e.errorClicks||(u=!1);var d=e.deadClicks!==!1&&e.deadClicks!==null,f=e.rageClicks!==!1&&e.rageClicks!==null,p=e.thrashedCursor!==!1&&e.thrashedCursor!==null;e.thrashedCursor||(p=!1);var m=Pc(e,`rageClicks`,Cn,f),h=Pc(e,`deadClicks`,xn,d),g=Pc(e,`errorClicks`,Sn,u),_=e.dataAttributePrefix??vn,v=new Zs(e),y=s([],t(new Set(s(s(s([],t(m),!1),t(h),!1),t(g),!1))),!1),b=function(){var e,t=function(e){return ir(bs(e).map(function(e){return v.addAdditionalEventProperties(e,`click`,y,_,!0)}))},n=t(`click`),r=t(`pointerdown`),i=ir(Es().map(function(e){return v.addTypeAndTimestamp(e,`error`)})),a=ir(ys(v.shadowGate).map(function(e){return v.addAdditionalEventProperties(e,`mutation`,y,_)})),o;window.navigation&&(o=ir(new K.default(function(e){var t=function(t){e.next(c(c({},t),{type:`navigate`}))};return window.navigation.addEventListener(`navigate`,t),function(){window.navigation.removeEventListener(`navigate`,t)}}).map(function(e){return v.addAdditionalEventProperties(e,`navigate`,y,_)})));
12var s=ir(new K.default(function(e){var t=function(){var t=document.activeElement;if(t&&(t.tagName===`TEXTAREA`||t.tagName===`INPUT`)){var n=void 0,r=void 0;try{if(n=t.selectionStart,r=t.selectionEnd,n===r)return}catch{return}return e.next()}var i=window.getSelection();if(i&&!i.isCollapsed)return e.next()};return window.document.addEventListener(`selectionchange`,t),function(){window.document.removeEventListener(`selectionchange`,t)}})),l=ir(Ds());return e={},e[q.ClickObservable]=n,e[q.PointerDownObservable]=r,e[q.MutationObservable]=a,e[q.NavigateObservable]=o,e[q.BrowserErrorObservable]=i,e[q.SelectionObservable]=s,e[q.MouseMoveObservable]=l,e};return{name:a,type:o,setup:function(t,n){return i(void 0,void 0,void 0,function(){var i,o,s,c,y,x,S,C,w,T,E,D;return r(this,function(r){return typeof document>`u`?[2]:(i=b(),o=$s(t,v),o&&l.push({unsubscribe:o}),f&&(s=Wo(e,m),c=yc({allObservables:i,amplitude:n,shouldTrackRageClick:s}),l.push(c)),d&&(y=Wo(e,h),x=dc({amplitude:n,allObservables:i,getEventProperties:function(e,t){return v.getEventProperties(e,t,_)},shouldTrackDeadClick:y}),l.push(x)),u&&(S=Wo(e,g),C=xc({amplitude:n,allObservables:i,shouldTrackErrorClick:S}),l.push(C)),p&&(w=void 0,T=void 0,typeof e.thrashedCursor==`object`&&(w=e.thrashedCursor.directionChanges,T=e.thrashedCursor.threshold,w&&w<Fc&&(t.loggerProvider.warn(`'thrashedCursor.directionChanges' of ${w} is below the minimum of ${Fc}, setting to ${Fc}`),w=Fc),T&&T>Ic&&(t.loggerProvider.warn(`'thrashedCursor.threshold' of ${T} is above the maximum of ${Ic}, setting to ${Ic}`),T=Ic)),E=Nc({amplitude:n,options:e,allObservables:i,directionChanges:w,thresholdMs:T}),l.push(E)),(D=t?.loggerProvider)==null||D.log(`${a} has been successfully added.`),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){var e,t,i,a,o;return r(this,function(r){try{for(e=n(l),t=e.next();!t.done;t=e.next())i=t.value,i.unsubscribe()}catch(e){a={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return[2]})})}}},Rc=100,zc=1e4;function Bc(e,t){var n=e.startTime+e.duration;return t.filter(function(t){return t.startTime<n&&t.startTime+t.duration>e.startTime}).map(function(e){return e.name})}function Vc(e,t){var n=Bc(e,t),r=e.scripts??[],i=r.map(function(e){return e.sourceURL}).filter(Boolean),a=r.map(function(e){return e.sourceFunctionName}).filter(Boolean),o=r.map(function(e){return e.sourceCharPosition}).filter(function(e){return typeof e==`number`&&e>=0}),s=r.map(function(e){return e.invokerType}).filter(Boolean),l=r.map(function(e){return e.invoker}).filter(Boolean);return c(c(c(c(c(c(c({"[Amplitude] Main Thread Block Source":`long-animation-frame`,"[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.blockingDuration,"[Amplitude] Main Thread Block Start Time":e.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),{"[Amplitude] Main Thread Block Render Start":e.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":e.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":r.length}),i.length>0&&{"[Amplitude] Main Thread Block Script URLs":i}),a.length>0&&{"[Amplitude] Main Thread Block Script Functions":a}),o.length>0&&{"[Amplitude] Main Thread Block Script Positions":o}),s.length>0&&{"[Amplitude] Main Thread Block Invoker Types":s}),l.length>0&&{"[Amplitude] Main Thread Block Invokers":l})}function Hc(e,t){var n=Bc(e,t),r=e.attribution??[];return c(c({"[Amplitude] Main Thread Block Source":`long-task`,"[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.duration,"[Amplitude] Main Thread Block Start Time":e.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),r.length>0&&{"[Amplitude] Main Thread Block Attribution":r.map(function(e){return e.name})})}function Uc(){if(typeof PerformanceObserver>`u`)return null;try{var e=PerformanceObserver.supportedEntryTypes;if(e.includes(`long-animation-frame`))return`long-animation-frame`;if(e.includes(`longtask`))return`longtask`}catch{}return null}function Wc(e){var t=e.amplitude,r=e.options,i=e.durationThreshold,a=i===void 0?Rc:i,o=Uc();if(!o)return{unsubscribe:function(){}};var s=[],c=new PerformanceObserver(function(e){var t,r,i=performance.now();try{for(var a=n(e.getEntries()),o=a.next();!o.done;o=a.next()){var c=o.value;s.push(c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}for(var l=i-zc;s.length>0&&s[0].startTime<l;)s.shift()});try{c.observe({entryTypes:[`measure`]})}catch{}var l=new PerformanceObserver(function(e){var i,c;try{for(var l=n(e.getEntries()),u=l.next();!u.done;u=l.next()){var d=u.value;if(!Uo(r))return;if(!(d.duration<a)){var f=o===`long-animation-frame`?Vc(d,s):Hc(d,s);t.track(_a,f)}}}catch(e){i={error:e}}finally{try{u&&!u.done&&(c=l.return)&&c.call(l)}finally{if(i)throw i.error}}});try{l.observe({entryTypes:[o]})}catch{return c.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){l.disconnect(),c.disconnect()}}}var Gc=100,Kc=function(e){e===void 0&&(e={});var t=fa,a=`enrichment`,o=[],s=e.mainThreadBlock===!0||typeof e.mainThreadBlock==`object`&&e.mainThreadBlock!==null;return{name:t,type:a,setup:function(n,a){return i(void 0,void 0,void 0,function(){var i,c,l;return r(this,function(r){return typeof document>`u`?[2]:(s&&(i=Gc,typeof e.mainThreadBlock==`object`&&e.mainThreadBlock.durationThreshold!==void 0&&(i=e.mainThreadBlock.durationThreshold),c=Wc({amplitude:a,options:e,durationThreshold:i}),o.push(c)),(l=n?.loggerProvider)==null||l.log(`${t} performance tracking has been successfully added.`),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){var e,t,i,a,s;return r(this,function(r){try{for(e=n(o),t=e.next();!t.done;t=e.next())i=t.value,i.unsubscribe()}catch(e){a={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]})})}}},qc=`@amplitude/plugin-network-capture-browser`,Jc=`500-599`;function Yc(e,t){var n=`^`+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,`\\$&`).replace(/\*/g,`.*`)+`$`;return new RegExp(n).test(e)}function Xc(e,r){var i,a,o=r.split(`,`);try{for(var s=n(o),c=s.next();!c.done;c=s.next()){var l=c.value,u=t(l.split(`-`).map(Number),2),d=u[0],f=u[1];if(e===d&&f===void 0||e>=d&&e<=f)return!0}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return!1}function Zc(e,t,n,r,i){if((!e.hosts||e.hosts.find(function(e){return Yc(t,e)}))&&!(r&&e.urls&&!bt(r,e.urls))&&!(i&&e.methods&&!e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||e===`*`})))return!n&&n!==0||!!Xc(n,e.statusCodeRange||Jc)}function Qc(e){var t=e.indexOf(`#`),n=t>
12=0?e.slice(t+1):``,r=t>=0?e.slice(0,t):e,i=r.indexOf(`?`),a=i>=0?r.slice(i+1):``,o=i>=0?r.slice(0,i):r;return{query:a,fragment:n,href:e,hrefWithoutQueryOrHash:o,host:o.match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i)?.[1]??``}}function $c(e){if(e)try{var t=B()?.location.href,n=new URL(e,t),r=n.searchParams.toString(),i=n.hash.replace(`#`,``),a=n.href,o=n.host;return n.hash=``,n.search=``,{query:r,fragment:i,href:a,hrefWithoutQueryOrHash:n.href,host:o}}catch{try{return Qc(e)}catch{return}}}function el(e,t){if(e.includes(`amplitude.com`))try{var n=t.body;if(typeof n!=`string`)return!1;if(JSON.parse(n).events.find(function(e){return e.event_type===`[Amplitude] Network Request`}))return!0}catch{}return!1}function tl(e){if(typeof e!=`object`||!e)return e?s([],t(L),!1):void 0;if(e.length!==0)return e}function nl(e){return!e?.allowlist?.length&&!e?.blocklist?.length&&!e?.excludelist?.length}function rl(e,n){n===void 0&&(n={});var r=$c(e.url);if(!r)return!1;var i=r.host;if(n.ignoreAmplitudeRequests!==!1&&(Yc(i,`*.amplitude.com`)||Yc(i,`amplitude.com`))||n.ignoreHosts?.find(function(e){return Yc(i,e)})||!n.captureRules&&e.status!==void 0&&!Xc(e.status,Jc))return!1;if(n.captureRules){var a;if(s([],t(n.captureRules),!1).reverse().find(function(t){if(a=Zc(t,i,e.status,e.url,e.method),a){var n=tl(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var o=tl(t.requestHeaders);if(e.requestWrapper&&o){var s=e.requestWrapper.headers(o);s&&(e.requestHeaders=s)}if(e.responseWrapper&&t.responseBody&&!nl(t.responseBody)){var c=t.responseBody.excludelist||t.responseBody.blocklist;e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,c)}if(e.requestWrapper&&t.requestBody&&!nl(t.requestBody)){var c=t.requestBody.excludelist||t.requestBody.blocklist;e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,c)}}return a!==void 0}),!a)return!1}return!(e.requestWrapper&&el(i,e.requestWrapper))}function il(e,n,a,o){return i(this,void 0,void 0,function(){var i,s,c;return r(this,function(r){switch(r.label){case 0:return n.requestBodyJson||n.responseBodyJson?[4,Promise.all([n.requestBodyJson,n.responseBodyJson])]:[3,2];case 1:if(i=t.apply(void 0,[r.sent(),2]),s=i[0],c=i[1],s)try{e[`[Amplitude] Request Body`]=JSON.stringify(s)}catch(e){o?.debug(`Failed to stringify request body`,e)}if(c)try{e[`[Amplitude] Response Body`]=JSON.stringify(c)}catch{o?.debug(`Failed to stringify response body`)}r.label=2;case 2:return a?.track(`[Amplitude] Network Request`,e),[2]}})})}function al(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return rl(e.event,n)}).subscribe(function(e){var t,n=e.event,a=$c(n.url);if(a){var o=n.responseWrapper?.bodySize,s=n.requestWrapper?.bodySize;il((t={},t[`[Amplitude] URL`]=a.hrefWithoutQueryOrHash,t[`[Amplitude] URL Query`]=a.query,t[`[Amplitude] URL Fragment`]=a.fragment,t[`[Amplitude] Request Method`]=n.method,t[`[Amplitude] Status Code`]=n.status,t[`[Amplitude] Start Time`]=n.startTime,t[`[Amplitude] Completion Time`]=n.endTime,t[`[Amplitude] Duration`]=n.duration,t[`[Amplitude] Request Body Size`]=s,t[`[Amplitude] Response Body Size`]=o,t[`[Amplitude] Request Type`]=n.type,t[`[Amplitude] Request Headers`]=n.requestHeaders,t[`[Amplitude] Response Headers`]=n.responseHeaders,t),n,r,i)}})}var ol;(function(e){e.NetworkObservable=`networkObservable`})(ol||={});var sl,cl=function(e){e===void 0&&(e={});var t=qc,n=`enrichment`,a,o=function(e,t){return{event:e,timestamp:Date.now(),type:t}},s=function(){var e,t=new K.default(function(e){var t=new Un(function(t){var n=o(t,`network`);e.next(n)});return Gn.subscribe(t,a),function(){Gn.unsubscribe(t)}});return e={},e[ol.NetworkObservable]=t,e};return{name:t,type:n,setup:function(n,o){return i(void 0,void 0,void 0,function(){var i;return r(this,function(r){return typeof document>`u`&&!Sr()?[2]:(i=s(),a=n?.loggerProvider,sl=al({allObservables:i,networkTrackingOptions:e,amplitude:o,loggerProvider:a}),a?.log(`${t} has been successfully added.`),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){return sl.unsubscribe(),[2]})})}}},ll=`web-vitals-browser`,ul=`[Amplitude] Web Vitals`,dl=1e3,fl={LCP:`[Amplitude] LCP`,FCP:`[Amplitude] FCP`,INP:`[Amplitude] INP`,CLS:`[Amplitude] CLS`,TTFB:`[Amplitude] TTFB`},pl=-1,ml=()=>pl,hl=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(pl=t.timeStamp,e(t))},!0)},gl=(e,t,n,r)=>{let i,a;return o=>{t.value>=0&&(o||r)&&(a=t.value-(i??0),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},_l=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},vl=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},yl=()=>vl()?.activationStart??0,bl=-1,xl=new Set,Sl=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,Cl=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of xl)e();isFinite(bl)||(bl=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,Cl,!0))}},wl=(e=!1)=>
12{if(e&&(bl=1/0),bl<0){let e=yl();bl=(document.prerendering?void 0:globalThis.performance.getEntriesByType(`visibility-state`).find(t=>t.name===`hidden`&&t.startTime>=e)?.startTime)??Sl(),addEventListener(`visibilitychange`,Cl,!0),addEventListener(`prerenderingchange`,Cl,!0),hl(()=>{setTimeout(()=>{bl=Sl()})})}return{get firstHiddenTime(){return bl},onHidden(e){xl.add(e)}}},Tl=(e,t=-1,n,r=0,i,a,o)=>{let s=vl(),c=s?.navigationId||0,l=`navigate`;return n?l=n:ml()>=0?l=`back-forward-cache`:s&&(document.prerendering||yl()>0?l=`prerender`:document.wasDiscarded?l=`restore`:s.type&&(l=s.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:l,navigationId:r||c,navigationInteractionId:i,navigationURL:a||s?.name,navigationStartTime:o||0}},El=new WeakMap;function Dl(e,t){let n=El.get(t);return n||(n=new WeakMap,El.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}var Ol=class{t;i=0;o=[];h(e){if(e.hadRecentInput)return;let t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},kl=(e,t,n={})=>{try{let r=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(r.length>0){let e=new PerformanceObserver(e=>{queueMicrotask(()=>{let n=e.getEntries();r.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(let t of r)e.observe({type:t,buffered:!0,...n});return e}}catch{}},Al=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes(`soft-navigation`)&&typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint==`function`&&e&&e.reportSoftNavs,jl=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},Ml=e=>{let t=!1;return()=>{t||=(e(),!0)}},Nl=class{l},Pl=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},Fl=[1800,3e3],Il=(e,t={})=>{let n=Al(t);Pl(()=>{let r=Dl(t,Nl),i=wl(),a,o=Tl(`FCP`),s=kl([`paint`],e=>{for(let t of e)t.name===`first-contentful-paint`&&(s.disconnect(),t.startTime<i.firstHiddenTime&&(o.value=Math.max(t.startTime-yl(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,a(!0)))});s&&(a=gl(e,o,Fl,t.reportAllChanges),hl(n=>{o=Tl(`FCP`,-1,`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ml()),a=gl(e,o,Fl,t.reportAllChanges),_l(()=>{o.value=performance.now()-n.timeStamp,a(!0)})})),n&&kl([`soft-navigation`],n=>{n.forEach(n=>{r.l&&n.navigationId&&jl(r.l,n),o=Tl(`FCP`,Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0),`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),a=gl(e,o,Fl,t.reportAllChanges),a(!0)})},t)})},Ll=[.1,.25],Rl=(e,t={})=>{let n=wl();Il(Ml(()=>{let r,i=Tl(`CLS`,0),a=Dl(t,Ol),o=(n,o,s,c,l)=>{i=Tl(`CLS`,0,n,o,s,c,l),a.i=0,r=gl(e,i,Ll,t.reportAllChanges)},s=(e=!1)=>{a.i>i.value&&(i.value=a.i,i.entries=a.o),r(e)},c=e=>{s(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=e=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.h(t);s()},u=[`layout-shift`];Al(t)&&u.push(`soft-navigation`);let d=kl(u,l);d&&(r=gl(e,i,Ll,t.reportAllChanges),n.onHidden(()=>{l(d.takeRecords()),r(!0)}),hl(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ml()),_l(r)}),setTimeout(r))}))},zl=0,Bl=1/0,Vl=0,Hl=e=>{for(let t of e)t.interactionId&&(Bl=Math.min(Bl,t.interactionId),Vl=Math.max(Vl,t.interactionId),zl=Vl?(Vl-Bl)/7+1:0)},Ul,Wl=()=>Ul?zl:performance.interactionCount??0,Gl=()=>{`interactionCount`in performance||Ul||(Ul=kl([`event`],Hl,{durationThreshold:0}))},Kl=class{u=0;v=[];m=new Map;p;T;_(){return Wl()-this.u}M(){this.u=Wl(),this.v.length=0,this.m.clear()}L(e){let t=this._(),n=Math.min(this.v.length-1,Math.floor(t/50));return!t||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;let t=this.v.at(-1),n=this.m.get(e.interactionId);if(n||this.v.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.m.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>
12t.P-e.P),this.v.length>10){let e=this.v.splice(10);for(let t of e)this.m.delete(t.id)}this.T?.(n)}}},ql=e=>{let t=`requestIdleCallback`in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,r=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let i=Ml(e),a=-1,o=()=>{r(a),i()};addEventListener(`visibilitychange`,o,{once:!0,capture:!0}),a=n(()=>{removeEventListener(`visibilitychange`,o,{capture:!0}),i()},{timeout:t})}},Jl=[200,500],Yl=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=wl();Pl(()=>{Gl();let r,i=Tl(`INP`),a=Dl(t,Kl),o=(n,o,s,c,l)=>{a.M(),i=Tl(`INP`,-1,n,o,s,c,l),r=gl(e,i,Jl,t.reportAllChanges)},s=()=>{let e=a.L(i.navigationType);e&&e.P!==i.value&&(i.value=e.P,i.entries=e.entries,r())},c=e=>{s(),r(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=(e,t=!1)=>{ql(()=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.h(t);s(),t&&r(!0)})},u=[`event`,`first-input`];Al(t)&&u.push(`soft-navigation`);let d=kl(u,l,{...t,durationThreshold:t.durationThreshold??40});r=gl(e,i,Jl,t.reportAllChanges),d&&(n.onHidden(()=>{l(d.takeRecords(),!0)}),hl(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ml())}))})},Xl=class{p;l;h(e){this.p?.(e)}},Zl=[2500,4e3],Ql=(e,t={})=>{let n=!1,r=Al(t);Pl(()=>{let i,a=wl(),o=Tl(`LCP`),s=Dl(t,Xl),c=(r,s,c,l,u)=>{o=Tl(`LCP`,-1,r,s,c,l,u),i=gl(e,o,Zl,t.reportAllChanges),n=!1,r===`soft-navigation`&&(a=wl(!0))},l=e=>{s.l&&e.navigationId&&jl(s.l,e),n||i(!0),c(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime);let t=e.getLargestInteractionContentfulPaint?.();t&&u([t])},u=e=>{t.reportAllChanges||r||(e=e.slice(-1));for(let t of e){if(!t)continue;if(t.entryType===`soft-navigation`){l(t);continue}let e=0,n=[],r=t.startTime;if(t.entryType===`largest-contentful-paint`)e=Math.max(t.startTime-yl(),0),s.h(t),n=[t];else if(t.entryType===`interaction-contentful-paint`){let i=t;if(!o.navigationId||`interactionId`in i&&i.interactionId!=o.navigationInteractionId)continue;r=i.largestContentfulPaint?.renderTime||0,e=Math.max(r-t.startTime,0),i.largestContentfulPaint&&(s.h(i.largestContentfulPaint),n=[i.largestContentfulPaint])}r<a.firstHiddenTime&&(o.value=e,o.entries=n,i())}},d=[`largest-contentful-paint`];r&&d.push(`interaction-contentful-paint`,`soft-navigation`);let f=kl(d,u);if(f){i=gl(e,o,Zl,t.reportAllChanges);let a=[`keydown`,`click`,`visibilitychange`],s=e=>{if(e.isTrusted&&!n){let e=o.id;ql(()=>{if(!n){if(!r){f.disconnect();for(let e of a)removeEventListener(e,s,{capture:!0})}e===o.id&&(n=!0,i(!0))}})}};for(let e of a)addEventListener(e,s,{capture:!0});hl(r=>{c(`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ml()),i=gl(e,o,Zl,t.reportAllChanges),_l(()=>{o.value=performance.now()-r.timeStamp,n=!0,i(!0)})})}})},$l=[800,1800],eu=e=>{document.prerendering?Pl(()=>eu(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>eu(e),!0)},tu=(e,t={})=>{let n=Al(t),r=Tl(`TTFB`),i=gl(e,r,$l,t.reportAllChanges);eu(()=>{let a=vl();if(a){let o=a.responseStart;r.value=Math.max(o-yl(),0),r.entries=[a],i(!0),hl(()=>{r=Tl(`TTFB`,0,`back-forward-cache`,r.navigationId,r.navigationInteractionId,r.navigationURL,ml()),i=gl(e,r,$l,t.reportAllChanges),i(!0)}),n&&kl([`soft-navigation`],n=>{n.forEach(n=>{n.navigationId&&(r=Tl(`TTFB`,0,`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),r.entries=[n],i=gl(e,r,$l,t.reportAllChanges),i(!0))})},t)}})};function nu(e){var t=e.entries[0]?.startTime||0;return performance.timeOrigin+t}function ru(e,t){t===void 0&&(t=!1);var n={value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(nu(e)),navigationStart:Math.floor(t?performance.timeOrigin+(e.navigationStartTime||0):performance.timeOrigin)};return t&&(n.navigationId=e.navigationId),n}var iu=function(){var e=null,t=B(),n=t?.document,a=t?.location;return{name:ll,type:`enrichment`,setup:function(t,o){return i(void 0,void 0,void 0,function(){var i,s;return r(this,function(r){return n===void 0?[2]:(i=xt(a?.href||``,t.loggerProvider),s={"[Amplitude] Page Domain":a?.hostname||``,"[Amplitude] Page Location":i,"[Amplitude] Page Path":xt(a?.pathname||``,t.loggerProvider),"[Amplitude] Page Title":typeof document<`u`&&document.title||``,"[Amplitude] Page URL":xt(i.split(`?`)[0],t.loggerProvider)},Ql(function(e){s[`[Amplitude] LCP`]=ru(e)}
12),Il(function(e){s[`[Amplitude] FCP`]=ru(e)}),Yl(function(e){s[`[Amplitude] INP`]=ru(e)}),Rl(function(e){s[`[Amplitude] CLS`]=ru(e)}),tu(function(e){s[`[Amplitude] TTFB`]=ru(e)}),e=function(){n.visibilityState===`hidden`&&e&&(o.track(ul,s),n.removeEventListener(`visibilitychange`,e),e=null)},n.addEventListener(`visibilitychange`,e),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(t){return e&&n?.removeEventListener(`visibilitychange`,e),[2]})})}}},au=Object.values(fl);function ou(e,t,n){var r=``,i=``;try{var a=new URL(e);r=a.hostname,i=a.pathname}catch(e){n.debug(`Web vitals plugin is unable to parse page URL: `,e)}var o=xt(e,n);return{"[Amplitude] Page Domain":r,"[Amplitude] Page Location":o,"[Amplitude] Page Path":xt(i,n),"[Amplitude] Page Title":t,"[Amplitude] Page URL":xt(o.split(`?`)[0],n)}}function su(e){return au.some(function(t){return t in e})}var cu=function(){var e=null,t,a=B(),o=a?.document,s=a?.location,c=!1,l=new Set;return{name:ll,type:`enrichment`,setup:function(a,u){return i(void 0,void 0,void 0,function(){var i,d,f,p,m,h,g,_;return r(this,function(r){return o===void 0?[2]:(c=!0,i=new Map,d=-1,f=function(e){var t=e.navigationId,n=i.get(t);return n||(n=ou(e.navigationURL||s?.href||``,o.title||``,a.loggerProvider),i.set(t,n)),n},p=function(e){l.add(e);var t=i.get(e);t&&(i.delete(e),su(t)&&u.track(ul,t))},m=function(){var e,t;try{for(var r=n(Array.from(i.keys())),a=r.next();!a.done;a=r.next()){var o=a.value;p(o)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},h=function(e){t!==void 0&&clearTimeout(t),t=setTimeout(function(){var r,a;t=void 0;try{for(var o=n(Array.from(i.keys())),s=o.next();!s.done;s=o.next()){var c=s.value;c<e&&p(c)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}},dl)},g=function(e){return function(t){c&&!l.has(t.navigationId)&&(f(t)[e]=ru(t,!0),t.navigationId>d&&(d!==-1&&h(t.navigationId),d=t.navigationId))}},_={reportSoftNavs:!0},Ql(g(fl.LCP),_),Il(g(fl.FCP),_),Yl(g(fl.INP),_),Rl(g(fl.CLS),_),tu(g(fl.TTFB),_),e=function(){o.visibilityState===`hidden`&&e&&m()},o.addEventListener(`visibilitychange`,e),[2])})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(n){return c=!1,t!==void 0&&(clearTimeout(t),t=void 0),e&&=(o?.removeEventListener(`visibilitychange`,e),null),[2]})})}}},lu=function(){var e=B();return e&&`PerformanceSoftNavigation`in e},uu=function(e){return e===void 0&&(e={}),e.reportSoftNav===!0&&lu()?cu():iu()},du=function(){function e(e,t){this.shouldTrackNewCampaign=!1,this.options=c({initialEmptyValue:`EMPTY`,resetSessionOnNewCampaign:!1,excludeReferrers:Li(t.cookieOptions?.domain||t.topLevelDomain),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=Mt(t.apiKey,`MKTG`),this.webExpStorageKey=Mt(t.apiKey,`MKTG_ORIGINAL`),this.currentCampaign=se,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log(`Installing web attribution tracking.`)}return e.prototype.init=function(){return i(this,void 0,void 0,function(){var e,n;return r(this,function(r){switch(r.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return n=t.apply(void 0,[r.sent(),2]),this.currentCampaign=n[0],this.previousCampaign=n[1],e=!this.lastEventTime||mt(this.sessionTimeout,this.lastEventTime),Ni(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:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return i(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return e=t.sent(),e?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||new qn().parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t=Ii(this.currentCampaign,this.options);return e&&(t.event_id=e),t},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),fu=`[Amplitude] Attribution`,pu=new Set([b.IDENTIFY,b.GROUP_IDENTIFY]),mu=function(e){return wt(e)},hu=function(e){e===void 0&&(e={});var t=e.fallbackAttributionEvent??!1,n=B(),a,o,s={},l=!1,u=!1,d,f,p,m,h=function(){return i(void 0,void 0,void 0,function(){var e;return r(this,function(n){switch(n.label){case 0:return[4,new qn().parse()];case 1:return e=n.sent(),s=mu(e),t&&(o?.log(`Tracking attribution fallback event.`),a?.track(fu,s)),[2]}})})},g=function(){h()},_=function(e){return new Proxy(e,{apply:function(e,t,n){Reflect.apply(e,t,n),l&&g()}})};return{name:`@amplitude/plugin-event-property-attribution-browser`,type:`enrichment`,setup:function(e,t){return i(void 0,void 0,void 0,function(){return r(this,function(r){switch(r.label){case 0:return a=t,o=e.loggerProvider,l=!0,o.log(`Installing event property attribution tracking.`),[4,h()];case 1:if(r.sent(),!n)return[2];if(n.addEventListener(`popstate`,g),!u){if(d=Reflect.get(n.history,`pushState`),f=Reflect.get(n.history,`replaceState`),!d||!f)return[2];p=_(d),n.history.pushState=p,m=_(f),n.history.replaceState=m,u=!0}return[2]}})})},execute:function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){return pu.has(e.event_type)||(e.event_properties=c(c({},s),e.event_properties)),[2,e]})})},teardown:function(){return i(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){return n&&(n.removeEventListener(`popstate`,g),e=Reflect.get(n.history,`pushState`),t=Reflect.get(n.history,`replaceState`),u&&e===p&&d&&(n.history.pushState=d),u&&t===m&&f&&(n.history.replaceState=f)),l=!1,u=!1,d=void 0,f=void 0,p=void 0,m=void 0,s={},[2]})})}}},gu=`AMP_CURRENT_PAGE`,_u=`AMP_PREVIOUS_PAGE`,vu=`AMP_URL_INFO`,yu;(function(e){e.Direct=`direct`,e.Internal=`internal`,e.External=`external`})(yu||={});var bu=new Set([b.IDENTIFY,b.GROUP_IDENTIFY,b.REVENUE]),xu=function(e){var n=(e===void 0?{}:e).internalDomains,a=n===void 0?[]:n,o=B(),s=void 0,l=!1,u=void 0,d=!1,f=!1,p=function(e){var t;try{t=new URL(e).hostname}catch(e){u?.error(`Could not parse URL: `,e)}return t},m=function(e){var t=typeof location<`u`&&location.hostname||``,n=e?p(e):void 0;if(!n)return yu.Direct;var r=a.some(function(e){return t.indexOf(e)!==-1}),i=a.some(function(e){return n.indexOf(e)!==-1});return t===n||i&&r?yu.Internal:yu.External},h=function(){return i(void 0,void 0,void 0,function(){var e,t,n,i,a;return r(this,function(r){switch(r.label){case 0:return s&&l?[4,s.get(vu)]:[3,3];case 1:return e=r.sent(),t=xt(typeof location<`u`&&location.href||``),n=e?.AMP_CURRENT_PAGE||``,i=void 0,i=t===n?e?.AMP_PREVIOUS_PAGE||``:n||document.referrer||``,[4,s.set(vu,(a={},a[gu]=t,a[_u]=i,a))];case 2:r.sent(),r.label=3;case 3:return[2]}})})},g=function(){h()};return{name:`@amplitude/plugin-page-url-enrichment-browser`,type:`enrichment`,setup:function(e,n){return i(void 0,void 0,void 0,function(){var n,i,a,c,m,_,v,y;return r(this,function(r){switch(r.label){case 0:if(u=e.loggerProvider,u.log(`Installing @amplitude/plugin-page-url-enrichment-browser`),f=!0,!o)return[3,7];try{s=new Nt(o.sessionStorage)}catch{u?.debug(`sessionStorage is not available in this environment.`)}return[4,s?.isEnabled()];case 1:return l=r.sent()??!1,s&&l?(n=typeof document<`u`&&document.referrer||``,i=n?p(n):void 0,a=typeof location<`u`&&location.hostname||``,c=xt(typeof location<`u`&&location.href||``),[4,s.get(vu)]):[3,6];case 2:return m=r.sent(),_=m?.AMP_CURRENT_PAGE||``,v=!!i&&i!==a&&_!==c,v?[4,s.set(vu,(y={},y[gu]=c,y[_u]=n,y))]:[3,4];case 3:return r.sent(),[3,6];case 4:return[4,h()];case 5:r.sent(),r.label=6;case 6:o.addEventListener(`popstate`,g),d||=(o.history.pushState=new Proxy(o.history.pushState,{apply:function(e,n,r){var i=t(r,3),a=i[0],o=i[1],s=i[2];e.apply(n,[a,o,s]),f&&g()}}),o.history.replaceState=new Proxy(o.history.replaceState,{apply:function(e,n,r){var i=t(r,3),a=i[0],o=i[1],s=i[2];e.apply(n,[a,o,s]),f&&g()}}),!0),r.label=7;case 7:return[2]}})})},execute:function(e){return i(void 0,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=xt(typeof location<`u`&&location.href||``),s&&l?[4,s.get(vu)]:[3,2];case 1:if(n=r.sent(),i=n?.AMP_PREVIOUS_PAGE||``,bu.has(e.event_type))return[2,e];e.event_properties=c(c({},e.event_properties||{}),{"[Amplitude] Page Domain":Su(e,`[Amplitude] Page Domain`,typeof location<`u`&&location.hostname||``),"[Amplitude] Page Location":Su(e,`[Amplitude] Page Location`,t),"[Amplitude] Page Path":Su(e,`[Amplitude] Page Path`,typeof location<`u`&&xt(location.pathname)||``),"[Amplitude] Page Title":Su(e,`[Amplitude] Page Title`,er($n)),"[Amplitude] Page URL":Su(e,`[Amplitude] Page URL`,t.split(`?`)[0]),"[Amplitude] Previous Page Location":i,"[Amplitude] Previous Page Type":m(i)}),r.label=2;case 2:return[2,e]}})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return o&&(o.removeEventListener(`popstate`,g),f=!1),s&&l?[4,s.set(vu,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}}};function Su(e,t,n){return e.event_properties||={},e.event_properties[t]===void 0?n:e.event_properties[t]}var Cu=function(){var e,t,n;function a(e){return typeof e!=`object`||!e?!1:`body`in e&&typeof e.body==`string`}function o(t){if(t)try{var n=Function(`return `+t)();if(typeof n==`function`)return n;e?.error(`Custom enrichment body did not evaluate to a function`)}catch(t){e?.error(`Could not create custom enrichment function`,t)}return function(e){return e}}return{name:`@amplitude/plugin-custom-enrichment-browser`,type:`enrichment`,setup:function(s,c){return i(void 0,void 0,void 0,function(){var i;return r(this,function(r){return e=s.loggerProvider,e?.log(`Installing @amplitude/plugin-custom-enrichment-browser`),s.remoteConfig?.fetchRemoteConfig&&(s.remoteConfigClient?(i=s.remoteConfigClient.subscribe(`configs.analyticsSDK.browserSDK.customEnrichment`,`all`,function(e){n=e&&a(e)?o(e.body||``):o(``)}),t=function(){return s.remoteConfigClient?.unsubscribe(i)}):e?.debug(`Remote config client is not provided, skipping remote config fetch`)),[2]})})},execute:function(t){return i(void 0,void 0,void 0,function(){return r(this,function(r){if(n)try{return[2,n(t)??null]}catch(n){return e?.error(`Could not execute custom enrichment function`,n),[2,t]}return[2,t]})})},teardown:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){return t&&t(),[2]})})}}},wu=`userProperty`,Tu=`eventProperty`,Eu=function(e){return e===`userProperty`||e===`eventProperty`},Du=[wu,Tu],Ou=function(e){var n=s([],t(new Set((Array.isArray(e)?e:[e]).filter(Eu))),!1);return n.length>0?n:s([],t(Du),!1)},ku=function(e,t){return Ou(e.trackingMethod).includes(t)},Au=function(e){return ku(e,wu)},ju=function(e){return ku(e,Tu)},Mu=-1,Nu=function(e){o(s,e);function s(){var t=e!==null&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return s.prototype.init=function(e,t,n){e===void 0&&(e=``);var r,i;return arguments.length>
122?(r=t,i=n):typeof t==`string`?(r=t,i=void 0):(r=t?.userId,i=t),V(this._init(c(c({},i),{userId:r,apiKey:e})))},s.prototype._init=function(t){return i(this,void 0,void 0,function(){var n,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b=this;return r(this,function(x){switch(x.label){case 0:return this.initializing?[2]:(this.initializing=!0,n=Ki(t),o=t.loggerProvider??new ze,t.loggerProvider||o.enable(t.logLevel??Le.Warn),s=t.serverZone??`US`,l=this._diagnosticsSampleRate,u=t.enableDiagnostics??!0,n?(c=new on(t.apiKey,o,s,t.remoteConfig?.serverUrl),[4,new Promise(function(e){c?.subscribe(`configs.diagnostics.browserSDK`,`all`,function(t,n,r){if(o.debug(`Diagnostics remote configuration received:`,JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;typeof i==`number`&&!isNaN(i)&&(l=i);var a=t.enabled;typeof a==`boolean`&&(u=a)}e()})})]):[3,2]);case 1:x.sent(),x.label=2;case 2:return d=new Yt(t.apiKey,o,s,{enabled:u,sampleRate:l}),d.setTag(`library`,`${ni}/${ti}`),d.setTag(`platform`,`Web`),d.setTag(`web_environment`,ei()),typeof navigator<`u`&&d.setTag(`user_agent`,navigator.userAgent),[4,Wi(t.apiKey,t,this,d,{loggerProvider:o,serverZone:s,enableDiagnostics:u,diagnosticsSampleRate:l})];case 3:return f=x.sent(),n&&c?[4,new Promise(function(e){c?.subscribe(`configs.analyticsSDK.browserSDK`,`all`,function(t,n,r){f.loggerProvider.debug(`Remote configuration received:`,JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&ca(t,f),e()})})]:[3,5];case 4:x.sent(),x.label=5;case 5:return[4,e.prototype._init.call(this,f)];case 6:return x.sent(),this.logBrowserOptions(f),this.config.remoteConfigClient=c,p=Gr(this.config),Dr(this.config.defaultTracking)&&Au(p)?(this.config.optOut&&this.timeline.addOptOutListener(function(e){return i(b,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e?[3,2]:(this.webAttribution=new du(p,this.config),[4,this.webAttribution.init()]);case 1:t.sent(),t.label=2;case 2:return[2]}})})}),this.webAttribution=new du(p,this.config),[4,this.webAttribution.init()]):[3,8];case 7:x.sent(),x.label=8;case 8:return m=vt(),h=m.ampTimestamp?Number(m.ampTimestamp):void 0,g=!h||Date.now()<h,_=g&&!Number.isNaN(Number(m.ampSessionId))?Number(m.ampSessionId):void 0,v=this.config.deferredSessionId,v===Mu&&!this.config.optOut&&(v=Date.now()),this.setSessionId(t.sessionId??_??v??this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return i(b,void 0,void 0,function(){return r(this,function(t){return!e&&this.config.deferredSessionId&&(this.config.deferredSessionId===Mu?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),y=ut(this.config.instanceName),y.identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),this.config.offline===null?[3,10]:[4,this.add(sa()).promise];case 9:x.sent(),x.label=10;case 10:return[4,this.add(new $e({diagnosticsClient:d})).promise];case 11:return x.sent(),[4,this.add(new ii).promise];case 12:return x.sent(),[4,this.add(new pt).promise];case 13:return x.sent(),oa(this.config),Or(this.config.defaultTracking)?(this.config.loggerProvider.debug(`Adding file download tracking plugin`),[4,this.add(ia()).promise]):[3,15];case 14:x.sent(),x.label=15;case 15:return kr(this.config.defaultTracking)?(this.config.loggerProvider.debug(`Adding form interaction plugin`),[4,this.add(ta()).promise]):[3,17];case 16:x.sent(),x.label=17;case 17:return Ar(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug(`Adding page view tracking plugin`),[4,this.add(Zi(Wr(this.config))).promise]):[3,20];case 18:return x.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return i(b,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug(`Adding page view tracking plugin`),[4,this.add(Zi(Wr(this.config))).promise]);case 1:return t.sent(),[2]}})})}),x.label=20;case 20:return Dr(this.config.defaultTracking)&&ju(p)?(this.config.loggerProvider.debug(`Adding event property attribution plugin`),[4,this.add(hu(p)).promise]):[3,22];case 21:x.sent(),x.label=22;case 22:return Pr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding user interactions plugin (autocapture plugin)`),[4,this.add(cc(Vr(this.config),{diagnosticsClient:d})).promise]):[3,24];case 23:x.sent(),x.label=24;case 24:return Lr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding frustration interactions plugin`),[4,this.add(Lc(Hr(this.config))).promise]):[3,26];
12case 25:x.sent(),x.label=26;case 26:return Nr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding network tracking plugin`),[4,this.add(cl(Ur(this.config))).promise]):[3,28];case 27:x.sent(),x.label=28;case 28:return Fr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding web vitals plugin`),[4,this.add(uu(Ir(this.config))).promise]):[3,30];case 29:x.sent(),x.label=30;case 30:return Rr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding performance tracking plugin`),[4,this.add(Kc(zr(this.config))).promise]):[3,32];case 31:x.sent(),x.label=32;case 32:return Mr(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding referrer page url plugin`),[4,this.add(xu()).promise]):[3,34];case 33:x.sent(),x.label=34;case 34:return Br(this.config.customEnrichment)?(this.config.loggerProvider.debug(`Adding custom enrichment plugin`),[4,this.add(Cu()).promise]):[3,36];case 35:x.sent(),x.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions(`dispatchQ`)];case 37:return x.sent(),y.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=a(t,[`time`]),i=typeof n==`number`?{time:n}:void 0;b.track(e.eventType,r,i)}),[2]}})})},s.prototype.getUserId=function(){return this.config?.userId},s.prototype.setUserId=function(e){if(!this.config){this.q.push(this.setUserId.bind(this,e));return}this.config.loggerProvider.debug(`function setUserId: `,e),(e!==this.config.userId||e===void 0)&&(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),dt(e,this.config.instanceName))},s.prototype.getDeviceId=function(){return this.config?.deviceId},s.prototype.setDeviceId=function(e){if(!this.config){this.q.push(this.setDeviceId.bind(this,e));return}this.config.loggerProvider.debug(`function setDeviceId: `,e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),ft(e,this.config.instanceName))},s.prototype.reset=function(){this.setDeviceId(we()),this.setUserId(void 0),this.timeline.onReset()},s.prototype.getIdentity=function(){return{deviceId:this.config?.deviceId,userId:this.config?.userId,userProperties:this.userProperties}},s.prototype.setIdentity=function(e){var r,i;if(`userId`in e&&this.setUserId(e.userId),`deviceId`in e&&e.deviceId&&this.setDeviceId(e.deviceId),`userProperties`in e){this.userProperties=e.userProperties;var a=new fe,o=e.userProperties??{};try{for(var s=n(Object.entries(o)),c=s.next();!c.done;c=s.next()){var l=t(c.value,2),u=l[0],d=l[1];a.set(u,d)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}this.identify(a)}},s.prototype.getOptOut=function(){return this.config?.optOut},s.prototype.getSessionId=function(){return this.config?.sessionId},s.prototype.setSessionId=function(e){var t=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),V(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=e??Mu,V(Promise.resolve());if(e===void 0&&(e=Date.now()),e===this.config.sessionId)return V(Promise.resolve());this.config.loggerProvider.debug(`function setSessionId: `,e);var n=this.getSessionId();n!==e&&this.timeline.onSessionIdChanged(e);var r=this.config.lastEventTime,i=this.config.lastEventId??-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,jr(this.config.defaultTracking)&&(n&&r&&t.push(this.track(yi,void 0,{device_id:this.previousSessionDeviceId,event_id:++i,session_id:n,time:r+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var a=this.trackCampaignEventIfNeeded(++i,t);return this.config.identify&&t.push(this.track(ke(this.config.identify)).promise),jr(this.config.defaultTracking)&&t.push(this.track(vi,void 0,{event_id:a?++i:i,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,V(Promise.all(t))},s.prototype.extendSession=function(){if(!this.config){this.q.push(this.extendSession.bind(this));return}
12this.config.lastEventTime=Date.now()},s.prototype.setTransport=function(e){if(!this.config){this.q.push(this.setTransport.bind(this,e));return}this.config.transportProvider=qi(e)},s.prototype.identify=function(t,n){if(Jr(t)){var r=t._q;t._q=[],t=qr(new fe,r)}return n?.user_id&&this.setUserId(n.user_id),n?.device_id&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},s.prototype.groupIdentify=function(t,n,r,i){if(Jr(r)){var a=r._q;r._q=[],r=qr(new fe,a)}return e.prototype.groupIdentify.call(this,t,n,r,i)},s.prototype.revenue=function(t,n){if(Jr(t)){var r=t._q;t._q=[],t=qr(new Pe,r)}return e.prototype.revenue.call(this,t,n)},s.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!Au(this.webAttribution.options))return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log(`Tracking attribution.`),!0},s.prototype.process=function(t){return i(this,void 0,void 0,function(){var n,i,a;return r(this,function(r){return n=Date.now(),i=mt(this.config.sessionTimeout,this.config.lastEventTime),a=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type!==`session_start`&&t.event_type!==`session_end`&&(!t.session_id||t.session_id===this.getSessionId())&&(i||a?(this.setSessionId(n),a&&this.config.loggerProvider.log(`Created a new session for new campaign.`)):i||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},s.prototype.logBrowserOptions=function(e){try{var t=c(c({},e),{apiKey:e.apiKey.substring(0,10)+`********`});this.config.loggerProvider.debug(`Initialized Amplitude with BrowserConfig:`,Ee(t))}catch(e){this.config.loggerProvider.error(`Error logging browser config`,e)}},s.prototype._setDiagnosticsSampleRate=function(e){if(!(e>1||e<0)&&!this.config){this._diagnosticsSampleRate=e;return}},s}(Ne),Pu=`[Amplitude]`,Fu=`${Pu} Session Replay ID`,Iu=gn.US,Lu={enabled:!0},Ru=1e3,zu=`${Pu} Session Replay Debug`,Bu=`amp-unmask`,Vu=`https://api-sr.amplitude.com/sessions/v2/track`,Hu=`https://api-sr.eu.amplitude.com/sessions/v2/track`,Uu=`https://api-sr.stag2.amplitude.com/sessions/v2/track`,Wu=2e6,Gu=6e6,Ku=9e6,qu=/payload.*exceed/i,Ju=3e4,Yu=6e4,Xu=1e4,Zu=1e3,Qu=1e4,$u=1024,ed=1e3,td=65536,nd=1e4,rd=6e4;2*Wu;var id=`amplitude-sr-iframe`,ad;(function(e){e.GET_SR_PROPS=`get-sr-props`,e.DEBUG_INFO=`debug-info`,e.FETCH_REQUEST=`fetch-request`,e.METADATA=`metadata`,e.TARGETING_DECISION=`targeting-decision`,e.REPLAY_GATE_DECISION=`replay-gate-decision`})(ad||={});var od=function(){function e(e){this.logger=e,this.log=this.getSafeMethod(`log`),this.warn=this.getSafeMethod(`warn`),this.error=this.getSafeMethod(`error`),this.debug=this.getSafeMethod(`debug`)}return e.prototype.getSafeMethod=function(e){if(!this.logger)return(function(){});var t=this.logger[e];return typeof t==`function`?(t.__rrweb_original__??t).bind(this.logger):(function(){})},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),sd=`medium`;function cd(e){return e.toLowerCase()}function ld(e){var t=e.type;return e.hasAttribute(`data-rr-is-password`)?`password`:t?cd(t):null}var ud=new Map,dd=function(e){var t=ud.get(e);if(t)return t;var n=`\0TRAIL\0`,r=`\0MID\0`,i=`\0DS\0`,a=`\0ST\0`,o=`\0QU\0`,s=e;s=s.replace(/\/\*\*$/,n),s=s.replace(/\/\*\*\//g,r),s=s.replace(/\*\*/g,i),s=s.replace(/\*/g,a),s=s.replace(/\?/g,o),s=s.replace(/[.+^${}()|[\]\\]/g,`\\$&`),s=s.split(n).join(`(/.*)?`),s=s.split(r).join(`/(.*\\/)?`),s=s.split(i).join(`.*`),s=s.split(a).join(`.*`),s=s.split(o).join(`.`);var c=RegExp(`^${s}$`);return ud.set(e,c),c},fd=function(e,t,n){switch(t){case`light`:if(e!==`input`)return!1;var r=n?ld(n):``;return r?!!([`password`,`hidden`,`email`,`tel`].includes(r)||n.autocomplete.startsWith(`cc-`)):!1;case`medium`:return e===`input`;case`conservative`:return!0;default:return fd(e,sd,n)}},pd=function(e,t){var r,i;if(e&&t.urlMaskLevels)try{for(var a=n(t.urlMaskLevels),o=a.next();!o.done;o=a.next()){var s=o.value;if(dd(s.match).test(e))return s.maskLevel}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return t.defaultMaskLevel??sd},md=function(e,t,n,r){if(t===void 0&&(t={defaultMaskLevel:sd}),n){if(n.closest(`.amp-mask, [data-amp-mask]`)||(t.maskSelector??[]).some(function(e){return n.closest(e)}))return!0;
12if(n.closest(`.amp-unmask, [data-amp-unmask]`)||(t.unmaskSelector??[]).some(function(e){return n.closest(e)}))return!1}return fd(e,pd(r,t),n)},hd=function(e,t,n){return function(r,i){return md(e,t,i,n?.())?r.replace(/[^\s]/g,`*`):r}},gd=function(e,t){return function(n,r,i){return n===`style`||!(e?.maskAttributes??[]).includes(n)?r:md([`INPUT`,`SELECT`,`TEXTAREA`].includes(i.tagName)?`input`:`text`,e,i,t?.())?r.replace(/[^\s]/g,`*`):r}},_d=function(e){var n=e?.blockSelector;return s(s([],t(typeof n==`string`?n?[n]:[]:n??[]),!1),[`[data-amp-block]`],!1).join(`,`)},vd=function(e,n){return e&&(pd(n,e)===`conservative`||e.defaultMaskLevel===`conservative`||e.urlMaskLevels?.some(function(e){return e.maskLevel===`conservative`}))?`*`:s(s([],t(e?.maskSelector??[]),!1),[`[data-amp-mask]`],!1).join(`,`)},yd=function(e,t){return t===void 0&&(t=function(){return``}),{maskAllInputs:!0,maskTextClass:`amp-mask`,blockClass:`amp-block`,blockSelector:_d(e),maskTextSelector:vd(e,t()),maskInputFn:hd(`input`,e,t),maskTextFn:hd(`text`,e,t),maskAttributeFn:gd(e,t)}},bd=function(e,t,r){var i,a,o=c({},e);try{for(var s=n([`blockSelector`,`maskSelector`,`unmaskSelector`]),l=s.next();!l.done;l=s.next()){var u=l.value,d=e[u],f=(typeof d==`string`?[d]:d??[]).filter(function(e){try{return t(e),!0}catch{if(!r)throw Error(`Invalid privacy selector: ${e}`);return r(e),!1}});o[u]=f.length?f:void 0}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return o};function xd(e,t){return t||(e===`STAGING`?Uu:e===`EU`?Hu:Vu)}var Sd=function(){var e=B();return e?.location?e.location.href:``},Cd=function(e,t){return`${t}/${e}`},wd=function(e){return!(typeof e!=`string`||e.trim()===``||!/^\/|^https?:\/\/[^\s]+$/.test(e))},Td=function(e){if(!e.every(function(e){return typeof e.selector==`string`&&typeof e.replacement==`string`}))throw Error(`ugcFilterRules must be an array of objects with selector and replacement properties`);if(!e.every(function(e){return wd(e.selector)}))throw Error(`ugcFilterRules must be an array of objects with valid globs`)},Ed=function(e,t){var r,i;try{for(var a=n(t),o=a.next();!o.done;o=a.next()){var s=o.value,c=dd(s.selector);if(c.test(e))return e.replace(c,s.replacement)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e},Dd=function(){return i(void 0,void 0,void 0,function(){var e,t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e=B(),e?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=r.sent(),n=t.usage,i=t.quota,a=t.usageDetails,o=n?Math.round(n/$u):0,s=n&&i?Math.round((n/i+2**-52)*1e3)/1e3:0,[2,{totalStorageSize:o,percentOfQuota:s,usageDetails:JSON.stringify(a)}];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:``}]}})})},Od=function(e){var t=c({},e),n=t.apiKey;return t.apiKey=`****${n.substring(n.length-4)}`,t},kd=function(){return{flushMaxRetries:2,logLevel:Le.Warn,loggerProvider:new ze,transportProvider:new Zt}},Ad=function(e){o(n,e);function n(n,r){var i=this,a=kd();i=e.call(this,c(c({transportProvider:a.transportProvider,loggerProvider:new od(r.loggerProvider||a.loggerProvider)},r),{apiKey:n}))||this,i.flushMaxRetries=r.flushMaxRetries!==void 0&&r.flushMaxRetries<=a.flushMaxRetries?r.flushMaxRetries:a.flushMaxRetries,i.apiKey=n,i.sampleRate=r.sampleRate||0,i.serverZone=r.serverZone||Iu,i.configServerUrl=r.configServerUrl,i.trackServerUrl=r.trackServerUrl,i.shouldInlineStylesheet=r.shouldInlineStylesheet,i.inlineImages=r.inlineImages,i.version=r.version,i.performanceConfig=r.performanceConfig||Lu,i.storeType=r.storeType??`memory`,i.applyBackgroundColorToBlockedElements=r.applyBackgroundColorToBlockedElements??!1,i.enableUrlChangePolling=r.enableUrlChangePolling??!1,i.urlChangePollingInterval=r.urlChangePollingInterval??Ru,i.captureDocumentTitle=r.captureDocumentTitle??!1,r.fullSnapshotIntervalMs!==void 0&&(i.fullSnapshotIntervalMs=r.fullSnapshotIntervalMs),r.eagerFullSnapshotSend!==void 0&&(i.eagerFullSnapshotSend=r.eagerFullSnapshotSend),i.captureFullSnapshotOnFocus=r.captureFullSnapshotOnFocus??!1,r.maxPersistedEventsSizeBytes!==void 0&&(i.maxPer
12sistedEventsSizeBytes=Fd(r.maxPersistedEventsSizeBytes,Md,Nd,`maxPersistedEventsSizeBytes`,i.loggerProvider)),r.maxSingleEventSizeBytes!==void 0&&(i.maxSingleEventSizeBytes=Fd(r.maxSingleEventSizeBytes,Md,Pd,`maxSingleEventSizeBytes`,i.loggerProvider)),i.privacyConfig=c(c({},r.privacyConfig??{}),{unmaskSelector:Array.from(new Set(s([`.${Bu}`],t(r.privacyConfig?.unmaskSelector??[]),!1)))}),r.interactionConfig&&(i.interactionConfig=r.interactionConfig,i.interactionConfig.ugcFilterRules&&Td(i.interactionConfig.ugcFilterRules)),r.debugMode&&(i.debugMode=r.debugMode);var o=r;return i.useWebWorker=r.useWebWorker??o.experimental?.useWebWorker??!0,i.enableTransportCompression=r.enableTransportCompression??!0,i.sendTimeoutMs=r.sendTimeoutMs,i.captureAdoptedStyleSheets=r.captureAdoptedStyleSheets??!0,r.crossOriginIframes&&(i.crossOriginIframes=r.crossOriginIframes),r.flushIntervalConfig?i.flushIntervalConfig=Id(r.flushIntervalConfig,i.loggerProvider):i.flushIntervalConfig={minIntervalMs:Zu,maxIntervalMs:Qu},i.handleSendEvents=r.handleSendEvents,i.handleFetchConfig=r.handleFetchConfig,i}return n}(He),jd=100,Md=1e3,Nd=8e6,Pd=1e7;function Fd(e,t,n,r,i){if(!Number.isFinite(e)){i.warn(`${r} value is not a finite number (got ${String(e)}); ignoring.`);return}return e<t?(i.warn(`${r} ${e} is below floor ${t}; clamping.`),t):e>n?(i.warn(`${r} ${e} exceeds ceiling ${n}; clamping.`),n):e}function Id(e,t){var n={};if(e.minIntervalMs!==void 0&&(!Number.isFinite(e.minIntervalMs)||e.minIntervalMs<jd?(t.warn(`flushIntervalConfig.minIntervalMs ${e.minIntervalMs} is below floor ${jd}ms; clamping.`),n.minIntervalMs=jd):n.minIntervalMs=e.minIntervalMs),e.maxIntervalMs!==void 0&&(Number.isNaN(e.maxIntervalMs)||e.maxIntervalMs<jd?(t.warn(`flushIntervalConfig.maxIntervalMs ${e.maxIntervalMs} is below floor ${jd}ms; clamping.`),n.maxIntervalMs=jd):n.maxIntervalMs=e.maxIntervalMs),n.minIntervalMs!==void 0||n.maxIntervalMs!==void 0){var r=n.minIntervalMs??500,i=n.maxIntervalMs??Xu;i<r&&(n.maxIntervalMs===void 0?(t.warn(`flushIntervalConfig.minIntervalMs (${r}) exceeds the default maxIntervalMs (${Xu}); raising max to match min.`),n.maxIntervalMs=r):n.minIntervalMs===void 0?(t.warn(`flushIntervalConfig.maxIntervalMs (${i}) is below the default minIntervalMs (500); lowering min to match max.`),n.minIntervalMs=i):(t.warn(`flushIntervalConfig.maxIntervalMs (${n.maxIntervalMs}) is less than minIntervalMs (${n.minIntervalMs}); raising max to match min.`),n.maxIntervalMs=n.minIntervalMs))}return n}var Ld=(e=>(e[e.DomContentLoaded=0]=`DomContentLoaded`,e[e.Load=1]=`Load`,e[e.FullSnapshot=2]=`FullSnapshot`,e[e.IncrementalSnapshot=3]=`IncrementalSnapshot`,e[e.Meta=4]=`Meta`,e[e.Custom=5]=`Custom`,e[e.Plugin=6]=`Plugin`,e))(Ld||{}),Rd=(e=>(e[e.Mutation=0]=`Mutation`,e[e.MouseMove=1]=`MouseMove`,e[e.MouseInteraction=2]=`MouseInteraction`,e[e.Scroll=3]=`Scroll`,e[e.ViewportResize=4]=`ViewportResize`,e[e.Input=5]=`Input`,e[e.TouchMove=6]=`TouchMove`,e[e.MediaInteraction=7]=`MediaInteraction`,e[e.StyleSheetRule=8]=`StyleSheetRule`,e[e.CanvasMutation=9]=`CanvasMutation`,e[e.Font=10]=`Font`,e[e.Log=11]=`Log`,e[e.Drag=12]=`Drag`,e[e.StyleDeclaration=13]=`StyleDeclaration`,e[e.Selection=14]=`Selection`,e[e.AdoptedStyleSheet=15]=`AdoptedStyleSheet`,e[e.CustomElement=16]=`CustomElement`,e))(Rd||{}),zd=(e=>(e[e.MouseUp=0]=`MouseUp`,e[e.MouseDown=1]=`MouseDown`,e[e.Click=2]=`Click`,e[e.ContextMenu=3]=`ContextMenu`,e[e.DblClick=4]=`DblClick`,e[e.Focus=5]=`Focus`,e[e.Blur=6]=`Blur`,e[e.TouchStart=7]=`TouchStart`,e[e.TouchMove_Departed=8]=`TouchMove_Departed`,e[e.TouchEnd=9]=`TouchEnd`,e[e.TouchCancel=10]=`TouchCancel`,e))(zd||{}),Bd=1500,Vd=function(e,t){var n=document.createDocumentFragment();return bd(e,function(e){n.querySelector(e)},function(e){t.warn(`[session-replay-browser] omitting selector "${e}" because it is invalid`)})},Hd=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){return i(this,void 0,void 0,function(){var e,i,a,o,l,u,d,f,p,m,h,g,_,v,y,b,x,S=this;return r(this,function(r){switch(r.label){case 0:e=c({},this.localConfig),e.optOut=this.localConfig.optOut,e.captureEnabled=!0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,new Promise(function(t,n){S.remoteConfigClient.subscribe(`configs.sessionReplay`,{timeout:Bd}
12,function(r,a){if(S.localConfig.loggerProvider.debug(`Session Replay remote configuration received from ${a}:`,JSON.stringify(r,null,2)),!r){n(Error(`No remote config received`));return}var o=r,s=o.sr_sampling_config,c=o.sr_privacy_config,l=o.sr_targeting_config,u=e.interactionConfig?.ugcFilterRules;e.interactionConfig=o.sr_interaction_config,e.interactionConfig&&u&&(e.interactionConfig.ugcFilterRules=u),e.loggingConfig=o.sr_logging_config,(s||c||l)&&(i={},s&&(i.sr_sampling_config=s),c&&(i.sr_privacy_config=c),l&&(i.sr_targeting_config=l)),t()})})];case 2:return r.sent(),[3,4];case 3:return a=r.sent(),this.localConfig.loggerProvider.error(`Failed to generate joined config: `,a),e.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:e,remoteConfig:void 0}];case 4:if(!i)return[2,{localConfig:this.localConfig,joinedConfig:e,remoteConfig:i}];if(o=i.sr_sampling_config,l=i.sr_privacy_config,u=i.sr_targeting_config,o&&Object.keys(o).length>0?(Object.prototype.hasOwnProperty.call(o,`capture_enabled`)?e.captureEnabled=o.capture_enabled:e.captureEnabled=!1,Object.prototype.hasOwnProperty.call(o,`sample_rate`)&&(e.sampleRate=o.sample_rate),Object.prototype.hasOwnProperty.call(o,`min_session_duration_ms`)&&(e.minSessionDurationMs=this.sanitizeMinSessionDurationMs(o.min_session_duration_ms))):(e.captureEnabled=!0,this.localConfig.loggerProvider.debug(`Remote config successfully fetched, but no values set for project, Session Replay capture enabled.`)),l){d=e.privacyConfig??{},f={defaultMaskLevel:l.defaultMaskLevel??d.defaultMaskLevel??`medium`,blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:s([],t(new Set(s(s([],t(d.maskAttributes??[]),!1),t(l.maskAttributes??[]),!1))),!1),urlMaskLevels:s(s([],t(l.urlMaskLevels??[]),!1),t(d.urlMaskLevels??[]),!1)},p=function(e){var t,r,i,a,o,s,c={};typeof e.blockSelector==`string`&&(e.blockSelector=[e.blockSelector]);try{for(var l=n(e.blockSelector??[]),u=l.next();!u.done;u=l.next()){var d=u.value;c[d]=`block`}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}try{for(var f=n(e.maskSelector??[]),p=f.next();!p.done;p=f.next()){var d=p.value;c[d]=`mask`}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}try{for(var m=n(e.unmaskSelector??[]),h=m.next();!h.done;h=m.next()){var d=h.value;c[d]=`unmask`}}catch(e){o={error:e}}finally{try{h&&!h.done&&(s=m.return)&&s.call(m)}finally{if(o)throw o.error}}return c},m=c(c({},p(d)),p(l));try{for(h=n(Object.entries(m)),g=h.next();!g.done;g=h.next())_=t(g.value,2),v=_[0],y=_[1],y===`mask`?f.maskSelector.push(v):y===`block`?f.blockSelector.push(v):y===`unmask`&&f.unmaskSelector.push(v)}catch(e){b={error:e}}finally{try{g&&!g.done&&(x=h.return)&&x.call(h)}finally{if(b)throw b.error}}e.privacyConfig=Vd(f,this.localConfig.loggerProvider)}return u&&Object.keys(u).length>0&&(e.targetingConfig=u),this.localConfig.loggerProvider.debug(JSON.stringify({name:`session replay joined config`,config:Od(e)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:e,remoteConfig:i}]}})})},e.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 ${String(e)}); ignoring.`);return}if(e<0){this.localConfig.loggerProvider.warn(`min_session_duration_ms remote value is negative (${e}); ignoring.`);return}return e>6e4?(this.localConfig.loggerProvider.warn(`min_session_duration_ms remote value ${e} exceeds ${Ud}ms ceiling; clamping.`),Ud):e},e}(),Ud=6e4,Wd=function(e,t){return i(void 0,void 0,void 0,function(){var n,i;return r(this,function(r){return n=new Ad(e,t),i=new on(e,n.loggerProvider,n.serverZone,t.configServerUrl,t.handleFetchConfig),[2,new Hd(i,n)]})})};function Gd(e){if(e.type!==Ld.IncrementalSnapshot)return!1;var t=e.data;return t.source===Rd.Mutation&&!t.isAttachIframe}function Kd(e){return typeof e==`object`&&!!e}function qd(e){var t,r,i,a,o={};try{for(var s=n(e),c=s.next();!c.done;c=s.next()){var l=c.value;try{for(var u=(i=void 0,n(Object.keys(l))),d=u.next();!d.done;d=u.next()){var f=d.value;o[f]=l[f]}}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o}function Jd(e){var t,r,i=new Map;if(e.forEach(function(e,t){if(e.attributes&&`style`in e.attributes){var n=i.get(e.id);n?n.push(t):i.set(e.id,[t])}}),i.size===0)return e;var a=function(t){return e[t].attributes.style},o=new Set,s=new Map,l=function(e){if(e.length===1)return`continue`;var t=-1;e.forEach(function(e,n){Kd(a(e))||(t=n)});var n=[];if(e.forEach(function(e,r){r!==t&&(o.add(e),r>t&&n.push(e))}),n.length>0){var r=n[n.length-1],i=qd(n.map(function(e){return a(e)}));o.delete(r),s.set(r,i)}};try{for(var u=n(i.values()),d=u.next();!d.done;d=u.next()){var f=d.value;l(f)}}catch(e){t={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}if(o.size===0&&s.size===0)return e;var p=[];return e.forEach(function(e,t){var n=s.get(t);if(n!==void 0){p.push(c(c({},e),{attributes:c(c({},e.attributes),{style:n})}));return}if(!o.has(t)){p.push(e);return}var r=c({},e.attributes);delete r.style,Object.keys(r).length>0&&p.push(c(c({},e),{attributes:r}))}),p}function Yd(e){var r,i,a,o,s=e[0],l=new Map,u=new Map,d=new Map,f=new Map,p=new Map;e.forEach(function(e,t){var r,i,a,o,s=e.data;try{for(var c=n(s.adds),m=c.next();!m.done;m=c.next()){var h=m.value;l.has(h.node.id)||l.set(h.node.id,t),u.set(h.node.id,t),p.set(h.node.id,h.parentId)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}try{for(var g=n(s.removes),_=g.next();!_.done;_=g.next()){var v=_.value;d.has(v.id)||d.set(v.id,t),f.set(v.id,t)}}catch(e){a={error:e}}finally{try{_&&!_.done&&(o=g.return)&&o.call(g)}finally{if(a)throw a.error}}});var m=new Set,h=new Set;try{for(var g=n(l),_=g.next();!_.done;
12_=g.next()){var v=t(_.value,2),y=v[0],b=v[1],x=d.get(y);x!==void 0&&(u.get(y)>=f.get(y)||(b<x?m.add(y):x<b&&h.add(y)))}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=g.return)&&i.call(g)}finally{if(r)throw r.error}}var S=new Set;if(m.size>0||h.size>0)for(var C=!0;C;){C=!1;try{for(var w=(a=void 0,n(p)),T=w.next();!T.done;T=w.next()){var E=t(T.value,2),D=E[0],O=E[1];if(!m.has(D)&&!h.has(D)&&!S.has(D)&&(m.has(O)||h.has(O)||S.has(O))){var k=d.get(D),A=l.get(D);k!==void 0&&A!==void 0&&k<A?h.add(D):k!==void 0&&A!==void 0&&k===A?S.add(D):m.add(D),C=!0}}}catch(e){a={error:e}}finally{try{T&&!T.done&&(o=w.return)&&o.call(w)}finally{if(a)throw a.error}}}var j=m.size>0||h.size>0||S.size>0,M=[];e.forEach(function(e,t){var r,i;try{for(var a=n(e.data.removes),o=a.next();!o.done;o=a.next()){var s=o.value;m.has(s.id)||h.has(s.id)&&t>=l.get(s.id)||S.has(s.id)&&(m.has(s.parentId)||h.has(s.parentId)||S.has(s.parentId))||M.push(s)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}});var N=e.flatMap(function(e){return e.data.adds}),ee=e.flatMap(function(e){return e.data.texts}),P=e.flatMap(function(e){return e.data.attributes}),F=j?P.filter(function(e){return!m.has(e.id)&&!h.has(e.id)&&!S.has(e.id)}):P,te={source:Rd.Mutation,removes:M,adds:j?N.filter(function(e){return!m.has(e.node.id)&&!h.has(e.node.id)&&!S.has(e.node.id)}):N,texts:j?ee.filter(function(e){return!m.has(e.id)&&!h.has(e.id)&&!S.has(e.id)}):ee,attributes:Jd(F)};return c(c({},s),{data:te})}function Xd(e){if(e.length<=1)return e;for(var t=[],n=0;n<e.length;){if(!Gd(e[n])){t.push(e[n]),n++;continue}for(var r=n+1;r<e.length&&Gd(e[r]);)r++;t.push(r>n+1?Yd(e.slice(n,r)):e[n]),n=r}return t}var Zd=2e3,Qd=function(){function e(e,n,r,i,a){var o=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e,n=t.type,r=t.timestamp,i=t.delay,a=t.data;return JSON.stringify(i==null?{type:n,timestamp:r,data:a}:{type:n,timestamp:r,delay:i,data:a})},this.addCompressedEventToManager=function(e,t){var n=new Blob([e]).size;if(n>(o.config.maxSingleEventSizeBytes??9e6)){o.config.loggerProvider.warn(`Session replay event dropped: serialized size ${Math.round(n/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}o.eventsManager&&o.deviceId&&o.eventsManager.addEvent({event:{type:`replay`,data:e},sessionId:t,deviceId:o.deviceId})},this.addCompressedEvent=function(e,t){if(o.worker)try{o.worker.postMessage({event:e,sessionId:t})}catch(n){n.name===`DataCloneError`?o.worker.postMessage(JSON.stringify({event:e,sessionId:t})):o.config.loggerProvider.warn(`Unexpected error while posting message to worker:`,n)}else{var n=o.compressEvent(e);o.addCompressedEventToManager(n,t)}},this.flushQueue=function(){var e;for(o.pendingQueue.length>0&&(e=o.taskQueue).push.apply(e,s([],t(o.mergeMutationTasks(o.pendingQueue.splice(0))),!1));o.taskQueue.length>0;){var n=o.taskQueue.shift();if(n){var r=n.event,i=n.sessionId,a=o.compressEvent(r);o.addCompressedEventToManager(a,i)}}o.isProcessing=!1},this.terminate=function(){var e;(e=o.worker)==null||e.terminate()};var c=B();if(this.canUseIdleCallback=c&&`requestIdleCallback`in c,this.eventsManager=e,this.config=n,this.deviceId=r,this.timeout=n.performanceConfig?.timeout||Zd,this.onFullSnapshotProcessed=a,i){n.loggerProvider.log(`Enabling web worker for compression`);try{var l=new Blob([i],{type:`application/javascript`}),u=URL.createObjectURL(l),d=new Worker(u);d.onerror=function(e){e.preventDefault(),n.loggerProvider.error(`Worker failed, falling back to non-worker compression: ${e.message} (${e.filename}:${e.lineno})`),d.terminate(),o.worker=void 0},d.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;o.addCompressedEventToManager(n,r)},this.worker=d}catch(e){n.loggerProvider.error(`Failed to create worker, falling back to non-worker compression:`,e)}}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,r){var i,a,o;if(e.type===Ld.FullSnapshot){if(this.config.loggerProvider.debug(`Processing full snapshot immediately.`),this.taskQueue.length>0||this.pendingQueue.length>0){var c=s(s([],t(this.taskQueue.splice(0)),!1),t(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var l=n(c),u=l.next();!u.done;u=l.next()){var d=u.value,f=this.compressEvent(d.event);this.addCompressedEventToManager(f,d.sessionId)}}catch(e){i={error:e}}finally{try{u&&!u.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}this.isProcessing=!1}var p=this.compressEvent(e);this.addCompressedEventToManager(p,r),(o=this.onFullSnapshotProcessed)==null||o.call(this);return}this.canUseIdleCallback&&this.config.performanceConfig?.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))},e.prototype.processQueue=function(e){var n,r=this;for(this.pendingQueue.length>0&&(n=this.taskQueue).push.apply(n,s([],t(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var i=this.taskQueue.shift();if(i){var a=i.event,o=i.sessionId;this.addCompressedEvent(a,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(e){r.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e.prototype.mergeMutationTasks=function(e){var t,r;if(this.config.performanceConfig?.mergeMutations===!1||e.length<=1)return e;for(var i=[],a=0;a<e.length;){for(var o=e[a].sessionId,s=a+1;s<e.length&&e[s].sessionId===o;)s++;var c=Xd(e.slice(a,s).map(function(e){return e.event}));try{for(var l=(t=void 0,n(c)),u=l.next();!u.done;u=l.next()){var d=u.value;i.push({event:d,sessionId:o})}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}a=s}return i},e}(),$d=`Unexpected error occurred`,ef=`Network error occurred, event batch rejected`,tf=`Session replay event batch rejected due to exceeded retry count`,nf=`Failed to store session replay events in IndexedDB`,rf=`Session replay event batch not sent due to missing device ID`,af=`Session replay event batch not sent due to missing api key`,of=`Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session`,sf=`1.51.0`;function cf(e,t){return i(this,void 0,void 0,function(){var a,o,s,c,l,u,d,f,p,m,h,g,_,v,y=this;return r(this,function(b){switch(b.label){case 0:return b.trys.push([0,4,,5]),a=t.CompressionStream,o=new a(`gzip`),s=o.writable.getWriter(),c=o.readable.getReader(),l=[],u=(function(){return i(y,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return[4,c.read()];case 1:if(e=r.sent(),t=e.done,n=e.value,t)return[3,3];l.push(n),r.label=2;case 2:return[3,0];case 3:return[2]}})})})(),[4,s.write(new TextEncoder().encode(e))];case 1:return b.sent(),[4,s.close()];case 2:return b.sent(),[4,u];case 3:b.sent(),d=l.reduce(function(e,t){return e+t.length},0),f=new Uint8Array(d),p=0;try{for(m=n(l),h=m.next();!h.done;h=m.next())g=h.value,f.set(g,p),p+=g.length}catch(e){_={error:e}}finally{try{h&&!h.done&&(v=m.return)&&v.call(m)}finally{if(_)throw _.error}}return[2,f];case 4:return b.sent(),[2,null];case 5:return[2]}})})}var lf=256,uf=256;function df(e,t){return new Promise(function(n,r){var i=function(){var e=Error(`Custom session replay transport aborted by send timeout`);e.name=`AbortError`,r(e)};t.addEventListener(`abort`,i,{once:!0}),e.then(function(e){t.removeEventListener(`abort`,i),n(e)},function(e){t.removeEventListener(`abort`,i),r(e)})})}var ff=function(){function e(e){var r=e.trackServerUrl,i=e.loggerProvider,a=e.payloadBatcher,o=e.workerScript,s=e.enableTransportCompression,c=e.sendTimeoutMs,l=e.handleSendEvents,u=this;if(this.storageKey=``,this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.timedOutWorkerRequests=new Map,this.flushPauseUntilMs=0,this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,this.mergeLogFiredThisPause=!1,this.killedSessions=new Set,this.loggerProvider=i,this.payloadBatcher=a||function(e){return e},this.trackServerUrl=r,this.enableTransportCompression=s??!0,this.sendTimeoutMs=c??nd,this.handleSendEvents=l,o)try{var d=new Blob([o],{type:`application/javascript`}),f=URL.createObjectURL(d),p=new Worker(f);p.onerror=function(e){var r,a;e.preventDefault(),i.error(`Track destination worker failed, falling back to main-thread sending: ${e.message} (${e.filename}:${e.lineno})`),p.terminate(),u.worker=void 0;try{for(var o=n(u.pendingWorkerRequests),s=o.next();!s.done;s=o.next()){var c=t(s.value,2)[1];c.timeout&&clearTimeout(c.timeout),i.warn(`Session replay event send failed due to worker crash: ${e.message}`),c.resolve()}}catch(e){r={error:e}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}u.pendingWorkerRequests.clear(),u.timedOutWorkerRequests.clear()},p.onmessage=function(e){var t=e.data;if(t.type===`log`)i.log(t.message);else if(t.type===`warn`)i.warn(t.message);else if(t.type===`payload_too_large`){var n=u.pendingWorkerRequests.get(t.id);if(n)n.timeout&&clearTimeout(n.timeout),u.handlePayloadTooLargeResponse(n.context,t.isWaf),n.resolve(),u.pendingWorkerRequests.delete(t.id);else{var r=u.timedOutWorkerRequests.get(t.id);r&&(u.timedOutWorkerRequests.delete(t.id),u.handlePayloadTooLargeResponse(r,t.isWaf))}}else if(t.type===`complete`){var a=u.pendingWorkerRequests.get(t.id);if(a)a.timeout&&clearTimeout(a.timeout),t.skipCode!==void 0&&u.applyServerDirective(a.context.sessionId,t.skipCode),u.completeRequest({context:a.context}),a.resolve(),u.pendingWorkerRequests.delete(t.id);else{var r=u.timedOutWorkerRequests.get(t.id);r&&(u.timedOutWorkerRequests.delete(t.id),t.skipCode!==void 0&&u.applyServerDirective(r.sessionId,t.skipCode),u.completeRequest({context:r}))}}else t.type===`fetch-request`&&u.handleDelegatedFetch(p,t).catch(function(e){i.warn(`Failed to handle delegated session replay fetch:`,e)})},this.worker=p}catch(e){i.error(`Failed to create track destination worker, falling back to main-thread sending:`,e)}}return e.prototype.sendEventsList=function(e){this.addToQueue(c(c({},e),{attempts:0,timeout:0}))},e.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},e.prototype.sendBeacon=function(e){var t=this,n,r=e.events,i=e.sessionId,a=e.deviceId,o=e.apiKey,s=e.serverZone,c=65536,l=function(e){return new Blob([e]).size},u=r,d=JSON.stringify({version:2,events:u});if(l(d)>c){for(var f=0,p=u.length;f<p;){var m=Math.floor((f+p+1)/2);
12l(JSON.stringify({version:2,events:u.slice(0,m)}))<=c?f=m:p=m-1}u=u.slice(0,f),d=JSON.stringify({version:2,events:u}),this.loggerProvider.warn(`sendBeacon payload exceeded 64 KB limit, trimmed from ${r.length} to ${u.length} events`)}if(u.length!==0){if(this.handleSendEvents){var h=new URLSearchParams({device_id:a,session_id:String(i),type:`replay`}),g=`${xd(s,this.trackServerUrl)}?${h.toString()}`,_={"Content-Type":`application/json`,Accept:`*/*`,Authorization:`Bearer ${o}`};this.loggerProvider.debug(`Routing session replay exit batch (${u.length} events) through custom transport for session id ${i}.`);try{this.handleSendEvents({url:g,method:`POST`,headers:_,body:d,keepalive:!0}).catch(function(e){t.loggerProvider.warn(`Custom transport failed to send session replay exit batch:`,e)})}catch(e){this.loggerProvider.warn(`Custom transport threw while sending session replay exit batch:`,e)}return}var v=new URLSearchParams({device_id:a,session_id:String(i),type:`replay`,api_key:o}),y=`${xd(s,this.trackServerUrl)}?${v.toString()}`,b=B();try{var x=new Blob([d],{type:`application/json`});((n=b?.navigator)?.sendBeacon)?.call(n,y,x)===!1&&this.loggerProvider.warn(`sendBeacon failed to queue session replay payload`)}catch{}}},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter(function(t){return e.killedSessions.has(t.sessionId)?(e.completeRequest({context:t,err:of}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:tf}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),e.schedule(0)})},e.prototype.schedule=function(e){var t=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),r=n>0,i=n>e?n:e;r&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},i)}},e.prototype.flush=function(e){return e===void 0&&(e=!1),i(this,void 0,void 0,function(){var t,i,a,o,s,c,l;return r(this,function(r){switch(r.label){case 0:t=this.queue,this.queue=[],this.scheduled&&=(clearTimeout(this.scheduled),null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,t=this.mergeQueueAfterThrottle(t)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,t=this.mergeDrainBacklog(t)),r.label=1;case 1:r.trys.push([1,6,7,8]),i=n(t),a=i.next(),r.label=2;case 2:return a.done?[3,5]:(o=a.value,[4,this.send(o,e)]);case 3:r.sent(),r.label=4;case 4:return a=i.next(),[3,2];case 5:return[3,8];case 6:return s=r.sent(),c={error:s},[3,8];case 7:try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}return[7];case 8:return[2]}})})},e.prototype.mergeQueueAfterThrottle=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log(`Session replay throttle pause ended; merged ${e.length} queued batches into ${t.length} request(s)`)),t},e.prototype.mergeDrainBacklog=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&this.loggerProvider.log(`Session replay coalesced ${e.length} persisted page-load backlog batches into ${t.length} request(s)`),t},e.prototype.coalesceByIdentity=function(e){var a,o,l,u,d=this;if(e.length<=1)return e;var f=new Map;try{for(var p=n(e),m=p.next();!m.done;m=p.next()){var h=m.value,g=[h.sessionId,h.deviceId??``,h.apiKey??``,h.type,h.serverZone??``,h.sampleRate,h.version?.type??``,h.version?.version??``].join(`|`),_=f.get(g);_?_.push(h):f.set(g,[h])}}catch(e){a={error:e}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(a)throw a.error}}var v=[],y=function(e){var a,o;if(e.length===1)return v.push(e[0]),`continue`;var l=null,u=0,f=function(){l&&v.push(l),l=null,u=0},p=function(e){var n=e.events.reduce(function(e,t){return e+new Blob([t]).size},0);if(l===null)return l=c(c({},e),{events:s([],t(e.events),!1),attempts:0}),u=n,`continue`;if(u+n>4e6)return f(),l=c(c({},e),{events:s([],t(e.events),!1),attempts:0}),u=n,`continue`;var a=l.onComplete,o=e.onComplete;l.events=l.events.concat(e.events),u+=n,l.onComplete=function(){return i(d,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return[4,Promise.allSettled([a(),o()])];case 1:return e.sent(),[2]}})})}};try{for(var m=(a=void 0,n(e)),h=m.next();!h.done;h=m.next()){var g=h.value;p(g)}}catch(e){a={error:e}}
12finally{try{h&&!h.done&&(o=m.return)&&o.call(m)}finally{if(a)throw a.error}}f()};try{for(var b=n(f.values()),x=b.next();!x.done;x=b.next()){var S=x.value;y(S)}}catch(e){l={error:e}}finally{try{x&&!x.done&&(u=b.return)&&u.call(b)}finally{if(l)throw l.error}}return v},e.prototype.send=function(e,t){return t===void 0&&(t=!0),i(this,void 0,void 0,function(){var n,i,a,o;return r(this,function(r){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:of})]:(n=e.apiKey,n?(i=e.deviceId,i?(a=this.payloadBatcher({version:1,events:e.events}),a.events.length===0?(this.completeRequest({context:e}),[2]):(o=this.worker,o?[2,this.sendViaWorker(o,e,a,t)]:[2,this.sendOnMainThread(n,i,e,a,t)])):[2,this.completeRequest({context:e,err:rf})]):[2,this.completeRequest({context:e,err:af})])})})},e.prototype.sendViaWorker=function(e,t,n,a){return i(this,void 0,void 0,function(){var i,o=this;return r(this,function(r){return i=`${++this.sendIdCounter}`,[2,new Promise(function(r){var s=o.sendTimeoutMs>0?setTimeout(function(){var e=o.pendingWorkerRequests.get(i);e&&(o.pendingWorkerRequests.delete(i),o.rememberTimedOutRequest(i,e.context),o.loggerProvider.warn(`Session replay worker send timed out after ${o.sendTimeoutMs}ms;
12 leaving events for retry`),e.resolve())},o.sendTimeoutMs):void 0;o.pendingWorkerRequests.set(i,{context:t,resolve:r,timeout:s}),e.postMessage({type:`send`,id:i,payload:n,useRetry:a,useCustomTransport:!!o.handleSendEvents,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:t.flushMaxRetries??0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:Sd(),sdkVersion:sf,enableTransportCompression:o.enableTransportCompression,sendTimeoutMs:o.sendTimeoutMs}})})]})})},e.prototype.rememberTimedOutRequest=function(e,t){var r,i;if(this.timedOutWorkerRequests.set(e,t),this.timedOutWorkerRequests.size>uf)try{for(var a=n(this.timedOutWorkerRequests.keys()),o=a.next();!o.done;o=a.next()){var s=o.value;this.timedOutWorkerRequests.delete(s);break}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}},e.prototype.handleDelegatedFetch=function(e,t){var n;return i(this,void 0,void 0,function(){var i,a,o,s,c,l,u,d,f,p,m;return r(this,function(r){switch(r.label){case 0:i=t.requestId,a=t.url,o=t.method,s=t.headers,c=t.body,l=t.keepalive,r.label=1;case 1:return r.trys.push([1,10,,11]),u=void 0,this.handleSendEvents?[4,this.handleSendEvents({url:a,method:o,headers:s,body:c,keepalive:l})]:[3,3];case 2:return u=r.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(a,{method:o,headers:s,body:c,keepalive:l})];case 4:u=r.sent(),r.label=5;case 5:if(d=u.status,f=null,p=``,d>=200&&d<300&&(f=((n=u.headers)?.get)?.call(n,`X-Session-Replay-Event-Skipped`)??null),d!==413)return[3,9];r.label=6;case 6:return r.trys.push([6,8,,9]),[4,u.text()];case 7:return p=r.sent(),[3,9];case 8:return r.sent(),[3,9];case 9:return this.loggerProvider.debug(`Delegated session replay fetch (request ${i}) returned status ${d}.`),e.postMessage({type:`fetch-response`,requestId:i,status:d,skipHeader:f,body:p}),[3,11];case 10:return m=r.sent(),this.loggerProvider.debug(`Delegated session replay fetch (request ${i}) failed:`,m),e.postMessage({type:`fetch-response`,requestId:i,status:0,skipHeader:null,body:String(m),error:!0}),[3,11];case 11:return[2]}})})},e.prototype.sendOnMainThread=function(e,t,n,a,o){var s;return i(this,void 0,void 0,function(){var i,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,O,k,A;return r(this,function(r){switch(r.label){case 0:i=Sd(),l=sf,u=n.sampleRate,d=new URLSearchParams({device_id:t,session_id:`${n.sessionId}`,type:`${n.type}`}),f=`${n.version?.type??`standalone`}/${n.version?.version??l}`,r.label=1;case 1:return r.trys.push([1,19,,23]),p=JSON.stringify(a),m=B(),this.enableTransportCompression&&m&&`CompressionStream`in m?[4,cf(p,m)]:[3,3];case 2:return g=r.sent(),[3,4];case 3:g=null,r.label=4;case 4:if(h=g,_=h?h.byteLength:new Blob([p]).size,v=new AbortController,y=c({"Content-Type":`application/json`,Accept:`*/*`,Authorization:`Bearer ${e}`,"X-Client-Version":l,"X-Client-Library":f,"X-Client-Url":i.substring(0,ed),"X-Client-Sample-Rate":`${u}`,"X-Sampling-Hash-Alg":`xxhash32`},h?{"Content-Encoding":`gzip`}:{}),b=h??p,x=_<=td,S={headers:y,body:b,method:`POST`,keepalive:x,signal:v.signal},C=`${xd(n.serverZone,this.trackServerUrl)}?${d.toString()}`,a.events.length===0)return this.completeRequest({context:n}),[2];w=this.sendTimeoutMs>0?setTimeout(function(){v.abort()},this.sendTimeoutMs):void 0,T=void 0,r.label=5;case 5:return r.trys.push([5,,10,11]),this.handleSendEvents?[4,df(this.handleSendEvents({url:C,method:`POST`,headers:y,body:b,keepalive:x}),v.signal)]:[3,7];case 6:return E=r.sent(),[3,9];case 7:return[4,fetch(C,S)];case 8:E=r.sent(),r.label=9;case 9:return T=E,[3,11];case 10:return w&&clearTimeout(w),[7];case 11:if(T===null)return this.completeRequest({context:n,err:$d}),[2];if(T.status>=200&&T.status<300&&(D=((s=T.headers)?.get)?.call(s,`X-Session-Replay-Event-Skipped`)??null,this.applyServerDirective(n.sessionId,D)),o)return[3,12];O=``;try{O=JSON.stringify(T.body,null,2)}catch{}return this.completeRequest({context:n,success:`${T.status}: ${O}`}),[3,18];
12case 12:if(O=``,T.status!==413)return[3,16];r.label=13;case 13:return r.trys.push([13,15,,16]),[4,T.text()];case 14:return O=r.sent(),[3,16];case 15:return r.sent(),[3,16];case 16:return[4,this.handleReponse(T.status,n,O)];case 17:r.sent(),r.label=18;case 18:return[3,23];case 19:return k=r.sent(),A=!!k&&typeof k==`object`&&k.name===`AbortError`,A&&o?[4,this.handleOtherResponse(n)]:[3,21];case 20:return r.sent(),[3,22];case 21:this.completeRequest({context:n,err:k}),r.label=22;case 22:return[3,23];case 23:return[2]}})})},e.prototype.handleReponse=function(e,t,n){return n===void 0&&(n=``),i(this,void 0,void 0,function(){var i,a;return r(this,function(r){switch(r.label){case 0:switch(i=new Xt().buildStatus(e),a=i,a){case z.Success:return[3,1];case z.Failed:return[3,2];case z.Timeout:return[3,2];case z.RateLimit:return[3,2];case z.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:return r.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,qu.test(n)),[3,8];case 5:return e===499?[4,this.handleOtherResponse(t)]:[3,7];case 6:return r.sent(),[3,8];case 7:this.completeRequest({context:t,err:ef}),r.label=8;case 8:return[2]}})})},e.prototype.handlePayloadTooLargeResponse=function(e,t){var n=t?`WAF (compressed payload too large)`:`server (event too large)`,r=Math.round(e.events.reduce(function(e,t){return e+t.length},0)/$u);if(!t){this.completeRequest({context:e,err:`Session replay event batch dropped: ${n} rejected payload (${e.events.length} events, ${r} KB) — not retrying non-WAF 413`});return}if(e.events.length===1){this.completeRequest({context:e,err:`Session replay event dropped: single event (${r} KB, 1 event) rejected by ${n} — cannot split further`});return}this.loggerProvider.warn(`Session replay event batch rejected by ${n} (${e.events.length} events, ${r} KB total) — splitting and retrying`),e.onComplete();var i=function(){return Promise.resolve()},a=Math.floor(e.events.length/2);this.sendEventsList(c(c({},e),{events:e.events.slice(0,a),onComplete:i})),this.sendEventsList(c(c({},e),{events:e.events.slice(a),onComplete:i}))},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/$u);this.completeRequest({context:e,success:`Session replay event batch tracked successfully for session id ${e.sessionId}, size of events: ${t} KB`})},e.prototype.handleOtherResponse=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:tf}),[2]):[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e.prototype.applyServerDirective=function(e,t){if(t===null){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if(t===`429`){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+rd,n||this.loggerProvider.log(`Session replay throttled by server; pausing flush schedule for ${rd/1e3}s`);return}(t===`4005`||t===`4004`)&&this.killSession(e,t)},e.prototype.killSession=function(e,t){var r,i,a,o;if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>lf)try{for(var s=n(this.killedSessions),c=s.next();!c.done;c=s.next()){var l=c.value;this.killedSessions.delete(l);break}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}this.loggerProvider.log(`Session replay capture stopped for session ${e} by server directive ${t}; remaining events will be dropped`);var u=[];try{for(var d=n(this.queue),f=d.next();!f.done;f=d.next()){var p=f.value;p.sessionId===e?this.completeRequest({context:p,err:of}):u.push(p)}}catch(e){a={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(a)throw a.error}}this.queue=u}},e}(),pf=(e,t)=>
12t.some(t=>e instanceof t),mf,hf;function gf(){return mf||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function _f(){return hf||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var vf=new WeakMap,yf=new WeakMap,bf=new WeakMap;function xf(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(Df(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return bf.set(t,e),t}function Sf(e){if(vf.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});vf.set(e,t)}var Cf={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return vf.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Df(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)||t in e}};function wf(e){Cf=e(Cf)}function Tf(e){return _f().includes(e)?function(...t){return e.apply(Of(this),t),Df(this.request)}:function(...t){return Df(e.apply(Of(this),t))}}function Ef(e){return typeof e==`function`?Tf(e):(e instanceof IDBTransaction&&Sf(e),pf(e,gf())?new Proxy(e,Cf):e)}function Df(e){if(e instanceof IDBRequest)return xf(e);if(yf.has(e))return yf.get(e);let t=Ef(e);return t!==e&&(yf.set(e,t),bf.set(t,e)),t}var Of=e=>bf.get(e);function kf(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=Df(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(Df(o.result),e.oldVersion,e.newVersion,Df(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var Af=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],jf=[`put`,`add`,`delete`,`clear`],Mf=new Map;function Nf(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(Mf.get(t))return Mf.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=jf.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Af.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return Mf.set(t,a),a}wf(e=>({...e,get:(t,n,r)=>Nf(t,n)||e.get(t,n,r),has:(t,n)=>!!Nf(t,n)||e.has(t,n)}));var Pf=[`continue`,`continuePrimaryKey`,`advance`],Ff={},If=new WeakMap,Lf=new WeakMap,Rf={get(e,t){if(!Pf.includes(t))return e[t];let n=Ff[t];return n||=Ff[t]=function(...e){If.set(this,Lf.get(this)[t](...e))},n}};async function*zf(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,Rf);for(Lf.set(n,t),bf.set(n,Of(t));t;)yield n,t=await(If.get(n)||t.continue()),If.delete(n)}function Bf(e,t){return t===Symbol.asyncIterator&&pf(e,[IDBIndex,IDBObjectStore,IDBCursor])||t===`iterate`&&pf(e,[IDBIndex,IDBObjectStore])}wf(e=>({...e,get(t,n,r){return Bf(t,n)?zf:e.get(t,n,r)},has(t,n){return Bf(t,n)||e.has(t,n)}}));var Vf=function(){function e(e){var t=this;this.minInterval=500,this.maxInterval=Xu,this.maxPersistedEventsSize=Gu,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,n){var r=t.getStringSize(n);return t.getEventsArraySize(e)+r>=t.maxPersistedEventsSize?!0:Date.now()-t.timeAtLastSplit>t.interval&&e.length?(t.interval=Math.min(t.maxInterval,t.interval+t.minInterval),t._timeAtLastSplit=Date.now(),!0):!1},this.loggerProvider=e.loggerProvider,this.minInterval=e.minInterval??this.minInterval,this.maxInterval=e.maxInterval??this.maxInterval,this.maxPersistedEventsSize=e.maxPersistedEventsSize??this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit}
12,enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<=127)t++;else if(r<=2047)t+=2;else if(r>=55296&&r<=56319){var i=n+1<e.length?e.charCodeAt(n+1):NaN;i>=56320&&i<=57343?(t+=4,n++):t+=3}else t+=3}return t},e.prototype.getEventsArraySize=function(e){var t,r,i=0;try{for(var a=n(e),o=a.next();!o.done;o=a.next()){var s=o.value;i+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}var c=2+Math.max(0,e.length-1)+e.length*2;return i+c},e}(),Hf=function(e){return typeof e==`object`&&!!e&&e.name===`AbortError`},Uf=function(e,t,n){Hf(n)?e.debug(t):e.warn(t)};function Wf(){try{return crypto.randomUUID()}catch{return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){var t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}}var Gf=`sessionCurrentSequence`,Kf=`sequencesToSend`,qf=2e3,Jf=5e3;function Yf(e,t,n){return n===void 0&&(n=`IDB operation timed out`),new Promise(function(r,i){var a=setTimeout(function(){return i(Error(`${n} after ${t}ms`))},t);e.then(function(e){clearTimeout(a),r(e)},function(e){clearTimeout(a),i(e)})})}function Xf(e,t,n){var r=setTimeout(n,t);return e.then(function(){return clearTimeout(r)},function(){return clearTimeout(r)}),function(){return clearTimeout(r)}}var Zf=function(e){var t,n;return e.objectStoreNames.contains(`sessionCurrentSequence`)||(n=e.createObjectStore(Gf,{keyPath:`sessionId`})),e.objectStoreNames.contains(`sequencesToSend`)||(t=e.createObjectStore(Kf,{keyPath:`sequenceId`,autoIncrement:!0}),t.createIndex(`sessionId`,`sessionId`)),{sequencesStore:t,currentSequenceStore:n}},Qf=function(e){return i(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Yf(kf(e,1,{upgrade:Zf}),qf,`IDB openDB timed out`)];case 1:return[2,t.sent()]}})})},$f=function(e){o(t,e);function t(t){var n=this;return n=e.call(this,t)||this,n.consecutiveFailures=0,n.hasTriggeredFallback=!1,n.emptyFilteredCount=0,n.getSequencesToSend=function(){return i(n,void 0,void 0,function(){var e,t,n,i,a,o,s,c,l,u,d=this;return r(this,function(r){switch(r.label){case 0:e=!1,t=!1,r.label=1;case 1:return r.trys.push([1,9,,10]),n=[],i=this.db.transaction(`sequencesToSend`,`readwrite`),i.done.catch(function(n){!e&&!t&&(Uf(d.loggerProvider,`${nf}: ${n}`,n),d.recordFailure())}),a=Xf(i.done,Jf,function(){!e&&!t&&(t=!0,Uf(d.loggerProvider,`${nf}: transaction timed out`),d.recordFailure())}),[4,i.store.openCursor()];case 2:o=r.sent(),r.label=3;case 3:return o?(s=o.value,c=s.sessionId,l=s.events,l.length===0?(this.maybeLogEmptyFiltered(`getSequencesToSend`),[4,o.delete()]):[3,5]):[3,8];case 4:return r.sent(),[3,6];case 5:n.push({events:l,sequenceId:o.key,sessionId:c}),r.label=6;case 6:return[4,o.continue()];case 7:return o=r.sent(),[3,3];case 8:return this.recordSuccess(),a(),[2,n];case 9:return u=r.sent(),t||(e=!0,Uf(this.loggerProvider,`${nf}: ${u}`,u),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},n.storeCurrentSequence=function(e){return i(n,void 0,void 0,function(){var t,n,i,o,s,l,u,d,f=this;return r(this,function(r){switch(r.label){case 0:t=!1,n=!1,r.label=1;case 1:return r.trys.push([1,5,,6]),i=this.db.transaction([Gf,Kf],`readwrite`),i.done.catch(function(e){!t&&!n&&(Uf(f.loggerProvider,`${nf}: ${e}`,e),f.recordFailure())}),o=Xf(i.done,Jf,function(){!t&&!n&&(n=!0,Uf(f.loggerProvider,`${nf}: transaction timed out`),f.recordFailure())}),[4,i.objectStore(Gf).get(e)];case 2:return s=r.sent(),!s||s.tabId&&s.tabId!==this.tabId?(o(),[2,void 0]):s.events.length===0?(this.maybeLogEmptyFiltered(`storeCurrentSequence`),o(),[2,void 0]):[4,i.objectStore(Kf).put({sessionId:e,events:s.events,tabId:this.tabId})];case 3:return l=r.sent(),[4,i.objectStore(Gf).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return r.sent(),this.recordSuccess(),o(),s.tabId,u=a(s,[`tabId`]),[2,c(c({},u),{sessionId:e,sequenceId:l})];case 5:return d=r.sent(),n||(t=!0,Uf(this.loggerProvider,`${nf}: ${d}`,d),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},n.addEventToCurrentSequence=function(e,t){return i(n,void 0,void 0,function(){var n,i,a,o,s,c,l,u,d,f=this;return r(this,function(r){switch(r.label){case 0:n=!1,i=!1,r.label=1;case 1:return r.trys.push([1,15,,16]),a=this.db.transaction([Gf,Kf],`readwrite`),a.done.catch(function(e){!n&&!i&&(Uf(f.loggerProvider,`${nf}: ${e}`,e),f.recordFailure())}
12),o=Xf(a.done,Jf,function(){!n&&!i&&(i=!0,Uf(f.loggerProvider,`${nf}: transaction timed out`),f.recordFailure())}),[4,a.objectStore(Gf).get(e)];case 2:return s=r.sent(),s?.tabId&&s.tabId!==this.tabId?s.events.length>0?[4,a.objectStore(Kf).put({sessionId:e,events:s.events,tabId:s.tabId})]:[3,4]:[3,6];case 3:r.sent(),r.label=4;case 4:return[4,a.objectStore(Gf).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:return r.sent(),this.recordSuccess(),o(),[2,void 0];case 6:return c=s,c?[3,8]:[4,a.objectStore(Gf).put({sessionId:e,events:[t],tabId:this.tabId})];case 7:return r.sent(),this.recordSuccess(),o(),[2,void 0];case 8:return this.shouldSplitEventsList(c.events,t)?[3,10]:[4,a.objectStore(Gf).put({sessionId:e,events:c.events.concat(t),tabId:this.tabId})];case 9:return r.sent(),this.recordSuccess(),o(),[2,void 0];case 10:return l=c.events,l.length===0?(this.maybeLogEmptyFiltered(`addEventToCurrentSequence`),[4,a.objectStore(Gf).put({sessionId:e,events:[t],tabId:this.tabId})]):[3,12];case 11:return r.sent(),this.recordSuccess(),o(),[2,void 0];case 12:return[4,a.objectStore(Gf).put({sessionId:e,events:[t],tabId:this.tabId})];case 13:return r.sent(),[4,a.objectStore(Kf).put({sessionId:e,events:l,tabId:this.tabId})];case 14:return u=r.sent(),this.recordSuccess(),o(),[2,{events:l,sessionId:e,sequenceId:u}];case 15:return d=r.sent(),i||(n=!0,Uf(this.loggerProvider,`${nf}: ${d}`,d),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},n.storeSendingEvents=function(e,t){return i(n,void 0,void 0,function(){var n,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.db.put(Kf,{sessionId:e,events:t,tabId:this.tabId})];case 1:return n=r.sent(),this.recordSuccess(),[2,n];case 2:return i=r.sent(),Uf(this.loggerProvider,`${nf}: ${i}`,i),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(e,t){return i(n,void 0,void 0,function(){var e;return r(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Kf,t)];case 2:return n.sent(),this.recordSuccess(),[3,4];case 3:return e=n.sent(),Uf(this.loggerProvider,`${nf}: ${e}`,e),this.recordFailure(),[3,4];case 4:return[2]}})})},n.db=t.db,n.tabId=t.tabId,n.onPersistentFailure=t.onPersistentFailure,n.consecutiveFailureThreshold=t.consecutiveFailureThreshold??1,n}return t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug(`Filtered empty session replay sequence at ${e} (idb store)`)},t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,(e=this.onPersistentFailure)==null||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,n){return i(this,void 0,void 0,function(){var i,a,o,s,l;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),i=e===`replay`?``:`_${e}`,a=`${n.apiKey.substring(0,10)}_amp_session_replay_events${i}`,[4,Qf(a)];case 1:return o=r.sent(),s=n.tabId??Wf(),[2,new t(c(c({},n),{db:o,tabId:s}))];case 2:return l=r.sent(),Uf(n.loggerProvider,`${nf}: ${l}`,l),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return i(this,void 0,void 0,function(){var t,i,o,s,c,t,i,l,u,d;return r(this,function(r){switch(r.label){case 0:return e?[4,this.db.get(`sessionCurrentSequence`,e)]:[3,2];case 1:return t=r.sent(),!t||t.tabId&&t.tabId!==this.tabId?[2,void 0]:(t.tabId,i=a(t,[`tabId`]),[2,[i]]);case 2:o=[],r.label=3;case 3:return r.trys.push([3,8,9,10]),[4,this.db.getAll(`sessionCurrentSequence`)];case 4:s=n.apply(void 0,[r.sent()]),c=s.next(),r.label=5;case 5:if(c.done)return[3,7];if(t=c.value,t.tabId&&t.tabId!==this.tabId)return[3,6];t.tabId,i=a(t,[`tabId`]),o.push(i),r.label=6;case 6:return c=s.next(),[3,5];case 7:return[3,10];case 8:return l=r.sent(),u={error:l},[3,10];case 9:try{c&&!c.done&&(d=s.return)&&d.call(s)}finally{if(u)throw u.error}return[7];case 10:return[2,o]}})})},t}(Vf),ep=function(e){o(a,e);function a(){var t=e!==null&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t.emptyFilteredCount=0,t}return a.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},a.prototype.addSequence=function(e){var n=this.sequenceId++,r=s([],t(this.sequences[e]),!1);return this.finalizedSequences[n]={sessionId:e,events:r},this.resetCurrentSequence(e),{sequenceId:n,events:r,sessionId:e}},a.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug(`Filtered empty session replay sequence at ${e} (in-memory store)`)},a.prototype.getSequencesToSend=function(){return i(this,void 0,void 0,function(){var e,i,a,o,s,c,l,u,d,f;return r(this,function(r){e=[];try{for(i=n(Object.entries(this.finalizedSequences)),a=i.next();!a.done;a=i.next()){if(o=t(a.value,2),s=o[0],c=o[1],l=c.sessionId,u=c.events,u.length===0){this.maybeLogEmptyFiltered(`getSequencesToSend`),delete this.finalizedSequences[Number(s)];continue}e.push({sequenceId:Number(s),sessionId:l,events:u})}}catch(e){d={error:e}}finally{try{a&&!a.done&&(f=i.return)&&f.call(i)}finally{if(d)throw d.error}}return[2,e]})})},a.prototype.storeCurrentSequence=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){return t=this.sequences[e],t?t.length===0?(this.maybeLogEmptyFiltered(`storeCurrentSequence`),[2,void 0]):[2,this.addSequence(e)]:[2,void 0]})})},a.prototype.addEventToCurrentSequence=function(e,t){return i(this,void 0,void 0,function(){var n;return r(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(this.sequences[e].length===0?this.maybeLogEmptyFiltered(`addEventToCurrentSequence`):n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},a.prototype.storeSendingEvents=function(e,t){return i(this,void 0,void 0,function(){return r(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},a.prototype.cleanUpSessionEventsStore=function(e,t){return i(this,void 0,void 0,function(){return r(this,function(e){return t!==void 0&&delete this.finalizedSequences[t],[2]})})},a}(Vf),tp=function(e){var n=e.config,a=e.minInterval,o=e.maxInterval,l=e.maxPersistedEventsSize,u=e.type,d=e.payloadBatcher,f=e.storeType,p=e.trackDestinationWorkerScript,m=e.shouldSe
12nd;return i(void 0,void 0,void 0,function(){function e(e){return e===void 0&&(e=!1),i(this,void 0,void 0,function(){return r(this,function(t){return[2,g.flush(e)]})})}var h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M;return r(this,function(N){switch(N.label){case 0:return h=n.maxSingleEventSizeBytes??Ku,g=new ff(c(c({},n),{loggerProvider:n.loggerProvider,payloadBatcher:d,workerScript:p})),_=function(){return new ep({loggerProvider:n.loggerProvider,maxInterval:o,minInterval:a,maxPersistedEventsSize:l})},y=!1,x=function(){return i(void 0,void 0,void 0,function(){var e,t,i;return r(this,function(r){switch(r.label){case 0:return y?(y=!1,n.loggerProvider.warn(`IDB store is experiencing repeated failures; falling back to in-memory event store.`),v?[4,b.getSequencesToSend()]:[3,2]):[2];case 1:return t=r.sent(),[3,3];case 2:t=void 0,r.label=3;case 3:return e=t,b=_(),e&&v&&(i=v,e.forEach(function(e){D({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})})),[2]}})})},S=function(){return i(void 0,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return[4,$f.new(u,{loggerProvider:n.loggerProvider,minInterval:a,maxInterval:o,maxPersistedEventsSize:l,apiKey:n.apiKey,onPersistentFailure:function(){x()}})];case 1:return e=t.sent(),e?(y=!0,[2,e]):(n.loggerProvider.log(`Failed to initialize idb store, falling back to memory store.`),[2,_()])}})})},f===`idb`?[4,S()]:[3,2];case 1:return C=N.sent(),[3,3];case 2:C=_(),N.label=3;case 3:return b=C,w=[],T=0,E=function(e){if(!(e<=T)){var t=Math.min(e-T,w.length);t>0&&(w.splice(0,t),T=e)}},D=function(e){var t=e.events,a=e.sessionId,o=e.deviceId,s=e.sequenceId,c=t.map(function(e){return{event:e,bytes:new Blob([e]).size}}),l=c.filter(function(e){return e.bytes>h});l.length>0&&n.loggerProvider.warn(`Dropping ${l.length} oversized event(s) from session replay sequence before send. Sizes: ${l.map(function(e){return`${Math.round(e.bytes/1024)} KB`}).join(`, `)}. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.`);var d=l.length>0?c.filter(function(e){return e.bytes<=h}).map(function(e){return e.event}):t;if(d.length===0){b.cleanUpSessionEventsStore(a,s).catch(function(e){n.loggerProvider.warn(`Failed to clean up session replay events store:`,e)});return}n.debugMode&&Dd().then(function(e){var t=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;n.loggerProvider.debug(`Total storage size: ${t} KB, percentage of quota: ${r}%, usage details: ${i}`)}).catch(function(){}),g.sendEventsList({events:d,sessionId:a,flushMaxRetries:n.flushMaxRetries,apiKey:n.apiKey,deviceId:o,sampleRate:n.sampleRate,serverZone:n.serverZone,version:n.version,type:u,onComplete:function(){return i(void 0,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return[4,b.cleanUpSessionEventsStore(a,s)];case 1:return e.sent(),[2]}})})}})},O=function(e){var t=e.sessionId,r=e.deviceId;if(v=r,!m||m()){var i=T+w.length;b.storeCurrentSequence(t).then(function(e){e&&(E(i),D({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r}))}).catch(function(e){n.loggerProvider.warn(`Failed to get current sequence of session replay events for session:`,e)})}},k=function(e){var t=e.deviceId;return i(void 0,void 0,void 0,function(){var e;return r(this,function(r){switch(r.label){case 0:return v=t,[4,b.getSequencesToSend()];case 1:return e=r.sent(),e?.length?(n.loggerProvider.log(`Draining ${e.length} stored sequence(s) from previous session.`),e.length>1&&g.markCoalesceNextFlush(),e.forEach(function(e){D({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})}),[2]):[2]}})})},A=function(e){var t=e.event,r=e.sessionId,i=e.deviceId;v=i;var a=!m||m(),o=T+w.length;w.push(t.data),b.addEventToCurrentSequence(r,t.data).then(function(e){if(e){if(!a){b.cleanUpSessionEventsStore(e.sessionId,e.sequenceId).catch(function(e){n.loggerProvider.warn(`Failed to clean up dropped session replay sequence:`,e)}),E(o);return}E(o),D({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})}}).catch(function(e){n.loggerProvider.warn(`Failed to add event to session replay capture:`,e)})},j=function(){return s([],t(w),!1)},M=function(){E(T+w.length)},[2,{sendCurrentSequenceEvents:O,addEvent:A,sendStoredEvents:k,flush:e,getBeaconEvents:j,dropPendingBeaconEvents:M,trackDestination:g}]}})})},np=function(){function e(){var e=[...arguments],t=new Map;e.forEach(function(e){t.set(e.name,e.manager)}),this.managers=t}return e.prototype.sendStoredEvents=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEac
12h(function(n){t.push(n.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,i=e.deviceId;(t=this.managers.get(r.type))==null||t.addEvent({sessionId:n,event:r,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},e.prototype.flush=function(e){return i(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e}(),rp,ip,ap;function op(e,t){if(ap=new Date,e.nodeType!==Node.ELEMENT_NODE)throw Error(`Can't generate CSS selector for non-element node type.`);if(e.tagName.toLowerCase()===`html`)return`html`;var n={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};rp=c(c({},n),t),ip=sp(rp.root,n);var r=cp(e,`all`,function(){return cp(e,`two`,function(){return cp(e,`one`,function(){return cp(e,`none`)})})});if(r){var i=wp(Tp(r,e));return i.length>0&&(r=i[0]),up(r)}throw Error(`Selector was not found.`)}function sp(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}function cp(e,r,i){for(var a=null,o=[],c=e,l=0,u=function(){var e,u,d=new Date().getTime()-ap.getTime();if(rp.timeoutMs!==void 0&&d>rp.timeoutMs)throw Error(`Timeout: Can't find a unique selector after ${d}ms`);var f=xp(pp(c))||xp.apply(void 0,s([],t(mp(c)),!1))||xp.apply(void 0,s([],t(hp(c)),!1))||xp(gp(c))||[_p()],p=vp(c);if(r==`all`)p&&(f=f.concat(f.filter(bp).map(function(e){return yp(e,p)})));else if(r==`two`)f=f.slice(0,1),p&&(f=f.concat(f.filter(bp).map(function(e){return yp(e,p)})));else if(r==`one`){var m=t(f=f.slice(0,1),1)[0];p&&bp(m)&&(f=[yp(m,p)])}else r==`none`&&(f=[_p()],p&&(f=[yp(f[0],p)]));try{for(var h=(e=void 0,n(f)),g=h.next();!g.done;g=h.next()){var m=g.value;m.level=l}}catch(t){e={error:t}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(e)throw e.error}}if(o.push(f),o.length>=rp.seedMinLength&&(a=lp(o,i),a))return`break`;c=c.parentElement,l++};c&&u()!==`break`;);return a||=lp(o,i),!a&&i?i():a}function lp(e,t){var r,i,a=wp(Cp(e));if(a.length>rp.threshold)return t?t():null;try{for(var o=n(a),s=o.next();!s.done;s=o.next()){var c=s.value;if(fp(c))return c}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return null}function up(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var i=e[r].level||0;n=t.level===i-1?`${e[r].name} > ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function dp(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function fp(e){var t=up(e);switch(ip.querySelectorAll(t).length){case 0:throw Error(`Can't select any node with this selector: ${t}`);case 1:return!0;default:return!1}}function pp(e){var t=e.getAttribute(`id`);return t&&rp.idName(t)?{name:`#`+CSS.escape(t),penalty:0}:null}function mp(e){return Array.from(e.attributes).filter(function(e){return rp.attr(e.name,e.value)}).map(function(e){return{name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5}})}function hp(e){return Array.from(e.classList).filter(rp.className).map(function(e){return{name:`.`+CSS.escape(e),penalty:1}})}function gp(e){var t=e.tagName.toLowerCase();return rp.tagName(t)?{name:t,penalty:2}:null}function _p(){return{name:`*`,penalty:3}}function vp(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;for(var r=0;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function yp(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function bp(e){return e.name!==`html`&&!e.name.startsWith(`#`)}function xp(){var e=[...arguments].filter(Sp);return e.length>0?e:null}function Sp(e){return e!=null}function Cp(e,t){var i,a,o,s,c,l;return t===void 0&&(t=[]),r(this,function(r){switch(r.label){case 0:if(!(e.length>0))return[3,9];r.label=1;case 1:r.trys.push([1,6,7,8]),i=n(e[0]),a=i.next(),r.label=2;case 2:return a.done?[3,5]:(o=a.value,[5,n(Cp(e.slice(1,e.length),t.concat(o)))]);case 3:r.sent(),r.label=4;case 4:return a=i.next(),[3,2];case 5:return[3,8];case 6:return s=r.sent(),c={error:s},[3,8];case 7:try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}
12return[7];case 8:return[3,11];case 9:return[4,t];case 10:r.sent(),r.label=11;case 11:return[2]}})}function wp(e){return s([],t(e),!1).sort(function(e,t){return dp(e)-dp(t)})}function Tp(e,i,a){var o,c,l;return a===void 0&&(a={counter:0,visited:new Map}),r(this,function(r){switch(r.label){case 0:if(!(e.length>2&&e.length>rp.optimizedMinLength))return[3,5];o=1,r.label=1;case 1:return o<e.length-1?a.counter>rp.maxNumberOfTries||(a.counter+=1,c=s([],t(e),!1),c.splice(o,1),l=up(c),a.visited.has(l))?[2]:fp(c)&&Ep(c,i)?[4,c]:[3,4]:[3,5];case 2:return r.sent(),a.visited.set(l,!0),[5,n(Tp(c,i,a))];case 3:r.sent(),r.label=4;case 4:return o++,[3,1];case 5:return[2]}})}function Ep(e,t){return ip.querySelector(up(e))===t}var Dp=36e5,Op=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);t.count=1,t.type===`click`&&r.push(t)}),{version:t,events:r}},kp=function(e){var t=e.version,n=e.events,r=[];n.forEach(function(e){var t=JSON.parse(e);t.type===`click`&&r.push(t)});var i=r.reduce(function(e,t){var n=t.x,r=t.y,i=t.selector,a=t.timestamp,o=a-a%Dp,s=`${n}:${r}:${i??``}:${o}`;return e[s]?e[s].count+=1:e[s]=c(c({},t),{timestamp:o,count:1}),e},{});return{version:t,events:Object.values(i)}},Ap=function(){function e(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,a=e.mirror,o=e.ugcFilterRules,s=e.performanceOptions;return function(e){if(e.type===zd.Click){var c=B();if(c){var l=c.location,u=c.innerHeight,d=c.innerWidth;if(l){var f=e.x,p=e.y;if(f!==void 0&&p!==void 0){var m=a.getNode(e.id),h;if(m)try{h=op(m,s)}catch{n.logger.debug(`error resolving selector from finder`)}var g=Ed(l.href,o),_={x:f+n.scrollWatcher.currentScrollX,y:p+n.scrollWatcher.currentScrollY,selector:h,viewportHeight:u,viewportWidth:d,pageUrl:g,timestamp:Date.now(),type:`click`},v=i();v&&t.addEvent({sessionId:r,event:{type:`interaction`,data:JSON.stringify(_)},deviceId:v})}}}}}},this.logger=e,this.scrollWatcher=t}return e}();function jp(){return B()?.innerHeight||document.documentElement&&document.documentElement.clientHeight||0}function Mp(){return B()?.innerWidth||document.documentElement&&document.documentElement.clientWidth||0}var Np=function(){function e(e,t){var n=B();this.sendBeacon=n&&n.navigator&&typeof n.navigator.sendBeacon==`function`?function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch{}return!1}:function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open(`POST`,e,!0),n.setRequestHeader(`Accept`,`*/*`),n.send(JSON.stringify(t)),!0},this.basePageUrl=xd(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e,this.handleSendEvents=t.handleSendEvents,this.loggerProvider=t.loggerProvider}return e.prototype.send=function(e,t){var n=this,r,i=this.context,a=i.sessionId,o=i.t
12ype;if(this.handleSendEvents){var s=new URLSearchParams({device_id:e,session_id:String(a),type:String(o)}),c=`${this.basePageUrl}?${s.toString()}`,l={"Content-Type":`application/json`,Accept:`*/*`,Authorization:`Bearer ${this.apiKey}`};try{this.handleSendEvents({url:c,method:`POST`,headers:l,body:JSON.stringify(t),keepalive:!0}).catch(function(e){var t;(t=n.loggerProvider)==null||t.warn(`Custom transport failed to send session replay interaction beacon:`,e)})}catch(e){(r=this.loggerProvider)==null||r.warn(`Custom transport threw while sending session replay interaction beacon:`,e)}return}var u=new URLSearchParams({device_id:e,session_id:String(a),type:String(o),api_key:this.apiKey}),d=`${this.basePageUrl}?${u.toString()}`;this.sendBeacon(d,t)||this.sendXhr(d,t)},e}(),Pp=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r=e(),i=B();if(i&&r){var a=i.scrollX??0,o=i.scrollY??0;(a>0||o>0)&&n.update({id:1,x:a,y:o}),n.transport.send(r,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:jp(),viewportWidth:Mp(),pageUrl:Ed(i.location.href,n.config.interactionConfig?.ugcFilterRules??[]),timestamp:n.timestamp,type:`scroll`}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=Mp(),this._maxScrollHeight=jp(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new Np(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=Mp();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=jp();this._maxScrollY=e.y;var a=e.y+i;a>this._maxScrollHeight&&(this._maxScrollHeight=a),this.timestamp=t}},e}(),Fp=function(){function e(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=Cd(t,n))}return e}(),Ip=`AMP_SR_START_`,Lp=10,Rp=function(e){return`${Ip}${e.substring(0,Lp)}_`},zp=function(e,t){return`${Rp(e)}${t}`},Bp=function(){try{return B()?.localStorage}catch{return}},Vp=function(e,t,n,r){var i=Bp();if(i){var a=zp(e,t);try{var o=i.getItem(a);if(o!==null){var s=Number(o);if(Number.isFinite(s)&&s>0&&s<=n&&n-s<864e5)return s}return i.setItem(a,String(n)),n}catch(e){r?.debug(`Failed to read/write replay start time from storage: ${String(e)}`);return}}},Hp=function(e,t,n,r){var i=Bp();if(i)try{i.setItem(zp(e,t),String(n))}catch(e){r?.debug(`Failed to write replay start time to storage: ${String(e)}`)}},Up=function(e,t,n){var r=Bp();if(r)try{r.removeItem(zp(e,t))}catch(e){n?.debug(`Failed to remove replay start time from storage: ${String(e)}`)}},Wp=function(e,t,r){var i,a,o=Bp();if(o){var s=Rp(e);try{for(var c=[],l=0;l<o.length;l++){var u=o.key(l);if(u&&u.startsWith(s)){var d=o.getItem(u);if(d!==null){var f=Number(d);(!Number.isFinite(f)||f<=0||t-f>=864e5)&&c.push(u)}}}try{for(var p=n(c),m=p.next();!m.done;m=p.next()){var u=m.value;o.removeItem(u)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}catch(e){r?.debug(`Failed to prune stale replay start times: ${String(e)}`)}}},Gp=new(function(){function e(){var e=this;this.dbs={},this.createStore=function(t){return i(e,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return[4,kf(t,1,{upgrade:function(e){e.objectStoreNames.contains(`sessionTargetingMatch`)||e.createObjectStore(`sessionTargetingMatch`,{keyPath:`sessionId`})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return i(e,void 0,void 0,function(){var e,n;return r(this,function(r){switch(r.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e=`${t.substring(0,10)}_amp_session_replay_targeting`,[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,a=t.apiKey,o=t.sessionId;return i(e,void 0,void 0,function(){var e,t,i,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.openOrCreateDB(a)];case 1:return e=r.sent(),t=String(o),[4,e.get(`sessionTargetingMatch`,t)];case 2:return i=r.sent(),[2,i?.targetingMatch];case 3:return s=r.sent(),Uf(n,`Failed to get targeting match for session id ${o}: ${s}`,s),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,a=t.apiKey,o=t.sessionId,s=t.targetingMatch;return i(e,void 0,void 0,function(){var e,t,i,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.openOrCreateDB(a)];case 1:return e=r.sent(),t=String(o),[4,e.put(`sessionTargetingMatch`,{targetingMatch:s,sessionId:t,lastUpdated:Date.now()})];case 2:return i=r.sent(),[2,i];case 3:return c=r.sent(),Uf(n,`Failed to store targeting match for session id ${o}: ${c}`,c),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,a=t.apiKey,o=t.currentSessionId;return i(e,void 0,void 0,function(){var e,t,i,s,c,l,u,d;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),[4,this.openOrCreateDB(a)];case 1:return e=r.sent(),t=String(o),i=e.transaction(`sessionTargetingMatch`,`readwrite`),[4,i.store.getAll()];case 2:s=r.sent(),c=0,r.label=3;case 3:return c<s.length?(l=s[c],u=Date.now()-l.lastUpdated,l.sessionId!==t&&u>1728e5?[4,i.store.delete(l.sessionId)]:[3,5]):[3,6];case 4:r.sent(),r.label=5;case 5:return c++,[3,3];case 6:return[4,i.done];case 7:return r.sent(),[3,9];case 8:return d=r.sent(),Uf(n,`Failed to clear old targeting matches for sessions: ${d}`,d),[3,9];case 9:return[2]}})})}}return e}()),Kp=function(t){var n=t.sessionId,a=t.targetingConfig,o=t.loggerProvider,s=t.apiKey,l=t.targetingParams,u=t.urlChange,d=u!==void 0&&u;return i(void 0,void 0,void 0,function(){var t,i,u,f,p,m,h;return r(this,function(r){switch(r.label){case 0:return[4,Gp.clearStoreOfOldSessions({loggerProvider:o,apiKey:s,currentSessionId:n})];case 1:return r.sent(),[4,Gp.getTargetingMatchForSession({loggerProvider:o,apiKey:s,sessionId:n})];case 2:if(t=r.sent(),t===!0&&!d)return[2,!0];i=!0,r.label=3;case 3:return r.trys.push([3,6,,7]),[4,e(()=>import(`./DKluN0jK.js`),__vite__mapDeps([0,1]),import.meta.url)];case 4:return u=r.sent().evaluateTargeting,f=c(c({},l),{flag:a,sessionId:typeof n==`string`?parseInt(n,10):n,apiKey:s,loggerProvider:o}),[4,u(f)];case 5:return p=r.sent(),p&&p.sr_targeting_config&&(i=p.sr_targeting_config.key===`on`),Gp.storeTargetingMatchForSession({loggerProvider:o,apiKey:s,sessionId:n,targetingMatch:i}),[3,7];case 6:return m=r.sent(),h=m,o.warn(h.message),[3,7];case 7:return[2,i]}})})},qp=2654435761,Jp=2246822519,Yp=3266489917,Xp=668265263,Zp=374761393;function Qp(e,t){return(e<<t|e>>>32-t)>>>0}function $p(e,t){return e=e+Math.imul(t,Jp)>>>0,e=Qp(e,13),e=Math.imul(e,qp)>>>0,e}function em(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function tm(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=(r-55296<<10)+(i-56320)+65536,n++)}r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<65536?t.push(224|r>>12,128|r>>6&63,128|r&63):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return new Uint8Array(t)}function nm(e,t){t===void 0&&(t=0);var n=tm(e),r=n.length,i,a=0;if(r>=16){for(var o=t+qp+Jp>>>0,s=t+Jp>>>0,c=t>>>0,l=t-qp>>>0;a<=r-16;)o=$p(o,em(n,a)),a+=4,s=$p(s,em(n,a)),a+=4,c=$p(c,em(n,a)),a+=4,l=$p(l,em(n,a)),a+=4;i=Qp(o,1)+Qp(s,7)+Qp(c,12)+Qp(l,18)>>>0}else i=t+Zp>>>0;for(i=i+r>>>0;a<=r-4;)i=i+Math.imul(em(n,a),Yp)>>>0,i=Math.imul(Qp(i,17),Xp)>>>0,a+=4;for(;a<r;)i=i+Math.imul(n[a],Zp)>>>0,i=Math.imul(Qp(i,11),qp)>>>0,a++;return i^=i>>>15,i=Math.imul(i,Jp)>>>0,i^=i>>>13,i=Math.imul(i,Yp)>>>0,i^=i>>>16,i>>>0}function rm(e,t){return nm(e.toString())%1e6/1e6<t}var im=`__amplitude_url_tracking_patched__`,am=new WeakMap;function om(e,t,n){if(n===void 0&&(n={}),!e?.location)return function(){};var r=n.enablePolling,i=r!==void 0&&r,a=n.pollingInterval,o=a===void 0?Ru:a;if(i){var s=function(){return e.location.href??``},c=s(),l=e.setInterval(function(){var e=s();e!==c&&(c=e,t(e))},o);return function(){l!=null&&e.clearInterval(l)}}var u=am.get(e);if(!u){var d=void 0,f=new Set,p=function(){return e.location.href??``},m=function(){var e=p();(d===void 0||e!==d)&&(d=e,f.forEach(function(t){return t(e)}))},h=function(e){var t=function(){var t=[...arguments],n=e.apply(this,t);return m(),n};return t[im]=!0,t},g=e.history;if(g?.pushState){var _=Reflect.get(g,`pushState`);_[im]||(g.pushState=h(_))}if(g?.replaceState){var v=Reflect.get(g,`replaceState`);v[im]||(g.replaceState=h(v))}u={callbacks:f,notify:m,onPopStateOrHashChange:function(){return m()},listenersAttached:!1},am.set(e,u)}var y=u;return y.listenersAttached||=(e.addEventListener(`popstate`,y.onPopStateOrHashChange),e.addEventListener(`hashchange`,y.onPopStateOrHashChange),!0),y.callbacks.add(t),function(){y.callbacks.delete(t),y.callbacks.size===0&&(y.listenersAttached&&=(e.removeEventListener(`popstate`,y.onPopStateOrHashChange),e.removeEventListener(`hashchange`,y.onPopStateOrHashChange),!1))}}function sm(e){return e===void 0&&(e={}),{name:`amplitude/url-tracking@1`,observer:function(t,n,r){var i=c(c({},e),r),a=i.ugcFilterRules||[],o=i.enablePolling??!1,s=i.pollingInterval??Ru,l=i.captureDocumentTitle??!1;if(!n)return function(){};var u=void 0,d=function(){return n.location&&n.location.href||``},f=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=d(),o=``;return l&&(o=r?.title||``),{href:a.length>
120?Ed(i,a):i,title:o,viewportHeight:e,viewportWidth:t,type:`url-change-event`}},p=function(){var e=d();(u===void 0||e!==u)&&(u=e,t(f()))},m=om(n,function(){return p()},o?{enablePolling:!0,pollingInterval:s}:{});return p(),function(){return m()}},options:e}}sm();function cm(){try{var e=B();return e?e.parent!==e:!1}catch{return!0}}var lm=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e=this,t;(t=this.mutationObserver)==null||t.disconnect(),B()&&(this.sendToAllIframes({type:id,action:`start`}),this.mutationObserver=new MutationObserver(function(t){var r,i,a,o,s,c;try{for(var l=n(t),u=l.next();!u.done;u=l.next()){var d=u.value;try{for(var f=(a=void 0,n(Array.from(d.addedNodes))),p=f.next();!p.done;p=f.next()){var m=p.value;m instanceof HTMLIFrameElement?e.sendToIframeAfterLoad(m):m instanceof Element&&m.querySelectorAll(`iframe`).forEach(function(t){e.sendToIframeAfterLoad(t)})}}catch(e){a={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(a)throw a.error}}try{for(var h=(s=void 0,n(Array.from(d.removedNodes))),g=h.next();!g.done;g=h.next()){var m=g.value;if(m instanceof HTMLIFrameElement){var _=e.pendingLoadListeners.get(m);_&&(m.removeEventListener(`load`,_),e.pendingLoadListeners.delete(m))}}}catch(e){s={error:e}}finally{try{g&&!g.done&&(c=h.return)&&c.call(h)}finally{if(s)throw s.error}}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},e.prototype.stop=function(){var e;(e=this.mutationObserver)==null||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener(`load`,e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:id,action:`stop`})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:id,action:`start`})};this.pendingLoadListeners.set(e,n),e.addEventListener(`load`,n,{once:!0})},e.prototype.sendToAllIframes=function(e){var t=this;document.querySelectorAll(`iframe`).forEach(function(n){return t.sendToIframe(n,e)})},e.prototype.sendToIframe=function(e,t){var n;try{(n=e.contentWindow)==null||n.postMessage(t,`*`)}catch{}},e}();function um(e){var t=B();if(!t)return function(){};var n=t.parent;function r(t){if(t.source===n){var r=t.data;r?.type===`amplitude-sr-iframe`&&(r.action===`start`?e.onStart():r.action===`stop`&&e.onStop())}}return t.addEventListener(`message`,r),function(){return t.removeEventListener(`message`,r)}}var dm=function(){function a(){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(t){var n=B();n&&(n.removeEventListener(`blur`,e.blurListener),n.removeEventListener(`focus`,e.focusListener),!t&&n.addEventListener(`blur`,e.blurListener),!t&&n.addEventListener(`focus`,e.focusListener),n.self&&`onpagehide`in n.self?(n.removeEventListener(`pagehide`,e.pageLeaveListener),!t&&n.addEventListener(`pagehide`,e.pageLeaveListener)):(n.removeEventListener(`beforeunload`,e.pageLeaveListener),!t&&n.addEventListener(`beforeunload`,e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){if(e.recordingEnabled){if(e.recordCancelCallback&&e.recordFunction){if(e.config?.captureFullSnapshotOnFocus===!1)return;try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn(`Failed to take full snapshot on focus:`,t)}}else e.recordEventsInFlight||e.recordEvents(!1)}},this.pageLeaveListener=function(t){var n;(n=e.eventCompressor)==null||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,a,o){return n===void 0&&(n=!1),a===void 0&&(a=!1),o===void 0&&(o=!1),i(e,void 0,void 0,function(){var e,i,s,c,l,u,d;return r(this,function(r){switch(r.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=t,e=this.config.targetingConfig,i=e&&!this.sessionTargetingMatch,i?(s=o?this.latestUrlChangeTargetingEvaluationId:void 0,c=t.event,c&&Object.values(b).includes(c.event_type)&&(c=void 0),l=t.page?.url??B()?.location?.href??``,u=t.page??(l===``?void 0:{url:l}),[4,Kp({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:c,page:u},urlChange:o})]):[3,2];case 1:if(d=r.sent(),o&&s!==void 0&&s!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug(`Ignoring stale URL-change targeting result #${s}; latest is #${this.latestUrlChangeTargetingEvaluationId}.`),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||d,this.loggerProvider.debug(JSON.stringify({name:`targeted replay capture config`,sessionTargetingMatch:this.sessionTargetingMatch,event:c,targetingParams:t},null,2)),r.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return!a&&this.recordCancelCallback?[3,5]:(this.loggerProvider.log(`Recording events for session due to forceRestart or no ongoing recording.`),[4,this.recordEvents()]);case 4:r.sent(),r.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,a){return n===void 0&&(n={}),a===void 0&&(a=!0),i(e,void 0,void 0,function(){var e,i,o,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e=void 0,i=this.config,!(i&&t!==ad.METADATA)||(e={config:Od(i),version:sf},!a)?[3,2]:[4,Dd()];case 1:o=r.sent(),e=c(c({},o),e),r.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,c(c({},n),e)):this.loggerProvider.debug(`Not able to add custom replay capture event ${t} due to no ongoing recording.`),[3,4];case 3:return s=r.sent(),this.loggerProvider.debug(`Error while adding custom replay capture event: `,s),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t,n,r;try{e.loggerProvider.log(`Session Replay capture stopping.`),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,(t=e.networkObservers)==null||t.stop(),(n=e.crossOriginIframeC
12oordinator)==null||n.stop(),e.crossOriginIframeCoordinator=null,(r=e.crossOriginParentSignalCleanup)==null||r.call(e),e.crossOriginParentSignalCleanup=null}catch(t){var i=t;e.loggerProvider.warn(`Error occurred while stopping replay capture: ${i.toString()}`)}},this.loggerProvider=new od(new ze)}return a.prototype.init=function(e,t){return V(this._init(e,t))},a.prototype.setupUrlChangeListener=function(){var e=this,t;(t=this.urlChangeCleanup)==null||t.call(this);var n=B();if(n?.location){var r=!!this.config?.targetingConfig,i=om(n,function(t){if(e.currentPageUrl=t,r){var n=++e.latestUrlChangeTargetingEvaluationId;e.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:t}},!1,!1,!0),e.loggerProvider.debug(`Queued URL-change targeting re-evaluation #${n} for ${t}.`)}});this.urlChangeCleanup=function(){i(),e.urlChangeCleanup=null}}},a.prototype.isBelowMinSessionDuration=function(){var e=this.config?.minSessionDurationMs;return e===void 0||this.sessionStartTime===void 0?!1:Date.now()-this.sessionStartTime<e},a.prototype.getCurrentPageForTargeting=function(){var e=B()?.location?.href;return e==null?void 0:{url:e}},a.prototype._init=function(a,o){var l;return i(this,void 0,void 0,function(){var i,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,E,A,j,M,N,ee,P,F,te,ne,re,ie,I=this;return r(this,function(r){switch(r.label){case 0:return(l=this.urlChangeCleanup)==null||l.call(this),this.recordingEnabled=!0,this.startChildRecordingOnSetup=!1,this.loggerProvider=new od(o.loggerProvider||new ze),Object.prototype.hasOwnProperty.call(o,`logLevel`)&&this.loggerProvider.enable(o.logLevel),this.currentPageUrl=Sd(),this.identifiers=new Fp({sessionId:o.sessionId,deviceId:o.deviceId}),i=Date.now(),Wp(a,i,this.loggerProvider),this.sessionStartTime=o.sessionId===void 0?i:Vp(a,o.sessionId,i,this.loggerProvider)??i,u=this,[4,Wd(a,o)];case 1:return u.joinedConfigGenerator=r.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return d=r.sent(),f=d.joinedConfig,p=d.localConfig,m=d.remoteConfig,this.config=f,this.setMetadata(o.sessionId,f,p,m,o.version?.version,sf,o.version?.type),this.pageLeaveFns=[],o.sessionId&&this.config.interactionConfig?.enabled&&(h=Pp.default({sessionId:o.sessionId,type:`interaction`},this.config),this.pageLeaveFns=[h.send(this.getDeviceId.bind(this)).bind(h)],this.scrollHook=h.hook.bind(h),this.clickHandler=new Ap(this.loggerProvider,h)),g=[],_=this.config.storeType,_===`idb`&&!B()?.indexedDB&&(_=`memory`,this.loggerProvider.warn(`Could not use preferred indexedDB storage, reverting to in memory option.`)),this.loggerProvider.log(`Using ${_} for event storage.`),b=B(),this.config.useWebWorker&&b&&b.Worker?[4,e(()=>import(`./DahueVGo.js`),[],import.meta.url)]:[3,4];case 3:x=r.sent(),S=x.compressionScript,C=x.trackDestinationScript,v=S,y=C,r.label=4;case 4:return r.trys.push([4,6,,7]),[4,tp({config:this.config,type:`replay`,minInterval:this.config.flushIntervalConfig?.minIntervalMs,maxInterval:this.config.flushIntervalConfig?.maxIntervalMs,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:_,trackDestinationWorkerScript:y,shouldSend:function(){return!I.isBelowMinSessionDuration()}})];case 5:return w=r.sent(),this.rrwebEventManager=w,g.push({name:`replay`,manager:w}),[3,7];case 6:return T=r.sent(),E=T,this.loggerProvider.warn(`Error occurred while creating replay events manager: ${E.toString()}`),[3,7];case 7:if(!this.config.interactionConfig?.enabled)return[3,11];D=this.config.interactionConfig.batch?kp:Op,r.label=8;case 8:return r.trys.push([8,10,,11]),[4,tp({config:this.config,type:`interaction`,minInterval:this.config.interactionConfig.trackEveryNms??Ju,maxInterval:Yu,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:D,storeType:_,trackDestinationWorkerScript:y})];case 9:return O=r.sent(),g.push({name:`interaction`,manager:O}),[3,11];case 10:return k=r.sent(),E=k,this.loggerProvider.warn(`Error occurred while creating interaction events manager: ${E.toString()}`),[3,11];case 11:if(this.eventsManager=new(np.bind.apply(np,s([void 0],t(g),!1))),this.eventCompressor&&this.eventCompressor.terminate(),A=this.config.eagerFullSnapshotSend===!0?function(){return I.sendEvents()}:void 0,this.eventCompressor=new Qd(this.eventsManager,this.config,this.getDeviceId(),v,A),this.pendingEmitEvents.length>0){j=this.pendingEmitEvents.splice(0);try{for(M=n(j),N=M.next();!N.done;N=M.next())ee=N.value,P=ee.event,F=ee.sessionId,this.eventCompressor.enqueueEvent(P,F)}catch(e){re={error:e}}finally{try{N&&!N.done&&(ie=M.return)&&ie.call(M)}finally{if(re)throw re.error}}}return this.pageLeaveFns=s(s([],t(this.pageLeaveFns),!1),[function(){if(I.config&&I.identifiers?.sessionId&&w){var e=w.getBeaconEvents();if(e.length){var t=I.getDeviceId();t&&(I.isBelowMinSessionDuration()||w.trackDestination.sendBeacon({events:e,sessionId:I.identifiers.sessionId,deviceId:t,apiKey:I.config.apiKey,serverZone:I.config.serverZone}))}}}],!1),[4,this.initializeNetworkObservers()];case 12:return r.sent(),B()?.opener&&(te=hr(),yr(te),te.setup(c({logger:this.loggerProvider},this.config.serverZone&&{endpoint:or[this.config.serverZone]}))),this.loggerProvider.log(`Installing @amplitude/session-replay-browser.`),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:o.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return r.sent(),ne=this.config.targetingConfig||(this.config.privacyConfig?.urlMaskLevels?.length??0)>0,ne&&this.setupUrlChangeListener(),[2]}})})},a.prototype.setSessionId=function(e,t){return V(this.asyncSetSessionId(e,t))},a.prototype.asyncSetSessionId=function(e,t,n){var a;return i(this,void 0,void 0,function(){var i,o,s,c,l;return r(this,function(r){switch(r.label){case 0:return i=this.identifiers?.sessionId,o=this.getDeviceId(),i!==void 0&&i===e&&(t===void 0||t===o)&&(n?.userProperties===void 0||Object.keys(n.userProperties).length===0)?[2]:(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,i&&this.sendEvents(i),s=i!==e,s&&((a=this.rrwebEventManager)==null||a.dropPendingBeaconEvents()),c=t||this.getDeviceId(),this.identifiers=new Fp({sessionId:e,deviceId:c}),s&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,this.config?.apiKey&&(Hp(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),i!==void 0&&Up(this.config.apiKey,i,this.loggerProvider))),this.joinedConfigGenerator&&i?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2]);case 1:l=r.sent().joinedConfig,this.config=l,r.label=2;case 2:return this.config?.targetingConfig?[4,this.evaluateTargetingAndCapture({userProperties:n?.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return r.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:r.sent(),r.label=6;case 6:return[2]}})})},a.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn(`Session replay init has not been called, cannot get session replay properties.`),{};var r=this.getShouldRecord(),i={};return r&&(i=(e={},e[Fu]=n.sessionReplayId?n.sessionReplayId:null,e),t.debugMode&&(i[zu]=JSON.stringify({appHash:St(t.apiKey).toString()}))),this.addCustomRRWebEvent(ad.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},this.eventCount===10),this.eventCount===10&&(this.eventCount=0),this.eventCount++,i},a.prototype.sendEvents=function(e){var t=e||this.identifiers?.sessionId,n=this.getDeviceId();if(this.eventsManager&&t&&n){if(this.isBelowMinSessionDuration()){var r=this.sessionStartTime,i=this.config.minSessionDurationMs;this.loggerProvider.log(`Session ${t} not sent: duration ${Date.now()-r}ms is below minimum ${i}ms.`),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&this.config?.minSessionDurationMs!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var a=this.sessionStartTime===void 0?void 0:Date.now()-this.sessionStartTime;this.addCustomRRWebEvent(ad.REPLAY_GATE_DECISION,{sessionId:t,suppressedSendCount:this.suppressedSendCount,elapsedMs:a,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:t,deviceId:n})}},a.prototype.initialize=function(e){return e===void 0&&(e=!1),i(this,void 0,void 0,function(){var t;return r(this,function(n){return this.identifiers?.sessionId?(t=this.getDeviceId(),t?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:t}),[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()])})})},a.prototype.shouldOptOut=function(){var e;return this.config?.instanceName&&(e=ut(this.config.instanceName).identityStore.getIdentity().optOut),e===void 0?this.config?.optOut:e},a.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 ${this.identifiers.sessionId}
12 not being captured because recording was stopped.`),!1;if(!this.config.captureEnabled)return this.loggerProvider.log(`Session ${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 ${this.identifiers.sessionId} out of recording due to optOut config.`),!1;var e=!1,t=``,n=!1;return this.config.targetingConfig?this.sessionTargetingMatch?(t=`Capturing replays for session ${this.identifiers.sessionId} due to matching targeting conditions.`,this.loggerProvider.log(t),e=!0,n=!0):(t=`Not capturing replays for session ${this.identifiers.sessionId} due to not matching targeting conditions.`,this.loggerProvider.log(t),e=!1,n=!1):rm(this.identifiers.sessionId,this.config.sampleRate)?(e=!0,n=!0):(t=`Opting session ${this.identifiers.sessionId} out of recording due to sample rate.`,this.loggerProvider.log(t),e=!1,n=!1),this.lastShouldRecordDecision!==e&&this.config.targetingConfig&&(this.addCustomRRWebEvent(ad.TARGETING_DECISION,{message:t,sessionId:this.identifiers.sessionId,matched:n,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=e),e},a.prototype.getBlockSelectors=function(){return _d(this.config?.privacyConfig)},a.prototype.getMaskTextSelectors=function(){return vd(this.config?.privacyConfig,this.currentPageUrl)},a.prototype.getRecordingPlugins=function(t){return i(this,void 0,void 0,function(){var n,i,a,o;return r(this,function(r){switch(r.label){case 0:n=[];try{i=sm({ugcFilterRules:this.config?.interactionConfig?.ugcFilterRules||[],enablePolling:this.config?.enableUrlChangePolling||!1,pollingInterval:this.config?.urlChangePollingInterval,captureDocumentTitle:this.config?.captureDocumentTitle}),n.push(i)}catch(e){this.loggerProvider.warn(`Failed to create URL tracking plugin:`,e)}if(!t?.console?.enabled)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e(()=>import(`./DCPkmLQ7.js`),[],import.meta.url)];case 2:return a=r.sent().getRecordConsolePlugin,n.push(a({level:t.console.levels})),[3,4];case 3:return o=r.sent(),this.loggerProvider.warn(`Failed to load console plugin:`,o),[3,4];case 4:return[2,n.length>0?n:void 0]}})})},a.prototype.getRecordFunction=function(){return i(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(this.recordFunction)return[2,this.recordFunction];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e(()=>import(`./7BTAtpAU.js`),[],import.meta.url)];case 2:return t=r.sent().record,this.recordFunction=t,[2,t];case 3:return n=r.sent(),this.loggerProvider.warn(`Failed to load rrweb-record module:`,n),[2,null];case 4:return[2]}})})},a.prototype.recordEvents=function(e){return e===void 0&&(e=!0),i(this,void 0,void 0,function(){var t;return r(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]:(t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)]);case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},a.prototype.shouldAbandonRecordStart=function(e){return!this.recordingEnabled||e!==this.recordingGeneration},a.prototype._recordEvents=function(e){var t;return e===void 0&&(e=!0),i(this,void 0,void 0,function(){var n,i,a,o,s,l,u,d,f,p,m,h,g,_,v,y,b,x=this;return r(this,function(r){switch(r.label){case 0:return n=this.config,i=this.getShouldRecord(),a=this.identifiers?.sessionId,!i||!a||!n?[2]:(this.stopRecordingEvents(),o=this.recordingGeneration,[4,this.getRecordFunction()]);case 1:return s=r.sent(),!s||this.shouldAbandonRecordStart(o)?[2]:[4,this.initializeNetworkObservers()];case 2:if(r.sent(),this.shouldAbandonRecordStart(o))return[2];l=n.loggingConfig?.network,u=xd(n.serverZone,n.trackServerUrl),d=[Vu,Hu,Uu,u],(t=this.networkObservers)==null||t.start(function(e){d.some(function(t){return e.url.
12startsWith(t)})||x.addCustomRRWebEvent(ad.FETCH_REQUEST,e)},l),f=n.interactionConfig,p=n.loggingConfig,m=f?.enabled?{mouseInteraction:this.eventsManager&&this.clickHandler?.createHook({eventsManager:this.eventsManager,sessionId:a,deviceIdFn:this.getDeviceId.bind(this),mirror:s.mirror,ugcFilterRules:f.ugcFilterRules??[],performanceOptions:n.performanceConfig?.interaction}),scroll:this.scrollHook}:{},h=f?.enabled&&f.ugcFilterRules?f.ugcFilterRules:[],this.loggerProvider.log(`Session Replay capture beginning for ${a}.`),r.label=3;case 3:return r.trys.push([3,5,,6]),g=!!n.crossOriginIframes?.enabled,_=n.crossOriginIframes?.coordinateChildren!==!1,v=g&&cm(),v&&_?(this.crossOriginParentSignalCleanup=um({onStart:function(){x.recordingEnabled&&x._recordEventsInChildMode(s,a,n,m)},onStop:function(){try{x.recordCancelCallback&&x.recordCancelCallback(),x.recordCancelCallback=null}catch(t){var e=t;x.loggerProvider.warn(`Error occurred while stopping child iframe replay capture: ${e.toString()}`)}}}),this.startChildRecordingOnSetup&&(this.startChildRecordingOnSetup=!1,this._recordEventsInChildMode(s,a,n,m)),[2]):(this.startChildRecordingOnSetup=!1,[4,this.getRecordingPlugins(p)]);case 4:return y=r.sent(),this.shouldAbandonRecordStart(o)?[2]:(this.recordCancelCallback=s(c(c({},this.buildRRWebRecordOptions(n,m,function(e){if(x.shouldOptOut()||!x.recordingEnabled){x.loggerProvider.log(x.shouldOptOut()?`Opting session ${a} out of recording due to optOut config.`:`Session Replay capture stopping for ${a}.`),x.stopRecordingEvents(),x.sendEvents();return}e.type===Ld.Meta&&(e.data.href=Ed(e.data.href,h)),x.eventCompressor?x.eventCompressor.enqueueEvent(e,a):x.pendingEmitEvents.push({event:e,sessionId:a})},`Error while capturing replay: `)),{plugins:y,recordCrossOriginIframes:g})),g&&!v&&_&&(this.crossOriginIframeCoordinator||=new lm,this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(ad.DEBUG_INFO),e&&this.addCustomRRWebEvent(ad.METADATA,this.metadata),[3,6]);case 5:return b=r.sent(),this.loggerProvider.warn(`Failed to initialize session replay:`,b),[3,6];case 6:return[2]}})})},a.prototype.buildRRWebRecordOptions=function(e,t,n,r){var i=this,a=e.privacyConfig;return c(c(c(c({emit:n,inlineStylesheet:e.shouldInlineStylesheet,inlineImages:e.inlineImages,hooks:t},yd(a,function(){return i.currentPageUrl})),{applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements}),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(e){var t=e;if(t.message.includes(`insertRule`)&&t.message.includes(`CSSStyleSheet`)||t._external_)throw t;return i.loggerProvider.warn(r,t.toString()),!0}})},a.prototype._recordEventsInChildMode=function(e,t,n,r){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e(c(c({},this.buildRRWebRecordOptions(n,r,function(){},`Error while capturing replay (child iframe): `)),{recordCrossOriginIframes:!0})),this.loggerProvider.log(`Session Replay child iframe capture beginning for session ${t}.`)}catch(e){this.loggerProvider.warn(`Failed to initialize session replay in child iframe mode:`,e)}},a.prototype.getDeviceId=function(){return this.identifiers?.deviceId},a.prototype.getSessionId=function(){return this.identifiers?.sessionId},a.prototype.start=function(){return V(this._start())},a.prototype._start=function(){return i(this,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return this.recordingEnabled=!0,this.startChildRecordingOnSetup=!0,[4,this.recordEvents()];case 1:return e.sent(),[2]}})})},a.prototype.stop=function(){this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,this.stopRecordingEvents(),this.sendEvents()},a.prototype.flush=function(e){return e===void 0&&(e=!1),i(this,void 0,void 0,function(){return r(this,function(t){return[2,this.eventsManager?.flush(e)]})})},a.prototype.shutdown=function(){var e,t;this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,(e=this.urlChangeCleanup)==null||e.call(this),(t=this.crossOriginParentSignalCleanup)==null||t.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},a.prototype.mapSDKType=function(e){return e===`plugin`?`@amplitude/plugin-session-replay-browser`:e===`segment`?`@amplitude/segment-session-replay-plugin`:null},a.prototype.setMetadata=function(e,t,n,r,i,a,o){var s=e?.toString()?St(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:s,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(o),replaySDKVersion:i,standaloneSDKType:`@amplitude/session-replay-browser`,standaloneSDKVersion:a}},a.prototype.initializeNetworkObservers=function(){return i(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(!this.config?.loggingConfig?.network?.enabled||this.networkObservers)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e(()=>import(`./GFFeWM2w.js`),__vite__mapDeps([2,1]),import.meta.url)];case 2:return t=r.sent().NetworkObservers,this.networkObservers=new t,[3,4];case 3:return n=r.sent(),this.loggerProvider.warn(`Failed to import or instantiate NetworkObservers:`,n),[3,4];case 4:return[2]}})})},a}(),fm=function(e){return function(){var t=e.config||kd();return{logger:t.loggerProvider,logLevel:t.logLevel}}},pm=function(){var e=new dm;return{init:W(e.init.bind(e),`init`,fm(e)),evaluateTargetingAndCapture:W(e.evaluateTargetingAndCapture.bind(e),`evaluateTargetingAndRecord`,fm(e)),setSessionId:W(e.setSessionId.bind(e),`setSessionId`,fm(e)),getSessionId:W(e.getSessionId.bind(e),`getSessionId`,fm(e)),getSessionReplayProperties:W(e.getSessionReplayProperties.bind(e),`getSessionReplayProperties`,fm(e)),flush:W(e.flush.bind(e),`flush`,fm(e)),start:W(e.start.bind(e),`start`,fm(e)),stop:W(e.stop.bind(e),`stop`,fm(e)),shutdown:W(e.shutdown.bind(e),`shutdown`,fm(e))}}(),mm=pm.init,hm=pm.setSessionId,gm=pm.getSessionId,_m=pm.getSessionReplayProperties,vm=pm.flush,ym=pm.start,bm=pm.stop,xm=pm.shutdown,Sm=pm.evaluateTargetingAndCapture,Cm;(function(e){e.SET=`$set`,e.SET_ONCE=`$setOnce`,e.ADD=`$add`,e.APPEND=`$append`,e.PREPEND=`$prepend`,e.REMOVE=`$remove`,e.PREINSERT=`$preInsert`,e.POSTINSERT=`$postInsert`,e.UNSET=`$unset`,e.CLEAR_ALL=`$clearAll`})(Cm||={});var wm;(function(e){e.REVENUE_PRODUCT_ID=`$productId`,e.REVENUE_QUANTITY=`$quantity`,e.REVENUE_PRICE=`$price`,e.REVENUE_TYPE=`$revenueType`,e.REVENUE_CURRENCY=`$currency`,e.REVENUE=`$revenue`})(wm||={});var Tm;(function(e){e.IDENTIFY=`$identify`,e.GROUP_IDENTIFY=`$groupidentify`,e.REVENUE=`revenue_amount`})(Tm||={});var Em=[Cm.SET,Cm.SET_ONCE,Cm.ADD,Cm.APPEND,Cm.PREPEND,Cm.POSTINSERT],Dm=function(e){if(e.user_properties){var t={};
12return Object.keys(e.user_properties).forEach(function(n){if(Em.includes(n)){var r=e.user_properties&&e.user_properties[n];t=c(c({},t),r)}}),t}},Om=`1.35.5`,km=`[Amplitude] Session Replay ID`,Am=function(){function e(t){this.name=e.pluginName,this.type=`enrichment`,this.config=null,this.sessionReplay={flush:vm,getSessionId:gm,getSessionReplayProperties:_m,init:mm,setSessionId:hm,start:ym,stop:bm,shutdown:xm,evaluateTargetingAndCapture:Sm},this.options=c({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){return i(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version 1.35.5.`),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})),t=ut(this.config.instanceName).identityStore,n=t.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:this.options.deviceId??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||this.config.remoteConfig?.serverUrl,trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:this.options.privacyConfig?.blockSelector,maskSelector:this.options.privacyConfig?.maskSelector,unmaskSelector:this.options.privacyConfig?.unmaskSelector,defaultMaskLevel:this.options.privacyConfig?.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,inlineImages:this.options.inlineImages,version:{type:`plugin`,version:Om},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:this.options.useWebWorker??this.options.experimental?.useWebWorker,userProperties:n,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval,captureAdoptedStyleSheets:this.options.captureAdoptedStyleSheets,crossOriginIframes:this.options.crossOriginIframes,flushIntervalConfig:this.options.flushIntervalConfig,eagerFullSnapshotSend:this.options.eagerFullSnapshotSend,captureFullSnapshotOnFocus:this.options.captureFullSnapshotOnFocus,maxPersistedEventsSizeBytes:this.options.maxPersistedEventsSizeBytes,maxSingleEventSizeBytes:this.options.maxSingleEventSizeBytes,sendTimeoutMs:this.options.sendTimeoutMs,handleSendEvents:this.options.handleSendEvents,handleFetchConfig:this.options.handleFetchConfig},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),e?.loggerProvider.error(`Session Replay: Failed to initialize due to ${i.message}`),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return i(this,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return(t=this.config)==null||t.loggerProvider.debug(`Analytics session id is changed to ${e}, SR session id is ${String(this.sessionReplay.getSessionId())}.`),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return i(this,void 0,void 0,function(){var n;return r(this,function(r){switch(r.label){case 0:return(t=this.config)==null||t.loggerProvider.debug(`optOut is changed to ${String(e)}, calling ${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=r.sent(),r.label=3;case 3:r.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t;return i(this,void 0,void 0,function(){var n,i,n,a,o,i,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,9,,10]),this.options.customSessionId?(n=this.options.customSessionId(e),n?n===this.sessionReplay.getSessionId()?[3,2]:[4,this.sessionReplay.setSessionId(n).promise]:[3,3]):[3,4];case 1:r.sent(),r.label=2;case 2:i=this.sessionReplay.getSessionReplayProperties(),e.event_properties=c(c({},e.event_properties),i),r.label=3;case 3:return[3,8];case 4:return n=this.config?.sessionId,n&&n!==this.sessionReplay.getSessionId()?[4,this.sessionReplay.setSessionId(n).promise]:[3,6];case 5:r.sent(),r.label=6;case 6:return n&&n===e.session_id?(a=void 0,e.event_type===b.IDENTIFY&&(a=Dm(e)),o=B(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:a,page:o?.location?.href==null?void 0:{url:o.location.href}})]):[3,8];case 7:r.sent(),i=this.sessionReplay.getSessionReplayProperties(),e.event_properties=c(c({},e.event_properties),i),r.label=8;case 8:return e.event_type===b.IDENTIFY&&e.event_properties&&delete e.event_properties[km],[2,Promise.resolve(e)];case 9:return s=r.sent(),(t=this.config)==null||t.loggerProvider.error(`Session Replay: Failed to enrich event due to ${s.message}`),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return i(this,void 0,void 0,function(){return r(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(t){(e=this.config)==null||e.loggerProvider.error(`Session Replay: teardown failed due to ${t.message}`)}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.prototype.start=function(){return i(this,void 0,void 0,function(){return r(this,function(e){switch(e.label){case 0:return[4,this.sessionReplay.start().promise];case 1:return e.sent(),[2]}})})},e.prototype.stop=function(){this.sessionReplay.stop()},e.pluginName=`@amplitude/plugin-session-replay-browser`,e}(),jm=function(e){return new Am(e)},J={IS:`is`,IS_NOT:`is not`,CONTAINS:`contains`,DOES_NOT_CONTAIN:`does not contain`,LESS_THAN:`less`,LESS_THAN_EQUALS:`less or equal`,GREATER_THAN:`greater`,GREATER_THAN_EQUALS:`greater or equal`,VERSION_LESS_THAN:`ver
12sion less`,VERSION_LESS_THAN_EQUALS:`version less or equal`,VERSION_GREATER_THAN:`version greater`,VERSION_GREATER_THAN_EQUALS:`version greater or equal`,SET_IS:`set is`,SET_IS_NOT:`set is not`,SET_CONTAINS:`set contains`,SET_DOES_NOT_CONTAIN:`set does not contain`,SET_CONTAINS_ANY:`set contains any`,SET_DOES_NOT_CONTAIN_ANY:`set does not contain any`,REGEX_MATCH:`regex match`,REGEX_DOES_NOT_MATCH:`regex does not match`},Mm=e=>{let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return Uint8Array.from(t)},Nm=-862048943,Pm=461845907,Fm=15,Im=13,Lm=5,Rm=-430675100,zm=(e,t=0)=>{let n=Mm(e),r=n.length,i=r>>2,a=t;for(let e=0;e<i;e++)a=Bm(Um(n,e<<2),a);let o=i<<2,s=0;switch(r-o){case 3:s^=n[o+2]<<16,s^=n[o+1]<<8,s^=n[o],s=Math.imul(s,Nm),s=Hm(s,Fm),s=Math.imul(s,Pm),a^=s;break;case 2:s^=n[o+1]<<8,s^=n[o],s=Math.imul(s,Nm),s=Hm(s,Fm),s=Math.imul(s,Pm),a^=s;break;case 1:s^=n[o],s=Math.imul(s,Nm),s=Hm(s,Fm),s=Math.imul(s,Pm),a^=s}return a^=r,Vm(a)>>>0},Bm=(e,t)=>{let n=e,r=t;return n=Math.imul(n,Nm),n=Hm(n,Fm),n=Math.imul(n,Pm),r^=n,r=Hm(r,Im),r=Math.imul(r,Lm),r+Rm|0},Vm=e=>{let t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16,t},Hm=(e,t,n=32)=>{t>n&&(t%=n);let r=(e&4294967295<<n-t>>>0)>>>0>>>n-t>>>0;return(e<<t|r)>>>0},Um=(e,t=0)=>Wm(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]),Wm=e=>(e&-16777216)>>>24|(e&16711680)>>>8|(e&65280)<<8|(e&255)<<24,Gm=(e,t)=>{if(t&&t.length!==0){for(let n of t){if(!n||!e||typeof e!=`object`)return;e=e[n]}if(e!=null)return e}},Km=`^(\\d+)\\.(\\d+)(\\.(\\d+)(-(([-\\w]+\\.?)*))?)?$`,qm=class e{constructor(e,t,n,r=void 0){this.major=e,this.minor=t,this.patch=n,this.preRelease=r}static parse(t){if(!t)return;let n=new RegExp(Km).exec(t);if(!n)return;let r=Number(n[1]),i=Number(n[2]);if(isNaN(r)||isNaN(i))return;let a=Number(n[4])||0,o=n[5]||void 0;return new e(r,i,a,o)}compareTo(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0}},Jm=class{evaluate(e,t){let n={},r={context:e,result:n};for(let e of t){let t=this.evaluateFlag(r,e);t&&(n[e.key]=t)}return n}evaluateWithTraces(e,t){let n={},r={},i={context:e,result:n};for(let e of t){let{variant:t,trace:a}=this.evaluateFlagWithTrace(i,e);t&&(n[e.key]=t),r[e.key]=a}return{results:n,traces:r}}evaluateFlag(e,t){let n;for(let r of t.segments)if(n=this.evaluateSegment(e,t,r),n){let e=Object.assign(Object.assign(Object.assign({},t.metadata),r.metadata),n.metadata);n=Object.assign(Object.assign({},n),{metadata:e});break}return n}evaluateFlagWithTrace(e,t){let n=[],r,i,a;for(let o of t.segments){if(!o.conditions){let s=this.bucket(e,o),c=s!==void 0;n.push({segmentMetadata:o.metadata,conditionsPassed:!0,bucketed:c,bucketVariant:s,conditionResult:void 0,matched:c}),!r&&s!==void 0&&(r=t.variants[s],i=o,a=o.metadata?.segmentName);continue}let s=[],c=!1;for(let t of o.conditions){let n=!0,r=[];for(let i of t){let t=Gm(e,i.selector),a=this.matchCondition(e,i);if(r.push({propValue:t,condition:i,matched:a}),!a){n=!1;break}}if(s.push(r),n){c=!0;break}}let l=!1,u;c&&(u=this.bucket(e,o),l=u!==void 0),n.push({segmentMetadata:o.metadata,conditionsPassed:c,bucketed:l,bucketVariant:u,conditionResult:s,matched:c&&l}),c&&u!==void 0&&!r&&(r=t.variants[u],i=o,a=o.metadata?.segmentName)}if(r&&i){let e=Object.assign(Object.assign(Object.assign({},t.metadata),i.metadata),r.metadata);r=Object.assign(Object.assign({},r),{metadata:e})}let o={flagKey:t.key,matched:r!==void 0,matchedSegment:a,steps:n};return{variant:r,trace:o}}evaluateSegment(e,t,n){if(!n.conditions){let r=this.bucket(e,n);return r===void 0?void 0:t.variants[r]}if(this.evaluateConditions(e,n.conditions)){let r=this.bucket(e,n);return r===void 0?void 0:t.variants[r]}}evaluateConditions(e,t){for(let n of t){let t=!0;for(let r of n)if(t=this.matchCondition(e,r),!t)break;
12if(t)return!0}return!1}matchCondition(e,t){let n=Gm(e,t.selector);if(n==null)return this.matchNull(t.op,t.values);{let e=this.coerceStringArray(n);if(this.isSetOperator(t.op))return e?this.matchSet(e,t.op,t.values):!1;if(e)return this.matchStringsNonSet(e,t.op,t.values);{let e=this.coerceString(n);return e!==void 0&&this.matchString(e,t.op,t.values)}}}getHash(e){return zm(e)}bucket(e,t){if(!t.bucket)return t.variant;let n=this.coerceString(Gm(e,t.bucket.selector));if(!n||n.length===0)return t.variant;let r=`${t.bucket.salt}/${n}`,i=this.getHash(r),a=i%100,o=Math.floor(i/100);for(let e of t.bucket.allocations){let t=e.range[0],n=e.range[1];if(a>=t&&a<n)for(let t of e.distributions){let e=t.range[0],n=t.range[1];if(o>=e&&o<n)return t.variant}}return t.variant}matchNull(e,t){let n=this.containsNone(t);switch(e){case J.IS:case J.CONTAINS:case J.LESS_THAN:case J.LESS_THAN_EQUALS:case J.GREATER_THAN:case J.GREATER_THAN_EQUALS:case J.VERSION_LESS_THAN:case J.VERSION_LESS_THAN_EQUALS:case J.VERSION_GREATER_THAN:case J.VERSION_GREATER_THAN_EQUALS:case J.SET_IS:case J.SET_CONTAINS:case J.SET_CONTAINS_ANY:return n;case J.IS_NOT:case J.DOES_NOT_CONTAIN:case J.SET_DOES_NOT_CONTAIN:case J.SET_DOES_NOT_CONTAIN_ANY:return!n;default:return!1}}matchSet(e,t,n){switch(t){case J.SET_IS:return this.setEquals(e,n);case J.SET_IS_NOT:return!this.setEquals(e,n);case J.SET_CONTAINS:return this.matchesSetContainsAll(e,n);case J.SET_DOES_NOT_CONTAIN:return!this.matchesSetContainsAll(e,n);case J.SET_CONTAINS_ANY:return this.matchesSetContainsAny(e,n);case J.SET_DOES_NOT_CONTAIN_ANY:return!this.matchesSetContainsAny(e,n);default:return!1}}matchString(e,t,n){switch(t){case J.IS:return this.matchesIs(e,n);case J.IS_NOT:return!this.matchesIs(e,n);case J.CONTAINS:return this.matchesContains(e,n);case J.DOES_NOT_CONTAIN:return!this.matchesContains(e,n);case J.LESS_THAN:case J.LESS_THAN_EQUALS:case J.GREATER_THAN:case J.GREATER_THAN_EQUALS:return this.matchesComparable(e,t,n,e=>this.parseNumber(e),(e,t,n)=>this.comparator(e,t,n));case J.VERSION_LESS_THAN:case J.VERSION_LESS_THAN_EQUALS:case J.VERSION_GREATER_THAN:case J.VERSION_GREATER_THAN_EQUALS:return this.matchesComparable(e,t,n,e=>qm.parse(e),(e,t,n)=>this.versionComparator(e,t,n));case J.REGEX_MATCH:return this.matchesRegex(e,n);case J.REGEX_DOES_NOT_MATCH:return!this.matchesRegex(e,n);default:return!1}}matchStringsNonSet(e,t,n){return e.some(e=>this.matchString(e,t,n))}matchesIs(e,t){if(this.containsBooleans(t)){let n=e.toLowerCase();if(n===`true`||n===`false`)return t.some(e=>e.toLowerCase()===n)}return t.some(t=>e===t)}matchesContains(e,t){for(let n of t)if(e.toLowerCase().includes(n.toLowerCase()))return!0;return!1}matchesComparable(e,t,n,r,i){let a=r(e),o=n.map(e=>r(e)).filter(e=>e!==void 0);return a===void 0||o.length===0?n.some(n=>this.comparator(e,t,n)):o.some(e=>i(a,t,e))}comparator(e,t,n){switch(t){case J.LESS_THAN:case J.VERSION_LESS_THAN:return e<n;case J.LESS_THAN_EQUALS:case J.VERSION_LESS_THAN_EQUALS:return e<=n;case J.GREATER_THAN:case J.VERSION_GREATER_THAN:return e>n;case J.GREATER_THAN_EQUALS:case J.VERSION_GREATER_THAN_EQUALS:return e>=n;default:return!1}}versionComparator(e,t,n){let r=e.compareTo(n);switch(t){case J.LESS_THAN:case J.VERSION_LESS_THAN:return r<0;case J.LESS_THAN_EQUALS:case J.VERSION_LESS_THAN_EQUALS:return r<=0;case J.GREATER_THAN:case J.VERSION_GREATER_THAN:return r>0;case J.GREATER_THAN_EQUALS:case J.VERSION_GREATER_THAN_EQUALS:return r>=0;default:return!1}}matchesRegex(e,t){return t.some(t=>!!new RegExp(t).exec(e))}containsNone(e){return e.some(e=>e===`(none)`)}containsBooleans(e){return e.some(e=>{switch(e.toLowerCase()){case`true`:case`false`:return!0;default:return!1}})}parseNumber(e){return Number(e)??void 0}coerceString(e){if(e!=null)return typeof e==`object`?JSON.stringify(e):String(e)}coerceStringArray(e){if(Array.isArray(e))return e.map(e=>this.coerceString(e)).filter(Boolean);let t=String(e);if(t.startsWith(`[`))try{let e=JSON.parse(t);return Array.isArray(e)?e.map(e=>this.coerceString(e)).filter(Boolean):void 0}catch{return}}isSetOperator(e){switch(e){case J.SET_IS:case J.SET_IS_NOT:case J.SET_CONTAINS:case J.SET_DOES_NOT_CONTAIN:case J.SET_CONTAINS_ANY:case J.SET_DOES_NOT_CONTAIN_ANY:return!0;default:return!1}}setEquals(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...r].every(e=>n.has(e))}matchesSetContainsAll(e,t){if(e.length<t.length)return!1;for(let n of t)if(!this.matchesIs(n,e))return!1;return!0}matchesSetContainsAny(e,t){for(let n of t)if(this.matchesIs(n,e))return!0;return!1}},Ym=(e,t)=>
12{let n=Object.assign({},e),r=[],i=t||Object.keys(n);for(let e of i){let t=Xm(e,n);t&&r.push(...t)}return r},Xm=(e,t,n=[])=>{let r=t[e];if(!r)return;if(!r.dependencies||r.dependencies.length===0)return delete t[r.key],[r];n.push(r.key);let i=[];for(let e of r.dependencies){if(n.some(t=>t===e))throw Error(`Detected a cycle between flags ${n.join(`, `)}`);let r=Xm(e,t,n);r&&i.push(...r)}return i.push(r),n.pop(),delete t[r.key],i};function Zm(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var Qm=`3.7.8`,$m=Qm,eh=typeof Buffer==`function`,th=typeof TextDecoder==`function`?new TextDecoder:void 0,nh=typeof TextEncoder==`function`?new TextEncoder:void 0,rh=Array.prototype.slice.call(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`),ih=(e=>{let t={};return e.forEach((e,n)=>t[e]=n),t})(rh),ah=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Y=String.fromCharCode.bind(String),oh=typeof Uint8Array.from==`function`?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),sh=e=>e.replace(/=/g,``).replace(/[+\/]/g,e=>e==`+`?`-`:`_`),ch=e=>e.replace(/[^A-Za-z0-9\+\/]/g,``),lh=e=>{let t,n,r,i,a=``,o=e.length%3;for(let o=0;o<e.length;){if((n=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)throw TypeError(`invalid character found`);t=n<<16|r<<8|i,a+=rh[t>>18&63]+rh[t>>12&63]+rh[t>>6&63]+rh[t&63]}return o?a.slice(0,o-3)+`===`.substring(o):a},uh=typeof btoa==`function`?e=>btoa(e):eh?e=>Buffer.from(e,`binary`).toString(`base64`):lh,dh=eh?e=>Buffer.from(e).toString(`base64`):e=>{let t=4096,n=[];for(let r=0,i=e.length;r<i;r+=t)n.push(Y.apply(null,e.subarray(r,r+t)));return uh(n.join(``))},fh=(e,t=!1)=>t?sh(dh(e)):dh(e),ph=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Y(192|t>>>6)+Y(128|t&63):Y(224|t>>>12&15)+Y(128|t>>>6&63)+Y(128|t&63)}var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Y(240|t>>>18&7)+Y(128|t>>>12&63)+Y(128|t>>>6&63)+Y(128|t&63)},mh=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,hh=e=>e.replace(mh,ph),gh=eh?e=>Buffer.from(e,`utf8`).toString(`base64`):nh?e=>dh(nh.encode(e)):e=>uh(hh(e)),_h=(e,t=!1)=>t?sh(gh(e)):gh(e),vh=e=>_h(e,!0),yh=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,bh=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return Y((t>>>10)+55296)+Y((t&1023)+56320);case 3:return Y((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Y((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},xh=e=>e.replace(yh,bh),Sh=e=>{if(e=e.replace(/\s+/g,``),!ah.test(e))throw TypeError(`malformed base64.`);e+=`==`.slice(2-(e.length&3));let t,n,r,i=[];for(let a=0;a<e.length;)t=ih[e.charAt(a++)]<<18|ih[e.charAt(a++)]<<12|(n=ih[e.charAt(a++)])<<6|(r=ih[e.charAt(a++)]),n===64?i.push(Y(t>>16&255)):r===64?i.push(Y(t>>16&255,t>>8&255)):i.push(Y(t>>16&255,t>>8&255,t&255));return i.join(``)},Ch=typeof atob==`function`?e=>atob(ch(e)):eh?e=>Buffer.from(e,`base64`).toString(`binary`):Sh,wh=eh?e=>oh(Buffer.from(e,`base64`)):e=>oh(Ch(e).split(``).map(e=>e.charCodeAt(0))),Th=e=>wh(Dh(e)),Eh=eh?e=>Buffer.from(e,`base64`).toString(`utf8`):th?e=>th.decode(wh(e)):e=>xh(Ch(e)),Dh=e=>ch(e.replace(/[-_]/g,e=>e==`-`?`+`:`/`)),Oh=e=>Eh(Dh(e)),kh=e=>{if(typeof e!=`string`)return!1;let t=e.replace(/\s+/g,``).replace(/={0,2}$/,``);return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Ah=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),jh=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,Ah(t));e(`fromBase64`,function(){return Oh(this)}),e(`toBase64`,function(e){return _h(this,e)}),e(`toBase64URI`,function(){return _h(this,!0)}),e(`toBase64URL`,function(){return _h(this,!0)}),e(`toUint8Array`,function(){return Th(this)})},Mh=function(){let e=(e,t)=>
12Object.defineProperty(Uint8Array.prototype,e,Ah(t));e(`toBase64`,function(e){return fh(this,e)}),e(`toBase64URI`,function(){return fh(this,!0)}),e(`toBase64URL`,function(){return fh(this,!0)})},Nh={version:Qm,VERSION:$m,atob:Ch,atobPolyfill:Sh,btoa:uh,btoaPolyfill:lh,fromBase64:Oh,toBase64:_h,encode:_h,encodeURI:vh,encodeURL:vh,utob:hh,btou:xh,decode:Oh,isValid:kh,fromUint8Array:fh,toUint8Array:Th,extendString:jh,extendUint8Array:Mh,extendBuiltins:()=>{jh(),Mh()}},Ph=class e extends Error{constructor(t,n){super(n),this.statusCode=t,Object.setPrototypeOf(this,e.prototype)}},Fh=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},Ih=class{constructor(e,t,n){this.deploymentKey=e,this.serverUrl=t,this.httpClient=n}getVariants(e,t){return Zm(this,void 0,void 0,function*(){let n=Nh.encodeURL(JSON.stringify(e)),r={Authorization:`Api-Key ${this.deploymentKey}`,"X-Amp-Exp-User":n};t?.flagKeys&&(r[`X-Amp-Exp-Flag-Keys`]=Nh.encodeURL(JSON.stringify(t.flagKeys))),t?.trackingOption&&(r[`X-Amp-Exp-Track`]=t.trackingOption),t?.exposureTrackingOption&&(r[`X-Amp-Exp-Exposure-Track`]=t.exposureTrackingOption);let i=new URL(`${this.serverUrl}/sdk/v2/vardata?v=0`);t?.evaluationMode&&i.searchParams.append(`eval_mode`,t?.evaluationMode),t?.deliveryMethod&&i.searchParams.append(`delivery_method`,t?.deliveryMethod);let a=yield this.httpClient.request({requestUrl:i.toString(),method:`GET`,headers:r,timeoutMillis:t?.timeoutMillis});if(a.status!=200)throw new Ph(a.status,`Fetch error response: status=${a.status}`);return JSON.parse(a.body)})}},Lh=class{constructor(e,t,n){this.deploymentKey=e,this.serverUrl=t,this.httpClient=n}getFlags(e){return Zm(this,void 0,void 0,function*(){let t={Authorization:`Api-Key ${this.deploymentKey}`};e?.libraryName&&e?.libraryVersion&&(t[`X-Amp-Exp-Library`]=`${e.libraryName}/${e.libraryVersion}`),e?.user&&(t[`X-Amp-Exp-User`]=Nh.encodeURL(JSON.stringify(e.user)));let n=yield this.httpClient.request({requestUrl:`${this.serverUrl}/sdk/v2/flags`+(e?.deliveryMethod?`?delivery_method=${e.deliveryMethod}`:``),method:`GET`,headers:t,timeoutMillis:e?.timeoutMillis});if(n.status!=200)throw Error(`Flags error response: status=${n.status}`);return JSON.parse(n.body).reduce((e,t)=>(e[t.key]=t,e),{})})}},X=()=>{if(typeof globalThis<`u`&&globalThis!==null)return globalThis;if(typeof window<`u`&&window!==null)return window;if(typeof self<`u`&&self!==null)return self;if(typeof global<`u`&&global!==null)return global};X();var Rh=()=>{let e=X();if(e)try{let t=`EXP_test`;return e.localStorage.setItem(t,t),e.localStorage.removeItem(t),!0}catch{return!1}return!1},zh=()=>X()?.localStorage,Bh=()=>X()?.sessionStorage,Vh=()=>X()?.document,Hh=()=>{let e=X();return e?.fetch?e.fetch.bind(e):void 0},Uh=()=>{let e=X();return e?.setTimeout?e.setTimeout.bind(e):void 0},Wh=()=>{let e=X();return e?.clearTimeout?e.clearTimeout.bind(e):void 0},Gh=()=>{let e=X();return e?.setInterval?e.setInterval.bind(e):void 0},Kh=()=>{let e=X();return e?.clearInterval?e.clearInterval.bind(e):void 0},qh=class{constructor(e,t){this.poller=void 0,this.action=e,this.ms=t}start(){if(this.poller)return;let e=Gh();e&&(this.poller=e(()=>{this.action()},this.ms),this.action())}stop(){if(!this.poller)return;let e=Kh();e&&e(this.poller),this.poller=void 0}},Jh=h(((e,t)=>{(function(n,r){var i=`0.7.33`,a=``,o=`function`,s=`undefined`,c=`object`,l=`string`,u=`major`,d=`model`,f=`name`,p=`type`,m=`vendor`,h=`version`,g=`architecture`,_=`console`,v=`mobile`,y=`tablet`,b=`smarttv`,x=`wearable`,S=`embedded`,C=`Amazon`,w=`Apple`,T=`ASUS`,E=`BlackBerry`,D=`Browser`,O=`Chrome`,k=`Edge`,A=`Firefox`,j=`Google`,M=`Huawei`,N=`LG`,ee=`Microsoft`,P=`Motorola`,F=`Opera`,te=`Samsung`,ne=`Sharp`,re=`Sony`,ie=`Xiaomi`,I=`Zebra`,ae=`Facebook`,oe=function(e,t){var n={};for(var r in e)n[r]=t[r]&&t[r].length%2==0?t[r].concat(e[r]):e[r];return n},se=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},L=function(e,t){return typeof e==l&&ce(t).indexOf(ce(e))!==-1},ce=function(e){return e.toLowerCase()},le=function(e){return typeof e==l?e.replace(/[^\d\.]/g,a).split(`.`)[0]:r},ue=function(e,t){if(typeof e==l)return e=e.replace(/^\s\s*/,a),typeof t===s?e:e.substring(0,350)},de=function(e,t){for(var n=0,i,a,s,l,u,d;n<t.length&&!u;){var f=t[n],p=t[n+1];for(i=a=0;i<f.length&&!u;)if(u=f[i++].exec(e),u)for(s=0;s<p.length;s++)d=u[++a],l=p[s],typeof l==c&&l.length>0?l.length===2?typeof l[1]==o?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:l.length===3?typeof l[1]===o&&!(l[1].exec&&l[1].test)?this[l[0]]=d?l[1].call(this,d,l[2]):r:this[l[0]]=d?d.replace(l[1],l[2]):r:l.length===4&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):r):this[l]=d||r;n+=2}},fe=function(e,t){for(var n in t)if(typeof t[n]==c&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(L(t[n][i],e))return n===`?`?r:n}else if(L(t[n],e))return n===`?`?r:n;return e},R={"1.0":`/8`,1.2:`/1`,1.3:`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},pe={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,8.1:`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},me={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[f,`Chrome`]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[f,`Edge`]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[f,h],[/opios[\/ ]+([\w\.]+)/i],[h,[f,F+` Mini`]],[/\bopr\/([\w\.]+)/i],[h,[f,F]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[f,h],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[f,`UC`+D]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[h,[f,`WeChat(Win) Desktop`]],[/micromessenger\/([\w\.]+)/i],[h,[f,`WeChat`]],[/konqueror\/([\w\.]+)/i],[h,[f,`Konqueror`]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[f,`IE`]],[/yabrowser\/([\w\.]+)/i],[h,[f,`Yandex`]],[/(avast|avg)\/([\w\.]+)/i],[[f,/(.+)/,`$1 Secure `+D],h],[/\bfocus\/([\w\.]+)/i],[h,[f,A+` Focus`]],[/\bopt\/([\w\.]+)/i],[h,[f,F+` Touch`]],[/coc_coc\w+\/([\w\.]+)/i],[h,[f,`Coc Coc`]],[/dolfin\/([\w\.]+)/i],[h,[f,`Dolphin`]],[/coast\/([\w\.]+)/i],[h,[f,F+` Coast`]],[/miuibrowser\/([\w\.]+)/i],[h,[f,`MIUI `+D]],[/fxios\/([-\w\.]+)/i],[h,[f,A]],[/\bqihu|(qi?ho?o?|360)browser/i],[[f,`360 `+D]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[f,/(.+)/,`$1 `+D],h],[/(comodo_dragon)\/([\w\.]+)/i],[[f,/_/g,` `],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[f,h],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[f],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[f,ae],h],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[f,h],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[f,`GSA`]],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[f,O+` Headless`]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[f,O+` WebView`],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[f,`Android `+D]],[/(chrome|omniweb|arora|[t
vendor: 4,759 bytes, line 12
12izenoka]{5} ?browser)\/v?([\w\.]+)/i],[f,h],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[h,[f,`Mobile Safari`]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[h,f],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[f,[h,fe,R]],[/(webkit|khtml)\/([\w\.]+)/i],[f,h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[f,`Netscape`],h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[f,A+` Reality`]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[f,h],[/(cobalt)\/([\w\.]+)/i],[f,[h,/master.|lts./,``]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[g,`amd64`]],[/(ia32(?=;))/i],[[g,ce]],[/((?:i[346]|x)86)[;\)]/i],[[g,`ia32`]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[g,`arm64`]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[g,`armhf`]],[/windows (ce|mobile); ppc;/i],[[g,`arm`]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[g,/ower/,a,ce]],[/(sun4\w)[;\)]/i],[[g,`sparc`]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[g,ce]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[m,te],[p,y]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[d,[m,te],[p,v]],[/((ipod|iphone)\d+,\d+)/i],[d,[m,w],[p,v]],[/(ipad\d+,\d+)/i],[d,[m,w],[p,y]],[/\((ip(?:hone|od)[\w ]*);/i],[d,[m,w],[p,v]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[m,w],[p,y]],[/(macintosh);/i],[d,[m,w]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[m,M],[p,y]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[m,M],[p,v]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[d,/_/g,` `],[m,ie],[p,v]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g,` `],[m,ie],[p,y]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[m,`OPPO`],[p,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[m,`Vivo`],[p,v]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[d,[m,`Realme`],[p,v]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[m,P],[p,v]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[m,P],[p,y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[m,N],[p,y]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[m,N],[p,v]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[m,`Lenovo`],[p,y]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g,` `],[m,`Nokia`],[p,v]],[/(pixel c)\b/i],[d,[m,j],[p,y]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[m,j],[p,v]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[m,re],[p,v]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,`Xperia Tablet`],[m,re],[p,y]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[m,`OnePlus`],[p,v]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[m,C],[p,y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,`Fire Phone $1`],[m,C],[p,v]],[/(playbook);[-\w\),; ]+(rim)/i],[d,m,[p,y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[m,E],[p,v]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[m,T],[p,y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[m,T],[p,v]],[/(nexus 9)/i],[d,[m,`HTC`],[p,y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i],[m,[d,/_/g,` `],[p,v]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[m,`Acer`],[p,y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[m,`Meizu`],[p,v]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[m,ne],[p,v]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asu
vendor: 5,264 bytes, line 12
12s)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[m,d,[p,v]],[/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[m,d,[p,y]],[/(surface duo)/i],[d,[m,ee],[p,y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[m,`Fairphone`],[p,v]],[/(u304aa)/i],[d,[m,`AT&T`],[p,v]],[/\bsie-(\w*)/i],[d,[m,`Siemens`],[p,v]],[/\b(rct\w+) b/i],[d,[m,`RCA`],[p,y]],[/\b(venue[\d ]{2,7}) b/i],[d,[m,`Dell`],[p,y]],[/\b(q(?:mv|ta)\w+) b/i],[d,[m,`Verizon`],[p,y]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[m,`Barnes & Noble`],[p,y]],[/\b(tm\d{3}\w+) b/i],[d,[m,`NuVision`],[p,y]],[/\b(k88) b/i],[d,[m,`ZTE`],[p,y]],[/\b(nx\d{3}j) b/i],[d,[m,`ZTE`],[p,v]],[/\b(gen\d{3}) b.+49h/i],[d,[m,`Swiss`],[p,v]],[/\b(zur\d{3}) b/i],[d,[m,`Swiss`],[p,y]],[/\b((zeki)?tb.*\b) b/i],[d,[m,`Zeki`],[p,y]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[m,`Dragon Touch`],d,[p,y]],[/\b(ns-?\w{0,9}) b/i],[d,[m,`Insignia`],[p,y]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[m,`NextBook`],[p,y]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[m,`Voice`],d,[p,v]],[/\b(lvtel\-)?(v1[12]) b/i],[[m,`LvTel`],d,[p,v]],[/\b(ph-1) /i],[d,[m,`Essential`],[p,v]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[m,`Envizen`],[p,y]],[/\b(trio[-\w\. ]+) b/i],[d,[m,`MachSpeed`],[p,y]],[/\btu_(1491) b/i],[d,[m,`Rotor`],[p,y]],[/(shield[\w ]+) b/i],[d,[m,`Nvidia`],[p,y]],[/(sprint) (\w+)/i],[m,d,[p,v]],[/(kin\.[onetw]{3})/i],[[d,/\./g,` `],[m,ee],[p,v]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[m,I],[p,y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[m,I],[p,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[m,d,[p,_]],[/droid.+; (shield) bui/i],[d,[m,`Nvidia`],[p,_]],[/(playstation [345portablevi]+)/i],[d,[m,re],[p,_]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[m,ee],[p,_]],[/smart-tv.+(samsung)/i],[m,[p,b]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,`SmartTV`],[m,te],[p,b]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[m,N],[p,b]],[/(apple) ?tv/i],[m,[d,w+` TV`],[p,b]],[/crkey/i],[[d,O+`cast`],[m,j],[p,b]],[/droid.+aft(\w)( bui|\))/i],[d,[m,C],[p,b]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[m,ne],[p,b]],[/(bravia[\w ]+)( bui|\))/i],[d,[m,re],[p,b]],[/(mitv-\w{5}) bui/i],[d,[m,ie],[p,b]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i],[[m,ue],[d,ue],[p,b]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[p,b]],[/((pebble))app/i],[m,d,[p,x]],[/droid.+; (glass) \d/i],[d,[m,j],[p,x]],[/droid.+; (wt63?0{2,3})\)/i],[d,[m,I],[p,x]],[/(quest( 2)?)/i],[d,[m,ae],[p,x]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[m,[p,S]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[d,[p,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[p,y]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[p,y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[p,v]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[m,`Generic`]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[f,k+`HTML`]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[f,`Blink`]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[f,h],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,f]],os:[[/microsoft (windows) (vista|xp)/i],[f,h],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[f,[h,fe,pe]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,`Windows`],[h,fe,pe]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,`.`],[f,`iOS`]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[f,`Mac OS`],[h,/_/g,`.`]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,f],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[f,h],[/\(bb(10);/i],[h,[f,E]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[h,[f,`Symbian`]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[f,A+` OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[f,`webOS`]],[/crkey\/([\d\.]+)/i],[h,[f,O+`cast`]],[/(cros) [\w]+ ([\w\.]+\w)/i],[[f,`Chromium OS`],h],[/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[f,h],[/(sunos) ?([\w\.\d]*)/i],[[f,`Solaris`],h
12],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[f,h]]},he=function(e,t){if(typeof e==c&&(t=e,e=r),!(this instanceof he))return new he(e,t).getResult();var i=e||(typeof n!==s&&n.navigator&&n.navigator.userAgent?n.navigator.userAgent:a),o=t?oe(me,t):me;return this.getBrowser=function(){var e={};return e[f]=r,e[h]=r,de.call(e,i,o.browser),e.major=le(e.version),e},this.getCPU=function(){var e={};return e[g]=r,de.call(e,i,o.cpu),e},this.getDevice=function(){var e={};return e[m]=r,e[d]=r,e[p]=r,de.call(e,i,o.device),e},this.getEngine=function(){var e={};return e[f]=r,e[h]=r,de.call(e,i,o.engine),e},this.getOS=function(){var e={};return e[f]=r,e[h]=r,de.call(e,i,o.os),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return i},this.setUA=function(e){return i=typeof e==l&&e.length>350?ue(e,350):e,this},this.setUA(i),this};he.VERSION=i,he.BROWSER=se([f,h,u]),he.CPU=se([g]),he.DEVICE=se([d,m,p,_,v,b,y,x,S]),he.ENGINE=he.OS=se([f,h]),typeof e===s?typeof define===o&&define.amd?define(function(){return he}):typeof n!==s&&(n.UAParser=he):(typeof t!==s&&t.exports&&(e=t.exports=he),e.UAParser=he);var ge=typeof n!==s&&(n.jQuery||n.Zepto);if(ge&&!ge.ua){var _e=new he;ge.ua=_e.getResult(),ge.ua.get=function(){return _e.getUA()},ge.ua.set=function(e){_e.setUA(e);var t=_e.getResult();for(var n in t)ge.ua[n]=t[n]}}})(typeof window==`object`?window:e)}))();function Z(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var Yh=(e,t=!1)=>{let n=Qh(e,t),r,i=Vh();if(!i)return;let a=i.cookie.split(`; `);for(let e of a){let[t,i]=e.split(`=`,2);t===n&&(r=decodeURIComponent(i))}if(r)try{if(t){let e=atob(r);return JSON.parse(decodeURIComponent(e))}let e=r.split(`.`),n;return e.length>=2&&e[1]&&(n=atob(e[1])),{deviceId:e[0],userId:n}}catch{return}},Xh=e=>{let t=Qh(e,!0);try{let e=zh();if(!e)return;let n=e.getItem(t);if(!n)return;let r=JSON.parse(n);return typeof r==`object`?r:void 0}catch{return}},Zh=e=>{let t=Qh(e,!0);try{let e=Bh();if(!e)return;let n=e.getItem(t);if(!n)return;let r=JSON.parse(n);return typeof r==`object`?r:void 0}catch{return}},Qh=(e,t)=>{if(t)return e?.length<10?void 0:`AMP_${e.substring(0,10)}`;if(!(e?.length<6))return`amp_${e.substring(0,6)}`},$h=class{constructor(e,t,n){this.type=`integration`,this.apiKey=e,this.identityStore=t.identityStore,this.eventBridge=t.eventBridge,this.contextProvider=t.applicationContextProvider,this.timeoutMillis=n,this.loadPersistedState(),n<=0&&(this.setup=void 0)}setup(e,t){return Z(this,void 0,void 0,function*(){return e?.automaticFetchOnAmplitudeIdentityChange&&this.identityStore.addIdentityListener(()=>{t?.fetch()}),this.waitForConnectorIdentity(this.timeoutMillis)})}getUser(){let e=this.identityStore.getIdentity();return{user_id:e.userId,device_id:e.deviceId,user_properties:e.userProperties,version:this.contextProvider.versionName}}track(e){return this.eventBridge.receiver?(this.eventBridge.logEvent({eventType:e.eventType,eventProperties:e.eventProperties}),!0):!1}loadPersistedState(){if(!this.apiKey||this.apiKey.startsWith(`client-`))return!1;let e=Yh(this.apiKey,!0);return e||(e=Yh(this.apiKey,!1),e)||(e=Xh(this.apiKey),e)||(e=Zh(this.apiKey),e)?(this.commitIdentityToConnector(e),!0):!1}commitIdentityToConnector(e){let t=this.identityStore.editIdentity();t.setDeviceId(e.deviceId),e.userId&&t.setUserId(e.userId),t.commit()}waitForConnectorIdentity(e){return Z(this,void 0,void 0,function*(){let t=this.identityStore.getIdentity();if(!t.userId&&!t.deviceId)return Promise.race([new Promise(e=>{let t=()=>{e(),this.identityStore.removeIdentityListener(t)};this.identityStore.addIdentityListener(t)}),new Promise((t,n)=>{let r=Uh();if(!r){n(`Timed out waiting for Amplitude Analytics SDK to initialize.`);return}r(n,e,`Timed out waiting for Amplitude Analytics SDK to initialize.`)})])})}};function eg(e,t){return t||={},new Promise(function(n,r){var i=new XMLHttpRequest,a=[],o=[],s={},c=function(){return{ok:(i.status/100|0)==2,statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(JSON.parse(i.responseText))},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:c,headers:{keys:function(){return a},entries:function(){return o},get:function(e){return s[e.toLowerCase()]},has:function(e){return e.toLowerCase()in s}}}};for(var l in i.open(t.method||`get`,e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,n){a.push(t=t.toLowerCase()),o.push([t,n]),s[t]=s[t]?s[t]+`,`+n:n}),n(c())},i.onerror=r,i.withCredentials=t.credentials==`include`,t.headers)i.setRequestHeader(l,t.headers[l]);i.send(t.body||null)})}var tg=Hh()||eg,ng=(e,t)=>
12t==null||t<=0?e:new Promise(function(n,r){let i=Uh();i&&i(function(){r(new Fh(`Request timeout after ${t} milliseconds`))},t),e.then(n,r)}),rg=(e,t,n,r,i)=>ng(Z(void 0,void 0,void 0,function*(){let i=yield tg(e,{method:t,headers:n,body:r});return{status:i.status,body:yield i.text()}}),i),ig=class{constructor(e){this.client=e}request(e){return Z(this,void 0,void 0,function*(){return yield this.client.request(e.requestUrl,e.method,e.headers,null,e.timeoutMillis)})}},ag={request:rg},og;(function(e){e[e.Disable=0]=`Disable`,e[e.Error=1]=`Error`,e[e.Warn=2]=`Warn`,e[e.Info=3]=`Info`,e[e.Debug=4]=`Debug`,e[e.Verbose=5]=`Verbose`})(og||={});var sg;(function(e){e.LocalStorage=`localStorage`,e.InitialVariants=`initialVariants`})(sg||={});var Q;(function(e){e.LocalStorage=`storage`,e.InitialVariants=`initial`,e.SecondaryLocalStorage=`secondary-storage`,e.SecondaryInitialVariants=`secondary-initial`,e.FallbackInline=`fallback-inline`,e.FallbackConfig=`fallback-config`,e.LocalEvaluation=`local-evaluation`})(Q||={});var cg=e=>!e||e===Q.FallbackInline||e===Q.FallbackConfig||e===Q.SecondaryInitialVariants,lg={debug:!1,logLevel:og.Error,loggerProvider:null,instanceName:`$default_instance`,fallbackVariant:{},initialVariants:{},initialFlags:void 0,source:sg.LocalStorage,serverUrl:`https://api.lab.amplitude.com`,flagsServerUrl:`https://flag.lab.amplitude.com`,serverZone:`US`,fetchTimeoutMillis:1e4,retryFetchOnFailure:!0,throwOnError:!1,automaticExposureTracking:!0,pollOnStart:!0,flagConfigPollingIntervalMillis:3e5,fetchOnStart:!0,automaticFetchOnAmplitudeIdentityChange:!1,userProvider:null,analyticsProvider:null,exposureTrackingProvider:null,httpClient:ag},ug=`1.23.1`,dg=512,fg=class{constructor(e,t){this.isReady=new Promise(e=>{this.resolve=e}),this.config=e,this.client=t;let n=e.instanceName??lg.instanceName;this.queue=new mg(n,dg,e.internalPersistenceAllowed),this.cache=new pg(n,e.internalPersistenceAllowed)}ready(){return this.integration?this.isReady:Promise.resolve()}setIntegration(e){this.integration&&this.integration.teardown&&this.integration.teardown(),this.integration=e,e.setup?this.integration.setup(this.config,this.client).then(()=>{this.queue.setTracker(this.integration.track.bind(e)),this.resolve()},()=>{this.queue.setTracker(this.integration.track.bind(e)),this.resolve()}):(this.queue.setTracker(this.integration.track.bind(e)),this.resolve())}getUser(){return this.integration?this.integration.getUser():{}}track(e,t){if(this.cache.shouldTrack(e,t)){let t=this.getExposureEvent(e);this.queue.push(t)}}getExposureEvent(e){let t={eventType:`$exposure`,eventProperties:e};return e.metadata?.exposureEvent?t={eventType:e.metadata?.exposureEvent,eventProperties:e}:e.metadata?.deliveryMethod===`web`&&(t={eventType:`$impression`,eventProperties:e}),t}},pg=class{constructor(e,t){this.persistenceAllowed=t,this.clearStoredOnReopen=!1,this.hasGatedEntries=!1,this.inMemoryCache={},this.identity={},this.storageKey=`EXP_sent_v3_${e}`}isGated(){return this.persistenceAllowed!==void 0&&!this.persistenceAllowed()}usableStorage(){if(this.isGated())return;this.isSessionStorageAvailable===void 0&&(this.isSessionStorageAvailable=hg());let e=Bh();if(this.isSessionStorageAvailable&&e)return this.clearStoredOnReopen&&(this.clearStoredOnReopen=!1,e.removeItem(this.storageKey)),e}shouldTrack(e,t){if(e.metadata?.deliveryMethod===`web`)return!0;let n={userId:t?.user_id,deviceId:t?.device_id};this.identityEquals(this.identity,n)||this.clearCache(),this.identity=n,this.loadCache();let r=e.flag_key in this.inMemoryCache,i=this.inMemoryCache[e.flag_key],a=e.variant??null,o=i??null,s=!1;return(!r||o!==a)&&(s=!0,this.inMemoryCache[e.flag_key]=a,this.isGated()&&(this.hasGatedEntries=!0)),this.storeCache(),s}clearCache(){this.inMemoryCache={},this.hasGatedEntries=!1;let e=this.usableStorage();e?e.removeItem(this.storageKey):this.isGated()&&(this.clearStoredOnReopen=!0)}identityEquals(e,t){return e.userId&&t.userId?e.userId===t.userId:!e.userId&&!t.userId&&e.deviceId===t.deviceId}loadCache(){let e=this.usableStorage();if(e){let t=e.getItem(this.storageKey),n=t?JSON.parse(t):{};this.hasGatedEntries?(this.inMemoryCache=Object.assign(Object.assign({},n),this.inMemoryCache),this.hasGatedEntries=!1):this.inMemoryCache=n}}
12storeCache(){let e=this.usableStorage();if(e)try{e.setItem(this.storageKey,JSON.stringify(this.inMemoryCache))}catch{}}},mg=class{constructor(e,t=dg,n){this.persistenceAllowed=n,this.inMemoryQueue=[],this.holdsGatedEvents=!1,this.storageKey=`EXP_unsent_${e}`,this.maxQueueSize=t}push(e){this.loadQueue(),this.inMemoryQueue.push(e),this.canPersist()||(this.holdsGatedEvents=!0),this.flush(),this.storeQueue()}setTracker(e){this.tracker=e;let t=Gh();t&&(this.poller=t(()=>{this.loadFlushStore()},1e3)),this.loadFlushStore()}flush(){if(!this.tracker||this.inMemoryQueue.length===0)return;let e=0;for(;e<this.inMemoryQueue.length;e++)try{if(!this.tracker(this.inMemoryQueue[e]))break}catch{break}if(this.inMemoryQueue=this.inMemoryQueue.slice(e),this.inMemoryQueue.length===0&&this.poller){let e=Kh();e&&e(this.poller),this.poller=void 0}}canPersist(){return!this.persistenceAllowed||this.persistenceAllowed()}usableStorage(){if(!this.canPersist())return;this.isLocalStorageAvailable===void 0&&(this.isLocalStorageAvailable=Rh());let e=zh();return this.isLocalStorageAvailable&&e?e:void 0}loadQueue(){let e=this.usableStorage();if(e){let t=e.getItem(this.storageKey),n=t?JSON.parse(t):[];this.holdsGatedEvents?(this.inMemoryQueue=[...n,...this.inMemoryQueue],this.holdsGatedEvents=!1):this.inMemoryQueue=n}}storeQueue(){let e=this.usableStorage();if(e){if(this.inMemoryQueue.length===0){e.removeItem(this.storageKey);return}this.inMemoryQueue.length>this.maxQueueSize&&(this.inMemoryQueue=this.inMemoryQueue.slice(this.inMemoryQueue.length-this.maxQueueSize)),e.setItem(this.storageKey,JSON.stringify(this.inMemoryQueue))}}loadFlushStore(){this.loadQueue(),this.flush(),this.storeQueue()}},hg=()=>{let e=X();if(e)try{let t=`EXP_test`;return e.sessionStorage.setItem(t,t),e.sessionStorage.removeItem(t),!0}catch{return!1}return!1},gg=class{constructor(e,t=og.Error){this.logger=e,this.logLevel=t}error(e,...t){this.logLevel>=og.Error&&this.logger.error(e,...t)}warn(e,...t){this.logLevel>=og.Warn&&this.logger.warn(e,...t)}info(e,...t){this.logLevel>=og.Info&&this.logger.info(e,...t)}debug(e,...t){this.logLevel>=og.Debug&&this.logger.debug(e,...t)}verbose(e,...t){this.logLevel>=og.Verbose&&this.logger.verbose(e,...t)}},_g=class{error(e,...t){console.error(e,...t)}warn(e,...t){console.warn(e,...t)}info(e,...t){console.info(e,...t)}debug(e,...t){console.debug(e,...t)}verbose(e,...t){console.debug(e,...t)}},vg=class{constructor(){this.globalScope=X()}get(e){return this.globalScope?.localStorage.getItem(e)}put(e,t){var n;(n=this.globalScope)==null||n.localStorage.setItem(e,t)}delete(e){var t;(t=this.globalScope)==null||t.localStorage.removeItem(e)}},yg=(e,t,n)=>new Cg(`amp-exp-${t}-${e.substring(e.length-6)}`,n,wg),bg=(e,t,n=new vg)=>new Cg(`amp-exp-${t}-${e.substring(e.length-6)}-flags`,n),xg=(e,t,n=new vg)=>new Sg(`amp-exp-${t}-${e.substring(e.length-6)}-variants-options`,n),Sg=class{constructor(e,t){this.namespace=e,this.storage=t}get(){return this.value}put(e){this.value=e}load(){let e=this.storage.get(this.namespace);e&&(this.value=JSON.parse(e))}store(){this.value===void 0?this.storage.delete(this.namespace):this.storage.put(this.namespace,JSON.stringify(this.value))}},Cg=class{constructor(e,t,n){this.cache={},this.namespace=e,this.storage=t,this.transformer=n}get(e){return this.cache[e]}getAll(){return Object.assign({},this.cache)}put(e,t){this.cache[e]=t}putAll(e){for(let t of Object.keys(e))this.cache[t]=e[t]}remove(e){delete this.cache[e]}clear(){this.cache={}}load(){let e=this.storage.get(this.namespace),t;try{t=JSON.parse(e)||{}}catch{return}let n={};for(let e of Object.keys(t))try{let r;r=this.transformer?this.transformer(t[e]):t[e],r&&(n[e]=r)}catch{}this.clear(),this.putAll(n)}store(e=this.cache){this.storage.put(this.namespace,JSON.stringify(e))}},wg=e=>{if(typeof e==`string`)return{key:e,value:e};if(typeof e==`object`){let t=e.key,n=e.value,r=e.payload,i=e.metadata,a=e.expKey;i&&i.experimentKey?a=i.experimentKey:a&&(i||={},i.experimentKey=a);let o={};return t?o.key=t:n&&(o.key=n),n&&(o.value=n),i&&(o.metadata=i),r&&(o.payload=r),a&&(o.expKey=a),o}},Tg=class{constructor(){this.globalScope=X()}get(e){return this.globalScope?.sessionStorage.getItem(e)}put(e,t){var n;(n=this.globalScope)==null||n.sessionStorage.setItem(e,t)}delete(e){var t;(t=this.globalScope)==null||t.sessionStorage.removeItem(e)}},Eg=(e,t,n,r)=>{let i=n?.value,a=`[Experiment] ${t}`;return{name:`[Experiment] Exposure`,user:e,key:t,variant:n,userProperty:a,properties:{key:t,variant:i,source:r},userProperties:{[a]:i}}},Dg=e=>e==null,Og=e=>Dg(e)?!0:e&&Object.keys(e).length===0,kg=e=>{if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))Dg(r)||(t[n]=r);return t},Ag=e=>e?.metadata?.evaluationMode===`local`,jg=class{constructor(e,t,n,r){this.started=!1,this.done=!1,this.attempts=e,this.min=t,this.max=n,this.scalar=r}start(e){return Z(this,void 0,void 0,function*(){if(!this.started)this.started=!0;else throw Error(`Backoff already started`);yield this.backoff(e,0,this.min)})}cancel(){this.done=!0;let e=Wh();e&&e(this.timeoutHandle)}backoff(e,t,n){return Z(this,void 0,void 0,function*(){if(this.done)return;let r=Uh();r&&(this.timeoutHandle=r(()=>{Z(this,void 0,void 0,function*(){try{yield e()}catch{let r=t+1;if(r<this.attempts){let t=Math.min(n*this.scalar,this.max);yield this.backoff(e,r,t)}}})}
12,n))})}},Mg=e=>{if(!e)return{};let t={user:e},n=X();n?.location&&(t.page={url:n.location.href});let r={};if(!e.groups)return t;for(let t of Object.keys(e.groups)){let n=e.groups[t];if(n.length>0&&n[0]){let i=n[0],a={group_name:i},o=e.group_properties?.[t]?.[i];o&&Object.keys(o).length>0&&(a.group_properties=o),r[t]=a}}return Object.keys(r).length>0&&(t.groups=r),delete t.user.groups,delete t.user.group_properties,t},Ng=e=>e==null?{}:typeof e==`string`?{key:e,value:e}:e,Pg=e=>{if(!e)return{};let t;e.metadata&&(t=e.metadata.experimentKey);let n={};return e.key&&(n.key=e.key),e.value&&(n.value=e.value),e.payload&&(n.payload=e.payload),t&&(n.expKey=t),e.metadata&&(n.metadata=e.metadata),n},Fg=class{constructor(e){this.setProperties={},this.unsetProperties={},this.analyticsProvider=e}track(e){this.setProperties[e.key]!=e.variant.value&&(this.setProperties[e.key]=e.variant.value,delete this.unsetProperties[e.key],this.analyticsProvider.track(e))}setUserProperty(e){this.setProperties[e.key]!=e.variant.value&&this.analyticsProvider.setUserProperty(e)}unsetUserProperty(e){this.unsetProperties[e.key]||(this.unsetProperties[e.key]=`unset`,delete this.setProperties[e.key],this.analyticsProvider.unsetUserProperty(e))}},Ig=class{constructor(e){this.tracked={},this.identity={},this.exposureTrackingProvider=e}track(e,t){let n={userId:t?.user_id,deviceId:t?.device_id};this.identityEquals(this.identity,n)||(this.tracked={}),this.identity=n;let r=e.flag_key in this.tracked,i=this.tracked[e.flag_key];r&&i===e.variant||(this.tracked[e.flag_key]=e.variant,this.exposureTrackingProvider.track(e))}identityEquals(e,t){return e.userId===t.userId&&e.deviceId===t.deviceId}},Lg=1e4,Rg=8,zg=500,Bg=1e4,Vg=1.5,Hg=6e4,Ug=`https://api.lab.eu.amplitude.com`,Wg=`https://flag.lab.eu.amplitude.com`,Gg=class e{constructor(t,n){this.engine=new Jm,this.isRunning=!1,this.apiKey=t,n=kg(n),this.config=Object.assign(Object.assign(Object.assign({},lg),n),{serverUrl:n?.serverUrl||((n?.serverZone)?.toLowerCase()===`eu`?Ug:lg.serverUrl),flagsServerUrl:n?.flagsServerUrl||((n?.serverZone)?.toLowerCase()===`eu`?Wg:lg.flagsServerUrl),flagConfigPollingIntervalMillis:n.flagConfigPollingIntervalMillis<Hg?Hg:n.flagConfigPollingIntervalMillis??lg.flagConfigPollingIntervalMillis}),this.logger=new gg(this.config.loggerProvider||new _g,e.getLogLevel(n));let r=this.config?.internalInstanceNameSuffix;if(this.isWebExperiment=r===`web`,this.poller=new qh(()=>Z(this,void 0,void 0,function*(){try{yield this.doFlags()}catch(e){this.logger.info(e)}}),this.config.flagConfigPollingIntervalMillis),this.config.initialVariants)for(let e in this.config.initialVariants)this.config.initialVariants[e]=wg(this.config.initialVariants[e]);this.config.userProvider&&(this.userProvider=this.config.userProvider),this.config.analyticsProvider&&(this.analyticsProvider=new Fg(this.config.analyticsProvider)),this.config.exposureTrackingProvider&&(this.userSessionExposureTracker=new Ig(this.config.exposureTrackingProvider)),this.integrationManager=new fg(this.config,this);let i=new ig(this.config.httpClient||ag);this.flagApi=new Lh(this.apiKey,this.config.flagsServerUrl,i),this.evaluationApi=new Ih(this.apiKey,this.config.serverUrl,i);let a,o=r?`${this.config.instanceName}-${String(r)}`:this.config.instanceName;a=this.isWebExperiment?this.config?.internalCacheStorage??new Tg:new vg,this.variants=yg(this.apiKey,o,a),this.flags=bg(this.apiKey,o,a),this.fetchVariantsOptions=xg(this.apiKey,o,a);try{this.flags.load(),this.variants.load(),this.fetchVariantsOptions.load()}catch{}this.mergeInitialFlagsWithStorage()}start(e){return Z(this,void 0,void 0,function*(){if(!this.isRunning){this.isRunning=!0,this.setUser(e);try{let t=this.doFlags();this.config.fetchOnStart??!0?yield Promise.all([this.fetch(e),t]):yield t}catch(e){if(this.config.throwOnError)throw e}this.config.pollOnStart&&this.poller.start()}})}stop(){this.isRunning&&=(this.poller.stop(),!1)}fetch(){return Z(this,arguments,void 0,function*(e=this.user,t){this.setUser(e||{});try{yield this.fetchInternal(e,this.config.fetchTimeoutMillis,this.config.retryFetchOnFailure,t)}catch(e){if(this.config.throwOnError)throw e;e instanceof Fh?this.logger.debug(e):this.logger.error(e)}return this})}variant(e,t){if(!this.apiKey)return{value:void 0};let n=this.variantAndSource(e,t);return this.config.automaticExposureTracking&&this.exposureInternal(e,n),this.logger.debug(`[Experiment] variant for ${e} is ${n.variant?.key||n.variant?.value}`),n.variant||{}}exposure(e){let t=this.variantAndSource(e);this.exposureInternal(e,t)}all(){if(!this.apiKey)return{};let e=this.evaluate();for(let t in e)Ag(this.flags.get(t))||delete e[t];return Object.assign(Object.assign(Object.assign({},this.secondaryVariants()),this.sourceVariants()),e)}clear(){this.variants.clear();try{this.variants.store()}catch{}}getUser(){if(!this.user)return this.user;if(this.user?.user_properties){let e=Object.assign({},this.user.user_properties);return Object.assign(Object.assign({},this.user),{user_properties:e})}return Object.assign({},this.user)}setUser(e){if(!e){this.user=null;return}if(this.user?.user_properties){let t=Object.assign({},e.user_properties);this.user=Object.assign(Object.assign({},e),{user_properties:t})}else this.user=Object.assign({},e)}getUserProvider(){return this.userProvider}setUserProvider(e){return this.userProvider=e,this}mergeInitialFlagsWithStorage(){this.config.initialFlags&&JSON.parse(this.config.initialFlags).forEac
12h(e=>{this.flags.get(e.key)||this.flags.put(e.key,e)})}evaluate(e){let t=this.addContext(this.user),n=Ym(this.flags.getAll(),e),r=Mg(t),i=this.engine.evaluate(r,n),a={};for(let e of Object.keys(i))a[e]=Pg(i[e]);return a}getEvaluationTraces(e){let t=this.addContext(this.user),n=Ym(this.flags.getAll(),e),r=Mg(t),{traces:i}=this.engine.evaluateWithTraces(r,n);return i}variantAndSource(e,t){let n={};this.config.source===sg.LocalStorage?n=this.localStorageVariantAndSource(e,t):this.config.source===sg.InitialVariants&&(n=this.initialVariantsVariantAndSource(e,t));let r=this.flags.get(e);return(Ag(r)||!n.variant&&r)&&(n=this.localEvaluationVariantAndSource(e,r,t)),n}localEvaluationVariantAndSource(e,t,n){let r={},i=this.evaluate([t.key])[e],a=Q.LocalEvaluation,o=i?.metadata?.default;if(!Dg(i)&&!o)return{variant:Ng(i),source:a,hasDefaultVariant:!1};if(o&&(r={variant:Ng(i),source:a,hasDefaultVariant:!0}),!Dg(n))return{variant:Ng(n),source:Q.FallbackInline,hasDefaultVariant:r.hasDefaultVariant};let s=this.config.initialVariants[e];if(!Dg(s))return{variant:Ng(s),source:Q.SecondaryInitialVariants,hasDefaultVariant:r.hasDefaultVariant};let c=Ng(this.config.fallbackVariant),l={variant:c,source:Q.FallbackConfig,hasDefaultVariant:r.hasDefaultVariant};return Og(c)?r:l}localStorageVariantAndSource(e,t){let n={},r=this.variants.get(e),i=r?.metadata?.default;if(!Dg(r)&&!i)return{variant:Ng(r),source:Q.LocalStorage,hasDefaultVariant:!1};if(i&&(n={variant:Ng(r),source:Q.LocalStorage,hasDefaultVariant:!0}),!Dg(t))return{variant:Ng(t),source:Q.FallbackInline,hasDefaultVariant:n.hasDefaultVariant};let a=this.config.initialVariants[e];if(!Dg(a))return{variant:Ng(a),source:Q.SecondaryInitialVariants,hasDefaultVariant:n.hasDefaultVariant};let o=Ng(this.config.fallbackVariant),s={variant:o,source:Q.FallbackConfig,hasDefaultVariant:n.hasDefaultVariant};
12return Og(o)?n:s}initialVariantsVariantAndSource(e,t){let n={},r=this.config.initialVariants[e];if(!Dg(r))return{variant:Ng(r),source:Q.InitialVariants,hasDefaultVariant:!1};let i=this.variants.get(e),a=i?.metadata?.default;if(!Dg(i)&&!a)return{variant:Ng(i),source:Q.LocalStorage,hasDefaultVariant:!1};if(a&&(n={variant:Ng(i),source:Q.LocalStorage,hasDefaultVariant:!0}),!Dg(t))return{variant:Ng(t),source:Q.FallbackInline,hasDefaultVariant:n.hasDefaultVariant};let o=Ng(this.config.fallbackVariant),s={variant:o,source:Q.FallbackConfig,hasDefaultVariant:n.hasDefaultVariant};return Og(o)?n:s}fetchInternal(e,t,n,r){return Z(this,void 0,void 0,function*(){if(!this.apiKey)throw Error(`Experiment API key is empty`);this.logger.debug(`[Experiment] Fetch all: retry=${String(n)}`),n&&this.stopRetries();try{let n=yield this.doFetch(e,t,Object.assign({trackingOption:this.fetchVariantsOptions.get()?.trackingOption},r));return yield this.storeVariants(n,r),n}catch(t){throw n&&this.shouldRetryFetch(t)&&this.startRetries(e,r),t}})}setTracksAssignment(e){return Z(this,void 0,void 0,function*(){this.fetchVariantsOptions.put(Object.assign(Object.assign({},this.fetchVariantsOptions.get()||{}),{trackingOption:e?`track`:`no-track`})),this.fetchVariantsOptions.store()})}cleanUserPropsForFetch(e){let t=Object.assign({},e);return delete t.cookie,t}doFetch(e,t,n){return Z(this,void 0,void 0,function*(){e=yield this.addContextOrWait(e),e=this.cleanUserPropsForFetch(e),this.logger.debug(`[Experiment] Fetch variants for user: `,e);let r=yield this.evaluationApi.getVariants(e,Object.assign({timeoutMillis:t},n)),i={};for(let e of Object.keys(r))i[e]=Pg(r[e]);return this.logger.debug(`[Experiment] Received variants: `,i),i})}doFlags(){return Z(this,void 0,void 0,function*(){try{let e;this.isWebExperiment&&(e=yield this.addContextOrWait(this.getUser()));let t=yield this.flagApi.getFlags({libraryName:`experiment-js-client`,libraryVersion:ug,timeoutMillis:this.config.fetchTimeoutMillis,deliveryMethod:this.isWebExperiment?`web`:void 0,user:e?.user_id||e?.device_id?{user_id:e?.user_id,device_id:e?.device_id}:void 0});this.flags.clear(),this.flags.putAll(t)}catch(e){if(e instanceof Fh){if(this.logger.debug(e),this.config.throwOnError)throw e}else throw e}try{this.flags.store()}catch{}this.mergeInitialFlagsWithStorage()})}storeVariants(e,t){return Z(this,void 0,void 0,function*(){let n=t&&t.flagKeys?t.flagKeys:[];n.length===0&&this.variants.clear();for(let t in e)n=n.filter(e=>e!==t),this.variants.put(t,e[t]);for(let e of n)this.variants.remove(e);try{this.variants.store()}catch{}this.logger.debug(`[Experiment] Stored variants: `,e)})}startRetries(e,t){return Z(this,void 0,void 0,function*(){this.logger.debug(`[Experiment] Retry fetch`),this.retriesBackoff=new jg(Rg,zg,Bg,Vg),this.retriesBackoff.start(()=>Z(this,void 0,void 0,function*(){yield this.fetchInternal(e,Lg,!1,t)}))})}stopRetries(){this.retriesBackoff&&this.retriesBackoff.cancel()}addContext(e){let t=this.userProvider?.getUser(),n=this.integrationManager.getUser(),r=Object.assign(Object.assign(Object.assign({},t?.user_properties),n.user_properties),e?.user_properties);return Object.assign(Object.assign(Object.assign(Object.assign({library:`experiment-js-client/${ug}`},t),n),e),{user_properties:r})}addContextOrWait(e){return Z(this,void 0,void 0,function*(){return yield this.integrationManager.ready(),this.addContext(e)})}sourceVariants(){if(this.config.source==sg.LocalStorage)return this.variants.getAll();if(this.config.source==sg.InitialVariants)return this.config.initialVariants}secondaryVariants(){if(this.config.source==sg.LocalStorage)return this.config.initialVariants;if(this.config.source==sg.InitialVariants)return this.variants.getAll()}exposureInternal(e,t){var n;if(!(t.variant?.metadata?.trackExposure??!0))return;this.legacyExposureInternal(e,t.variant,t.source);let r={flag_key:e},i=cg(t.source);if(i&&!t.hasDefaultVariant)return;t.variant?.expKey&&(r.experiment_key=t.variant?.expKey);let a=t.variant?.metadata;if(!i&&!a?.default&&(t.variant?.key?r.variant=t.variant.key:t.variant?.value&&(r.variant=t.variant.value)),a&&(r.metadata=a),this.isWebExperiment&&(r.time=Date.now()),this.isWebExperiment){let e=X();if(e?.location)try{let t=e.location.href;r.metadata.url=t.split(`?`)[0]||``}catch{}}let o=this.addContext(this.getUser());(n=this.userSessionExposureTracker)==null||n.track(r,o),this.integrationManager.track(r,o)}legacyExposureInternal(e,t,n){var r,i,a,o,s;if(this.analyticsProvider){let c=Eg(this.addContext(this.getUser()),e,t,n);cg(n)||!t?.value?(i=(r=this.analyticsProvider)?.unsetUserProperty)==null||i.call(r,c):t?.value&&((o=(a=this.analyticsProvider)?.setUserProperty)==null||o.call(a,c),(s=this.analyticsProvider)==null||s.track(c))}}static getLogLevel(e){return e.debug===!0?og.Debug:e.logLevel??og.Error}shouldRetryFetch(e){return e instanceof Ph?e.statusCode<400||e.statusCode>=500||e.statusCode===429:!0}addPlugin(e){e.type===`integration`&&this.integrationManager.setIntegration(e)}},Kg=class{constructor(e,t,n){this.globalScope=X(),this.userAgent=this.globalScope?.navigator===void 0?void 0:this.globalScope?.navigator.userAgent,this.ua=new Jh.UAParser(this.userAgent).getResult(),this.localStorage=new vg,this.sessionStorage=new Tg,this.userProvider=e,this.apiKey=t,this.persistenceAllowed=n,this.storageKey=`EXP_${this.apiKey?.slice(0,10)}_DEFAULT_USER_PROVIDER`}canPersist(){return!this.persistenceAllowed||this.persistenceAllowed()}getUser(){let e=this.userProvider?.getUser()||{};return Object.assign({language:this.getLanguage(),platform:`Web`,os:this.getOs(this.ua),device_model:this.getDeviceModel(this.ua),device_category:this.ua.device?.type??`desktop`,referring_url:(this.globalScope?.document)?.referrer.replace(/\/$/,``),cookie
12:this.getCookie(),browser:this.getBrowser(this.ua),landing_url:this.getLandingUrl(),first_seen:this.getFirstSeen(),url_param:this.getUrlParam(),user_agent:this.userAgent},e)}getLanguage(){return typeof navigator<`u`&&(navigator.languages&&navigator.languages[0]||navigator.language)||``}getOs(e){return[e.browser?.name,e.browser?.major].filter(e=>e!=null).join(` `)}getDeviceModel(e){return e.os?.name}getBrowser(e){let t=e.browser?.name;return t?.includes(`Chrom`)&&(t=`Chrome`),t?.includes(`Firefox`)&&(t=`Firefox`),t?.includes(`Safari`)&&(t=`Safari`),t?.includes(`Edge`)&&(t=`Edge`),t?.includes(`Opera`)&&(t=`Opera`),t}getCookie(){if(this.canPersist()&&this.globalScope?.document?.cookie)return Object.fromEntries((this.globalScope?.document?.cookie)?.split(`; `).map(e=>e.split(`=`)))}getLandingUrl(){if(!this.canPersist())return this.gatedLandingUrl??=this.getCurrentUrl(),this.gatedLandingUrl;try{let e=JSON.parse(this.sessionStorage.get(this.storageKey)||`{}`);return e.landing_url||(e.landing_url=this.gatedLandingUrl??this.getCurrentUrl(),this.sessionStorage.put(this.storageKey,JSON.stringify(e))),e.landing_url}catch{return}}getCurrentUrl(){return(this.globalScope?.location)?.href.replace(/\/$/,``)}getFirstSeen(){if(!this.canPersist())return(Date.now()/1e3).toString();try{let e=JSON.parse(this.localStorage.get(this.storageKey)||`{}`);return e.first_seen||(e.first_seen=(Date.now()/1e3).toString(),this.localStorage.put(this.storageKey,JSON.stringify(e))),e.first_seen}catch{return}}getUrlParam(){if(!this.globalScope)return;let e={};try{let t=new URL(this.globalScope.location.href);for(let[n,r]of t.searchParams)e[n]=[...e[n]??[],...r.split(`,`)]}catch{return}return Object.entries(e).reduce((e,[t,n])=>(e[t]=n.length==1?n[0]:n,e),{})}},qg=X();qg&&(qg.experimentInstances={});var Jg=qg?.experimentInstances??{},Yg=(e,t)=>$g(e,t,()=>new $h(e,lt.getInstance(Xg(t)),1e4)),Xg=e=>e?.instanceName||lg.instanceName,Zg=(e,t)=>{let n=Xg(t),r=t?.internalInstanceNameSuffix;return r?`${n}.${e}.${String(r)}`:`${n}.${e}`},Qg=(e,t)=>new Gg(e,Object.assign(Object.assign({},t),{userProvider:new Kg(t?.userProvider,e,t?.internalPersistenceAllowed)})),$g=(e,t,n)=>{let r=Zg(e,t),i=Jg[r];return i||(i=Qg(e,t),n&&i.addPlugin(n()),Jg[r]=i,i)},e_=function(){function e(t){this.name=e.pluginName,this.config=t}return e.prototype.setup=function(e,t){return i(this,void 0,void 0,function(){var t;return r(this,function(n){return t=this.config?.instanceName!==void 0||e.instanceName===void 0?this.config:c(c({},this.config),{instanceName:e.instanceName}),this.experiment=Yg(this.config?.deploymentKey||e.apiKey,t),[2]})})},e.pluginName=`@amplitude/experiment-analytics-plugin`,e}(),t_=function(e){return new e_(e)},n_=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:r_(),platform:`Web`,os:void 0,deviceModel:void 0}},e}(),r_=function(){return typeof navigator<`u`&&(navigator.languages&&navigator.languages[0]||navigator.language)||``},i_=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(t){e(t)}),this.queue=[])},e}(),a_=function(){return a_=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a_.apply(this,arguments)};function o_(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function s_(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}var c_=function(e,t){var n,r,i=[`string`,`number`,`boolean`,`undefined`],a=typeof e;if(a!==typeof t)return!1;try{for(var o=o_(i),s=o.next();!s.done;s=o.next())if(s.value===a)return e===t}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(e==null&&t==null)return!0;
12if(e==null||t==null||e.length!==t.length)return!1;var c=Array.isArray(e),l=Array.isArray(t);if(c!==l)return!1;if(c&&l){for(var u=0;u<e.length;u++)if(!c_(e[u],t[u]))return!1}else{if(!c_(Object.keys(e).sort(),Object.keys(t).sort()))return!1;var d=!0;return Object.keys(e).forEach(function(n){c_(e[n],t[n])||(d=!1)}),d}return!0},l_=`$set`,u_=`$unset`,d_=`$clearAll`;Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var f_=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=a_({},this.identity.userProperties),n=a_(a_({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,a,o,s,c=n.userProperties||{};try{for(var l=o_(Object.entries(e)),u=l.next();!u.done;u=l.next()){var d=s_(u.value,2),f=d[0],p=d[1];switch(f){case l_:try{for(var m=(i=void 0,o_(Object.entries(p))),h=m.next();!h.done;h=m.next()){var g=s_(h.value,2),_=g[0],v=g[1];c[_]=v}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}break;case u_:try{for(var y=(o=void 0,o_(Object.keys(p))),b=y.next();!b.done;b=y.next()){var _=b.value;delete c[_]}}catch(e){o={error:e}}finally{try{b&&!b.done&&(s=y.return)&&s.call(y)}finally{if(o)throw o.error}}break;case d_:c={}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return a_({},this.identity)},e.prototype.setIdentity=function(e){var t=a_({},this.identity);this.identity=a_({},e),c_(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),p_=typeof globalThis<`u`?globalThis:typeof window<`u`?window:self,m_=function(){function e(){this.identityStore=new f_,this.eventBridge=new i_,this.applicationContextProvider=new n_}return e.getInstance=function(t){return p_.analyticsConnectorInstances||={},p_.analyticsConnectorInstances[t]||(p_.analyticsConnectorInstances[t]=new e),p_.analyticsConnectorInstances[t]},e}(),h_=[`boot`],g_=`$default_instance`,__=Symbol.for(`amplitude-engagement-plugin-caller`);function v_(e){let t=typeof window<`u`?window.engagement:void 0,n=!1,r={_q:t?._q??[],_configuration:{apiKey:t?._configuration?.apiKey??``,serverUrl:t?._configuration?.serverUrl,chatUrl:t?._configuration?.chatUrl,mediaUrl:t?._configuration?.mediaUrl,serverZone:t?._configuration?.serverZone??`US`,autoRefreshIntervalSeconds:t?._configuration?.autoRefreshIntervalSeconds,integrations:t?._configuration?.integrations,options:{...t?._configuration?.options}},init(t,i){var a;if(r._configuration.apiKey){console.log(`Engagement SDK has already been initialized. Ignoring additional init call.`);return}if(i?.skip===!0){console.log("Engagement SDK init skipped via `skip: true`. The SDK bundle will not be loaded."),n=!0;return}if(n&&(r._q.length=0),n=!1,i!=null&&i.useEngagementDomain){let e=(i.serverZone??r._configuration.serverZone)===`EU`,t=`amplitudeengagement.com`;i.serverUrl||=e?`https://gs.eu.${t}`:`https://gs.${t}`,i.chatUrl||=e?`https://houston-chat.eu.${t}`:`https://houston-chat.${t}`,i.mediaUrl||=e?`https://engagement-static.eu.${t}`:`https://engagement-static.${t}`,i.cdnUrl||=e?`https://cdn.eu.${t}`:`https://cdn.${t}`}r._configuration={...r._configuration,...i,apiKey:t,options:{splitting:!0,...r._configuration.options,...i?.options}},(a=r._configuration?.options)!=null&&a.logger&&r._configuration.options.logger.enable(r._configuration.options.logLevel??2);let o;if(i!=null&&i.cdnUrl)o=r._configuration.options.splitting?`${i.cdnUrl}/engagement-browser/prod/split/index.js`:i.cdnUrl+`/engagement-browser/prod/index.min.js.gz`;else{let e=r._configuration.serverZone===`EU`?`https://cdn.eu.amplitude.com`:`https://cdn.amplitude.com`;o=r._configuration.options.splitting?`${e}/engagement-browser/prod/split/index.js`:`${e}/engagement-browser/prod/index.min.js.gz`}let s=null,c=()=>
12{if(n=!0,s&&=(clearTimeout(s),null),r._q&&r._q.length>0)for(console.warn(`Engagement SDK failed to load within ${l}ms. Resolving pending calls gracefully.`);r._q.length>0;){let e=r._q.shift();if(!e)continue;let t=e[0],n=h_.includes(t);if(console.warn(`Engagement SDK method '${t}' still in queue (isAsyncMethod=${n}); attempting to resolve as no-op.`),n&&e[1]instanceof Function&&e[2]instanceof Function){let n=e[1];console.warn(`Engagement SDK method '${t}' resolved as no-op due to script loading failure`),n(void 0)}}};e(o,r._configuration.options.splitting?`module`:void 0,i?.nonce,c);let l=1e4;s=setTimeout(()=>{c()},l)},plugin(e){let t=r.init,n=e?.token,i=e?.skip===!0,a=(e,t,r)=>{let i=r.getIdentity(),a=typeof n==`function`?n():n;return{user_id:e.getUserId(),device_id:e.getDeviceId(),version:t.appVersion,user_properties:i.userProperties,getSessionId:e.getSessionId,...a?{token:a}:{}}};return{name:`@amplitude/engagement-browser`,type:`enrichment`,async setup(n,o){if(i){t(n.apiKey,{skip:!0});return}let s=n.instanceName??g_,c=m_.getInstance(s).identityStore;r._configuration._installedViaPlugin=!0,t(n.apiKey,{serverZone:n.serverZone,...e,options:{logLevel:n.logLevel,logger:n.loggerProvider,...e?.options}});let l=[{track:e=>{o.track(e)}}];await window.engagement.boot({user:()=>a(o,n,c),integrations:l},__),c.addIdentityListener(e=>{var t,r;if(!((t=window.engagement)!=null&&t._.user)||!((r=window.engagement)!=null&&r._analytics.hasBooted)){console.warn(`Engagement SDK not booted. Ignoring identity change.`);return}window.engagement?._.user?.user_id===e.userId?window.engagement._setUserProperties(e.userProperties):(window.engagement.shutdown(__),window.engagement.boot({user:()=>a(o,n,c),integrations:l},__))})},async execute(e){return i||window.engagement.forwardEvent(e),e}}}},i=r;return new Proxy(r,{get:function(e,t){if(t in i)return i[t];if(t!==`then`)return t===`gs`||t===`rc`||t===`assistant`?new Proxy({},{get:function(e,n){return function(){let e=Array.from(arguments),i=`${t}.${n}`;e.unshift(i),r._q.push(e)}}}):h_.includes(t)?function(){let e=Array.prototype.slice.call(arguments);return new Promise((i,a)=>{e.unshift(t,i,a),r._q.push(e),n&&i(void 0)})}:function(){let e=Array.prototype.slice.call(arguments);e.unshift(t),r._q.push(e)}}})}var y_=(e=>(e.Local=`https://local.amplitude.com:3010/`,e.Staging=`https://apps.stag2.amplitude.com/`,e.Production=`https://app.amplitude.com/`,e.ProductionEU=`https://app.eu.amplitude.com/`,e))(y_||{}),b_=e=>{if(typeof window<`u`&&window.opener)for(let t of Object.values(y_))window.opener.postMessage({message:e},t)};function x_(e,t,n,r){for(let i of e){let e=document.createElement(`script`);e.src=i,e.id=`engagement-sdk-bundle`,n&&e.setAttribute(`nonce`,n),t&&e.setAttribute(`type`,t),r&&(e.onerror=r);let a=document.getElementsByTagName(`head`)[0];a&&a.appendChild(e)}}var S_=(b_(`ENGAGEMENT_SNIPPET`),v_((e,t,n,r)=>x_([e||`https://cdn.amplitude.com/engagement-browser/prod/index.min.js.gz`],t,n,r))),C_=e=>(typeof window<`u`&&!window.engagement&&(window.engagement=S_),S_.plugin(e)),w_=`1.1.38`,T_=`amplitude-ts-unified`,E_=function(){return{type:`enrichment`,name:`@amplitude/unified-library-plugin`,execute:function(e){return i(this,void 0,void 0,function(){return r(this,function(t){return e.library=`${T_}/${w_}-${e.library??``}`,[2,e]})})}}},D_=function(e){o(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.sessionReplay=function(){return this._sessionReplay},t.prototype.experiment=function(){if(this.config!==void 0){var e=this.plugins(e_);if(e.length===0){this.config.loggerProvider.debug(`${e_.pluginName} plugin is not found.`);return}if(e.length===1)return e[0].experiment;this.config.loggerProvider.debug(`Multiple instances of ${e_.pluginName} are found.`)}},t.prototype.initAll=function(t,n){return i(this,void 0,void 0,function(){var a=this;return r(this,function(o){return this._initAllPromise||=(function(){return i(a,void 0,void 0,function(){var i,a;return r(this,function(r){switch(r.label){case 0:return i={serverZone:n?.serverZone,instanceName:n?.instanceName},e.prototype.add.call(this,E_()),[4,e.prototype.init.call(this,t,c(c({}
12,n?.analytics),i)).promise];case 1:return r.sent(),[4,e.prototype.add.call(this,jm(c(c({},n?.sessionReplay),i))).promise];case 2:return r.sent(),[4,e.prototype.add.call(this,t_(c(c({},n?.experiment),i))).promise];case 3:return r.sent(),a=this.plugin(Am.pluginName),a===void 0?this.config.loggerProvider.debug(`${Am.pluginName} plugin is not found.`):this._sessionReplay=a.sessionReplay,[4,e.prototype.add.call(this,C_(c(c({},n?.engagement),i))).promise];case 4:return r.sent(),[2]}})})})().finally(function(){a._initAllPromise=void 0}),[2,this._initAllPromise]})})},t.prototype.init=function(t,n,r){return t===void 0&&(t=``),e.prototype.init.call(this,t,n,r)},t}(Nu),O_=function(){var e=new D_;return{_setDiagnosticsSampleRate:W(e._setDiagnosticsSampleRate.bind(e),`_setDiagnosticsSampleRate`,H(e),U(e,[`config`])),experiment:W(e.experiment.bind(e),`experiment`,H(e),U(e,[`config`])),sessionReplay:W(e.sessionReplay.bind(e),`sessionReplay`,H(e),U(e,[`config`])),initAll:W(e.initAll.bind(e),`initAll`,H(e),U(e,[`config`])),init:W(e.init.bind(e),`init`,H(e),U(e,[`config`])),add:W(e.add.bind(e),`add`,H(e),U(e,[`config.apiKey`,`timeline.plugins`])),remove:W(e.remove.bind(e),`remove`,H(e),U(e,[`config.apiKey`,`timeline.plugins`])),track:W(e.track.bind(e),`track`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),logEvent:W(e.logEvent.bind(e),`logEvent`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),identify:W(e.identify.bind(e),`identify`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),groupIdentify:W(e.groupIdentify.bind(e),`groupIdentify`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),setGroup:W(e.setGroup.bind(e),`setGroup`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),revenue:W(e.revenue.bind(e),`revenue`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),flush:W(e.flush.bind(e),`flush`,H(e),U(e,[`config.apiKey`,`timeline.queue.length`])),getUserId:W(e.getUserId.bind(e),`getUserId`,H(e),U(e,[`config`,`config.userId`])),setUserId:W(e.setUserId.bind(e),`setUserId`,H(e),U(e,[`config`,`config.userId`])),getDeviceId:W(e.getDeviceId.bind(e),`getDeviceId`,H(e),U(e,[`config`,`config.deviceId`])),setDeviceId:W(e.setDeviceId.bind(e),`setDeviceId`,H(e),U(e,[`config`,`config.deviceId`])),reset:W(e.reset.bind(e),`reset`,H(e),U(e,[`config`,`config.userId`,`config.deviceId`])),getSessionId:W(e.getSessionId.bind(e),`getSessionId`,H(e),U(e,[`config`])),setSessionId:W(e.setSessionId.bind(e),`setSessionId`,H(e),U(e,[`config`])),extendSession:W(e.extendSession.bind(e),`extendSession`,H(e),U(e,[`config`])),setOptOut:W(e.setOptOut.bind(e),`setOptOut`,H(e),U(e,[`config`])),getOptOut:W(e.getOptOut.bind(e),`getOptOut`,H(e),U(e,[`config`])),setTransport:W(e.setTransport.bind(e),`setTransport`,H(e),U(e,[`config`])),getIdentity:W(e.getIdentity.bind(e),`getIdentity`,H(e),U(e,[`config`])),setIdentity:W(e.setIdentity.bind(e),`setIdentity`,H(e),U(e,[`config`,`config.userId`,`config.deviceId`]))}},$=O_(),k_=g({Identify:()=>fe,Revenue:()=>Pe,Types:()=>ki,_setDiagnosticsSampleRate:()=>A_,add:()=>P_,createInstance:()=>O_,experiment:()=>M_,extendSession:()=>F_,flush:()=>I_,getDeviceId:()=>L_,getIdentity:()=>R_,getOptOut:()=>z_,getSessionId:()=>B_,getUserId:()=>V_,groupIdentify:()=>H_,identify:()=>U_,initAll:()=>j_,logEvent:()=>W_,remove:()=>G_,reset:()=>K_,revenue:()=>q_,sessionReplay:()=>N_,setDeviceId:()=>J_,setGroup:()=>Y_,setIdentity:()=>X_,setOptOut:()=>Z_,setSessionId:()=>Q_,setTransport:()=>$_,setUserId:()=>ev,track:()=>tv}),A_=$._setDiagnosticsSampleRate,j_=$.initAll,M_=$.experiment,N_=$.sessionReplay,P_=$.add,F_=$.extendSession,I_=$.flush,L_=$.getDeviceId,R_=$.getIdentity,z_=$.getOptOut,B_=$.getSessionId,V_=$.getUserId,H_=$.groupIdentify,U_=$.identify,W_=$.logEvent,G_=$.remove,K_=$.reset,q_=$.revenue,J_=$.setDeviceId,Y_=$.setGroup,X_=$.setIdentity,Z_=$.setOptOut,Q_=$.setSessionId,$_=$.setTransport,ev=$.setUserId,tv=$.track;export{B as a,En as i,tv as n,kf as r,k_ 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.