@qonto/embed-sdk 0.64.1 → 0.64.2

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.
Files changed (91) hide show
  1. package/dist/cards/client/cards.client.d.ts +1 -1
  2. package/dist/cards/client/cards.client.d.ts.map +1 -1
  3. package/dist/index.umd.js +81 -81
  4. package/dist/mocks/handlers.d.ts.map +1 -1
  5. package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/decorators/property.js +1 -1
  6. package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/reactive-element.js +1 -1
  7. package/dist/node_modules/.pnpm/{lit-element@4.2.1 → lit-element@4.2.2}/node_modules/lit-element/lit-element.js +2 -2
  8. package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/lit-html.js +1 -1
  9. package/dist/node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.js +1 -0
  10. package/dist/server/cards/client/cards.client.d.ts +1 -1
  11. package/dist/server/cards/client/cards.client.d.ts.map +1 -1
  12. package/dist/server/index.server.umd.js +1 -1
  13. package/dist/server/mocks/handlers.d.ts.map +1 -1
  14. package/dist/server/node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.js +1 -0
  15. package/dist/server/src/beneficiaries/shared/beneficiaries.api.js +1 -1
  16. package/dist/server/src/sepa-transfers/bulk-transfers/server/bulk-transfers.server.js +1 -1
  17. package/dist/server/src/sepa-transfers/server/sepa-transfers.server.js +1 -1
  18. package/dist/src/beneficiaries/shared/beneficiaries.api.js +1 -1
  19. package/dist/src/cards/client/cards.client.js +1 -1
  20. package/dist/src/cards/shared/cards.serializer.js +1 -1
  21. package/dist/src/iframe/iframe-message-builder.js +1 -1
  22. package/dist/src/sepa-transfers/bulk-transfers/client/bulk-transfers.client.js +1 -1
  23. package/dist/src/sepa-transfers/client/sepa-transfers.client.js +1 -1
  24. package/dist/src/ui/customizable-components/amount-field/qonto-amount-field.js +1 -1
  25. package/dist/src/ui/customizable-components/amount-field/qonto-amount-field.styles.js +1 -1
  26. package/dist/src/ui/customizable-components/badge-status/qonto-badge-status.js +1 -1
  27. package/dist/src/ui/customizable-components/badge-status/qonto-badge-status.styles.js +1 -1
  28. package/dist/src/ui/customizable-components/beneficiary-card/qonto-beneficiary-card.js +1 -1
  29. package/dist/src/ui/customizable-components/beneficiary-card/qonto-beneficiary-card.styles.js +1 -1
  30. package/dist/src/ui/customizable-components/button/qonto-button.js +1 -1
  31. package/dist/src/ui/customizable-components/button/qonto-button.styles.js +1 -1
  32. package/dist/src/ui/customizable-components/icons/icon-checkmark-rounded-filled.js +1 -1
  33. package/dist/src/ui/customizable-components/icons/icon-clock-filled.js +1 -1
  34. package/dist/src/ui/customizable-components/icons/icon-declined.js +1 -1
  35. package/dist/src/ui/customizable-components/icons/icon-error-filled.js +1 -1
  36. package/dist/src/ui/customizable-components/icons/icon-in-progress.js +1 -1
  37. package/dist/src/ui/customizable-components/icons/icon-warning.js +1 -1
  38. package/dist/src/ui/customizable-components/lottie-player/qonto-lottie-player.js +1 -1
  39. package/dist/src/ui/customizable-components/lottie-player/qonto-lottie-player.styles.js +1 -1
  40. package/dist/src/ui/customizable-components/select-field/qonto-option.js +1 -1
  41. package/dist/src/ui/customizable-components/select-field/qonto-select-field.js +1 -1
  42. package/dist/src/ui/customizable-components/select-field/qonto-select-field.styles.js +1 -1
  43. package/dist/src/ui/customizable-components/skeleton-loader/qonto-skeleton-loader-line.js +1 -1
  44. package/dist/src/ui/customizable-components/skeleton-loader/qonto-skeleton-loader-line.styles.js +1 -1
  45. package/dist/src/ui/customizable-components/styles/component-styles/table-styles.js +1 -1
  46. package/dist/src/ui/customizable-components/text/qonto-text-body.js +1 -1
  47. package/dist/src/ui/customizable-components/text/qonto-text-body.styles.js +1 -1
  48. package/dist/src/ui/customizable-components/text/qonto-text-heading.js +1 -1
  49. package/dist/src/ui/customizable-components/text/qonto-text-heading.styles.js +1 -1
  50. package/dist/src/ui/customizable-components/text-field/qonto-text-field.js +1 -1
  51. package/dist/src/ui/customizable-components/text-field/qonto-text-field.styles.js +1 -1
  52. package/dist/src/ui/ui-elements/list-utils/list.utils.js +1 -1
  53. package/dist/src/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.js +1 -1
  54. package/dist/src/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.styles.js +1 -1
  55. package/dist/src/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.utils.js +1 -1
  56. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/beneficiary-selection-page.js +1 -1
  57. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/beneficiary-selection-page.styles.js +1 -1
  58. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/beneficiary-selection-page.utils.js +1 -1
  59. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-details-page.js +1 -1
  60. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-details-page.styles.js +1 -1
  61. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-error-page.js +1 -1
  62. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-error-page.styles.js +1 -1
  63. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-success-page.js +1 -1
  64. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-success-page.styles.js +1 -1
  65. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-summary-page.js +1 -1
  66. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-summary-page.styles.js +1 -1
  67. package/dist/src/ui/ui-elements/sepa-transfer-creation/pages/transfer-summary-page.utils.js +1 -1
  68. package/dist/src/ui/ui-elements/sepa-transfer-creation/sepa-transfer-creation.js +1 -1
  69. package/dist/src/ui/ui-elements/sepa-transfer-creation/sepa-transfer-creation.styles.js +1 -1
  70. package/dist/src/ui/ui-elements/transaction-list/transaction-list.js +1 -1
  71. package/dist/src/ui/ui-elements/transfer-list/transfer-list.js +1 -1
  72. package/package.json +18 -18
  73. package/dist/node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js +0 -1
  74. package/dist/server/node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js +0 -1
  75. /package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/css-tag.js +0 -0
  76. /package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/decorators/base.js +0 -0
  77. /package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/decorators/custom-element.js +0 -0
  78. /package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/decorators/query.js +0 -0
  79. /package/dist/node_modules/.pnpm/{@lit_reactive-element@2.1.1 → @lit_reactive-element@2.1.2}/node_modules/@lit/reactive-element/decorators/state.js +0 -0
  80. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/async-directive.js +0 -0
  81. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/directive-helpers.js +0 -0
  82. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/directive.js +0 -0
  83. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/directives/ref.js +0 -0
  84. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/directives/unsafe-html.js +0 -0
  85. /package/dist/node_modules/.pnpm/{lit-html@3.3.1 → lit-html@3.3.2}/node_modules/lit-html/static.js +0 -0
  86. /package/dist/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/native.js +0 -0
  87. /package/dist/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/rng.js +0 -0
  88. /package/dist/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/stringify.js +0 -0
  89. /package/dist/server/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/native.js +0 -0
  90. /package/dist/server/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/rng.js +0 -0
  91. /package/dist/server/node_modules/.pnpm/{uuid@11.1.0/node_modules/uuid/dist/esm-browser → uuid@13.0.0/node_modules/uuid/dist}/stringify.js +0 -0
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbedServer={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class r extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class i extends r{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid authentication method. Provide either a proxyRequestFunction (recommended) or accessToken, either as parameters or by calling the initialize function first."}}function o(){if(!n.hasAccessToken())throw new i;return n.getAccessToken()}function a(){return!("undefined"!=typeof window&&"undefined"!=typeof document)}const s={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},c={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},l=3e4,d="REJECT",f={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"},p="https://embed.qonto.com",g="https://embed-js{branch}.staging.qonto.co",h="https://embed.dev.qonto.co",v={[s.PRODUCTION]:{EMBED_BASE_URL:p,EMBED_URL:`${p}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[s.STAGING]:{EMBED_BASE_URL:g,EMBED_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[s.LOCAL]:{EMBED_BASE_URL:h,EMBED_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class m{constructor(){let e,t;this.environment=s.PRODUCTION,this.branch=c.SANDBOX,"undefined"!=typeof process&&process.env&&(e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH),this.environment=Object.values(s).includes(e)?e:s.PRODUCTION,this.branch=Object.values(c).includes(t)?t:c.SANDBOX}static getInstance(){return m.instance||(m.instance=new m),m.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===s.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=s.PRODUCTION,this.branch=c.MASTER}getEnvironmentUrls(){if(this.environment===s.PRODUCTION)return v.production;{const e=v[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const y=m.getInstance();class b{constructor(){this.currentLocale="en"}static getInstance(){return b.instance||(b.instance=new b),b.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const T=b.getInstance();class w{constructor(){this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return w.instance||(w.instance=new w),w.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction),e.proxyEndpointDescriptor&&(this.proxyEndpointDescriptor=e.proxyEndpointDescriptor)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}getProxyEndpointDescriptor(){return this.proxyEndpointDescriptor}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=u.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0,this.proxyEndpointDescriptor=void 0}getSettings(){return{uiParentElementId:this.uiParentElementId,mfaPreference:this.mfaPreference,debugMode:this.debugMode,proxyRequestFunction:this.proxyRequestFunction}}}const k=w.getInstance();class S extends r{constructor({message:e,data:t,code:n}){super(),this.code=500;const r=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${r}`,this.data=t||{},this.code=n||this.code}}function E({accessToken:e,stagingToken:t,idempotencyKey:r,mfaPreference:i,scaSessionToken:o}){const a=new Headers;a.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&a.append("X-Qonto-Staging-Token",s),r&&a.append("X-Qonto-Idempotency-Key",r);const c=i||k.getMFAPreference();return c&&a.append("X-Qonto-2fa-Preference",c),o&&a.append("X-Qonto-SCA-Session-Token",o),a.append("Content-Type","application/json"),a.append("Accept-Language",T.getLocale()),a}async function _({path:e,options:t}){const n=`${y.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,r=await fetch(n,{...t,headers:E(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===r.status)return;const i=await r.json();if(!r.ok)throw i.errors?new S({code:r.status,message:i.errors.map((e=>`${e.code}: ${e.detail}`))}):new S({code:r.status,message:`${i.code}: ${i.detail}`,data:i});return i}function I(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return r=n,a()?Buffer.from(r).toString("base64"):btoa(r);var r}function P(e){return JSON.parse((t=e,a()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function A({accessToken:e,stagingToken:t,action:n,callbackUrl:r}){const i={post_authn_action:n};return r&&(i.callback_url=r),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}async function O(e){const t=A({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await _(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}function R(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}class x extends r{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}function C(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new x(n.map((e=>`Missing required parameter: ${e}`)))}function D(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function L(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}function N(e){if(!e||"object"!=typeof e)throw new x("requestSettings must be an object");const t=e,{action:n,callbackUrl:r}=e;C(t,[{name:"action"}]);const i=D(t),o=Object.values(f);if(o.includes(n)||i.push(`action must be one of ${o.join(", ")}`),i.length>0)throw new x(i);if(void 0!==r&&""===r.trim())throw new x("callbackUrl cannot be empty")}async function U({requestSettings:e,operationSettings:t}){N(e);const{accessToken:n,stagingToken:r}=t||{},i=n||o();return R(await O({accessToken:i,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}const j={request:U};function M(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function q(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}const F=[];for(let e=0;e<256;++e)F.push((e+256).toString(16).slice(1));let B;const $=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function H(e,t,n){if(K.randomUUID&&!e)return K.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!B){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");B=crypto.getRandomValues.bind(crypto)}return B($)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase()}(r)}function z(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function V(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const G="/v2/sepa/beneficiaries";async function J({paginationSettings:e,accessToken:t,stagingToken:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${G}${o}`,options:r}}({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:o}=await _(r);return{beneficiaries:i,meta:o}}function W({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${G}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Y({accessToken:e,stagingToken:t,beneficiaryId:n}){const r=W({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await _(r);return i}async function Q({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=H()}){const i=function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=H()}){return{path:G,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:r},body:{beneficiary:V(e)}}}}({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r}),{beneficiary:o}=await _(i);return o}async function X({beneficiaryIds:e,accessToken:t,stagingToken:n}){const r=function({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${G}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await _(r);return i}async function Z({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const o=function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const{name:o,email:a,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i},body:{beneficiary:{name:o,email:a,activity_tag:s}}};return{path:`${G}/${e.id}`,options:c}}({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}),{beneficiary:a}=await _(o);return a}const ee=[{name:"name"},{name:"iban"}];function te(e){if(!e)throw new x("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new x("beneficiaryId must be a string");return e}const ne={getBeneficiaries:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await J({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.beneficiaries.map((e=>z(e))),c=q(a.meta);return{beneficiaries:s,...c?{meta:c}:{}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=te(e?.beneficiaryId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return z(await Y({beneficiaryId:n,accessToken:a,stagingToken:i}))},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new x("beneficiary must be an object");C(e,ee);const t=D({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new x(t);return e}(e),{accessToken:r,stagingToken:i,idempotencyKey:a}=t||{},s=r||o();return z(await Q({beneficiary:n,accessToken:s,stagingToken:i,idempotencyKey:a}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:r,activityTag:i}=e||{};if(!t)throw new x("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!r&&!i)throw new x("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=D({name:n,email:r,activityTag:i});if(o.length>0)throw new x(o);return{id:t,name:n,email:r,activityTag:i}}(e),{accessToken:r,stagingToken:i,idempotencyKey:a,mfaPreference:s}=t||{},c={beneficiaryParamsBeingEdited:n,accessToken:r||o(),stagingToken:i,idempotencyKey:a,mfaPreference:s};return z(await Z(c))},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new x("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{accessToken:r,stagingToken:i}=t||{},a=r||o();return(await X({beneficiaryIds:n,accessToken:a,stagingToken:i})).map(z)}},re="SDK Initialized",ie="Cards List";var oe=function(e,t){return oe=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])},oe(e,t)};function ae(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}oe(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var se,ce,ue=function(){return ue=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ue.apply(this,arguments)};function le(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(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 de(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function fe(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function pe(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ge(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function he(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,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"}(se||(se={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(ce||(ce={}));var ve,me="AMP",ye="".concat(me,"_unsent"),be="$default_instance",Te="https://api2.amplitude.com/2/httpapi",we="dclid",ke="fbclid",Se="gbraid",Ee="gclid",_e="ko_click_id",Ie="li_fat_id",Pe="msclkid",Ae="rdt_cid",Oe="ttclid",Re="twclid",xe="wbraid",Ce={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},De=["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"],Le=["authorization","cookie","set-cookie"],Ne=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!Ue(t,n))return!1}return!0},Ue=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=pe(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if("object"==typeof s)i=i&&Ne(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return Ne(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},je=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return ue({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(ve.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(ve.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(ve.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(ve.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(ve.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(ve.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(ve.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(ve.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(ve.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[ve.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[ve.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===ve.ADD?"number"==typeof n:e===ve.UNSET||e===ve.REMOVE||Ue(t,n)))},e}();!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"}(ve||(ve={}));var Me,qe=[ve.CLEAR_ALL,ve.UNSET,ve.SET,ve.SET_ONCE,ve.ADD,ve.APPEND,ve.PREPEND,ve.PREINSERT,ve.POSTINSERT,ve.REMOVE];!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"}(Me||(Me={}));var Fe,Be=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=Me.Unknown),{event:e,code:t,message:n}},$e=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},Ke=he([],ge(Array(256).keys()),!1).map((function(e){return e.toString(16).padStart(2,"0")})),He=function(e){var t,n=$e();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,He)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,he([],ge(r.entries()),!1).map((function(e){var t=ge(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(Ke[r]):Ke[r]})).join("")},ze=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,r;return de(this,void 0,void 0,(function(){return fe(this,(function(i){switch(i.label){case 0:return this.plugins.some((function(t){return t.name===e.name}))?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=He(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e,t){var n;return de(this,void 0,void 0,(function(){var r,i;return fe(this,(function(o){switch(o.label){case 0:return r=this.plugins.findIndex((function(t){return t.name===e})),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}}))}))},e.prototype.reset=function(e){this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.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 de(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T;return fe(this,(function(w){switch(w.label){case 0:if(!e)return[2];t=ge(e,1),n=t[0],r=ge(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),o=this.plugins.filter((function(e){return"before"===e.type})),w.label=1;case 1:w.trys.push([1,6,7,8]),a=pe(o),s=a.next(),w.label=2;case 2:return s.done?[3,5]:(f=s.value).execute?[4,f.execute(ue({},n))]:[3,4];case 3:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=4;case 4:return s=a.next(),[3,2];case 5:return[3,8];case 6:return c=w.sent(),m={error:c},[3,8];case 7:try{s&&!s.done&&(y=a.return)&&y.call(a)}finally{if(m)throw m.error}return[7];case 8:u=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),w.label=9;case 9:w.trys.push([9,14,15,16]),l=pe(u),d=l.next(),w.label=10;case 10:return d.done?[3,13]:(f=d.value).execute?[4,f.execute(ue({},n))]:[3,12];case 11:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=12;case 12:return d=l.next(),[3,10];case 13:return[3,16];case 14:return g=w.sent(),b={error:g},[3,16];case 15:try{d&&!d.done&&(T=l.return)&&T.call(l)}finally{if(b)throw b.error}return[7];case 16:return h=this.plugins.filter((function(e){return"destination"===e.type})),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),v=h.map((function(e){var t=ue({},n);return e.execute(t).catch((function(e){return Be(t,0,String(e))}))})),Promise.all(v).then((function(e){var t=ge(e,1)[0]||Be(n,100,"Event not tracked, no destination plugins on the instance");i(t)})),[2]}}))}))},e.prototype.flush=function(){return de(this,void 0,void 0,(function(){var e,t,n,r=this;return fe(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"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return i.sent(),[2]}}))}))},e.prototype.onIdentityChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)}))},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)}))},e.prototype.onOptOutChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)}))},e.prototype.onReset=function(){this.plugins.forEach((function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)}))},e}(),Ve=function(e,t){return ue(ue({},t),{event_type:ce.IDENTIFY,user_properties:e.getUserProperties()})},Ge=function(e){return{promise:e||Promise.resolve()}},Je=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new ze(this),this.name=e}return e.prototype._init=function(e){return de(this,void 0,void 0,(function(){return fe(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 de(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c;return fe(this,(function(u){switch(u.label){case 0:t=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),n=pe(t),r=n.next(),u.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return a=u.sent(),s={error:a},[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:u.sent(),u.label=12;case 12:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return ue(ue(ue({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return Ge(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Ve(e,t);return Ge(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=function(e,t,n,r){var i;return ue(ue({},r),{event_type:ce.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})}(e,t,n,r);return Ge(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,i=new je;return i.set(e,t),ue(ue({},n),{event_type:ce.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return Ge(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return ue(ue({},t),{event_type:ce.REVENUE,event_properties:e.getEventProperties()})}(e,t);return Ge(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),Ge())},e.prototype._addPlugin=function(e){return Ge(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)),Ge())},e.prototype._removePlugin=function(e){return Ge(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(Be(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return de(this,void 0,void 0,(function(){var t=this;return fe(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={};if(void 0===e)return t;var n={};return Object.keys(e).forEach((function(t){Object.values(se).includes(t)||(n[t]=e[t])})),qe.forEach((function(n){if(Object.keys(e).includes(n)){var r=e[n];switch(n){case se.CLEAR_ALL:Object.keys(t).forEach((function(e){delete t[e]}));break;case se.UNSET:Object.keys(r).forEach((function(e){delete t[e]}));break;case se.SET:Object.assign(t,r)}}})),Object.assign(t,n),t},e.prototype.process=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i;return fe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.config.optOut?[2,Be(e,0,"Event skipped due to optOut config")]:(e.event_type===ce.IDENTIFY&&(t=this.getOperationAppliedUserProperties(e.user_properties),this.timeline.onIdentityChanged({userProperties:t})),[4,this.timeline.push(e)]);case 1:return 200===(i=o.sent()).code?this.config.loggerProvider.log(i.message):100===i.code?this.config.loggerProvider.warn(i.message):this.config.loggerProvider.error(i.message),[2,i];case 2:return n=o.sent(),r=String(n),this.config.loggerProvider.error(r),[2,i=Be(e,0,r)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.timeline.onOptOutChanged(e),this.config.optOut=Boolean(e))},e.prototype.flush=function(){return Ge(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find((function(t){return t.name===e}));if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter((function(t){return t instanceof e}))},e}(),We=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){return Ne(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?ue({},this.properties):{};return e[Fe.REVENUE_PRODUCT_ID]=this.productId,e[Fe.REVENUE_QUANTITY]=this.quantity,e[Fe.REVENUE_PRICE]=this.price,e[Fe.REVENUE_TYPE]=this.revenueType,e[Fe.REVENUE_CURRENCY]=this.currency,e[Fe.REVENUE]=this.revenue,e[Fe.RECEIPT]=this.receipt,e[Fe.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(Fe||(Fe={}));var Ye;!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"}(Ye||(Ye={}));var Qe="Amplitude Logger ",Xe=function(){function e(){this.logLevel=Ye.None}return e.prototype.disable=function(){this.logLevel=Ye.None},e.prototype.enable=function(e){void 0===e&&(e=Ye.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Ye.Verbose||console.log("".concat(Qe,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Ye.Warn||console.warn("".concat(Qe,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Ye.Error||console.error("".concat(Qe,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Ye.Debug||console.log("".concat(Qe,"[Debug]: ").concat(e.join(" ")))},e}(),Ze=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:be,logLevel:Ye.Warn,loggerProvider:new Xe,offline:!1,optOut:!1,serverUrl:Te,serverZone:"US",useBatch:!1}},et=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=Ze();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var a=nt(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=a.serverZone,this.serverUrl=a.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),tt=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":Te},nt=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=Ze().serverZone),void 0===n&&(n=Ze().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:Ze().serverZone;return{serverZone:r,serverUrl:tt(r,n)}},rt=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function it(e){return e>=200&&e<300}var ot=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},at=function(e){return function(){var t=ue({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},st=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=pe(t.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(!(a in e))return;e=e[a]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},ct=function(e,t){return function(){var n,r,i={};try{for(var o=pe(t),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=st(e,s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ut=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=n(),c=s.logger,u=s.logLevel;if(u&&u<Ye.Debug||!u||!c)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:ot(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}};function lt(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var dt=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return de(this,void 0,void 0,(function(){var n,r=this;return fe(this,(function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(ye,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map((function(e){return r.execute(e)}))).catch(),[2,Promise.resolve(void 0)]}}))}))},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=He()),new Promise((function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()}))},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter((function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)}))},e.prototype.scheduleEvents=function(e){var t=this;e.forEach((function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)}))},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout((function(){t.queue=t.queue.map((function(e){return e.timeout=0,e})),t.flush(!0)}),e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),de(this,void 0,void 0,(function(){var t,n,r=this;return fe(this,(function(i){switch(i.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 0===e.timeout?t.push(e):n.push(e)})),o=t,a=this.config.flushQueueSize,s=Math.max(a,1),[4,o.reduce((function(e,t,n){var r=Math.floor(n/s);return e[r]||(e[r]=[]),e[r].push(t),e}),[]).reduce((function(t,n){return de(r,void 0,void 0,(function(){return fe(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}}))}))}),Promise.resolve())]);case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var o,a,s}))}))},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),de(this,void 0,void 0,(function(){var r,i,o,a,s;return fe(this,(function(c){switch(c.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,le(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new rt,c.label=1;case 1:return c.trys.push([1,3,,4]),i=nt(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(i,r)];case 2:return null===(o=c.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(o,e),[3,4]):("body"in o?this.fulfillRequest(e,o.statusCode,"".concat(o.status,": ").concat(lt(o))):this.fulfillRequest(e,o.statusCode,o.status),[2]);case 3:return a=c.sent(),s=(u=a)instanceof Error?u.message:String(u),this.config.loggerProvider.error(s),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map((function(e){return e.event.event_type})),message:s,stack_trace:ot()}),this.handleResponse({status:Me.Failed,statusCode:0},e),[3,4];case 4:return[2]}var u}))}))},e.prototype.handleResponse=function(e,t){var n;it(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map((function(e){return e.event.event_type})),code:e.statusCode,status:e.status,body:lt(e),stack_trace:ot()});var r=e.status;switch(r){case Me.Success:this.handleSuccessResponse(e,t);break;case Me.Invalid:this.handleInvalidResponse(e,t);break;case Me.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case Me.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=he(he(he(he([],ge(Object.values(e.body.eventsWithInvalidFields)),!1),ge(Object.values(e.body.eventsWithMissingFields)),!1),ge(Object.values(e.body.eventsWithInvalidIdLengths)),!1),ge(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter((function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(lt(e));var a=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(a)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(lt(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,a=new Set(r),s=new Set(i),c=new Set(o),u=t.filter((function(t,r){if(!(t.event.user_id&&a.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)))return c.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));u.length>0&&this.config.loggerProvider.warn(lt(e));var l=this.removeEventsExceedFlushMaxRetries(u);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e})),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;it(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map((function(e){return e.event.event_type})),code:t,message:n,stack_trace:ot()})),this.removeEvents(e),e.forEach((function(e){return e.callback(Be(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}(),ft=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:pt(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),pt=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},gt=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}(),ht=function(){return ht=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ht.apply(this,arguments)};function vt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function mt(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}"function"==typeof SuppressedError&&SuppressedError;var yt=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=vt(["string","number","boolean","undefined"]),a=o.next();!a.done;a=o.next()){if(a.value===i)return e===t}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var s=Array.isArray(e),c=Array.isArray(t);if(s!==c)return!1;if(!s||!c){var u=Object.keys(e).sort(),l=Object.keys(t).sort();if(!yt(u,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){yt(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!yt(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var bt,Tt=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=ht({},this.identity.userProperties),n=ht(ht({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,a,s,c=n.userProperties||{};try{for(var u=vt(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=mt(l.value,2),f=d[0],p=d[1];switch(f){case"$set":try{for(var g=(i=void 0,vt(Object.entries(p))),h=g.next();!h.done;h=g.next()){var v=mt(h.value,2),m=v[0],y=v[1];c[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(a=void 0,vt(Object.keys(p))),T=b.next();!T.done;T=b.next()){delete c[m=T.value]}}catch(e){a={error:e}}finally{try{T&&!T.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}break;case"$clearAll":c={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return ht({},this.identity)},e.prototype.setIdentity=function(e){var t=ht({},this.identity);this.identity=ht({},e),yt(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}(),wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,kt=function(){function e(){this.identityStore=new Tt,this.eventBridge=new gt,this.applicationContextProvider=new ft}return e.getInstance=function(t){return wt.analyticsConnectorInstances||(wt.analyticsConnectorInstances={}),wt.analyticsConnectorInstances[t]||(wt.analyticsConnectorInstances[t]=new e),wt.analyticsConnectorInstances[t]},e}(),St=function(e){return void 0===e&&(e=be),kt.getInstance(e)},Et=function(){function e(){this.name="identity",this.type="before",this.identityStore=St().identityStore}return e.prototype.execute=function(e){return de(this,void 0,void 0,(function(){var t;return fe(this,(function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]}))}))},e.prototype.setup=function(e){return de(this,void 0,void 0,(function(){return fe(this,(function(t){return e.instanceName&&(this.identityStore=St(e.instanceName).identityStore),[2]}))}))},e}(),_t=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},It=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[me,t,e.substring(0,n)].filter(Boolean).join("_")},Pt=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},At=function(){var e,t=$e();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=Ot(n[0]),i=Ot(n[1]);return i?(e[r]=i,e):e}),{}):{}},Ot=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},Rt=function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))},xt=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Ct=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},Dt=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return de(this,void 0,void 0,(function(){return fe(this,(function(e){return[2,!0]}))}))},e.prototype.get=function(e){return de(this,void 0,void 0,(function(){return fe(this,(function(t){return[2,this.memoryStorage.get(e)]}))}))},e.prototype.getRaw=function(e){return de(this,void 0,void 0,(function(){var t;return fe(this,(function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}}))}))},e.prototype.set=function(e,t){return de(this,void 0,void 0,(function(){return fe(this,(function(n){return this.memoryStorage.set(e,t),[2]}))}))},e.prototype.remove=function(e){return de(this,void 0,void 0,(function(){return fe(this,(function(t){return this.memoryStorage.delete(e),[2]}))}))},e.prototype.reset=function(){return de(this,void 0,void 0,(function(){return fe(this,(function(e){return this.memoryStorage.clear(),[2]}))}))},e}(),Lt=function(){function e(e){this.options=ue({},e)}return e.prototype.isEnabled=function(){return de(this,void 0,void 0,(function(){var t,n;return fe(this,(function(r){switch(r.label){case 0:if(!$e())return[2,!1];e.testValue=String(Date.now()),t=new e(this.options),n="AMP_TEST",r.label=1;case 1:return r.trys.push([1,4,5,7]),[4,t.set(n,e.testValue)];case 2:return r.sent(),[4,t.get(n)];case 3:return[2,r.sent()===e.testValue];case 4:return r.sent(),[2,!1];case 5:return[4,t.remove(n)];case 6:return r.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){var t;return de(this,void 0,void 0,(function(){var n,r;return fe(this,(function(i){switch(i.label){case 0:return[4,this.getRaw(e)];case 1:if(!(n=i.sent()))return[2,void 0];try{return void 0===(r=null!==(t=Nt(n))&&void 0!==t?t:Ut(n))?(console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(n)),[2,void 0]):[2,JSON.parse(r)]}catch(t){return console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(n)),[2,void 0]}return[2]}}))}))},e.prototype.getRaw=function(e){var t,n;return de(this,void 0,void 0,(function(){var r,i,o;return fe(this,(function(a){return r=$e(),i=null!==(n=null===(t=null==r?void 0:r.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[],o=i.find((function(t){return 0===t.indexOf(e+"=")})),o?[2,o.substring(e.length+1)]:[2,void 0]}))}))},e.prototype.set=function(e,t){var n;return de(this,void 0,void 0,(function(){var r,i,o,a,s,c,u;return fe(this,(function(l){try{r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=void 0,(i=null!==t?r:-1)&&((a=new Date).setTime(a.getTime()+24*i*60*60*1e3),o=a),s="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t)))),o&&(s+="; expires=".concat(o.toUTCString())),s+="; path=/",this.options.domain&&(s+="; domain=".concat(this.options.domain)),this.options.secure&&(s+="; Secure"),this.options.sameSite&&(s+="; SameSite=".concat(this.options.sameSite)),(c=$e())&&(c.document.cookie=s)}catch(t){u=t instanceof Error?t.message:String(t),console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(u))}return[2]}))}))},e.prototype.remove=function(e){return de(this,void 0,void 0,(function(){return fe(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 de(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},e}(),Nt=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}},Ut=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}},jt=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[me,t,e.substring(0,n)].filter(Boolean).join("_")},Mt=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return de(this,void 0,void 0,(function(){var t,n,r;return fe(this,(function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return de(this,void 0,void 0,(function(){var t;return fe(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())?[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){var t;return de(this,void 0,void 0,(function(){return fe(this,(function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]}))}))},e.prototype.set=function(e,t){var n;return de(this,void 0,void 0,(function(){return fe(this,(function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]}))}))},e.prototype.remove=function(e){var t;return de(this,void 0,void 0,(function(){return fe(this,(function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]}))}))},e.prototype.reset=function(){var e;return de(this,void 0,void 0,(function(){return fe(this,(function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]}))}))},e}(),qt="tags",Ft="counters",Bt="histograms",$t="events",Kt="internal",Ht="last_flush_timestamp",zt=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=$e())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return de(this,void 0,void 0,(function(){return fe(this,(function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]}))}))},e.prototype.openDB=function(){var e=this;return new Promise((function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new 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(qt)||e.createObjectStore(qt,{keyPath:"key"}),e.objectStoreNames.contains(Ft)||e.createObjectStore(Ft,{keyPath:"key"}),e.objectStoreNames.contains(Bt)||e.createObjectStore(Bt,{keyPath:"key"}),e.objectStoreNames.contains($t))||e.createObjectStore($t,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Kt)||e.createObjectStore(Kt,{keyPath:"key"})},e.prototype.setTags=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i,o=this;return fe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([qt],"readwrite"),r=n.objectStore(qt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach((function(e){var t=ge(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}}))}))},e.prototype.incrementCounters=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i,o=this;return fe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Ft],"readwrite"),r=n.objectStore(Ft),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach((function(e){var t=ge(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e=a.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}}))}))},e.prototype.setHistogramStats=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i,o=this;return fe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Bt],"readwrite"),r=n.objectStore(Bt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach((function(e){var t=ge(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e,t=a.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}}))}))},e.prototype.addEventRecords=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i,o=this;return fe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([$t],"readwrite"),r=n.objectStore($t),[2,new Promise((function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach((function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}}))},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}}))}))},e.prototype.setInternal=function(e,t){return de(this,void 0,void 0,(function(){var n,r,i,o;return fe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=a.sent(),r=n.transaction([Kt],"readwrite"),i=r.objectStore(Kt),[2,new Promise((function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var a=i.put({key:e,value:t});a.onsuccess=function(){return n()},a.onerror=function(){return o(new Error("Failed to set internal value"))}}))];case 2:return o=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}}))}))},e.prototype.getInternal=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i;return fe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Kt],"readonly"),r=n.objectStore(Kt),[2,new Promise((function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}}))];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}}))}))},e.prototype.getLastFlushTimestamp=function(){return de(this,void 0,void 0,(function(){var e,t;return fe(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Ht)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}}))}))},e.prototype.setLastFlushTimestamp=function(e){return de(this,void 0,void 0,(function(){var t;return fe(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Ht,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(new Error("Failed to clear table ".concat(t)))}}))},e.prototype.getAllAndClear=function(){return de(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s;return fe(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([qt,Ft,Bt,$t],"readwrite"),[4,Promise.all([this.getAllFromStore(t,qt),this.getAllFromStore(t,Ft),this.getAllFromStore(t,Bt),this.getAllFromStore(t,$t)])];case 2:return n=ge.apply(void 0,[c.sent(),4]),r=n[0],i=n[1],o=n[2],a=n[3],[4,Promise.all([this.clearTable(t,Ft),this.clearTable(t,Bt),this.clearTable(t,$t)])];case 3:return c.sent(),[2,{tags:r,counters:i,histogramStats:o,events:a}];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(new Error("Failed to get all from ".concat(t)))}}))},e}(),Vt=function(e){var t,n=null==(t=$e())?void 0:t.__AMPLITUDE_SCRIPT_URL__;if(n)return e.filename&&e.filename.includes(n)?"filename":e.stack&&e.stack.includes(n)?"stack":void 0},Gt=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},Jt=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},Wt=3e5,Yt=1e4,Qt=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=ue({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Ct(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,zt.isSupported()?this.storage=new zt(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=$e();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",ue({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",(function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Vt({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})}),!0),t.addEventListener("unhandledrejection",(function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Gt(i),a=Vt({filename:o,stack:i});a&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:Jt(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})}),!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=Yt?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=Yt?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=Yt)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{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){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout((function(){e.saveAllDataToStorage().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)})).finally((function(){e.saveTimer=null}))}),1e3)),this.flushTimer||(this.flushTimer=setTimeout((function(){e._flush().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)})).finally((function(){e.flushTimer=null}))}),Wt))},e.prototype.saveAllDataToStorage=function(){return de(this,void 0,void 0,(function(){var e,t,n,r;return fe(this,(function(i){switch(i.label){case 0:return this.storage?(e=ue({},this.inMemoryTags),t=ue({},this.inMemoryCounters),n=ue({},this.inMemoryHistograms),r=he([],ge(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 de(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,c,u;return fe(this,(function(l){switch(l.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return l.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=l.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach((function(e){o[e.key]=e.value})),a={},n.forEach((function(e){a[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}})),0===Object.keys(a).length&&0===Object.keys(s).length&&0===c.length?[2]:(u={tags:o,histogram:s,counters:a,events:c},this.fetch(u),[2])}}))}))},e.prototype.fetch=function(e){return de(this,void 0,void 0,(function(){var t;return fe(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!$e())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}}))}))},e.prototype.initializeFlushInterval=function(){return de(this,void 0,void 0,(function(){var e,t,n;return fe(this,(function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(Wt),[2]):(n=e-t)>=Wt?(this._flush(),[2]):(this._setFlushTimer(Wt-n),[2])}}))}))},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout((function(){t._flush().catch((function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)})).finally((function(){t.flushTimer=null}))}),e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=Ct(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),Xt=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k;if("object"!=typeof e)return null;var S=e.code||0,E=this.buildStatus(S);switch(E){case Me.Success:return{status:E,statusCode:S,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case Me.Invalid:return{status:E,statusCode:S,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(s=e.events_with_missing_fields)&&void 0!==s?s:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(p=e.throttled_devices)&&void 0!==p?p:{},throttledEvents:null!==(g=e.throttled_events)&&void 0!==g?g:[]}};case Me.PayloadTooLarge:return{status:E,statusCode:S,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case Me.RateLimit:return{status:E,statusCode:S,body:{error:null!==(v=e.error)&&void 0!==v?v:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(T=e.exceeded_daily_quota_devices)&&void 0!==T?T:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(k=e.throttled_events)&&void 0!==k?k:[]}};case Me.Timeout:default:return{status:E,statusCode:S}}},e.prototype.buildStatus=function(e){return it(e)?Me.Success:429===e?Me.RateLimit:413===e?Me.PayloadTooLarge:408===e?Me.Timeout:e>=400&&e<500?Me.Invalid:e>=500?Me.Failed:Me.Unknown},e}(),Zt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ae(t,e),t.prototype.send=function(e,t){return de(this,void 0,void 0,(function(){var n,r,i;return fe(this,(function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(Xt),en=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),tn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new en(e,t)}return e.prototype.subscribe=function(e,t,n){var r=He(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex((function(t){return t.id===e}));return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return de(this,void 0,void 0,(function(){var e,t=this;return fe(this,(function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach((function(n){t.sendCallback(n,e,"remote")})),[2]}}))}))},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.fetchPromise=this.fetch().then((function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t})).finally((function(){e.fetchPromise=null}))),this.fetchPromise},e.prototype.subscribeAll=function(e){return de(this,void 0,void 0,(function(){var t,n,r,i=this;return fe(this,(function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then((function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)})),n=this.storage.fetchConfig().then((function(e){return e})),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}}))}))},e.prototype.subscribeWaitForRemote=function(e,t){return de(this,void 0,void 0,(function(){var n,r;return fe(this,(function(i){switch(i.label){case 0:n=new Promise((function(e,n){setTimeout((function(){n("Timeout exceeded")}),t)})),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}}))}))},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce((function(e,t){return null===e?e:t in e?e[t]:null}),t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),de(this,void 0,void 0,(function(){var n,r,i,o,a,s,c=this;return fe(this,(function(u){switch(u.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,s,u,l;return fe(this,(function(d){switch(d.label){case 0:i=new AbortController,a=setTimeout((function(){return i.abort()}),t),d.label=1;case 1:return d.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:i.signal})];case 2:return(s=d.sent()).ok?[3,4]:[4,s.text()];case 3:return u=d.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(s.status,": ").concat(u)),[3,6];case 4:return[4,s.json()];case 5:return[2,{value:{remoteConfig:d.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(l=d.sent())instanceof Error&&"AbortError"===l.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),l),[3,9];case 8:return clearTimeout(a),[7];case 9:return r<e-1?[4,new Promise((function(e){return setTimeout(e,c.getJitterDelay(n))}))]:[3,11];case 10:d.sent(),d.label=11;case 11:return[2]}}))},o=this,a=0,u.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(s=u.sent()))return[2,s.value];u.label=3;case 3:return a++,[3,1];case 4:return[2,r]}}))}))},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}();!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(bt||(bt={}));var nn=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],rn="data-amp-track-",on=["div","span","h1","h2","h3","h4","h5","h6"],an=he(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],ge(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),sn=["*"];function cn(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function un(e,t,n){e&&ln({json:e,allowlist:t.map(dn),excludelist:n.map(dn),ancestors:[]})}function ln(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,a=e.excludelist,s=e.ancestors,c=e.parentObject,u=e.targetKey;i||(i=r);var l=Object.keys(i);try{for(var d=pe(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=he(he([],ge(s),!1),[p],!1);cn(i[p])?pn(g,o)&&!pn(g,a)||delete i[p]:ln({json:r,targetObject:i[p],allowlist:o,excludelist:a,ancestors:g,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}}0===Object.keys(i).length&&c&&u&&delete c[u]}function dn(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map((function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")}))}function fn(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(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 o=n;o<=e.length;o++)if(fn(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&fn(e,t,n+1,r+1)}function pn(e,t){return t.some((function(t){return fn(e,t)}))}var gn=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach((function(e){var t=ge(e,2),n=t[0],r=t[1];i[n]=r}));else if(r instanceof Headers)r.forEach((function(e,t){i[t]=e}));else if("object"==typeof r&&null!==r)try{for(var o=pe(Object.entries(r)),a=o.next();!a.done;a=o.next()){var s=ge(a.value,2),c=s[0],u=s[1];i[c]=u}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kn(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=$e();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=vn(t,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"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),de(this,void 0,void 0,(function(){return fe(this,(function(n){return 0===e.length?[2,null]:[2,Tn(this.body,e,t)]}))}))},e}(),hn=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),kn(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return vn(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),de(this,void 0,void 0,(function(){return fe(this,(function(n){return 0===e.length?[2,null]:[2,Tn(this.body,e,t)]}))}))},e}();function vn(e,t){var n,r,i,o=$e(),a=null==o?void 0:o.TextEncoder;if(a){var s;if("string"==typeof e)s=e,i=(new a).encode(s).length;else if(e instanceof Blob)i=(s=e).size;else if(e instanceof URLSearchParams)s=e,i=(new a).encode(s.toString()).length;else if(ArrayBuffer.isView(e))i=(s=e).byteLength;else if(e instanceof ArrayBuffer)i=(s=e).byteLength;else if(e instanceof FormData){var c=e,u=0,l=0;try{for(var d=pe(c.entries()),f=d.next();!f.done;f=d.next()){var p=ge(f.value,2),g=p[0],h=p[1];if(u+=g.length,"string"==typeof h)u+=(new a).encode(h).length;else{if(!(h instanceof Blob))return;u+=h.size}if(++l>=t)return}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}i=u}else if(e instanceof ReadableStream)return void(s=e);return i}}var mn,yn=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,(function(e,t){r[t]=e})),kn(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return de(this,void 0,void 0,(function(){var e,t;return fe(this,(function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise((function(e){return setTimeout((function(){return e(null)}),500)})),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}}))}))},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),de(this,void 0,void 0,(function(){return fe(this,(function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,Tn(n.sent(),e,t)]}}))}))},e}(),bn=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(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=pe(i),a=o.next();!a.done;a=o.next()){var s=ge(a.value.split(": "),2),c=s[0],u=s[1];c&&u&&(r[c]=u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kn(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),de(this,void 0,void 0,(function(){var n;return fe(this,(function(r){return 0===e.length?[2,null]:(n=this.getJson())?(un(n,e,t),[2,n]):[2,null]}))}))},e}();function Tn(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return un(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(mn||(mn={}));var wn="[REDACTED]",kn=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,a=t.strategy,s=void 0===a?mn.REMOVE:a,c=he([],ge(Le),!1),u={},l=function(t){var n=t.toLowerCase();c.find((function(e){return e.toLowerCase()===n}))?s===mn.REDACT&&(u[t]=wn):o.find((function(e){return e.toLowerCase()===n}))?u[t]=e[t]:s===mn.REDACT&&(u[t]=wn)};try{for(var d=pe(Object.keys(e)),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u},Sn=function(){function e(e,t,n,r,i,o,a,s,c,u,l){void 0===a&&(a=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=a,this.duration=s,this.responseWrapper=c,this.error=u,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(he([],ge(De),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(he([],ge(De),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter((function(e){var t=ge(e,2);return t[0],void 0!==t[1]})))},e}();var En=function(e,t){void 0===t&&(t=He()),this.callback=e,this.id=t},_n=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=$e();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=$e();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,a,s,c,u,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,p=null===(s=null===(a=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===a?void 0:a.prototype)||void 0===s?void 0:s.send,g=null===(l=null===(u=null===(c=this.globalScope)||void 0===c?void 0:c.XMLHttpRequest)||void 0===u?void 0:u.prototype)||void 0===l?void 0:l.setRequestHeader;f&&p&&g&&this.observeXhr(f,p,g);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),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){var r;try{n.callback(e)}catch(e){null===(r=t.logger)||void 0===r||r.debug("an unexpected error occurred while triggering event callbacks",e)}}))},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,a){var s;if(void 0!==o&&void 0!==a){var c,u,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?c=null===(s=null==t?void 0:t.toString)||void 0===s?void 0:s.call(t):(c=t.url,d=t.method),c)try{var f=new URL(c);c="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(u=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},u=0);var p=Math.floor(performance.now()-a),g=Math.floor(o+p),h=new Sn(e,d,o,o,c,n,u,p,r,l,g);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return de(t,void 0,void 0,(function(){var t,i,o,a,s,c;return fe(this,(function(u){switch(u.label){case 0:try{t=this.getTimestamps()}catch(e){null===(s=this.logger)||void 0===s||s.debug("an unexpected error occurred while retrieving timestamps",e)}u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),o=a,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new gn(r):void 0,i?new yn(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while handling fetch",e)}if(i)return[2,i];throw o}}))}))})},e.createXhrJsonParser=function(e,t){return function(){var n,r;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&(null===(r=t.logger)||void 0===r||r.error("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=ge(r,2),s=a[0],c=a[1];try{this.$$AmplitudeAnalyticsEvent=ue({method:s,url:null===(e=null==c?void 0:c.toString)||void 0===e?void 0:e.call(c),headers:{}},o.getTimestamps())}catch(e){null===(n=o.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr open",e)}return t.apply(this,r)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,a=e.createXhrJsonParser(this,o),s=t[0],c=i.$$AmplitudeAnalyticsEvent;return i.addEventListener("loadend",(function(){var e;try{var t=i.getAllResponseHeaders(),n=i.getResponseHeader("content-length"),r=new bn(i.status,t,n?parseInt(n,10):void 0,a),u=i.$$AmplitudeAnalyticsEvent.headers,l=new hn(s,u);c.status=i.status,o.handleNetworkRequestEvent("xhr",{url:c.url,method:c.method},l,r,void 0,c.startTime,c.durationStart)}catch(t){null===(e=o.logger)||void 0===e||e.error("an unexpected error occurred while handling xhr send",t)}})),n.apply(i,t)},i.setRequestHeader=function(e,t){var n;try{this.$$AmplitudeAnalyticsEvent.headers[e]=t}catch(e){null===(n=o.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr setRequestHeader",e)}r.apply(this,[e,t])}}},e}(),In=new _n,Pn=function(){function e(){}return e.prototype.parse=function(){return de(this,void 0,void 0,(function(){return fe(this,(function(e){return[2,ue(ue(ue(ue({},Ce),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=At();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=At();return(e={})[we]=t[we],e[ke]=t[ke],e[Se]=t[Se],e[Ee]=t[Ee],e[_e]=t[_e],e[Ie]=t[Ie],e[Pe]=t[Pe],e[Ae]=t[Ae],e[Oe]=t[Oe],e[Re]=t[Re],e[xe]=t[xe],e},e}(),An="data-amp-mask",On="*****",Rn=/\b(?:\d[ -]*?){13,16}\b/,xn=/(\d{3}-?\d{2}-?\d{4})/g,Cn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Dn=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(Rn,On)).replace(xn,On)).replace(Cn,On);try{for(var o=pe(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,On)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},Ln=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(An)?On:e?e(document.title):document.title};function Nn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Un(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Un(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Un(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Mn(e,t,n){return t&&jn(e.prototype,t),n&&jn(e,n),e}var qn=function(){return"function"==typeof Symbol},Fn=function(e){return qn()&&Boolean(Symbol[e])},Bn=function(e){return Fn(e)?Symbol[e]:"@@"+e};qn()&&!Fn("observable")&&(Symbol.observable=Symbol("observable"));var $n=Bn("iterator"),Kn=Bn("observable"),Hn=Bn("species");function zn(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function Vn(e){var t=e.constructor;return void 0!==t&&null===(t=t[Hn])&&(t=void 0),void 0!==t?t:nr}function Gn(e){return e instanceof nr}function Jn(e){Jn.log?Jn.log(e):setTimeout((function(){throw e}))}function Wn(e){Promise.resolve().then((function(){try{e()}catch(e){Jn(e)}}))}function Yn(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=zn(t,"unsubscribe");n&&n.call(t)}}catch(e){Jn(e)}}function Qn(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function Xn(e,t,n){e._state="running";var r=e._observer;try{var i=zn(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(Qn(e),!i)throw n;i.call(r,n);break;case"complete":Qn(e),i&&i.call(r)}}catch(e){Jn(e)}"closed"===e._state?Yn(e):"running"===e._state&&(e._state="ready")}function Zn(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void Wn((function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(Xn(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)}))):void Xn(e,t,n);e._queue.push({type:t,value:n})}}var er=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new tr(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(Qn(this),Yn(this))},Mn(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),tr=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){Zn(this._subscription,"next",e)},t.error=function(e){Zn(this._subscription,"error",e)},t.complete=function(){Zn(this._subscription,"complete")},Mn(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),nr=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new er(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise((function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}}))},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Vn(this))((function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Vn(this))((function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Vn(this),r=arguments.length>1,i=!1,o=arguments[1];return new n((function(n){return t.subscribe({next:function(t){var a=!i;if(i=!0,!a||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})}))},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=Vn(this);return new i((function(t){var r,o=0;return function e(a){r=a.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}}))},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Vn(this);return new n((function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))},t[Kn]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=zn(t,Kn);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Gn(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(Fn("iterator")&&(r=zn(t,$n)))return new n((function(e){Wn((function(){if(!e.closed){for(var n,i=Nn(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){Wn((function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)((function(e){Wn((function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}}))}))},Mn(e,null,[{key:Hn,get:function(){return this}}]),e}();function rr(e,t){return new nr((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 ir(e,t){return new nr((function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=pe(i),o=n.next();!o.done;o=n.next()){var a=o.value;try{a.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},a=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return a(e),a(t),o}))}function or(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new nr((function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=pe(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.next)||void 0===i||i.call(s,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var a=pe(t),s=a.next();!s.done;s=a.next()){var c=s.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=pe(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.complete)||void 0===i||i.call(s)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}}))}qn()&&Object.defineProperty(nr,Symbol("extensions"),{value:{symbol:Kn,hostReportError:Jn},configurable:!0});var ar=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},sr=function(e){return ar(e,"attribution")},cr=function(e){return ar(e,"pageViews")},ur=function(e){return ar(e,"sessions")},lr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},dr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},fr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},pr=function(e){if(dr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},gr=function(e){if(fr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},hr=function(e){var t;if(lr(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),ue(ue({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map((function(t){var n,r,i;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var o=JSON.stringify(t.hosts),a=JSON.stringify(t.urls);return null===(i=e.loggerProvider)||void 0===i||i.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),ue(ue({},t),{hosts:void 0})}return t}))})}},vr=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return cr(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},mr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,a=r.resolve,s=e&&e[i];if("function"==typeof s){var c=s.apply(e,o);"function"==typeof a&&a(null==c?void 0:c.promise)}}return e},yr=function(e){return e&&void 0!==e._q},br="2.32.2",Tr="amplitude-ts",wr=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(Tr,"/").concat(br),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return de(this,void 0,void 0,(function(){var r,i,o;return fe(this,(function(a){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,o=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,ue(ue(ue(ue(ue(ue(ue(ue({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Pt()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:He(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:o,library:this.library,user_agent:this.userAgent})]}))}))},e}(),kr=1e3,Sr=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=$e())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return ae(t,e),t.prototype.set=function(t,n){var r;return de(this,void 0,void 0,(function(){var i;return fe(this,(function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>kr?(i=n.length-kr,[4,e.prototype.set.call(this,t,n.slice(0,kr))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(kr,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))},t}(Mt),Er=function(e){function t(){var t;return e.call(this,null===(t=$e())||void 0===t?void 0:t.sessionStorage)||this}return ae(t,e),t}(Mt),_r=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={done:4},t}return ae(t,e),t.prototype.send=function(e,t){return de(this,void 0,void 0,(function(){var n=this;return fe(this,(function(r){return[2,new Promise((function(r,i){"undefined"==typeof XMLHttpRequest&&i(new Error("XHRTransport is not supported."));var o=new XMLHttpRequest;o.open("POST",e,!0),o.onreadystatechange=function(){if(o.readyState===n.state.done){var e=o.responseText;try{r(n.buildResponse(JSON.parse(e)))}catch(e){r(n.buildResponse({code:o.status}))}}},o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Accept","*/*"),o.send(JSON.stringify(t))}))]}))}))},t}(Xt),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ae(t,e),t.prototype.send=function(e,t){return de(this,void 0,void 0,(function(){var n=this;return fe(this,(function(r){return[2,new Promise((function(r,i){var o=$e();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var a=JSON.stringify(t);return r(o.navigator.sendBeacon(e,JSON.stringify(t))?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:a.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}}))]}))}))},t}(Xt),Pr=function(e,t,n){return void 0===n&&(n=!0),de(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d;return fe(this,(function(f){switch(f.label){case 0:return r=function(e){return"".concat(me.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=f.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:f.sent(),f.label=3;case 3:return o=ge(i.split("."),6),a=o[0],s=o[1],c=o[2],u=o[3],l=o[4],d=o[5],[2,{deviceId:a,userId:Or(s),sessionId:Ar(u),lastEventId:Ar(d),lastEventTime:Ar(l),optOut:Boolean(c)}]}}))}))},Ar=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Or=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Rr="[Amplitude]",xr="".concat(Rr," Form Started"),Cr="".concat(Rr," Form Submitted"),Dr="".concat(Rr," File Downloaded"),Lr="session_start",Nr="session_end",Ur="".concat(Rr," File Extension"),jr="".concat(Rr," File Name"),Mr="".concat(Rr," Link ID"),qr="".concat(Rr," Link Text"),Fr="".concat(Rr," Link URL"),Br="".concat(Rr," Form ID"),$r="".concat(Rr," Form Name"),Kr="".concat(Rr," Form Destination"),Hr="cookie",zr=function(e){function t(t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,S,E,_,I,P,A,O,R,x,C,D,L,N,U,j,M,q,F){void 0===r&&(r=new Dt),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===c&&(c=1e3),void 0===u&&(u=5),void 0===l&&(l=30),void 0===d&&(d=Hr),void 0===v&&(v=new Xe),void 0===m&&(m=Ye.Warn),void 0===b&&(b=!1),void 0===T&&(T=!1),void 0===S&&(S=""),void 0===E&&(E="US"),void 0===I&&(I=18e5),void 0===P&&(P=new Sr({loggerProvider:v})),void 0===A&&(A={ipAddress:!0,language:!0,platform:!0}),void 0===O&&(O="fetch"),void 0===R&&(R=!1),void 0===x&&(x=!0),void 0===j&&(j=!0),void 0===M&&(M=0);var B,$=e.call(this,{apiKey:t,storageProvider:P,transportProvider:Jr(O)})||this;return $.apiKey=t,$.appVersion=n,$.cookieOptions=i,$.defaultTracking=o,$.autocapture=a,$.flushIntervalMillis=c,$.flushMaxRetries=u,$.flushQueueSize=l,$.identityStorage=d,$.ingestionMetadata=f,$.instanceName=p,$.loggerProvider=v,$.logLevel=m,$.minIdLength=y,$.offline=b,$.partnerId=w,$.plan=k,$.serverUrl=S,$.serverZone=E,$.sessionTimeout=I,$.storageProvider=P,$.trackingOptions=A,$.transport=O,$.useBatch=R,$.fetchRemoteConfig=x,$.networkTrackingOptions=N,$.identify=U,$.enableDiagnostics=j,$.diagnosticsSampleRate=M,$.diagnosticsClient=q,$.remoteConfig=F,$.version=br,$._optOut=!1,$._cookieStorage=r,$.deviceId=s,$.lastEventId=g,$.lastEventTime=h,$.optOut=T,$.sessionId=_,$.pageCounter=D,$.userId=C,$.debugLogsEnabled=L,$.loggerProvider.enable(L?Ye.Debug:$.logLevel),$.networkTrackingOptions=N,$.identify=U,$.enableDiagnostics=j,$.diagnosticsSampleRate=M,$.diagnosticsClient=q,B=!0===(null==F?void 0:F.fetchRemoteConfig)||!1!==(null==F?void 0:F.fetchRemoteConfig)&&!1!==x,$.remoteConfig=$.remoteConfig||{},$.remoteConfig.fetchRemoteConfig=B,$.fetchRemoteConfig=B,$}return ae(t,e),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,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,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled};this.cookieStorage.set(It(this.apiKey),e)},t}(et),Vr=function(e,t,n){return void 0===t&&(t={}),de(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,S,E,_,I,P,A,O,R,x,C,D,L,N,U,j,M,q,F,B,$,K,H,z,V,G;return fe(this,(function(J){switch(J.label){case 0:return r=t.identityStorage||Hr,S={},r===Hr?[3,1]:(o="",[3,5]);case 1:return null===(_=null===(E=t.cookieOptions)||void 0===E?void 0:E.domain)||void 0===_?[3,2]:(a=_,[3,4]);case 2:return[4,Wr()];case 3:a=J.sent(),J.label=4;case 4:o=a,J.label=5;case 5:return i=ue.apply(void 0,[(S.domain=o,S.expiration=365,S.sameSite="Lax",S.secure=!1,S.upgrade=!0,S),t.cookieOptions]),s=Gr(t.identityStorage,i),[4,Pr(e,s,null===(P=null===(I=t.cookieOptions)||void 0===I?void 0:I.upgrade)||void 0===P||P)];case 6:return c=J.sent(),[4,s.get(It(e))];case 7:return u=J.sent(),l=At(),d=l.ampTimestamp?Number(l.ampTimestamp):void 0,f=!d||Date.now()<d,p=null!==(C=null!==(x=null!==(R=null!==(A=t.deviceId)&&void 0!==A?A:f?null!==(O=l.ampDeviceId)&&void 0!==O?O:l.deviceId:void 0)&&void 0!==R?R:null==u?void 0:u.deviceId)&&void 0!==x?x:c.deviceId)&&void 0!==C?C:He(),g=null!==(D=null==u?void 0:u.lastEventId)&&void 0!==D?D:c.lastEventId,h=null!==(L=null==u?void 0:u.lastEventTime)&&void 0!==L?L:c.lastEventTime,v=null!==(U=null!==(N=t.optOut)&&void 0!==N?N:null==u?void 0:u.optOut)&&void 0!==U?U:c.optOut,m=null!==(j=null==u?void 0:u.sessionId)&&void 0!==j?j:c.sessionId,y=null!==(q=null!==(M=t.userId)&&void 0!==M?M:null==u?void 0:u.userId)&&void 0!==q?q:c.userId,n.previousSessionDeviceId=null!==(F=null==u?void 0:u.deviceId)&&void 0!==F?F:c.deviceId,n.previousSessionUserId=null!==(B=null==u?void 0:u.userId)&&void 0!==B?B:c.userId,b={ipAddress:null===(K=null===($=t.trackingOptions)||void 0===$?void 0:$.ipAddress)||void 0===K||K,language:null===(z=null===(H=t.trackingOptions)||void 0===H?void 0:H.language)||void 0===z||z,platform:null===(G=null===(V=t.trackingOptions)||void 0===V?void 0:V.platform)||void 0===G||G},T=null==u?void 0:u.pageCounter,w=null==u?void 0:u.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(k=new zr(e,t.appVersion,s,i,t.defaultTracking,t.autocapture,p,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,r,t.ingestionMetadata,t.instanceName,g,h,t.loggerProvider,t.logLevel,t.minIdLength,t.offline,v,t.partnerId,t.plan,t.serverUrl,t.serverZone,m,t.sessionTimeout,t.storageProvider,b,t.transport,t.useBatch,t.fetchRemoteConfig,y,T,w,t.networkTrackingOptions,t.identify,t.enableDiagnostics,n._diagnosticsSampleRate,void 0,t.remoteConfig)).storageProvider.isEnabled()];case 8:return J.sent()||(k.loggerProvider.warn("Storage provider ".concat(k.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),k.storageProvider=new Dt),[2,k]}}))}))},Gr=function(e,t){switch(void 0===e&&(e=Hr),void 0===t&&(t={}),e){case"localStorage":return new Sr;case"sessionStorage":return new Er;case"none":return new Dt;default:return new Lt(ue(ue({},t),{expirationDays:t.expiration}))}},Jr=function(e){return"xhr"===e?new _r:"beacon"===e?new Ir:new Zt},Wr=function(e){return de(void 0,void 0,void 0,(function(){var e,t,n,r,i,o,a;return fe(this,(function(s){switch(s.label){case 0:return[4,(new Lt).isEnabled()];case 1:if(!s.sent()||"undefined"==typeof location||!location.hostname)return[2,""];for(e=location.hostname,t=e.split("."),n=[],r="AMP_TLDTEST",i=t.length-2;i>=0;--i)n.push(t.slice(i).join("."));i=0,s.label=2;case 2:return i<n.length?(o=n[i],[4,(a=new Lt({domain:"."+o})).set(r,1)]):[3,7];case 3:return s.sent(),[4,a.get(r)];case 4:return s.sent()?[4,a.remove(r)]:[3,6];case 5:return s.sent(),[2,"."+o];case 6:return i++,[3,2];case 7:return[2,""]}}))}))},Yr=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Qr=function(e){var t;void 0===e&&(e={});var n,r=$e(),i=void 0,o=!1,a=e.trackOn,s=e.trackHistoryChanges,c=e.eventType,u=void 0===c?"[Amplitude] Page Viewed":c,l=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==i||i.error("Malformed URI sequence: ",e)}return t},d=function(){return de(void 0,void 0,void 0,(function(){var e,t,n;return fe(this,(function(r){switch(r.label){case 0:return e=l("undefined"!=typeof location&&location.href||""),n={event_type:u},t=[{}],[4,Xr()];case 1:return[2,(n.event_properties=ue.apply(void 0,[ue.apply(void 0,t.concat([r.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":e,"[Amplitude] Page Path":"undefined"!=typeof location&&l(location.pathname)||"","[Amplitude] Page Title":Ln(Dn),"[Amplitude] Page URL":e.split("?")[0]}]),n)]}}))}))},f=function(){return void 0===a||"function"==typeof a&&a()},p="undefined"!=typeof location?location.href:null,g=function(){return de(void 0,void 0,void 0,(function(){var e,n,r,o;return fe(this,(function(a){switch(a.label){case 0:return e=location.href,n=ei(s,e,p||"")&&f(),p=e,n?(null==i||i.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return o=(r=t).track,[4,d()];case 2:o.apply(r,[a.sent()]),a.label=3;case 3:a.label=4;case 4:return[2]}}))}))},h=function(){g()},v={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,a){return de(void 0,void 0,void 0,(function(){var s,c;return fe(this,(function(u){switch(u.label){case 0:return t=a,n=e,(i=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o=!0,r&&(r.addEventListener("popstate",h),r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=ge(n,3),i=r[0],a=r[1],s=r[2];e.apply(t,[i,a,s]),o&&g()}})),f()?(i.log("Tracking page view event"),c=(s=t).track,[4,d()]):[3,2];case 1:c.apply(s,[u.sent()]),u.label=2;case 2:return[2]}}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){var t;return fe(this,(function(r){switch(r.label){case 0:return"attribution"===a&&Zr(e)?(null==i||i.log("Enriching campaign event to page view event with campaign parameters"),[4,d()]):[3,2];case 1:t=r.sent(),e.event_type=t.event_type,e.event_properties=ue(ue({},e.event_properties),t.event_properties),r.label=2;case 2:return n&&e.event_type===u&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=ue(ue({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(e){return r&&(r.removeEventListener("popstate",h),o=!1),[2]}))}))}};return v},Xr=function(){return de(void 0,void 0,void 0,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return e=Yr,[4,(new Pn).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},Zr=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[se.SET]||{},r=t[se.UNSET]||{},i=he(he([],ge(Object.keys(n)),!1),ge(Object.keys(r)),!1);return Object.keys(Ce).every((function(e){return i.includes(e)}))}return!1},ei=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},ti=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(t,r){return de(void 0,void 0,void 0,(function(){var i,o;return fe(this,(function(a){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var t=!1;n(e,"change",(function(){var n,i=ri(e);t||r.track(xr,((n={})[Br]=ni(e.id),n[$r]=ni(e.name),n[Kr]=i,n)),t=!0})),n(e,"submit",(function(){var n,i,o=ri(e);t||r.track(xr,((n={})[Br]=ni(e.id),n[$r]=ni(e.name),n[Kr]=o,n)),r.track(Cr,((i={})[Br]=ni(e.id),i[$r]=ni(e.name),i[Kr]=o,i)),t=!1}))};Array.from(document.getElementsByTagName("form")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"FORM"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else t.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?i():(o=$e())?o.addEventListener("load",i):t.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},ni=function(e){if("string"==typeof e)return e},ri=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},ii=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return de(void 0,void 0,void 0,(function(){var i,o;return fe(this,(function(a){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),a=null==i?void 0:i[1];a&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",(function(){var t;a&&r.track(Dr,((t={})[Ur]=a,t[jr]=n.pathname,t[Mr]=e.id,t[qr]=e.text,t[Fr]=e.href,t))}))},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=$e())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},oi=!1,ai=function(){var e=$e(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return de(void 0,void 0,void 0,(function(){return fe(this,(function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",(function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout((function(){t.flush()}),e.flushIntervalMillis)})),n("offline",(function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2])}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(n){return t.forEach((function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)})),t=[],[2]}))}))}}};function si(e){var t,n,r,i,o,a,s,c,u,l,d;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var f=Object.keys(e);try{for(var p=pe(f),g=p.next();!g.done;g=p.next()){var h=g.value;try{var v=e[h];"boolean"==typeof(null==v?void 0:v.enabled)&&(v.enabled?(delete v.enabled,0===Object.keys(v).length&&(e[h]=!0)):e[h]=!1),si(v)}catch(e){}}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}try{if(null===(u=null===(c=null===(s=e.autocapture)||void 0===s?void 0:s.networkTracking)||void 0===c?void 0:c.captureRules)||void 0===u?void 0:u.length)try{for(var m=pe(e.autocapture.networkTracking.captureRules),y=m.next();!y.done;y=m.next()){var b=y.value;try{for(var T=(o=void 0,pe(["responseHeaders","requestHeaders"])),w=T.next();!w.done;w=T.next()){var k=w.value,S=null!==(l=b[k])&&void 0!==l?l:{},E=S.captureSafeHeaders,_=S.allowlist;(E||_)&&(void 0===_||Array.isArray(_)?b[k]=he(he([],ge(E?De:[]),!1),ge(null!=_?_:[]),!1):delete b[k])}}catch(e){o={error:e}}finally{try{w&&!w.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}catch(e){}var I=null===(d=e.autocapture)||void 0===d?void 0:d.frustrationInteractions;I&&(I.rageClick&&(I.rageClicks=I.rageClick,delete I.rageClick),I.deadClick&&(I.deadClicks=I.deadClick,delete I.deadClick))}}function ci(e,t,n){var r,i,o=[];try{for(var a=pe(null!=t?t:[]),s=a.next();!s.done;s=a.next()){var c=s.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e.concat(o)}function ui(e,t){var n,r,i,o,a,s,c;if(e){si(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var u=e;if(u&&"autocapture"in u){if("boolean"==typeof u.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture&&null!==u.autocapture){var l=ue({},u.autocapture);if(void 0===t.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture.elementInteractions&&null!==u.autocapture.elementInteractions&&(null===(i=u.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===i?void 0:i.length)){l.elementInteractions=ue({},u.autocapture.elementInteractions);var d=l.elementInteractions,f=null!==(o=d.pageUrlAllowlist)&&void 0!==o?o:[],p=u.autocapture.elementInteractions.pageUrlAllowlistRegex;d.pageUrlAllowlist=ci(f,p,t),delete d.pageUrlAllowlistRegex}if("object"==typeof u.autocapture.networkTracking&&null!==u.autocapture.networkTracking&&(null===(a=u.autocapture.networkTracking.captureRules)||void 0===a?void 0:a.length)){l.networkTracking=ue({},u.autocapture.networkTracking);var g=null!==(s=l.networkTracking.captureRules)&&void 0!==s?s:[];try{for(var h=pe(g),v=h.next();!v.done;v=h.next()){var m=v.value;m.urls=ci(null!==(c=m.urls)&&void 0!==c?c:[],m.urlsRegex,t),delete m.urlsRegex}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=ue({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},l)),"object"==typeof t.autocapture&&(t.autocapture=ue(ue({},t.autocapture),l))}t.defaultTracking=t.autocapture}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 li="1.18.2",di="[Amplitude] Element Clicked",fi="[Amplitude] Element Tag",pi="[Amplitude] Element Text",gi="[Amplitude] Page URL",hi="https://app.amplitude.com",vi={US:hi,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},mi="data-amp-mask-attributes",yi=["input","select","textarea"],bi=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},Ti=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,a,s=e.pageUrlAllowlist,c=e.pageUrlExcludelist,u=e.shouldTrackEventResolver,l=null===(a=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===a?void 0:a.call(o);if(!l)return!1;if(u)return u(r,i);if(!Rt(window.location.href,s))return!1;if(c&&c.length>0&&Rt(window.location.href,c))return!1;var d=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof d)switch(d.toLowerCase()){case"hidden":case"password":return!1}var f=bi(i,r);if(n&&f)return!0;if(t){var p=t.some((function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))}));if(!p)return!1}switch(l){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!f||"click"===r}}},wi=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},ki=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:ki(null==e?void 0:e.parentElement,t):null};var Si=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};var Ei=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",mi,An]),_i=["type"],Ii=["svg","path","g"],Pi=["password","hidden"];function Ai(e,t){var n,r,i,o,a,s;if(null===e)return null;var c=String(e.tagName).toLowerCase(),u={tag:c},l=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);l.length&&(u.index=l.indexOf(e),u.indexOfType=l.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var d=null===(s=null===(a=e.previousElementSibling)||void 0===a?void 0:a.tagName)||void 0===s?void 0:s.toLowerCase();d&&(u.prevSib=String(d));var f=e.getAttribute("id");f&&(u.id=String(f));var p=Array.from(e.classList);p.length&&(u.classes=p);var g={},h=Array.from(e.attributes).filter((function(e){return!Ei.has(e.name)})),v=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!yi.includes(i)&&!o}(e);if(!Pi.includes(String(e.getAttribute("type")))&&!Ii.includes(c))try{for(var m=pe(h),y=m.next();!y.done;y=m.next()){var b=y.value;v&&!_i.includes(b.name)||(t.has(b.name)?g[b.name]=On:g[b.name]=String(b.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(g).length&&(u.attrs=g),u}var Oi=function(e,t,n){e.forEach((function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}}))},Ri=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Dn(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,a,s=performance.now();if(!e)return[];for(var c,u=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),l=new Map,d=u.length-1;d>=0;d--){var f=u[d];if(f){var p=(c=f.getAttribute(mi))?c.split(",").map((function(e){return e.trim()})).filter((function(e){return e.length>0&&"id"!==e&&"class"!==e})):[],g=d===u.length-1?[]:null!==(r=l.get(u[d+1]))&&void 0!==r?r:new Set,h=new Set(he(he([],ge(g),!1),ge(p),!1));l.set(f,h)}}a=u.map((function(e){var t;return Ai(e,null!==(t=l.get(e))&&void 0!==t?t:new Set)}));var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach((function(t){var n=ge(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))}))};try{for(var m=pe(a),y=m.next();!y.done;y=m.next())v(y.value)}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",b-s),a},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getEventProperties=function(e,t,n){var r,i,a,s,c,u,l=null===(a=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===a?void 0:a.call(i),d="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=o.getHierarchy(t),p=null===(s=f[0])||void 0===s?void 0:s.attrs,g=o.getNearestLabel(t),h=(c=null!=p?p:{},u=n,Object.entries(c).reduce((function(e,t){var n=ge(t,2),r=n[0],i=n[1];if(r.startsWith(u)){var o=r.replace(u,"");o&&(e[o]=i||"")}return e}),{})),v=((r={})["[Amplitude] Element Hierarchy"]=f,r[fi]=l,r[pi]=o.getText(t),r["[Amplitude] Element Position Left"]=null==d.left?null:Math.round(d.left),r["[Amplitude] Element Position Top"]=null==d.top?null:Math.round(d.top),r["[Amplitude] Element Attributes"]=h,r["[Amplitude] Element Parent Label"]=g,r[gi]=xt(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=Ln(o.replaceSensitiveString),r["[Amplitude] Viewport Height"]=window.innerHeight,r["[Amplitude] Viewport Width"]=window.innerWidth,r);if(v["[Amplitude] Element ID"]=t.getAttribute("id")||"",v["[Amplitude] Element Class"]=t.getAttribute("class"),v["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===l&&"click"===e&&t instanceof HTMLAnchorElement){var m=t.href.substring(0,128);v["[Amplitude] Element Href"]=o.replaceSensitiveString(m)}return wi(v)},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var a={event:e,timestamp:Date.now(),type:t};if(function(e){return"click"===e.type||"change"===e.type}(a)&&null!==a.event.target){if(i&&bi(a.event.target,a.type))return a.closestTrackedAncestor=a.event.target,a.targetElementProperties=o.getEventProperties(a.type,a.closestTrackedAncestor,r),a;var s=ki(a.event.target,n);return s&&(a.closestTrackedAncestor=s,a.targetElementProperties=o.getEventProperties(a.type,s,r)),a}return a},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getText=function(e){if(null!==e.closest("[".concat(An,"]")))return On;var t="";if(e.querySelector("[".concat(An,"], [contenteditable]"))){var n=e.cloneNode(!0);n.querySelectorAll("[".concat(An,"], [contenteditable]")).forEach((function(e){e.innerText=On})),t=n.innerText||""}else t=e.innerText||"";return o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),a=((t={})[fi]=i,t[pi]=o.getText(e),t[gi]=window.location.href.split("?")[0],t);return wi(a)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var a=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],s=[];try{for(var c=pe(a),u=c.next();!u.done;u=c.next()){var l=u.value;if(s.length>=25)break;if(l instanceof RegExp)s.push(l);else if("pattern"in l&&"string"==typeof l.pattern)try{s.push(new RegExp(l.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=s},xi=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?hi:t,r=this;this.endpoint=hi,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise((function(t,a){r.requestCallbacks[i]={resolve:t,reject:a},r.notify(o),(null==n?void 0:n.timeout)>0&&setTimeout((function(){a(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{dataExtractor:new Ri({})}:e,r=n.logger,i=n.endpoint,o=n.isElementSelectable,a=n.cssSelectorAllowlist,s=n.actionClickAllowlist,c=n.dataExtractor;this.logger=r,i&&this.endpoint===hi&&(this.endpoint=i);var u=null;window.addEventListener("message",(function(e){var n,r,i,l,d;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var f,p=null==e?void 0:e.data,g=null==p?void 0:p.action;if(g)if("id"in p)null===(l=null===(i=t.logger)||void 0===i?void 0:i.debug)||void 0===l||l.call(i,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(p);else if("ping"===g)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===g){var h=null==p?void 0:p.data;(f="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=f,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(f)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;u=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:c.getEventTagProps,isElementSelectable:function(e){return!o||o((null==h?void 0:h.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:t,cssSelectorAllowlist:a,actionClickAllowlist:s,extractDataFromDataSource:c.extractDataFromDataSource,dataExtractor:c,diagnostics:{autocapture:{version:li}}}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===g&&(null===(d=null==u?void 0:u.close)||void 0===d||d.call(u))}})),this.notify({action:"page-loaded"})},e}();var Ci,Di=function(){return new nr((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()}}))},Li=function(e){return void 0===e&&(e="click"),new nr((function(t){var n,r=function(e){t.next(e)};return null===(n=$e())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=$e())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}}))},Ni={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Ui=function(e){var t,n,r,i,o=Object.values(Ni).reduce((function(e,t){return e[t]=new Set,e}),{});if(!e)return o;try{for(var a=pe(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{try{for(var u=(r=void 0,pe(c.definition)),l=u.next();!l.done;l=u.next()){var d=l.value,f=Ni[d.event_type];f&&o[f].add(c.id)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},ji=function(e){var t,n,r,i,o=new Map;try{for(var a=pe(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{for(var u=(r=void 0,pe(c.conditions)),l=u.next();!l.done;l=u.next()){var d=l.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,p=o.get(f);p||(p=[],o.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},Mi=function(e,t){return t.filter((function(t){return t.definition.some((function(t){return Ni[t.event_type]===e.type&&t.filters.every((function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)}))}))}))},qi=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=function(e,t){var n,r,i,o,a=new Set;try{for(var s=pe(e),c=s.next();!c.done;c=s.next()){var u=c.value,l=t.get(u.id);if(l)try{for(var d=(i=void 0,pe(l)),f=d.next();!f.done;f=d.next()){var p=f.value;a.add(p)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(a)}(Mi(e,Array.from(this.groupedLabeledEvents[e.type]).map((function(e){return r.labeledEvents[e]}))),this.labeledEventToTriggerMap);try{for(var o=pe(i),a=o.next();!a.done;a=o.next()){var s=a.value;Oi(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}();!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable"}(Ci||(Ci={}));var Fi=function(e,t){var n,r,i,o,a,s,c,u;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",li);var l=e.dataAttributePrefix,d=void 0===l?rn:l,f=e.visualTaggingOptions,p=void 0===f?{enabled:!0,messenger:new xi}:f;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:nn,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:on,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0,e.pageUrlExcludelist=null===(o=e.pageUrlExcludelist)||void 0===o?void 0:o.reduce((function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e}),[]);var g="@amplitude/plugin-autocapture-browser",h=[],v=new Ri(e,t),m=Ui(Object.values(null!==(s=null===(a=e.pageActions)||void 0===a?void 0:a.labeledEvents)&&void 0!==s?s:{})),y=ji(null!==(u=null===(c=e.pageActions)||void 0===c?void 0:c.triggers)&&void 0!==u?u:[]),b=function(e,t,n,r){return new qi(e,t,n,r)}(m,y,v,e);return{name:g,type:"enrichment",setup:function(t,n){return de(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,f,T;return fe(this,(function(w){return"undefined"==typeof document||(t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("analyticsSDK.pageActions","all",(function(t){!function(t){var n,r;t&&(e.pageActions=ue(ue({},e.pageActions),t),m=Ui(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),y=ji(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),b.update(m,y,e))}(t)})):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),r=Ti(e,e.cssSelectorAllowlist),i=Ti(e,e.actionClickAllowlist),o=function(){var t,n,r=or(Li().map((function(t){return v.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,d)}))),i=or(new nr((function(t){var n,r=function(n){var r=v.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,d);t.next(r)};return null===(n=$e())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=$e())||void 0===e?void 0:e.document.removeEventListener("change",r)}})));window.navigation&&(n=or(new nr((function(t){var n=function(n){var r=v.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,d);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}))));var o=or(Di().map((function(t){return v.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,d)})));return(t={})[Ci.ChangeObservable]=i,t[Ci.ClickObservable]=r,t[Ci.MutationObservable]=o,t[Ci.NavigateObservable]=n,t}(),a=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(Si).filter((function(e){return r("click",e.closestTrackedAncestor)})).map((function(e){return i(e)})).subscribe((function(e){null==t||t.track(di,e.targetElementProperties)}))}({allObservables:o,amplitude:n,shouldTrackEvent:r,evaluateTriggers:b.evaluate.bind(b)}),h.push(a),s=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(Si).filter((function(e){return i("change",e.closestTrackedAncestor)})).map((function(e){return o(e)})).subscribe((function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))}))}({allObservables:o,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.getEventProperties.apply(v,he(he([],ge(e),!1),[d],!1))},amplitude:n,shouldTrackEvent:r,evaluateTriggers:b.evaluate.bind(b)}),h.push(s),c=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,a=e.shouldTrackActionClick,s=n.clickObservable,c=n.mutationObservable,u=n.navigateObservable,l=s.filter((function(e){return!o("click",e.closestTrackedAncestor)})).map((function(e){var t=ki(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e})).filter(Si).filter((function(e){return a("click",e.closestTrackedAncestor)})),d=u?ir(c,u):c,f=ir(l,d),p=null,g=null;return rr(f,(function(e){if(p&&(clearTimeout(p),p=null),"click"===e.type)return g=e,p=setTimeout((function(){p=null,g=null}),500),Promise.resolve(null);if(g){var t=g;return g=null,Promise.resolve(t)}return Promise.resolve(null)})).subscribe((function(e){e&&(null==t||t.track(di,i("click",e.closestTrackedAncestor)))}))}({allObservables:o,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.getEventProperties.apply(v,he(he([],ge(e),!1),[d],!1))},amplitude:n,shouldTrackEvent:r,shouldTrackActionClick:i}),c&&h.push(c),null===(f=null==t?void 0:t.loggerProvider)||void 0===f||f.log("".concat(g," has been successfully added.")),window.opener&&p.enabled&&(u=e.cssSelectorAllowlist,l=e.actionClickAllowlist,null===(T=p.messenger)||void 0===T||T.setup(ue(ue({dataExtractor:v,logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:vi[t.serverZone]}),{isElementSelectable:Ti(e,he(he([],ge(u),!1),ge(l),!1)),cssSelectorAllowlist:u,actionClickAllowlist:l})))),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){var e,t,n,r;return fe(this,(function(i){try{for(e=pe(h),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Bi=["mutation","navigate"];function $i(e,t){var n,r,i,o,a=t.event,s=a.clientX,c=a.clientY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:c,c),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:c,c),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:s,s),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:s,s),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Ki(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:ue({"[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.clientX,Y:e.event.clientY,Time:e.timestamp}})),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function Hi(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,a=[],s={},c=null;return rr(o.filter((function(e){return i("click",e.closestTrackedAncestor)})),(function(e){return de(t,void 0,void 0,(function(){var t;return fe(this,(function(n){return $i(s,e),t=null,0===a.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(a,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(a,e)||s.isOutOfBounds?(c&&(t=Ki(a)),function(e){a=[],s={},e&&($i(s,e),a.push(e))}(e)):a.push(e),c&&(clearTimeout(c.timerId),c.resolve(t),c=null),a.length>=4?[2,new Promise((function(e){c={resolve:e,timerId:setTimeout((function(){e(Ki(a))}),1e3)}}))]:[2,null]}))}))})).subscribe((function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})}))}var zi,Vi,Gi=function(e){var t,n,r,i,o;void 0===e&&(e={});var a="@amplitude/plugin-frustration-browser",s=[],c=null!==(n=null===(t=e.rageClicks)||void 0===t?void 0:t.cssSelectorAllowlist)&&void 0!==n?n:sn,u=null!==(i=null===(r=e.deadClicks)||void 0===r?void 0:r.cssSelectorAllowlist)&&void 0!==i?i:an,l=null!==(o=e.dataAttributePrefix)&&void 0!==o?o:rn,d=new Ri(e),f=he([],ge(new Set(he(he([],ge(c),!1),ge(u),!1))),!1);return{name:a,type:"enrichment",setup:function(t,n){return de(void 0,void 0,void 0,(function(){var r,i,o,p,g,h;return fe(this,(function(v){return"undefined"==typeof document||(r=Ti(e,c),i=Ti(e,u),o=function(){var e,t,n=or(Li("pointerdown").map((function(e){return d.addAdditionalEventProperties(e,"click",f,l,!0)}))),r=or(Di().map((function(e){return d.addAdditionalEventProperties(e,"mutation",f,l)})));return window.navigation&&(t=or(new nr((function(e){var t=function(t){e.next(ue(ue({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}})).map((function(e){return d.addAdditionalEventProperties(e,"navigate",f,l)})))),(e={})[Ci.ClickObservable]=n,e[Ci.MutationObservable]=r,e[Ci.NavigateObservable]=t,e}(),p=Hi({allObservables:o,amplitude:n,shouldTrackRageClick:r}),s.push(p),g=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,o=n.clickObservable,a=n.mutationObservable,s=n.navigateObservable,c=o.filter((function(e){return Si(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')})),u=s?ir(a,s):a,l=ir(c,u),d=null;return rr(l,(function(e){return d&&Bi.includes(e.type)?(clearTimeout(d),d=null,Promise.resolve(null)):"click"===e.type?d?Promise.resolve(null):new Promise((function(t){d=setTimeout((function(){t(e),d=null}),3e3)})):Promise.resolve(null)})).subscribe((function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",ue(ue({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}}))}({amplitude:n,allObservables:o,getEventProperties:function(e,t){return d.getEventProperties(e,t,l)},shouldTrackDeadClick:i}),s.push(g),null===(h=null==t?void 0:t.loggerProvider)||void 0===h||h.log("".concat(a," has been successfully added."))),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){var e,t,n,r;return fe(this,(function(i){try{for(e=pe(s),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Ji="[Amplitude] Network Request",Wi="500-599";function Yi(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function Qi(e,t){var n,r,i=t.split(",");try{for(var o=pe(i),a=o.next();!a.done;a=o.next()){var s=ge(a.value.split("-").map(Number),2),c=s[0],u=s[1];if(e===c&&void 0===u)return!0;if(e>=c&&e<=u)return!0}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function Xi(e){var t;if(e)try{var n=null===(t=$e())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),a=r.href,s=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:r.href,host:s}}catch(e){return}}function Zi(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return he([],ge(De),!1);if(void 0===e){return}}}function eo(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function to(e,t){var n;void 0===t&&(t={});var r=Xi(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(Yi(o,"*.amplitude.com")||Yi(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find((function(e){return Yi(o,e)})))return!1;if(!t.captureRules&&void 0!==e.status&&!Qi(e.status,Wi))return!1;if(t.captureRules&&(he([],ge(t.captureRules),!1).reverse().find((function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find((function(e){return Yi(t,e)})))&&(!r||!e.urls||Rt(r,e.urls))&&(!i||!e.methods||e.methods.find((function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e}))))return!((n||0===n)&&!Qi(n,e.statusCodeRange||Wi))}(t,o,e.status,e.url,e.method),i){var n=Zi(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var a=Zi(t.requestHeaders);if(e.requestWrapper&&a){var s=e.requestWrapper.headers(a);s&&(e.requestHeaders=s)}e.responseWrapper&&t.responseBody&&!eo(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!eo(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i})),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find((function(e){return e.event_type===Ji})))return!0}catch(e){}return!1}(o,e.requestWrapper)}function no(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter((function(e){return to(e.event,n)})).subscribe((function(e){var t,n,o,a=e.event,s=Xi(a.url);if(s){var c=null===(n=a.responseWrapper)||void 0===n?void 0:n.bodySize,u=null===(o=a.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){de(this,void 0,void 0,(function(){var i,o,a;return fe(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=ge.apply(void 0,[s.sent(),2]),o=i[0],a=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(a)try{e["[Amplitude] Response Body"]=JSON.stringify(a)}catch(e){null==r||r.debug("Failed to stringify response body")}s.label=2;case 2:return null==n||n.track(Ji,e),[2]}}))}))}(((t={})["[Amplitude] URL"]=s.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=s.query,t["[Amplitude] URL Fragment"]=s.fragment,t["[Amplitude] Request Method"]=a.method,t["[Amplitude] Status Code"]=a.status,t["[Amplitude] Start Time"]=a.startTime,t["[Amplitude] Completion Time"]=a.endTime,t["[Amplitude] Duration"]=a.duration,t["[Amplitude] Request Body Size"]=u,t["[Amplitude] Response Body Size"]=c,t["[Amplitude] Request Type"]=a.type,t["[Amplitude] Request Headers"]=a.requestHeaders,t["[Amplitude] Response Headers"]=a.responseHeaders,t),a,r,i)}}))}!function(e){e.NetworkObservable="networkObservable"}(zi||(zi={}));var ro=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new nr((function(e){var n=new En((function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)}));return In.subscribe(n,t),function(){In.unsubscribe(n)}}));return(e={})[zi.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return de(void 0,void 0,void 0,(function(){var a;return fe(this,(function(s){return"undefined"==typeof document||(a=r(),t=null==i?void 0:i.loggerProvider,Vi=no({allObservables:a,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(e){return Vi.unsubscribe(),[2]}))}))}}};let io=-1;const oo=e=>{addEventListener("pageshow",(t=>{t.persisted&&(io=t.timeStamp,e(t))}),!0)},ao=(e,t,n,r)=>{let i,o;return a=>{t.value>=0&&(a||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},so=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},co=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},uo=()=>{const e=co();return e?.activationStart??0},lo=(e,t=-1)=>{const n=co();let r="navigate";return io>=0?r="back-forward-cache":n&&(document.prerendering||uo()>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())+1e12}`,navigationType:r}},fo=new WeakMap;function po(e,t){return fo.get(e)||fo.set(e,new t),fo.get(e)}class go{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const 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)}}const ho=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe({type:e,buffered:!0,...n}),r}}catch{}},vo=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let mo=-1;const yo=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,bo=e=>{"hidden"===document.visibilityState&&mo>-1&&(mo="visibilitychange"===e.type?e.timeStamp:0,wo())},To=()=>{addEventListener("visibilitychange",bo,!0),addEventListener("prerenderingchange",bo,!0)},wo=()=>{removeEventListener("visibilitychange",bo,!0),removeEventListener("prerenderingchange",bo,!0)},ko=()=>{if(mo<0){const e=uo(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>"hidden"===t.name&&t.startTime>e))[0]?.startTime;mo=t??yo(),To(),oo((()=>{setTimeout((()=>{mo=yo(),To()}))}))}return{get firstHiddenTime(){return mo}}},So=e=>{document.prerendering?addEventListener("prerenderingchange",(()=>e()),!0):e()},Eo=[1800,3e3],_o=(e,t={})=>{So((()=>{const n=ko();let r,i=lo("FCP");const o=ho("paint",(e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uo(),0),i.entries.push(t),r(!0)))}));o&&(r=ao(e,i,Eo,t.reportAllChanges),oo((n=>{i=lo("FCP"),r=ao(e,i,Eo,t.reportAllChanges),so((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},Io=[.1,.25];let Po=0,Ao=1/0,Oo=0;const Ro=e=>{for(const t of e)t.interactionId&&(Ao=Math.min(Ao,t.interactionId),Oo=Math.max(Oo,t.interactionId),Po=Oo?(Oo-Ao)/7+1:0)};let xo;const Co=()=>xo?Po:performance.interactionCount??0;let Do=0;class Lo{u=[];l=new Map;m;p;v(){Do=Co(),this.u.length=0,this.l.clear()}P(){const e=Math.min(this.u.length-1,Math.floor((Co()-Do)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.T){if(n?e.duration>n.T?(n.entries=[e],n.T=e.duration):e.duration===n.T&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],T:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.T-e.T)),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const No=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(t(e=vo(e)),document.addEventListener("visibilitychange",e,{once:!0}))},Uo=[200,500],jo=(e,t={})=>{globalThis.PerformanceEventTiming&&"interactionId"in PerformanceEventTiming.prototype&&So((()=>{"interactionCount"in performance||xo||(xo=ho("event",Ro,{type:"event",buffered:!0,durationThreshold:0}));let n,r=lo("INP");const i=po(t,Lo),o=e=>{No((()=>{for(const t of e)i.h(t);const t=i.P();t&&t.T!==r.value&&(r.value=t.T,r.entries=t.entries,n())}))},a=ho("event",o,{durationThreshold:t.durationThreshold??40});n=ao(e,r,Uo,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&(o(a.takeRecords()),n(!0))})),oo((()=>{i.v(),r=lo("INP"),n=ao(e,r,Uo,t.reportAllChanges)})))}))};class Mo{m;h(e){this.m?.(e)}}const qo=[2500,4e3],Fo=[800,1800],Bo=e=>{document.prerendering?So((()=>Bo(e))):"complete"!==document.readyState?addEventListener("load",(()=>Bo(e)),!0):setTimeout(e)};function $o(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function Ko(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor($o(e)),navigationStart:Math.floor(performance.timeOrigin)}}var Ho,zo=function(){var e=null,t=$e(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return de(void 0,void 0,void 0,(function(){var o,a;return fe(this,(function(s){return void 0===n||(o=xt((null==r?void 0:r.href)||"",t.loggerProvider),a={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":xt((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":xt(o.split("?")[0],t.loggerProvider)},((e,t={})=>{So((()=>{const n=ko();let r,i=lo("LCP");const o=po(t,Mo),a=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-uo(),0),i.entries=[t],r())},s=ho("largest-contentful-paint",a);if(s){r=ao(e,i,qo,t.reportAllChanges);const n=vo((()=>{a(s.takeRecords()),s.disconnect(),r(!0)}));for(const e of["keydown","click","visibilitychange"])addEventListener(e,(()=>No(n)),{capture:!0,once:!0});oo((n=>{i=lo("LCP"),r=ao(e,i,qo,t.reportAllChanges),so((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((function(e){a["[Amplitude] LCP"]=Ko(e)})),_o((function(e){a["[Amplitude] FCP"]=Ko(e)})),jo((function(e){a["[Amplitude] INP"]=Ko(e)})),((e,t={})=>{_o(vo((()=>{let n,r=lo("CLS",0);const i=po(t,go),o=e=>{for(const t of e)i.h(t);i.i>r.value&&(r.value=i.i,r.entries=i.o,n())},a=ho("layout-shift",o);a&&(n=ao(e,r,Io,t.reportAllChanges),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&(o(a.takeRecords()),n(!0))})),oo((()=>{i.i=0,r=lo("CLS",0),n=ao(e,r,Io,t.reportAllChanges),so((()=>n()))})),setTimeout(n))})))})((function(e){a["[Amplitude] CLS"]=Ko(e)})),((e,t={})=>{let n=lo("TTFB"),r=ao(e,n,Fo,t.reportAllChanges);Bo((()=>{const i=co();i&&(n.value=Math.max(i.responseStart-uo(),0),n.entries=[i],r(!0),oo((()=>{n=lo("TTFB",0),r=ao(e,n,Fo,t.reportAllChanges),r(!0)})))}))})((function(e){a["[Amplitude] TTFB"]=Ko(e)})),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return[2,e]}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]}))}))}}},Vo=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},Go=function(e,t,n,r,i){void 0===i&&(i=!0),e.referrer;var o=e.referring_domain,a=le(e,["referrer","referring_domain"]),s=t||{};s.referrer;var c=s.referring_domain,u=le(s,["referrer","referring_domain"]);if(Jo(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var l=JSON.stringify(a)!==JSON.stringify(u),d=Vo(o||"")!==Vo(c||""),f=!t||l||d;return f?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."),f},Jo=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))},Wo=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=ue({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=null===(n=t.cookieOptions)||void 0===n?void 0:n.domain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[])},e),this.storage=t.cookieStorage,this.storageKey=jt(t.apiKey,"MKTG"),this.webExpStorageKey=jt(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=Ce,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return de(this,void 0,void 0,(function(){var e,t;return fe(this,(function(n){switch(n.label){case 0:return[4,this.fetchCampaign()];case 1:return t=ge.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||_t(this.sessionTimeout,this.lastEventTime),Go(this.currentCampaign,this.previousCampaign,this.options,this.logger,e)?(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 de(this,void 0,void 0,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new Pn).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}}))}))},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,o=(t=this.currentCampaign,n=this.options,r=ue(ue({},Ce),t),i=Object.entries(r).reduce((function(e,t){var r,i=ge(t,2),o=i[0],a=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=a?a:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),a?e.set(o,a):e.unset(o)}),new je),Ve(i));return e&&(o.event_id=e),o},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),Yo="AMP_CURRENT_PAGE",Qo="AMP_PREVIOUS_PAGE",Xo="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(Ho||(Ho={}));var Zo=new Set([ce.IDENTIFY,ce.GROUP_IDENTIFY,ce.REVENUE]),ea=function(e){var t={}.internalDomains,n=void 0===t?[]:t,r=$e(),i=void 0,o=!1,a=void 0,s=!1,c=!1,u=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=xt(e,a);t=new URL(n).hostname}catch(e){null==a||a.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return Ho.Direct;var i=n.some((function(e){return-1!==t.indexOf(e)})),o=n.some((function(e){return-1!==r.indexOf(e)}));return t===r||o&&i?Ho.Internal:Ho.External},l=function(){de(void 0,void 0,void 0,(function(){var e,t,n,r,a;return fe(this,(function(s){switch(s.label){case 0:return i&&o?[4,i.get(Xo)]:[3,3];case 1:return e=s.sent(),t=xt("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[Yo])||"",r=void 0,r=t===n?(null==e?void 0:e[Qo])||"":n||document.referrer||"",[4,i.set(Xo,(a={},a[Yo]=t,a[Qo]=r,a))];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},d={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return de(void 0,void 0,void 0,(function(){return fe(this,(function(t){switch(t.label){case 0:return(a=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),c=!0,r?[4,(i=new Mt(r.sessionStorage)).isEnabled()]:[3,2];case 1:o=t.sent(),r.addEventListener("popstate",l),s||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=ge(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=ge(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),s=!0),t.label=2;case 2:return[2]}}))}))},execute:function(e){return de(void 0,void 0,void 0,(function(){var t,n,r,a,s;return fe(this,(function(c){switch(c.label){case 0:return t=xt("undefined"!=typeof location&&location.href||""),i&&o?[4,i.get(Xo)]:[3,5];case 1:return(null==(n=c.sent())?void 0:n[Yo])?[3,3]:[4,i.set(Xo,(s={},s[Yo]=t,s[Qo]=document.referrer||"",s))];case 2:c.sent(),c.label=3;case 3:return[4,i.get(Xo)];case 4:if(r=c.sent(),a="",r&&(a=r[Qo]||""),Zo.has(e.event_type))return[2,e];e.event_properties=ue(ue({},e.event_properties||{}),{"[Amplitude] Page Domain":ta(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":ta(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":ta(e,"[Amplitude] Page Path","undefined"!=typeof location&&xt(location.pathname)||""),"[Amplitude] Page Title":ta(e,"[Amplitude] Page Title",Ln(Dn)),"[Amplitude] Page URL":ta(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":a,"[Amplitude] Previous Page Type":u(a)}),c.label=5;case 5:return[2,e]}}))}))},teardown:function(){return de(void 0,void 0,void 0,(function(){return fe(this,(function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",l),c=!1),i&&o?[4,i.set(Xo,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}};return d};function ta(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var na=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return ae(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),Ge(this._init(ue(ue({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o;return de(this,void 0,void 0,(function(){var a,s,c,u,l,d,f,p,g,h=this;return fe(this,(function(v){switch(v.label){case 0:return this.initializing?[2]:(this.initializing=!0,[4,Vr(t.apiKey,t,this)]);case 1:return a=v.sent(),a.remoteConfig&&a.remoteConfig.fetchRemoteConfig?(s=new tn(a.apiKey,a.loggerProvider,a.serverZone,null===(n=a.remoteConfig)||void 0===n?void 0:n.serverUrl),[4,new Promise((function(e){null==s||s.subscribe("configs.analyticsSDK.browserSDK","all",(function(t,n,r){a.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&ui(t,a),e()}))}))]):[3,4];case 2:return v.sent(),[4,new Promise((function(e){null==s||s.subscribe("configs.diagnostics.browserSDK","all",(function(t,n,r){if(a.loggerProvider.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(a.diagnosticsSampleRate=i);var o=t.enabled;"boolean"==typeof o&&(a.enableDiagnostics=o)}e()}))}))];case 3:v.sent(),v.label=4;case 4:return(c=new Qt(a.apiKey,a.loggerProvider,a.serverZone,{enabled:a.enableDiagnostics,sampleRate:a.diagnosticsSampleRate})).setTag("library","".concat(Tr,"/").concat(br)),c.setTag("user_agent",navigator.userAgent),[4,e.prototype._init.call(this,a)];case 5:return v.sent(),this.logBrowserOptions(a),this.config.diagnosticsClient=c,this.config.remoteConfigClient=s,sr(this.config.defaultTracking)?(y=this.config,u=sr(y.defaultTracking)&&y.defaultTracking&&"object"==typeof y.defaultTracking&&y.defaultTracking.attribution&&"object"==typeof y.defaultTracking.attribution?ue({},y.defaultTracking.attribution):{},this.webAttribution=new Wo(u,this.config),[4,this.webAttribution.init()]):[3,7];case 6:v.sent(),v.label=7;case 7:return l=At(),d=l.ampTimestamp?Number(l.ampTimestamp):void 0,f=!d||Date.now()<d,p=f&&!Number.isNaN(Number(l.ampSessionId))?Number(l.ampSessionId):void 0,this.setSessionId(null!==(o=null!==(i=null!==(r=t.sessionId)&&void 0!==r?r:p)&&void 0!==i?i:this.config.sessionId)&&void 0!==o?o:Date.now()),(g=St(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,9]:[4,this.add(ai()).promise];case 8:v.sent(),v.label=9;case 9:return[4,this.add(new dt({diagnosticsClient:c})).promise];case 10:return v.sent(),[4,this.add(new wr).promise];case 11:return v.sent(),[4,this.add(new Et).promise];case 12:return v.sent(),function(e){oi||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),oi=!0)}(this.config),m=this.config.defaultTracking,ar(m,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(ii()).promise]):[3,14];case 13:v.sent(),v.label=14;case 14:return function(e){return ar(e,"formInteractions")}(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(ti()).promise]):[3,16];case 15:v.sent(),v.label=16;case 16:return cr(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Qr(vr(this.config))).promise]):[3,18];case 17:v.sent(),v.label=18;case 18:return dr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Fi(pr(this.config),{diagnosticsClient:c})).promise]):[3,20];case 19:v.sent(),v.label=20;case 20:return fr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(Gi(gr(this.config))).promise]):[3,22];case 21:v.sent(),v.label=22;case 22:return lr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(ro(hr(this.config))).promise]):[3,24];case 23:v.sent(),v.label=24;case 24:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(zo()).promise]):[3,26];case 25:v.sent(),v.label=26;case 26:return function(e){return ar(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(ea()).promise]):[3,28];case 27:v.sent(),v.label=28;case 28:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 29:return v.sent(),g.eventBridge.setEventReceiver((function(e){var t=e.eventProperties||{},n=t.time,r=le(t,["time"]),i="number"==typeof n?{time:n}:void 0;h.track(e.eventType,r,i)})),[2]}var m,y}))}))},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){St(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){St(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(He()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),Ge(Promise.resolve());if(e===this.config.sessionId)return Ge(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,ur(this.config.defaultTracking)&&(r&&i&&n.push(this.track(Nr,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var a=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Ve(this.config.identify)).promise),ur(this.config.defaultTracking)&&n.push(this.track(Lr,void 0,{event_id:a?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,Ge(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Jr(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(yr(t)){var r=t._q;t._q=[],t=mr(new je,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,r,i){if(yr(r)){var o=r._q;r._q=[],r=mr(new je,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(yr(t)){var r=t._q;t._q=[],t=mr(new We,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 de(this,void 0,void 0,(function(){var n,r,i;return fe(this,(function(o){return n=Date.now(),r=_t(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===Lr||t.event_type===Nr||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),t.event_type===ce.IDENTIFY&&t.user_properties&&(this.userProperties=this.getOperationAppliedUserProperties(t.user_properties)),[2,e.prototype.process.call(this,t)]}))}))},t.prototype.logBrowserOptions=function(e){try{var t=ue(ue({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",JSON.stringify(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t}(Je),ra=function(){var e=new na;return{init:ut(e.init.bind(e),"init",at(e),ct(e,["config"])),add:ut(e.add.bind(e),"add",at(e),ct(e,["config.apiKey","timeline.plugins"])),remove:ut(e.remove.bind(e),"remove",at(e),ct(e,["config.apiKey","timeline.plugins"])),track:ut(e.track.bind(e),"track",at(e),ct(e,["config.apiKey","timeline.queue.length"])),logEvent:ut(e.logEvent.bind(e),"logEvent",at(e),ct(e,["config.apiKey","timeline.queue.length"])),identify:ut(e.identify.bind(e),"identify",at(e),ct(e,["config.apiKey","timeline.queue.length"])),groupIdentify:ut(e.groupIdentify.bind(e),"groupIdentify",at(e),ct(e,["config.apiKey","timeline.queue.length"])),setGroup:ut(e.setGroup.bind(e),"setGroup",at(e),ct(e,["config.apiKey","timeline.queue.length"])),revenue:ut(e.revenue.bind(e),"revenue",at(e),ct(e,["config.apiKey","timeline.queue.length"])),flush:ut(e.flush.bind(e),"flush",at(e),ct(e,["config.apiKey","timeline.queue.length"])),getUserId:ut(e.getUserId.bind(e),"getUserId",at(e),ct(e,["config","config.userId"])),setUserId:ut(e.setUserId.bind(e),"setUserId",at(e),ct(e,["config","config.userId"])),getDeviceId:ut(e.getDeviceId.bind(e),"getDeviceId",at(e),ct(e,["config","config.deviceId"])),setDeviceId:ut(e.setDeviceId.bind(e),"setDeviceId",at(e),ct(e,["config","config.deviceId"])),reset:ut(e.reset.bind(e),"reset",at(e),ct(e,["config","config.userId","config.deviceId"])),getSessionId:ut(e.getSessionId.bind(e),"getSessionId",at(e),ct(e,["config"])),setSessionId:ut(e.setSessionId.bind(e),"setSessionId",at(e),ct(e,["config"])),extendSession:ut(e.extendSession.bind(e),"extendSession",at(e),ct(e,["config"])),setOptOut:ut(e.setOptOut.bind(e),"setOptOut",at(e),ct(e,["config"])),setTransport:ut(e.setTransport.bind(e),"setTransport",at(e),ct(e,["config"])),getIdentity:ut(e.getIdentity.bind(e),"getIdentity",at(e),ct(e,["config"])),getOptOut:ut(e.getOptOut.bind(e),"getOptOut",at(e),ct(e,["config"])),_setDiagnosticsSampleRate:ut(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",at(e),ct(e,["config"]))}},ia=ra(),oa=Object.freeze({__proto__:null,DEFAULT_ACTION_CLICK_ALLOWLIST:on,DEFAULT_CSS_SELECTOR_ALLOWLIST:nn,DEFAULT_DATA_ATTRIBUTE_PREFIX:rn,get IdentifyOperation(){return se},get LogLevel(){return Ye},OfflineDisabled:null,get RevenueProperty(){return Fe},get ServerZone(){return bt},get SpecialEventType(){return ce}}),aa=ia.add,sa=ia.extendSession,ca=ia.flush,ua=ia.getDeviceId,la=ia.getIdentity,da=ia.getOptOut,fa=ia.getSessionId,pa=ia.getUserId,ga=ia.groupIdentify,ha=ia.identify,va=ia.init,ma=ia.logEvent,ya=ia.remove,ba=ia.reset,Ta=ia.revenue,wa=ia.setDeviceId,ka=ia.setGroup,Sa=ia.setOptOut,Ea=ia.setSessionId,_a=ia.setTransport,Ia=ia.setUserId,Pa=ia.track,Aa=ia._setDiagnosticsSampleRate,Oa=Object.freeze({__proto__:null,AmplitudeBrowser:na,Identify:je,Revenue:We,Types:oa,_setDiagnosticsSampleRate:Aa,add:aa,createInstance:ra,extendSession:sa,flush:ca,getDeviceId:ua,getIdentity:la,getOptOut:da,getSessionId:fa,getUserId:pa,groupIdentify:ga,identify:ha,init:va,logEvent:ma,remove:ya,reset:ba,revenue:Ta,runQueuedFunctions:function(e,t){mr(e,t)},setDeviceId:wa,setGroup:ka,setOptOut:Sa,setSessionId:Ea,setTransport:_a,setUserId:Ia,track:Pa});function Ra(e,t){if(!k.getDebugMode())return;const n=["[Qonto Embed SDK]",e];console.log(...n)}class xa{constructor(){this.isInitialized=!1}static getInstance(){return xa.instance||(xa.instance=new xa),xa.instance}initialize(){if(this.isInitialized||a())return;const e=y.getEnvironment()||"production",t=e===s.PRODUCTION?"52c120d2f5c89ca646fae6649a1ce7ad":"373aa80c38e5bc2a55895a96c8447fef";if(t)try{if(!Oa||"function"!=typeof va)throw new Error("Analytics SDK module not available");const n={defaultTracking:{sessions:!1,pageViews:!1,formInteractions:!1,fileDownloads:!1},logLevel:e!==s.PRODUCTION?Ye.Debug:Ye.None};va(t,void 0,n),this.isInitialized=!0,this.track(re)}catch(e){console.error("Failed to initialize analytics tracking:",e)}else Ra("No tracking client will be initialized due to missing API key")}isEnabled(){return this.isInitialized}track(e,t){if(this.isInitialized)try{Pa(e,t)}catch(e){console.error("Failed to track analytics event:",e)}}reset(){if(this.isInitialized)try{ba()}catch(e){console.error("Failed to reset analytics:",e)}}}const Ca=xa.getInstance();function Da(e,t){Ca.track(e,t)}const La=e=>{Da(ie,e)};class Na extends r{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}async function Ua({proxyFunction:e,networkCallDescriptor:t,proxyEndpointDescriptor:n}){if(n){const e={...Object.fromEntries([...E(t.options?.headers)??{}])},r=I({...t,options:{...t.options,headers:e}}),i=await fetch(n.path,{method:n.method,headers:n.options.headers,body:r}),o=P(await i.text());if(!i.ok)throw new S({code:i.status,data:o,message:`Error from proxy endpoint: ${i.status} ${i.statusText}`});return o}if(e){const n=Object.fromEntries([...E(t.options?.headers)??{}]),r=I({...t,options:{...t.options,headers:n}});return P(await e(r))}throw new Na("No proxy function or proxy endpoint descriptor provided for proxy call.")}var ja;function Ma(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(ja||(ja={}));const qa={getCards:async function(e){La();const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new x("membershipId must be a string");const{accessToken:n,stagingToken:r}=e?.operationSettings||{},i=n||o(),a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const r=function({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await _(r);return i}({membershipId:t,accessToken:i,stagingToken:r});return a.map((e=>Ma(e)))},getCard:async function({cardSettings:e,operationSettings:t}){!function(e){if(!e)throw new x("cardSettings parameter is required for the called function");if(!e.cardId)throw new x("cardId parameter is required for the called function");const t=D({cardId:e.cardId});if(t.length>0)throw new x(t)}(e);const n=e.cardId,{accessToken:r,stagingToken:i}=t||{},a=r||o(),s=await async function({cardId:e,accessToken:t,stagingToken:n}){const r=function({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await _(r);return i[0]}({cardId:n,accessToken:a,stagingToken:i});return Ma(s)}},Fa=e=>({id:e?.id,slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:parseFloat(e.balance),balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Ba={getOrganization:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||o(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await _(n)})({accessToken:r,stagingToken:n});return{id:(a=i.organization).id,slug:a.slug,legalName:a.legal_name,legalNumber:a.legal_number,legalSector:a.legal_sector,legalRegistrationDate:a.legal_registration_date,legalAddress:a.legal_address,legalForm:a.legal_form,legalCountry:a.legal_country,legalShareCapital:a.legal_share_capital,locale:a.locale,contractSignedAt:a.contract_signed_at,bankAccounts:a.bank_accounts.map(Fa)};var a},getBankAccounts:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||o(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/bank_accounts/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await _(n)})({accessToken:r,stagingToken:n});return i.bank_accounts.map(Fa)}},$a={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},Ka=e=>{if(!(e=>Object.values($a).includes(e))(e))throw new x(`currency ${e} is not valid, valid currencies are ${Object.values($a).join(", ")}`)},Ha={GOOD:"good",SERVICE:"service"},za={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Va=e=>{if(!(e=>Object.values(za).includes(e))(e))throw new x(`unit ${e} is not valid, valid units are ${Object.values(za).join(", ")}`)},Ga=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],Ja=[{name:"currency"},{name:"value"}];const Wa=e=>{if(!Object.values(Ha).includes(e))throw new x(`type ${e} is not valid, valid types are ${Object.values(Ha).join(", ")}`)};const Ya={getPaymentLinkCreationFlowUrl:async({paymentLinkSettings:e,operationSettings:t})=>{const{items:n}=e;!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{C(e,Ga),C(e.unitPrice,Ja);const t=[...D({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...L({quantity:e.quantity})].flat();if(t.length>0)throw new x(t);Wa(e.type),Ka(e.unitPrice.currency),Va(e.measureUnit)}))}(n);const r=function(e){if(!e?.callbackUrl)throw new x("callbackUrl parameter is required for the payment link creation flow");if("string"!=typeof e.callbackUrl)throw new x("callbackUrl must be a string");if(""===e.callbackUrl.trim())throw new x("callbackUrl cannot be empty");return e.callbackUrl}(e),i=await U({requestSettings:{action:f.PAYMENT_LINK_CREATE,callbackUrl:r},operationSettings:t}),o=new URLSearchParams({...n?{items:JSON.stringify(n)}:{}});return o.toString()?`${i.url}?${o.toString()}`:i.url}};function Qa(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function Xa(e){return{name:e.name,iban:e.iban}}const Za="/v2/sepa",es=`${Za}/transfers`;async function ts({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${es}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:o}=await _(r);return{transfers:i,meta:o}}async function ns({accessToken:e,stagingToken:t,sepaTransferId:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${es}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await _(r);return i}async function rs({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}(e);return{path:es,options:{method:"POST",headers:{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o},body:{transfer:a,vop_proof_token:t}}}}({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}),{transfer:s}=await _(a);return s}async function is({sepaTransferId:e,accessToken:t,stagingToken:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${es}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:e,accessToken:t,stagingToken:n});await _(r)}async function os({sepaPayee:e,accessToken:t,stagingToken:n}){const r=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Za}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await _(r)}function as(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function ss(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}const cs="/v2/sepa/bulk_transfers";async function us({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${cs}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{bulk_transfers:i,meta:o}=await _(r);return{bulkTransfers:i,meta:o}}async function ls({accessToken:e,stagingToken:t,bulkTransferId:n}){const r=function({bulkTransferId:e,accessToken:t,stagingToken:n}){return{path:`${cs}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({bulkTransferId:n,accessToken:e,stagingToken:t}),{bulk_transfer:i}=await _(r);return i}async function ds({sepaPayees:e,accessToken:t,stagingToken:n}){const r=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Za}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Xa)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await _(r)}function fs(e){if(!e)throw new x("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new x("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new x("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new x("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new x(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new x(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new x(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new x(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=D({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),r=L({amount:e.amount}),i=[...n,...r].flat();if(i.length>0)throw new x(i);if(e.amount>l&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new x(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const ps={requiresUI:!1};function gs(e,{requiresUI:t}=ps){const n=e?.uiParentElementId||k.getUIParentElementId();if(t){if(!n)throw new x("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");if(!["string","function"].includes(typeof n))throw new x("operationSettings.uiParentElementId must be a string or a function returning an HTMLElement")}const r=e?.mfaPreference||k.getMFAPreference();if(r){const e=(i=Object.values(u),y.isProductionEnvironment()?i.filter((e=>e!==u.MOCK)):i);if(!e.includes(r))throw new x(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(y.isProductionEnvironment()&&r===u.MOCK)throw new x("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const o=e?.debugMode||k.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new x("operationSettings.debugMode must be a boolean.");const a=e?.proxyRequestFunction||k.getProxyRequestFunction();if(a&&"function"!=typeof a)throw new x("operationSettings.proxyRequestFunction must be a function.");const s=e?.proxyEndpointDescriptor||k.getProxyEndpointDescriptor();if(s&&!s.path)throw new x("operationSettings.proxyEndpointDescriptor must have at least a string-formatted path property.");return{...e,uiParentElementId:n,mfaPreference:r,debugMode:o,proxyRequestFunction:a,proxyEndpointDescriptor:s}}async function hs({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:await async function({beneficiarySettings:e,operationSettings:t}){const n=te(e?.beneficiaryId),{proxyRequestFunction:r,proxyEndpointDescriptor:i,accessToken:a,stagingToken:s}=gs(t||{});if(r||i){const e=W({beneficiaryId:n});return z((await Ua({proxyFunction:r,proxyEndpointDescriptor:i,networkCallDescriptor:e})).body.beneficiary)}{const e=a||o();return z(await Y({beneficiaryId:n,accessToken:e,stagingToken:s}))}}({beneficiarySettings:{beneficiaryId:e?.beneficiaryId},operationSettings:t})}function vs(e,t){const n=t?.locale||T.getLocale(),r=new URL(e);return n&&r.searchParams.append("lang",n),t?.mfaPreference&&r.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&r.searchParams.append("idempotencyKey",t.idempotencyKey),r.toString()}const ms=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];const ys={getSepaTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await ts({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.transfers.map(Qa),c=q(a.meta);return{transfers:s,...c?{meta:c}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new x("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return Qa(await ns({sepaTransferId:n,accessToken:a,stagingToken:i}))},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:a}=t||{},s=n||o(),c=a||H();!function(e){if(!e)throw new x("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new x("sepaTransferSettings must be an object");if(!e.beneficiaryId&&!e.beneficiary)throw new x("Either beneficiaryId or beneficiary must be provided");const t=D({beneficiaryId:e.beneficiaryId});if(t.length>0)throw new x(t)}(e);const u=e?.beneficiary?e.beneficiary:await hs({sepaTransferSettings:e,operationSettings:t}),f={name:u.name,iban:u.iban},p=await os({sepaPayee:f,accessToken:s,stagingToken:r}),g=yield(h=p,{matchResult:h.match_result,matchedName:h.matched_name});var h;let v;if("string"==typeof g){if(g===d)return}else{if(g.vopDecision===d)return;v=g.sepaTransferSettings}const m={...e,...v};!function(e){if(!e)throw new x("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new x("sepaTransferSettings must be an object");C(e,ms);const t=[...D({bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...L({amount:e.amount})].flat();if(t.length>0)throw new x(t);if(e.amount>l&&(!e.attachmentIds||0===e.attachmentIds.length))throw new x("Attachments are required for transfers over €30,000")}(m);const y={...m,beneficiary:u};return{transfer:Qa(await rs({transfer:y,vopProofToken:p.proof_token.token,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c})),meta:{idempotencyKey:c}}},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new x("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();await is({sepaTransferId:n,accessToken:a,stagingToken:i})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new x("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new x("callbackUrl must be a string");return e.callbackUrl}(e),{accessToken:r,stagingToken:i}=t||{},a=r||o(),s=await async function({requestSettings:e,operationSettings:t}){N(e);const{proxyRequestFunction:n,proxyEndpointDescriptor:r,stagingToken:i}=gs(t||{});if(n||r){const t=A({stagingToken:i,action:e.action,callbackUrl:e.callbackUrl});return R((await Ua({proxyFunction:n,proxyEndpointDescriptor:r,networkCallDescriptor:t})).body)}{const n=t?.accessToken||o();return R(await O({accessToken:n,stagingToken:i,action:e.action,callbackUrl:e.callbackUrl}))}}({requestSettings:{action:f.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:{stagingToken:i,accessToken:a}});return{...s,url:vs(s.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await us({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.bulkTransfers?.map(as),c=q(a.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({bulkTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new x("bulkTransferId must be a string.");return e}(e?.bulkTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return as(await ls({accessToken:a,stagingToken:i,bulkTransferId:n}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:a}=t||{},s=n||o(),c=a||H(),u=fs(e),l=new Map;for(const e of u.bulkTransfers){const t=e.beneficiary;if(t){const e=t.iban;e&&!l.has(e)&&l.set(e,{name:t.name,iban:e})}}const f=Array.from(l.values()),p=await ds({sepaPayees:f,accessToken:s,stagingToken:r});if((yield p.requests.map(ss))===d)return;const g=await async function({bulkTransfers:e,accessToken:t,stagingToken:n,scaSessionToken:r,bankAccountId:i,idempotencyKey:o}){const a={method:"POST",headers:{...E({accessToken:t,stagingToken:n,scaSessionToken:r,idempotencyKey:o})},body:JSON.stringify({bank_account_id:i,bulk_transfers:e.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))})},s=new URL(`${y.getEnvironmentUrls().THIRD_PARTY_API_URL}${cs}`),c=await fetch(s,a),u=await c.json();if(!c.ok||u.errors)throw new S({message:u.errors?u.errors.map((e=>`${e.code}: ${e.detail}`)).join(", "):"Failed to create SEPA bulk transfer"});return u.bulk_transfer}({bulkTransfers:u.bulkTransfers,bankAccountId:u.bankAccountId,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c});return{bulkTransfer:as(g),meta:{idempotencyKey:c}}}}},bs="/v2/transactions";async function Ts(e){const t=function({bankAccountId:e,iban:t,status:n,updatedAtFrom:r,updatedAtTo:i,emittedAtFrom:o,emittedAtTo:a,settledAtFrom:s,settledAtTo:c,side:u,operationType:l,withAttachments:d,paginationSettings:f,accessToken:p,stagingToken:g}){const h={method:"GET",headers:{accessToken:p,stagingToken:g}},v=new URLSearchParams;e&&v.append("bank_account_id",e),t&&v.append("iban",t),n&&v.append("status",n),r&&v.append("updated_at_from",r),i&&v.append("updated_at_to",i),o&&v.append("emitted_at_from",o),a&&v.append("emitted_at_to",a),s&&v.append("settled_at_from",s),c&&v.append("settled_at_to",c),u&&v.append("side",u),l&&v.append("operation_type",l),void 0!==d&&v.append("with_attachments",String(d));const m=M(f);for(const[e,t]of m)v.append(e,t);const y=v.toString();return{path:`${bs}${y?`?${y}`:""}`,options:h}}(e),{transactions:n,meta:r}=await _(t);return{transactions:n,meta:r}}async function ws(e){const t=function({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${bs}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}(e),{transaction:n}=await _(t);return n}function ks(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const Ss={getTransactions:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i={...e?.transactionSettings||{},paginationSettings:r},a=t||o(),s=await Ts({...i,accessToken:a,stagingToken:n});return{transactions:s.transactions.map(ks),meta:q(s.meta)}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r}=t||{},{transactionId:i}=function(e){if(!e)throw new x("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new x("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new x("transactionSettings.transactionId must be a string.");return e}(e),a=n||o();return ks(await ws({transactionId:i,accessToken:a,stagingToken:r}))}};e.authLinks=j,e.beneficiaries=ne,e.cards=qa,e.organizations=Ba,e.paymentLinks=Ya,e.sepaTransfers=ys,e.transactions=Ss}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbedServer={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class r extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class i extends r{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid authentication method. Provide either a proxyRequestFunction (recommended) or accessToken, either as parameters or by calling the initialize function first."}}function o(){if(!n.hasAccessToken())throw new i;return n.getAccessToken()}function a(){return!("undefined"!=typeof window&&"undefined"!=typeof document)}const s={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},c={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},l=3e4,d="REJECT",f={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"},p="https://embed.qonto.com",g="https://embed-js{branch}.staging.qonto.co",h="https://embed.dev.qonto.co",v={[s.PRODUCTION]:{EMBED_BASE_URL:p,EMBED_URL:`${p}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[s.STAGING]:{EMBED_BASE_URL:g,EMBED_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[s.LOCAL]:{EMBED_BASE_URL:h,EMBED_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class m{constructor(){let e,t;this.environment=s.PRODUCTION,this.branch=c.SANDBOX,"undefined"!=typeof process&&process.env&&(e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH),this.environment=Object.values(s).includes(e)?e:s.PRODUCTION,this.branch=Object.values(c).includes(t)?t:c.SANDBOX}static getInstance(){return m.instance||(m.instance=new m),m.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===s.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=s.PRODUCTION,this.branch=c.MASTER}getEnvironmentUrls(){if(this.environment===s.PRODUCTION)return v.production;{const e=v[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const y=m.getInstance();class b{constructor(){this.currentLocale="en"}static getInstance(){return b.instance||(b.instance=new b),b.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const T=b.getInstance();class w{constructor(){this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return w.instance||(w.instance=new w),w.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction),e.proxyEndpointDescriptor&&(this.proxyEndpointDescriptor=e.proxyEndpointDescriptor)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}getProxyEndpointDescriptor(){return this.proxyEndpointDescriptor}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=u.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0,this.proxyEndpointDescriptor=void 0}getSettings(){return{uiParentElementId:this.uiParentElementId,mfaPreference:this.mfaPreference,debugMode:this.debugMode,proxyRequestFunction:this.proxyRequestFunction}}}const k=w.getInstance();class S extends r{constructor({message:e,data:t,code:n}){super(),this.code=500;const r=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${r}`,this.data=t||{},this.code=n||this.code}}function E({accessToken:e,stagingToken:t,idempotencyKey:r,mfaPreference:i,scaSessionToken:o}){const a=new Headers;a.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&a.append("X-Qonto-Staging-Token",s),r&&a.append("X-Qonto-Idempotency-Key",r);const c=i||k.getMFAPreference();return c&&a.append("X-Qonto-2fa-Preference",c),o&&a.append("X-Qonto-SCA-Session-Token",o),a.append("Content-Type","application/json"),a.append("Accept-Language",T.getLocale()),a}async function _({path:e,options:t}){const n=`${y.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,r=await fetch(n,{...t,headers:E(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===r.status)return;const i=await r.json();if(!r.ok)throw i.errors?new S({code:r.status,message:i.errors.map((e=>`${e.code}: ${e.detail}`))}):new S({code:r.status,message:`${i.code}: ${i.detail}`,data:i});return i}function I(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return r=n,a()?Buffer.from(r).toString("base64"):btoa(r);var r}function P(e){return JSON.parse((t=e,a()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function A({accessToken:e,stagingToken:t,action:n,callbackUrl:r}){const i={post_authn_action:n};return r&&(i.callback_url=r),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}async function O(e){const t=A({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await _(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}function R(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}class x extends r{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}function C(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new x(n.map((e=>`Missing required parameter: ${e}`)))}function D(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function L(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}function N(e){if(!e||"object"!=typeof e)throw new x("requestSettings must be an object");const t=e,{action:n,callbackUrl:r}=e;C(t,[{name:"action"}]);const i=D(t),o=Object.values(f);if(o.includes(n)||i.push(`action must be one of ${o.join(", ")}`),i.length>0)throw new x(i);if(void 0!==r&&""===r.trim())throw new x("callbackUrl cannot be empty")}async function U({requestSettings:e,operationSettings:t}){N(e);const{accessToken:n,stagingToken:r}=t||{},i=n||o();return R(await O({accessToken:i,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}const j={request:U};function M(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function q(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}const F=[];for(let e=0;e<256;++e)F.push((e+256).toString(16).slice(1));let B;const $=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function H(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!B){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");B=crypto.getRandomValues.bind(crypto)}return B($)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase()}(r)}function z(e,t,n){return K.randomUUID?K.randomUUID():H(e)}function V(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function G(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const J="/v2/sepa/beneficiaries";async function W({paginationSettings:e,accessToken:t,stagingToken:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${J}${o}`,options:r}}({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:o}=await _(r);return{beneficiaries:i,meta:o}}function Y({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${J}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Q({accessToken:e,stagingToken:t,beneficiaryId:n}){const r=Y({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await _(r);return i}async function X({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=z()}){const i=function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=z()}){return{path:J,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:r},body:{beneficiary:G(e)}}}}({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r}),{beneficiary:o}=await _(i);return o}async function Z({beneficiaryIds:e,accessToken:t,stagingToken:n}){const r=function({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${J}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await _(r);return i}async function ee({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const o=function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const{name:o,email:a,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i},body:{beneficiary:{name:o,email:a,activity_tag:s}}};return{path:`${J}/${e.id}`,options:c}}({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}),{beneficiary:a}=await _(o);return a}const te=[{name:"name"},{name:"iban"}];function ne(e){if(!e)throw new x("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new x("beneficiaryId must be a string");return e}const re={getBeneficiaries:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await W({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.beneficiaries.map((e=>V(e))),c=q(a.meta);return{beneficiaries:s,...c?{meta:c}:{}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=ne(e?.beneficiaryId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return V(await Q({beneficiaryId:n,accessToken:a,stagingToken:i}))},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new x("beneficiary must be an object");C(e,te);const t=D({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new x(t);return e}(e),{accessToken:r,stagingToken:i,idempotencyKey:a}=t||{},s=r||o();return V(await X({beneficiary:n,accessToken:s,stagingToken:i,idempotencyKey:a}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:r,activityTag:i}=e||{};if(!t)throw new x("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!r&&!i)throw new x("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=D({name:n,email:r,activityTag:i});if(o.length>0)throw new x(o);return{id:t,name:n,email:r,activityTag:i}}(e),{accessToken:r,stagingToken:i,idempotencyKey:a,mfaPreference:s}=t||{},c={beneficiaryParamsBeingEdited:n,accessToken:r||o(),stagingToken:i,idempotencyKey:a,mfaPreference:s};return V(await ee(c))},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new x("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{accessToken:r,stagingToken:i}=t||{},a=r||o();return(await Z({beneficiaryIds:n,accessToken:a,stagingToken:i})).map(V)}},ie="SDK Initialized",oe="Cards List";var ae=function(e,t){return ae=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])},ae(e,t)};function se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}ae(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ce,ue,le=function(){return le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},le.apply(this,arguments)};function de(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(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 fe(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function pe(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function ge(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function ve(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,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"}(ce||(ce={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(ue||(ue={}));var me,ye="AMP",be="".concat(ye,"_unsent"),Te="$default_instance",we="https://api2.amplitude.com/2/httpapi",ke="dclid",Se="fbclid",Ee="gbraid",_e="gclid",Ie="ko_click_id",Pe="li_fat_id",Ae="msclkid",Oe="rdt_cid",Re="ttclid",xe="twclid",Ce="wbraid",De={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},Le=["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"],Ne=["authorization","cookie","set-cookie"],Ue=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!je(t,n))return!1}return!0},je=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=ge(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if("object"==typeof s)i=i&&Ue(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return Ue(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},Me=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return le({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(me.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(me.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(me.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(me.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(me.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(me.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(me.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(me.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(me.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[me.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[me.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===me.ADD?"number"==typeof n:e===me.UNSET||e===me.REMOVE||je(t,n)))},e}();!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"}(me||(me={}));var qe,Fe=[me.CLEAR_ALL,me.UNSET,me.SET,me.SET_ONCE,me.ADD,me.APPEND,me.PREPEND,me.PREINSERT,me.POSTINSERT,me.REMOVE];!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"}(qe||(qe={}));var Be,$e=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=qe.Unknown),{event:e,code:t,message:n}},Ke=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},He=ve([],he(Array(256).keys()),!1).map((function(e){return e.toString(16).padStart(2,"0")})),ze=function(e){var t,n=Ke();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,ze)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,ve([],he(r.entries()),!1).map((function(e){var t=he(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(He[r]):He[r]})).join("")},Ve=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,r;return fe(this,void 0,void 0,(function(){return pe(this,(function(i){switch(i.label){case 0:return this.plugins.some((function(t){return t.name===e.name}))?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=ze(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e,t){var n;return fe(this,void 0,void 0,(function(){var r,i;return pe(this,(function(o){switch(o.label){case 0:return r=this.plugins.findIndex((function(t){return t.name===e})),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}}))}))},e.prototype.reset=function(e){this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.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 fe(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T;return pe(this,(function(w){switch(w.label){case 0:if(!e)return[2];t=he(e,1),n=t[0],r=he(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),o=this.plugins.filter((function(e){return"before"===e.type})),w.label=1;case 1:w.trys.push([1,6,7,8]),a=ge(o),s=a.next(),w.label=2;case 2:return s.done?[3,5]:(f=s.value).execute?[4,f.execute(le({},n))]:[3,4];case 3:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=4;case 4:return s=a.next(),[3,2];case 5:return[3,8];case 6:return c=w.sent(),m={error:c},[3,8];case 7:try{s&&!s.done&&(y=a.return)&&y.call(a)}finally{if(m)throw m.error}return[7];case 8:u=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),w.label=9;case 9:w.trys.push([9,14,15,16]),l=ge(u),d=l.next(),w.label=10;case 10:return d.done?[3,13]:(f=d.value).execute?[4,f.execute(le({},n))]:[3,12];case 11:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=12;case 12:return d=l.next(),[3,10];case 13:return[3,16];case 14:return g=w.sent(),b={error:g},[3,16];case 15:try{d&&!d.done&&(T=l.return)&&T.call(l)}finally{if(b)throw b.error}return[7];case 16:return h=this.plugins.filter((function(e){return"destination"===e.type})),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),v=h.map((function(e){var t=le({},n);return e.execute(t).catch((function(e){return $e(t,0,String(e))}))})),Promise.all(v).then((function(e){var t=he(e,1)[0]||$e(n,100,"Event not tracked, no destination plugins on the instance");i(t)})),[2]}}))}))},e.prototype.flush=function(){return fe(this,void 0,void 0,(function(){var e,t,n,r=this;return pe(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"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return i.sent(),[2]}}))}))},e.prototype.onIdentityChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)}))},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)}))},e.prototype.onOptOutChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)}))},e.prototype.onReset=function(){this.plugins.forEach((function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)}))},e}(),Ge=function(e,t){return le(le({},t),{event_type:ue.IDENTIFY,user_properties:e.getUserProperties()})},Je=function(e){return{promise:e||Promise.resolve()}},We=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new Ve(this),this.name=e}return e.prototype._init=function(e){return fe(this,void 0,void 0,(function(){return pe(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 fe(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c;return pe(this,(function(u){switch(u.label){case 0:t=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),n=ge(t),r=n.next(),u.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return a=u.sent(),s={error:a},[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:u.sent(),u.label=12;case 12:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return le(le(le({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return Je(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Ge(e,t);return Je(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=function(e,t,n,r){var i;return le(le({},r),{event_type:ue.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})}(e,t,n,r);return Je(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,i=new Me;return i.set(e,t),le(le({},n),{event_type:ue.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return Je(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return le(le({},t),{event_type:ue.REVENUE,event_properties:e.getEventProperties()})}(e,t);return Je(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),Je())},e.prototype._addPlugin=function(e){return Je(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)),Je())},e.prototype._removePlugin=function(e){return Je(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t($e(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return fe(this,void 0,void 0,(function(){var t=this;return pe(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={};if(void 0===e)return t;var n={};return Object.keys(e).forEach((function(t){Object.values(ce).includes(t)||(n[t]=e[t])})),Fe.forEach((function(n){if(Object.keys(e).includes(n)){var r=e[n];switch(n){case ce.CLEAR_ALL:Object.keys(t).forEach((function(e){delete t[e]}));break;case ce.UNSET:Object.keys(r).forEach((function(e){delete t[e]}));break;case ce.SET:Object.assign(t,r)}}})),Object.assign(t,n),t},e.prototype.process=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i;return pe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.config.optOut?[2,$e(e,0,"Event skipped due to optOut config")]:(e.event_type===ue.IDENTIFY&&(t=this.getOperationAppliedUserProperties(e.user_properties),this.timeline.onIdentityChanged({userProperties:t})),[4,this.timeline.push(e)]);case 1:return 200===(i=o.sent()).code?this.config.loggerProvider.log(i.message):100===i.code?this.config.loggerProvider.warn(i.message):this.config.loggerProvider.error(i.message),[2,i];case 2:return n=o.sent(),r=String(n),this.config.loggerProvider.error(r),[2,i=$e(e,0,r)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.timeline.onOptOutChanged(e),this.config.optOut=Boolean(e))},e.prototype.flush=function(){return Je(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find((function(t){return t.name===e}));if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter((function(t){return t instanceof e}))},e}(),Ye=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){return Ue(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?le({},this.properties):{};return e[Be.REVENUE_PRODUCT_ID]=this.productId,e[Be.REVENUE_QUANTITY]=this.quantity,e[Be.REVENUE_PRICE]=this.price,e[Be.REVENUE_TYPE]=this.revenueType,e[Be.REVENUE_CURRENCY]=this.currency,e[Be.REVENUE]=this.revenue,e[Be.RECEIPT]=this.receipt,e[Be.RECEIPT_SIG]=this.receiptSig,e},e}();!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"}(Be||(Be={}));var Qe;!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"}(Qe||(Qe={}));var Xe="Amplitude Logger ",Ze=function(){function e(){this.logLevel=Qe.None}return e.prototype.disable=function(){this.logLevel=Qe.None},e.prototype.enable=function(e){void 0===e&&(e=Qe.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Qe.Verbose||console.log("".concat(Xe,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Qe.Warn||console.warn("".concat(Xe,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Qe.Error||console.error("".concat(Xe,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<Qe.Debug||console.log("".concat(Xe,"[Debug]: ").concat(e.join(" ")))},e}(),et=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:Te,logLevel:Qe.Warn,loggerProvider:new Ze,offline:!1,optOut:!1,serverUrl:we,serverZone:"US",useBatch:!1}},tt=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=et();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var a=rt(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=a.serverZone,this.serverUrl=a.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),nt=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":we},rt=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=et().serverZone),void 0===n&&(n=et().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:et().serverZone;return{serverZone:r,serverUrl:nt(r,n)}},it=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function ot(e){return e>=200&&e<300}var at=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},st=function(e){return function(){var t=le({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ct=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=ge(t.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(!(a in e))return;e=e[a]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},ut=function(e,t){return function(){var n,r,i={};try{for(var o=ge(t),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=ct(e,s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},lt=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=n(),c=s.logger,u=s.logLevel;if(u&&u<Qe.Debug||!u||!c)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:at(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}};function dt(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var ft=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return fe(this,void 0,void 0,(function(){var n,r=this;return pe(this,(function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(be,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map((function(e){return r.execute(e)}))).catch(),[2,Promise.resolve(void 0)]}}))}))},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=ze()),new Promise((function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()}))},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter((function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)}))},e.prototype.scheduleEvents=function(e){var t=this;e.forEach((function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)}))},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout((function(){t.queue=t.queue.map((function(e){return e.timeout=0,e})),t.flush(!0)}),e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),fe(this,void 0,void 0,(function(){var t,n,r=this;return pe(this,(function(i){switch(i.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 0===e.timeout?t.push(e):n.push(e)})),o=t,a=this.config.flushQueueSize,s=Math.max(a,1),[4,o.reduce((function(e,t,n){var r=Math.floor(n/s);return e[r]||(e[r]=[]),e[r].push(t),e}),[]).reduce((function(t,n){return fe(r,void 0,void 0,(function(){return pe(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}}))}))}),Promise.resolve())]);case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var o,a,s}))}))},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),fe(this,void 0,void 0,(function(){var r,i,o,a,s;return pe(this,(function(c){switch(c.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,de(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new it,c.label=1;case 1:return c.trys.push([1,3,,4]),i=rt(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(i,r)];case 2:return null===(o=c.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(o,e),[3,4]):("body"in o?this.fulfillRequest(e,o.statusCode,"".concat(o.status,": ").concat(dt(o))):this.fulfillRequest(e,o.statusCode,o.status),[2]);case 3:return a=c.sent(),s=(u=a)instanceof Error?u.message:String(u),this.config.loggerProvider.error(s),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map((function(e){return e.event.event_type})),message:s,stack_trace:at()}),this.handleResponse({status:qe.Failed,statusCode:0},e),[3,4];case 4:return[2]}var u}))}))},e.prototype.handleResponse=function(e,t){var n;ot(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map((function(e){return e.event.event_type})),code:e.statusCode,status:e.status,body:dt(e),stack_trace:at()});var r=e.status;switch(r){case qe.Success:this.handleSuccessResponse(e,t);break;case qe.Invalid:this.handleInvalidResponse(e,t);break;case qe.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case qe.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=ve(ve(ve(ve([],he(Object.values(e.body.eventsWithInvalidFields)),!1),he(Object.values(e.body.eventsWithMissingFields)),!1),he(Object.values(e.body.eventsWithInvalidIdLengths)),!1),he(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter((function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(dt(e));var a=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(a)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(dt(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,a=new Set(r),s=new Set(i),c=new Set(o),u=t.filter((function(t,r){if(!(t.event.user_id&&a.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)))return c.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));u.length>0&&this.config.loggerProvider.warn(dt(e));var l=this.removeEventsExceedFlushMaxRetries(u);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e})),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;ot(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map((function(e){return e.event.event_type})),code:t,message:n,stack_trace:at()})),this.removeEvents(e),e.forEach((function(e){return e.callback($e(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}(),pt=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:gt(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),gt=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},ht=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}(),vt=function(){return vt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},vt.apply(this,arguments)};function mt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function yt(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}"function"==typeof SuppressedError&&SuppressedError;var bt=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=mt(["string","number","boolean","undefined"]),a=o.next();!a.done;a=o.next()){if(a.value===i)return e===t}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var s=Array.isArray(e),c=Array.isArray(t);if(s!==c)return!1;if(!s||!c){var u=Object.keys(e).sort(),l=Object.keys(t).sort();if(!bt(u,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){bt(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!bt(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var Tt,wt=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=vt({},this.identity.userProperties),n=vt(vt({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,a,s,c=n.userProperties||{};try{for(var u=mt(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=yt(l.value,2),f=d[0],p=d[1];switch(f){case"$set":try{for(var g=(i=void 0,mt(Object.entries(p))),h=g.next();!h.done;h=g.next()){var v=yt(h.value,2),m=v[0],y=v[1];c[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(a=void 0,mt(Object.keys(p))),T=b.next();!T.done;T=b.next()){delete c[m=T.value]}}catch(e){a={error:e}}finally{try{T&&!T.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}break;case"$clearAll":c={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return vt({},this.identity)},e.prototype.setIdentity=function(e){var t=vt({},this.identity);this.identity=vt({},e),bt(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}(),kt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,St=function(){function e(){this.identityStore=new wt,this.eventBridge=new ht,this.applicationContextProvider=new pt}return e.getInstance=function(t){return kt.analyticsConnectorInstances||(kt.analyticsConnectorInstances={}),kt.analyticsConnectorInstances[t]||(kt.analyticsConnectorInstances[t]=new e),kt.analyticsConnectorInstances[t]},e}(),Et=function(e){return void 0===e&&(e=Te),St.getInstance(e)},_t=function(){function e(){this.name="identity",this.type="before",this.identityStore=Et().identityStore}return e.prototype.execute=function(e){return fe(this,void 0,void 0,(function(){var t;return pe(this,(function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]}))}))},e.prototype.setup=function(e){return fe(this,void 0,void 0,(function(){return pe(this,(function(t){return e.instanceName&&(this.identityStore=Et(e.instanceName).identityStore),[2]}))}))},e}(),It=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},Pt=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[ye,t,e.substring(0,n)].filter(Boolean).join("_")},At=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},Ot=function(){var e,t=Ke();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=Rt(n[0]),i=Rt(n[1]);return i?(e[r]=i,e):e}),{}):{}},Rt=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},xt=function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))},Ct=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Dt=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},Lt=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return fe(this,void 0,void 0,(function(){return pe(this,(function(e){return[2,!0]}))}))},e.prototype.get=function(e){return fe(this,void 0,void 0,(function(){return pe(this,(function(t){return[2,this.memoryStorage.get(e)]}))}))},e.prototype.getRaw=function(e){return fe(this,void 0,void 0,(function(){var t;return pe(this,(function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}}))}))},e.prototype.set=function(e,t){return fe(this,void 0,void 0,(function(){return pe(this,(function(n){return this.memoryStorage.set(e,t),[2]}))}))},e.prototype.remove=function(e){return fe(this,void 0,void 0,(function(){return pe(this,(function(t){return this.memoryStorage.delete(e),[2]}))}))},e.prototype.reset=function(){return fe(this,void 0,void 0,(function(){return pe(this,(function(e){return this.memoryStorage.clear(),[2]}))}))},e}(),Nt=function(){function e(e){this.options=le({},e)}return e.prototype.isEnabled=function(){return fe(this,void 0,void 0,(function(){var t,n;return pe(this,(function(r){switch(r.label){case 0:if(!Ke())return[2,!1];e.testValue=String(Date.now()),t=new e(this.options),n="AMP_TEST",r.label=1;case 1:return r.trys.push([1,4,5,7]),[4,t.set(n,e.testValue)];case 2:return r.sent(),[4,t.get(n)];case 3:return[2,r.sent()===e.testValue];case 4:return r.sent(),[2,!1];case 5:return[4,t.remove(n)];case 6:return r.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){var t;return fe(this,void 0,void 0,(function(){var n,r;return pe(this,(function(i){switch(i.label){case 0:return[4,this.getRaw(e)];case 1:if(!(n=i.sent()))return[2,void 0];try{return void 0===(r=null!==(t=Ut(n))&&void 0!==t?t:jt(n))?(console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(n)),[2,void 0]):[2,JSON.parse(r)]}catch(t){return console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(n)),[2,void 0]}return[2]}}))}))},e.prototype.getRaw=function(e){var t,n;return fe(this,void 0,void 0,(function(){var r,i,o;return pe(this,(function(a){return r=Ke(),i=null!==(n=null===(t=null==r?void 0:r.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[],o=i.find((function(t){return 0===t.indexOf(e+"=")})),o?[2,o.substring(e.length+1)]:[2,void 0]}))}))},e.prototype.set=function(e,t){var n;return fe(this,void 0,void 0,(function(){var r,i,o,a,s,c,u;return pe(this,(function(l){try{r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=void 0,(i=null!==t?r:-1)&&((a=new Date).setTime(a.getTime()+24*i*60*60*1e3),o=a),s="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t)))),o&&(s+="; expires=".concat(o.toUTCString())),s+="; path=/",this.options.domain&&(s+="; domain=".concat(this.options.domain)),this.options.secure&&(s+="; Secure"),this.options.sameSite&&(s+="; SameSite=".concat(this.options.sameSite)),(c=Ke())&&(c.document.cookie=s)}catch(t){u=t instanceof Error?t.message:String(t),console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(u))}return[2]}))}))},e.prototype.remove=function(e){return fe(this,void 0,void 0,(function(){return pe(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 fe(this,void 0,void 0,(function(){return pe(this,(function(e){return[2]}))}))},e}(),Ut=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}},jt=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}},Mt=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[ye,t,e.substring(0,n)].filter(Boolean).join("_")},qt=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return fe(this,void 0,void 0,(function(){var t,n,r;return pe(this,(function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return fe(this,void 0,void 0,(function(){var t;return pe(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())?[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){var t;return fe(this,void 0,void 0,(function(){return pe(this,(function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]}))}))},e.prototype.set=function(e,t){var n;return fe(this,void 0,void 0,(function(){return pe(this,(function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]}))}))},e.prototype.remove=function(e){var t;return fe(this,void 0,void 0,(function(){return pe(this,(function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]}))}))},e.prototype.reset=function(){var e;return fe(this,void 0,void 0,(function(){return pe(this,(function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]}))}))},e}(),Ft="tags",Bt="counters",$t="histograms",Kt="events",Ht="internal",zt="last_flush_timestamp",Vt=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=Ke())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return fe(this,void 0,void 0,(function(){return pe(this,(function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]}))}))},e.prototype.openDB=function(){var e=this;return new Promise((function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new 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(Ft)||e.createObjectStore(Ft,{keyPath:"key"}),e.objectStoreNames.contains(Bt)||e.createObjectStore(Bt,{keyPath:"key"}),e.objectStoreNames.contains($t)||e.createObjectStore($t,{keyPath:"key"}),e.objectStoreNames.contains(Kt))||e.createObjectStore(Kt,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Ht)||e.createObjectStore(Ht,{keyPath:"key"})},e.prototype.setTags=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Ft],"readwrite"),r=n.objectStore(Ft),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach((function(e){var t=he(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}}))}))},e.prototype.incrementCounters=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Bt],"readwrite"),r=n.objectStore(Bt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach((function(e){var t=he(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e=a.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}}))}))},e.prototype.setHistogramStats=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([$t],"readwrite"),r=n.objectStore($t),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach((function(e){var t=he(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e,t=a.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}}))}))},e.prototype.addEventRecords=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Kt],"readwrite"),r=n.objectStore(Kt),[2,new Promise((function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach((function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}}))},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}}))}))},e.prototype.setInternal=function(e,t){return fe(this,void 0,void 0,(function(){var n,r,i,o;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=a.sent(),r=n.transaction([Ht],"readwrite"),i=r.objectStore(Ht),[2,new Promise((function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var a=i.put({key:e,value:t});a.onsuccess=function(){return n()},a.onerror=function(){return o(new Error("Failed to set internal value"))}}))];case 2:return o=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}}))}))},e.prototype.getInternal=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i;return pe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Ht],"readonly"),r=n.objectStore(Ht),[2,new Promise((function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}}))];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}}))}))},e.prototype.getLastFlushTimestamp=function(){return fe(this,void 0,void 0,(function(){var e,t;return pe(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(zt)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}}))}))},e.prototype.setLastFlushTimestamp=function(e){return fe(this,void 0,void 0,(function(){var t;return pe(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(zt,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(new Error("Failed to clear table ".concat(t)))}}))},e.prototype.getAllAndClear=function(){return fe(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s;return pe(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([Ft,Bt,$t,Kt],"readwrite"),[4,Promise.all([this.getAllFromStore(t,Ft),this.getAllFromStore(t,Bt),this.getAllFromStore(t,$t),this.getAllFromStore(t,Kt)])];case 2:return n=he.apply(void 0,[c.sent(),4]),r=n[0],i=n[1],o=n[2],a=n[3],[4,Promise.all([this.clearTable(t,Bt),this.clearTable(t,$t),this.clearTable(t,Kt)])];case 3:return c.sent(),[2,{tags:r,counters:i,histogramStats:o,events:a}];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(new Error("Failed to get all from ".concat(t)))}}))},e}(),Gt=function(e){var t,n=null==(t=Ke())?void 0:t.__AMPLITUDE_SCRIPT_URL__;if(n)return e.filename&&e.filename.includes(n)?"filename":e.stack&&e.stack.includes(n)?"stack":void 0},Jt=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},Wt=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},Yt=3e5,Qt=1e4,Xt=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=le({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Dt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,Vt.isSupported()?this.storage=new Vt(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=Ke();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",le({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",(function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Gt({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})}),!0),t.addEventListener("unhandledrejection",(function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Jt(i),a=Gt({filename:o,stack:i});a&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:Wt(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})}),!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=Qt?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=Qt?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=Qt)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{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){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout((function(){e.saveAllDataToStorage().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)})).finally((function(){e.saveTimer=null}))}),1e3)),this.flushTimer||(this.flushTimer=setTimeout((function(){e._flush().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)})).finally((function(){e.flushTimer=null}))}),Yt))},e.prototype.saveAllDataToStorage=function(){return fe(this,void 0,void 0,(function(){var e,t,n,r;return pe(this,(function(i){switch(i.label){case 0:return this.storage?(e=le({},this.inMemoryTags),t=le({},this.inMemoryCounters),n=le({},this.inMemoryHistograms),r=ve([],he(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 fe(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,c,u;return pe(this,(function(l){switch(l.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return l.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=l.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach((function(e){o[e.key]=e.value})),a={},n.forEach((function(e){a[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}})),0===Object.keys(a).length&&0===Object.keys(s).length&&0===c.length?[2]:(u={tags:o,histogram:s,counters:a,events:c},this.fetch(u),[2])}}))}))},e.prototype.fetch=function(e){return fe(this,void 0,void 0,(function(){var t;return pe(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!Ke())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}}))}))},e.prototype.initializeFlushInterval=function(){return fe(this,void 0,void 0,(function(){var e,t,n;return pe(this,(function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(Yt),[2]):(n=e-t)>=Yt?(this._flush(),[2]):(this._setFlushTimer(Yt-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=Dt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),Zt=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k;if("object"!=typeof e)return null;var S=e.code||0,E=this.buildStatus(S);switch(E){case qe.Success:return{status:E,statusCode:S,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case qe.Invalid:return{status:E,statusCode:S,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(s=e.events_with_missing_fields)&&void 0!==s?s:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(p=e.throttled_devices)&&void 0!==p?p:{},throttledEvents:null!==(g=e.throttled_events)&&void 0!==g?g:[]}};case qe.PayloadTooLarge:return{status:E,statusCode:S,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case qe.RateLimit:return{status:E,statusCode:S,body:{error:null!==(v=e.error)&&void 0!==v?v:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(T=e.exceeded_daily_quota_devices)&&void 0!==T?T:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(k=e.throttled_events)&&void 0!==k?k:[]}};case qe.Timeout:default:return{status:E,statusCode:S}}},e.prototype.buildStatus=function(e){return ot(e)?qe.Success:429===e?qe.RateLimit:413===e?qe.PayloadTooLarge:408===e?qe.Timeout:e>=400&&e<500?qe.Invalid:e>=500?qe.Failed:qe.Unknown},e}(),en=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return se(t,e),t.prototype.send=function(e,t){return fe(this,void 0,void 0,(function(){var n,r,i;return pe(this,(function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(Zt),tn=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),nn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new tn(e,t)}return e.prototype.subscribe=function(e,t,n){var r=ze(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex((function(t){return t.id===e}));return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return fe(this,void 0,void 0,(function(){var e,t=this;return pe(this,(function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach((function(n){t.sendCallback(n,e,"remote")})),[2]}}))}))},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.fetchPromise=this.fetch().then((function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t})).finally((function(){e.fetchPromise=null}))),this.fetchPromise},e.prototype.subscribeAll=function(e){return fe(this,void 0,void 0,(function(){var t,n,r,i=this;return pe(this,(function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then((function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)})),n=this.storage.fetchConfig().then((function(e){return e})),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}}))}))},e.prototype.subscribeWaitForRemote=function(e,t){return fe(this,void 0,void 0,(function(){var n,r;return pe(this,(function(i){switch(i.label){case 0:n=new Promise((function(e,n){setTimeout((function(){n("Timeout exceeded")}),t)})),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}}))}))},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce((function(e,t){return null===e?e:t in e?e[t]:null}),t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),fe(this,void 0,void 0,(function(){var n,r,i,o,a,s,c=this;return pe(this,(function(u){switch(u.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,s,u,l;return pe(this,(function(d){switch(d.label){case 0:i=new AbortController,a=setTimeout((function(){return i.abort()}),t),d.label=1;case 1:return d.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:i.signal})];case 2:return(s=d.sent()).ok?[3,4]:[4,s.text()];case 3:return u=d.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(s.status,": ").concat(u)),[3,6];case 4:return[4,s.json()];case 5:return[2,{value:{remoteConfig:d.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(l=d.sent())instanceof Error&&"AbortError"===l.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),l),[3,9];case 8:return clearTimeout(a),[7];case 9:return r<e-1?[4,new Promise((function(e){return setTimeout(e,c.getJitterDelay(n))}))]:[3,11];case 10:d.sent(),d.label=11;case 11:return[2]}}))},o=this,a=0,u.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(s=u.sent()))return[2,s.value];u.label=3;case 3:return a++,[3,1];case 4:return[2,r]}}))}))},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}();!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(Tt||(Tt={}));var rn=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],on="data-amp-track-",an=["div","span","h1","h2","h3","h4","h5","h6"],sn=ve(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],he(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),cn=["*"];function un(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function ln(e,t,n){e&&dn({json:e,allowlist:t.map(fn),excludelist:n.map(fn),ancestors:[]})}function dn(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,a=e.excludelist,s=e.ancestors,c=e.parentObject,u=e.targetKey;i||(i=r);var l=Object.keys(i);try{for(var d=ge(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=ve(ve([],he(s),!1),[p],!1);un(i[p])?gn(g,o)&&!gn(g,a)||delete i[p]:dn({json:r,targetObject:i[p],allowlist:o,excludelist:a,ancestors:g,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}}0===Object.keys(i).length&&c&&u&&delete c[u]}function fn(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map((function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")}))}function pn(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(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 o=n;o<=e.length;o++)if(pn(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&pn(e,t,n+1,r+1)}function gn(e,t){return t.some((function(t){return pn(e,t)}))}var hn=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach((function(e){var t=he(e,2),n=t[0],r=t[1];i[n]=r}));else if(r instanceof Headers)r.forEach((function(e,t){i[t]=e}));else if("object"==typeof r&&null!==r)try{for(var o=ge(Object.entries(r)),a=o.next();!a.done;a=o.next()){var s=he(a.value,2),c=s[0],u=s[1];i[c]=u}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Sn(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=Ke();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=mn(t,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"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),fe(this,void 0,void 0,(function(){return pe(this,(function(n){return 0===e.length?[2,null]:[2,wn(this.body,e,t)]}))}))},e}(),vn=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),Sn(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return mn(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),fe(this,void 0,void 0,(function(){return pe(this,(function(n){return 0===e.length?[2,null]:[2,wn(this.body,e,t)]}))}))},e}();function mn(e,t){var n,r,i,o=Ke(),a=null==o?void 0:o.TextEncoder;if(a){var s;if("string"==typeof e)s=e,i=(new a).encode(s).length;else if(e instanceof Blob)i=(s=e).size;else if(e instanceof URLSearchParams)s=e,i=(new a).encode(s.toString()).length;else if(ArrayBuffer.isView(e))i=(s=e).byteLength;else if(e instanceof ArrayBuffer)i=(s=e).byteLength;else if(e instanceof FormData){var c=e,u=0,l=0;try{for(var d=ge(c.entries()),f=d.next();!f.done;f=d.next()){var p=he(f.value,2),g=p[0],h=p[1];if(u+=g.length,"string"==typeof h)u+=(new a).encode(h).length;else{if(!(h instanceof Blob))return;u+=h.size}if(++l>=t)return}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}i=u}else if(e instanceof ReadableStream)return void(s=e);return i}}var yn,bn=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,(function(e,t){r[t]=e})),Sn(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return fe(this,void 0,void 0,(function(){var e,t;return pe(this,(function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise((function(e){return setTimeout((function(){return e(null)}),500)})),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}}))}))},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),fe(this,void 0,void 0,(function(){return pe(this,(function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,wn(n.sent(),e,t)]}}))}))},e}(),Tn=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(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=ge(i),a=o.next();!a.done;a=o.next()){var s=he(a.value.split(": "),2),c=s[0],u=s[1];c&&u&&(r[c]=u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Sn(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),fe(this,void 0,void 0,(function(){var n;return pe(this,(function(r){return 0===e.length?[2,null]:(n=this.getJson())?(ln(n,e,t),[2,n]):[2,null]}))}))},e}();function wn(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return ln(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(yn||(yn={}));var kn="[REDACTED]",Sn=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,a=t.strategy,s=void 0===a?yn.REMOVE:a,c=ve([],he(Ne),!1),u={},l=function(t){var n=t.toLowerCase();c.find((function(e){return e.toLowerCase()===n}))?s===yn.REDACT&&(u[t]=kn):o.find((function(e){return e.toLowerCase()===n}))?u[t]=e[t]:s===yn.REDACT&&(u[t]=kn)};try{for(var d=ge(Object.keys(e)),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u},En=function(){function e(e,t,n,r,i,o,a,s,c,u,l){void 0===a&&(a=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=a,this.duration=s,this.responseWrapper=c,this.error=u,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(ve([],he(Le),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(ve([],he(Le),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter((function(e){var t=he(e,2);return t[0],void 0!==t[1]})))},e}();var _n=function(e,t){void 0===t&&(t=ze()),this.callback=e,this.id=t},In=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=Ke();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=Ke();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,a,s,c,u,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,p=null===(s=null===(a=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===a?void 0:a.prototype)||void 0===s?void 0:s.send,g=null===(l=null===(u=null===(c=this.globalScope)||void 0===c?void 0:c.XMLHttpRequest)||void 0===u?void 0:u.prototype)||void 0===l?void 0:l.setRequestHeader;f&&p&&g&&this.observeXhr(f,p,g);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),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){var r;try{n.callback(e)}catch(e){null===(r=t.logger)||void 0===r||r.debug("an unexpected error occurred while triggering event callbacks",e)}}))},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,a){var s;if(void 0!==o&&void 0!==a){var c,u,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?c=null===(s=null==t?void 0:t.toString)||void 0===s?void 0:s.call(t):(c=t.url,d=t.method),c)try{var f=new URL(c);c="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(u=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},u=0);var p=Math.floor(performance.now()-a),g=Math.floor(o+p),h=new En(e,d,o,o,c,n,u,p,r,l,g);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return fe(t,void 0,void 0,(function(){var t,i,o,a,s,c;return pe(this,(function(u){switch(u.label){case 0:try{t=this.getTimestamps()}catch(e){null===(s=this.logger)||void 0===s||s.debug("an unexpected error occurred while retrieving timestamps",e)}u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),o=a,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new hn(r):void 0,i?new bn(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while handling fetch",e)}if(i)return[2,i];throw o}}))}))})},e.createXhrJsonParser=function(e,t){return function(){var n,r;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&(null===(r=t.logger)||void 0===r||r.error("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=he(r,2),s=a[0],c=a[1];try{this.$$AmplitudeAnalyticsEvent=le({method:s,url:null===(e=null==c?void 0:c.toString)||void 0===e?void 0:e.call(c),headers:{}},o.getTimestamps())}catch(e){null===(n=o.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr open",e)}return t.apply(this,r)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,a=e.createXhrJsonParser(this,o),s=t[0],c=i.$$AmplitudeAnalyticsEvent;return i.addEventListener("loadend",(function(){var e;try{var t=i.getAllResponseHeaders(),n=i.getResponseHeader("content-length"),r=new Tn(i.status,t,n?parseInt(n,10):void 0,a),u=i.$$AmplitudeAnalyticsEvent.headers,l=new vn(s,u);c.status=i.status,o.handleNetworkRequestEvent("xhr",{url:c.url,method:c.method},l,r,void 0,c.startTime,c.durationStart)}catch(t){null===(e=o.logger)||void 0===e||e.error("an unexpected error occurred while handling xhr send",t)}})),n.apply(i,t)},i.setRequestHeader=function(e,t){var n;try{this.$$AmplitudeAnalyticsEvent.headers[e]=t}catch(e){null===(n=o.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr setRequestHeader",e)}r.apply(this,[e,t])}}},e}(),Pn=new In,An=function(){function e(){}return e.prototype.parse=function(){return fe(this,void 0,void 0,(function(){return pe(this,(function(e){return[2,le(le(le(le({},De),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=Ot();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=Ot();return(e={})[ke]=t[ke],e[Se]=t[Se],e[Ee]=t[Ee],e[_e]=t[_e],e[Ie]=t[Ie],e[Pe]=t[Pe],e[Ae]=t[Ae],e[Oe]=t[Oe],e[Re]=t[Re],e[xe]=t[xe],e[Ce]=t[Ce],e},e}(),On="data-amp-mask",Rn="*****",xn=/\b(?:\d[ -]*?){13,16}\b/,Cn=/(\d{3}-?\d{2}-?\d{4})/g,Dn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Ln=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(xn,Rn)).replace(Cn,Rn)).replace(Dn,Rn);try{for(var o=ge(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,Rn)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},Nn=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(On)?Rn:e?e(document.title):document.title};function Un(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return jn(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function qn(e,t,n){return t&&Mn(e.prototype,t),n&&Mn(e,n),e}var Fn=function(){return"function"==typeof Symbol},Bn=function(e){return Fn()&&Boolean(Symbol[e])},$n=function(e){return Bn(e)?Symbol[e]:"@@"+e};Fn()&&!Bn("observable")&&(Symbol.observable=Symbol("observable"));var Kn=$n("iterator"),Hn=$n("observable"),zn=$n("species");function Vn(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function Gn(e){var t=e.constructor;return void 0!==t&&null===(t=t[zn])&&(t=void 0),void 0!==t?t:rr}function Jn(e){return e instanceof rr}function Wn(e){Wn.log?Wn.log(e):setTimeout((function(){throw e}))}function Yn(e){Promise.resolve().then((function(){try{e()}catch(e){Wn(e)}}))}function Qn(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=Vn(t,"unsubscribe");n&&n.call(t)}}catch(e){Wn(e)}}function Xn(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function Zn(e,t,n){e._state="running";var r=e._observer;try{var i=Vn(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(Xn(e),!i)throw n;i.call(r,n);break;case"complete":Xn(e),i&&i.call(r)}}catch(e){Wn(e)}"closed"===e._state?Qn(e):"running"===e._state&&(e._state="ready")}function er(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void Yn((function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(Zn(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)}))):void Zn(e,t,n);e._queue.push({type:t,value:n})}}var tr=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new nr(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(Xn(this),Qn(this))},qn(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),nr=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){er(this._subscription,"next",e)},t.error=function(e){er(this._subscription,"error",e)},t.complete=function(){er(this._subscription,"complete")},qn(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),rr=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new tr(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise((function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}}))},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Gn(this))((function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Gn(this))((function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Gn(this),r=arguments.length>1,i=!1,o=arguments[1];return new n((function(n){return t.subscribe({next:function(t){var a=!i;if(i=!0,!a||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})}))},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=Gn(this);return new i((function(t){var r,o=0;return function e(a){r=a.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}}))},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Gn(this);return new n((function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))},t[Hn]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=Vn(t,Hn);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Jn(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(Bn("iterator")&&(r=Vn(t,Kn)))return new n((function(e){Yn((function(){if(!e.closed){for(var n,i=Un(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){Yn((function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)((function(e){Yn((function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}}))}))},qn(e,null,[{key:zn,get:function(){return this}}]),e}();function ir(e,t){return new rr((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 or(e,t){return new rr((function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=ge(i),o=n.next();!o.done;o=n.next()){var a=o.value;try{a.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},a=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return a(e),a(t),o}))}function ar(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new rr((function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=ge(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.next)||void 0===i||i.call(s,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var a=ge(t),s=a.next();!s.done;s=a.next()){var c=s.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=ge(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.complete)||void 0===i||i.call(s)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}}))}Fn()&&Object.defineProperty(rr,Symbol("extensions"),{value:{symbol:Hn,hostReportError:Wn},configurable:!0});var sr=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},cr=function(e){return sr(e,"attribution")},ur=function(e){return sr(e,"pageViews")},lr=function(e){return sr(e,"sessions")},dr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},fr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},pr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},gr=function(e){if(fr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},hr=function(e){if(pr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},vr=function(e){var t;if(dr(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),le(le({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map((function(t){var n,r,i;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var o=JSON.stringify(t.hosts),a=JSON.stringify(t.urls);return null===(i=e.loggerProvider)||void 0===i||i.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),le(le({},t),{hosts:void 0})}return t}))})}},mr=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return ur(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},yr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,a=r.resolve,s=e&&e[i];if("function"==typeof s){var c=s.apply(e,o);"function"==typeof a&&a(null==c?void 0:c.promise)}}return e},br=function(e){return e&&void 0!==e._q},Tr="2.32.2",wr="amplitude-ts",kr=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(wr,"/").concat(Tr),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return fe(this,void 0,void 0,(function(){var r,i,o;return pe(this,(function(a){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,o=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,le(le(le(le(le(le(le(le({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:At()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:ze(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:o,library:this.library,user_agent:this.userAgent})]}))}))},e}(),Sr=1e3,Er=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=Ke())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return se(t,e),t.prototype.set=function(t,n){var r;return fe(this,void 0,void 0,(function(){var i;return pe(this,(function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>Sr?(i=n.length-Sr,[4,e.prototype.set.call(this,t,n.slice(0,Sr))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(Sr,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))},t}(qt),_r=function(e){function t(){var t;return e.call(this,null===(t=Ke())||void 0===t?void 0:t.sessionStorage)||this}return se(t,e),t}(qt),Ir=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={done:4},t}return se(t,e),t.prototype.send=function(e,t){return fe(this,void 0,void 0,(function(){var n=this;return pe(this,(function(r){return[2,new Promise((function(r,i){"undefined"==typeof XMLHttpRequest&&i(new Error("XHRTransport is not supported."));var o=new XMLHttpRequest;o.open("POST",e,!0),o.onreadystatechange=function(){if(o.readyState===n.state.done){var e=o.responseText;try{r(n.buildResponse(JSON.parse(e)))}catch(e){r(n.buildResponse({code:o.status}))}}},o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Accept","*/*"),o.send(JSON.stringify(t))}))]}))}))},t}(Zt),Pr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return se(t,e),t.prototype.send=function(e,t){return fe(this,void 0,void 0,(function(){var n=this;return pe(this,(function(r){return[2,new Promise((function(r,i){var o=Ke();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var a=JSON.stringify(t);return r(o.navigator.sendBeacon(e,JSON.stringify(t))?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:a.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}}))]}))}))},t}(Zt),Ar=function(e,t,n){return void 0===n&&(n=!0),fe(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d;return pe(this,(function(f){switch(f.label){case 0:return r=function(e){return"".concat(ye.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=f.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:f.sent(),f.label=3;case 3:return o=he(i.split("."),6),a=o[0],s=o[1],c=o[2],u=o[3],l=o[4],d=o[5],[2,{deviceId:a,userId:Rr(s),sessionId:Or(u),lastEventId:Or(d),lastEventTime:Or(l),optOut:Boolean(c)}]}}))}))},Or=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Rr=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},xr="[Amplitude]",Cr="".concat(xr," Form Started"),Dr="".concat(xr," Form Submitted"),Lr="".concat(xr," File Downloaded"),Nr="session_start",Ur="session_end",jr="".concat(xr," File Extension"),Mr="".concat(xr," File Name"),qr="".concat(xr," Link ID"),Fr="".concat(xr," Link Text"),Br="".concat(xr," Link URL"),$r="".concat(xr," Form ID"),Kr="".concat(xr," Form Name"),Hr="".concat(xr," Form Destination"),zr="cookie",Vr=function(e){function t(t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,S,E,_,I,P,A,O,R,x,C,D,L,N,U,j,M,q,F){void 0===r&&(r=new Lt),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===c&&(c=1e3),void 0===u&&(u=5),void 0===l&&(l=30),void 0===d&&(d=zr),void 0===v&&(v=new Ze),void 0===m&&(m=Qe.Warn),void 0===b&&(b=!1),void 0===T&&(T=!1),void 0===S&&(S=""),void 0===E&&(E="US"),void 0===I&&(I=18e5),void 0===P&&(P=new Er({loggerProvider:v})),void 0===A&&(A={ipAddress:!0,language:!0,platform:!0}),void 0===O&&(O="fetch"),void 0===R&&(R=!1),void 0===x&&(x=!0),void 0===j&&(j=!0),void 0===M&&(M=0);var B,$=e.call(this,{apiKey:t,storageProvider:P,transportProvider:Wr(O)})||this;return $.apiKey=t,$.appVersion=n,$.cookieOptions=i,$.defaultTracking=o,$.autocapture=a,$.flushIntervalMillis=c,$.flushMaxRetries=u,$.flushQueueSize=l,$.identityStorage=d,$.ingestionMetadata=f,$.instanceName=p,$.loggerProvider=v,$.logLevel=m,$.minIdLength=y,$.offline=b,$.partnerId=w,$.plan=k,$.serverUrl=S,$.serverZone=E,$.sessionTimeout=I,$.storageProvider=P,$.trackingOptions=A,$.transport=O,$.useBatch=R,$.fetchRemoteConfig=x,$.networkTrackingOptions=N,$.identify=U,$.enableDiagnostics=j,$.diagnosticsSampleRate=M,$.diagnosticsClient=q,$.remoteConfig=F,$.version=Tr,$._optOut=!1,$._cookieStorage=r,$.deviceId=s,$.lastEventId=g,$.lastEventTime=h,$.optOut=T,$.sessionId=_,$.pageCounter=D,$.userId=C,$.debugLogsEnabled=L,$.loggerProvider.enable(L?Qe.Debug:$.logLevel),$.networkTrackingOptions=N,$.identify=U,$.enableDiagnostics=j,$.diagnosticsSampleRate=M,$.diagnosticsClient=q,B=!0===(null==F?void 0:F.fetchRemoteConfig)||!1!==(null==F?void 0:F.fetchRemoteConfig)&&!1!==x,$.remoteConfig=$.remoteConfig||{},$.remoteConfig.fetchRemoteConfig=B,$.fetchRemoteConfig=B,$}return se(t,e),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,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,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled};this.cookieStorage.set(Pt(this.apiKey),e)},t}(tt),Gr=function(e,t,n){return void 0===t&&(t={}),fe(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,S,E,_,I,P,A,O,R,x,C,D,L,N,U,j,M,q,F,B,$,K,H,z,V,G;return pe(this,(function(J){switch(J.label){case 0:return r=t.identityStorage||zr,S={},r===zr?[3,1]:(o="",[3,5]);case 1:return null===(_=null===(E=t.cookieOptions)||void 0===E?void 0:E.domain)||void 0===_?[3,2]:(a=_,[3,4]);case 2:return[4,Yr()];case 3:a=J.sent(),J.label=4;case 4:o=a,J.label=5;case 5:return i=le.apply(void 0,[(S.domain=o,S.expiration=365,S.sameSite="Lax",S.secure=!1,S.upgrade=!0,S),t.cookieOptions]),s=Jr(t.identityStorage,i),[4,Ar(e,s,null===(P=null===(I=t.cookieOptions)||void 0===I?void 0:I.upgrade)||void 0===P||P)];case 6:return c=J.sent(),[4,s.get(Pt(e))];case 7:return u=J.sent(),l=Ot(),d=l.ampTimestamp?Number(l.ampTimestamp):void 0,f=!d||Date.now()<d,p=null!==(C=null!==(x=null!==(R=null!==(A=t.deviceId)&&void 0!==A?A:f?null!==(O=l.ampDeviceId)&&void 0!==O?O:l.deviceId:void 0)&&void 0!==R?R:null==u?void 0:u.deviceId)&&void 0!==x?x:c.deviceId)&&void 0!==C?C:ze(),g=null!==(D=null==u?void 0:u.lastEventId)&&void 0!==D?D:c.lastEventId,h=null!==(L=null==u?void 0:u.lastEventTime)&&void 0!==L?L:c.lastEventTime,v=null!==(U=null!==(N=t.optOut)&&void 0!==N?N:null==u?void 0:u.optOut)&&void 0!==U?U:c.optOut,m=null!==(j=null==u?void 0:u.sessionId)&&void 0!==j?j:c.sessionId,y=null!==(q=null!==(M=t.userId)&&void 0!==M?M:null==u?void 0:u.userId)&&void 0!==q?q:c.userId,n.previousSessionDeviceId=null!==(F=null==u?void 0:u.deviceId)&&void 0!==F?F:c.deviceId,n.previousSessionUserId=null!==(B=null==u?void 0:u.userId)&&void 0!==B?B:c.userId,b={ipAddress:null===(K=null===($=t.trackingOptions)||void 0===$?void 0:$.ipAddress)||void 0===K||K,language:null===(z=null===(H=t.trackingOptions)||void 0===H?void 0:H.language)||void 0===z||z,platform:null===(G=null===(V=t.trackingOptions)||void 0===V?void 0:V.platform)||void 0===G||G},T=null==u?void 0:u.pageCounter,w=null==u?void 0:u.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(k=new Vr(e,t.appVersion,s,i,t.defaultTracking,t.autocapture,p,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,r,t.ingestionMetadata,t.instanceName,g,h,t.loggerProvider,t.logLevel,t.minIdLength,t.offline,v,t.partnerId,t.plan,t.serverUrl,t.serverZone,m,t.sessionTimeout,t.storageProvider,b,t.transport,t.useBatch,t.fetchRemoteConfig,y,T,w,t.networkTrackingOptions,t.identify,t.enableDiagnostics,n._diagnosticsSampleRate,void 0,t.remoteConfig)).storageProvider.isEnabled()];case 8:return J.sent()||(k.loggerProvider.warn("Storage provider ".concat(k.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),k.storageProvider=new Lt),[2,k]}}))}))},Jr=function(e,t){switch(void 0===e&&(e=zr),void 0===t&&(t={}),e){case"localStorage":return new Er;case"sessionStorage":return new _r;case"none":return new Lt;default:return new Nt(le(le({},t),{expirationDays:t.expiration}))}},Wr=function(e){return"xhr"===e?new Ir:"beacon"===e?new Pr:new en},Yr=function(e){return fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,o,a;return pe(this,(function(s){switch(s.label){case 0:return[4,(new Nt).isEnabled()];case 1:if(!s.sent()||"undefined"==typeof location||!location.hostname)return[2,""];for(e=location.hostname,t=e.split("."),n=[],r="AMP_TLDTEST",i=t.length-2;i>=0;--i)n.push(t.slice(i).join("."));i=0,s.label=2;case 2:return i<n.length?(o=n[i],[4,(a=new Nt({domain:"."+o})).set(r,1)]):[3,7];case 3:return s.sent(),[4,a.get(r)];case 4:return s.sent()?[4,a.remove(r)]:[3,6];case 5:return s.sent(),[2,"."+o];case 6:return i++,[3,2];case 7:return[2,""]}}))}))},Qr=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Xr=function(e){var t;void 0===e&&(e={});var n,r=Ke(),i=void 0,o=!1,a=e.trackOn,s=e.trackHistoryChanges,c=e.eventType,u=void 0===c?"[Amplitude] Page Viewed":c,l=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==i||i.error("Malformed URI sequence: ",e)}return t},d=function(){return fe(void 0,void 0,void 0,(function(){var e,t,n;return pe(this,(function(r){switch(r.label){case 0:return e=l("undefined"!=typeof location&&location.href||""),n={event_type:u},t=[{}],[4,Zr()];case 1:return[2,(n.event_properties=le.apply(void 0,[le.apply(void 0,t.concat([r.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":e,"[Amplitude] Page Path":"undefined"!=typeof location&&l(location.pathname)||"","[Amplitude] Page Title":Nn(Ln),"[Amplitude] Page URL":e.split("?")[0]}]),n)]}}))}))},f=function(){return void 0===a||"function"==typeof a&&a()},p="undefined"!=typeof location?location.href:null,g=function(){return fe(void 0,void 0,void 0,(function(){var e,n,r,o;return pe(this,(function(a){switch(a.label){case 0:return e=location.href,n=ti(s,e,p||"")&&f(),p=e,n?(null==i||i.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return o=(r=t).track,[4,d()];case 2:o.apply(r,[a.sent()]),a.label=3;case 3:a.label=4;case 4:return[2]}}))}))},h=function(){g()},v={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,a){return fe(void 0,void 0,void 0,(function(){var s,c;return pe(this,(function(u){switch(u.label){case 0:return t=a,n=e,(i=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o=!0,r&&(r.addEventListener("popstate",h),r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=he(n,3),i=r[0],a=r[1],s=r[2];e.apply(t,[i,a,s]),o&&g()}})),f()?(i.log("Tracking page view event"),c=(s=t).track,[4,d()]):[3,2];case 1:c.apply(s,[u.sent()]),u.label=2;case 2:return[2]}}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){var t;return pe(this,(function(r){switch(r.label){case 0:return"attribution"===a&&ei(e)?(null==i||i.log("Enriching campaign event to page view event with campaign parameters"),[4,d()]):[3,2];case 1:t=r.sent(),e.event_type=t.event_type,e.event_properties=le(le({},e.event_properties),t.event_properties),r.label=2;case 2:return n&&e.event_type===u&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=le(le({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(e){return r&&(r.removeEventListener("popstate",h),o=!1),[2]}))}))}};return v},Zr=function(){return fe(void 0,void 0,void 0,(function(){var e;return pe(this,(function(t){switch(t.label){case 0:return e=Qr,[4,(new An).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},ei=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[ce.SET]||{},r=t[ce.UNSET]||{},i=ve(ve([],he(Object.keys(n)),!1),he(Object.keys(r)),!1);return Object.keys(De).every((function(e){return i.includes(e)}))}return!1},ti=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},ni=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(t,r){return fe(void 0,void 0,void 0,(function(){var i,o;return pe(this,(function(a){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var t=!1;n(e,"change",(function(){var n,i=ii(e);t||r.track(Cr,((n={})[$r]=ri(e.id),n[Kr]=ri(e.name),n[Hr]=i,n)),t=!0})),n(e,"submit",(function(){var n,i,o=ii(e);t||r.track(Cr,((n={})[$r]=ri(e.id),n[Kr]=ri(e.name),n[Hr]=o,n)),r.track(Dr,((i={})[$r]=ri(e.id),i[Kr]=ri(e.name),i[Hr]=o,i)),t=!1}))};Array.from(document.getElementsByTagName("form")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"FORM"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else t.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?i():(o=Ke())?o.addEventListener("load",i):t.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},ri=function(e){if("string"==typeof e)return e},ii=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},oi=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return fe(void 0,void 0,void 0,(function(){var i,o;return pe(this,(function(a){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),a=null==i?void 0:i[1];a&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",(function(){var t;a&&r.track(Lr,((t={})[jr]=a,t[Mr]=n.pathname,t[qr]=e.id,t[Fr]=e.text,t[Br]=e.href,t))}))},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=Ke())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},ai=!1,si=function(){var e=Ke(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",(function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout((function(){t.flush()}),e.flushIntervalMillis)})),n("offline",(function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2])}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(n){return t.forEach((function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)})),t=[],[2]}))}))}}};function ci(e){var t,n,r,i,o,a,s,c,u,l,d;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var f=Object.keys(e);try{for(var p=ge(f),g=p.next();!g.done;g=p.next()){var h=g.value;try{var v=e[h];"boolean"==typeof(null==v?void 0:v.enabled)&&(v.enabled?(delete v.enabled,0===Object.keys(v).length&&(e[h]=!0)):e[h]=!1),ci(v)}catch(e){}}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}try{if(null===(u=null===(c=null===(s=e.autocapture)||void 0===s?void 0:s.networkTracking)||void 0===c?void 0:c.captureRules)||void 0===u?void 0:u.length)try{for(var m=ge(e.autocapture.networkTracking.captureRules),y=m.next();!y.done;y=m.next()){var b=y.value;try{for(var T=(o=void 0,ge(["responseHeaders","requestHeaders"])),w=T.next();!w.done;w=T.next()){var k=w.value,S=null!==(l=b[k])&&void 0!==l?l:{},E=S.captureSafeHeaders,_=S.allowlist;(E||_)&&(void 0===_||Array.isArray(_)?b[k]=ve(ve([],he(E?Le:[]),!1),he(null!=_?_:[]),!1):delete b[k])}}catch(e){o={error:e}}finally{try{w&&!w.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}catch(e){}var I=null===(d=e.autocapture)||void 0===d?void 0:d.frustrationInteractions;I&&(I.rageClick&&(I.rageClicks=I.rageClick,delete I.rageClick),I.deadClick&&(I.deadClicks=I.deadClick,delete I.deadClick))}}function ui(e,t,n){var r,i,o=[];try{for(var a=ge(null!=t?t:[]),s=a.next();!s.done;s=a.next()){var c=s.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e.concat(o)}function li(e,t){var n,r,i,o,a,s,c;if(e){ci(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var u=e;if(u&&"autocapture"in u){if("boolean"==typeof u.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture&&null!==u.autocapture){var l=le({},u.autocapture);if(void 0===t.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture.elementInteractions&&null!==u.autocapture.elementInteractions&&(null===(i=u.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===i?void 0:i.length)){l.elementInteractions=le({},u.autocapture.elementInteractions);var d=l.elementInteractions,f=null!==(o=d.pageUrlAllowlist)&&void 0!==o?o:[],p=u.autocapture.elementInteractions.pageUrlAllowlistRegex;d.pageUrlAllowlist=ui(f,p,t),delete d.pageUrlAllowlistRegex}if("object"==typeof u.autocapture.networkTracking&&null!==u.autocapture.networkTracking&&(null===(a=u.autocapture.networkTracking.captureRules)||void 0===a?void 0:a.length)){l.networkTracking=le({},u.autocapture.networkTracking);var g=null!==(s=l.networkTracking.captureRules)&&void 0!==s?s:[];try{for(var h=ge(g),v=h.next();!v.done;v=h.next()){var m=v.value;m.urls=ui(null!==(c=m.urls)&&void 0!==c?c:[],m.urlsRegex,t),delete m.urlsRegex}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=le({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},l)),"object"==typeof t.autocapture&&(t.autocapture=le(le({},t.autocapture),l))}t.defaultTracking=t.autocapture}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 di="1.18.2",fi="[Amplitude] Element Clicked",pi="[Amplitude] Element Tag",gi="[Amplitude] Element Text",hi="[Amplitude] Page URL",vi="https://app.amplitude.com",mi={US:vi,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},yi="data-amp-mask-attributes",bi=["input","select","textarea"],Ti=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},wi=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,a,s=e.pageUrlAllowlist,c=e.pageUrlExcludelist,u=e.shouldTrackEventResolver,l=null===(a=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===a?void 0:a.call(o);if(!l)return!1;if(u)return u(r,i);if(!xt(window.location.href,s))return!1;if(c&&c.length>0&&xt(window.location.href,c))return!1;var d=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof d)switch(d.toLowerCase()){case"hidden":case"password":return!1}var f=Ti(i,r);if(n&&f)return!0;if(t){var p=t.some((function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))}));if(!p)return!1}switch(l){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!f||"click"===r}}},ki=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},Si=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:Si(null==e?void 0:e.parentElement,t):null};var Ei=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};var _i=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",yi,On]),Ii=["type"],Pi=["svg","path","g"],Ai=["password","hidden"];function Oi(e,t){var n,r,i,o,a,s;if(null===e)return null;var c=String(e.tagName).toLowerCase(),u={tag:c},l=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);l.length&&(u.index=l.indexOf(e),u.indexOfType=l.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var d=null===(s=null===(a=e.previousElementSibling)||void 0===a?void 0:a.tagName)||void 0===s?void 0:s.toLowerCase();d&&(u.prevSib=String(d));var f=e.getAttribute("id");f&&(u.id=String(f));var p=Array.from(e.classList);p.length&&(u.classes=p);var g={},h=Array.from(e.attributes).filter((function(e){return!_i.has(e.name)})),v=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!bi.includes(i)&&!o}(e);if(!Ai.includes(String(e.getAttribute("type")))&&!Pi.includes(c))try{for(var m=ge(h),y=m.next();!y.done;y=m.next()){var b=y.value;v&&!Ii.includes(b.name)||(t.has(b.name)?g[b.name]=Rn:g[b.name]=String(b.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(g).length&&(u.attrs=g),u}var Ri=function(e,t,n){e.forEach((function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}}))},xi=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Ln(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,a,s=performance.now();if(!e)return[];for(var c,u=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),l=new Map,d=u.length-1;d>=0;d--){var f=u[d];if(f){var p=(c=f.getAttribute(yi))?c.split(",").map((function(e){return e.trim()})).filter((function(e){return e.length>0&&"id"!==e&&"class"!==e})):[],g=d===u.length-1?[]:null!==(r=l.get(u[d+1]))&&void 0!==r?r:new Set,h=new Set(ve(ve([],he(g),!1),he(p),!1));l.set(f,h)}}a=u.map((function(e){var t;return Oi(e,null!==(t=l.get(e))&&void 0!==t?t:new Set)}));var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach((function(t){var n=he(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))}))};try{for(var m=ge(a),y=m.next();!y.done;y=m.next())v(y.value)}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",b-s),a},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getEventProperties=function(e,t,n){var r,i,a,s,c,u,l=null===(a=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===a?void 0:a.call(i),d="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=o.getHierarchy(t),p=null===(s=f[0])||void 0===s?void 0:s.attrs,g=o.getNearestLabel(t),h=(c=null!=p?p:{},u=n,Object.entries(c).reduce((function(e,t){var n=he(t,2),r=n[0],i=n[1];if(r.startsWith(u)){var o=r.replace(u,"");o&&(e[o]=i||"")}return e}),{})),v=((r={})["[Amplitude] Element Hierarchy"]=f,r[pi]=l,r[gi]=o.getText(t),r["[Amplitude] Element Position Left"]=null==d.left?null:Math.round(d.left),r["[Amplitude] Element Position Top"]=null==d.top?null:Math.round(d.top),r["[Amplitude] Element Attributes"]=h,r["[Amplitude] Element Parent Label"]=g,r[hi]=Ct(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=Nn(o.replaceSensitiveString),r["[Amplitude] Viewport Height"]=window.innerHeight,r["[Amplitude] Viewport Width"]=window.innerWidth,r);if(v["[Amplitude] Element ID"]=t.getAttribute("id")||"",v["[Amplitude] Element Class"]=t.getAttribute("class"),v["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===l&&"click"===e&&t instanceof HTMLAnchorElement){var m=t.href.substring(0,128);v["[Amplitude] Element Href"]=o.replaceSensitiveString(m)}return ki(v)},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var a={event:e,timestamp:Date.now(),type:t};if(function(e){return"click"===e.type||"change"===e.type}(a)&&null!==a.event.target){if(i&&Ti(a.event.target,a.type))return a.closestTrackedAncestor=a.event.target,a.targetElementProperties=o.getEventProperties(a.type,a.closestTrackedAncestor,r),a;var s=Si(a.event.target,n);return s&&(a.closestTrackedAncestor=s,a.targetElementProperties=o.getEventProperties(a.type,s,r)),a}return a},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getText=function(e){if(null!==e.closest("[".concat(On,"]")))return Rn;var t="";if(e.querySelector("[".concat(On,"], [contenteditable]"))){var n=e.cloneNode(!0);n.querySelectorAll("[".concat(On,"], [contenteditable]")).forEach((function(e){e.innerText=Rn})),t=n.innerText||""}else t=e.innerText||"";return o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),a=((t={})[pi]=i,t[gi]=o.getText(e),t[hi]=window.location.href.split("?")[0],t);return ki(a)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var a=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],s=[];try{for(var c=ge(a),u=c.next();!u.done;u=c.next()){var l=u.value;if(s.length>=25)break;if(l instanceof RegExp)s.push(l);else if("pattern"in l&&"string"==typeof l.pattern)try{s.push(new RegExp(l.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=s},Ci=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?vi:t,r=this;this.endpoint=vi,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise((function(t,a){r.requestCallbacks[i]={resolve:t,reject:a},r.notify(o),(null==n?void 0:n.timeout)>0&&setTimeout((function(){a(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{dataExtractor:new xi({})}:e,r=n.logger,i=n.endpoint,o=n.isElementSelectable,a=n.cssSelectorAllowlist,s=n.actionClickAllowlist,c=n.dataExtractor;this.logger=r,i&&this.endpoint===vi&&(this.endpoint=i);var u=null;window.addEventListener("message",(function(e){var n,r,i,l,d;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var f,p=null==e?void 0:e.data,g=null==p?void 0:p.action;if(g)if("id"in p)null===(l=null===(i=t.logger)||void 0===i?void 0:i.debug)||void 0===l||l.call(i,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(p);else if("ping"===g)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===g){var h=null==p?void 0:p.data;(f="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=f,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(f)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;u=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:c.getEventTagProps,isElementSelectable:function(e){return!o||o((null==h?void 0:h.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:t,cssSelectorAllowlist:a,actionClickAllowlist:s,extractDataFromDataSource:c.extractDataFromDataSource,dataExtractor:c,diagnostics:{autocapture:{version:di}}}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===g&&(null===(d=null==u?void 0:u.close)||void 0===d||d.call(u))}})),this.notify({action:"page-loaded"})},e}();var Di,Li=function(){return new rr((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()}}))},Ni=function(e){return void 0===e&&(e="click"),new rr((function(t){var n,r=function(e){t.next(e)};return null===(n=Ke())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=Ke())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}}))},Ui={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},ji=function(e){var t,n,r,i,o=Object.values(Ui).reduce((function(e,t){return e[t]=new Set,e}),{});if(!e)return o;try{for(var a=ge(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{try{for(var u=(r=void 0,ge(c.definition)),l=u.next();!l.done;l=u.next()){var d=l.value,f=Ui[d.event_type];f&&o[f].add(c.id)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},Mi=function(e){var t,n,r,i,o=new Map;try{for(var a=ge(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{for(var u=(r=void 0,ge(c.conditions)),l=u.next();!l.done;l=u.next()){var d=l.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,p=o.get(f);p||(p=[],o.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},qi=function(e,t){return t.filter((function(t){return t.definition.some((function(t){return Ui[t.event_type]===e.type&&t.filters.every((function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)}))}))}))},Fi=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=function(e,t){var n,r,i,o,a=new Set;try{for(var s=ge(e),c=s.next();!c.done;c=s.next()){var u=c.value,l=t.get(u.id);if(l)try{for(var d=(i=void 0,ge(l)),f=d.next();!f.done;f=d.next()){var p=f.value;a.add(p)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(a)}(qi(e,Array.from(this.groupedLabeledEvents[e.type]).map((function(e){return r.labeledEvents[e]}))),this.labeledEventToTriggerMap);try{for(var o=ge(i),a=o.next();!a.done;a=o.next()){var s=a.value;Ri(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}();!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable"}(Di||(Di={}));var Bi=function(e,t){var n,r,i,o,a,s,c,u;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",di);var l=e.dataAttributePrefix,d=void 0===l?on:l,f=e.visualTaggingOptions,p=void 0===f?{enabled:!0,messenger:new Ci}:f;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:rn,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:an,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0,e.pageUrlExcludelist=null===(o=e.pageUrlExcludelist)||void 0===o?void 0:o.reduce((function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e}),[]);var g="@amplitude/plugin-autocapture-browser",h=[],v=new xi(e,t),m=ji(Object.values(null!==(s=null===(a=e.pageActions)||void 0===a?void 0:a.labeledEvents)&&void 0!==s?s:{})),y=Mi(null!==(u=null===(c=e.pageActions)||void 0===c?void 0:c.triggers)&&void 0!==u?u:[]),b=function(e,t,n,r){return new Fi(e,t,n,r)}(m,y,v,e);return{name:g,type:"enrichment",setup:function(t,n){return fe(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,f,T;return pe(this,(function(w){return"undefined"==typeof document||(t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("analyticsSDK.pageActions","all",(function(t){!function(t){var n,r;t&&(e.pageActions=le(le({},e.pageActions),t),m=ji(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),y=Mi(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),b.update(m,y,e))}(t)})):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),r=wi(e,e.cssSelectorAllowlist),i=wi(e,e.actionClickAllowlist),o=function(){var t,n,r=ar(Ni().map((function(t){return v.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,d)}))),i=ar(new rr((function(t){var n,r=function(n){var r=v.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,d);t.next(r)};return null===(n=Ke())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=Ke())||void 0===e?void 0:e.document.removeEventListener("change",r)}})));window.navigation&&(n=ar(new rr((function(t){var n=function(n){var r=v.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,d);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}))));var o=ar(Li().map((function(t){return v.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,d)})));return(t={})[Di.ChangeObservable]=i,t[Di.ClickObservable]=r,t[Di.MutationObservable]=o,t[Di.NavigateObservable]=n,t}(),a=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(Ei).filter((function(e){return r("click",e.closestTrackedAncestor)})).map((function(e){return i(e)})).subscribe((function(e){null==t||t.track(fi,e.targetElementProperties)}))}({allObservables:o,amplitude:n,shouldTrackEvent:r,evaluateTriggers:b.evaluate.bind(b)}),h.push(a),s=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(Ei).filter((function(e){return i("change",e.closestTrackedAncestor)})).map((function(e){return o(e)})).subscribe((function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))}))}({allObservables:o,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.getEventProperties.apply(v,ve(ve([],he(e),!1),[d],!1))},amplitude:n,shouldTrackEvent:r,evaluateTriggers:b.evaluate.bind(b)}),h.push(s),c=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,a=e.shouldTrackActionClick,s=n.clickObservable,c=n.mutationObservable,u=n.navigateObservable,l=s.filter((function(e){return!o("click",e.closestTrackedAncestor)})).map((function(e){var t=Si(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e})).filter(Ei).filter((function(e){return a("click",e.closestTrackedAncestor)})),d=u?or(c,u):c,f=or(l,d),p=null,g=null;return ir(f,(function(e){if(p&&(clearTimeout(p),p=null),"click"===e.type)return g=e,p=setTimeout((function(){p=null,g=null}),500),Promise.resolve(null);if(g){var t=g;return g=null,Promise.resolve(t)}return Promise.resolve(null)})).subscribe((function(e){e&&(null==t||t.track(fi,i("click",e.closestTrackedAncestor)))}))}({allObservables:o,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.getEventProperties.apply(v,ve(ve([],he(e),!1),[d],!1))},amplitude:n,shouldTrackEvent:r,shouldTrackActionClick:i}),c&&h.push(c),null===(f=null==t?void 0:t.loggerProvider)||void 0===f||f.log("".concat(g," has been successfully added.")),window.opener&&p.enabled&&(u=e.cssSelectorAllowlist,l=e.actionClickAllowlist,null===(T=p.messenger)||void 0===T||T.setup(le(le({dataExtractor:v,logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:mi[t.serverZone]}),{isElementSelectable:wi(e,ve(ve([],he(u),!1),he(l),!1)),cssSelectorAllowlist:u,actionClickAllowlist:l})))),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){var e,t,n,r;return pe(this,(function(i){try{for(e=ge(h),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},$i=["mutation","navigate"];function Ki(e,t){var n,r,i,o,a=t.event,s=a.clientX,c=a.clientY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:c,c),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:c,c),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:s,s),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:s,s),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Hi(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:le({"[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.clientX,Y:e.event.clientY,Time:e.timestamp}})),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function zi(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,a=[],s={},c=null;return ir(o.filter((function(e){return i("click",e.closestTrackedAncestor)})),(function(e){return fe(t,void 0,void 0,(function(){var t;return pe(this,(function(n){return Ki(s,e),t=null,0===a.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(a,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(a,e)||s.isOutOfBounds?(c&&(t=Hi(a)),function(e){a=[],s={},e&&(Ki(s,e),a.push(e))}(e)):a.push(e),c&&(clearTimeout(c.timerId),c.resolve(t),c=null),a.length>=4?[2,new Promise((function(e){c={resolve:e,timerId:setTimeout((function(){e(Hi(a))}),1e3)}}))]:[2,null]}))}))})).subscribe((function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})}))}var Vi,Gi,Ji=function(e){var t,n,r,i,o;void 0===e&&(e={});var a="@amplitude/plugin-frustration-browser",s=[],c=null!==(n=null===(t=e.rageClicks)||void 0===t?void 0:t.cssSelectorAllowlist)&&void 0!==n?n:cn,u=null!==(i=null===(r=e.deadClicks)||void 0===r?void 0:r.cssSelectorAllowlist)&&void 0!==i?i:sn,l=null!==(o=e.dataAttributePrefix)&&void 0!==o?o:on,d=new xi(e),f=ve([],he(new Set(ve(ve([],he(c),!1),he(u),!1))),!1);return{name:a,type:"enrichment",setup:function(t,n){return fe(void 0,void 0,void 0,(function(){var r,i,o,p,g,h;return pe(this,(function(v){return"undefined"==typeof document||(r=wi(e,c),i=wi(e,u),o=function(){var e,t,n=ar(Ni("pointerdown").map((function(e){return d.addAdditionalEventProperties(e,"click",f,l,!0)}))),r=ar(Li().map((function(e){return d.addAdditionalEventProperties(e,"mutation",f,l)})));return window.navigation&&(t=ar(new rr((function(e){var t=function(t){e.next(le(le({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}})).map((function(e){return d.addAdditionalEventProperties(e,"navigate",f,l)})))),(e={})[Di.ClickObservable]=n,e[Di.MutationObservable]=r,e[Di.NavigateObservable]=t,e}(),p=zi({allObservables:o,amplitude:n,shouldTrackRageClick:r}),s.push(p),g=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,o=n.clickObservable,a=n.mutationObservable,s=n.navigateObservable,c=o.filter((function(e){return Ei(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')})),u=s?or(a,s):a,l=or(c,u),d=null;return ir(l,(function(e){return d&&$i.includes(e.type)?(clearTimeout(d),d=null,Promise.resolve(null)):"click"===e.type?d?Promise.resolve(null):new Promise((function(t){d=setTimeout((function(){t(e),d=null}),3e3)})):Promise.resolve(null)})).subscribe((function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",le(le({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}}))}({amplitude:n,allObservables:o,getEventProperties:function(e,t){return d.getEventProperties(e,t,l)},shouldTrackDeadClick:i}),s.push(g),null===(h=null==t?void 0:t.loggerProvider)||void 0===h||h.log("".concat(a," has been successfully added."))),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){var e,t,n,r;return pe(this,(function(i){try{for(e=ge(s),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Wi="[Amplitude] Network Request",Yi="500-599";function Qi(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function Xi(e,t){var n,r,i=t.split(",");try{for(var o=ge(i),a=o.next();!a.done;a=o.next()){var s=he(a.value.split("-").map(Number),2),c=s[0],u=s[1];if(e===c&&void 0===u)return!0;if(e>=c&&e<=u)return!0}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function Zi(e){var t;if(e)try{var n=null===(t=Ke())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),a=r.href,s=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:r.href,host:s}}catch(e){return}}function eo(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return ve([],he(Le),!1);if(void 0===e){return}}}function to(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function no(e,t){var n;void 0===t&&(t={});var r=Zi(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(Qi(o,"*.amplitude.com")||Qi(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find((function(e){return Qi(o,e)})))return!1;if(!t.captureRules&&void 0!==e.status&&!Xi(e.status,Yi))return!1;if(t.captureRules&&(ve([],he(t.captureRules),!1).reverse().find((function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find((function(e){return Qi(t,e)})))&&(!r||!e.urls||xt(r,e.urls))&&(!i||!e.methods||e.methods.find((function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e}))))return!((n||0===n)&&!Xi(n,e.statusCodeRange||Yi))}(t,o,e.status,e.url,e.method),i){var n=eo(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var a=eo(t.requestHeaders);if(e.requestWrapper&&a){var s=e.requestWrapper.headers(a);s&&(e.requestHeaders=s)}e.responseWrapper&&t.responseBody&&!to(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!to(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i})),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find((function(e){return e.event_type===Wi})))return!0}catch(e){}return!1}(o,e.requestWrapper)}function ro(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter((function(e){return no(e.event,n)})).subscribe((function(e){var t,n,o,a=e.event,s=Zi(a.url);if(s){var c=null===(n=a.responseWrapper)||void 0===n?void 0:n.bodySize,u=null===(o=a.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){fe(this,void 0,void 0,(function(){var i,o,a;return pe(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=he.apply(void 0,[s.sent(),2]),o=i[0],a=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(a)try{e["[Amplitude] Response Body"]=JSON.stringify(a)}catch(e){null==r||r.debug("Failed to stringify response body")}s.label=2;case 2:return null==n||n.track(Wi,e),[2]}}))}))}(((t={})["[Amplitude] URL"]=s.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=s.query,t["[Amplitude] URL Fragment"]=s.fragment,t["[Amplitude] Request Method"]=a.method,t["[Amplitude] Status Code"]=a.status,t["[Amplitude] Start Time"]=a.startTime,t["[Amplitude] Completion Time"]=a.endTime,t["[Amplitude] Duration"]=a.duration,t["[Amplitude] Request Body Size"]=u,t["[Amplitude] Response Body Size"]=c,t["[Amplitude] Request Type"]=a.type,t["[Amplitude] Request Headers"]=a.requestHeaders,t["[Amplitude] Response Headers"]=a.responseHeaders,t),a,r,i)}}))}!function(e){e.NetworkObservable="networkObservable"}(Vi||(Vi={}));var io=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new rr((function(e){var n=new _n((function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)}));return Pn.subscribe(n,t),function(){Pn.unsubscribe(n)}}));return(e={})[Vi.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return fe(void 0,void 0,void 0,(function(){var a;return pe(this,(function(s){return"undefined"==typeof document||(a=r(),t=null==i?void 0:i.loggerProvider,Gi=ro({allObservables:a,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(e){return Gi.unsubscribe(),[2]}))}))}}};let oo=-1;const ao=e=>{addEventListener("pageshow",(t=>{t.persisted&&(oo=t.timeStamp,e(t))}),!0)},so=(e,t,n,r)=>{let i,o;return a=>{t.value>=0&&(a||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},co=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},uo=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},lo=()=>{const e=uo();return e?.activationStart??0},fo=(e,t=-1)=>{const n=uo();let r="navigate";return oo>=0?r="back-forward-cache":n&&(document.prerendering||lo()>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())+1e12}`,navigationType:r}},po=new WeakMap;function go(e,t){return po.get(e)||po.set(e,new t),po.get(e)}class ho{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const 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)}}const vo=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe({type:e,buffered:!0,...n}),r}}catch{}},mo=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let yo=-1;const bo=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,To=e=>{"hidden"===document.visibilityState&&yo>-1&&(yo="visibilitychange"===e.type?e.timeStamp:0,ko())},wo=()=>{addEventListener("visibilitychange",To,!0),addEventListener("prerenderingchange",To,!0)},ko=()=>{removeEventListener("visibilitychange",To,!0),removeEventListener("prerenderingchange",To,!0)},So=()=>{if(yo<0){const e=lo(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>"hidden"===t.name&&t.startTime>e))[0]?.startTime;yo=t??bo(),wo(),ao((()=>{setTimeout((()=>{yo=bo(),wo()}))}))}return{get firstHiddenTime(){return yo}}},Eo=e=>{document.prerendering?addEventListener("prerenderingchange",(()=>e()),!0):e()},_o=[1800,3e3],Io=(e,t={})=>{Eo((()=>{const n=So();let r,i=fo("FCP");const o=vo("paint",(e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-lo(),0),i.entries.push(t),r(!0)))}));o&&(r=so(e,i,_o,t.reportAllChanges),ao((n=>{i=fo("FCP"),r=so(e,i,_o,t.reportAllChanges),co((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},Po=[.1,.25];let Ao=0,Oo=1/0,Ro=0;const xo=e=>{for(const t of e)t.interactionId&&(Oo=Math.min(Oo,t.interactionId),Ro=Math.max(Ro,t.interactionId),Ao=Ro?(Ro-Oo)/7+1:0)};let Co;const Do=()=>Co?Ao:performance.interactionCount??0;let Lo=0;class No{u=[];l=new Map;m;p;v(){Lo=Do(),this.u.length=0,this.l.clear()}P(){const e=Math.min(this.u.length-1,Math.floor((Do()-Lo)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.T){if(n?e.duration>n.T?(n.entries=[e],n.T=e.duration):e.duration===n.T&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],T:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.T-e.T)),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const Uo=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(t(e=mo(e)),document.addEventListener("visibilitychange",e,{once:!0}))},jo=[200,500],Mo=(e,t={})=>{globalThis.PerformanceEventTiming&&"interactionId"in PerformanceEventTiming.prototype&&Eo((()=>{"interactionCount"in performance||Co||(Co=vo("event",xo,{type:"event",buffered:!0,durationThreshold:0}));let n,r=fo("INP");const i=go(t,No),o=e=>{Uo((()=>{for(const t of e)i.h(t);const t=i.P();t&&t.T!==r.value&&(r.value=t.T,r.entries=t.entries,n())}))},a=vo("event",o,{durationThreshold:t.durationThreshold??40});n=so(e,r,jo,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&(o(a.takeRecords()),n(!0))})),ao((()=>{i.v(),r=fo("INP"),n=so(e,r,jo,t.reportAllChanges)})))}))};class qo{m;h(e){this.m?.(e)}}const Fo=[2500,4e3],Bo=[800,1800],$o=e=>{document.prerendering?Eo((()=>$o(e))):"complete"!==document.readyState?addEventListener("load",(()=>$o(e)),!0):setTimeout(e)};function Ko(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function Ho(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(Ko(e)),navigationStart:Math.floor(performance.timeOrigin)}}var zo,Vo=function(){var e=null,t=Ke(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return fe(void 0,void 0,void 0,(function(){var o,a;return pe(this,(function(s){return void 0===n||(o=Ct((null==r?void 0:r.href)||"",t.loggerProvider),a={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":Ct((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":Ct(o.split("?")[0],t.loggerProvider)},((e,t={})=>{Eo((()=>{const n=So();let r,i=fo("LCP");const o=go(t,qo),a=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-lo(),0),i.entries=[t],r())},s=vo("largest-contentful-paint",a);if(s){r=so(e,i,Fo,t.reportAllChanges);const n=mo((()=>{a(s.takeRecords()),s.disconnect(),r(!0)}));for(const e of["keydown","click","visibilitychange"])addEventListener(e,(()=>Uo(n)),{capture:!0,once:!0});ao((n=>{i=fo("LCP"),r=so(e,i,Fo,t.reportAllChanges),co((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((function(e){a["[Amplitude] LCP"]=Ho(e)})),Io((function(e){a["[Amplitude] FCP"]=Ho(e)})),Mo((function(e){a["[Amplitude] INP"]=Ho(e)})),((e,t={})=>{Io(mo((()=>{let n,r=fo("CLS",0);const i=go(t,ho),o=e=>{for(const t of e)i.h(t);i.i>r.value&&(r.value=i.i,r.entries=i.o,n())},a=vo("layout-shift",o);a&&(n=so(e,r,Po,t.reportAllChanges),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&(o(a.takeRecords()),n(!0))})),ao((()=>{i.i=0,r=fo("CLS",0),n=so(e,r,Po,t.reportAllChanges),co((()=>n()))})),setTimeout(n))})))})((function(e){a["[Amplitude] CLS"]=Ho(e)})),((e,t={})=>{let n=fo("TTFB"),r=so(e,n,Bo,t.reportAllChanges);$o((()=>{const i=uo();i&&(n.value=Math.max(i.responseStart-lo(),0),n.entries=[i],r(!0),ao((()=>{n=fo("TTFB",0),r=so(e,n,Bo,t.reportAllChanges),r(!0)})))}))})((function(e){a["[Amplitude] TTFB"]=Ho(e)})),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return[2,e]}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]}))}))}}},Go=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},Jo=function(e,t,n,r,i){void 0===i&&(i=!0),e.referrer;var o=e.referring_domain,a=de(e,["referrer","referring_domain"]),s=t||{};s.referrer;var c=s.referring_domain,u=de(s,["referrer","referring_domain"]);if(Wo(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var l=JSON.stringify(a)!==JSON.stringify(u),d=Go(o||"")!==Go(c||""),f=!t||l||d;return f?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."),f},Wo=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))},Yo=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=le({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=null===(n=t.cookieOptions)||void 0===n?void 0:n.domain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[])},e),this.storage=t.cookieStorage,this.storageKey=Mt(t.apiKey,"MKTG"),this.webExpStorageKey=Mt(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=De,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return fe(this,void 0,void 0,(function(){var e,t;return pe(this,(function(n){switch(n.label){case 0:return[4,this.fetchCampaign()];case 1:return t=he.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||It(this.sessionTimeout,this.lastEventTime),Jo(this.currentCampaign,this.previousCampaign,this.options,this.logger,e)?(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 fe(this,void 0,void 0,(function(){var e;return pe(this,(function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new An).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}}))}))},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,o=(t=this.currentCampaign,n=this.options,r=le(le({},De),t),i=Object.entries(r).reduce((function(e,t){var r,i=he(t,2),o=i[0],a=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=a?a:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),a?e.set(o,a):e.unset(o)}),new Me),Ge(i));return e&&(o.event_id=e),o},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),Qo="AMP_CURRENT_PAGE",Xo="AMP_PREVIOUS_PAGE",Zo="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(zo||(zo={}));var ea=new Set([ue.IDENTIFY,ue.GROUP_IDENTIFY,ue.REVENUE]),ta=function(e){var t={}.internalDomains,n=void 0===t?[]:t,r=Ke(),i=void 0,o=!1,a=void 0,s=!1,c=!1,u=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=Ct(e,a);t=new URL(n).hostname}catch(e){null==a||a.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return zo.Direct;var i=n.some((function(e){return-1!==t.indexOf(e)})),o=n.some((function(e){return-1!==r.indexOf(e)}));return t===r||o&&i?zo.Internal:zo.External},l=function(){fe(void 0,void 0,void 0,(function(){var e,t,n,r,a;return pe(this,(function(s){switch(s.label){case 0:return i&&o?[4,i.get(Zo)]:[3,3];case 1:return e=s.sent(),t=Ct("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[Qo])||"",r=void 0,r=t===n?(null==e?void 0:e[Xo])||"":n||document.referrer||"",[4,i.set(Zo,(a={},a[Qo]=t,a[Xo]=r,a))];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},d={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(t){switch(t.label){case 0:return(a=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),c=!0,r?[4,(i=new qt(r.sessionStorage)).isEnabled()]:[3,2];case 1:o=t.sent(),r.addEventListener("popstate",l),s||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=he(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=he(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),s=!0),t.label=2;case 2:return[2]}}))}))},execute:function(e){return fe(void 0,void 0,void 0,(function(){var t,n,r,a,s;return pe(this,(function(c){switch(c.label){case 0:return t=Ct("undefined"!=typeof location&&location.href||""),i&&o?[4,i.get(Zo)]:[3,5];case 1:return(null==(n=c.sent())?void 0:n[Qo])?[3,3]:[4,i.set(Zo,(s={},s[Qo]=t,s[Xo]=document.referrer||"",s))];case 2:c.sent(),c.label=3;case 3:return[4,i.get(Zo)];case 4:if(r=c.sent(),a="",r&&(a=r[Xo]||""),ea.has(e.event_type))return[2,e];e.event_properties=le(le({},e.event_properties||{}),{"[Amplitude] Page Domain":na(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":na(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":na(e,"[Amplitude] Page Path","undefined"!=typeof location&&Ct(location.pathname)||""),"[Amplitude] Page Title":na(e,"[Amplitude] Page Title",Nn(Ln)),"[Amplitude] Page URL":na(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":a,"[Amplitude] Previous Page Type":u(a)}),c.label=5;case 5:return[2,e]}}))}))},teardown:function(){return fe(void 0,void 0,void 0,(function(){return pe(this,(function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",l),c=!1),i&&o?[4,i.set(Zo,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}};return d};function na(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var ra=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return se(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),Je(this._init(le(le({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o;return fe(this,void 0,void 0,(function(){var a,s,c,u,l,d,f,p,g,h=this;return pe(this,(function(v){switch(v.label){case 0:return this.initializing?[2]:(this.initializing=!0,[4,Gr(t.apiKey,t,this)]);case 1:return a=v.sent(),a.remoteConfig&&a.remoteConfig.fetchRemoteConfig?(s=new nn(a.apiKey,a.loggerProvider,a.serverZone,null===(n=a.remoteConfig)||void 0===n?void 0:n.serverUrl),[4,new Promise((function(e){null==s||s.subscribe("configs.analyticsSDK.browserSDK","all",(function(t,n,r){a.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&li(t,a),e()}))}))]):[3,4];case 2:return v.sent(),[4,new Promise((function(e){null==s||s.subscribe("configs.diagnostics.browserSDK","all",(function(t,n,r){if(a.loggerProvider.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(a.diagnosticsSampleRate=i);var o=t.enabled;"boolean"==typeof o&&(a.enableDiagnostics=o)}e()}))}))];case 3:v.sent(),v.label=4;case 4:return(c=new Xt(a.apiKey,a.loggerProvider,a.serverZone,{enabled:a.enableDiagnostics,sampleRate:a.diagnosticsSampleRate})).setTag("library","".concat(wr,"/").concat(Tr)),c.setTag("user_agent",navigator.userAgent),[4,e.prototype._init.call(this,a)];case 5:return v.sent(),this.logBrowserOptions(a),this.config.diagnosticsClient=c,this.config.remoteConfigClient=s,cr(this.config.defaultTracking)?(y=this.config,u=cr(y.defaultTracking)&&y.defaultTracking&&"object"==typeof y.defaultTracking&&y.defaultTracking.attribution&&"object"==typeof y.defaultTracking.attribution?le({},y.defaultTracking.attribution):{},this.webAttribution=new Yo(u,this.config),[4,this.webAttribution.init()]):[3,7];case 6:v.sent(),v.label=7;case 7:return l=Ot(),d=l.ampTimestamp?Number(l.ampTimestamp):void 0,f=!d||Date.now()<d,p=f&&!Number.isNaN(Number(l.ampSessionId))?Number(l.ampSessionId):void 0,this.setSessionId(null!==(o=null!==(i=null!==(r=t.sessionId)&&void 0!==r?r:p)&&void 0!==i?i:this.config.sessionId)&&void 0!==o?o:Date.now()),(g=Et(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,9]:[4,this.add(si()).promise];case 8:v.sent(),v.label=9;case 9:return[4,this.add(new ft({diagnosticsClient:c})).promise];case 10:return v.sent(),[4,this.add(new kr).promise];case 11:return v.sent(),[4,this.add(new _t).promise];case 12:return v.sent(),function(e){ai||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),ai=!0)}(this.config),m=this.config.defaultTracking,sr(m,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(oi()).promise]):[3,14];case 13:v.sent(),v.label=14;case 14:return function(e){return sr(e,"formInteractions")}(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(ni()).promise]):[3,16];case 15:v.sent(),v.label=16;case 16:return ur(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Xr(mr(this.config))).promise]):[3,18];case 17:v.sent(),v.label=18;case 18:return fr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Bi(gr(this.config),{diagnosticsClient:c})).promise]):[3,20];case 19:v.sent(),v.label=20;case 20:return pr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(Ji(hr(this.config))).promise]):[3,22];case 21:v.sent(),v.label=22;case 22:return dr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(io(vr(this.config))).promise]):[3,24];case 23:v.sent(),v.label=24;case 24:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(Vo()).promise]):[3,26];case 25:v.sent(),v.label=26;case 26:return function(e){return sr(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(ta()).promise]):[3,28];case 27:v.sent(),v.label=28;case 28:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 29:return v.sent(),g.eventBridge.setEventReceiver((function(e){var t=e.eventProperties||{},n=t.time,r=de(t,["time"]),i="number"==typeof n?{time:n}:void 0;h.track(e.eventType,r,i)})),[2]}var m,y}))}))},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){Et(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){Et(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(ze()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),Je(Promise.resolve());if(e===this.config.sessionId)return Je(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,lr(this.config.defaultTracking)&&(r&&i&&n.push(this.track(Ur,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var a=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Ge(this.config.identify)).promise),lr(this.config.defaultTracking)&&n.push(this.track(Nr,void 0,{event_id:a?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,Je(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Wr(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(br(t)){var r=t._q;t._q=[],t=yr(new Me,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,r,i){if(br(r)){var o=r._q;r._q=[],r=yr(new Me,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(br(t)){var r=t._q;t._q=[],t=yr(new Ye,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 fe(this,void 0,void 0,(function(){var n,r,i;return pe(this,(function(o){return n=Date.now(),r=It(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===Nr||t.event_type===Ur||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()),t.event_type===ue.IDENTIFY&&t.user_properties&&(this.userProperties=this.getOperationAppliedUserProperties(t.user_properties)),[2,e.prototype.process.call(this,t)]}))}))},t.prototype.logBrowserOptions=function(e){try{var t=le(le({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",JSON.stringify(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t}(We),ia=function(){var e=new ra;return{init:lt(e.init.bind(e),"init",st(e),ut(e,["config"])),add:lt(e.add.bind(e),"add",st(e),ut(e,["config.apiKey","timeline.plugins"])),remove:lt(e.remove.bind(e),"remove",st(e),ut(e,["config.apiKey","timeline.plugins"])),track:lt(e.track.bind(e),"track",st(e),ut(e,["config.apiKey","timeline.queue.length"])),logEvent:lt(e.logEvent.bind(e),"logEvent",st(e),ut(e,["config.apiKey","timeline.queue.length"])),identify:lt(e.identify.bind(e),"identify",st(e),ut(e,["config.apiKey","timeline.queue.length"])),groupIdentify:lt(e.groupIdentify.bind(e),"groupIdentify",st(e),ut(e,["config.apiKey","timeline.queue.length"])),setGroup:lt(e.setGroup.bind(e),"setGroup",st(e),ut(e,["config.apiKey","timeline.queue.length"])),revenue:lt(e.revenue.bind(e),"revenue",st(e),ut(e,["config.apiKey","timeline.queue.length"])),flush:lt(e.flush.bind(e),"flush",st(e),ut(e,["config.apiKey","timeline.queue.length"])),getUserId:lt(e.getUserId.bind(e),"getUserId",st(e),ut(e,["config","config.userId"])),setUserId:lt(e.setUserId.bind(e),"setUserId",st(e),ut(e,["config","config.userId"])),getDeviceId:lt(e.getDeviceId.bind(e),"getDeviceId",st(e),ut(e,["config","config.deviceId"])),setDeviceId:lt(e.setDeviceId.bind(e),"setDeviceId",st(e),ut(e,["config","config.deviceId"])),reset:lt(e.reset.bind(e),"reset",st(e),ut(e,["config","config.userId","config.deviceId"])),getSessionId:lt(e.getSessionId.bind(e),"getSessionId",st(e),ut(e,["config"])),setSessionId:lt(e.setSessionId.bind(e),"setSessionId",st(e),ut(e,["config"])),extendSession:lt(e.extendSession.bind(e),"extendSession",st(e),ut(e,["config"])),setOptOut:lt(e.setOptOut.bind(e),"setOptOut",st(e),ut(e,["config"])),setTransport:lt(e.setTransport.bind(e),"setTransport",st(e),ut(e,["config"])),getIdentity:lt(e.getIdentity.bind(e),"getIdentity",st(e),ut(e,["config"])),getOptOut:lt(e.getOptOut.bind(e),"getOptOut",st(e),ut(e,["config"])),_setDiagnosticsSampleRate:lt(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",st(e),ut(e,["config"]))}},oa=ia(),aa=Object.freeze({__proto__:null,DEFAULT_ACTION_CLICK_ALLOWLIST:an,DEFAULT_CSS_SELECTOR_ALLOWLIST:rn,DEFAULT_DATA_ATTRIBUTE_PREFIX:on,get IdentifyOperation(){return ce},get LogLevel(){return Qe},OfflineDisabled:null,get RevenueProperty(){return Be},get ServerZone(){return Tt},get SpecialEventType(){return ue}}),sa=oa.add,ca=oa.extendSession,ua=oa.flush,la=oa.getDeviceId,da=oa.getIdentity,fa=oa.getOptOut,pa=oa.getSessionId,ga=oa.getUserId,ha=oa.groupIdentify,va=oa.identify,ma=oa.init,ya=oa.logEvent,ba=oa.remove,Ta=oa.reset,wa=oa.revenue,ka=oa.setDeviceId,Sa=oa.setGroup,Ea=oa.setOptOut,_a=oa.setSessionId,Ia=oa.setTransport,Pa=oa.setUserId,Aa=oa.track,Oa=oa._setDiagnosticsSampleRate,Ra=Object.freeze({__proto__:null,AmplitudeBrowser:ra,Identify:Me,Revenue:Ye,Types:aa,_setDiagnosticsSampleRate:Oa,add:sa,createInstance:ia,extendSession:ca,flush:ua,getDeviceId:la,getIdentity:da,getOptOut:fa,getSessionId:pa,getUserId:ga,groupIdentify:ha,identify:va,init:ma,logEvent:ya,remove:ba,reset:Ta,revenue:wa,runQueuedFunctions:function(e,t){yr(e,t)},setDeviceId:ka,setGroup:Sa,setOptOut:Ea,setSessionId:_a,setTransport:Ia,setUserId:Pa,track:Aa});function xa(e,t){if(!k.getDebugMode())return;const n=["[Qonto Embed SDK]",e];console.log(...n)}class Ca{constructor(){this.isInitialized=!1}static getInstance(){return Ca.instance||(Ca.instance=new Ca),Ca.instance}initialize(){if(this.isInitialized||a())return;const e=y.getEnvironment()||"production",t=e===s.PRODUCTION?"52c120d2f5c89ca646fae6649a1ce7ad":"373aa80c38e5bc2a55895a96c8447fef";if(t)try{if(!Ra||"function"!=typeof ma)throw new Error("Analytics SDK module not available");const n={defaultTracking:{sessions:!1,pageViews:!1,formInteractions:!1,fileDownloads:!1},logLevel:e!==s.PRODUCTION?Qe.Debug:Qe.None};ma(t,void 0,n),this.isInitialized=!0,this.track(ie)}catch(e){console.error("Failed to initialize analytics tracking:",e)}else xa("No tracking client will be initialized due to missing API key")}isEnabled(){return this.isInitialized}track(e,t){if(this.isInitialized)try{Aa(e,t)}catch(e){console.error("Failed to track analytics event:",e)}}reset(){if(this.isInitialized)try{Ta()}catch(e){console.error("Failed to reset analytics:",e)}}}const Da=Ca.getInstance();function La(e,t){Da.track(e,t)}const Na=e=>{La(oe,e)};class Ua extends r{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}async function ja({proxyFunction:e,networkCallDescriptor:t,proxyEndpointDescriptor:n}){if(n){const e={...Object.fromEntries([...E(t.options?.headers)??{}])},r=I({...t,options:{...t.options,headers:e}}),i=await fetch(n.path,{method:n.method,headers:n.options.headers,body:r}),o=P(await i.text());if(!i.ok)throw new S({code:i.status,data:o,message:`Error from proxy endpoint: ${i.status} ${i.statusText}`});return o}if(e){const n=Object.fromEntries([...E(t.options?.headers)??{}]),r=I({...t,options:{...t.options,headers:n}});return P(await e(r))}throw new Ua("No proxy function or proxy endpoint descriptor provided for proxy call.")}var Ma;function qa(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(Ma||(Ma={}));const Fa={getCards:async function(e){Na();const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new x("membershipId must be a string");const{accessToken:n,stagingToken:r}=e?.operationSettings||{},i=n||o(),a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const r=function({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await _(r);return i}({membershipId:t,accessToken:i,stagingToken:r});return a.map((e=>qa(e)))},getCard:async function({cardSettings:e,operationSettings:t}){!function(e){if(!e)throw new x("cardSettings parameter is required for the called function");if(!e.cardId)throw new x("cardId parameter is required for the called function");const t=D({cardId:e.cardId});if(t.length>0)throw new x(t)}(e);const n=e.cardId,{accessToken:r,stagingToken:i}=t||{},a=r||o(),s=await async function({cardId:e,accessToken:t,stagingToken:n}){const r=function({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await _(r);return i[0]}({cardId:n,accessToken:a,stagingToken:i});return qa(s)}},Ba=e=>({id:e?.id,slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:parseFloat(e.balance),balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),$a={getOrganization:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||o(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await _(n)})({accessToken:r,stagingToken:n});return{id:(a=i.organization).id,slug:a.slug,legalName:a.legal_name,legalNumber:a.legal_number,legalSector:a.legal_sector,legalRegistrationDate:a.legal_registration_date,legalAddress:a.legal_address,legalForm:a.legal_form,legalCountry:a.legal_country,legalShareCapital:a.legal_share_capital,locale:a.locale,contractSignedAt:a.contract_signed_at,bankAccounts:a.bank_accounts.map(Ba)};var a},getBankAccounts:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||o(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/bank_accounts/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await _(n)})({accessToken:r,stagingToken:n});return i.bank_accounts.map(Ba)}},Ka={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},Ha=e=>{if(!(e=>Object.values(Ka).includes(e))(e))throw new x(`currency ${e} is not valid, valid currencies are ${Object.values(Ka).join(", ")}`)},za={GOOD:"good",SERVICE:"service"},Va={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Ga=e=>{if(!(e=>Object.values(Va).includes(e))(e))throw new x(`unit ${e} is not valid, valid units are ${Object.values(Va).join(", ")}`)},Ja=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],Wa=[{name:"currency"},{name:"value"}];const Ya=e=>{if(!Object.values(za).includes(e))throw new x(`type ${e} is not valid, valid types are ${Object.values(za).join(", ")}`)};const Qa={getPaymentLinkCreationFlowUrl:async({paymentLinkSettings:e,operationSettings:t})=>{const{items:n}=e;!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{C(e,Ja),C(e.unitPrice,Wa);const t=[...D({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...L({quantity:e.quantity})].flat();if(t.length>0)throw new x(t);Ya(e.type),Ha(e.unitPrice.currency),Ga(e.measureUnit)}))}(n);const r=function(e){if(!e?.callbackUrl)throw new x("callbackUrl parameter is required for the payment link creation flow");if("string"!=typeof e.callbackUrl)throw new x("callbackUrl must be a string");if(""===e.callbackUrl.trim())throw new x("callbackUrl cannot be empty");return e.callbackUrl}(e),i=await U({requestSettings:{action:f.PAYMENT_LINK_CREATE,callbackUrl:r},operationSettings:t}),o=new URLSearchParams({...n?{items:JSON.stringify(n)}:{}});return o.toString()?`${i.url}?${o.toString()}`:i.url}};function Xa(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function Za(e){return{name:e.name,iban:e.iban}}const es="/v2/sepa",ts=`${es}/transfers`;async function ns({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${ts}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:o}=await _(r);return{transfers:i,meta:o}}async function rs({accessToken:e,stagingToken:t,sepaTransferId:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${ts}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await _(r);return i}async function is({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}(e);return{path:ts,options:{method:"POST",headers:{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o},body:{transfer:a,vop_proof_token:t}}}}({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}),{transfer:s}=await _(a);return s}async function os({sepaTransferId:e,accessToken:t,stagingToken:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${ts}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:e,accessToken:t,stagingToken:n});await _(r)}async function as({sepaPayee:e,accessToken:t,stagingToken:n}){const r=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${es}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await _(r)}function ss(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function cs(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}const us="/v2/sepa/bulk_transfers";async function ls({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=M(e),o=i.size?`?${i.toString()}`:"";return{path:`${us}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{bulk_transfers:i,meta:o}=await _(r);return{bulkTransfers:i,meta:o}}async function ds({accessToken:e,stagingToken:t,bulkTransferId:n}){const r=function({bulkTransferId:e,accessToken:t,stagingToken:n}){return{path:`${us}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({bulkTransferId:n,accessToken:e,stagingToken:t}),{bulk_transfer:i}=await _(r);return i}async function fs({sepaPayees:e,accessToken:t,stagingToken:n}){const r=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${es}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Za)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await _(r)}function ps(e){if(!e)throw new x("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new x("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new x("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new x("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new x(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new x(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new x(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new x(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=D({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),r=L({amount:e.amount}),i=[...n,...r].flat();if(i.length>0)throw new x(i);if(e.amount>l&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new x(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const gs={requiresUI:!1};function hs(e,{requiresUI:t}=gs){const n=e?.uiParentElementId||k.getUIParentElementId();if(t){if(!n)throw new x("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");if(!["string","function"].includes(typeof n))throw new x("operationSettings.uiParentElementId must be a string or a function returning an HTMLElement")}const r=e?.mfaPreference||k.getMFAPreference();if(r){const e=(i=Object.values(u),y.isProductionEnvironment()?i.filter((e=>e!==u.MOCK)):i);if(!e.includes(r))throw new x(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(y.isProductionEnvironment()&&r===u.MOCK)throw new x("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const o=e?.debugMode||k.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new x("operationSettings.debugMode must be a boolean.");const a=e?.proxyRequestFunction||k.getProxyRequestFunction();if(a&&"function"!=typeof a)throw new x("operationSettings.proxyRequestFunction must be a function.");const s=e?.proxyEndpointDescriptor||k.getProxyEndpointDescriptor();if(s&&!s.path)throw new x("operationSettings.proxyEndpointDescriptor must have at least a string-formatted path property.");return{...e,uiParentElementId:n,mfaPreference:r,debugMode:o,proxyRequestFunction:a,proxyEndpointDescriptor:s}}async function vs({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:await async function({beneficiarySettings:e,operationSettings:t}){const n=ne(e?.beneficiaryId),{proxyRequestFunction:r,proxyEndpointDescriptor:i,accessToken:a,stagingToken:s}=hs(t||{});if(r||i){const e=Y({beneficiaryId:n});return V((await ja({proxyFunction:r,proxyEndpointDescriptor:i,networkCallDescriptor:e})).body.beneficiary)}{const e=a||o();return V(await Q({beneficiaryId:n,accessToken:e,stagingToken:s}))}}({beneficiarySettings:{beneficiaryId:e?.beneficiaryId},operationSettings:t})}function ms(e,t){const n=t?.locale||T.getLocale(),r=new URL(e);return n&&r.searchParams.append("lang",n),t?.mfaPreference&&r.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&r.searchParams.append("idempotencyKey",t.idempotencyKey),r.toString()}const ys=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];const bs={getSepaTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await ns({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.transfers.map(Xa),c=q(a.meta);return{transfers:s,...c?{meta:c}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new x("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return Xa(await rs({sepaTransferId:n,accessToken:a,stagingToken:i}))},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:a}=t||{},s=n||o(),c=a||z();!function(e){if(!e)throw new x("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new x("sepaTransferSettings must be an object");if(!e.beneficiaryId&&!e.beneficiary)throw new x("Either beneficiaryId or beneficiary must be provided");const t=D({beneficiaryId:e.beneficiaryId});if(t.length>0)throw new x(t)}(e);const u=e?.beneficiary?e.beneficiary:await vs({sepaTransferSettings:e,operationSettings:t}),f={name:u.name,iban:u.iban},p=await as({sepaPayee:f,accessToken:s,stagingToken:r}),g=yield(h=p,{matchResult:h.match_result,matchedName:h.matched_name});var h;let v;if("string"==typeof g){if(g===d)return}else{if(g.vopDecision===d)return;v=g.sepaTransferSettings}const m={...e,...v};!function(e){if(!e)throw new x("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new x("sepaTransferSettings must be an object");C(e,ys);const t=[...D({bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...L({amount:e.amount})].flat();if(t.length>0)throw new x(t);if(e.amount>l&&(!e.attachmentIds||0===e.attachmentIds.length))throw new x("Attachments are required for transfers over €30,000")}(m);const y={...m,beneficiary:u};return{transfer:Xa(await is({transfer:y,vopProofToken:p.proof_token.token,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c})),meta:{idempotencyKey:c}}},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new x("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();await os({sepaTransferId:n,accessToken:a,stagingToken:i})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new x("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new x("callbackUrl must be a string");return e.callbackUrl}(e),{accessToken:r,stagingToken:i}=t||{},a=r||o(),s=await async function({requestSettings:e,operationSettings:t}){N(e);const{proxyRequestFunction:n,proxyEndpointDescriptor:r,stagingToken:i}=hs(t||{});if(n||r){const t=A({stagingToken:i,action:e.action,callbackUrl:e.callbackUrl});return R((await ja({proxyFunction:n,proxyEndpointDescriptor:r,networkCallDescriptor:t})).body)}{const n=t?.accessToken||o();return R(await O({accessToken:n,stagingToken:i,action:e.action,callbackUrl:e.callbackUrl}))}}({requestSettings:{action:f.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:{stagingToken:i,accessToken:a}});return{...s,url:ms(s.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||o(),a=await ls({accessToken:i,stagingToken:n,paginationSettings:r}),s=a.bulkTransfers?.map(ss),c=q(a.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({bulkTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new x("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new x("bulkTransferId must be a string.");return e}(e?.bulkTransferId),{accessToken:r,stagingToken:i}=t||{},a=r||o();return ss(await ds({accessToken:a,stagingToken:i,bulkTransferId:n}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:a}=t||{},s=n||o(),c=a||z(),u=ps(e),l=new Map;for(const e of u.bulkTransfers){const t=e.beneficiary;if(t){const e=t.iban;e&&!l.has(e)&&l.set(e,{name:t.name,iban:e})}}const f=Array.from(l.values()),p=await fs({sepaPayees:f,accessToken:s,stagingToken:r});if((yield p.requests.map(cs))===d)return;const g=await async function({bulkTransfers:e,accessToken:t,stagingToken:n,scaSessionToken:r,bankAccountId:i,idempotencyKey:o}){const a={method:"POST",headers:{...E({accessToken:t,stagingToken:n,scaSessionToken:r,idempotencyKey:o})},body:JSON.stringify({bank_account_id:i,bulk_transfers:e.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))})},s=new URL(`${y.getEnvironmentUrls().THIRD_PARTY_API_URL}${us}`),c=await fetch(s,a),u=await c.json();if(!c.ok||u.errors)throw new S({message:u.errors?u.errors.map((e=>`${e.code}: ${e.detail}`)).join(", "):"Failed to create SEPA bulk transfer"});return u.bulk_transfer}({bulkTransfers:u.bulkTransfers,bankAccountId:u.bankAccountId,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c});return{bulkTransfer:ss(g),meta:{idempotencyKey:c}}}}},Ts="/v2/transactions";async function ws(e){const t=function({bankAccountId:e,iban:t,status:n,updatedAtFrom:r,updatedAtTo:i,emittedAtFrom:o,emittedAtTo:a,settledAtFrom:s,settledAtTo:c,side:u,operationType:l,withAttachments:d,paginationSettings:f,accessToken:p,stagingToken:g}){const h={method:"GET",headers:{accessToken:p,stagingToken:g}},v=new URLSearchParams;e&&v.append("bank_account_id",e),t&&v.append("iban",t),n&&v.append("status",n),r&&v.append("updated_at_from",r),i&&v.append("updated_at_to",i),o&&v.append("emitted_at_from",o),a&&v.append("emitted_at_to",a),s&&v.append("settled_at_from",s),c&&v.append("settled_at_to",c),u&&v.append("side",u),l&&v.append("operation_type",l),void 0!==d&&v.append("with_attachments",String(d));const m=M(f);for(const[e,t]of m)v.append(e,t);const y=v.toString();return{path:`${Ts}${y?`?${y}`:""}`,options:h}}(e),{transactions:n,meta:r}=await _(t);return{transactions:n,meta:r}}async function ks(e){const t=function({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${Ts}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}(e),{transaction:n}=await _(t);return n}function Ss(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const Es={getTransactions:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i={...e?.transactionSettings||{},paginationSettings:r},a=t||o(),s=await ws({...i,accessToken:a,stagingToken:n});return{transactions:s.transactions.map(Ss),meta:q(s.meta)}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r}=t||{},{transactionId:i}=function(e){if(!e)throw new x("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new x("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new x("transactionSettings.transactionId must be a string.");return e}(e),a=n||o();return Ss(await ks({transactionId:i,accessToken:a,stagingToken:r}))}};e.authLinks=j,e.beneficiaries=re,e.cards=Fa,e.organizations=$a,e.paymentLinks=Qa,e.sepaTransfers=bs,e.transactions=Es}));