@tiendanube/live-state 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/clarity-BvtWdaMS.js +45 -0
- package/dist/clarity-BvtWdaMS.js.map +1 -0
- package/dist/clarity-Dc6nPh3X.cjs +2 -0
- package/dist/clarity-Dc6nPh3X.cjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8039 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/LiveStateAlert.d.ts +15 -0
- package/dist/src/components/LiveStateAlert.d.ts.map +1 -0
- package/dist/src/components/LiveStateInfo.d.ts +16 -0
- package/dist/src/components/LiveStateInfo.d.ts.map +1 -0
- package/dist/src/components/LiveStateRenderer.d.ts +11 -0
- package/dist/src/components/LiveStateRenderer.d.ts.map +1 -0
- package/dist/src/hooks/useLiveState.d.ts +22 -0
- package/dist/src/hooks/useLiveState.d.ts.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/providers/LiveStateProvider.d.ts +28 -0
- package/dist/src/providers/LiveStateProvider.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +101 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/utils/analytics.d.ts +41 -0
- package/dist/src/utils/analytics.d.ts.map +1 -0
- package/dist/src/utils/cta.d.ts +8 -0
- package/dist/src/utils/cta.d.ts.map +1 -0
- package/package.json +102 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`react`);l=c(l,1);let u=require(`react/jsx-runtime`),d=require(`@nimbus-ds/components`),f=require(`@nimbus-ds/icons`);var p=o((e=>{var t=require(`react`);function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),m=o((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function n(e,t){d||a.startTransition===void 0||(d=!0,console.error(`You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.`));var n=t();if(!f){var i=t();o(n,i)||(console.error(`The result of getSnapshot should be cached to avoid an infinite loop`),f=!0)}i=s({inst:{value:n,getSnapshot:t}});var p=i[0].inst,m=i[1];return l(function(){p.value=n,p.getSnapshot=t,r(p)&&m({inst:p})},[e,n,t]),c(function(){return r(p)&&m({inst:p}),e(function(){r(p)&&m({inst:p})})},[e]),u(n),n}function r(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch{return!0}}function i(e,t){return t()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=require(`react`),o=typeof Object.is==`function`?Object.is:t,s=a.useState,c=a.useEffect,l=a.useLayoutEffect,u=a.useDebugValue,d=!1,f=!1,p=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?i:n;e.useSyncExternalStore=a.useSyncExternalStore===void 0?p:a.useSyncExternalStore,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),h=o(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=p():t.exports=m()}))(),g=Object.prototype.hasOwnProperty;function _(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&_(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(g.call(e,n)&&++r&&!g.call(t,n)||!(n in t)||!_(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var v=new WeakMap,y=()=>{},b=void 0,x=Object,S=e=>e===b,C=e=>typeof e==`function`,w=(e,t)=>({...e,...t}),T=e=>C(e.then),E={},D={},O=`undefined`,k=typeof window!=O,A=typeof document!=O,ee=k&&`Deno`in window,j=()=>k&&typeof window.requestAnimationFrame!=O,te=(e,t)=>{let n=v.get(e);return[()=>!S(t)&&e.get(t)||E,r=>{if(!S(t)){let i=e.get(t);t in D||(D[t]=i),n[5](t,w(i,r),i||E)}},n[6],()=>!S(t)&&t in D?D[t]:!S(t)&&e.get(t)||E]},M=!0,ne=()=>M,[N,re]=k&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[y,y],ie=()=>{let e=A&&document.visibilityState;return S(e)||e!==`hidden`},ae=e=>(A&&document.addEventListener(`visibilitychange`,e),N(`focus`,e),()=>{A&&document.removeEventListener(`visibilitychange`,e),re(`focus`,e)}),oe=e=>{let t=()=>{M=!0,e()},n=()=>{M=!1};return N(`online`,t),N(`offline`,n),()=>{re(`online`,t),re(`offline`,n)}},se={isOnline:ne,isVisible:ie},ce={initFocus:ae,initReconnect:oe},le=!l.default.useId,ue=!k||ee,de=e=>j()?window.requestAnimationFrame(e):setTimeout(e,1),P=ue?l.useEffect:l.useLayoutEffect,fe=typeof navigator<`u`&&navigator.connection,pe=!ue&&fe&&([`slow-2g`,`2g`].includes(fe.effectiveType)||fe.saveData),me=new WeakMap,he=e=>x.prototype.toString.call(e),ge=(e,t)=>e===`[object ${t}]`,_e=0,ve=e=>{let t=typeof e,n=he(e),r=ge(n,`Date`),i=ge(n,`RegExp`),a=ge(n,`Object`),o,s;if(x(e)===e&&!r&&!i){if(o=me.get(e),o)return o;if(o=++_e+`~`,me.set(e,o),Array.isArray(e)){for(o=`@`,s=0;s<e.length;s++)o+=ve(e[s])+`,`;me.set(e,o)}if(a){o=`#`;let t=x.keys(e).sort();for(;!S(s=t.pop());)S(e[s])||(o+=s+`:`+ve(e[s])+`,`);me.set(e,o)}}else o=r?e.toJSON():t==`symbol`?e.toString():t==`string`?JSON.stringify(e):``+e;return o},ye=e=>{if(C(e))try{e=e()}catch{e=``}let t=e;return e=typeof e==`string`?e:(Array.isArray(e)?e.length:e)?ve(e):``,[e,t]},be=0,xe=()=>++be;async function Se(...e){let[t,n,r,i]=e,a=w({populateCache:!0,throwOnError:!0},typeof i==`boolean`?{revalidate:i}:i||{}),o=a.populateCache,s=a.rollbackOnError,c=a.optimisticData,l=e=>typeof s==`function`?s(e):s!==!1,u=a.throwOnError;if(C(n)){let e=n,r=[],i=t.keys();for(let n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(d))}return d(n);async function d(n){let[i]=ye(n);if(!i)return;let[s,d]=te(t,i),[f,p,m,h]=v.get(t),g=()=>{let e=f[i];return(C(a.revalidate)?a.revalidate(s().data,n):a.revalidate!==!1)&&(delete m[i],delete h[i],e&&e[0])?e[0](2).then(()=>s().data):s().data};if(e.length<3)return g();let _=r,y,x=!1,w=xe();p[i]=[w,0];let E=!S(c),D=s(),O=D.data,k=D._c,A=S(k)?O:k;if(E&&(c=C(c)?c(A,O):c,d({data:c,_c:A})),C(_))try{_=_(A)}catch(e){y=e,x=!0}if(_&&T(_))if(_=await _.catch(e=>{y=e,x=!0}),w!==p[i][0]){if(x)throw y;return _}else x&&E&&l(y)&&(o=!0,d({data:A,_c:b}));if(o&&(x||(C(o)?d({data:o(_,A),error:b,_c:b}):d({data:_,error:b,_c:b}))),p[i][1]=xe(),Promise.resolve(g()).then(()=>{d({_c:b})}),x){if(u)throw y;return}return _}}var Ce=(e,t)=>{for(let n in e)e[n][0]&&e[n][0](t)},we=(e,t)=>{if(!v.has(e)){let n=w(ce,t),r=Object.create(null),i=Se.bind(b,e),a=y,o=Object.create(null),s=(e,t)=>{let n=o[e]||[];return o[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},c=(t,n,r)=>{e.set(t,n);let i=o[t];if(i)for(let e of i)e(n,r)},l=()=>{if(!v.has(e)&&(v.set(e,[r,Object.create(null),Object.create(null),Object.create(null),i,c,s]),!ue)){let t=n.initFocus(setTimeout.bind(b,Ce.bind(b,r,0))),i=n.initReconnect(setTimeout.bind(b,Ce.bind(b,r,1)));a=()=>{t&&t(),i&&i(),v.delete(e)}}};return l(),[e,i,l,a]}return[e,v.get(e)[4]]},Te=(e,t,n,r,i)=>{let a=n.errorRetryCount,o=i.retryCount,s=~~((Math.random()+.5)*(1<<(o<8?o:8)))*n.errorRetryInterval;!S(a)&&o>a||setTimeout(r,s,i)},Ee=_,[De,Oe]=we(new Map),ke=w({onLoadingSlow:y,onSuccess:y,onError:y,onErrorRetry:Te,onDiscarded:y,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:pe?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:pe?5e3:3e3,compare:Ee,isPaused:()=>!1,cache:De,mutate:Oe,fallback:{}},se),Ae=(e,t)=>{let n=w(e,t);if(t){let{use:r,fallback:i}=e,{use:a,fallback:o}=t;r&&a&&(n.use=r.concat(a)),i&&o&&(n.fallback=w(i,o))}return n},je=(0,l.createContext)({}),Me=e=>{let{value:t}=e,n=(0,l.useContext)(je),r=C(t),i=(0,l.useMemo)(()=>r?t(n):t,[r,n,t]),a=(0,l.useMemo)(()=>r?i:Ae(n,i),[r,n,i]),o=i&&i.provider,s=(0,l.useRef)(b);o&&!s.current&&(s.current=we(o(a.cache||De),i));let c=s.current;return c&&(a.cache=c[0],a.mutate=c[1]),P(()=>{if(c)return c[2]&&c[2](),c[3]},[]),(0,l.createElement)(je.Provider,w(e,{value:a}))},Ne=k&&window.__SWR_DEVTOOLS_USE__,Pe=Ne?window.__SWR_DEVTOOLS_USE__:[],Fe=()=>{Ne&&(window.__SWR_DEVTOOLS_REACT__=l.default)},Ie=e=>C(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Le=()=>{let e=(0,l.useContext)(je);return(0,l.useMemo)(()=>w(ke,e),[e])},Re=Pe.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{let[r]=ye(t),[,,,i]=v.get(De);if(r.startsWith(`$inf$`))return n(...e);let a=i[r];return S(a)?n(...e):(delete i[r],a)}),r)),ze=e=>function(...t){let n=Le(),[r,i,a]=Ie(t),o=Ae(n,a),s=e,{use:c}=o,l=(c||[]).concat(Re);for(let e=l.length;e--;)s=l[e](s);return s(r,i||o.fetcher||null,o)},Be=(e,t,n)=>{let r=t[e]||(t[e]=[]);return r.push(n),()=>{let e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}};Fe();var Ve=l.default.use||(e=>{switch(e.status){case`pending`:throw e;case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:throw e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t}),e}}),He={dedupe:!0},Ue=Promise.resolve(b),We=()=>y,Ge=(e,t,n)=>{let{cache:r,compare:i,suspense:a,fallbackData:o,revalidateOnMount:s,revalidateIfStale:c,refreshInterval:u,refreshWhenHidden:d,refreshWhenOffline:f,keepPreviousData:p,strictServerPrefetchWarning:m}=n,[g,_,y,x]=v.get(r),[E,D]=ye(e),O=(0,l.useRef)(!1),k=(0,l.useRef)(!1),A=(0,l.useRef)(E),ee=(0,l.useRef)(t),j=(0,l.useRef)(n),M=()=>j.current,ne=()=>M().isVisible()&&M().isOnline(),[N,re,ie,ae]=te(r,E),oe=(0,l.useRef)({}).current,se=S(o)?S(n.fallback)?b:n.fallback[E]:o,ce=(e,t)=>{for(let n in oe){let r=n;if(r===`data`){if(!i(e[r],t[r])&&(!S(e[r])||!i(Ce,t[r])))return!1}else if(t[r]!==e[r])return!1}return!0},fe=!O.current,pe=(0,l.useMemo)(()=>{let e=N(),n=ae(),r=e=>{let n=w(e);return delete n._k,!(!E||!t||M().isPaused())&&(fe&&!S(s)?s:S(S(se)?n.data:se)||c)?{isValidating:!0,isLoading:!0,...n}:n},i=r(e),a=e===n?i:r(n),o=i;return[()=>{let e=r(N());return ce(e,o)?(o.data=e.data,o.isLoading=e.isLoading,o.isValidating=e.isValidating,o.error=e.error,o):(o=e,e)},()=>a]},[r,E]),me=(0,h.useSyncExternalStore)((0,l.useCallback)(e=>ie(E,(t,n)=>{ce(n,t)||e()}),[r,E]),pe[0],pe[1]),he=g[E]&&g[E].length>0,ge=me.data,_e=S(ge)?se&&T(se)?Ve(se):se:ge,ve=me.error,be=(0,l.useRef)(_e),Ce=p?S(ge)?S(be.current)?_e:be.current:ge:_e,we=E&&S(_e),Te=(0,l.useRef)(null);!ue&&(0,h.useSyncExternalStore)(We,()=>(Te.current=!1,Te),()=>(Te.current=!0,Te));let Ee=Te.current;m&&Ee&&!a&&we&&console.warn(`Missing pre-initiated data for serialized key "${E}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);let De=!E||!t||M().isPaused()||he&&!S(ve)?!1:fe&&!S(s)?s:a?S(_e)?!1:c:S(_e)||c,Oe=fe&&De,ke=S(me.isValidating)?Oe:me.isValidating,Ae=S(me.isLoading)?Oe:me.isLoading,je=(0,l.useCallback)(async e=>{let t=ee.current;if(!E||!t||k.current||M().isPaused())return!1;let r,a,o=!0,s=e||{},c=!y[E]||!s.dedupe,l=()=>le?!k.current&&E===A.current&&O.current:E===A.current,u={isValidating:!1,isLoading:!1},d=()=>{re(u)},f=()=>{let e=y[E];e&&e[1]===a&&delete y[E]},p={isValidating:!0};S(N().data)&&(p.isLoading=!0);try{if(c&&(re(p),n.loadingTimeout&&S(N().data)&&setTimeout(()=>{o&&l()&&M().onLoadingSlow(E,n)},n.loadingTimeout),y[E]=[t(D),xe()]),[r,a]=y[E],r=await r,c&&setTimeout(f,n.dedupingInterval),!y[E]||y[E][1]!==a)return c&&l()&&M().onDiscarded(E),!1;u.error=b;let e=_[E];if(!S(e)&&(a<=e[0]||a<=e[1]||e[1]===0))return d(),c&&l()&&M().onDiscarded(E),!1;let s=N().data;u.data=i(s,r)?s:r,c&&l()&&M().onSuccess(r,E,n)}catch(e){f();let t=M(),{shouldRetryOnError:n}=t;t.isPaused()||(u.error=e,c&&l()&&(t.onError(e,E,t),(n===!0||C(n)&&n(e))&&(!M().revalidateOnFocus||!M().revalidateOnReconnect||ne())&&t.onErrorRetry(e,E,t,e=>{let t=g[E];t&&t[0]&&t[0](3,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return o=!1,d(),!0},[E,r]),Me=(0,l.useCallback)((...e)=>Se(r,A.current,...e),[]);if(P(()=>{ee.current=t,j.current=n,S(ge)||(be.current=ge)}),P(()=>{if(!E)return;let e=je.bind(b,He),t=0;M().revalidateOnFocus&&(t=Date.now()+M().focusThrottleInterval);let n=Be(E,g,(n,r={})=>{if(n==0){let n=Date.now();M().revalidateOnFocus&&n>t&&ne()&&(t=n+M().focusThrottleInterval,e())}else if(n==1)M().revalidateOnReconnect&&ne()&&e();else if(n==2)return je();else if(n==3)return je(r)});return k.current=!1,A.current=E,O.current=!0,re({_k:D}),De&&(y[E]||(S(_e)||ue?e():de(e))),()=>{k.current=!0,n()}},[E]),P(()=>{let e;function t(){let t=C(u)?u(N().data):u;t&&e!==-1&&(e=setTimeout(n,t))}function n(){!N().error&&(d||M().isVisible())&&(f||M().isOnline())?je(He).then(t):t()}return t(),()=>{e&&=(clearTimeout(e),-1)}},[u,d,f,E]),(0,l.useDebugValue)(Ce),a){if(!le&&ue&&we)throw Error(`Fallback data is required when using Suspense in SSR.`);we&&(ee.current=t,j.current=n,k.current=!1);let e=x[E];if(Ve(!S(e)&&we?Me(e):Ue),!S(ve)&&we)throw ve;let r=we?je(He):Ue;!S(Ce)&&we&&(r.status=`fulfilled`,r.value=!0),Ve(r)}return{mutate:Me,get data(){return oe.data=!0,Ce},get error(){return oe.error=!0,ve},get isValidating(){return oe.isValidating=!0,ke},get isLoading(){return oe.isLoading=!0,Ae}}},Ke=x.defineProperty(Me,`defaultValue`,{value:ke}),qe=ze(Ge),Je=function(e,t){return Je=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Je(e,t)};function Ye(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Je(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var F=function(){return F=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},F.apply(this,arguments)};function Xe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function I(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())})}function L(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function R(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 z(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}function B(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Ze;(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`})(Ze||={});var Qe;(function(e){e.IDENTIFY=`$identify`,e.GROUP_IDENTIFY=`$groupidentify`,e.REVENUE=`revenue_amount`})(Qe||={});var $e=`AMP_unsent`,et=`$default_instance`,tt=`https://api2.amplitude.com/2/httpapi`,nt=`https://api.eu.amplitude.com/2/httpapi`,rt=`https://api2.amplitude.com/batch`,it=`https://api.eu.amplitude.com/batch`,at=`utm_campaign`,ot=`utm_content`,st=`utm_id`,ct=`utm_medium`,lt=`utm_source`,ut=`utm_term`,dt=`dclid`,ft=`fbclid`,pt=`gbraid`,mt=`gclid`,ht=`ko_click_id`,gt=`li_fat_id`,_t=`msclkid`,vt=`rdt_cid`,yt=`ttclid`,bt=`twclid`,xt=`wbraid`,St={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},Ct=`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(`.`),wt=[`authorization`,`cookie`,`set-cookie`],Tt=1e3,Et=function(e){if(Object.keys(e).length>Tt)return!1;for(var t in e){var n=e[t];if(!Dt(t,n))return!1}return!0},Dt=function(e,t){var n,r;if(typeof e!=`string`)return!1;if(Array.isArray(t)){var i=!0;try{for(var a=R(t),o=a.next();!o.done;o=a.next()){var s=o.value;if(Array.isArray(s))return!1;if(typeof s==`object`)i&&=Et(s);else if(![`number`,`string`].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}else if(t==null)return!1;else if(typeof t==`object`)return Et(t);else if(![`number`,`string`,`boolean`].includes(typeof t))return!1;return!0},Ot=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return F({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(V.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(V.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(V.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(V.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(V.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(V.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(V.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(V.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(V.UNSET,e,`-`),this},e.prototype.clearAll=function(){return this._properties={},this._properties[V.CLEAR_ALL]=`-`,this},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[V.CLEAR_ALL]!==void 0||this._propertySet.has(t)?!1:e===V.ADD?typeof n==`number`:e!==V.UNSET&&e!==V.REMOVE?Dt(t,n):!0},e}(),V;(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`})(V||={});var kt=[V.CLEAR_ALL,V.UNSET,V.SET,V.SET_ONCE,V.ADD,V.APPEND,V.PREPEND,V.PREINSERT,V.POSTINSERT,V.REMOVE],At=`Event tracked successfully`,jt=`Unexpected error occurred`,Mt=`Event rejected due to exceeded retry count`,Nt=`Event skipped due to optOut config`,Pt=`Event rejected due to missing API key`,Ft=`Client not initialized`,H;(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`})(H||={});var It=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=H.Unknown),{event:e,code:t,message:n}},U=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},Lt=function(e){return e?(e^Math.random()*16>>e/4).toString(16):`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,zt)},Rt=B([],z(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,`0`)}),zt=function(e){var t=U();if(!t?.crypto?.getRandomValues)return Lt(e);var n=t.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,B([],z(n.entries()),!1).map(function(e){var t=z(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?`-${Rt[r]}`:Rt[r]}).join(``)},Bt=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this._optOutListeners=[]}return e.prototype.register=function(e,t){return I(this,void 0,void 0,function(){return L(this,function(n){switch(n.label){case 0:return this.plugins.some(function(t){return t.name===e.name})?(this.loggerProvider.warn(`Plugin with name ${e.name} already exists, skipping registration`),[2]):(e.name===void 0&&(e.name=zt(),this.loggerProvider.warn(`Plugin name is undefined.
|
|
2
|
+
Generating a random UUID for plugin name: ${e.name}.
|
|
3
|
+
Set a name for the plugin to prevent it from being added multiple times.`)),e.type=e.type??`enrichment`,[4,e.setup?.call(e,t,this.client)]);case 1:return n.sent(),this.plugins.push(e),[2]}})})},e.prototype.deregister=function(e,t){return I(this,void 0,void 0,function(){var n,r;return L(this,function(i){switch(i.label){case 0:return 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]):(r=this.plugins[n],this.plugins.splice(n,1),[4,r.teardown?.call(r)]);case 1:return i.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.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 t,n,r,i,a,o,s,c,l,u,d,f,p,c,l,m,h,g,_,v,y,b;return L(this,function(x){switch(x.label){case 0:if(!e)return[2];t=z(e,1),n=t[0],r=z(e,2),i=r[1],this.loggerProvider.log(`Timeline.apply: Initial event`,n),a=this.plugins.filter(function(e){return e.type===`before`}),x.label=1;case 1:x.trys.push([1,6,7,8]),o=R(a),s=o.next(),x.label=2;case 2:return s.done?[3,5]:(c=s.value,c.execute?[4,c.execute(F({},n))]:[3,4]);case 3:if(l=x.sent(),l===null)return this.loggerProvider.log(`Timeline.apply: Event filtered out by before plugin '${String(c.name)}', event: ${JSON.stringify(n)}`),i({event:n,code:0,message:``}),[2];n=l,this.loggerProvider.log(`Timeline.apply: Event after before plugin '${String(c.name)}', event: ${JSON.stringify(n)}`),x.label=4;case 4:return s=o.next(),[3,2];case 5:return[3,8];case 6:return u=x.sent(),_={error:u},[3,8];case 7:try{s&&!s.done&&(v=o.return)&&v.call(o)}finally{if(_)throw _.error}return[7];case 8:d=this.plugins.filter(function(e){return e.type===`enrichment`||e.type===void 0}),x.label=9;case 9:x.trys.push([9,14,15,16]),f=R(d),p=f.next(),x.label=10;case 10:return p.done?[3,13]:(c=p.value,c.execute?[4,c.execute(F({},n))]:[3,12]);case 11:if(l=x.sent(),l===null)return this.loggerProvider.log(`Timeline.apply: Event filtered out by enrichment plugin '${String(c.name)}', event: ${JSON.stringify(n)}`),i({event:n,code:0,message:``}),[2];n=l,this.loggerProvider.log(`Timeline.apply: Event after enrichment plugin '${String(c.name)}', event: ${JSON.stringify(n)}`),x.label=12;case 12:return p=f.next(),[3,10];case 13:return[3,16];case 14:return m=x.sent(),y={error:m},[3,16];case 15:try{p&&!p.done&&(b=f.return)&&b.call(f)}finally{if(y)throw y.error}return[7];case 16:return h=this.plugins.filter(function(e){return e.type===`destination`}),this.loggerProvider.log(`Timeline.apply: Final event before destinations, event: ${JSON.stringify(n)}`),g=h.map(function(e){var t=F({},n);return e.execute(t).catch(function(e){return It(t,0,String(e))})}),Promise.all(g).then(function(e){var t=z(e,1)[0]||It(n,100,`Event not tracked, no destination plugins on the instance`);i(t)}),[2]}})})},e.prototype.flush=function(){return I(this,void 0,void 0,function(){var e,t,n,r=this;return L(this,function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return r.apply(e)}))];case 1:return i.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 i.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,n,r,i,a,o,s;return L(this,function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),t=R(this._optOutListeners),n=t.next(),c.label=1;case 1:if(n.done)return[3,6];r=n.value,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,r(e)];case 3:return c.sent(),[3,5];case 4:return i=c.sent(),this.loggerProvider.error(`Error calling optOut listener`,i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return a=c.sent(),o={error:a},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;(t=e.onReset)==null||t.call(e)})},e}(),Vt=function(e,t,n){return F(F(F({},typeof e==`string`?{event_type:e}:e),n),t&&{event_properties:t})},Ht=function(e,t){return F(F({},t),{event_type:Qe.IDENTIFY,user_properties:e.getUserProperties()})},Ut=function(e,t,n,r){var i;return F(F({},r),{event_type:Qe.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})},Wt=function(e,t,n){var r,i=new Ot;return i.set(e,t),F(F({},n),{event_type:Qe.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})},Gt=function(e,t){return F(F({},t),{event_type:Qe.REVENUE,event_properties:e.getEventProperties()})},W=function(e){return{promise:e||Promise.resolve()}},Kt=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 Bt(this),this.name=e}return e.prototype._init=function(e){return I(this,void 0,void 0,function(){return L(this,function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions(`q`)];case 1:return t.sent(),this.isReady=!0,[2]}})})},e.prototype.runQueuedFunctions=function(e){return I(this,void 0,void 0,function(){var t,n,r,i,a,o,s,c;return L(this,function(l){switch(l.label){case 0:t=this[e],this[e]=[],l.label=1;case 1:l.trys.push([1,8,9,10]),n=R(t),r=n.next(),l.label=2;case 2:return r.done?[3,7]:(i=r.value,a=i(),a&&`promise`in a?[4,a.promise]:[3,4]);case 3:return l.sent(),[3,6];case 4:return[4,a];case 5:l.sent(),l.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return o=l.sent(),s={error:o},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(s)throw s.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:l.sent(),l.label=12;case 12:return[2]}})})},e.prototype.track=function(e,t,n){var r=Vt(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),W(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Ht(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),W(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=Ut(e,t,n,r);return W(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=Wt(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),W(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=Gt(e,t);return W(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),W())},e.prototype._addPlugin=function(e){return W(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)),W())},e.prototype._removePlugin=function(e){return W(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(It(e,0,Ft));this.process(e).then(t)},e.prototype.dispatch=function(e){return I(this,void 0,void 0,function(){var t=this;return L(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=F({},this.userProperties??{});if(e===void 0)return t;var n={};return Object.keys(e).forEach(function(t){Object.values(Ze).includes(t)||(n[t]=e[t])}),kt.forEach(function(n){if(Object.keys(e).includes(n)){var r=e[n];switch(n){case Ze.CLEAR_ALL:Object.keys(t).forEach(function(e){delete t[e]});break;case Ze.UNSET:Object.keys(r).forEach(function(e){delete t[e]});break;case Ze.SET:Object.assign(t,r);break}}}),Object.assign(t,n),t},e.prototype.process=function(e){return I(this,void 0,void 0,function(){var t,n,r,t;return L(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.config.optOut?[2,It(e,0,Nt)]:(e.event_type===Qe.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]);case 1:return t=i.sent(),t.code===200?this.config.loggerProvider.log(t.message):t.code===100?this.config.loggerProvider.warn(t.message):this.config.loggerProvider.error(t.message),[2,t];case 2:return n=i.sent(),r=String(n),this.config.loggerProvider.error(r),t=It(e,0,r),[2,t];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 W(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}(),qt=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));Et(t)&&(this.properties=t)}catch{}return this},e.prototype.getEventProperties=function(){var e=this.properties?F({},this.properties):{};return e[Jt.REVENUE_PRODUCT_ID]=this.productId,e[Jt.REVENUE_QUANTITY]=this.quantity,e[Jt.REVENUE_PRICE]=this.price,e[Jt.REVENUE_TYPE]=this.revenueType,e[Jt.REVENUE_CURRENCY]=this.currency,e[Jt.REVENUE]=this.revenue,e[Jt.RECEIPT]=this.receipt,e[Jt.RECEIPT_SIG]=this.receiptSig,e},e}(),Jt;(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`})(Jt||={});var Yt=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},[])},G;(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`})(G||={});var Xt=`Amplitude Logger `,Zt=function(){function e(){this.logLevel=G.None}return e.prototype.disable=function(){this.logLevel=G.None},e.prototype.enable=function(e){e===void 0&&(e=G.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<G.Verbose||console.log(`${Xt}[Log]: ${e.join(` `)}`)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<G.Warn||console.warn(`${Xt}[Warn]: ${e.join(` `)}`)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<G.Error||console.error(`${Xt}[Error]: ${e.join(` `)}`)},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<G.Debug||console.log(`${Xt}[Debug]: ${e.join(` `)}`)},e}(),Qt=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:et,logLevel:G.Warn,loggerProvider:new Zt,offline:!1,optOut:!1,serverUrl:tt,serverZone:`US`,useBatch:!1}},$t=function(){function e(e){this._optOut=!1;var t=Qt();this.apiKey=e.apiKey,this.flushIntervalMillis=e.flushIntervalMillis??t.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||t.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||t.flushQueueSize,this.instanceName=e.instanceName||t.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=tn(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},enumerable:!1,configurable:!0}),e}(),en=function(e,t){return e===`EU`?t?it:nt:t?rt:tt},tn=function(e,t,n){if(e===void 0&&(e=``),t===void 0&&(t=Qt().serverZone),n===void 0&&(n=Qt().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=[`US`,`EU`].includes(t)?t:Qt().serverZone;return{serverZone:r,serverUrl:en(r,n)}},nn=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();(function(){function e(){}return e})();function rn(e){return e>=200&&e<300}var an=function(e){return e===void 0&&(e=0),(Error().stack||``).split(`
|
|
4
|
+
`).slice(2+e).map(function(e){return e.trim()})},K=function(e){return function(){var t=F({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},on=function(e,t){var n,r;t=t.replace(/\[(\w+)\]/g,`.$1`),t=t.replace(/^\./,``);try{for(var i=R(t.split(`.`)),a=i.next();!a.done;a=i.next()){var o=a.value;if(o in e)e=e[o];else return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},q=function(e,t){return function(){var n,r,i={};try{for(var a=R(t),o=a.next();!o.done;o=a.next()){var s=o.value;i[s]=on(e,s)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i}},J=function(e,t,n,r,i){return i===void 0&&(i=null),function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var s=n(),c=s.logger,l=s.logLevel;if(l&&l<G.Debug||!l||!c)return e.apply(i,a);var u={type:`invoke public method`,name:t,args:a,stacktrace:an(1),time:{start:new Date().toISOString()},states:{}};r&&u.states&&(u.states.before=r());var d=e.apply(i,a);return d&&d.promise?d.promise.then(function(){r&&u.states&&(u.states.after=r()),u.time&&(u.time.end=new Date().toISOString()),c.debug(JSON.stringify(u,null,2))}):(r&&u.states&&(u.states.after=r()),u.time&&(u.time.end=new Date().toISOString()),c.debug(JSON.stringify(u,null,2))),d}},sn=new Set([tt,nt,rt,it]),cn=function(e,t){return t===void 0&&(t=!1),sn.has(e)?!0:t};function ln(e){return e instanceof Error?e.message:String(e)}function un(e){var t=``;try{`body`in e&&(t=JSON.stringify(e.body,null,2))}catch{}return t}var dn=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 L(this,function(r){switch(r.label){case 0:return this.config=e,this.storageKey=`${$e}_${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||=zt(),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?!0:(t.fulfillRequest([e],500,Mt),!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,r,i=this;return L(this,function(a){switch(a.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug(`Skipping flush while offline.`),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug(`Skipping flush because previous flush has not resolved.`),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach(function(e){return e.timeout===0?t.push(e):n.push(e)}),r=Yt(t,this.config.flushQueueSize),[4,r.reduce(function(t,n){return I(i,void 0,void 0,function(){return L(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 a.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 r,i,a,o,s,c;return L(this,function(l){switch(l.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,Pt)];r={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,Xe(t,[`extra`])}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new nn,l.label=1;case 1:return l.trys.push([1,3,,4]),i=tn(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,a=cn(i,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(i,r,this.config._enableRequestBodyCompressionExperimental&&a)];case 2:return o=l.sent(),o===null?(this.fulfillRequest(e,0,jt),[2]):t?(this.handleResponse(o,e),[3,4]):(`body`in o?this.fulfillRequest(e,o.statusCode,`${o.status}: ${un(o)}`):this.fulfillRequest(e,o.statusCode,o.status),[2]);case 3:return s=l.sent(),c=ln(s),this.config.loggerProvider.error(c),(n=this.diagnosticsClient)==null||n.recordEvent(`analytics.events.unsuccessful.from.catch.error`,{events:e.map(function(e){return e.event.event_type}),message:c,stack_trace:an()}),this.handleResponse({status:H.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},e.prototype.handleResponse=function(e,t){var n;rn(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:un(e),stack_trace:an()});var r=e.status;switch(r){case H.Success:this.handleSuccessResponse(e,t);break;case H.Invalid:this.handleInvalidResponse(e,t);break;case H.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case H.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn(`{code: 0, error: "Status '${r}' provided for ${t.length} events"}`),this.handleOtherResponse(t);break}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,At)},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith(`Invalid API key`)){this.fulfillRequest(t,e.statusCode,e.body.error);return}var r=B(B(B(B([],z(Object.values(e.body.eventsWithInvalidFields)),!1),z(Object.values(e.body.eventsWithMissingFields)),!1),z(Object.values(e.body.eventsWithInvalidIdLengths)),!1),z(e.body.silencedEvents),!1).flat(),i=new Set(r),a=t.filter(function(t,r){if(i.has(r)){n.fulfillRequest([t],e.statusCode,e.body.error);return}return!0});a.length>0&&this.config.loggerProvider.warn(un(e));var o=this.removeEventsExceedFlushMaxRetries(a);this.scheduleEvents(o)},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(t.length===1){this.fulfillRequest(t,e.statusCode,e.body.error);return}this.config.loggerProvider.warn(un(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(un(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;rn(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:an()})),this.removeEvents(e),e.forEach(function(e){return e.callback(It(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}(),fn=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:pn(),platform:`Web`,os:void 0,deviceModel:void 0}},e}(),pn=function(){return typeof navigator<`u`&&(navigator.languages&&navigator.languages[0]||navigator.language)||``},mn=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}(),hn=function(){return hn=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},hn.apply(this,arguments)};function gn(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 _n(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 vn=function(e,t){var n,r,i=[`string`,`number`,`boolean`,`undefined`],a=typeof e;if(a!==typeof t)return!1;try{for(var o=gn(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;if(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(!vn(e[u],t[u]))return!1}else{if(!vn(Object.keys(e).sort(),Object.keys(t).sort()))return!1;var d=!0;return Object.keys(e).forEach(function(n){vn(e[n],t[n])||(d=!1)}),d}return!0},yn=`$set`,bn=`$unset`,xn=`$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 Sn=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=hn({},this.identity.userProperties),n=hn(hn({},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=gn(Object.entries(e)),u=l.next();!u.done;u=l.next()){var d=_n(u.value,2),f=d[0],p=d[1];switch(f){case yn:try{for(var m=(i=void 0,gn(Object.entries(p))),h=m.next();!h.done;h=m.next()){var g=_n(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 bn:try{for(var y=(o=void 0,gn(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 xn:c={};break}}}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 hn({},this.identity)},e.prototype.setIdentity=function(e){var t=hn({},this.identity);this.identity=hn({},e),vn(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}(),Cn=typeof globalThis<`u`?globalThis:typeof global<`u`?global:self,wn=function(){function e(){this.identityStore=new Sn,this.eventBridge=new mn,this.applicationContextProvider=new fn}return e.getInstance=function(t){return Cn.analyticsConnectorInstances||={},Cn.analyticsConnectorInstances[t]||(Cn.analyticsConnectorInstances[t]=new e),Cn.analyticsConnectorInstances[t]},e}(),Tn=function(e){return e===void 0&&(e=et),wn.getInstance(e)},En=function(e,t){Tn(t).identityStore.editIdentity().setUserId(e).commit()},Dn=function(e,t){Tn(t).identityStore.editIdentity().setDeviceId(e).commit()},On=function(){function e(){this.name=`identity`,this.type=`before`,this.identityStore=Tn().identityStore}return e.prototype.execute=function(e){return I(this,void 0,void 0,function(){var t;return L(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 L(this,function(t){return e.instanceName&&(this.identityStore=Tn(e.instanceName).identityStore),[2]})})},e}(),kn=function(e,t){return t===void 0&&(t=Date.now()),Date.now()-t>e},An=function(e,t,n){return t===void 0&&(t=``),n===void 0&&(n=10),[`AMP`,t,e.substring(0,n)].filter(Boolean).join(`_`)},jn=function(e){return`amp_${e.substring(0,6)}`},Mn=function(){if(typeof navigator>`u`)return``;var e=navigator.userLanguage;return navigator.languages?.[0]??navigator.language??e??``},Nn=function(){var e=U();return e?.location?.search?e.location.search.substring(1).split(`&`).filter(Boolean).reduce(function(e,t){var n=t.split(`=`,2),r=Pn(n[0]),i=Pn(n[1]);return i&&(e[r]=i),e},{}):{}},Pn=function(e){e===void 0&&(e=``);try{return decodeURIComponent(e)}catch{return``}},Fn=function(e,t){return!t||!t.length?!0:t.some(function(t){return typeof t==`string`?e===t:e.match(t)})},In=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){t?.error(`Malformed URI sequence: `,e)}return n},Ln=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},Rn=function(e,t){var n=Ln(e.toString());return Math.abs(n)*31%1e5/1e5<t},zn=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){return L(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return I(this,void 0,void 0,function(){return L(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 L(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 L(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return I(this,void 0,void 0,function(){return L(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return I(this,void 0,void 0,function(){return L(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),Bn=function(){return U()?.navigator?.locks},Vn=function(){function e(e,t){t===void 0&&(t={}),this.options=F({},e),this.config=t}return e.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){var t,n,r,i,a=this;return L(this,function(o){switch(o.label){case 0:return t=`AMP_TEST`,n=F({},this.options),r=new e(n),i=String(Date.now()),[4,r.transaction(t,function(e){var n,r;try{e.set(i);var o=e.get()===i;return!o&&a.config.diagnosticsClient&&((n=a.config.diagnosticsClient)==null||n.recordEvent(`cookies.isEnabled.failure`,{reason:`Test Value mismatch`,testKey:t,testValue:i,sync:!0})),o}catch(e){if(a.config.diagnosticsClient){var s=e instanceof Error?e.message:String(e);(r=a.config.diagnosticsClient)==null||r.recordEvent(`cookies.isEnabled.failure`,{reason:`Cookie getter/setter failed`,testKey:t,testValue:i,error:s,sync:!0})}return!1}finally{e.set(null)}})];case 1:return[2,o.sent()]}})})},e.prototype.get=function(e){return I(this,void 0,void 0,function(){var t;return L(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=Wn(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,n;return I(this,void 0,void 0,function(){var r,i,a,o,s,c,l,u,d;return L(this,function(f){switch(f.label){case 0:r=U(),i=r,f.label=1;case 1:return f.trys.push([1,4,,5]),a=i?.cookieStore,a?[4,a.getAll(e)]:[3,3];case 2:if(o=f.sent(),o){o.length>1&&((t=this.config.diagnosticsClient)==null||t.recordEvent(`cookies.duplicate`,{cookies:o.map(function(e){return e.domain})}),(n=this.config.diagnosticsClient)==null||n.increment(`cookies.duplicate.occurrence.cookieStore`));try{for(s=R(o),c=s.next();!c.done;c=s.next())if(l=c.value,Gn(l.domain,this.options.domain))return[2,l.value]}catch(e){u={error:e}}finally{try{c&&!c.done&&(d=s.return)&&d.call(s)}finally{if(u)throw u.error}}}f.label=3;case 3:return[3,5];case 4:return f.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t=this,n=((U()?.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 L(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){try{var n=this.options.expirationDays??0,r=t===null?-1:n,i=void 0;if(r){var a=new Date;a.setTime(a.getTime()+r*24*60*60*1e3),i=a}var o=`${e}=${btoa(encodeURIComponent(JSON.stringify(t)))}`;i&&(o+=`; expires=${i.toUTCString()}`),o+=`; path=/`,this.options.domain&&(o+=`; domain=${this.options.domain}`),this.options.secure&&(o+=`; Secure`),this.options.sameSite&&(o+=`; SameSite=${this.options.sameSite}`);var s=U();s?.document&&(s.document.cookie=o)}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 L(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 L(this,function(e){return[2]})})},e.isDomainWritable=function(t){return I(this,void 0,void 0,function(){var n,r,i,a;return L(this,function(o){switch(o.label){case 0:if(e.cachedTlds[t])return[2,!0];n={domain:`.`+t},r=`AMP_TLDTEST`,i=new e(n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.transaction(r,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 a=o.sent(),[2,!!a];case 3:return o.sent(),[2,!1];case 4:return[2]}})})},e.prototype.transaction=function(e,t){return I(this,void 0,void 0,function(){var n,r,i=this;return L(this,function(a){switch(a.label){case 0:if(n=Bn(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.request(`com.amplitude:cookie-lock:${e}`,r)];case 2:return[2,a.sent()];case 3:return a.sent(),[2,r()];case 4:return[2]}})})},e.cachedTlds={},e}(),Hn=function(e){try{return decodeURIComponent(atob(e))}catch{return}},Un=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch{return}},Wn=function(e){return Hn(e)??Un(e)},Gn=function(e,t){if(e===``&&t===``)return!0;if(!e||!t)return!1;var n=e.startsWith(`.`)?e.substring(1):e,r=t.startsWith(`.`)?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},Kn=function(e,t,n){return t===void 0&&(t=``),n===void 0&&(n=10),[`AMP`,t,e.substring(0,n)].filter(Boolean).join(`_`)},qn=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return I(this,void 0,void 0,function(){var t,n,r,i;return L(this,function(a){switch(a.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r=`AMP_TEST`,a.label=1;case 1:return a.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return a.sent(),[4,n.get(r)];case 3:return i=a.sent(),[2,i===t];case 4:return a.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return a.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return I(this,void 0,void 0,function(){var t;return L(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 L(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 L(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 L(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 L(this,function(t){try{(e=this.storage)==null||e.clear()}catch{}return[2]})})},e}(),Jn=10,Yn=1,Y={TAGS:`tags`,COUNTERS:`counters`,HISTOGRAMS:`histograms`,EVENTS:`events`,INTERNAL:`internal`},Xn={LAST_FLUSH_TIMESTAMP:`last_flush_timestamp`},Zn=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName=`AMP_diagnostics_${e.substring(0,10)}`}return e.isSupported=function(){return U()?.indexedDB!==void 0},e.prototype.getDB=function(){return I(this,void 0,void 0,function(){return L(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,Yn);r.onerror=function(){e.dbPromise=null,n(Error(`Failed to open IndexedDB`))},r.onsuccess=function(){var n=r.result;n.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(t){var n=t.target.result;e.createTables(n)}})},e.prototype.createTables=function(e){e.objectStoreNames.contains(Y.TAGS)||e.createObjectStore(Y.TAGS,{keyPath:`key`}),e.objectStoreNames.contains(Y.COUNTERS)||e.createObjectStore(Y.COUNTERS,{keyPath:`key`}),e.objectStoreNames.contains(Y.HISTOGRAMS)||e.createObjectStore(Y.HISTOGRAMS,{keyPath:`key`}),e.objectStoreNames.contains(Y.EVENTS)||e.createObjectStore(Y.EVENTS,{keyPath:`id`,autoIncrement:!0}).createIndex(`time_idx`,`time`,{unique:!1}),e.objectStoreNames.contains(Y.INTERNAL)||e.createObjectStore(Y.INTERNAL,{keyPath:`key`})},e.prototype.setTags=function(e){return I(this,void 0,void 0,function(){var t,n,r,i,a=this;return L(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Y.TAGS],`readwrite`),r=n.objectStore(Y.TAGS),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){a.logger.debug(`DiagnosticsStorage: Failed to set tags`,e),t()},i.forEach(function(e){var t=z(e,2),n=t[0],i=t[1],o=r.put({key:n,value:i});o.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to set tag`,n,i,e)}})})];case 2:return i=o.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set tags`,i),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return I(this,void 0,void 0,function(){var t,n,r,i,a=this;return L(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Y.COUNTERS],`readwrite`),r=n.objectStore(Y.COUNTERS),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){a.logger.debug(`DiagnosticsStorage: Failed to increment counters`,e),t()},i.forEach(function(e){var t=z(e,2),n=t[0],i=t[1],o=r.get(n);o.onsuccess=function(){var e=o.result,t=e?e.value:0,s=r.put({key:n,value:t+i});s.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to update counter`,n,e)}},o.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to read existing counter`,n,e)}})})];case 2:return i=o.sent(),this.logger.debug(`DiagnosticsStorage: Failed to increment counters`,i),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return I(this,void 0,void 0,function(){var t,n,r,i,a=this;return L(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Y.HISTOGRAMS],`readwrite`),r=n.objectStore(Y.HISTOGRAMS),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){a.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,e),t()},i.forEach(function(e){var t=z(e,2),n=t[0],i=t[1],o=r.get(n);o.onsuccess=function(){var e=o.result,t=e?{key:n,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:n,count:i.count,min:i.min,max:i.max,sum:i.sum},s=r.put(t);s.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,n,e)}},o.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to read existing histogram stats`,n,e)}})})];case 2:return i=o.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set histogram stats`,i),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return I(this,void 0,void 0,function(){var t,n,r,i,a=this;return L(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e.length===0?[2]:[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Y.EVENTS],`readwrite`),r=n.objectStore(Y.EVENTS),[2,new Promise(function(t){n.oncomplete=function(){t()},n.onabort=function(e){a.logger.debug(`DiagnosticsStorage: Failed to add event records`,e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,Jn-t);n<e.length&&a.logger.debug(`DiagnosticsStorage: Only added ${n} of ${e.length} events due to storage limit`),e.slice(0,n).forEach(function(e){var t=r.add(e);t.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to add event record`,e)}})},i.onerror=function(e){a.logger.debug(`DiagnosticsStorage: Failed to count existing events`,e)}})];case 2:return i=o.sent(),this.logger.debug(`DiagnosticsStorage: Failed to add event records`,i),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return I(this,void 0,void 0,function(){var n,r,i,a;return L(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=o.sent(),r=n.transaction([Y.INTERNAL],`readwrite`),i=r.objectStore(Y.INTERNAL),[2,new Promise(function(n,a){r.onabort=function(){return a(Error(`Failed to set internal value`))};var o=i.put({key:e,value:t});o.onsuccess=function(){return n()},o.onerror=function(){return a(Error(`Failed to set internal value`))}})];case 2:return a=o.sent(),this.logger.debug(`DiagnosticsStorage: Failed to set internal value`,a),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return I(this,void 0,void 0,function(){var t,n,r,i;return L(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Y.INTERNAL],`readonly`),r=n.objectStore(Y.INTERNAL),[2,new Promise(function(t,i){n.onabort=function(){return i(Error(`Failed to get internal value`))};var a=r.get(e);a.onsuccess=function(){return t(a.result)},a.onerror=function(){return i(Error(`Failed to get internal value`))}})];case 2:return i=a.sent(),this.logger.debug(`DiagnosticsStorage: Failed to get internal value`,i),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return I(this,void 0,void 0,function(){var e,t;return L(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Xn.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 L(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Xn.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,t,n,r,i,a,o,s;return L(this,function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=c.sent(),t=e.transaction([Y.TAGS,Y.COUNTERS,Y.HISTOGRAMS,Y.EVENTS],`readwrite`),[4,Promise.all([this.getAllFromStore(t,Y.TAGS),this.getAllFromStore(t,Y.COUNTERS),this.getAllFromStore(t,Y.HISTOGRAMS),this.getAllFromStore(t,Y.EVENTS)])];case 2:return n=z.apply(void 0,[c.sent(),4]),r=n[0],i=n[1],a=n[2],o=n[3],[4,Promise.all([this.clearTable(t,Y.COUNTERS),this.clearTable(t,Y.HISTOGRAMS),this.clearTable(t,Y.EVENTS)])];case 3:return c.sent(),[2,{tags:r,counters:i,histogramStats:a,events:o}];case 4:return s=c.sent(),this.logger.debug(`DiagnosticsStorage: Failed to get all and clear data`,s),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(Error(`Failed to get all from ${t}`))}})},e}(),Qn=`__AMPLITUDE_SCRIPT_URL__`,$n=`sdk.error.uncaught`,er=function(){var e=U();if(!e)return[];var t=e[Qn];return Array.isArray(t)?t:typeof t==`string`?[t]:[]},tr=function(e){var t=U();if(!(!t||typeof t.addEventListener!=`function`)){var n=function(e){var t=e.error instanceof Error?e.error:void 0,n=t?.stack,r=nr({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=rr(n),a=nr({filename:r,stack:n});a&&i({type:`unhandledrejection`,message:t?.message??ir(e.reason),stack:n,filename:r,errorName:t?.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})},i=function(t){e.recordEvent($n,F({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener(`error`,n,!0),t.addEventListener(`unhandledrejection`,r,!0)}},nr=function(e){var t,n,r=er();if(r.length!==0)try{for(var i=R(r),a=i.next();!a.done;a=i.next()){var o=a.value;if(e.filename&&e.filename.includes(o))return`filename`;if(e.stack&&e.stack.includes(o))return`stack`}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},rr=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},ir=function(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return`[object Object]`}},ar=1e3,or=300*1e3,sr=`https://diagnostics.prod.us-west-2.amplitude.com/v1/capture`,cr=`https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture`,lr=function(){function e(e,t,n,r){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`?sr:cr,this.logger.debug(`DiagnosticsClient: Initializing with options`,JSON.stringify(r,null,2)),this.config=F({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Rn(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,Zn.isSupported()?this.storage=new Zn(e,t):this.logger.debug(`DiagnosticsClient: IndexedDB is not supported`),this.initializeFlushInterval(),this.shouldTrack&&(this.increment(`sdk.diagnostics.sampled.in.and.enabled`),tr(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})},ar),this.flushTimer||=setTimeout(function(){e._flush().catch(function(t){e.logger.debug(`DiagnosticsClient: Failed to flush`,t)}).finally(function(){e.flushTimer=null})},or)},e.prototype.saveAllDataToStorage=function(){return I(this,void 0,void 0,function(){var e,t,n,r;return L(this,function(i){switch(i.label){case 0:return this.storage?(e=F({},this.inMemoryTags),t=F({},this.inMemoryCounters),n=F({},this.inMemoryHistograms),r=B([],z(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])]):[2];case 1:return i.sent(),[2]}})})},e.prototype._flush=function(){return I(this,void 0,void 0,function(){var e,t,n,r,i,a,o,s,c,l;return L(this,function(u){switch(u.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return u.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=u.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),a={},t.forEach(function(e){a[e.key]=e.value}),o={},n.forEach(function(e){o[e.key]=e.value}),s={},r.forEach(function(e){s[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),c=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),Object.keys(o).length===0&&Object.keys(s).length===0&&c.length===0?[2]:(l={tags:a,histogram:s,counters:o,events:c},this.fetch(l),[2])}})})},e.prototype.fetch=function(e){return I(this,void 0,void 0,function(){var t,n;return L(this,function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),!U())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 L(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(or),[2]):(n=e-t,n>=3e5?(this._flush(),[2]):(this._setFlushTimer(or-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=Rn(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug(`DiagnosticsClient: Should track is`,this.shouldTrack)},e}(),ur=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 H.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 H.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 H.PayloadTooLarge:return{status:n,statusCode:t,body:{error:e.error??``}};case H.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 H.Timeout:default:return{status:n,statusCode:t}}},e.prototype.buildStatus=function(e){return rn(e)?H.Success:e===429?H.RateLimit:e===413?H.PayloadTooLarge:e===408?H.Timeout:e>=400&&e<500?H.Invalid:e>=500?H.Failed:H.Unknown},e}();function dr(){return typeof CompressionStream<`u`}function fr(e){return I(this,void 0,void 0,function(){var t,n;return L(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 pr=function(){function e(e,t){this.key=`AMP_remote_config_${e.substring(0,10)}`,this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug(`Remote config localstorage failed to access: `,e),Promise.resolve(t)}if(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: ${JSON.stringify(n)}`),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug(`Remote config localstorage failed to parse: `,e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug(`Remote config localstorage set successfully.`),Promise.resolve(!0)}catch(e){this.logger.debug(`Remote config localstorage failed to set: `,e)}return Promise.resolve(!1)},e}(),mr={INVALID_API_KEY:401,FORBIDDEN:403,RATE_LIMIT:429},hr=1e3,gr=300*1e3,_r=function(){function e(e,t,n,r){n===void 0&&(n=`US`),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||(n===`US`?`https://sr-client-cfg.amplitude.com/config`:`https://sr-client-cfg.eu.amplitude.com/config`),this.logger=t,this.storage=new pr(e,t)}return e.prototype.subscribe=function(e,t,n){var r=zt(),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 L(this,function(r){switch(r.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<gr)?(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,r,i=this;return L(this,function(a){switch(a.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug(`Remote config client subscription all mode fetched from remote: ${JSON.stringify(t)}`),i.sendCallback(e,t,`remote`),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return r=a.sent(),r!==void 0&&(this.logger.debug(`Remote config client subscription all mode fetched from cache: ${JSON.stringify(r)}`),r.remoteConfig===null?this.logger.debug(`Remote config client skips sending callback because cache is empty (first time user).`):this.sendCallback(e,r,`cache`)),[4,t];case 2:return a.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return I(this,void 0,void 0,function(){var n,r,r;return L(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n(`Timeout exceeded`)},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug(`Remote config client subscription wait for remote mode returns from remote.`),this.sendCallback(e,r,`remote`),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug(`Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache.`),[4,this.storage.fetchConfig()];case 4:return r=i.sent(),r.remoteConfig===null?(this.logger.debug(`Remote config client subscription wait for remote mode failed to fetch cache.`),this.sendCallback(e,r,`remote`)):(this.logger.debug(`Remote config client subscription wait for remote mode returns a cached copy.`),this.sendCallback(e,r,`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=hr),I(this,void 0,void 0,function(){var n,r,i,a,o,s,c=this;return L(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,o,s,l,u,d,f;return L(this,function(p){switch(p.label){case 0:i=!0,o=new AbortController,s=setTimeout(function(){return o.abort()},t),p.label=1;case 1:return p.trys.push([1,7,8,9]),[4,fetch(a.getUrlParams(),{method:`GET`,headers:{Accept:`*/*`},signal:o.signal})];case 2:return l=p.sent(),l.ok?[3,4]:[4,l.text()];case 3:return u=p.sent(),a.logger.debug(`Remote config client fetch with retry time ${e} failed with ${l.status}: ${u}`),l.status===mr.INVALID_API_KEY||l.status===mr.FORBIDDEN?(a.logger.error(`Remote config client fetch failed with ${l.status}. Invalid API key; future fetches will be skipped.`),a.isLastFetchInvalidApiKey=!0,i=!1):l.status>=400&&l.status<500&&l.status!==mr.RATE_LIMIT&&(i=!1),[3,6];case 4:return[4,l.json()];case 5:return d=p.sent(),[2,{value:{remoteConfig:d,lastFetch:new Date}}];case 6:return[3,9];case 7:return f=p.sent(),f instanceof Error&&f.name===`AbortError`?a.logger.debug(`Remote config client fetch with retry time ${e} timed out after ${t}ms`):a.logger.debug(`Remote config client fetch with retry time ${e} is rejected because: `,f),[3,9];case 8:return clearTimeout(s),[7];case 9:return i?r<e-1?[4,new Promise(function(e){return setTimeout(e,c.getJitterDelay(n))})]:[3,11]:[2,`break`];case 10:p.sent(),p.label=11;case 11:return[2]}})},a=this,o=0,l.label=1;case 1:return o<e?[5,i(o)]:[3,4];case 2:if(s=l.sent(),typeof s==`object`)return[2,s.value];if(s===`break`)return[3,4];l.label=3;case 3:return o++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append(`config_group`,e.CONFIG_GROUP),`${this.serverUrl}/${t}?${n.toString()}`},e.CONFIG_GROUP=`browser`,e}(),vr=U()?.console,yr={},br={},xr=!1;function Sr(e){return!vr||typeof vr[e]!=`function`?!1:br[e]?!0:(br[e]=vr[e],vr[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{if(yr[e]&&!xr){xr=!0;var r=yr[e];r&&r.forEach(function(n){try{n(e,t)}catch{}})}}catch{}return xr=!1,br[e].apply(vr,t)},!0)}function Cr(e,t){if(!Sr(e))return Error(`Console override failed`);yr[e]?yr[e].push(t):yr[e]=[t]}function wr(e){var t,n;try{for(var r=R(Object.values(yr)),i=r.next();!i.done;i=r.next())for(var a=i.value,o=a.length-1;o>=0;o--)if(a[o]===e){a.splice(o,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}}function Tr(){var e,t;try{for(var n=R(Object.entries(br)),r=n.next();!r.done;r=n.next()){var i=z(r.value,2),a=i[0],o=i[1];o&&(vr[a]=o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}br={},yr={}}var Er={addListener:Cr,removeListener:wr,_restoreConsole:Tr},Dr=[`a`,`button`,`input`,`select`,`textarea`,`label`,`video`,`audio`,`[contenteditable="true" i]`,`[data-amp-default-track]`,`.amp-default-track`],Or=`data-amp-track-`,kr=[`div`,`span`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],Ar=B([`input[type="button"]`,`input[type="submit"]`,`input[type="reset"]`,`input[type="image"]`,`input[type="file"]`],z([`a`,`button`,`[role="button"]`,`[role="link"]`,`[role="menuitem"]`,`[role="menuitemcheckbox"]`,`[role="menuitemradio"]`,`[role="option"]`,`[role="tab"]`,`[role="treeitem"]`,`[contenteditable="true" i]`]),!1),jr=Ar,Mr=Ar,Nr=[`*`],Pr=1e3;function Fr(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e==null}function Ir(e,t,n){e&&Lr({json:e,allowlist:t.map(Rr),excludelist:n.map(Rr),ancestors:[]})}function Lr(e){var t,n,r=e.json,i=e.targetObject,a=e.allowlist,o=e.excludelist,s=e.ancestors,c=e.parentObject,l=e.targetKey;i||=r;var u=Object.keys(i);try{for(var d=R(u),f=d.next();!f.done;f=d.next()){var p=f.value,m=B(B([],z(s),!1),[p],!1);Fr(i[p])?(!Br(m,a)||Br(m,o))&&delete i[p]:Lr({json:r,targetObject:i[p],allowlist:a,excludelist:o,ancestors:m,parentObject:i,targetKey:p})}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}Object.keys(i).length===0&&c&&l&&delete c[l]}function Rr(e){return e.startsWith(`/`)&&(e=e.slice(1)),e.split(`/`).map(function(e){return e.replace(/~0/g,`~`).replace(/~1/g,`/`)})}function zr(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];if(i===`**`){if(r+1===t.length)return!0;for(var a=n;a<=e.length;a++)if(zr(e,t,a,r+1))return!0;return!1}else if(i===`*`||i===e[n])return zr(e,t,n+1,r+1);else return!1}function Br(e,t){return t.some(function(t){return zr(e,t)})}var Vr=500,Hr=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;e===void 0&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach(function(e){var t=z(e,2),n=t[0];i[n]=t[1]});else if(r instanceof Headers)r.forEach(function(e,t){i[t]=e});else if(typeof r==`object`&&r)try{for(var a=R(Object.entries(r)),o=a.next();!o.done;o=a.next()){var s=z(o.value,2),c=s[0];i[c]=s[1]}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return Xr(i,{allow:e})},Object.defineProperty(e.prototype,`bodySize`,{get:function(){if(typeof this._bodySize==`number`)return this._bodySize;if(U()?.TextEncoder){var e=this.request.body;return this._bodySize=Wr(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 L(this,function(r){return e.length===0?[2,null]:(n=this.body,[2,qr(n,e,t)])})})},e}(),Ur=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return e===void 0&&(e=[]),Xr(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,`bodySize`,{get:function(){return Wr(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 L(this,function(r){return e.length===0?[2,null]:(n=this.body,[2,qr(n,e,t)])})})},e}();function Wr(e,t){var n,r,i,a=U()?.TextEncoder;if(a){var o;if(typeof e==`string`)o=e,i=new a().encode(o).length;else if(e instanceof Blob)o=e,i=o.size;else if(e instanceof URLSearchParams)o=e,i=new a().encode(o.toString()).length;else if(ArrayBuffer.isView(e))o=e,i=o.byteLength;else if(e instanceof ArrayBuffer)o=e,i=o.byteLength;else if(e instanceof FormData){var s=e,c=0,l=0;try{for(var u=R(s.entries()),d=u.next();!d.done;d=u.next()){var f=z(d.value,2),p=f[0],m=f[1];if(c+=p.length,typeof m==`string`)c+=new a().encode(m).length;else if(m instanceof Blob)c+=m.size;else return;if(++l>=t)return}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}i=c}else if(e instanceof ReadableStream){o=e;return}return i}}var Gr=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}),Xr(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 L(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)},Vr)}),[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 L(this,function(r){switch(r.label){case 0:return e.length===0?[2,null]:[4,this.text()];case 1:return n=r.sent(),[2,qr(n,e,t)]}})})},e}(),Kr=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,`bodySize`,{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`status`,{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var t,n;if(e===void 0&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split(`\r
|
|
5
|
+
`);try{for(var a=R(i),o=a.next();!o.done;o=a.next()){var s=o.value,c=z(s.split(`: `),2),l=c[0],u=c[1];l&&u&&(r[l]=u)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return Xr(r,{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 L(this,function(r){return e.length===0?[2,null]:(n=this.getJson(),n?(Ir(n,e,t),[2,n]):[2,null])})})},e}();function qr(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return Ir(r,t,n),r}catch{return null}}var Jr;(function(e){e.REDACT=`redact`,e.REMOVE=`remove`})(Jr||={});var Yr=`[REDACTED]`,Xr=function(e,t){var n,r,i=t.allow,a=i===void 0?[]:i,o=t.strategy,s=o===void 0?Jr.REMOVE:o,c=B([],z(wt),!1),l={},u=function(t){var n=t.toLowerCase();c.find(function(e){return e.toLowerCase()===n})?s===Jr.REDACT&&(l[t]=Yr):a.find(function(e){return e.toLowerCase()===n})?l[t]=e[t]:s===Jr.REDACT&&(l[t]=Yr)};try{for(var d=R(Object.keys(e)),f=d.next();!f.done;f=d.next()){var p=f.value;u(p)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return l},Zr=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(B([],z(Ct),!1)),requestBodySize:this.requestWrapper?.bodySize,responseHeaders:this.responseWrapper?.headers(B([],z(Ct),!1)),responseBodySize:this.responseWrapper?.bodySize};return Object.fromEntries(Object.entries(e).filter(function(e){var t=z(e,2);return t[0],t[1]!==void 0}))},e}();function Qr(e){return typeof e==`object`&&!!e&&`url`in e&&`method`in e}var $r=function(){function e(e,t){t===void 0&&(t=zt()),this.callback=e,this.id=t}return e}();function ei(e){try{e()}catch{}}var ti=new(function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=U();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=U();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){ei(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(Qr(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 Zr(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,r){return I(t,void 0,void 0,function(){var t,i,a,o,s=this;return L(this,function(c){switch(c.label){case 0:try{t=this.getTimestamps()}catch(e){ei(function(){return s.logger?.debug(`an unexpected error occurred while retrieving timestamps`,e)})}c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=c.sent(),[3,4];case 3:return o=c.sent(),a=o,[3,4];case 4:try{this.handleNetworkRequestEvent(`fetch`,n,r?new Hr(r):void 0,i?new Gr(i):void 0,a,t?.startTime,t?.durationStart)}catch(e){ei(function(){return s.logger?.debug(`an unexpected error occurred while handling fetch`,e)})}if(i)return[2,i];throw a}})})})},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`&&ei(function(){return t.logger?.debug(`unexpected error when retrieving responseText. responseType='${e.responseType}'`)}),null}return null}},e.prototype.observeXhr=function(t,n,r){if(!(!this.globalScope||!t||!n)){var i=this.globalScope.XMLHttpRequest.prototype,a=this;i.open=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=this,i=z(e,2),o=i[0],s=i[1];try{r.$$AmplitudeAnalyticsEvent=F({method:o,url:(s?.toString)?.call(s),headers:{}},a.getTimestamps())}catch(e){ei(function(){return a.logger?.debug(`an unexpected error occurred while calling xhr open`,e)})}return t.apply(r,e)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,o=i,s=e.createXhrJsonParser(i,a),c=t[0],l=o.$$AmplitudeAnalyticsEvent;return o.$$AmplitudeAnalyticsEvent&&o.addEventListener(`loadend`,function(){try{var e=o.getAllResponseHeaders(),t=o.getResponseHeader(`content-length`),n=new Kr(o.status,e,t?parseInt(t,10):void 0,s),r=o.$$AmplitudeAnalyticsEvent.headers,i=new Ur(c,r);l.status=o.status,a.handleNetworkRequestEvent(`xhr`,{url:l.url,method:l.method},i,n,void 0,l.startTime,l.durationStart)}catch(e){ei(function(){return a.logger?.debug(`an unexpected error occurred while handling xhr send`,e)})}}),n.apply(o,t)},i.setRequestHeader=function(e,t){var n=this;try{var i=n.$$AmplitudeAnalyticsEvent;i&&(i.headers[e]=t)}catch(e){ei(function(){return a.logger?.debug(`an unexpected error occurred while calling xhr setRequestHeader`,e)})}r.apply(n,[e,t])}}},e}()),ni=function(){function e(){}return e.prototype.parse=function(){return I(this,void 0,void 0,function(){return L(this,function(e){return[2,F(F(F(F({},St),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=Nn();return{utm_campaign:e[at],utm_content:e[ot],utm_id:e[st],utm_medium:e[ct],utm_source:e[lt],utm_term:e[ut]}},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=Nn();return e={},e[dt]=t[dt],e[ft]=t[ft],e[pt]=t[pt],e[mt]=t[mt],e[ht]=t[ht],e[gt]=t[gt],e[_t]=t[_t],e[vt]=t[vt],e[yt]=t[yt],e[bt]=t[bt],e[xt]=t[xt],e},e}(),ri=`data-amp-mask`,ii=`*****`,ai=/\b(?:\d[ -]*?){13,16}\b/,oi=/(\d{3}-?\d{2}-?\d{4})/g,si=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,ci=function(e,t){var n,r;if(t===void 0&&(t=[]),typeof e!=`string`)return``;var i=e;i=i.replace(ai,ii),i=i.replace(oi,ii),i=i.replace(si,ii);try{for(var a=R(t),o=a.next();!o.done;o=a.next()){var s=o.value;try{i=i.replace(s,ii)}catch{}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i},li=function(e){if(typeof document>`u`||!document.title)return``;var t=document.querySelector(`title`);return t&&t.hasAttribute(`data-amp-mask`)?ii:e?e(document.title):document.title},ui=o((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);break}}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()=>{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})})),X=c(o(((e,t)=>{t.exports=ui().Observable}))());function di(e,t){return new X.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 fi(e,t){return new X.default(function(n){var r=!1,i=new Set,a=function(){var e,t;r=!0;try{for(var n=R(i),a=n.next();!a.done;a=n.next()){var o=a.value;try{o.unsubscribe()}catch{}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},o=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),a())},complete:function(){i.delete(t),!r&&i.size===0&&(n.complete(),a(),r=!0)}});i.add(t)};return o(e),o(t),a})}function pi(e){var t=new Set,n=null;function r(){n?.unsubscribe(),n=null,t.clear()}return new X.default(function(i){return t.add(i),n===null&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var a=R(t),o=a.next();!o.done;o=a.next()){var s=o.value;(i=s.next)==null||i.call(s,e)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},error:function(e){var n,i,a;try{for(var o=R(t),s=o.next();!s.done;s=o.next()){var c=s.value;(a=c.error)==null||a.call(c,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var a=R(t),o=a.next();!o.done;o=a.next()){var s=o.value;(i=s.complete)==null||i.call(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),t.size===0&&n&&(n.unsubscribe(),n=null)}})}var mi=c(o(((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}))()),hi=mi.default||mi,gi=`https://app.amplitude.com`,_i={US:gi,EU:`https://app.eu.amplitude.com`,STAGING:`https://apps.stag2.amplitude.com`},vi=`https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz`,yi=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 bi(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}var xi,Si=`__AMPLITUDE_MESSENGER_INSTANCE__`,Ci=`__AMPLITUDE_MESSENGER__`,wi=function(){function e(e){var t=(e===void 0?{}:e).origin,n=t===void 0?gi:t;this[xi]=!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=bi(),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 n,r,i,a;this.actionHandlers.has(e)&&((a=(i=this.logger)?.warn)==null||a.call(i,`Overwriting existing action handler for: ${e}`)),this.actionHandlers.set(e,t);var o=this.pendingMessages.get(e);if(o){this.pendingMessages.delete(e);try{for(var s=R(o),c=s.next();!c.done;c=s.next()){var l=c.value;t(l)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return I(this,void 0,void 0,function(){var t,n,r;return L(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e),t)return[2,t];n=yi(e).then(function(){}),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t=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),!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=U();e?.[Ci]===this&&delete e[Ci]},e}();xi=Si;function Ti(e){return typeof e==`object`&&!!e&&Si in e&&e[Si]===!0}function Ei(e){var t=U(),n=t?.[Ci];if(Ti(n))return n;var r=new wi(e);return t&&(t[Ci]=r),r}var Di=`__AMPLITUDE_BACKGROUND_CAPTURE__`;function Oi(e,t){var n=e;if(n[Di]!==!0){n[Di]=!0;var r=t?.scriptUrl??vi,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(){var t,n;(n=(t=e.logger)?.debug)==null||n.call(t,`Initializing background capture (external script)`);var o=new URL(r,e.endpoint).toString();e.loadScriptOnce(o).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,{messenger:e,onBackgroundCapture:a}),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 ki={always:`always`,ifEmptyCampaign:`ifEmptyCampaign`},Ai=function(e,t){return typeof e==`boolean`?e:e?.[t]!==!1},ji=function(e){return Ai(e,`attribution`)},Mi=function(e){return Ai(e,`fileDownloads`)},Ni=function(e){return Ai(e,`formInteractions`)},Pi=function(e){return Ai(e,`pageViews`)},Fi=function(e){return Ai(e,`sessions`)},Ii=function(e){return Ai(e,`pageUrlEnrichment`)},Li=function(e){return typeof e==`boolean`?e:typeof e==`object`&&(e.networkTracking===!0||typeof e.networkTracking==`object`)},Ri=function(e){return typeof e==`boolean`?e:typeof e==`object`&&(e.elementInteractions===!0||typeof e.elementInteractions==`object`)},zi=function(e){return typeof e==`boolean`?e:typeof e==`object`&&e.webVitals===!0},Bi=function(e){return typeof e==`boolean`?e:typeof e==`object`&&(e.frustrationInteractions===!0||typeof e.frustrationInteractions==`object`)},Vi=function(e){return typeof e==`boolean`?e:!!(typeof e==`object`&&e&&e.enabled!==!1)},Hi=function(e){if(Ri(e.autocapture)&&typeof e.autocapture==`object`&&typeof e.autocapture.elementInteractions==`object`)return e.autocapture.elementInteractions},Ui=function(e){if(Bi(e.autocapture)&&typeof e.autocapture==`object`&&typeof e.autocapture.frustrationInteractions==`object`)return e.autocapture.frustrationInteractions},Wi=function(e){if(Li(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),F(F({},t),{captureRules:(t?.captureRules)?.map(function(t){var n;if(t.urls?.length&&t.hosts?.length){var r=JSON.stringify(t.hosts),i=JSON.stringify(t.urls);return(n=e.loggerProvider)==null||n.warn(`Found network capture rule with both urls='${i}' and hosts='${r}' set. Definition of urls takes precedence over hosts, so ignoring hosts.`),F(F({},t),{hosts:void 0})}return t})})}},Gi=function(e){var t=function(){return!1},n=void 0,r,i=e.pageCounter;return Pi(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}},Ki=function(e){return ji(e.defaultTracking)&&e.defaultTracking&&typeof e.defaultTracking==`object`&&e.defaultTracking.attribution&&typeof e.defaultTracking.attribution==`object`?F({},e.defaultTracking.attribution):{}},qi=function(e){if(Ni(e.defaultTracking)&&e.defaultTracking&&typeof e.defaultTracking==`object`&&typeof e.defaultTracking.formInteractions==`object`)return e.defaultTracking.formInteractions},Ji=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},Yi=function(e){var t=e;return t&&t._q!==void 0},Xi=`2.39.0`,Zi=`amplitude-ts`,Qi=`Web`,$i=`$remote`,ea=function(){function e(){this.name=`@amplitude/plugin-context-browser`,this.type=`before`,this.library=`${Zi}/${Xi}`,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,r,i;return L(this,function(a){return t=new Date().getTime(),n=this.config.lastEventId??-1,r=e.event_id??n+1,this.config.lastEventId=r,e.time||(this.config.lastEventTime=t),i=F(F(F(F(F(F(F(F({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:Qi}),this.config.trackingOptions.language&&{language:Mn()}),this.config.trackingOptions.ipAddress&&{ip:$i}),{insert_id:zt(),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:r,library:this.library,user_agent:this.userAgent}),[2,i]})})},e}(),ta=1e3,na=function(e){Ye(t,e);function t(t){var n=this,r,i;try{i=U()?.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 r;return I(this,void 0,void 0,function(){var i;return L(this,function(a){switch(a.label){case 0:return Array.isArray(n)&&n.length>ta?(i=n.length-ta,[4,e.prototype.set.call(this,t,n.slice(0,ta))]):[3,2];case 1:return a.sent(),(r=this.loggerProvider)==null||r.error(`Failed to save ${i} events because the queue length exceeded ${ta}.`),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:a.sent(),a.label=4;case 4:return[2]}})})},t}(qn),ra=function(e){Ye(t,e);function t(){return e.call(this,U()?.sessionStorage)||this}return t}(qn),ia=function(e){Ye(t,e);function t(t){t===void 0&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return t.prototype.send=function(e,t,n){return n===void 0&&(n=!1),I(this,void 0,void 0,function(){var r=this;return L(this,function(i){return[2,new Promise(function(i,a){typeof XMLHttpRequest>`u`&&a(Error(`XHRTransport is not supported.`));var o=new XMLHttpRequest;o.open(`POST`,e,!0),o.onreadystatechange=function(){if(o.readyState===r.state.done){var e=o.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch{i(r.buildResponse({code:o.status}))}}};var s={"Content-Type":`application/json`,Accept:`*/*`},c=JSON.stringify(t),l=n&&c.length>=2048&&dr(),u=function(e){var t,n;s=F(F({},r.customHeaders),s);try{for(var i=R(Object.entries(s)),a=i.next();!a.done;a=i.next()){var c=z(a.value,2),l=c[0],u=c[1];o.setRequestHeader(l,u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}o.send(e)};(function(){return I(r,void 0,void 0,function(){var e;return L(this,function(t){switch(t.label){case 0:return l?[4,fr(c)]:[3,2];case 1:return e=t.sent(),e?(s[`Content-Encoding`]=`gzip`,u(e)):u(c),[3,3];case 2:u(c),t.label=3;case 3:return[2]}})})})().catch(a)})]})})},t}(ur),aa=function(e){Ye(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,n){return n===void 0&&(n=!1),I(this,void 0,void 0,function(){var r,i,a,o,s,c,l,u;return L(this,function(d){switch(d.label){case 0:if(typeof fetch>`u`)throw Error(`FetchTransport is not supported`);return r=JSON.stringify(t),i=n&&r.length>=2048&&dr(),a=r,o={"Content-Type":`application/json`,Accept:`*/*`},i?[4,fr(r)]:[3,2];case 1:s=d.sent(),s&&(o[`Content-Encoding`]=`gzip`,a=s),d.label=2;case 2:return o=F(F({},this.customHeaders),o),c={headers:o,body:a,method:`POST`},[4,fetch(e,c)];case 3:return l=d.sent(),[4,l.text()];case 4:u=d.sent();try{return[2,this.buildResponse(JSON.parse(u))]}catch{return[2,this.buildResponse({code:l.status})]}return[2]}})})},t}(ur),oa=function(e){Ye(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 L(this,function(r){return[2,new Promise(function(r,i){var a=U();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}(ur),sa=function(e,t,n){return n===void 0&&(n=!0),I(void 0,void 0,void 0,function(){var r,i,a,o,s,c,l,u,d;return L(this,function(f){switch(f.label){case 0:return r=jn(e),[4,t.getRaw(r)];case 1:return i=f.sent(),i?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:f.sent(),f.label=3;case 3:return a=z(i.split(`.`),6),o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],[2,{deviceId:o,userId:la(s),sessionId:ca(l),lastEventId:ca(d),lastEventTime:ca(u),optOut:!!c}]}})})},ca=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},la=function(e){if(!(!atob||!escape||!e))try{return decodeURIComponent(escape(atob(e)))}catch{return}},Z=`[Amplitude]`;`${Z}`;var ua=`${Z} Form Started`,da=`${Z} Form Submitted`,fa=`${Z} File Downloaded`,pa=`session_start`,ma=`session_end`,ha=`${Z} File Extension`,ga=`${Z} File Name`,_a=`${Z} Link ID`,va=`${Z} Link Text`,ya=`${Z} Link URL`,ba=`${Z} Form ID`,xa=`${Z} Form Name`,Sa=`${Z} Form Destination`,Ca=`cookie`,wa=function(e){var t=e.split(`.`);return t.length<=2?e:t.slice(t.length-2,t.length).join(`.`)},Ta=function(e){return Object.values(e).every(function(e){return!e})},Ea=function(e){var t=F(F({},e),{referring_domain:void 0,referrer:void 0});return Object.values(t).every(function(e){return!e})},Da=function(e,t,n,r,i,a){i===void 0&&(i=!0),e.referrer;var o=e.referring_domain,s=Xe(e,[`referrer`,`referring_domain`]),c=t||{};c.referrer;var l=c.referring_domain,u=Xe(c,[`referrer`,`referring_domain`]),d=n.excludeInternalReferrers;if(d){var f=Ma(d,r);if(!(f instanceof TypeError)&&e.referring_domain&&Ia(e.referring_domain,a)&&(f===`always`||f===`ifEmptyCampaign`&&Ea(e)))return Na(f,e.referring_domain,r),!1}if(Oa(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&&Ta(e)&&t)return r.debug(`This is not a new campaign because this is a direct traffic in the same session.`),!1;var p=JSON.stringify(s)!==JSON.stringify(u),m=wa(o||``)!==wa(l||``),h=!t||p||m;return h?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.`),h},Oa=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})},ka=function(e,t){var n=t.startsWith(`.`)?t:`.${t}`;return!!(e.startsWith(`.`)?e:`.${e}`).endsWith(n)},Aa=function(e,t){var n=F(F({},St),e);return Ht(Object.entries(n).reduce(function(e,n){var r=z(n,2),i=r[0],a=r[1];return e.setOnce(`initial_${i}`,a??t.initialEmptyValue??`EMPTY`),a?e.set(i,a):e.unset(i)},new Ot))},ja=function(e){var t=e;return t?(t.startsWith(`.`)&&(t=t.substring(1)),[RegExp(`${t.replace(`.`,`\\.`)}\$`)]):[]},Ma=function(e,t){if(e===!0)return ki.always;if(typeof e==`object`){var n=e.condition;if(typeof n==`string`&&Object.keys(ki).includes(n))return n;if(n===void 0)return ki.always}var r=`Invalid configuration provided for attribution.excludeInternalReferrers: ${JSON.stringify(e)}`;return t.error(r),TypeError(r)};function Na(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 Pa=`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(`,`),Fa=function(e){var t=e||U()?.location?.hostname;if(!t)return``;var n=t.split(`.`),r=n[n.length-1],i=n[n.length-2];return Pa.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},Ia=function(e,t){var n=U();return n?ka(e,(t||``).trim()||Fa(n.location.hostname)):!1},La=function(e){Ye(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,ee,j,te,M,ne,N,re,ie,ae,oe,se,ce,le,ue,de){r===void 0&&(r=new zn),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=Ca),g===void 0&&(g=new Zt),_===void 0&&(_=G.Warn),y===void 0&&(y=!1),b===void 0&&(b=!1),C===void 0&&(C=``),w===void 0&&(w=`US`),D===void 0&&(D=1800*1e3),O===void 0&&(O=new na({loggerProvider:g})),k===void 0&&(k={ipAddress:!0,language:!0,platform:!0}),A===void 0&&(A=`fetch`),ee===void 0&&(ee=!1),j===void 0&&(j=!0),ie===void 0&&(ie=!0),ae===void 0&&(ae=0),le===void 0&&(le=!1),ue===void 0&&(ue=!1);var P=this;P=e.call(this,{apiKey:t,storageProvider:O,transportProvider:Va(A)})||this,P.apiKey=t,P.appVersion=n,P.cookieOptions=i,P.defaultTracking=a,P.autocapture=o,P.flushIntervalMillis=c,P.flushMaxRetries=l,P.flushQueueSize=u,P.identityStorage=d,P.ingestionMetadata=f,P.instanceName=p,P.loggerProvider=g,P.logLevel=_,P.minIdLength=v,P.offline=y,P.partnerId=x,P.plan=S,P.serverUrl=C,P.serverZone=w,P.sessionTimeout=D,P.storageProvider=O,P.trackingOptions=k,P.transport=A,P.useBatch=ee,P.fetchRemoteConfig=j,P.networkTrackingOptions=N,P.identify=re,P.enableDiagnostics=ie,P.diagnosticsSampleRate=ae,P.diagnosticsClient=oe,P.remoteConfig=se,P.topLevelDomain=ce,P.enableRequestBodyCompression=le,P._enableRequestBodyCompressionExperimental=ue,P.customEnrichment=de,P.version=Xi,P._optOut=!1,P._cookieStorage=r,P.deviceId=s,P.lastEventId=m,P.lastEventTime=h,P.optOut=b,P.deferredSessionId=E,P.sessionId=T,P.pageCounter=M,P.userId=te,P.debugLogsEnabled=ne,P.loggerProvider.enable(ne?G.Debug:P.logLevel),P.networkTrackingOptions=N,P.identify=re,P.enableDiagnostics=ie,P.diagnosticsSampleRate=ae,P.diagnosticsClient=oe;var fe=se?.fetchRemoteConfig??j;return P.remoteConfig=P.remoteConfig||{},P.remoteConfig.fetchRemoteConfig=fe,P.fetchRemoteConfig=fe,P.topLevelDomain=ce||Fa(),P}return Object.defineProperty(t.prototype,`cookieStorage`,{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},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 Vn&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(An(this.apiKey),e)},t}($t),Ra=function(e,t,n,r,i){return t===void 0&&(t={}),I(void 0,void 0,void 0,function(){var a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T;return L(this,function(E){switch(E.label){case 0:return a=t.identityStorage||`cookie`,o=``,a===`cookie`&&!t.cookieOptions?.domain&&t.cookieOptions?.domain!==``?[4,Ha(void 0,r)]:[3,2];case 1:o=E.sent(),E.label=2;case 2:return s=F({domain:t.cookieOptions?.domain??o,expiration:365,sameSite:`Lax`,secure:!1,upgrade:!0},t.cookieOptions),c={duplicateResolverFn:function(e){var t=Wn(e);return t?Gn(JSON.parse(t).cookieDomain,s.domain):!1},diagnosticsClient:r},l=za(t.identityStorage,s,c),[4,sa(e,l,t.cookieOptions?.upgrade??!0)];case 3:return u=E.sent(),[4,l.get(An(e))];case 4:return d=E.sent(),f=Nn(),p=f.ampTimestamp?Number(f.ampTimestamp):void 0,m=p?Date.now()<p:!0,h=t.deviceId??(m?f.ampDeviceId??f.deviceId:void 0)??d?.deviceId??u.deviceId??zt(),g=d?.lastEventId??u.lastEventId,_=d?.lastEventTime??u.lastEventTime,v=t.optOut??d?.optOut??u.optOut,y=d?.sessionId??u.sessionId,b=d?.deferredSessionId,x=t.userId??d?.userId??u.userId,n.previousSessionDeviceId=d?.deviceId??u.deviceId,n.previousSessionUserId=d?.userId??u.userId,S={ipAddress:t.trackingOptions?.ipAddress??!0,language:t.trackingOptions?.language??!0,platform:t.trackingOptions?.platform??!0},C=d?.pageCounter,w=d?.debugLogsEnabled,t.autocapture!==void 0&&(t.defaultTracking=t.autocapture),T=new La(e,t.appVersion,l,s,t.defaultTracking,t.autocapture,h,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,a,t.ingestionMetadata,t.instanceName,g,_,i?.loggerProvider??t.loggerProvider,t.logLevel,t.minIdLength,t.offline,v,t.partnerId,t.plan,t.serverUrl,i?.serverZone??t.serverZone,y,b,t.sessionTimeout,t.storageProvider,S,t.transport,t.useBatch,t.fetchRemoteConfig,x,C,w,t.networkTrackingOptions,t.identify,i?.enableDiagnostics??t.enableDiagnostics,i?.diagnosticsSampleRate??n._diagnosticsSampleRate,r,t.remoteConfig,o,t.enableRequestBodyCompression,n._enableRequestBodyCompressionExperimentalValue,t.customEnrichment),[4,T.storageProvider.isEnabled()];case 5:return E.sent()||(T.loggerProvider.warn(`Storage provider ${T.storageProvider.constructor.name} is not enabled. Falling back to MemoryStorage.`),T.storageProvider=new zn),[2,T]}})})},za=function(e,t,n){switch(e===void 0&&(e=Ca),t===void 0&&(t={}),e){case`localStorage`:return new na;case`sessionStorage`:return new ra;case`none`:return new zn;default:return new Vn(F(F({},t),{expirationDays:t.expiration}),n)}},Ba=function(e){return e===void 0&&(e={}),e.remoteConfig?.fetchRemoteConfig===!0?!0:!(e.remoteConfig?.fetchRemoteConfig===!1||e.fetchRemoteConfig===!1)},Va=function(e){var t=typeof e==`object`?e.type:e,n=typeof e==`object`?e.headers:void 0;return t===`xhr`?new ia(n):t===`beacon`?new oa:new aa(n)},Ha=function(e,t){return I(void 0,void 0,void 0,function(){var n,r,i,a,o,o,s,c,l;return L(this,function(u){switch(u.label){case 0:return[4,new Vn(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!u.sent()||!e&&(typeof location>`u`||!location.hostname)||(n=e??location.hostname,r=n.split(`.`),r.length===1))return[2,``];for(i=[],a=1,Pa.find(function(e){return n.endsWith(`.${e}`)})&&(a=2),o=r.length-a-1;o>=0;--o)i.push(r.slice(o).join(`.`));o=0,u.label=2;case 2:if(!(o<i.length))return[3,7];s=i[o],u.label=3;case 3:return u.trys.push([3,5,,6]),[4,Vn.isDomainWritable(s)];case 4:return c=u.sent(),c?[2,`.`+s]:[3,6];case 5:return l=u.sent(),t&&t.recordEvent(`cookies.tld.failure`,{reason:`Unexpected exception checking domain is writable: ${s}`,error:l instanceof Error?l.message:String(l)}),[3,6];case 6:return o++,[3,2];case 7:return t&&t.recordEvent(`cookies.tld.failure`,{reason:`Could not determine TLD for host ${n}`}),[2,``]}})})},Ua=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Wa=`[Amplitude] Page Viewed`,Ga=`AMP_PAGE_VIEW`,Ka=function(e){e===void 0&&(e={});var t,n=U(),r=void 0,i=!1,a,o,s=e.trackOn,c=e.trackHistoryChanges,l=e.eventType,u=l===void 0?Wa:l,d=function(e){var t=e;try{t=decodeURI(e)}catch(e){r?.error(`Malformed URI sequence: `,e)}return t},f=function(e){return I(void 0,void 0,void 0,function(){var t,n,r;return L(this,function(i){switch(i.label){case 0:return t=d(typeof location<`u`&&location.href||``),r={event_type:u},n=[{}],[4,qa()];case 1:return[2,(r.event_properties=F.apply(void 0,[F.apply(void 0,n.concat([i.sent()])),{"[Amplitude] Page Domain":typeof location<`u`&&location.hostname||``,"[Amplitude] Page Location":t,"[Amplitude] Page Path":typeof location<`u`&&d(location.pathname)||``,"[Amplitude] Page Title":li(ci),"[Amplitude] Page URL":t.split(`?`)[0],"[Amplitude] Page View ID":e}]),r)]}})})},p=function(){return s===void 0||typeof s==`function`&&s()},m=typeof location<`u`?location.href:null,h=function(){return I(void 0,void 0,void 0,function(){var e,n,i,a,s;return L(this,function(l){switch(l.label){case 0:return e=location.href,n=Ya(c,e,m||``)&&p(),m=e,n?(i=void 0,o&&(i=zt(),o.set(Ga,{pageViewId:i})),r?.log(`Tracking page view event`),t==null?[3,3]:[3,1]):[3,4];case 1:return s=(a=t).track,[4,f(i)];case 2:s.apply(a,[l.sent()]),l.label=3;case 3:l.label=4;case 4:return[2]}})})},g=function(){h()};return{name:`@amplitude/plugin-page-view-tracking-browser`,type:`enrichment`,setup:function(e,s){return I(void 0,void 0,void 0,function(){var c,l,u;return L(this,function(d){switch(d.label){case 0:if(t=s,a=e,r=e.loggerProvider,r.log(`Installing @amplitude/plugin-page-view-tracking-browser`),i=!0,n){try{o=new qn(n.sessionStorage)}catch{r?.debug(`sessionStorage is not available in this environment.`)}n.addEventListener(`popstate`,g),n.history.pushState=new Proxy(n.history.pushState,{apply:function(e,t,n){var r=z(n,3),a=r[0],o=r[1],s=r[2];e.apply(t,[a,o,s]),i&&g()}})}return p()?(r.log(`Tracking page view event`),c=void 0,o&&(c=zt(),o.set(Ga,{pageViewId:c})),u=(l=t).track,[4,f(c)]):[3,2];case 1:u.apply(l,[d.sent()]),d.label=2;case 2:return[2]}})})},execute:function(e){return I(void 0,void 0,void 0,function(){var t,n,i;return L(this,function(c){switch(c.label){case 0:return s===`attribution`&&Ja(e)?(r?.log(`Enriching campaign event to page view event with campaign parameters`),t=void 0,o?[4,o.get(Ga)]:[3,2]):[3,4];case 1:n=c.sent(),t=n?.pageViewId,c.label=2;case 2:return[4,f(t)];case 3:i=c.sent(),e.event_type=i.event_type,e.event_properties=F(F({},e.event_properties),i.event_properties),c.label=4;case 4:return a&&e.event_type===u&&(a.pageCounter=a.pageCounter?a.pageCounter+1:1,e.event_properties=F(F({},e.event_properties),{"[Amplitude] Page Counter":a.pageCounter})),[2,e]}})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(e){return n&&(n.removeEventListener(`popstate`,g),i=!1),[2]})})}}},qa=function(){return I(void 0,void 0,void 0,function(){var e;return L(this,function(t){switch(t.label){case 0:return e=Ua,[4,new ni().parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},Ja=function(e){if(e.event_type===`$identify`&&e.user_properties){var t=e.user_properties,n=t[Ze.SET]||{},r=t[Ze.UNSET]||{},i=B(B([],z(Object.keys(n)),!1),z(Object.keys(r)),!1);return Object.keys(St).every(function(e){return i.includes(e)})}return!1},Ya=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}},Xa=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},r=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;t?.removeEventListener(n,r)}),t=[]},i;return{name:`@amplitude/plugin-form-interaction-tracking-browser`,type:`enrichment`,setup:function(t,r){return I(void 0,void 0,void 0,function(){var a,o;return L(this,function(s){return i=qi(t),a=function(){if(!r){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 a=new WeakSet,o=function(e){if(!a.has(e)){a.add(e);var o=!1;n(e,`change`,function(){var t,n=Qa(e);o||r.track(ua,(t={},t[ba]=Za(e.id),t[xa]=Za(e.name),t[Sa]=n,t)),o=!0}),n(e,`submit`,function(n){var a,s,c=Qa(e);if(o||r.track(ua,(a={},a[ba]=Za(e.id),a[xa]=Za(e.name),a[Sa]=c,a)),o=!0,i?.shouldTrackSubmit!==void 0)if(typeof i.shouldTrackSubmit==`function`&&typeof SubmitEvent<`u`&&n instanceof SubmitEvent)try{if(!i.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.`);r.track(da,(s={},s[ba]=Za(e.id),s[xa]=Za(e.name),s[Sa]=c,s)),o=!1})}};Array.from(document.getElementsByTagName(`form`)).forEach(o),typeof MutationObserver<`u`&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){e.nodeName===`FORM`&&o(e),`querySelectorAll`in e&&typeof e.querySelectorAll==`function`&&Array.from(e.querySelectorAll(`form`)).map(o)})})}),e.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState===`complete`?a():(o=U(),o?o.addEventListener(`load`,a):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 L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(t){return e?.disconnect(),r(),[2]})})}}},Za=function(e){if(typeof e==`string`)return e},Qa=function(e){var t=e.getAttribute(`action`);try{t=new URL(encodeURI(t??``),window.location.href).href}catch{}return t},$a=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},r=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;t?.removeEventListener(n,r)}),t=[]};return{name:`@amplitude/plugin-file-download-tracking-browser`,type:`enrichment`,setup:function(t,r){return I(void 0,void 0,void 0,function(){var i,a;return L(this,function(o){return i=function(){if(!r){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 i=function(e){var t;try{t=new URL(e.href,window.location.href)}catch{return}var i=a.exec(t.href)?.[1];i&&n(e,`click`,function(){var n;i&&r.track(fa,(n={},n[ha]=i,n[ga]=t.pathname,n[_a]=e.id,n[va]=e.text,n[ya]=e.href,n))})},a=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName(`a`)).forEach(i),typeof MutationObserver<`u`&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){e.nodeName===`A`&&i(e),`querySelectorAll`in e&&typeof e.querySelectorAll==`function`&&Array.from(e.querySelectorAll(`a`)).map(i)})})}),e.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState===`complete`?i():(a=U(),a?a.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 L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(t){return e?.disconnect(),r(),[2]})})}}},eo=!1,to=function(e){eo||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:
|
|
6
|
+
|
|
7
|
+
amplitude.init(<YOUR_API_KEY>, {
|
|
8
|
+
defaultTracking: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details.`),eo=!0)},no=function(){var e=`@amplitude/plugin-network-checker-browser`,t=`before`,n=U(),r=[],i=function(e,t){n?.addEventListener&&(n?.addEventListener(e,t),r.push({type:e,handler:t}))},a=function(){r.forEach(function(e){var t=e.type,r=e.handler;n?.removeEventListener(t,r)}),r=[]};return{name:e,type:t,setup:function(e,t){return I(void 0,void 0,void 0,function(){return L(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,i(`online`,function(){e.loggerProvider.debug(`Network connectivity changed to online.`),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis)}),i(`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 L(this,function(e){return a(),[2]})})}}};function ro(e){var t,n,r,i,a,o;if(!(typeof e!=`object`||!e)&&!Array.isArray(e)){var s=Object.keys(e);try{for(var c=R(s),l=c.next();!l.done;l=c.next()){var u=l.value;try{var d=e[u];typeof d?.enabled==`boolean`&&(d.enabled?(delete d.enabled,Object.keys(d).length===0&&(e[u]=!0)):e[u]=!1),ro(d)}catch{}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}try{if(e.autocapture?.networkTracking?.captureRules?.length)try{for(var f=R(e.autocapture.networkTracking.captureRules),p=f.next();!p.done;p=f.next()){var m=p.value;try{for(var h=(a=void 0,R([`responseHeaders`,`requestHeaders`])),g=h.next();!g.done;g=h.next()){var _=g.value,v=m[_]??{},y=v.captureSafeHeaders,b=v.allowlist;if(!(!y&&!b)){if(b!==void 0&&!Array.isArray(b)){delete m[_];continue}m[_]=B(B([],z(y?Ct:[]),!1),z(b??[]),!1)}}}catch(e){a={error:e}}finally{try{g&&!g.done&&(o=h.return)&&o.call(h)}finally{if(a)throw a.error}}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}}catch{}var x=e.autocapture?.frustrationInteractions;x&&(x.rageClick&&(x.rageClicks=x.rageClick,delete x.rageClick),x.deadClick&&(x.deadClicks=x.deadClick,delete x.deadClick));try{var S=e.autocapture?.elementInteractions;if(S&&typeof S==`object`&&(S.viewportContentUpdated===!0&&(S.viewportContentUpdated={}),S.viewportContentUpdated===!1&&(S.viewportContentUpdated={enabled:!1}),S.exposureDuration!==void 0)){var C=S.viewportContentUpdated;C===void 0?S.viewportContentUpdated={exposureDuration:S.exposureDuration}:typeof C==`object`&&C.exposureDuration===void 0&&C.enabled!==!1&&(C.exposureDuration=S.exposureDuration),delete S.exposureDuration}}catch{}}}function io(e,t,n){var r,i,a=[];try{for(var o=R(t??[]),s=o.next();!s.done;s=o.next()){var c=s.value;try{a.push(new RegExp(c))}catch(e){n.loggerProvider.warn(`Invalid regex pattern: ${c}`,e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return e.concat(a)}function ao(e,t){var n,r;if(e){ro(e);try{t.loggerProvider.debug(`Update browser config with remote configuration:`,JSON.stringify(e));var i=e;if(i&&`autocapture`in i){if(typeof i.autocapture==`boolean`&&(t.autocapture=i.autocapture),typeof i.autocapture==`object`&&i.autocapture!==null){var a=F({},i.autocapture);if(t.autocapture===void 0&&(t.autocapture=i.autocapture),typeof i.autocapture.elementInteractions==`object`&&i.autocapture.elementInteractions!==null&&i.autocapture.elementInteractions.pageUrlAllowlistRegex?.length){a.elementInteractions=F({},i.autocapture.elementInteractions);var o=a.elementInteractions,s=o.pageUrlAllowlist??[],c=i.autocapture.elementInteractions.pageUrlAllowlistRegex;o.pageUrlAllowlist=io(s,c,t),delete o.pageUrlAllowlistRegex}if(typeof i.autocapture.networkTracking==`object`&&i.autocapture.networkTracking!==null&&i.autocapture.networkTracking.captureRules?.length){a.networkTracking=F({},i.autocapture.networkTracking);var l=a.networkTracking.captureRules??[];try{for(var u=R(l),d=u.next();!d.done;d=u.next()){var f=d.value;f.urls=io(f.urls??[],f.urlsRegex,t),delete f.urlsRegex}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}typeof t.autocapture==`boolean`&&(t.autocapture=F({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},a)),typeof t.autocapture==`object`&&(t.autocapture=F(F({},t.autocapture),a))}t.defaultTracking=t.autocapture}`customEnrichment`in i&&i.customEnrichment!==null&&t.customEnrichment!==!1&&(t.customEnrichment=i.customEnrichment),t.loggerProvider.debug(`Browser config after remote config update:`,JSON.stringify(t))}catch(e){t.loggerProvider.error(`Failed to apply remote configuration because of error: `,e)}}}var oo=`1.25.2`,so=`@amplitude/plugin-autocapture-browser`,co=`@amplitude/plugin-frustration-browser`,lo=`[Amplitude] Dead Click`,uo=`[Amplitude] Rage Click`,fo=`[Amplitude] Error Click`,po=`[Amplitude] Thrashed Cursor`,mo=`[Amplitude] Element ID`,ho=`[Amplitude] Element Class`,go=`[Amplitude] Element Tag`,_o=`[Amplitude] Element Text`,vo=`[Amplitude] Element Hierarchy`,yo=`[Amplitude] Element Href`,bo=`[Amplitude] Element Position Left`,xo=`[Amplitude] Element Position Top`,So=`[Amplitude] Element Aria Label`,Co=`[Amplitude] Element Attributes`,wo=`[Amplitude] Element Path`,To=`[Amplitude] Element Parent Label`,Eo=`[Amplitude] Page URL`,Do=`[Amplitude] Page Title`,Oo=`[Amplitude] Viewport Height`,ko=`[Amplitude] Viewport Width`,Ao=`[Amplitude] Max Page X`,jo=`[Amplitude] Max Page Y`,Mo=`[Amplitude] Page View ID`,No=`https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz`,Po=`amp-visual-tagging-selector-highlight`,Fo=`data-amp-mask-attributes`,Io=`AMP_PAGE_VIEW`,Lo=[`input`,`select`,`textarea`],Ro=function(e,t){return((window==null?void 0:window.getComputedStyle)?.call(window,e))?.getPropertyValue(`cursor`)===`pointer`&&t===`click`},zo=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&Fn(window.location.href,n)||!Fn(window.location.href,t))},Bo=function(e,t,n){return n===void 0&&(n=!1),function(r,i){var a,o=e.shouldTrackEventResolver,s=((a=i?.tagName)?.toLowerCase)?.call(a);if(!s)return!1;if(o)return o(r,i);if(!zo(e))return!1;var c=String(i?.getAttribute(`type`))||``;if(typeof c==`string`)switch(c.toLowerCase()){case`hidden`:return!1;case`password`:return!1}var l=Ro(i,r);if(n&&l)return!0;if(t&&!t.some(function(e){return!!(i?.matches)?.call(i,e)}))return!1;switch(s){case`input`:case`select`:case`textarea`:return r===`change`||r===`click`;default:return l?!0:r===`click`}}},Vo=function(e){var t,n=((t=e?.tagName)?.toLowerCase)?.call(t),r=e instanceof HTMLElement?e.getAttribute(`contenteditable`)?.toLowerCase()===`true`:!1;return!Lo.includes(n)&&!r},Ho=function(e){return e?e.split(`,`).map(function(e){return e.trim()}).filter(function(e){return e.length>0&&e!==`id`&&e!==`class`}):[]},Uo=function(e,t){return Object.entries(e).reduce(function(e,n){var r=z(n,2),i=r[0],a=r[1];if(i.startsWith(t)){var o=i.replace(t,``);o&&(e[o]=a||``)}return e},{})},Wo=function(e){return e==null||typeof e==`object`&&Object.keys(e).length===0||typeof e==`string`&&e.trim().length===0},Go=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return Wo(r)||(t[n]=r),t},{})},Ko=function(){try{var e=(U()?.sessionStorage)?.getItem(Io);if(!e)return;var t=JSON.parse(e);if(typeof t.pageViewId==`string`)return t.pageViewId}catch{}},qo=function(e,t){return e?t.some(function(t){return(e?.matches)?.call(e,t)})?e:qo(e?.parentElement,t):null},Jo=function(e){return!(e.event.target===null||!e.closestTrackedAncestor)};function Yo(e){return e.type===`click`||e.type===`change`}var Xo;(function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]=`LEFT_OR_TOUCH_CONTACT`,e[e.MIDDLE=1]=`MIDDLE`,e[e.RIGHT=2]=`RIGHT`})(Xo||={});var Zo=`__AMPLITUDE_VISUAL_TAGGING__`;function Qo(e,t){var n=e;if(n[Zo]!==!0){n[Zo]=!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(No).then(function(){s=(window==null?void 0:window.amplitudeVisualTaggingSelector)?.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return i?i(t?.actionType||`click`,e):!0},onTrack:l,onSelect:c,visualHighlightClass:Po,messenger:e,cssSelectorAllowlist:a,actionClickAllowlist:o,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:oo}}}),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 $o(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(Jo).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 es(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,a=e.evaluateTriggers;return n.changeObservable.filter(Jo).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 ts(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=fi(s.filter(function(e){return!a(`click`,e.closestTrackedAncestor)}).map(function(e){return e.closestTrackedAncestor=qo(e.event.target,r.actionClickAllowlist),e.closestTrackedAncestor!==null&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(Jo).filter(function(e){return o(`click`,e.closestTrackedAncestor)}),l?fi(c,l):c),d=null,f=null;return di(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 ns(e){e.amplitude;var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe(function(){var e=U(),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 rs=U(),is=function(){return new X.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()}})},as=function(e){return e===void 0&&(e=`click`),new X.default(function(t){var n,r=function(e){t.next(e)};return(n=U())==null||n.document.addEventListener(e,r,{capture:!0}),function(){var t;(t=U())==null||t.document.removeEventListener(e,r,{capture:!0})}})},os=function(){return new X.default(function(e){var t,n=function(t){e.next(t)};return(t=U())==null||t.addEventListener(`scroll`,n),function(){var e;(e=U())==null||e.removeEventListener(`scroll`,n)}})},ss=function(){return new X.default(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&typeof n[0][0]==`string`&&(i=n[0][0]),e.next({kind:`console`,message:i})};return Er.addListener(`error`,t),function(){Er.removeListener(t)}})},cs=function(e,t){return new X.default(function(n){var r=U();if(!r?.IntersectionObserver)return function(){};var i=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:`0px`,threshold:1}),a=t.join(`,`);(r?.document.querySelectorAll(a)??[]).forEach(function(e){i.observe(e)});var o=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){e instanceof Element&&(e.matches(a)&&i.observe(e),e.querySelectorAll(a).forEach(function(e){i.observe(e)}))})})});return function(){o.unsubscribe(),i.disconnect()}})},ls=function(){return new X.default(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:`error`};t.error instanceof Error||t.error instanceof DOMException?n=F(F({},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 rs.addEventListener(`error`,t),function(){rs.removeEventListener(`error`,t)}})},us=function(){return new X.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 rs.addEventListener(`unhandledrejection`,t),function(){rs.removeEventListener(`unhandledrejection`,t)}})},ds=function(){return fi(fi(ls(),us()),ss())},fs=function(){return new X.default(function(e){var t=function(t){e.next(t)},n={capture:!0};return rs.document.addEventListener(`mousemove`,t,n),function(){rs.document.removeEventListener(`mousemove`,t,n)}})},ps=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},ms=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}},hs=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}})},gs={"[Amplitude] Element Clicked":`click`,"[Amplitude] Element Changed":`change`},_s=function(e){var t,n,r,i,a=Object.values(gs).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return a;try{for(var o=R(e),s=o.next();!s.done;s=o.next()){var c=s.value;try{try{for(var l=(r=void 0,R(c.definition)),u=l.next();!u.done;u=l.next()){var d=gs[u.value.event_type];d&&a[d].add(c.id)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}catch(e){console.warn(`Skipping Labeled Event due to malformed definition`,c?.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},vs=function(e){var t,n,r,i,a=new Map;try{for(var o=R(e),s=o.next();!s.done;s=o.next()){var c=s.value;try{for(var l=(r=void 0,R(c.conditions)),u=l.next();!u.done;u=l.next()){var d=u.value;if(d.type===`LABELED_EVENT`){var f=d.match.eventId,p=a.get(f);p||(p=[],a.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},ys=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return gs[t.event_type]===e.type&&t.filters.every(function(t){return ps(e,t)})})})},bs=function(e,t){var n,r,i,a,o=new Set;try{for(var s=R(e),c=s.next();!c.done;c=s.next()){var l=c.value,u=t.get(l.id);if(u)try{for(var d=(i=void 0,R(u)),f=d.next();!f.done;f=d.next()){var p=f.value;o.add(p)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(o)},xs=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=bs(ys(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var a=R(i),o=a.next();!o.done;o=a.next()){var s=o.value;hs(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}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}(),Ss=function(e,t,n,r){return new xs(e,t,n,r)},Cs=new Set([`id`,`class`,`style`,`value`,`onclick`,`onchange`,`oninput`,`onblur`,`onsubmit`,`onfocus`,`onkeydown`,`onkeyup`,`onkeypress`,`data-reactid`,`data-react-checksum`,`data-reactroot`,Fo,ri]),ws=[`type`],Ts=[`svg`,`path`,`g`],Es=[`password`,`hidden`];function Ds(e,t){var n,r;if(e===null)return null;var i=String(e.tagName).toLowerCase(),a={tag:i},o=Array.from(e.parentElement?.children??[]);o.length&&(a.index=o.indexOf(e),a.indexOfType=o.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var s=(e.previousElementSibling?.tagName)?.toLowerCase();s&&(a.prevSib=String(s));var c=e.getAttribute(`id`);c&&(a.id=String(c));var l=Array.from(e.classList);l.length&&(a.classes=l);var u={},d=Array.from(e.attributes).filter(function(e){return!Cs.has(e.name)}),f=!Vo(e);if(!Es.includes(String(e.getAttribute(`type`)))&&!Ts.includes(i))try{for(var p=R(d),m=p.next();!m.done;m=p.next()){var h=m.value;if(!(f&&!ws.includes(h.name))){if(t.has(h.name)){u[h.name]=ii;continue}u[h.name]=String(h.value).substring(0,128)}}}catch(e){n={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}return Object.keys(u).length&&(a.attrs=u),a}function Os(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&n.tagName!==`HTML`;)t.push(n),n=n.parentElement;return t}var ks=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),As=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return``;for(var n=[],r=e;r;){var i=js(r,!!t,r===e);if(!i||(n.push(i),i.optimized))break;r=r.parentElement}return n.reverse(),n.join(` > `)},js=function(e,t,n){var r,i;if(e.nodeType!==Node.ELEMENT_NODE)return null;var a=e.getAttribute(`id`);if(t){if(a)return new ks(u(a),!0);var o=e.tagName.toLowerCase();if(o===`body`||o===`head`||o===`html`)return new ks(o,!0)}var s=e.tagName.toLowerCase();if(a)return new ks(s+u(a),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new ks(s,!0);function l(e){var t=e.getAttribute(`class`);return t?t.split(/\s+/g).filter(Boolean).map(function(e){return`$`+e}):[]}function u(e){return`#`+CSS.escape(e)}for(var d=l(e),f=!1,p=!1,m=-1,h=-1,g=c.children,_=0;g&&(m===-1||!p)&&_<g.length;++_){var v=g[_];if(v.nodeType===Node.ELEMENT_NODE){if(h+=1,v===e){m=h;continue}if(!p&&v.tagName.toLowerCase()===s){f=!0;var y=new Set(d);if(!y.size){p=!0;continue}for(var b=l(v),x=0;x<b.length;++x){var S=b[x];if(y.has(S)&&(y.delete(S),!y.size)){p=!0;break}}}}}var C=s;if(n&&s.toLowerCase()===`input`&&e.getAttribute(`type`)&&!e.getAttribute(`id`)&&!e.getAttribute(`class`)&&(C+=`[type=`+CSS.escape(e.getAttribute(`type`)||``)+`]`),p)C+=`:nth-child(`+String(m+1)+`)`;else if(f)try{for(var w=R(d),T=w.next();!T.done;T=w.next()){var E=T.value;C+=`.`+CSS.escape(E.slice(1))}}catch(e){r={error:e}}finally{try{T&&!T.done&&(i=w.return)&&i.call(w)}finally{if(r)throw r.error}}return new ks(C,!1)},Ms=function(){function e(e,t){var n,r,i=this;this.replaceSensitiveString=function(e){return ci(e,i.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,a=performance.now(),o=[];if(!e)return[];for(var s=Os(e),c=new Map,l=s.length-1;l>=0;l--){var u=s[l];if(u){var d=Ho(u.getAttribute(Fo)),f=l===s.length-1?[]:c.get(s[l+1])??new Set,p=new Set(B(B([],z(f),!1),z(d),!1));c.set(u,p)}}o=s.map(function(e){return Ds(e,c.get(e)??new Set)});var m=function(e){e?.attrs&&Object.entries(e.attrs).forEach(function(t){var n=z(t,2),r=n[0],a=n[1];e.attrs&&(e.attrs[r]=i.replaceSensitiveString(a))})};try{for(var h=R(o),g=h.next();!g.done;g=h.next()){var _=g.value;m(_)}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var v=performance.now();return(r=i.diagnosticsClient)==null||r.recordHistogram(`autocapturePlugin.getHierarchy`,v-a),o},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?i.getText(n):i.getNearestLabel(t)},this.getElementPath=function(e){var t;if(!e)return``;var n=performance.now(),r=As(e),a=performance.now();return(t=i.diagnosticsClient)==null||t.recordHistogram(`autocapturePlugin.getElementPath`,a-n),r},this.getEventProperties=function(e,t,n){var r,a,o=((a=t?.tagName)?.toLowerCase)?.call(a),s=typeof t.getBoundingClientRect==`function`?t.getBoundingClientRect():{left:null,top:null},c=i.getHierarchy(t),l=c[0]?.attrs,u=i.getNearestLabel(t),d=Uo(l??{},n),f=(r={},r[vo]=c,r[go]=o,r[_o]=i.getText(t),r[bo]=s.left==null?null:Math.round(s.left),r[xo]=s.top==null?null:Math.round(s.top),r[Co]=d,r[wo]=i.getElementPath(t),r[To]=u,r[Eo]=In(window.location.href.split(`?`)[0]),r[Do]=li(i.replaceSensitiveString),r[Oo]=window.innerHeight,r[ko]=window.innerWidth,r),p=Ko();if(p&&(f[Mo]=p),f[mo]=t.getAttribute(`id`)||``,f[ho]=t.getAttribute(`class`),f[So]=l?.[`aria-label`],o===`a`&&e===`click`&&t instanceof HTMLAnchorElement){var m=t.href.substring(0,128);f[yo]=i.replaceSensitiveString(m)}return Go(f)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,a){a===void 0&&(a=!1);var o=i.addTypeAndTimestamp(e,t);if(Yo(o)&&o.event.target!==null){if(a&&Ro(o.event.target,o.type))return o.closestTrackedAncestor=o.event.target,o.targetElementProperties=i.getEventProperties(o.type,o.closestTrackedAncestor,r),o;var s=qo(o.event.target,n);return s&&(o.closestTrackedAncestor=s,o.targetElementProperties=i.getEventProperties(o.type,s,r)),o}return o},this.extractDataFromDataSource=function(e,t){if(e.sourceType===`DOM_ELEMENT`){var n=ms(e,t);return n?e.elementExtractType===`TEXT`?i.getText(n):e.elementExtractType===`ATTRIBUTE`&&e.attribute?n.getAttribute(e.attribute):void 0:void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r=`[${ri}], [contenteditable]`;if(!e.querySelector(r))return e.innerText;var a=``,o=Array.from(e.childNodes);try{for(var s=R(o),c=s.next();!c.done;c=s.next()){var l=c.value;if(l.nodeType===Node.TEXT_NODE){a+=l.textContent||``;continue}if(l instanceof Element){if(l.hasAttribute(`data-amp-mask`)||l.hasAttribute(`contenteditable`)){a+=ii;continue}a+=i.getTextWithMaskedDescendants(l)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return a},this.getText=function(e){if(e.closest(`[data-amp-mask]`)!==null)return ii;var t=``;return t=e.querySelector(`[data-amp-mask], [contenteditable]`)?i.getTextWithMaskedDescendants(e):e.innerText||``,i.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 Go((t={},t[go]=r,t[_o]=i.getText(e),t[Eo]=window.location.href.split(`?`)[0],t))},this.diagnosticsClient=t?.diagnosticsClient;var a=e.maskTextRegex??[],o=[];try{for(var s=R(a),c=s.next();!c.done;c=s.next()){var l=c.value;if(o.length>=25)break;if(l instanceof RegExp)o.push(l);else if(`pattern`in l&&typeof l.pattern==`string`)try{o.push(new RegExp(l.pattern,`i`))}catch{}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=o}return e}();function Ns(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=t.exposureObservable.subscribe(function(e){var t=e,i=t.target;if(t.isIntersecting){if(!o.get(i)){var c=setTimeout(function(){o.set(i,!0),n(r.getElementPath(i)),s.set(i,null)},a);s.set(i,c)}}else if(!t.isIntersecting&&t.intersectionRatio<1){var c=s.get(i);c&&(clearTimeout(c),s.set(i,null))}});return{unsubscribe:function(){c.unsubscribe()},reset:function(){s.forEach(function(e){e&&clearTimeout(e)}),s.clear(),o.clear()}}}function Ps(e){var t,n=e.amplitude,r=e.scrollTracker,i=e.currentElementExposed,a=e.elementExposedForPage,o=e.exposureTracker,s=e.isPageEnd,c=e.lastScroll,l=r.getState(),u=U(),d=u?.innerWidth??0,f=u?.innerHeight??0,p=(t={},t[Eo]=u?.location?.href,t[Ao]=l.maxX+d,t[jo]=l.maxY+f,t[Oo]=f,t[ko]=d,t[`[Amplitude] Element Exposed`]=Array.from(i),t),m=Ko();if(m&&(p[Mo]=m),i.size===0&&l.maxX===c.maxX&&l.maxY===c.maxY){s&&(r.reset(),a.clear(),o?.reset());return}n?.track(`[Amplitude] Viewport Content Updated`,p),c.maxX=l.maxX,c.maxY=l.maxY,i.clear(),s&&(r.reset(),a.clear(),o?.reset())}function Fs(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}var Q;(function(e){e.ClickObservable=`clickObservable`,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 Is=function(e,t){e===void 0&&(e={}),t?.diagnosticsClient.setTag(`plugin.autocapture.version`,`1.25.2`);var n=e.dataAttributePrefix,r=n===void 0?Or:n,i=e.visualTaggingOptions,a=i===void 0?{enabled:!0}:i;e.cssSelectorAllowlist=e.cssSelectorAllowlist??Dr,e.actionClickAllowlist=e.actionClickAllowlist??kr,e.debounceTime=e.debounceTime??0;var o=e.viewportContentUpdated?.enabled!==!1,s=e.viewportContentUpdated?.exposureDuration??e.exposureDuration??150;e.viewportContentUpdated=F(F({},e.viewportContentUpdated),{exposureDuration:s}),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 c=so,l=`enrichment`,u=[],d=new Ms(e,t),f=new Set,p=new Set,m,h=function(){var t,n=pi(as().map(function(t){return d.addAdditionalEventProperties(t,`click`,e.cssSelectorAllowlist,r)})),i=pi(new X.default(function(t){var n,i=function(n){var i=d.addAdditionalEventProperties(n,`change`,e.cssSelectorAllowlist,r);t.next(i)};return(n=U())==null||n.document.addEventListener(`change`,i,{capture:!0}),function(){return U()?.document.removeEventListener(`change`,i)}})),a;window.navigation&&(a=pi(new X.default(function(t){var n=function(n){var i=d.addAdditionalEventProperties(n,`navigate`,e.cssSelectorAllowlist,r);t.next(i)};return window.navigation.addEventListener(`navigate`,n),function(){window.navigation.removeEventListener(`navigate`,n)}})));var o=pi(is().map(function(t){return d.addAdditionalEventProperties(t,`mutation`,e.cssSelectorAllowlist,r)})),s=os(),c=cs(o,e.cssSelectorAllowlist);return t={},t[Q.ChangeObservable]=i,t[Q.ClickObservable]=n,t[Q.MutationObservable]=o,t[Q.NavigateObservable]=a,t[Q.ScrollObservable]=s,t[Q.ExposureObservable]=c,t},g=_s(Object.values(e.pageActions?.labeledEvents??{})),_=vs(e.pageActions?.triggers??[]),v=Ss(g,_,d,e),y=function(t){t&&(e.pageActions=F(F({},e.pageActions),t),g=_s(Object.values(e.pageActions.labeledEvents??{})),_=vs(e.pageActions.triggers??[]),v.update(g,_,e))};return{name:c,type:l,setup:function(t,n){return I(void 0,void 0,void 0,function(){var i,l,g,_,b,x,S,C,w,T,E,D,O,k,A,ee,j,te,M,ne,N;return L(this,function(re){return typeof document>`u`?[2]:(i=!1,l={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe(`configs.analyticsSDK.pageActions`,`all`,function(e){y(e)}):t.loggerProvider.debug(`Remote config client is not provided, skipping remote config fetch`)),g=Bo(e,e.cssSelectorAllowlist),_=Bo(e,e.actionClickAllowlist),b=h(),x=$o({allObservables:b,amplitude:n,shouldTrackEvent:g,evaluateTriggers:v.evaluate.bind(v)}),u.push(x),S=es({allObservables:b,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.getEventProperties.apply(d,B(B([],z(e),!1),[r],!1))},amplitude:n,shouldTrackEvent:g,evaluateTriggers:v.evaluate.bind(v)}),u.push(S),C=ts({allObservables:b,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.getEventProperties.apply(d,B(B([],z(e),!1),[r],!1))},amplitude:n,shouldTrackEvent:g,shouldTrackActionClick:_}),C&&u.push(C),w=ns({allObservables:b,amplitude:n}),u.push(w),T={},E=U(),D=function(e){e&&i||(setTimeout(function(){i=!1},100),i=!0,Ps({amplitude:n,scrollTracker:w,currentElementExposed:p,elementExposedForPage:f,exposureTracker:T.exposure,isPageEnd:e,lastScroll:l}))},O=function(e){Fs(e,f,p,D)},o&&(T.exposure=Ns({allObservables:b,onExposure:O,dataExtractor:d,exposureDuration:s}),T.exposure&&u.push(T.exposure),k=function(){D(!0)},E?.addEventListener(`beforeunload`,k),m=function(){E?.removeEventListener(`beforeunload`,k)},u.push({unsubscribe:function(){return m()}}),A=b[Q.NavigateObservable],A?u.push(A.subscribe(function(){D(!0)})):E&&(ee=function(){D(!0)},E.addEventListener(`popstate`,ee),j=E.history.pushState,E.history&&j&&(E.history.pushState=new Proxy(j,{apply:function(e,t,n){var r=z(n,3),i=r[0],a=r[1],o=r[2];e.apply(t,[i,a,o]),D(!0)}})),u.push({unsubscribe:function(){E.removeEventListener(`popstate`,ee),E.history&&j&&(E.history.pushState=j)}}))),(N=t?.loggerProvider)==null||N.log(`${c} has been successfully added.`),window.opener&&a.enabled&&(te=e.cssSelectorAllowlist,M=e.actionClickAllowlist,ne=Ei(),Qo(ne,{dataExtractor:d,isElementSelectable:Bo(e,B(B([],z(te),!1),z(M),!1)),cssSelectorAllowlist:te,actionClickAllowlist:M}),Oi(ne),ne.setup(F({logger:t?.loggerProvider},t?.serverZone&&{endpoint:_i[t.serverZone]}))),[2])})})},execute:function(e){return I(void 0,void 0,void 0,function(){return L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){var e,t,n,r,i;return L(this,function(a){try{for(e=R(u),t=e.next();!t.done;t=e.next())n=t.value,n.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]})})}}},Ls=3e3,Rs=[`mutation`,`navigate`];function zs(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,a=n.clickObservable,o=n.mutationObservable,s=n.navigateObservable,c=fi(a.filter(function(e){return Jo(e)&&i(`click`,e.closestTrackedAncestor)&&e.event.target instanceof Element&&e.event.target.closest(`a[target="_blank"]`)===null&&e.event.button===Xo.LEFT_OR_TOUCH_CONTACT}),s?fi(o,s):o),l=null;return di(c,function(e){return l&&Rs.includes(e.type)?(clearTimeout(l),l=null,Promise.resolve(null)):e.type===`click`?l?Promise.resolve(null):new Promise(function(t){l=setTimeout(function(){t(e),l=null},Ls)}):Promise.resolve(null)}).subscribe(function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track(lo,F(F({},r(`click`,e.closestTrackedAncestor)),n),{time:e.timestamp})}})}var Bs=4,Vs=Pr,Hs=50;function Us(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>Hs||e.xMax-e.xMin>Hs}function Ws(e){if(e.length===0)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:F({"[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 Gs(e,t){var n=e[Math.max(0,e.length-Bs+1)];return t.timestamp-n.timestamp>=Vs}function Ks(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}function qs(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,a=r.clickObservable,o=r.selectionObservable,s=[],c={},l=null;function u(e){s=[],c={},e&&(Us(c,e),s.push(e))}var d=di(a.filter(function(e){return i(`click`,e.closestTrackedAncestor)}),function(e){return I(t,void 0,void 0,function(){var t;return L(this,function(n){return Us(c,e),t=null,s.length===0||Ks(s,e)||Gs(s,e)||c.isOutOfBounds?(l&&(t=Ws(s)),u(e)):s.push(e),l&&=(clearTimeout(l.timerId),l.resolve(t),null),s.length>=Bs?[2,new Promise(function(e){l={resolve:e,timerId:setTimeout(function(){e(Ws(s))},Vs)}})]:[2,null]})})}),f=o?.subscribe(function(){u()}),p=d.subscribe(function(e){e!==null&&n.track(uo,e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){p.unsubscribe(),f?.unsubscribe()}}}var Js=2e3;function Ys(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.clickObservable,a=n.browserErrorObservable,o=i.filter(function(e){return Jo(e)&&r(`click`,e.closestTrackedAncestor)&&e.event.target instanceof Element&&e.event.target.closest(`a[target="_blank"]`)===null&&e.event.button===Xo.LEFT_OR_TOUCH_CONTACT}),s=null,c=null,l=function(){s!==null&&(clearTimeout(s),s=null),c=null};return fi(o,a).subscribe(function(e){var n;if(e.type===`click`){l(),c=e,s=setTimeout(l,Js);return}e.type===`error`&&c&&(t.track(fo,F((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),c.targetElementProperties)),l())})}var Xs;(function(e){e.INCREASING=`increasing`,e.DECREASING=`decreasing`})(Xs||={});var Zs;(function(e){e.X=`x`,e.Y=`y`})(Zs||={});var Qs=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new X.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===Xs.DECREASING&&e.next(Zs.X),r=Xs.INCREASING):a.x<n.x&&(r===Xs.INCREASING&&e.next(Zs.X),r=Xs.DECREASING),a.y>n.y?(i===Xs.DECREASING&&e.next(Zs.Y),i=Xs.INCREASING):a.y<n.y&&(i===Xs.INCREASING&&e.next(Zs.Y),i=Xs.DECREASING),n=a})})};function $s(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 tc(e){e.changes=[],e.startTime=void 0}function nc(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 rc(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 ic=20,ac=2e3,oc=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=n===void 0?ic:n,i=e.thresholdMs,a=i===void 0?ac:i;return new X.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),tc(n),tc(i))}return t.subscribe(function(e){s!==null&&clearTimeout(s),$s(e===Zs.X?n:i);var t=rc(n,i);return t?(o||=t,s=setTimeout(function(){c(),s=null},a)):c(),nc(n),nc(i),function(){s!==null&&(clearTimeout(s),s=null)}})})},sc=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,a=i===void 0?ic:i,o=e.thresholdMs,s=o===void 0?ac:o;return oc({mouseDirectionChangeObservable:Qs({allWindowObservables:r}),directionChanges:a,thresholdMs:s}).subscribe(function(e){zo(n)&&t.track(po,void 0,{time:e})})};function cc(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 lc=5,uc=4e3,dc=function(e){e===void 0&&(e={});var t=co,n=`enrichment`,r=[],i=e.errorClicks!==!1;e.errorClicks||(i=!1);var a=e.deadClicks!==!1&&e.deadClicks!==null,o=e.rageClicks!==!1&&e.rageClicks!==null,s=e.thrashedCursor!==!1&&e.thrashedCursor!==null;e.thrashedCursor||(s=!1);var c=cc(e,`rageClicks`,Nr,o),l=cc(e,`deadClicks`,jr,a),u=cc(e,`errorClicks`,Mr,i),d=e.dataAttributePrefix??Or,f=new Ms(e),p=B([],z(new Set(B(B(B([],z(c),!1),z(l),!1),z(u),!1))),!1),m=function(){var e,t=pi(as(`pointerdown`).map(function(e){return f.addAdditionalEventProperties(e,`click`,p,d,!0)})),n=pi(ds().map(function(e){return f.addTypeAndTimestamp(e,`error`)})),r=pi(is().map(function(e){return f.addAdditionalEventProperties(e,`mutation`,p,d)})),i;window.navigation&&(i=pi(new X.default(function(e){var t=function(t){e.next(F(F({},t),{type:`navigate`}))};return window.navigation.addEventListener(`navigate`,t),function(){window.navigation.removeEventListener(`navigate`,t)}}).map(function(e){return f.addAdditionalEventProperties(e,`navigate`,p,d)})));var a=pi(new X.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)}})),o=pi(fs());return e={},e[Q.ClickObservable]=t,e[Q.MutationObservable]=r,e[Q.NavigateObservable]=i,e[Q.BrowserErrorObservable]=n,e[Q.SelectionObservable]=a,e[Q.MouseMoveObservable]=o,e};return{name:t,type:n,setup:function(n,p){return I(void 0,void 0,void 0,function(){var h,g,_,v,y,b,x,S,C,w,T;return L(this,function(E){return typeof document>`u`?[2]:(h=m(),o&&(g=Bo(e,c),_=qs({allObservables:h,amplitude:p,shouldTrackRageClick:g}),r.push(_)),a&&(v=Bo(e,l),y=zs({amplitude:p,allObservables:h,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:v}),r.push(y)),i&&(b=Bo(e,u),x=Ys({amplitude:p,allObservables:h,shouldTrackErrorClick:b}),r.push(x)),s&&(S=void 0,C=void 0,typeof e.thrashedCursor==`object`&&(S=e.thrashedCursor.directionChanges,C=e.thrashedCursor.threshold,S&&S<lc&&(n.loggerProvider.warn(`'thrashedCursor.directionChanges' of ${S} is below the minimum of ${lc}, setting to ${lc}`),S=lc),C&&C>uc&&(n.loggerProvider.warn(`'thrashedCursor.threshold' of ${C} is above the maximum of ${uc}, setting to ${uc}`),C=uc)),w=sc({amplitude:p,options:e,allObservables:h,directionChanges:S,thresholdMs:C}),r.push(w)),(T=n?.loggerProvider)==null||T.log(`${t} has been successfully added.`),[2])})})},execute:function(e){return I(void 0,void 0,void 0,function(){return L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){var e,t,n,i,a;return L(this,function(o){try{for(e=R(r),t=e.next();!t.done;t=e.next())n=t.value,n.unsubscribe()}catch(e){i={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(i)throw i.error}}return[2]})})}}},fc=`@amplitude/plugin-network-capture-browser`,pc=`500-599`;function mc(e,t){var n=`^`+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,`\\$&`).replace(/\*/g,`.*`)+`$`;return new RegExp(n).test(e)}function hc(e,t){var n,r,i=t.split(`,`);try{for(var a=R(i),o=a.next();!o.done;o=a.next()){var s=o.value,c=z(s.split(`-`).map(Number),2),l=c[0],u=c[1];if(e===l&&u===void 0||e>=l&&e<=u)return!0}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return!1}function gc(e,t,n,r,i){if(!(e.hosts&&!e.hosts.find(function(e){return mc(t,e)}))&&!(r&&e.urls&&!Fn(r,e.urls))&&!(i&&e.methods&&!e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||e===`*`})))return!((n||n===0)&&!hc(n,e.statusCodeRange||pc))}function _c(e){if(e)try{var t=U()?.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{return}}function vc(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 yc(e){if(typeof e!=`object`||!e)return e?B([],z(Ct),!1):void 0;if(e.length!==0)return e}function bc(e){return!e?.allowlist?.length&&!e?.blocklist?.length}function xc(e,t){t===void 0&&(t={});var n=_c(e.url);if(!n)return!1;var r=n.host;if(t.ignoreAmplitudeRequests!==!1&&(mc(r,`*.amplitude.com`)||mc(r,`amplitude.com`))||t.ignoreHosts?.find(function(e){return mc(r,e)})||!t.captureRules&&e.status!==void 0&&!hc(e.status,pc))return!1;if(t.captureRules){var i;if(B([],z(t.captureRules),!1).reverse().find(function(t){if(i=gc(t,r,e.status,e.url,e.method),i){var n=yc(t.responseHeaders);if(e.responseWrapper&&n){var a=e.responseWrapper.headers(n);a&&(e.responseHeaders=a)}var o=yc(t.requestHeaders);if(e.requestWrapper&&o){var s=e.requestWrapper.headers(o);s&&(e.requestHeaders=s)}e.responseWrapper&&t.responseBody&&!bc(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!bc(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return i!==void 0}),!i)return!1}return!(e.requestWrapper&&vc(r,e.requestWrapper))}function Sc(e,t,n,r){return I(this,void 0,void 0,function(){var i,a,o;return L(this,function(s){switch(s.label){case 0:return t.requestBodyJson||t.responseBodyJson?[4,Promise.all([t.requestBodyJson,t.responseBodyJson])]:[3,2];case 1:if(i=z.apply(void 0,[s.sent(),2]),a=i[0],o=i[1],a)try{e[`[Amplitude] Request Body`]=JSON.stringify(a)}catch(e){r?.debug(`Failed to stringify request body`,e)}if(o)try{e[`[Amplitude] Response Body`]=JSON.stringify(o)}catch{r?.debug(`Failed to stringify response body`)}s.label=2;case 2:return n?.track(`[Amplitude] Network Request`,e),[2]}})})}function Cc(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return xc(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;Sc((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 wc;(function(e){e.NetworkObservable=`networkObservable`})(wc||={});var Tc,Ec=function(e){e===void 0&&(e={});var t=fc,n=`enrichment`,r,i=function(e,t){return{event:e,timestamp:Date.now(),type:t}},a=function(){var e,t=new X.default(function(e){var t=new $r(function(t){var n=i(t,`network`);e.next(n)});return ti.subscribe(t,r),function(){ti.unsubscribe(t)}});return e={},e[wc.NetworkObservable]=t,e};return{name:t,type:n,setup:function(n,i){return I(void 0,void 0,void 0,function(){var o;return L(this,function(s){return typeof document>`u`?[2]:(o=a(),r=n?.loggerProvider,Tc=Cc({allObservables:o,networkTrackingOptions:e,amplitude:i,loggerProvider:r}),r?.log(`${t} has been successfully added.`),[2])})})},execute:function(e){return I(void 0,void 0,void 0,function(){return L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(e){return Tc.unsubscribe(),[2]})})}}},Dc=`web-vitals-browser`,Oc=`[Amplitude] Web Vitals`,kc=-1,Ac=e=>{addEventListener(`pageshow`,(t=>{t.persisted&&(kc=t.timeStamp,e(t))}),!0)},jc=(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)))}},Mc=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},Nc=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Pc=()=>Nc()?.activationStart??0,Fc=(e,t=-1)=>{let n=Nc(),r=`navigate`;return kc>=0?r=`back-forward-cache`:n&&(document.prerendering||Pc()>0?r=`prerender`:document.wasDiscarded?r=`restore`:n.type&&(r=n.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:r}},Ic=new WeakMap;function Lc(e,t){return Ic.get(e)||Ic.set(e,new t),Ic.get(e)}var Rc=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)}},zc=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe({type:e,buffered:!0,...n}),r}}catch{}},Bc=e=>{let t=!1;return()=>{t||=(e(),!0)}},Vc=-1,Hc=new Set,Uc=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,Wc=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of Hc)e();isFinite(Vc)||(Vc=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,Wc,!0))}},Gc=()=>{if(Vc<0){let e=Pc();Vc=(document.prerendering?void 0:globalThis.performance.getEntriesByType(`visibility-state`).filter((t=>t.name===`hidden`&&t.startTime>e))[0]?.startTime)??Uc(),addEventListener(`visibilitychange`,Wc,!0),addEventListener(`prerenderingchange`,Wc,!0),Ac((()=>{setTimeout((()=>{Vc=Uc()}))}))}return{get firstHiddenTime(){return Vc},onHidden(e){Hc.add(e)}}},Kc=e=>{document.prerendering?addEventListener(`prerenderingchange`,(()=>e()),!0):e()},qc=[1800,3e3],Jc=(e,t={})=>{Kc((()=>{let n=Gc(),r,i=Fc(`FCP`),a=zc(`paint`,(e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Pc(),0),i.entries.push(t),r(!0)))}));a&&(r=jc(e,i,qc,t.reportAllChanges),Ac((n=>{i=Fc(`FCP`),r=jc(e,i,qc,t.reportAllChanges),Mc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},Yc=[.1,.25],Xc=(e,t={})=>{let n=Gc();Jc(Bc((()=>{let r,i=Fc(`CLS`,0),a=Lc(t,Rc),o=e=>{for(let t of e)a.h(t);a.i>i.value&&(i.value=a.i,i.entries=a.o,r())},s=zc(`layout-shift`,o);s&&(r=jc(e,i,Yc,t.reportAllChanges),n.onHidden((()=>{o(s.takeRecords()),r(!0)})),Ac((()=>{a.i=0,i=Fc(`CLS`,0),r=jc(e,i,Yc,t.reportAllChanges),Mc((()=>r()))})),setTimeout(r))})))},Zc=0,Qc=1/0,$c=0,el=e=>{for(let t of e)t.interactionId&&(Qc=Math.min(Qc,t.interactionId),$c=Math.max($c,t.interactionId),Zc=$c?($c-Qc)/7+1:0)},tl,nl=()=>tl?Zc:performance.interactionCount??0,rl=()=>{`interactionCount`in performance||tl||(tl=zc(`event`,el,{type:`event`,buffered:!0,durationThreshold:0}))},il=0,al=class{u=[];l=new Map;m;p;v(){il=nl(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((nl()-il)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!==`first-input`)return;let t=this.u.at(-1),n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.P-e.P)),this.u.length>10){let e=this.u.splice(10);for(let t of e)this.l.delete(t.id)}this.p?.(n)}}},ol=e=>{let t=globalThis.requestIdleCallback||setTimeout;document.visibilityState===`hidden`?e():(e=Bc(e),addEventListener(`visibilitychange`,e,{once:!0,capture:!0}),t((()=>{e(),removeEventListener(`visibilitychange`,e,{capture:!0})})))},sl=[200,500],cl=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=Gc();Kc((()=>{rl();let r,i=Fc(`INP`),a=Lc(t,al),o=e=>{ol((()=>{for(let t of e)a.h(t);let t=a.L();t&&t.P!==i.value&&(i.value=t.P,i.entries=t.entries,r())}))},s=zc(`event`,o,{durationThreshold:t.durationThreshold??40});r=jc(e,i,sl,t.reportAllChanges),s&&(s.observe({type:`first-input`,buffered:!0}),n.onHidden((()=>{o(s.takeRecords()),r(!0)})),Ac((()=>{a.v(),i=Fc(`INP`),r=jc(e,i,sl,t.reportAllChanges)})))}))},ll=class{m;h(e){this.m?.(e)}},ul=[2500,4e3],dl=(e,t={})=>{Kc((()=>{let n=Gc(),r,i=Fc(`LCP`),a=Lc(t,ll),o=e=>{t.reportAllChanges||(e=e.slice(-1));for(let t of e)a.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Pc(),0),i.entries=[t],r())},s=zc(`largest-contentful-paint`,o);if(s){r=jc(e,i,ul,t.reportAllChanges);let n=Bc((()=>{o(s.takeRecords()),s.disconnect(),r(!0)})),a=e=>{e.isTrusted&&(ol(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});Ac((n=>{i=Fc(`LCP`),r=jc(e,i,ul,t.reportAllChanges),Mc((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))},fl=[800,1800],pl=e=>{document.prerendering?Kc((()=>pl(e))):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,(()=>pl(e)),!0)},ml=(e,t={})=>{let n=Fc(`TTFB`),r=jc(e,n,fl,t.reportAllChanges);pl((()=>{let i=Nc();i&&(n.value=Math.max(i.responseStart-Pc(),0),n.entries=[i],r(!0),Ac((()=>{n=Fc(`TTFB`,0),r=jc(e,n,fl,t.reportAllChanges),r(!0)})))}))};function hl(e){var t=e.entries[0]?.startTime||0;return performance.timeOrigin+t}function gl(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(hl(e)),navigationStart:Math.floor(performance.timeOrigin)}}var _l=function(){var e=null,t=U(),n=t?.document,r=t?.location;return{name:Dc,type:`enrichment`,setup:function(t,i){return I(void 0,void 0,void 0,function(){var a,o;return L(this,function(s){return n===void 0?[2]:(a=In(r?.href||``,t.loggerProvider),o={"[Amplitude] Page Domain":r?.hostname||``,"[Amplitude] Page Location":a,"[Amplitude] Page Path":In(r?.pathname||``,t.loggerProvider),"[Amplitude] Page Title":typeof document<`u`&&document.title||``,"[Amplitude] Page URL":In(a.split(`?`)[0],t.loggerProvider)},dl(function(e){o[`[Amplitude] LCP`]=gl(e)}),Jc(function(e){o[`[Amplitude] FCP`]=gl(e)}),cl(function(e){o[`[Amplitude] INP`]=gl(e)}),Xc(function(e){o[`[Amplitude] CLS`]=gl(e)}),ml(function(e){o[`[Amplitude] TTFB`]=gl(e)}),e=function(){n.visibilityState===`hidden`&&e&&(i.track(Oc,o),n.removeEventListener(`visibilitychange`,e),e=null)},n.addEventListener(`visibilitychange`,e),[2])})})},execute:function(e){return I(void 0,void 0,void 0,function(){return L(this,function(t){return[2,e]})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(t){return e&&n?.removeEventListener(`visibilitychange`,e),[2]})})}}},vl=function(){function e(e,t){this.shouldTrackNewCampaign=!1,this.options=F({initialEmptyValue:`EMPTY`,resetSessionOnNewCampaign:!1,excludeReferrers:ja(t.cookieOptions?.domain||t.topLevelDomain),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=Kn(t.apiKey,`MKTG`),this.webExpStorageKey=Kn(t.apiKey,`MKTG_ORIGINAL`),this.currentCampaign=St,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,t;return L(this,function(n){switch(n.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return t=z.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=this.lastEventTime?kn(this.sessionTimeout,this.lastEventTime):!0,Da(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return I(this,void 0,void 0,function(){var e;return L(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 ni().parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t=Aa(this.currentCampaign,this.options);return e&&(t.event_id=e),t},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),yl=`AMP_CURRENT_PAGE`,bl=`AMP_PREVIOUS_PAGE`,xl=`AMP_URL_INFO`,Sl;(function(e){e.Direct=`direct`,e.Internal=`internal`,e.External=`external`})(Sl||={});var Cl=new Set([Qe.IDENTIFY,Qe.GROUP_IDENTIFY,Qe.REVENUE]),wl=function(e){var t=(e===void 0?{}:e).internalDomains,n=t===void 0?[]:t,r=U(),i=void 0,a=!1,o=void 0,s=!1,c=!1,l=function(e){var t;try{var n=In(e,o);t=new URL(n).hostname}catch(e){o?.error(`Could not parse URL: `,e)}return t},u=function(e){var t=typeof location<`u`&&location.hostname||``,r=e?l(e):void 0;if(!r)return Sl.Direct;var i=n.some(function(e){return t.indexOf(e)!==-1}),a=n.some(function(e){return r.indexOf(e)!==-1});return t===r||a&&i?Sl.Internal:Sl.External},d=function(){return I(void 0,void 0,void 0,function(){var e,t,n,r,o;return L(this,function(s){switch(s.label){case 0:return i&&a?[4,i.get(xl)]:[3,3];case 1:return e=s.sent(),t=In(typeof location<`u`&&location.href||``),n=e?.AMP_CURRENT_PAGE||``,r=void 0,r=t===n?e?.AMP_PREVIOUS_PAGE||``:n||document.referrer||``,[4,i.set(xl,(o={},o[yl]=t,o[bl]=r,o))];case 2:s.sent(),s.label=3;case 3:return[2]}})})},f=function(){d()};return{name:`@amplitude/plugin-page-url-enrichment-browser`,type:`enrichment`,setup:function(e,t){return I(void 0,void 0,void 0,function(){return L(this,function(t){switch(t.label){case 0:if(o=e.loggerProvider,o.log(`Installing @amplitude/plugin-page-url-enrichment-browser`),c=!0,!r)return[3,2];try{i=new qn(r.sessionStorage)}catch{o?.debug(`sessionStorage is not available in this environment.`)}return[4,i?.isEnabled()];case 1:a=t.sent()??!1,r.addEventListener(`popstate`,f),s||=(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=z(n,3),i=r[0],a=r[1],o=r[2];e.apply(t,[i,a,o]),c&&f()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=z(n,3),i=r[0],a=r[1],o=r[2];e.apply(t,[i,a,o]),c&&f()}}),!0),t.label=2;case 2:return[2]}})})},execute:function(e){return I(void 0,void 0,void 0,function(){var t,n,r,o,s;return L(this,function(c){switch(c.label){case 0:return t=In(typeof location<`u`&&location.href||``),i&&a?[4,i.get(xl)]:[3,5];case 1:return n=c.sent(),n?.AMP_CURRENT_PAGE?[3,3]:[4,i.set(xl,(s={},s[yl]=t,s[bl]=document.referrer||``,s))];case 2:c.sent(),c.label=3;case 3:return[4,i.get(xl)];case 4:if(r=c.sent(),o=``,r&&(o=r.AMP_PREVIOUS_PAGE||``),Cl.has(e.event_type))return[2,e];e.event_properties=F(F({},e.event_properties||{}),{"[Amplitude] Page Domain":Tl(e,`[Amplitude] Page Domain`,typeof location<`u`&&location.hostname||``),"[Amplitude] Page Location":Tl(e,`[Amplitude] Page Location`,t),"[Amplitude] Page Path":Tl(e,`[Amplitude] Page Path`,typeof location<`u`&&In(location.pathname)||``),"[Amplitude] Page Title":Tl(e,`[Amplitude] Page Title`,li(ci)),"[Amplitude] Page URL":Tl(e,`[Amplitude] Page URL`,t.split(`?`)[0]),"[Amplitude] Previous Page Location":o,"[Amplitude] Previous Page Type":u(o)}),c.label=5;case 5:return[2,e]}})})},teardown:function(){return I(void 0,void 0,void 0,function(){return L(this,function(e){switch(e.label){case 0:return r&&(r.removeEventListener(`popstate`,f),c=!1),i&&a?[4,i.set(xl,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}}};function Tl(e,t,n){return e.event_properties||={},e.event_properties[t]===void 0?n:e.event_properties[t]}var El=function(){var e,t,n;function r(e){return typeof e!=`object`||!e?!1:`body`in e&&typeof e.body==`string`}function i(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(a,o){return I(void 0,void 0,void 0,function(){var o;return L(this,function(s){return e=a.loggerProvider,e?.log(`Installing @amplitude/plugin-custom-enrichment-browser`),a.remoteConfig?.fetchRemoteConfig&&(a.remoteConfigClient?(o=a.remoteConfigClient.subscribe(`configs.analyticsSDK.browserSDK.customEnrichment`,`all`,function(e){n=e&&r(e)?i(e.body||``):i(``)}),t=function(){return a.remoteConfigClient?.unsubscribe(o)}):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 L(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 L(this,function(e){return t&&t(),[2]})})}}},Dl=-1,Ol=function(e){Ye(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t._enableRequestBodyCompressionExperimentalValue=!1,t}return t.prototype.init=function(e,t,n){e===void 0&&(e=``);var r,i;return arguments.length>2?(r=t,i=n):typeof t==`string`?(r=t,i=void 0):(r=t?.userId,i=t),W(this._init(F(F({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){return I(this,void 0,void 0,function(){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this;return L(this,function(v){switch(v.label){case 0:return this.initializing?[2]:(this.initializing=!0,n=Ba(t),r=t.loggerProvider??new Zt,t.loggerProvider||r.enable(t.logLevel??G.Warn),i=t.serverZone??`US`,o=this._diagnosticsSampleRate,s=t.enableDiagnostics??!0,n?(a=new _r(t.apiKey,r,i,t.remoteConfig?.serverUrl),[4,new Promise(function(e){a?.subscribe(`configs.diagnostics.browserSDK`,`all`,function(t,n,i){if(r.debug(`Diagnostics remote configuration received:`,JSON.stringify({remoteConfig:t,source:n,lastFetch:i},null,2)),t){var a=t.sampleRate;typeof a==`number`&&!isNaN(a)&&(o=a);var c=t.enabled;typeof c==`boolean`&&(s=c)}e()})})]):[3,2]);case 1:v.sent(),v.label=2;case 2:return c=new lr(t.apiKey,r,i,{enabled:s,sampleRate:o}),c.setTag(`library`,`${Zi}/${Xi}`),typeof navigator<`u`&&c.setTag(`user_agent`,navigator.userAgent),[4,Ra(t.apiKey,t,this,c,{loggerProvider:r,serverZone:i,enableDiagnostics:s,diagnosticsSampleRate:o})];case 3:return l=v.sent(),n&&a?[4,new Promise(function(e){a?.subscribe(`configs.analyticsSDK.browserSDK`,`all`,function(t,n,r){l.loggerProvider.debug(`Remote configuration received:`,JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&ao(t,l),e()})})]:[3,5];case 4:v.sent(),v.label=5;case 5:return[4,e.prototype._init.call(this,l)];case 6:return v.sent(),this.logBrowserOptions(l),this.config.remoteConfigClient=a,ji(this.config.defaultTracking)?(this.config.optOut&&this.timeline.addOptOutListener(function(e){return I(_,void 0,void 0,function(){var t;return L(this,function(n){switch(n.label){case 0:return e?[3,2]:(t=Ki(this.config),this.webAttribution=new vl(t,this.config),[4,this.webAttribution.init()]);case 1:n.sent(),n.label=2;case 2:return[2]}})})}),u=Ki(this.config),this.webAttribution=new vl(u,this.config),[4,this.webAttribution.init()]):[3,8];case 7:v.sent(),v.label=8;case 8:return d=Nn(),f=d.ampTimestamp?Number(d.ampTimestamp):void 0,p=f?Date.now()<f:!0,m=p&&!Number.isNaN(Number(d.ampSessionId))?Number(d.ampSessionId):void 0,h=this.config.deferredSessionId,h===Dl&&!this.config.optOut&&(h=Date.now()),this.setSessionId(t.sessionId??m??h??this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return I(_,void 0,void 0,function(){return L(this,function(t){return!e&&this.config.deferredSessionId&&(this.config.deferredSessionId===Dl?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),g=Tn(t.instanceName),g.identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),this.config.offline===null?[3,10]:[4,this.add(no()).promise];case 9:v.sent(),v.label=10;case 10:return[4,this.add(new dn({diagnosticsClient:c})).promise];case 11:return v.sent(),[4,this.add(new ea).promise];case 12:return v.sent(),[4,this.add(new On).promise];case 13:return v.sent(),to(this.config),Mi(this.config.defaultTracking)?(this.config.loggerProvider.debug(`Adding file download tracking plugin`),[4,this.add($a()).promise]):[3,15];case 14:v.sent(),v.label=15;case 15:return Ni(this.config.defaultTracking)?(this.config.loggerProvider.debug(`Adding form interaction plugin`),[4,this.add(Xa()).promise]):[3,17];case 16:v.sent(),v.label=17;case 17:return Pi(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug(`Adding page view tracking plugin`),[4,this.add(Ka(Gi(this.config))).promise]):[3,20];case 18:return v.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return I(_,void 0,void 0,function(){return L(this,function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug(`Adding page view tracking plugin`),[4,this.add(Ka(Gi(this.config))).promise]);case 1:return t.sent(),[2]}})})}),v.label=20;case 20:return Ri(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding user interactions plugin (autocapture plugin)`),[4,this.add(Is(Hi(this.config),{diagnosticsClient:c})).promise]):[3,22];case 21:v.sent(),v.label=22;case 22:return Bi(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding frustration interactions plugin`),[4,this.add(dc(Ui(this.config))).promise]):[3,24];case 23:v.sent(),v.label=24;case 24:return Li(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding network tracking plugin`),[4,this.add(Ec(Wi(this.config))).promise]):[3,26];case 25:v.sent(),v.label=26;case 26:return zi(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding web vitals plugin`),[4,this.add(_l()).promise]):[3,28];case 27:v.sent(),v.label=28;case 28:return Ii(this.config.autocapture)?(this.config.loggerProvider.debug(`Adding referrer page url plugin`),[4,this.add(wl()).promise]):[3,30];case 29:v.sent(),v.label=30;case 30:return Vi(this.config.customEnrichment)?(this.config.loggerProvider.debug(`Adding custom enrichment plugin`),[4,this.add(El()).promise]):[3,32];case 31:v.sent(),v.label=32;case 32:return this.initializing=!1,[4,this.runQueuedFunctions(`dispatchQ`)];case 33:return v.sent(),g.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=Xe(t,[`time`]),i=typeof n==`number`?{time:n}:void 0;_.track(e.eventType,r,i)}),[2]}})})},t.prototype.getUserId=function(){return this.config?.userId},t.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}),En(e,this.config.instanceName))},t.prototype.getDeviceId=function(){return this.config?.deviceId},t.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}),Dn(e,this.config.instanceName))},t.prototype.reset=function(){this.setDeviceId(zt()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){return{deviceId:this.config?.deviceId,userId:this.config?.userId,userProperties:this.userProperties}},t.prototype.setIdentity=function(e){var t,n;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 r=new Ot,i=e.userProperties??{};try{for(var a=R(Object.entries(i)),o=a.next();!o.done;o=a.next()){var s=z(o.value,2),c=s[0],l=s[1];r.set(c,l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this.identify(r)}},t.prototype.getOptOut=function(){return this.config?.optOut},t.prototype.getSessionId=function(){return this.config?.sessionId},t.prototype.setSessionId=function(e){var t=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),W(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=e??Dl,W(Promise.resolve());if(e===void 0&&(e=Date.now()),e===this.config.sessionId)return W(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,Fi(this.config.defaultTracking)&&(n&&r&&t.push(this.track(ma,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(Ht(this.config.identify)).promise),Fi(this.config.defaultTracking)&&t.push(this.track(pa,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,W(Promise.all(t))},t.prototype.extendSession=function(){if(!this.config){this.q.push(this.extendSession.bind(this));return}this.config.lastEventTime=Date.now()},t.prototype.setTransport=function(e){if(!this.config){this.q.push(this.setTransport.bind(this,e));return}this.config.transportProvider=Va(e)},t.prototype.identify=function(t,n){if(Yi(t)){var r=t._q;t._q=[],t=Ji(new Ot,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)},t.prototype.groupIdentify=function(t,n,r,i){if(Yi(r)){var a=r._q;r._q=[],r=Ji(new Ot,a)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(Yi(t)){var r=t._q;t._q=[],t=Ji(new qt,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log(`Tracking attribution.`),!0},t.prototype.process=function(t){return I(this,void 0,void 0,function(){var n,r,i;return L(this,function(a){return n=Date.now(),r=kn(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type!==`session_start`&&t.event_type!==`session_end`&&(!t.session_id||t.session_id===this.getSessionId())&&(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log(`Created a new session for new campaign.`)):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},t.prototype.logBrowserOptions=function(e){try{var t=F(F({},e),{apiKey:e.apiKey.substring(0,10)+`********`});this.config.loggerProvider.debug(`Initialized Amplitude with BrowserConfig:`,hi(t))}catch(e){this.config.loggerProvider.error(`Error logging browser config`,e)}},t.prototype._setDiagnosticsSampleRate=function(e){if(!(e>1||e<0)&&!this.config){this._diagnosticsSampleRate=e;return}},t.prototype._enableRequestBodyCompressionExperimental=function(e){if(!this.config){this._enableRequestBodyCompressionExperimentalValue=e;return}},t}(Kt),$=function(){var e=new Ol;return{init:J(e.init.bind(e),`init`,K(e),q(e,[`config`])),add:J(e.add.bind(e),`add`,K(e),q(e,[`config.apiKey`,`timeline.plugins`])),remove:J(e.remove.bind(e),`remove`,K(e),q(e,[`config.apiKey`,`timeline.plugins`])),track:J(e.track.bind(e),`track`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),logEvent:J(e.logEvent.bind(e),`logEvent`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),identify:J(e.identify.bind(e),`identify`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),groupIdentify:J(e.groupIdentify.bind(e),`groupIdentify`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),setGroup:J(e.setGroup.bind(e),`setGroup`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),revenue:J(e.revenue.bind(e),`revenue`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),flush:J(e.flush.bind(e),`flush`,K(e),q(e,[`config.apiKey`,`timeline.queue.length`])),getUserId:J(e.getUserId.bind(e),`getUserId`,K(e),q(e,[`config`,`config.userId`])),setUserId:J(e.setUserId.bind(e),`setUserId`,K(e),q(e,[`config`,`config.userId`])),getDeviceId:J(e.getDeviceId.bind(e),`getDeviceId`,K(e),q(e,[`config`,`config.deviceId`])),setDeviceId:J(e.setDeviceId.bind(e),`setDeviceId`,K(e),q(e,[`config`,`config.deviceId`])),reset:J(e.reset.bind(e),`reset`,K(e),q(e,[`config`,`config.userId`,`config.deviceId`])),getSessionId:J(e.getSessionId.bind(e),`getSessionId`,K(e),q(e,[`config`])),setSessionId:J(e.setSessionId.bind(e),`setSessionId`,K(e),q(e,[`config`])),extendSession:J(e.extendSession.bind(e),`extendSession`,K(e),q(e,[`config`])),setOptOut:J(e.setOptOut.bind(e),`setOptOut`,K(e),q(e,[`config`])),setTransport:J(e.setTransport.bind(e),`setTransport`,K(e),q(e,[`config`])),getIdentity:J(e.getIdentity.bind(e),`getIdentity`,K(e),q(e,[`config`])),setIdentity:J(e.setIdentity.bind(e),`setIdentity`,K(e),q(e,[`config`,`config.userId`,`config.deviceId`])),getOptOut:J(e.getOptOut.bind(e),`getOptOut`,K(e),q(e,[`config`])),_setDiagnosticsSampleRate:J(e._setDiagnosticsSampleRate.bind(e),`_setDiagnosticsSampleRate`,K(e),q(e,[`config`])),_enableRequestBodyCompressionExperimental:J(e._enableRequestBodyCompressionExperimental.bind(e),`_enableRequestBodyCompressionExperimental`,K(e),q(e,[`config`]))}}();$.add,$.extendSession,$.flush,$.getDeviceId,$.getIdentity,$.getOptOut,$.getSessionId,$.getUserId,$.groupIdentify,$.identify;var kl=$.init;$.logEvent,$.remove,$.reset,$.revenue,$.setDeviceId,$.setGroup,$.setIdentity,$.setOptOut,$.setSessionId,$.setTransport,$.setUserId;var Al=$.track;$._setDiagnosticsSampleRate,$._enableRequestBodyCompressionExperimental;function jl(e){try{if(!e){console.warn(`[LiveState] Amplitude API key not provided`);return}kl(e,{defaultTracking:!1})}catch(e){console.warn(`[LiveState] Failed to initialize Amplitude:`,e)}}async function Ml(e){try{if(window.clarity){console.log(`[LiveState] Clarity already initialized by client`);return}let t=e||Nl();if(!t){console.warn(`[LiveState] Clarity project ID not provided`);return}(await Promise.resolve().then(()=>require(`./clarity-Dc6nPh3X.cjs`))).default.init(t)}catch(e){console.warn(`[LiveState] Failed to initialize Clarity:`,e)}}function Nl(){try{let e=document.querySelector(`script[src*="clarity.ms"]`);if(e)return e.getAttribute(`src`)?.match(/\/([a-z0-9]+)$/)?.[1];let t=window.clarity?.q?.[0]?.[1];if(typeof t==`string`)return t}catch{}}function Pl(e,t){try{Al(e,t)}catch(e){console.warn(`[LiveState] Failed to track Amplitude event:`,e)}}function Fl(e,t){try{window.clarity&&(window.clarity(`event`,e),t&&Object.entries(t).forEach(([e,t])=>{window.clarity?.(`set`,e,String(t))}))}catch(e){console.warn(`[LiveState] Failed to track Clarity event:`,e)}}function Il(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function Ll(e,t){Pl(e,t),Fl(e,t)}var Rl=(0,l.createContext)(null);function zl({children:e,fetcher:t,analytics:n}){return(0,l.useEffect)(()=>{n?.amplitudeKey&&jl(n.amplitudeKey),n?.clarityProjectId&&Ml(n.clarityProjectId)},[n]),(0,u.jsx)(Ke,{value:{provider:()=>new Map},children:(0,u.jsx)(Rl.Provider,{value:{fetcher:t,analytics:n},children:e})})}function Bl(){let e=(0,l.useContext)(Rl);if(!e)throw Error(`useLiveState must be used within LiveStateProvider`);return e}function Vl(){let{fetcher:e}=Bl(),{data:t,error:n,isLoading:r,mutate:i}=qe(`live-state`,e,{revalidateOnFocus:!1,revalidateOnReconnect:!0,dedupingInterval:6e4,shouldRetryOnError:!1,onError:e=>{console.warn(`[LiveState] Failed to fetch live state:`,e)}});return{liveState:t??null,isLoading:r,error:n??null,refresh:async()=>{try{await i()}catch(e){console.warn(`[LiveState] Failed to refresh live state:`,e)}}}}function Hl(e){try{switch(e.type){case`redirect`:window.location.href=e.url;break;case`whatsapp`:{let t=e.whatsappMessage?`${e.url}?text=${encodeURIComponent(e.whatsappMessage)}`:e.url;window.open(t,`_blank`);break}case`external`:window.open(e.url,`_blank`);break;default:console.warn(`[LiveState] Unknown CTA type: ${e.type}`)}}catch(e){console.warn(`[LiveState] Failed to handle CTA click:`,e)}}function Ul({data:e,trackingConfig:t}){let n=e.type===`alert`?`danger`:`warning`,r=()=>Il({context:e.context,campaignId:e.campaignId,group:e.group,...e.metadata,...t.properties});return(0,l.useEffect)(()=>{Ll(`${t.prefix}${t.page}_${e.context}_view`,r())},[]),(0,u.jsxs)(d.Alert,{appearance:n,title:e.title,onRemove:()=>{Ll(`${t.prefix}${t.page}_${e.context}_close`,r())},children:[(0,u.jsx)(`p`,{dangerouslySetInnerHTML:{__html:e.message}}),(0,u.jsx)(d.Button,{appearance:`neutral`,onClick:()=>{Ll(`${t.prefix}${t.page}_${e.context}_click`,r()),Hl(e.cta)},children:e.cta.label})]})}function Wl({data:e,trackingConfig:t,defaultVariant:n=`blue`}){let r=e.variant||n,i=()=>Il({context:e.context,campaignId:e.campaignId,group:e.group,...e.metadata,...t.properties}),a=()=>{Ll(`${t.prefix}${t.page}_${e.context}_click`,i()),Hl(e.cta)};(0,l.useEffect)(()=>{Ll(`${t.prefix}${t.page}_${e.context}_view`,i())},[]);let o=r===`blue`?`currentColor`:`primary-interactive`;return(0,u.jsx)(d.Card,{backgroundColor:r===`blue`?`primary-surface`:`neutral-background`,children:(0,u.jsx)(d.Card.Body,{children:(0,u.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,alignItems:`flex-start`},children:[(0,u.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,u.jsx)(d.Icon,{source:(0,u.jsx)(f.ExclamationCircleIcon,{}),color:o})}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(`h3`,{style:{fontSize:`16px`,fontWeight:600,margin:`0 0 8px 0`,lineHeight:`24px`},dangerouslySetInnerHTML:{__html:e.title}}),(0,u.jsx)(`p`,{style:{fontSize:`14px`,margin:`0 0 16px 0`,lineHeight:`20px`},dangerouslySetInnerHTML:{__html:e.message}}),(0,u.jsx)(d.Button,{onClick:a,children:e.cta.label})]})]})})})}function Gl({data:e,loading:t,trackingConfig:n,allowedContexts:r,defaultVariant:i}){return t||!e?null:!e.context||!e.type||!e.title||!e.message||!e.cta?.label||!e.cta?.url||!e.cta?.type?(console.warn(`[LiveState] Invalid payload, missing required fields`,e),null):r&&!r.includes(e.context)?null:e.type===`alert`||e.type===`warning`?(0,u.jsx)(Ul,{data:e,trackingConfig:n}):e.type===`info`?(0,u.jsx)(Wl,{data:e,trackingConfig:n,defaultVariant:i}):(console.warn(`[LiveState] Unknown type: ${e.type}`),null)}exports.LiveStateAlert=Ul,exports.LiveStateInfo=Wl,exports.LiveStateProvider=zl,exports.LiveStateRenderer=Gl,exports.handleCtaClick=Hl,exports.trackEvent=Ll,exports.useLiveState=Vl;
|
|
12
|
+
//# sourceMappingURL=index.cjs.map
|