@amplitude/plugin-autocapture-browser 1.24.2 → 1.25.0

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.
@@ -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).amplitude={})}(this,function(e){"use strict";var t=function(){return t=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},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function l(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,a)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=a(0),l.throw=a(1),l.return=a(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;l&&(l=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(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 o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.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 l}function l(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;var a=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},u=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},c=a(),s=null==c?void 0:c.console,d={},v={},f=!1;var p={addListener:function(e,t){var n,r=(n=e,!!s&&"function"==typeof s[n]&&(v[n]||(v[n]=s[n],s[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(d[n]&&!f){f=!0;var r=d[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return f=!1,v[n].apply(s,e)}),!0));if(!r)return new Error("Console override failed");d[e]?d[e].push(t):d[e]=[t]},removeListener:function(e){var t,n;try{for(var r=i(Object.values(d)),o=r.next();!o.done;o=r.next())for(var l=o.value,a=l.length-1;a>=0;a--)if(l[a]===e){l.splice(a,1);break}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=i(Object.entries(v)),r=n.next();!r.done;r=n.next()){var l=o(r.value,2),a=l[0],u=l[1];u&&(s[a]=u)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}v={},d={}}},h=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],g="data-amp-track-",m=["div","span","h1","h2","h3","h4","h5","h6"],b=l(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],o(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),y=b,w=b,E=["*"],x="data-amp-mask",T="*****",A=/\b(?:\d[ -]*?){13,16}\b/,k=/(\d{3}-?\d{2}-?\d{4})/g,O=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,S={};Object.defineProperty(S,"__esModule",{value:!0}),S.Observable=void 0;const C=e=>Boolean(Symbol[e]),P=e=>C(e)?Symbol[e]:"@@"+e,M=P("iterator"),_=P("observable"),L=P("species");function N(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function D(e){let t=e.constructor;return void 0!==t&&(t=t[L],null===t&&(t=void 0)),void 0!==t?t:Y}function I(e){I.log?I.log(e):setTimeout(()=>{throw e})}function R(e){Promise.resolve().then(()=>{try{e()}catch(e){I(e)}})}function H(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=N(t,"unsubscribe");e&&e.call(t)}}catch(e){I(e)}}function j(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function U(e,t,n){e._state="running";let r=e._observer;try{let i=N(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(j(e),!i)throw n;i.call(r,n);break;case"complete":j(e),i&&i.call(r)}}catch(e){I(e)}"closed"===e._state?H(e):"running"===e._state&&(e._state="ready")}function q(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 R(()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(U(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e))):void U(e,t,n);e._queue.push({type:t,value:n})}}class X{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){q(n,"next",e)},error(e){q(n,"error",e)},complete(){q(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(j(this),H(this))}}class Y{constructor(e){if(!(this instanceof Y))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new X(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(D(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(D(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=D(this),n=arguments.length>1,r=!1,i=arguments[1];return new t(t=>this.subscribe({next(o){let l=!r;if(r=!0,!l||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=D(this);return new t(n=>{let r,i=0;return function o(l){r=l.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=D(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let l=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(l);e>=0&&r.splice(e,1),o()}});r.push(l)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[_](){return this}static from(e){let t="function"==typeof this?this:Y;if(null==e)throw new TypeError(e+" is not an object");let n=N(e,_);if(n){let r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return function(e){return e instanceof Y}(r)&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(C("iterator")&&(n=N(e,M),n))return new t(t=>{R(()=>{if(!t.closed){for(let r of n.call(e))if(t.next(r),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{R(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:Y)(t=>{R(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})})}static get[L](){return this}}S.Observable=Y,Object.defineProperty(Y,Symbol("extensions"),{value:{symbol:_,hostReportError:I},configurable:!0});var G=S.Observable;function z(e,t){return new G(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 B(e,t){return new G(function(n){var r=!1,o=new Set,l=function(){var e,t;r=!0;try{for(var n=i(o),l=n.next();!l.done;l=n.next()){var a=l.value;try{a.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}o.clear()},a=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),l())},complete:function(){o.delete(t),r||0!==o.size||(n.complete(),l(),r=!0)}});o.add(t)};return a(e),a(t),l})}function F(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new G(function(o){return t.add(o),null===n&&(n=e.subscribe({next:function(e){var n,r,o;try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;null===(o=u.next)||void 0===o||o.call(u,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}},error:function(e){var n,o,l;try{for(var a=i(t),u=a.next();!u.done;u=a.next()){var c=u.value;null===(l=c.error)||void 0===l||l.call(c,e)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,o;try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;null===(o=u.complete)||void 0===o||o.call(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}r()}})),function(){t.delete(o),0===t.size&&n&&(n.unsubscribe(),n=null)}})}var V,W="https://app.amplitude.com",J={US:W,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var K="__AMPLITUDE_MESSENGER_INSTANCE__",Z="__AMPLITUDE_MESSENGER__",$=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?W:t;this[V]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;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,l){r.requestCallbacks[i]={resolve:t,reject:l},r.notify(o),n.timeout>0&&setTimeout(function(){l(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.registerActionHandler=function(e,t){var n,r,o,l;this.actionHandlers.has(e)&&(null===(l=null===(o=this.logger)||void 0===o?void 0:o.warn)||void 0===l||l.call(o,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var a=this.pendingMessages.get(e);if(a){this.pendingMessages.delete(e);try{for(var u=i(a),c=u.next();!c.done;c=u.next()){t(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise(function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",function(){t({status:!0})},{once:!0}),i.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(e)})}),null===(r=document.head)||void 0===r||r.appendChild(i)}catch(e){n(e)}})}(e).then(function(){}),this.scriptLoadPromises.set(e,n),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n];case 2:return r.sent(),[3,4];case 3:throw i=r.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,l=i.endpoint;o&&(this.logger=o),l&&this.endpoint===W&&(this.endpoint=l),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,l;if(null===(n=null===(t=r.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var a=e.data,u=null==a?void 0:a.action;if(u)if("id"in a&&a.id)null===(o=null===(i=r.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a);else{if("ping"===u)return void r.notify({action:"pong"});var c=r.actionHandlers.get(u);if(c)c(a.data);else{var s=null!==(l=r.pendingMessages.get(u))&&void 0!==l?l:[];s.push(a.data),r.pendingMessages.set(u,s)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=a();(null==e?void 0:e[Z])===this&&delete e[Z]},e}();function Q(e){var t,n=a(),r=null==n?void 0:n[Z];if("object"==typeof(t=r)&&null!==t&&K in t&&!0===t[K])return r;var i=new $(e);return n&&(n[Z]=i),i}V=K;var ee="__AMPLITUDE_BACKGROUND_CAPTURE__";var te,ne="1.24.2",re="[Amplitude] Element Clicked",ie="[Amplitude] Element Tag",oe="[Amplitude] Element Text",le="[Amplitude] Page URL",ae="[Amplitude] Viewport Height",ue="[Amplitude] Viewport Width",ce="[Amplitude] Page View ID",se="data-amp-mask-attributes",de=["input","select","textarea"],ve=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},fe=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&u(window.location.href,n))&&!!u(window.location.href,t)},pe=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,l,a=e.shouldTrackEventResolver,u=null===(l=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===l?void 0:l.call(o);if(!u)return!1;if(a)return a(r,i);if(!fe(e))return!1;var c=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}var s=ve(i,r);if(n&&s)return!0;if(t){var d=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(!d)return!1}switch(u){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!s||"click"===r}}},he=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},ge=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},{})},me=function(){var e;try{var t=a(),n=null===(e=null==t?void 0:t.sessionStorage)||void 0===e?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},be=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:be(null==e?void 0:e.parentElement,t):null},ye=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(te||(te={}));var we="__AMPLITUDE_VISUAL_TAGGING__";function Ee(e,t){var n=e;if(!0!==n[we]){n[we]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,l=t.actionClickAllowlist,a=null,u=function(t){e.notify({action:"element-selected",data:t})},c=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var n;a=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:c,onSelect:u,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:l,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:ne}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null===(e=null==a?void 0:a.close)||void 0===e||e.call(a)})}}var xe=a(),Te=function(){return new G(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()}})},Ae=function(e){return void 0===e&&(e="click"),new G(function(t){var n,r=function(e){t.next(e)};return null===(n=a())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=a())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}})},ke=function(){var e=B(new G(function(e){var n=function(n){if(n instanceof ErrorEvent){var r={kind:"error"};n.error instanceof Error||n.error instanceof DOMException?r=t(t({},r),{message:n.error.message,stack:n.error.stack,filename:n.filename,lineNumber:n.lineno,columnNumber:n.colno}):"string"==typeof n.error&&(r.message=n.error),e.next(r)}};return xe.addEventListener("error",n),function(){xe.removeEventListener("error",n)}}),new G(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return xe.addEventListener("unhandledrejection",t),function(){xe.removeEventListener("unhandledrejection",t)}}));return B(e,new G(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return p.addListener("error",t),function(){p.removeListener(t)}}))},Oe=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}})},Se={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Ce=function(e){var t,n,r,o,l=Object.values(Se).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return l;try{for(var a=i(e),u=a.next();!u.done;u=a.next()){var c=u.value;try{try{for(var s=(r=void 0,i(c.definition)),d=s.next();!d.done;d=s.next()){var v=d.value,f=Se[v.event_type];f&&l[f].add(c.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=s.return)&&o.call(s)}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{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return l},Pe=function(e){var t,n,r,o,l=new Map;try{for(var a=i(e),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var s=(r=void 0,i(c.conditions)),d=s.next();!d.done;d=s.next()){var v=d.value;if("LABELED_EVENT"===v.type){var f=v.match.eventId,p=l.get(f);p||(p=[],l.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return l},Me=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return Se[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)})})})},_e=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 o=function(e,t){var n,r,o,l,a=new Set;try{for(var u=i(e),c=u.next();!c.done;c=u.next()){var s=c.value,d=t.get(s.id);if(d)try{for(var v=(o=void 0,i(d)),f=v.next();!f.done;f=v.next()){var p=f.value;a.add(p)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(l=v.return)&&l.call(v)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return Array.from(a)}(Me(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var l=i(o),a=l.next();!a.done;a=l.next()){var u=a.value;Oe(u.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}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}(),Le=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",se,x]),Ne=["type"],De=["svg","path","g"],Ie=["password","hidden"];function Re(e,t){var n,r,o,l,a,u;if(null===e)return null;var c=String(e.tagName).toLowerCase(),s={tag:c},d=Array.from(null!==(l=null===(o=e.parentElement)||void 0===o?void 0:o.children)&&void 0!==l?l:[]);d.length&&(s.index=d.indexOf(e),s.indexOfType=d.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var v=null===(u=null===(a=e.previousElementSibling)||void 0===a?void 0:a.tagName)||void 0===u?void 0:u.toLowerCase();v&&(s.prevSib=String(v));var f=e.getAttribute("id");f&&(s.id=String(f));var p=Array.from(e.classList);p.length&&(s.classes=p);var h={},g=Array.from(e.attributes).filter(function(e){return!Le.has(e.name)}),m=!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!de.includes(i)&&!o}(e);if(!Ie.includes(String(e.getAttribute("type")))&&!De.includes(c))try{for(var b=i(g),y=b.next();!y.done;y=b.next()){var w=y.value;m&&!Ne.includes(w.name)||(t.has(w.name)?h[w.name]=T:h[w.name]=String(w.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=b.return)&&r.call(b)}finally{if(n)throw n.error}}return Object.keys(h).length&&(s.attrs=h),s}var He,je=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),Ue=function(e,t,n){var r,o;if(e.nodeType!==Node.ELEMENT_NODE)return null;var l=e.getAttribute("id");if(t){if(l)return new je(d(l),!0);var a=e.tagName.toLowerCase();if("body"===a||"head"===a||"html"===a)return new je(a,!0)}var u=e.tagName.toLowerCase();if(l)return new je(u+d(l),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new je(u,!0);function s(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]}function d(e){return"#"+CSS.escape(e)}for(var v=s(e),f=!1,p=!1,h=-1,g=-1,m=c.children,b=0;m&&(-1===h||!p)&&b<m.length;++b){var y=m[b];if(y.nodeType===Node.ELEMENT_NODE)if(g+=1,y!==e){if(!p&&y.tagName.toLowerCase()===u){f=!0;var w=new Set(v);if(w.size)for(var E=s(y),x=0;x<E.length;++x){var T=E[x];if(w.has(T)&&(w.delete(T),!w.size)){p=!0;break}}else p=!0}}else h=g}var A=u;if(n&&"input"===u.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(A+="[type="+CSS.escape(e.getAttribute("type")||"")+"]"),p)A+=":nth-child("+String(h+1)+")";else if(f)try{for(var k=i(v),O=k.next();!O.done;O=k.next()){var S=O.value;A+="."+CSS.escape(S.slice(1))}}catch(e){r={error:e}}finally{try{O&&!O.done&&(o=k.return)&&o.call(k)}finally{if(r)throw r.error}}return new je(A,!1)},qe=function(e,t){var n,r,a,u=this;this.replaceSensitiveString=function(e){return function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var o=e;o=(o=(o=o.replace(A,T)).replace(k,T)).replace(O,T);try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;try{o=o.replace(u,T)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return o}(e,u.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,a,c,s=performance.now();if(!e)return[];for(var d=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),v=new Map,f=d.length-1;f>=0;f--){var p=d[f];if(p){var h=he(p.getAttribute(se)),g=f===d.length-1?[]:null!==(r=v.get(d[f+1]))&&void 0!==r?r:new Set,m=new Set(l(l([],o(g),!1),o(h),!1));v.set(p,m)}}c=d.map(function(e){var t;return Re(e,null!==(t=v.get(e))&&void 0!==t?t:new Set)});var b=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=o(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=u.replaceSensitiveString(i))})};try{for(var y=i(c),w=y.next();!w.done;w=y.next())b(w.value)}catch(e){t={error:e}}finally{try{w&&!w.done&&(n=y.return)&&n.call(y)}finally{if(t)throw t.error}}var E=performance.now();return null===(a=u.diagnosticsClient)||void 0===a||a.recordHistogram("autocapturePlugin.getHierarchy",E-s),c},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?u.getText(t):u.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=Ue(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e),i=performance.now();return null===(t=u.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.getEventProperties=function(e,t,n){var r,i,l,a,c,s,d=null===(l=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===l?void 0:l.call(i),v="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=u.getHierarchy(t),p=null===(a=f[0])||void 0===a?void 0:a.attrs,h=u.getNearestLabel(t),g=(c=null!=p?p:{},s=n,Object.entries(c).reduce(function(e,t){var n=o(t,2),r=n[0],i=n[1];if(r.startsWith(s)){var l=r.replace(s,"");l&&(e[l]=i||"")}return e},{})),m=((r={})["[Amplitude] Element Hierarchy"]=f,r[ie]=d,r[oe]=u.getText(t),r["[Amplitude] Element Position Left"]=null==v.left?null:Math.round(v.left),r["[Amplitude] Element Position Top"]=null==v.top?null:Math.round(v.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Path"]=u.getElementPath(t),r["[Amplitude] Element Parent Label"]=h,r[le]=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n}(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(x)?T:e?e(document.title):document.title}(u.replaceSensitiveString),r[ae]=window.innerHeight,r[ue]=window.innerWidth,r),b=me();if(b&&(m[ce]=b),m["[Amplitude] Element ID"]=t.getAttribute("id")||"",m["[Amplitude] Element Class"]=t.getAttribute("class"),m["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===d&&"click"===e&&t instanceof HTMLAnchorElement){var y=t.href.substring(0,128);m["[Amplitude] Element Href"]=u.replaceSensitiveString(y)}return ge(m)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var o=u.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(o)&&null!==o.event.target){if(i&&ve(o.event.target,o.type))return o.closestTrackedAncestor=o.event.target,o.targetElementProperties=u.getEventProperties(o.type,o.closestTrackedAncestor,r),o;var l=be(o.event.target,n);return l&&(o.closestTrackedAncestor=l,o.targetElementProperties=u.getEventProperties(o.type,l,r)),o}return o},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?u.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(x,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var o="",l=Array.from(e.childNodes);try{for(var a=i(l),c=a.next();!c.done;c=a.next()){var s=c.value;s.nodeType!==Node.TEXT_NODE?s instanceof Element&&(s.hasAttribute(x)||s.hasAttribute("contenteditable")?o+=T:o+=u.getTextWithMaskedDescendants(s)):o+=s.textContent||""}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},this.getText=function(e){if(null!==e.closest("[".concat(x,"]")))return T;var t="";return t=e.querySelector("[".concat(x,"], [contenteditable]"))?u.getTextWithMaskedDescendants(e):e.innerText||"",u.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),o=((t={})[ie]=i,t[oe]=u.getText(e),t[le]=window.location.href.split("?")[0],t);return ge(o)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var c=null!==(a=e.maskTextRegex)&&void 0!==a?a:[],s=[];try{for(var d=i(c),v=d.next();!v.done;v=d.next()){var f=v.value;if(s.length>=25)break;if(f instanceof RegExp)s.push(f);else if("pattern"in f&&"string"==typeof f.pattern)try{s.push(new RegExp(f.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=s};!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(He||(He={}));var Xe=function(e,u){var c,s,d,v,f,p,b,y,w,E,x;void 0===e&&(e={}),null==u||u.diagnosticsClient.setTag("plugin.autocapture.version",ne);var T=e.dataAttributePrefix,A=void 0===T?g:T,k=e.visualTaggingOptions,O=void 0===k?{enabled:!0}:k;e.cssSelectorAllowlist=null!==(c=e.cssSelectorAllowlist)&&void 0!==c?c:h,e.actionClickAllowlist=null!==(s=e.actionClickAllowlist)&&void 0!==s?s:m,e.debounceTime=null!==(d=e.debounceTime)&&void 0!==d?d:0;var S=null!==(p=null!==(f=null===(v=e.viewportContentUpdated)||void 0===v?void 0:v.exposureDuration)&&void 0!==f?f:e.exposureDuration)&&void 0!==p?p:150;e.viewportContentUpdated=t(t({},e.viewportContentUpdated),{exposureDuration:S}),e.pageUrlExcludelist=null===(b=e.pageUrlExcludelist)||void 0===b?void 0:b.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 C,P="@amplitude/plugin-autocapture-browser",M=[],_=new qe(e,u),L=new Set,N=new Set,D=function(){var t,n,r=F(Ae().map(function(t){return _.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,A)})),i=F(new G(function(t){var n,r=function(n){var r=_.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,A);t.next(r)};return null===(n=a())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=a())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=F(new G(function(t){var n=function(n){var r=_.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,A);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=F(Te().map(function(t){return _.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,A)})),l=new G(function(e){var t,n=function(t){e.next(t)};return null===(t=a())||void 0===t||t.addEventListener("scroll",n),function(){var e;null===(e=a())||void 0===e||e.removeEventListener("scroll",n)}}),u=function(e,t){return new G(function(n){var r,i=a();if(!(null==i?void 0:i.IntersectionObserver))return function(){};var o=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:"0px",threshold:1}),l=t.join(",");(null!==(r=null==i?void 0:i.document.querySelectorAll(l))&&void 0!==r?r:[]).forEach(function(e){o.observe(e)});var u=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){e instanceof Element&&(e.matches(l)&&o.observe(e),e.querySelectorAll(l).forEach(function(e){o.observe(e)}))})})});return function(){u.unsubscribe(),o.disconnect()}})}(o,e.cssSelectorAllowlist);return(t={})[He.ChangeObservable]=i,t[He.ClickObservable]=r,t[He.MutationObservable]=o,t[He.NavigateObservable]=n,t[He.ScrollObservable]=l,t[He.ExposureObservable]=u,t},I=Ce(Object.values(null!==(w=null===(y=e.pageActions)||void 0===y?void 0:y.labeledEvents)&&void 0!==w?w:{})),R=Pe(null!==(x=null===(E=e.pageActions)||void 0===E?void 0:E.triggers)&&void 0!==x?x:[]),H=function(e,t,n,r){return new _e(e,t,n,r)}(I,R,_,e);return{name:P,type:"enrichment",setup:function(i,u){return n(void 0,void 0,void 0,function(){var n,c,s,d,v,f,p,h,g,m,b,y,w,E,x,T,k,j,U,q,X;return r(this,function(r){return"undefined"==typeof document||(n=!1,c={maxX:void 0,maxY:void 0},i.fetchRemoteConfig&&(i.remoteConfigClient?i.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(n){!function(n){var r,i;n&&(e.pageActions=t(t({},e.pageActions),n),I=Ce(Object.values(null!==(r=e.pageActions.labeledEvents)&&void 0!==r?r:{})),R=Pe(null!==(i=e.pageActions.triggers)&&void 0!==i?i:[]),H.update(I,R,e))}(n)}):i.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),s=pe(e,e.cssSelectorAllowlist),d=pe(e,e.actionClickAllowlist),v=D(),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(ye).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(re,e.targetElementProperties)})}({allObservables:v,amplitude:u,shouldTrackEvent:s,evaluateTriggers:H.evaluate.bind(H)}),M.push(f),p=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(ye).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:v,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _.getEventProperties.apply(_,l(l([],o(e),!1),[A],!1))},amplitude:u,shouldTrackEvent:s,evaluateTriggers:H.evaluate.bind(H)}),M.push(p),h=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,l=e.shouldTrackActionClick,a=n.clickObservable,u=n.mutationObservable,c=n.navigateObservable,s=a.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=be(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(ye).filter(function(e){return l("click",e.closestTrackedAncestor)}),d=c?B(u,c):u,v=B(s,d),f=null,p=null;return z(v,function(e){if(f&&(clearTimeout(f),f=null),"click"===e.type)return p=e,f=setTimeout(function(){f=null,p=null},500),Promise.resolve(null);if(p){var t=p;return p=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==t||t.track(re,i("click",e.closestTrackedAncestor)))})}({allObservables:v,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _.getEventProperties.apply(_,l(l([],o(e),!1),[A],!1))},amplitude:u,shouldTrackEvent:s,shouldTrackActionClick:d}),h&&M.push(h),g=function(e){e.amplitude;var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe(function(){var e,t,r,i,o=a(),l=Math.floor(null!==(t=null!==(e=null==o?void 0:o.scrollX)&&void 0!==e?e:null==o?void 0:o.pageXOffset)&&void 0!==t?t:0),u=Math.floor(null!==(i=null!==(r=null==o?void 0:o.scrollY)&&void 0!==r?r:null==o?void 0:o.pageYOffset)&&void 0!==i?i:0);n.maxX=Math.max(n.maxX,l),n.maxY=Math.max(n.maxY,u)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:v,amplitude:u}),M.push(g),m={},b=a(),y=function(e){e&&n||(setTimeout(function(){n=!1},100),n=!0,function(e){var t,n,r,i,o=e.amplitude,l=e.scrollTracker,u=e.currentElementExposed,c=e.elementExposedForPage,s=e.exposureTracker,d=e.isPageEnd,v=e.lastScroll,f=l.getState(),p=a(),h=null!==(n=null==p?void 0:p.innerWidth)&&void 0!==n?n:0,g=null!==(r=null==p?void 0:p.innerHeight)&&void 0!==r?r:0,m=((t={})[le]=null===(i=null==p?void 0:p.location)||void 0===i?void 0:i.href,t["[Amplitude] Max Page X"]=f.maxX+h,t["[Amplitude] Max Page Y"]=f.maxY+g,t[ae]=g,t[ue]=h,t["[Amplitude] Element Exposed"]=Array.from(u),t),b=me();b&&(m[ce]=b),0!==u.size||f.maxX!==v.maxX||f.maxY!==v.maxY?(null==o||o.track("[Amplitude] Viewport Content Updated",m),v.maxX=f.maxX,v.maxY=f.maxY,u.clear(),d&&(l.reset(),c.clear(),null==s||s.reset())):d&&(l.reset(),c.clear(),null==s||s.reset())}({amplitude:u,scrollTracker:g,currentElementExposed:N,elementExposedForPage:L,exposureTracker:m.exposure,isPageEnd:e,lastScroll:c}))},w=function(e){!function(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}(e,L,N,y)},m.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,l=new Map,a=new Map,u=t.exposureObservable.subscribe(function(e){var t=e,i=t.target;if(t.isIntersecting){if(!l.get(i)){var u=setTimeout(function(){l.set(i,!0);var e=r.getElementPath(i);n(e),a.set(i,null)},o);a.set(i,u)}}else!t.isIntersecting&&t.intersectionRatio<1&&(u=a.get(i))&&(clearTimeout(u),a.set(i,null))});return{unsubscribe:function(){u.unsubscribe()},reset:function(){a.forEach(function(e){e&&clearTimeout(e)}),a.clear(),l.clear()}}}({allObservables:v,onExposure:w,dataExtractor:_,exposureDuration:S}),m.exposure&&M.push(m.exposure),E=function(){y(!0)},null==b||b.addEventListener("beforeunload",E),C=function(){null==b||b.removeEventListener("beforeunload",E)},M.push({unsubscribe:function(){return C()}}),(x=v[He.NavigateObservable])?M.push(x.subscribe(function(){y(!0)})):b&&(T=function(){y(!0)},b.addEventListener("popstate",T),k=b.history.pushState,b.history&&k&&(b.history.pushState=new Proxy(k,{apply:function(e,t,n){var r=o(n,3),i=r[0],l=r[1],a=r[2];e.apply(t,[i,l,a]),y(!0)}})),M.push({unsubscribe:function(){b.removeEventListener("popstate",T),b.history&&k&&(b.history.pushState=k)}})),null===(X=null==i?void 0:i.loggerProvider)||void 0===X||X.log("".concat(P," has been successfully added.")),window.opener&&O.enabled&&(j=e.cssSelectorAllowlist,U=e.actionClickAllowlist,Ee(q=Q(),{dataExtractor:_,isElementSelectable:pe(e,l(l([],o(j),!1),o(U),!1)),cssSelectorAllowlist:j,actionClickAllowlist:U}),function(e,t){var n,r=e;if(!0!==r[ee]){r[ee]=!0;var i=null!==(n=null==t?void 0:t.scriptUrl)&&void 0!==n?n:"https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz",o=null,l=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){var t,n;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Initializing background capture (external script)");var r=new URL(i,e.endpoint).toString();e.loadScriptOnce(r).then(function(){var t,n,r;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),o=null===(r=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===r?void 0:r.call(window,{messenger:e,onBackgroundCapture:l}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null===(e=null==o?void 0:o.close)||void 0===e||e.call(o),o=null})}}(q),q.setup(t({logger:null==i?void 0:i.loggerProvider},(null==i?void 0:i.serverZone)&&{endpoint:J[i.serverZone]})))),[2]})})},execute:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return n(void 0,void 0,void 0,function(){var e,t,n,o;return r(this,function(r){try{for(e=i(M),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(n)throw n.error}}return[2]})})}}},Ye=["mutation","navigate"];function Ge(e,t){var n,r,i,o,l=t.event,a=l.pageX,u=l.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:u,u),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:u,u),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:a,a),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function ze(e){if(0===e.length)return null;var n=e[0],r=e[e.length-1];return{rageClickEvent:t({"[Amplitude] Begin Time":new Date(n.timestamp).toISOString(),"[Amplitude] End Time":new Date(r.timestamp).toISOString(),"[Amplitude] Duration":r.timestamp-n.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},n.targetElementProperties),time:n.timestamp}}function Be(e){var t=this,i=e.amplitude,o=e.allObservables,l=e.shouldTrackRageClick,a=o.clickObservable,u=o.selectionObservable,c=[],s={},d=null;function v(e){c=[],s={},e&&(Ge(s,e),c.push(e))}var f=z(a.filter(function(e){return l("click",e.closestTrackedAncestor)}),function(e){return n(t,void 0,void 0,function(){var t;return r(this,function(n){return Ge(s,e),t=null,0===c.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(c,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(c,e)||s.isOutOfBounds?(d&&(t=ze(c)),v(e)):c.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),c.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(ze(c))},1e3)}})]:[2,null]})})}),p=null==u?void 0:u.subscribe(function(){v()}),h=f.subscribe(function(e){null!==e&&i.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){h.unsubscribe(),null==p||p.unsubscribe()}}}var Fe,Ve;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}(Fe||(Fe={})),function(e){e.X="x",e.Y="y"}(Ve||(Ve={}));function We(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Je(e){e.changes=[],e.startTime=void 0}function Ke(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var Ze=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new G(function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},l=void 0,a=null;function u(){void 0!==l&&(e.next(l),l=void 0,null!==a&&clearTimeout(a),Je(n),Je(i))}return t.subscribe(function(e){null!==a&&clearTimeout(a),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Ve.X?n:i);var t=function(e,t){var n=void 0;if(We(e)&&(n=e.startTime),We(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(l=l||t,a=setTimeout(function(){u(),a=null},o)):u(),Ke(n),Ke(i),function(){null!==a&&(clearTimeout(a),a=null)}})})},$e=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,l=e.thresholdMs,a=void 0===l?2e3:l,u=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new G(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===Fe.DECREASING&&e.next(Ve.X),r=Fe.INCREASING):o.x<n.x&&(r===Fe.INCREASING&&e.next(Ve.X),r=Fe.DECREASING),o.y>n.y?(i===Fe.DECREASING&&e.next(Ve.Y),i=Fe.INCREASING):o.y<n.y&&(i===Fe.INCREASING&&e.next(Ve.Y),i=Fe.DECREASING),n=o):n=o})})}({allWindowObservables:r});return Ze({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:a}).subscribe(function(e){fe(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function Qe(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var et=4e3;e.DataExtractor=qe,e.autocapturePlugin=Xe,e.enableVisualTagging=Ee,e.frustrationPlugin=function(e){var a;void 0===e&&(e={});var u="@amplitude/plugin-frustration-browser",c=[],s=!1!==e.errorClicks;e.errorClicks||(s=!1);var d=!1!==e.deadClicks&&null!==e.deadClicks,v=!1!==e.rageClicks&&null!==e.rageClicks,f=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(f=!1);var p=Qe(e,"rageClicks",E,v),h=Qe(e,"deadClicks",y,d),m=Qe(e,"errorClicks",w,s),b=null!==(a=e.dataAttributePrefix)&&void 0!==a?a:g,x=new qe(e),T=l([],o(new Set(l(l(l([],o(p),!1),o(h),!1),o(m),!1))),!1),A=function(){var e,n,r=F(Ae("pointerdown").map(function(e){return x.addAdditionalEventProperties(e,"click",T,b,!0)})),i=F(ke().map(function(e){return x.addTypeAndTimestamp(e,"error")})),o=F(Te().map(function(e){return x.addAdditionalEventProperties(e,"mutation",T,b)}));window.navigation&&(n=F(new G(function(e){var n=function(n){e.next(t(t({},n),{type:"navigate"}))};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}).map(function(e){return x.addAdditionalEventProperties(e,"navigate",T,b)})));var l=F(new G(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}})),a=F(new G(function(e){var t=function(t){e.next(t)},n={capture:!0};return xe.document.addEventListener("mousemove",t,n),function(){xe.document.removeEventListener("mousemove",t,n)}}));return(e={})[He.ClickObservable]=r,e[He.MutationObservable]=o,e[He.NavigateObservable]=n,e[He.BrowserErrorObservable]=i,e[He.SelectionObservable]=l,e[He.MouseMoveObservable]=a,e};return{name:u,type:"enrichment",setup:function(i,o){return n(void 0,void 0,void 0,function(){var n,l,a,g,y,w,E,T,k,O,S;return r(this,function(r){return"undefined"==typeof document||(n=A(),v&&(l=pe(e,p),a=Be({allObservables:n,amplitude:o,shouldTrackRageClick:l}),c.push(a)),d&&(g=pe(e,h),y=function(e){var n=e.amplitude,r=e.allObservables,i=e.getEventProperties,o=e.shouldTrackDeadClick,l=r.clickObservable,a=r.mutationObservable,u=r.navigateObservable,c=l.filter(function(e){return ye(e)&&o("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===te.LEFT_OR_TOUCH_CONTACT}),s=u?B(a,u):a,d=B(c,s),v=null;return z(d,function(e){return v&&Ye.includes(e.type)?(clearTimeout(v),v=null,Promise.resolve(null)):"click"===e.type?v?Promise.resolve(null):new Promise(function(t){v=setTimeout(function(){t(e),v=null},3e3)}):Promise.resolve(null)}).subscribe(function(e){if(e){var r={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};n.track("[Amplitude] Dead Click",t(t({},i("click",e.closestTrackedAncestor)),r),{time:e.timestamp})}})}({amplitude:o,allObservables:n,getEventProperties:function(e,t){return x.getEventProperties(e,t,b)},shouldTrackDeadClick:g}),c.push(y)),s&&(w=pe(e,m),E=function(e){var n=e.amplitude,r=e.allObservables,i=e.shouldTrackErrorClick,o=r.clickObservable,l=r.browserErrorObservable,a=o.filter(function(e){return ye(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===te.LEFT_OR_TOUCH_CONTACT}),u=null,c=null,s=function(){null!==u&&(clearTimeout(u),u=null),c=null};return B(a,l).subscribe(function(e){var r;if("click"===e.type)return s(),c=e,void(u=setTimeout(s,2e3));"error"===e.type&&c&&(n.track("[Amplitude] Error Click",t(((r={})["[Amplitude] Kind"]=e.event.kind,r["[Amplitude] Message"]=e.event.message,r["[Amplitude] Stack"]=e.event.stack,r["[Amplitude] Filename"]=e.event.filename,r["[Amplitude] Line Number"]=e.event.lineNumber,r["[Amplitude] Column Number"]=e.event.columnNumber,r),c.targetElementProperties)),s())})}({amplitude:o,allObservables:n,shouldTrackErrorClick:w}),c.push(E)),f&&(T=void 0,k=void 0,"object"==typeof e.thrashedCursor&&(T=e.thrashedCursor.directionChanges,k=e.thrashedCursor.threshold,T&&T<5&&(i.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(T," is below the minimum of ").concat(5,", setting to ").concat(5)),T=5),k&&k>et&&(i.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(k," is above the maximum of ").concat(et,", setting to ").concat(et)),k=et)),O=$e({amplitude:o,options:e,allObservables:n,directionChanges:T,thresholdMs:k}),c.push(O)),null===(S=null==i?void 0:i.loggerProvider)||void 0===S||S.log("".concat(u," has been successfully added."))),[2]})})},execute:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return n(void 0,void 0,void 0,function(){var e,t,n,o;return r(this,function(r){try{for(e=i(c),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(n)throw n.error}}return[2]})})}}},e.plugin=Xe,Object.defineProperty(e,"__esModule",{value:!0})});
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).amplitude={})}(this,function(e){"use strict";var t=function(){return t=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},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function l(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,a)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=a(0),l.throw=a(1),l.return=a(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;l&&(l=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(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 o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.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 l}function l(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;var a=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},u=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},c=a(),s=null==c?void 0:c.console,d={},v={},f=!1;var p={addListener:function(e,t){var n,r=(n=e,!!s&&"function"==typeof s[n]&&(v[n]||(v[n]=s[n],s[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(d[n]&&!f){f=!0;var r=d[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return f=!1,v[n].apply(s,e)}),!0));if(!r)return new Error("Console override failed");d[e]?d[e].push(t):d[e]=[t]},removeListener:function(e){var t,n;try{for(var r=i(Object.values(d)),o=r.next();!o.done;o=r.next())for(var l=o.value,a=l.length-1;a>=0;a--)if(l[a]===e){l.splice(a,1);break}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=i(Object.entries(v)),r=n.next();!r.done;r=n.next()){var l=o(r.value,2),a=l[0],u=l[1];u&&(s[a]=u)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}v={},d={}}},h=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],g="data-amp-track-",m=["div","span","h1","h2","h3","h4","h5","h6"],b=l(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],o(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),y=b,w=b,E=["*"],x="data-amp-mask",T="*****",A=/\b(?:\d[ -]*?){13,16}\b/,k=/(\d{3}-?\d{2}-?\d{4})/g,O=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,S={};Object.defineProperty(S,"__esModule",{value:!0}),S.Observable=void 0;const C=e=>Boolean(Symbol[e]),P=e=>C(e)?Symbol[e]:"@@"+e,M=P("iterator"),_=P("observable"),L=P("species");function N(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function D(e){let t=e.constructor;return void 0!==t&&(t=t[L],null===t&&(t=void 0)),void 0!==t?t:Y}function I(e){I.log?I.log(e):setTimeout(()=>{throw e})}function R(e){Promise.resolve().then(()=>{try{e()}catch(e){I(e)}})}function H(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=N(t,"unsubscribe");e&&e.call(t)}}catch(e){I(e)}}function j(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function U(e,t,n){e._state="running";let r=e._observer;try{let i=N(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(j(e),!i)throw n;i.call(r,n);break;case"complete":j(e),i&&i.call(r)}}catch(e){I(e)}"closed"===e._state?H(e):"running"===e._state&&(e._state="ready")}function q(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 R(()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(U(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e))):void U(e,t,n);e._queue.push({type:t,value:n})}}class X{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){q(n,"next",e)},error(e){q(n,"error",e)},complete(){q(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(j(this),H(this))}}class Y{constructor(e){if(!(this instanceof Y))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new X(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(D(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(D(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=D(this),n=arguments.length>1,r=!1,i=arguments[1];return new t(t=>this.subscribe({next(o){let l=!r;if(r=!0,!l||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=D(this);return new t(n=>{let r,i=0;return function o(l){r=l.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=D(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let l=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(l);e>=0&&r.splice(e,1),o()}});r.push(l)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[_](){return this}static from(e){let t="function"==typeof this?this:Y;if(null==e)throw new TypeError(e+" is not an object");let n=N(e,_);if(n){let r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return function(e){return e instanceof Y}(r)&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(C("iterator")&&(n=N(e,M),n))return new t(t=>{R(()=>{if(!t.closed){for(let r of n.call(e))if(t.next(r),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{R(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:Y)(t=>{R(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})})}static get[L](){return this}}S.Observable=Y,Object.defineProperty(Y,Symbol("extensions"),{value:{symbol:_,hostReportError:I},configurable:!0});var G=S.Observable;function z(e,t){return new G(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 B(e,t){return new G(function(n){var r=!1,o=new Set,l=function(){var e,t;r=!0;try{for(var n=i(o),l=n.next();!l.done;l=n.next()){var a=l.value;try{a.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}o.clear()},a=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),l())},complete:function(){o.delete(t),r||0!==o.size||(n.complete(),l(),r=!0)}});o.add(t)};return a(e),a(t),l})}function F(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new G(function(o){return t.add(o),null===n&&(n=e.subscribe({next:function(e){var n,r,o;try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;null===(o=u.next)||void 0===o||o.call(u,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}},error:function(e){var n,o,l;try{for(var a=i(t),u=a.next();!u.done;u=a.next()){var c=u.value;null===(l=c.error)||void 0===l||l.call(c,e)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,o;try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;null===(o=u.complete)||void 0===o||o.call(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}r()}})),function(){t.delete(o),0===t.size&&n&&(n.unsubscribe(),n=null)}})}var V,W="https://app.amplitude.com",J={US:W,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var K="__AMPLITUDE_MESSENGER_INSTANCE__",Z="__AMPLITUDE_MESSENGER__",$=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?W:t;this[V]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;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,l){r.requestCallbacks[i]={resolve:t,reject:l},r.notify(o),n.timeout>0&&setTimeout(function(){l(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.registerActionHandler=function(e,t){var n,r,o,l;this.actionHandlers.has(e)&&(null===(l=null===(o=this.logger)||void 0===o?void 0:o.warn)||void 0===l||l.call(o,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var a=this.pendingMessages.get(e);if(a){this.pendingMessages.delete(e);try{for(var u=i(a),c=u.next();!c.done;c=u.next()){t(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise(function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",function(){t({status:!0})},{once:!0}),i.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(e)})}),null===(r=document.head)||void 0===r||r.appendChild(i)}catch(e){n(e)}})}(e).then(function(){}),this.scriptLoadPromises.set(e,n),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n];case 2:return r.sent(),[3,4];case 3:throw i=r.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,l=i.endpoint;o&&(this.logger=o),l&&this.endpoint===W&&(this.endpoint=l),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,l;if(null===(n=null===(t=r.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var a=e.data,u=null==a?void 0:a.action;if(u)if("id"in a&&a.id)null===(o=null===(i=r.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a);else{if("ping"===u)return void r.notify({action:"pong"});var c=r.actionHandlers.get(u);if(c)c(a.data);else{var s=null!==(l=r.pendingMessages.get(u))&&void 0!==l?l:[];s.push(a.data),r.pendingMessages.set(u,s)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=a();(null==e?void 0:e[Z])===this&&delete e[Z]},e}();function Q(e){var t,n=a(),r=null==n?void 0:n[Z];if("object"==typeof(t=r)&&null!==t&&K in t&&!0===t[K])return r;var i=new $(e);return n&&(n[Z]=i),i}V=K;var ee="__AMPLITUDE_BACKGROUND_CAPTURE__";var te,ne="1.25.0",re="[Amplitude] Element Clicked",ie="[Amplitude] Element Tag",oe="[Amplitude] Element Text",le="[Amplitude] Page URL",ae="[Amplitude] Viewport Height",ue="[Amplitude] Viewport Width",ce="[Amplitude] Page View ID",se="data-amp-mask-attributes",de=["input","select","textarea"],ve=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},fe=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&u(window.location.href,n))&&!!u(window.location.href,t)},pe=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,l,a=e.shouldTrackEventResolver,u=null===(l=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===l?void 0:l.call(o);if(!u)return!1;if(a)return a(r,i);if(!fe(e))return!1;var c=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}var s=ve(i,r);if(n&&s)return!0;if(t){var d=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(!d)return!1}switch(u){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!s||"click"===r}}},he=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},ge=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},{})},me=function(){var e;try{var t=a(),n=null===(e=null==t?void 0:t.sessionStorage)||void 0===e?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},be=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:be(null==e?void 0:e.parentElement,t):null},ye=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(te||(te={}));var we="__AMPLITUDE_VISUAL_TAGGING__";function Ee(e,t){var n=e;if(!0!==n[we]){n[we]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,l=t.actionClickAllowlist,a=null,u=function(t){e.notify({action:"element-selected",data:t})},c=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var n;a=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:c,onSelect:u,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:l,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:ne}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null===(e=null==a?void 0:a.close)||void 0===e||e.call(a)})}}var xe=a(),Te=function(){return new G(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()}})},Ae=function(e){return void 0===e&&(e="click"),new G(function(t){var n,r=function(e){t.next(e)};return null===(n=a())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=a())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}})},ke=function(){var e=B(new G(function(e){var n=function(n){if(n instanceof ErrorEvent){var r={kind:"error"};n.error instanceof Error||n.error instanceof DOMException?r=t(t({},r),{message:n.error.message,stack:n.error.stack,filename:n.filename,lineNumber:n.lineno,columnNumber:n.colno}):"string"==typeof n.error&&(r.message=n.error),e.next(r)}};return xe.addEventListener("error",n),function(){xe.removeEventListener("error",n)}}),new G(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return xe.addEventListener("unhandledrejection",t),function(){xe.removeEventListener("unhandledrejection",t)}}));return B(e,new G(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return p.addListener("error",t),function(){p.removeListener(t)}}))},Oe=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}})},Se={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Ce=function(e){var t,n,r,o,l=Object.values(Se).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return l;try{for(var a=i(e),u=a.next();!u.done;u=a.next()){var c=u.value;try{try{for(var s=(r=void 0,i(c.definition)),d=s.next();!d.done;d=s.next()){var v=d.value,f=Se[v.event_type];f&&l[f].add(c.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=s.return)&&o.call(s)}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{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return l},Pe=function(e){var t,n,r,o,l=new Map;try{for(var a=i(e),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var s=(r=void 0,i(c.conditions)),d=s.next();!d.done;d=s.next()){var v=d.value;if("LABELED_EVENT"===v.type){var f=v.match.eventId,p=l.get(f);p||(p=[],l.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return l},Me=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return Se[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)})})})},_e=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 o=function(e,t){var n,r,o,l,a=new Set;try{for(var u=i(e),c=u.next();!c.done;c=u.next()){var s=c.value,d=t.get(s.id);if(d)try{for(var v=(o=void 0,i(d)),f=v.next();!f.done;f=v.next()){var p=f.value;a.add(p)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(l=v.return)&&l.call(v)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return Array.from(a)}(Me(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var l=i(o),a=l.next();!a.done;a=l.next()){var u=a.value;Oe(u.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}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}(),Le=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",se,x]),Ne=["type"],De=["svg","path","g"],Ie=["password","hidden"];function Re(e,t){var n,r,o,l,a,u;if(null===e)return null;var c=String(e.tagName).toLowerCase(),s={tag:c},d=Array.from(null!==(l=null===(o=e.parentElement)||void 0===o?void 0:o.children)&&void 0!==l?l:[]);d.length&&(s.index=d.indexOf(e),s.indexOfType=d.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var v=null===(u=null===(a=e.previousElementSibling)||void 0===a?void 0:a.tagName)||void 0===u?void 0:u.toLowerCase();v&&(s.prevSib=String(v));var f=e.getAttribute("id");f&&(s.id=String(f));var p=Array.from(e.classList);p.length&&(s.classes=p);var h={},g=Array.from(e.attributes).filter(function(e){return!Le.has(e.name)}),m=!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!de.includes(i)&&!o}(e);if(!Ie.includes(String(e.getAttribute("type")))&&!De.includes(c))try{for(var b=i(g),y=b.next();!y.done;y=b.next()){var w=y.value;m&&!Ne.includes(w.name)||(t.has(w.name)?h[w.name]=T:h[w.name]=String(w.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=b.return)&&r.call(b)}finally{if(n)throw n.error}}return Object.keys(h).length&&(s.attrs=h),s}var He,je=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),Ue=function(e,t,n){var r,o;if(e.nodeType!==Node.ELEMENT_NODE)return null;var l=e.getAttribute("id");if(t){if(l)return new je(d(l),!0);var a=e.tagName.toLowerCase();if("body"===a||"head"===a||"html"===a)return new je(a,!0)}var u=e.tagName.toLowerCase();if(l)return new je(u+d(l),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new je(u,!0);function s(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]}function d(e){return"#"+CSS.escape(e)}for(var v=s(e),f=!1,p=!1,h=-1,g=-1,m=c.children,b=0;m&&(-1===h||!p)&&b<m.length;++b){var y=m[b];if(y.nodeType===Node.ELEMENT_NODE)if(g+=1,y!==e){if(!p&&y.tagName.toLowerCase()===u){f=!0;var w=new Set(v);if(w.size)for(var E=s(y),x=0;x<E.length;++x){var T=E[x];if(w.has(T)&&(w.delete(T),!w.size)){p=!0;break}}else p=!0}}else h=g}var A=u;if(n&&"input"===u.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(A+="[type="+CSS.escape(e.getAttribute("type")||"")+"]"),p)A+=":nth-child("+String(h+1)+")";else if(f)try{for(var k=i(v),O=k.next();!O.done;O=k.next()){var S=O.value;A+="."+CSS.escape(S.slice(1))}}catch(e){r={error:e}}finally{try{O&&!O.done&&(o=k.return)&&o.call(k)}finally{if(r)throw r.error}}return new je(A,!1)},qe=function(e,t){var n,r,a,u=this;this.replaceSensitiveString=function(e){return function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var o=e;o=(o=(o=o.replace(A,T)).replace(k,T)).replace(O,T);try{for(var l=i(t),a=l.next();!a.done;a=l.next()){var u=a.value;try{o=o.replace(u,T)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return o}(e,u.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,a,c,s=performance.now();if(!e)return[];for(var d=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),v=new Map,f=d.length-1;f>=0;f--){var p=d[f];if(p){var h=he(p.getAttribute(se)),g=f===d.length-1?[]:null!==(r=v.get(d[f+1]))&&void 0!==r?r:new Set,m=new Set(l(l([],o(g),!1),o(h),!1));v.set(p,m)}}c=d.map(function(e){var t;return Re(e,null!==(t=v.get(e))&&void 0!==t?t:new Set)});var b=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=o(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=u.replaceSensitiveString(i))})};try{for(var y=i(c),w=y.next();!w.done;w=y.next())b(w.value)}catch(e){t={error:e}}finally{try{w&&!w.done&&(n=y.return)&&n.call(y)}finally{if(t)throw t.error}}var E=performance.now();return null===(a=u.diagnosticsClient)||void 0===a||a.recordHistogram("autocapturePlugin.getHierarchy",E-s),c},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?u.getText(t):u.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=Ue(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e),i=performance.now();return null===(t=u.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.getEventProperties=function(e,t,n){var r,i,l,a,c,s,d=null===(l=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===l?void 0:l.call(i),v="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=u.getHierarchy(t),p=null===(a=f[0])||void 0===a?void 0:a.attrs,h=u.getNearestLabel(t),g=(c=null!=p?p:{},s=n,Object.entries(c).reduce(function(e,t){var n=o(t,2),r=n[0],i=n[1];if(r.startsWith(s)){var l=r.replace(s,"");l&&(e[l]=i||"")}return e},{})),m=((r={})["[Amplitude] Element Hierarchy"]=f,r[ie]=d,r[oe]=u.getText(t),r["[Amplitude] Element Position Left"]=null==v.left?null:Math.round(v.left),r["[Amplitude] Element Position Top"]=null==v.top?null:Math.round(v.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Path"]=u.getElementPath(t),r["[Amplitude] Element Parent Label"]=h,r[le]=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n}(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(x)?T:e?e(document.title):document.title}(u.replaceSensitiveString),r[ae]=window.innerHeight,r[ue]=window.innerWidth,r),b=me();if(b&&(m[ce]=b),m["[Amplitude] Element ID"]=t.getAttribute("id")||"",m["[Amplitude] Element Class"]=t.getAttribute("class"),m["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===d&&"click"===e&&t instanceof HTMLAnchorElement){var y=t.href.substring(0,128);m["[Amplitude] Element Href"]=u.replaceSensitiveString(y)}return ge(m)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var o=u.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(o)&&null!==o.event.target){if(i&&ve(o.event.target,o.type))return o.closestTrackedAncestor=o.event.target,o.targetElementProperties=u.getEventProperties(o.type,o.closestTrackedAncestor,r),o;var l=be(o.event.target,n);return l&&(o.closestTrackedAncestor=l,o.targetElementProperties=u.getEventProperties(o.type,l,r)),o}return o},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?u.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(x,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var o="",l=Array.from(e.childNodes);try{for(var a=i(l),c=a.next();!c.done;c=a.next()){var s=c.value;s.nodeType!==Node.TEXT_NODE?s instanceof Element&&(s.hasAttribute(x)||s.hasAttribute("contenteditable")?o+=T:o+=u.getTextWithMaskedDescendants(s)):o+=s.textContent||""}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},this.getText=function(e){if(null!==e.closest("[".concat(x,"]")))return T;var t="";return t=e.querySelector("[".concat(x,"], [contenteditable]"))?u.getTextWithMaskedDescendants(e):e.innerText||"",u.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),o=((t={})[ie]=i,t[oe]=u.getText(e),t[le]=window.location.href.split("?")[0],t);return ge(o)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var c=null!==(a=e.maskTextRegex)&&void 0!==a?a:[],s=[];try{for(var d=i(c),v=d.next();!v.done;v=d.next()){var f=v.value;if(s.length>=25)break;if(f instanceof RegExp)s.push(f);else if("pattern"in f&&"string"==typeof f.pattern)try{s.push(new RegExp(f.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=s};!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(He||(He={}));var Xe=function(e,u){var c,s,d,v,f,p,b,y,w,E,x,T;void 0===e&&(e={}),null==u||u.diagnosticsClient.setTag("plugin.autocapture.version",ne);var A=e.dataAttributePrefix,k=void 0===A?g:A,O=e.visualTaggingOptions,S=void 0===O?{enabled:!0}:O;e.cssSelectorAllowlist=null!==(c=e.cssSelectorAllowlist)&&void 0!==c?c:h,e.actionClickAllowlist=null!==(s=e.actionClickAllowlist)&&void 0!==s?s:m,e.debounceTime=null!==(d=e.debounceTime)&&void 0!==d?d:0;var C=!1!==(null===(v=e.viewportContentUpdated)||void 0===v?void 0:v.enabled),P=null!==(b=null!==(p=null===(f=e.viewportContentUpdated)||void 0===f?void 0:f.exposureDuration)&&void 0!==p?p:e.exposureDuration)&&void 0!==b?b:150;e.viewportContentUpdated=t(t({},e.viewportContentUpdated),{exposureDuration:P}),e.pageUrlExcludelist=null===(y=e.pageUrlExcludelist)||void 0===y?void 0:y.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 M,_="@amplitude/plugin-autocapture-browser",L=[],N=new qe(e,u),D=new Set,I=new Set,R=function(){var t,n,r=F(Ae().map(function(t){return N.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,k)})),i=F(new G(function(t){var n,r=function(n){var r=N.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,k);t.next(r)};return null===(n=a())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=a())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=F(new G(function(t){var n=function(n){var r=N.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,k);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=F(Te().map(function(t){return N.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,k)})),l=new G(function(e){var t,n=function(t){e.next(t)};return null===(t=a())||void 0===t||t.addEventListener("scroll",n),function(){var e;null===(e=a())||void 0===e||e.removeEventListener("scroll",n)}}),u=function(e,t){return new G(function(n){var r,i=a();if(!(null==i?void 0:i.IntersectionObserver))return function(){};var o=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:"0px",threshold:1}),l=t.join(",");(null!==(r=null==i?void 0:i.document.querySelectorAll(l))&&void 0!==r?r:[]).forEach(function(e){o.observe(e)});var u=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){e instanceof Element&&(e.matches(l)&&o.observe(e),e.querySelectorAll(l).forEach(function(e){o.observe(e)}))})})});return function(){u.unsubscribe(),o.disconnect()}})}(o,e.cssSelectorAllowlist);return(t={})[He.ChangeObservable]=i,t[He.ClickObservable]=r,t[He.MutationObservable]=o,t[He.NavigateObservable]=n,t[He.ScrollObservable]=l,t[He.ExposureObservable]=u,t},H=Ce(Object.values(null!==(E=null===(w=e.pageActions)||void 0===w?void 0:w.labeledEvents)&&void 0!==E?E:{})),j=Pe(null!==(T=null===(x=e.pageActions)||void 0===x?void 0:x.triggers)&&void 0!==T?T:[]),U=function(e,t,n,r){return new _e(e,t,n,r)}(H,j,N,e);return{name:_,type:"enrichment",setup:function(i,u){return n(void 0,void 0,void 0,function(){var n,c,s,d,v,f,p,h,g,m,b,y,w,E,x,T,A,O,q,X,Y;return r(this,function(r){return"undefined"==typeof document||(n=!1,c={maxX:void 0,maxY:void 0},i.fetchRemoteConfig&&(i.remoteConfigClient?i.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(n){!function(n){var r,i;n&&(e.pageActions=t(t({},e.pageActions),n),H=Ce(Object.values(null!==(r=e.pageActions.labeledEvents)&&void 0!==r?r:{})),j=Pe(null!==(i=e.pageActions.triggers)&&void 0!==i?i:[]),U.update(H,j,e))}(n)}):i.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),s=pe(e,e.cssSelectorAllowlist),d=pe(e,e.actionClickAllowlist),v=R(),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(ye).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(re,e.targetElementProperties)})}({allObservables:v,amplitude:u,shouldTrackEvent:s,evaluateTriggers:U.evaluate.bind(U)}),L.push(f),p=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(ye).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:v,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return N.getEventProperties.apply(N,l(l([],o(e),!1),[k],!1))},amplitude:u,shouldTrackEvent:s,evaluateTriggers:U.evaluate.bind(U)}),L.push(p),h=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,l=e.shouldTrackActionClick,a=n.clickObservable,u=n.mutationObservable,c=n.navigateObservable,s=a.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=be(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(ye).filter(function(e){return l("click",e.closestTrackedAncestor)}),d=c?B(u,c):u,v=B(s,d),f=null,p=null;return z(v,function(e){if(f&&(clearTimeout(f),f=null),"click"===e.type)return p=e,f=setTimeout(function(){f=null,p=null},500),Promise.resolve(null);if(p){var t=p;return p=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==t||t.track(re,i("click",e.closestTrackedAncestor)))})}({allObservables:v,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return N.getEventProperties.apply(N,l(l([],o(e),!1),[k],!1))},amplitude:u,shouldTrackEvent:s,shouldTrackActionClick:d}),h&&L.push(h),g=function(e){e.amplitude;var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe(function(){var e,t,r,i,o=a(),l=Math.floor(null!==(t=null!==(e=null==o?void 0:o.scrollX)&&void 0!==e?e:null==o?void 0:o.pageXOffset)&&void 0!==t?t:0),u=Math.floor(null!==(i=null!==(r=null==o?void 0:o.scrollY)&&void 0!==r?r:null==o?void 0:o.pageYOffset)&&void 0!==i?i:0);n.maxX=Math.max(n.maxX,l),n.maxY=Math.max(n.maxY,u)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:v,amplitude:u}),L.push(g),m={},b=a(),y=function(e){e&&n||(setTimeout(function(){n=!1},100),n=!0,function(e){var t,n,r,i,o=e.amplitude,l=e.scrollTracker,u=e.currentElementExposed,c=e.elementExposedForPage,s=e.exposureTracker,d=e.isPageEnd,v=e.lastScroll,f=l.getState(),p=a(),h=null!==(n=null==p?void 0:p.innerWidth)&&void 0!==n?n:0,g=null!==(r=null==p?void 0:p.innerHeight)&&void 0!==r?r:0,m=((t={})[le]=null===(i=null==p?void 0:p.location)||void 0===i?void 0:i.href,t["[Amplitude] Max Page X"]=f.maxX+h,t["[Amplitude] Max Page Y"]=f.maxY+g,t[ae]=g,t[ue]=h,t["[Amplitude] Element Exposed"]=Array.from(u),t),b=me();b&&(m[ce]=b),0!==u.size||f.maxX!==v.maxX||f.maxY!==v.maxY?(null==o||o.track("[Amplitude] Viewport Content Updated",m),v.maxX=f.maxX,v.maxY=f.maxY,u.clear(),d&&(l.reset(),c.clear(),null==s||s.reset())):d&&(l.reset(),c.clear(),null==s||s.reset())}({amplitude:u,scrollTracker:g,currentElementExposed:I,elementExposedForPage:D,exposureTracker:m.exposure,isPageEnd:e,lastScroll:c}))},w=function(e){!function(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}(e,D,I,y)},C&&(m.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,l=new Map,a=new Map,u=t.exposureObservable.subscribe(function(e){var t=e,i=t.target;if(t.isIntersecting){if(!l.get(i)){var u=setTimeout(function(){l.set(i,!0);var e=r.getElementPath(i);n(e),a.set(i,null)},o);a.set(i,u)}}else!t.isIntersecting&&t.intersectionRatio<1&&(u=a.get(i))&&(clearTimeout(u),a.set(i,null))});return{unsubscribe:function(){u.unsubscribe()},reset:function(){a.forEach(function(e){e&&clearTimeout(e)}),a.clear(),l.clear()}}}({allObservables:v,onExposure:w,dataExtractor:N,exposureDuration:P}),m.exposure&&L.push(m.exposure),E=function(){y(!0)},null==b||b.addEventListener("beforeunload",E),M=function(){null==b||b.removeEventListener("beforeunload",E)},L.push({unsubscribe:function(){return M()}}),(x=v[He.NavigateObservable])?L.push(x.subscribe(function(){y(!0)})):b&&(T=function(){y(!0)},b.addEventListener("popstate",T),A=b.history.pushState,b.history&&A&&(b.history.pushState=new Proxy(A,{apply:function(e,t,n){var r=o(n,3),i=r[0],l=r[1],a=r[2];e.apply(t,[i,l,a]),y(!0)}})),L.push({unsubscribe:function(){b.removeEventListener("popstate",T),b.history&&A&&(b.history.pushState=A)}}))),null===(Y=null==i?void 0:i.loggerProvider)||void 0===Y||Y.log("".concat(_," has been successfully added.")),window.opener&&S.enabled&&(O=e.cssSelectorAllowlist,q=e.actionClickAllowlist,Ee(X=Q(),{dataExtractor:N,isElementSelectable:pe(e,l(l([],o(O),!1),o(q),!1)),cssSelectorAllowlist:O,actionClickAllowlist:q}),function(e,t){var n,r=e;if(!0!==r[ee]){r[ee]=!0;var i=null!==(n=null==t?void 0:t.scriptUrl)&&void 0!==n?n:"https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz",o=null,l=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){var t,n;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Initializing background capture (external script)");var r=new URL(i,e.endpoint).toString();e.loadScriptOnce(r).then(function(){var t,n,r;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),o=null===(r=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===r?void 0:r.call(window,{messenger:e,onBackgroundCapture:l}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null===(e=null==o?void 0:o.close)||void 0===e||e.call(o),o=null})}}(X),X.setup(t({logger:null==i?void 0:i.loggerProvider},(null==i?void 0:i.serverZone)&&{endpoint:J[i.serverZone]})))),[2]})})},execute:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return n(void 0,void 0,void 0,function(){var e,t,n,o;return r(this,function(r){try{for(e=i(L),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(n)throw n.error}}return[2]})})}}},Ye=["mutation","navigate"];function Ge(e,t){var n,r,i,o,l=t.event,a=l.pageX,u=l.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:u,u),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:u,u),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:a,a),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function ze(e){if(0===e.length)return null;var n=e[0],r=e[e.length-1];return{rageClickEvent:t({"[Amplitude] Begin Time":new Date(n.timestamp).toISOString(),"[Amplitude] End Time":new Date(r.timestamp).toISOString(),"[Amplitude] Duration":r.timestamp-n.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},n.targetElementProperties),time:n.timestamp}}function Be(e){var t=this,i=e.amplitude,o=e.allObservables,l=e.shouldTrackRageClick,a=o.clickObservable,u=o.selectionObservable,c=[],s={},d=null;function v(e){c=[],s={},e&&(Ge(s,e),c.push(e))}var f=z(a.filter(function(e){return l("click",e.closestTrackedAncestor)}),function(e){return n(t,void 0,void 0,function(){var t;return r(this,function(n){return Ge(s,e),t=null,0===c.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(c,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(c,e)||s.isOutOfBounds?(d&&(t=ze(c)),v(e)):c.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),c.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(ze(c))},1e3)}})]:[2,null]})})}),p=null==u?void 0:u.subscribe(function(){v()}),h=f.subscribe(function(e){null!==e&&i.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){h.unsubscribe(),null==p||p.unsubscribe()}}}var Fe,Ve;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}(Fe||(Fe={})),function(e){e.X="x",e.Y="y"}(Ve||(Ve={}));function We(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Je(e){e.changes=[],e.startTime=void 0}function Ke(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var Ze=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new G(function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},l=void 0,a=null;function u(){void 0!==l&&(e.next(l),l=void 0,null!==a&&clearTimeout(a),Je(n),Je(i))}return t.subscribe(function(e){null!==a&&clearTimeout(a),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Ve.X?n:i);var t=function(e,t){var n=void 0;if(We(e)&&(n=e.startTime),We(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(l=l||t,a=setTimeout(function(){u(),a=null},o)):u(),Ke(n),Ke(i),function(){null!==a&&(clearTimeout(a),a=null)}})})},$e=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,l=e.thresholdMs,a=void 0===l?2e3:l,u=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new G(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===Fe.DECREASING&&e.next(Ve.X),r=Fe.INCREASING):o.x<n.x&&(r===Fe.INCREASING&&e.next(Ve.X),r=Fe.DECREASING),o.y>n.y?(i===Fe.DECREASING&&e.next(Ve.Y),i=Fe.INCREASING):o.y<n.y&&(i===Fe.INCREASING&&e.next(Ve.Y),i=Fe.DECREASING),n=o):n=o})})}({allWindowObservables:r});return Ze({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:a}).subscribe(function(e){fe(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function Qe(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var et=4e3;e.DataExtractor=qe,e.autocapturePlugin=Xe,e.enableVisualTagging=Ee,e.frustrationPlugin=function(e){var a;void 0===e&&(e={});var u="@amplitude/plugin-frustration-browser",c=[],s=!1!==e.errorClicks;e.errorClicks||(s=!1);var d=!1!==e.deadClicks&&null!==e.deadClicks,v=!1!==e.rageClicks&&null!==e.rageClicks,f=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(f=!1);var p=Qe(e,"rageClicks",E,v),h=Qe(e,"deadClicks",y,d),m=Qe(e,"errorClicks",w,s),b=null!==(a=e.dataAttributePrefix)&&void 0!==a?a:g,x=new qe(e),T=l([],o(new Set(l(l(l([],o(p),!1),o(h),!1),o(m),!1))),!1),A=function(){var e,n,r=F(Ae("pointerdown").map(function(e){return x.addAdditionalEventProperties(e,"click",T,b,!0)})),i=F(ke().map(function(e){return x.addTypeAndTimestamp(e,"error")})),o=F(Te().map(function(e){return x.addAdditionalEventProperties(e,"mutation",T,b)}));window.navigation&&(n=F(new G(function(e){var n=function(n){e.next(t(t({},n),{type:"navigate"}))};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}).map(function(e){return x.addAdditionalEventProperties(e,"navigate",T,b)})));var l=F(new G(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}})),a=F(new G(function(e){var t=function(t){e.next(t)},n={capture:!0};return xe.document.addEventListener("mousemove",t,n),function(){xe.document.removeEventListener("mousemove",t,n)}}));return(e={})[He.ClickObservable]=r,e[He.MutationObservable]=o,e[He.NavigateObservable]=n,e[He.BrowserErrorObservable]=i,e[He.SelectionObservable]=l,e[He.MouseMoveObservable]=a,e};return{name:u,type:"enrichment",setup:function(i,o){return n(void 0,void 0,void 0,function(){var n,l,a,g,y,w,E,T,k,O,S;return r(this,function(r){return"undefined"==typeof document||(n=A(),v&&(l=pe(e,p),a=Be({allObservables:n,amplitude:o,shouldTrackRageClick:l}),c.push(a)),d&&(g=pe(e,h),y=function(e){var n=e.amplitude,r=e.allObservables,i=e.getEventProperties,o=e.shouldTrackDeadClick,l=r.clickObservable,a=r.mutationObservable,u=r.navigateObservable,c=l.filter(function(e){return ye(e)&&o("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===te.LEFT_OR_TOUCH_CONTACT}),s=u?B(a,u):a,d=B(c,s),v=null;return z(d,function(e){return v&&Ye.includes(e.type)?(clearTimeout(v),v=null,Promise.resolve(null)):"click"===e.type?v?Promise.resolve(null):new Promise(function(t){v=setTimeout(function(){t(e),v=null},3e3)}):Promise.resolve(null)}).subscribe(function(e){if(e){var r={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};n.track("[Amplitude] Dead Click",t(t({},i("click",e.closestTrackedAncestor)),r),{time:e.timestamp})}})}({amplitude:o,allObservables:n,getEventProperties:function(e,t){return x.getEventProperties(e,t,b)},shouldTrackDeadClick:g}),c.push(y)),s&&(w=pe(e,m),E=function(e){var n=e.amplitude,r=e.allObservables,i=e.shouldTrackErrorClick,o=r.clickObservable,l=r.browserErrorObservable,a=o.filter(function(e){return ye(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===te.LEFT_OR_TOUCH_CONTACT}),u=null,c=null,s=function(){null!==u&&(clearTimeout(u),u=null),c=null};return B(a,l).subscribe(function(e){var r;if("click"===e.type)return s(),c=e,void(u=setTimeout(s,2e3));"error"===e.type&&c&&(n.track("[Amplitude] Error Click",t(((r={})["[Amplitude] Kind"]=e.event.kind,r["[Amplitude] Message"]=e.event.message,r["[Amplitude] Stack"]=e.event.stack,r["[Amplitude] Filename"]=e.event.filename,r["[Amplitude] Line Number"]=e.event.lineNumber,r["[Amplitude] Column Number"]=e.event.columnNumber,r),c.targetElementProperties)),s())})}({amplitude:o,allObservables:n,shouldTrackErrorClick:w}),c.push(E)),f&&(T=void 0,k=void 0,"object"==typeof e.thrashedCursor&&(T=e.thrashedCursor.directionChanges,k=e.thrashedCursor.threshold,T&&T<5&&(i.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(T," is below the minimum of ").concat(5,", setting to ").concat(5)),T=5),k&&k>et&&(i.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(k," is above the maximum of ").concat(et,", setting to ").concat(et)),k=et)),O=$e({amplitude:o,options:e,allObservables:n,directionChanges:T,thresholdMs:k}),c.push(O)),null===(S=null==i?void 0:i.loggerProvider)||void 0===S||S.log("".concat(u," has been successfully added."))),[2]})})},execute:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){return[2,e]})})},teardown:function(){return n(void 0,void 0,void 0,function(){var e,t,n,o;return r(this,function(r){try{for(e=i(c),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(n)throw n.error}}return[2]})})}}},e.plugin=Xe,Object.defineProperty(e,"__esModule",{value:!0})});
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"autocapture-plugin.d.ts","sourceRoot":"","sources":["../../src/autocapture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAK/B,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAoBnB,OAAO,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAIvE,KAAK,cAAc,GAAG;IACpB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAAkC,KAAK,IAAI,CAAC;IACvF,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAAkC,KAAK,IAAI,CAAC;CAC3F,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,cAAc,CAAC;KAC5B;CACF;AAED,KAAK,uBAAuB,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE9E,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CACnD,IAAI,CAAC,0BAA0B,EAAE,cAAc,GAAG,sBAAsB,GAAG,sBAAsB,CAAC,CACnG,GACC,0BAA0B,CAAC;AAE7B,oBAAY,eAAe;IACzB,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,mBAAmB,wBAAwB;IAC3C,mBAAmB,wBAAwB;CAC5C;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC;IACxF,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;IACnF,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,eAAO,MAAM,iBAAiB,GAC5B,UAAS,0BAA+B,EACxC,UAAU;IAAE,iBAAiB,EAAE,kBAAkB,CAAA;CAAE,KAClD,uBA6XF,CAAC"}
1
+ {"version":3,"file":"autocapture-plugin.d.ts","sourceRoot":"","sources":["../../src/autocapture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAK/B,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAoBnB,OAAO,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAIvE,KAAK,cAAc,GAAG;IACpB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAAkC,KAAK,IAAI,CAAC;IACvF,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAAkC,KAAK,IAAI,CAAC;CAC3F,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,cAAc,CAAC;KAC5B;CACF;AAED,KAAK,uBAAuB,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE9E,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CACnD,IAAI,CAAC,0BAA0B,EAAE,cAAc,GAAG,sBAAsB,GAAG,sBAAsB,CAAC,CACnG,GACC,0BAA0B,CAAC;AAE7B,oBAAY,eAAe;IACzB,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,mBAAmB,wBAAwB;IAC3C,mBAAmB,wBAAwB;CAC5C;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC;IACxF,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;IACnF,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,eAAO,MAAM,iBAAiB,GAC5B,UAAS,0BAA+B,EACxC,UAAU;IAAE,iBAAiB,EAAE,kBAAkB,CAAA;CAAE,KAClD,uBAgYF,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.24.2";
1
+ export declare const VERSION = "1.25.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/plugin-autocapture-browser",
3
- "version": "1.24.2",
3
+ "version": "1.25.0",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "tslib": "^2.4.1",
25
- "@amplitude/analytics-core": "2.43.1"
25
+ "@amplitude/analytics-core": "2.44.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aws-sdk/client-s3": "^3.229.0",