(window.webpackJsonp=window.webpackJsonp||[]).push([[133],{1321:function(e,t){!function(){var t,r={days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{D:"%m/%d/%y",F:"%Y-%m-%d",R:"%H:%M",T:"%H:%M:%S",X:"%T",c:"%a %b %d %X %Y",r:"%I:%M:%S %p",v:"%e-%b-%Y",x:"%D"}},s=new function e(t,s,i){var n,o=t||r,a=s||0,c=i||!1,l=0;var u=function(e,t){var r;if(t)r=t.getTime(),c&&(t=new Date(t.getTime()+b(t)+a));else{var s=Date.now();s>l?(l=s,n=new Date(l),r=l,c&&(n=new Date(l+b(n)+a))):r=l,t=n}return function e(t,r,s,i){for(var n="",o=null,l=!1,u=t.length,d=!1,b=0;b9?e:(null==t&&(t="0"),t+e)}function m(e){return e>99?e:e>9?"0"+e:"00"+e}function f(e){return 0===e?12:e>12?e-12:e}function p(e,t){t=t||"sunday";var r=e.getDay();"monday"===t&&(0===r?r=6:r--);var s=Date.UTC(e.getFullYear(),0,1),i=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),n=(Math.floor((i-s)/864e5)+7-r)/7;return Math.floor(n)}function g(e){var t=e%10,r=e%100;if(r>=11&&r<=13||0===t||t>=4)return"th";switch(t){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function b(e){return 6e4*(e.getTimezoneOffset()||0)}"function"!=typeof Date.now&&(Date.now=function(){return+new Date})}()},1322:function(e,t,r){"use strict";var s=r(1935);function i(e,t){return void 0===t&&(t=!0),e&&"object"==typeof e?function(e,t){return Object.keys(e).forEach((function(r){e[r]=i(e[r],t)})),e}(e,t):Array.isArray(e)?function(e,t){return e.forEach((function(r,s){e[s]=i(r,t)})),e}(e,t):s.is(e,t)?s.parse(e):e}e.exports=i},1323:function(e,t,r){"use strict";(function(e){ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var r=function(){return(r=Object.assign||function(e){for(var t,r=1,s=arguments.length;r=t||r<0||m&&e-d>=o}function v(){var e=c();if(b(e))return y(e);l=setTimeout(v,function(e){var r=t-(e-u);return m?P(r,o-(e-d)):r}(e))}function y(e){return l=void 0,f&&i?p(e):(i=n=void 0,a)}function w(){var e=c(),r=b(e);if(i=arguments,n=this,u=e,r){if(void 0===l)return g(u);if(m)return l=setTimeout(v,t),p(u)}return void 0===l&&(l=setTimeout(v,t)),a}return t=S(t)||0,s(r)&&(h=!!r.leading,o=(m="maxWait"in r)?k(S(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),w.cancel=function(){void 0!==l&&clearTimeout(l),d=0,i=u=n=l=void 0},w.flush=function(){return void 0===l?a:y(c())},w};var D=function(e,t,r){var i=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return s(r)&&(i="leading"in r?!!r.leading:i,n="trailing"in r?!!r.trailing:n),A(e,t,{leading:i,maxWait:t,trailing:n})},j=["scroll","resize"],C=["wheel","keydown","keyup","mousedown","mousemove","touchstart","touchmove","click","contextmenu"],N=function(){function e(e){var t=e.timeIntervalEllapsedCallbacks,s=void 0===t?[]:t,i=e.absoluteTimeEllapsedCallbacks,n=void 0===i?[]:i,o=e.checkCallbacksIntervalMs,a=void 0===o?100:o,c=e.browserTabInactiveCallbacks,l=void 0===c?[]:c,u=e.idleCallbacks,d=void 0===u?[]:u,h=e.stopTimerOnTabchange,m=void 0===h||h,f=e.activeCallbacks,p=void 0===f?[]:f,g=e.browserTabActiveCallbacks,b=void 0===g?[]:g,v=e.idleTimeoutMs,y=void 0===v?3e3:v,w=this;this.onBrowserTabInactive=function(){w.isRunning()&&w.stopTimerOnTabchange&&w.stopTimer(),w.browserTabInactiveCallbacks.forEach((function(e){return e(w.getTimeInMilliseconds())}))},this.onBrowserTabActive=function(){w.isRunning()||w.startTimer(),w.browserTabActiveCallbacks.forEach((function(e){return e(w.getTimeInMilliseconds())}))},this.onBrowserActiveChange=function(){"visible"===document.visibilityState?w.onBrowserTabActive():w.onBrowserTabInactive()},this.onTimePassed=function(){w.absoluteTimeEllapsedCallbacks.forEach((function(e,t){var r=e.callback,s=e.pending,i=e.timeInMilliseconds;s&&i<=w.getTimeInMilliseconds()&&(r(w.getTimeInMilliseconds()),w.absoluteTimeEllapsedCallbacks[t].pending=!1)})),w.timeIntervalEllapsedCallbacks.forEach((function(e,t){var r=e.callback,s=e.timeInMilliseconds,i=e.multiplier;s<=w.getTimeInMilliseconds()&&(r(w.getTimeInMilliseconds()),w.timeIntervalEllapsedCallbacks[t].timeInMilliseconds=i(s))})),w.currentIdleTimeMs>=w.idleTimeoutMs&&w.isRunning()?(w.idle=!0,w.stopTimer(),w.idleCallbacks.forEach((function(e){return e(w.getTimeInMilliseconds())}))):w.currentIdleTimeMs+=w.checkCallbacksIntervalMs},this.resetIdleTime=function(){w.idle&&w.startTimer(),w.activeCallbacks.forEach((function(e){return e(w.getTimeInMilliseconds())})),w.idle=!1,w.currentIdleTimeMs=0},this.registerEventListeners=function(){var e={passive:!0},t=r({},e,{capture:!0});document.addEventListener("visibilitychange",w.onBrowserActiveChange);var s=D(w.resetIdleTime,2e3,{leading:!0,trailing:!1});j.forEach((function(e){window.addEventListener(e,s,t)})),C.forEach((function(t){return document.addEventListener(t,s,e)}))},this.unregisterEventListeners=function(){document.removeEventListener("visibilitychange",w.onBrowserActiveChange),j.forEach((function(e){return window.removeEventListener(e,w.resetIdleTime)})),C.forEach((function(e){return document.removeEventListener(e,w.resetIdleTime)}))},this.checkCallbacksOnInterval=function(){w.checkCallbackIntervalId=window.setInterval((function(){w.onTimePassed()}),w.checkCallbacksIntervalMs)},this.startTimer=function(){w.checkCallbackIntervalId||w.checkCallbacksOnInterval();var e=w.times[w.times.length-1];e&&null===e.stop||(w.times.push({start:performance.now(),stop:null}),w.running=!0)},this.stopTimer=function(){w.times.length&&(w.times[w.times.length-1].stop=performance.now(),w.running=!1)},this.addTimeIntervalEllapsedCallback=function(e){w.timeIntervalEllapsedCallbacks.push(e)},this.addAbsoluteTimeEllapsedCallback=function(e){w.absoluteTimeEllapsedCallbacks.push(e)},this.addBrowserTabInactiveCallback=function(e){w.browserTabInactiveCallbacks.push(e)},this.addBrowserTabActiveCallback=function(e){w.browserTabActiveCallbacks.push(e)},this.addIdleCallback=function(e){w.idleCallbacks.push(e)},this.addActiveCallback=function(e){w.activeCallbacks.push(e)},this.getTimeInMilliseconds=function(){return w.times.reduce((function(e,t){return t.stop?e+=t.stop-t.start:e+=performance.now()-t.start,e}),0)},this.isRunning=function(){return w.running},this.isIdle=function(){return w.idle},this.reset=function(){w.times=[]},this.destroy=function(){w.unregisterEventListeners(),w.checkCallbackIntervalId&&window.clearInterval(w.checkCallbackIntervalId)},this.running=!1,this.times=[],this.idle=!1,this.currentIdleTimeMs=0,this.marks={},this.measures={},this.stopTimerOnTabchange=m,this.browserTabActiveCallbacks=b,this.browserTabInactiveCallbacks=l,this.checkCallbacksIntervalMs=a,this.idleTimeoutMs=y,this.timeIntervalEllapsedCallbacks=s,this.absoluteTimeEllapsedCallbacks=n,this.idleCallbacks=d,this.activeCallbacks=p,this.registerEventListeners()}return e.prototype.mark=function(e){this.marks[e]||(this.marks[e]=[]),this.marks[e].push({time:this.getTimeInMilliseconds()})},e.prototype.getMarks=function(e){if(!(this.marks[e].length<1))return this.marks[e]},e.prototype.measure=function(e,t,r){var s=this.marks[t],i=s[s.length-1],n=this.marks[r],o=n[n.length-1];this.measures[e]||(this.measures[e]=[]),this.measures[e].push({name:e,startTime:i.time,duration:o.time-i.time})},e.prototype.getMeasures=function(e){if(this.measures[e]||!(this.measures[e].length<1))return this.measures[e]},e}();t.a=N}).call(this,r(189))},1934:function(e,t,r){r(2269),e.exports=r(307)},1935:function(e,t,r){"use strict";var s=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;t.parse=function(e){var t=[1,5,6,7,11,12],r=s.exec(e),i=0;if(!r)return new Date(e);for(var n,o=0;n=t[o];o++)r[n]=parseInt(r[n],10)||0;r[2]=parseInt(r[2],10)||1,r[3]=parseInt(r[3],10)||1,r[2]--,r[8]=r[8]?(r[8]+"00").substring(0,3):0," "===r[4]?i=(new Date).getTimezoneOffset():"Z"!==r[9]&&r[10]&&(i=60*r[11]+r[12],"+"===r[10]&&(i=0-i));var a=Date.UTC(r[1],r[2],r[3],r[5],r[6]+i,r[7],r[8]);return new Date(a)},t.is=function(e,t){return"string"==typeof e&&((!t||!1!==/^\d{4}-\d{2}-\d{2}/.test(e))&&s.test(e))}},1936:function(e,t,r){"use strict";e.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}},2269:function(e,t,r){"use strict";r.r(t);var s={};r.r(s),r.d(s,"default",(function(){return Ar})),r.d(s,"apdexType",(function(){return E})),r.d(s,"envType",(function(){return g})),r.d(s,"eventType",(function(){return b})),r.d(s,"originType",(function(){return y})),r.d(s,"platformType",(function(){return v})),r.d(s,"tenantType",(function(){return w})),r.d(s,"userType",(function(){return I})),r.d(s,"originTracingType",(function(){return _})),r.d(s,"TypeAheadHelper",(function(){return Gr})),r.d(s,"DwellTimeHelper",(function(){return Rr})),r.d(s,"DwellTimeHelperWithBrowserInteraction",(function(){return Br})),r.d(s,"CompressionRule",(function(){return ae})),r.d(s,"ResilienceMechanism",(function(){return Ke}));r(126),r(398),r(304);var i=r(487),n=r.n(i),o=r(1321),a=r.n(o),c=r(89),l=r.n(c),u=r(889),d=r.n(u),h=r(2),m=r.n(h),f=r(128),p=r.n(f);let g,b,v,y,w,I,E;!function(e){e.LOCAL="local",e.DEV="dev",e.STAGING="staging",e.PROD="prod"}(g||(g={})),function(e){e.TRACK="track",e.UI="ui",e.OPERATIONAL="operational",e.SCREEN="screen",e.IDENTIFY="identify"}(b||(b={})),function(e){e.MAC="mac",e.LINUX="linux",e.WINDOWS="windows",e.DESKTOP="desktop",e.WEB="web",e.MOBILE_WEB="mobileWeb"}(v||(v={})),function(e){e.DESKTOP="desktop",e.WEB="web"}(y||(y={})),function(e){e.CLOUD_ID="cloudId",e.ORG_ID="orgId",e.OPSGENIE_CUSTOMER_ID="opsgenieCustomerId",e.NONE="none"}(w||(w={})),function(e){e.ATLASSIAN_ACCOUNT="atlassianAccount",e.HASHED_EMAIL="hashedEmail",e.TRELLO="trello",e.OPSGENIE="opsgenie",e.HALP="halp"}(I||(I={})),function(e){e.TRANSITION="transition",e.INITIAL_LOAD="initialLoad"}(E||(E={}));const O=Object.freeze([v.DESKTOP,v.MAC,v.LINUX,v.WINDOWS]),T=Object.freeze([v.WEB,v.MOBILE_WEB]);let _;function S(e){return Object.values(e)}function k(e,t){return Object.values(e).indexOf(t)>-1}!function(e){e.ATL_ORIGIN="atlOrigin"}(_||(_={}));class P{constructor(){m()(this,"_bindEventListeners",()=>{document.addEventListener(this._visibilityChange,this._handleVisibilityChange,!1)}),m()(this,"_handleVisibilityChange",()=>{const e=document[this._hidden];this._isHidden=e,this._callbacks.forEach(t=>t(e))}),this._isHidden=!1,this._callbacks=new Map,this._hidden=void 0,this._visibilityChange=void 0,void 0!==document.hidden?(this._isHidden=document.hidden,this._hidden="hidden",this._visibilityChange="visibilitychange"):void 0!==document.msHidden?(this._isHidden=document.msHidden,this._hidden="msHidden",this._visibilityChange="msvisibilitychange"):void 0!==document.webkitHidden&&(this._isHidden=document.webkitHidden,this._hidden="webkitHidden",this._visibilityChange="webkitvisibilitychange"),void 0!==document.addEventListener&&void 0!==this._hidden&&this._bindEventListeners()}addCallback(e,t){if("string"!=typeof e)throw new Error("Invalid name, must be string");if("function"!=typeof t)throw new Error("Invalid callback, must be function");this._callbacks.set(e,t)}removeCallback(e){this._callbacks.has(e)&&this._callbacks.delete(e)}getIsHidden(){return this._isHidden}}class A{constructor(){this._performance=window.performance}clearMarks(...e){this._performance&&this._performance.clearMarks&&this._performance.clearMarks(...e)}mark(...e){this._performance&&this._performance.mark&&this._performance.mark(...e)}getEntriesByName(...e){return this._performance&&this._performance.getEntriesByName?this._performance.getEntriesByName(...e):[]}getTimeOrigin(){return this._performance&&(this._performance.timeOrigin||this._performance.timing)?this._performance.timeOrigin||this._performance.timing.navigationStart:0}now(){return this._performance&&this._performance.now?this._performance.now():Date.now?Date.now():+new Date}isAvailable(){return!!(this._performance&&this._performance.clearMarks&&this._performance.mark&&this._performance.getEntriesByName&&this._performance.timing)}}function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function j(e){for(var t=1;tt?`${e}.${t}`:e),m()(this,"_getEventTimingByName",e=>{const t=this._performance.getEntriesByName(e);return t[t.length-1]}),m()(this,"_getApdexFields",e=>{const t=this._getApdexTimings(e),r=this._calculateApdex({duration:t.duration,threshold:e.threshold});return j(j({},t),{},{apdex:r})}),m()(this,"_getApdexTimings",e=>{const t=this._getEventKey(e),r=t+"-start",s=e.startTime||this._getStartTime(e,r),i=e.stopTime||this._getStopTime();return this._cleanApdexState(t),{startTime:s,stopTime:i,duration:i-s}}),m()(this,"_getStartTime",(e,t)=>{let r;const s=this._performance.getTimeOrigin();if(e.type===E.INITIAL_LOAD)r=s;else{r=s+this._getEventTimingByName(t).startTime}return r}),m()(this,"_getStopTime",()=>this._performance.getTimeOrigin()+this._performance.now()),m()(this,"_cleanApdexState",e=>{this._performance.clearMarks(e+"-start"),this._performance.clearMarks(e+"-stop"),this._startedEvents.delete(e)}),m()(this,"_getVisibilityFields",e=>{let t;if(e.type===E.INITIAL_LOAD)t=!this._wasPreviouslyHidden;else if(e.type===E.TRANSITION){const r=this._getEventKey(e);t=this._isActiveEvents.get(r)}return(e.startTime||e.stopTime)&&(t=!this._pageVisibility.getIsHidden()),{isActiveTab:t}}),m()(this,"_calculateApdex",({duration:e,threshold:t=this._threshold})=>{let r;return r=e<=t?1:e<=4*t?.5:0,r}),m()(this,"_validateStartEvent",e=>{if(!e)throw new Error('Missing "event" in Apdex start event');if(!e.task)throw new Error('Missing "task" in Apdex start event');if("string"!=typeof e.task)throw new Error('Invalid "task" in Apdex start event');if(e.taskId&&"string"!=typeof e.taskId)throw new Error('Invalid "taskId" in Apdex start event')}),m()(this,"_validateStopEvent",e=>{if(!e)throw new Error('Missing "event" in Apdex stop event');if(!e.task)throw new Error('Missing "task" in Apdex stop event');if("string"!=typeof e.task)throw new Error('Invalid "task" in Apdex stop event');if(e.taskId&&"string"!=typeof e.taskId)throw new Error('Invalid "taskId" in Apdex stop event');if(!e.type)throw new Error('Missing "type" in Apdex stop event');if(e.type&&!k(E,e.type))throw new Error('Invalid "type" in Apdex stop event');if(e.threshold&&"number"!=typeof e.threshold)throw new Error('Invalid "threshold" in Apdex stop event');if(!e.startTime&&e.type===E.TRANSITION){const t=this._getEventKey(e);if(!this._startedEvents.has(t))throw new Error(`Apdex event transition "${t}" was not started`)}if(e.startTime&&!("number"==typeof e.startTime&&e.startTime>=0))throw new Error('Invalid "startTime" in Apdex stop event');if(e.stopTime&&"number"!=typeof e.stopTime)throw new Error('Invalid "stopTime" in Apdex stop event');if(e.stopTime<=e.startTime)throw new Error('"stopTime" should be greater than "startTime" in Apdex stop event')}),m()(this,"_shouldSendEvent",e=>!!e&&"number"==typeof e.apdex),m()(this,"_sendEvent",(e,t)=>{this._shouldSendEvent(e)&&this._onEvent({source:"ui",action:"readyForUser",actionSubject:"ui",attributes:j(j({},e.additionalAttributes),{},{task:e.task,taskId:e.taskId,type:e.type,threshold:e.threshold||this._threshold,apdex:e.apdex,startTime:e.startTime,stopTime:e.stopTime,duration:e.duration,isActiveTab:e.isActiveTab})},t)}),!e)throw new Error("Missing onEvent callback");if("function"!=typeof e)throw new Error("Invalid onEvent, must be function");if(!(t instanceof P))throw new Error("Invalid pageVisibility, must be PageVisibility class");this._startedEvents=new Map,this._performance=new A,this._onEvent=e,this._threshold=1e3,this._wasPreviouslyHidden=t.getIsHidden(),this._isActiveEvents=new Map,this._pageVisibility=t,this._pageVisibility.addCallback("apdexEvent",e=>{this.onVisibilityChange(!e)})}start(e){if(this._validateStartEvent(e),!this._performance.isAvailable())return;const t=this._getEventKey(e),r=t+"-start";this._startedEvents.set(t,!0),this._isActiveEvents.set(t,!this._pageVisibility.getIsHidden()),this._performance.clearMarks(r),this._performance.mark(r)}getStart(e){if(this._validateStartEvent(e),!this._performance.isAvailable())return;const t=this._getEventKey(e)+"-start";return this._getEventTimingByName(t)}stop(e,t){if(this._validateStopEvent(e),!this._performance.isAvailable())return;const r=this._getApdexFields(e),s=this._getVisibilityFields(e);this._sendEvent(j(j(j({},e),r),s),t)}onVisibilityChange(e){e||(this._wasPreviouslyHidden=!0,this._isActiveEvents.forEach((e,t)=>this._isActiveEvents.set(t,!1)))}}var N=(e,t)=>()=>{if((e=>"function"==typeof e)(e))try{return e()}catch(e){return void console.error(`${t} - ${e.message}`)}return e};function M(e){return!0==(null!==(t=e)&&"object"==typeof t&&!1===Array.isArray(t))&&"[object Object]"===Object.prototype.toString.call(e);var t}function R(e){if(!1===M(e))return!1;const t=e.constructor;if("function"!=typeof t)return!1;const r=t.prototype;return!1!==M(r)&&"isPrototypeOf"in r}function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function L(e){for(var t=1;t0}function G(e,t){return $(t)?{[e]:t}:void 0}function K(e){if($(e)){return G("containers",function(e){const t={};return Object.keys(e).forEach(r=>{const s=e[r];t[r]={id:s.id,type:s.type}}),t}(e))}}function V(e,t){return L({containerType:e.containerType,containerId:e.containerId,source:e.source,objectType:e.objectType,objectId:e.objectId,actionSubject:e.actionSubject,action:e.action,actionSubjectId:e.actionSubjectId,attributes:e.attributes,nonPrivacySafeAttributes:e.nonPrivacySafeAttributes,tags:e.tags,highPriority:e.highPriority,eventType:t},K(e.containers))}function z(e,t,r,s,i,n,o,a,c,l,u,d){const h=W(e),m=U(t),f=F(r),p=B(l),g={title:"",path:"",url:"",referrer:"",search:"",eventType:b.SCREEN};return L(L(L(L(L(L(L(L(L({},h),m),f),p),g),function(e){return G("attributes",e)}(s)),function(e){return G("nonPrivacySafeAttributes",e)}(i)),K(d)),{},{tags:n,tabId:o,sessionId:a,taskSessions:c,pageLoadId:u})}function q(e){return`${e.actionSubject} ${e.action}`}function Q(e,t,r,s,i,n,o,a,c,l){const u=W(e,function(e){const{env:t,product:r,subproduct:s,version:i,origin:n,platform:o}=e;return{env:t,product:r,subproduct:s,version:i,origin:n,platform:o}}(s)),d=U(t),h=B(c),m=F(r),f=V(s,i);return L(L(L(L(L(L({},u),d),h),m),f),{},{tabId:n,sessionId:o,taskSessions:a,pageLoadId:l})}const J=Object.freeze([b.OPERATIONAL,b.TRACK,b.UI]);function X(e){if(e){if(e&&e.constructor!==Object)throw new Error("properties.containers must be an Object");Object.values(e).forEach(e=>function(e){if(!R(e))throw new Error("properties.containers must be an Object");if(!("id"in e))throw new Error("properties.containers is missing field 'id'");if("string"!=typeof e.id)throw new Error("properties.containers.id must be of type String");if("type"in e&&"string"!=typeof e.type)throw new Error("properties.containers.type must be of type String")}(e))}}function Y(e){switch(e){case b.OPERATIONAL:case b.TRACK:case b.UI:return!0;default:return!1}}function Z(e){if(!e)throw new Error("Missing event");if(!e.source)throw new Error("Missing event.source");if(!e.actionSubject)throw new Error("Missing event.actionSubject");if(!e.action)throw new Error("Missing event.action");X(e.containers)}function ee(e){if(!e)throw new Error("Missing event");if(!e.source)throw new Error("Missing event.source");if(!e.actionSubject)throw new Error("Missing event.actionSubject")}const te=(e,t)=>Object.keys(e).reduce((r,s)=>(r[t(e[s],s,e)]=e[s],r),{}),re=(e,t)=>Object.keys(e).filter(e=>t.indexOf(e)<0).reduce((t,r)=>(t[r]=e[r],t),{}),se=(e,t)=>{if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return e===t;if(e.prototype!==t.prototype)return!1;const r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>se(e[r],t[r]))},ie=(e,t)=>e.reduce((e,r,s,i)=>(e[t(r,s,i)?0:1].push(r),e),[[],[]]);function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function oe(e){for(var t=1;t{try{return e&&Y(e.eventType)&&this._predicate(e)}catch(e){return!1}}),m()(this,"compress",e=>{const[t,r]=ie(e,e=>this.canCompress(e)),s=this._compressFn(t);if(!s)throw new Error("No events were returned from the compression function");return s.forEach(e=>{!function(e){if(!Y(e))throw new Error(`Invalid action event type: ${e}, must be one of: [${J}]`)}(e.eventType),Z(e)}),s.concat(r)}),"function"!=typeof e)throw new Error("Invalid predicate, must be a function that accepts an event and returns a boolean");if("function"!=typeof t)throw new Error("Invalid compressFn, must be a function that both accepts and returns an array of events");this._predicate=e,this._compressFn=t}}class ce{constructor(e=[]){if(m()(this,"canCompress",e=>this._compressionRules.some(t=>t.canCompress(e))),m()(this,"compress",e=>this._createGroups(e).reduce((e,t)=>(this._compressGroup(t).forEach(t=>e.push(t)),e),[])),m()(this,"_createGroups",e=>e.reduce((e,t)=>{let r,s=null;for(let e=0;e{if(!e.compressor)return e.events;try{return e.compressor.compress(e.events).map(t=>oe(oe({},t),e.contextFields))}catch(t){return console.warn(`Failed to compress some analytics events. Error: ${t.message}. Sending ${e.events.length} uncompressed events instead`),e.events}}),!Array.isArray(e))throw new Error("Event compressors must be constructed with an array of CompressionRules");if(!e.every(e=>e instanceof ae))throw new Error("Event compressors can only be constructed with instances of CompressionRule");this._compressionRules=e}}class le{constructor(e,t){m()(this,"push",(e,t,r,s)=>{this._eventArgs.push({identifier:e,builtEvent:t,context:r,userInfo:s})}),m()(this,"size",()=>this._eventArgs.length),m()(this,"startFlush",()=>{try{this._eventArgs=this._compressEventArgs(this._eventArgs)}catch(e){console.warn(`Failed to perform compression on the delayed analytics events. Error: ${e.message}. Sending ${this._eventArgs.length} uncompressed events instead`)}this._flushNextBatch()}),m()(this,"cancelFlush",()=>{this._flushBatchTimeout&&(clearTimeout(this._flushBatchTimeout),this._flushBatchTimeout=null)}),m()(this,"_flushNextBatch",()=>{this._eventArgs.splice(0,7).forEach(e=>this._processFn(e.identifier,e.builtEvent,e.context,e.userInfo)),this._eventArgs.length>0?this._flushBatchTimeout=setTimeout(()=>this._flushNextBatch(),100):this._flushBatchTimeout=null}),m()(this,"_compressEventArgs",e=>{const[t,r]=ie(e,e=>this._compressor.canCompress(e.builtEvent)),s=t.reduce((e,t)=>{let r=null;for(let s=0;s{try{const r=t.eventArgs.map(e=>e.builtEvent),s=this._compressor.compress(r);return s.map(e=>({identifier:q(e),builtEvent:e,userInfo:t.userInfo,context:t.context})).forEach(t=>e.push(t)),e}catch(e){return console.warn(`Failed to compress some analytics events. Error: ${e.message}. Sending ${t.eventArgs.length} uncompressed events instead`),t.eventArgs}},[]);return r.forEach(e=>s.push(e)),s}),this._processFn=e,this._flushBatchTimeout=null,this._eventArgs=[],this._compressor=new ce(t)}}let ue,de;!function(e){e.IN_PROGRESS="inProgress",e.QUEUE="queue",e.RECLAIM_START="reclaimStart",e.RECLAIM_END="reclaimEnd",e.ACK="ack"}(ue||(ue={})),function(e){e[e.RECLAIM_TIMEOUT=1e4]="RECLAIM_TIMEOUT",e[e.RECLAIM_WAIT=500]="RECLAIM_WAIT",e[e.RECLAIM_WAIT_THRESHOLD=2e3]="RECLAIM_WAIT_THRESHOLD"}(de||(de={}));const he=(e,t)=>({[ue.ACK]:`${e}.${t}.${ue.ACK}`,[ue.QUEUE]:`${e}.${t}.${ue.QUEUE}`,[ue.IN_PROGRESS]:`${e}.${t}.${ue.IN_PROGRESS}`,[ue.RECLAIM_START]:`${e}.${t}.${ue.RECLAIM_START}`,[ue.RECLAIM_END]:`${e}.${t}.${ue.RECLAIM_END}`}),me=Object.values(ue);function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function pe(e){for(var t=1;tnew Promise(t=>{setTimeout(t,e)}),be=async(e,t)=>{const{queue:r,inProgress:s}=e.storageKeys,i=JSON.parse(localStorage.getItem(r)||"[]"),n=JSON.parse(localStorage.getItem(s)||"{}"),o=[...i,...Object.entries(n).map(([e,t])=>pe(pe({},t),{},{attemptNumber:t.attemptNumber+1,id:e}))];if(o.length>0){const i=await t(o);if("successful"===i.status)ve(e.storageKeys);else if("partial"===i.status){const e=o.filter(e=>!i.acceptedItemIds.includes(e.id));return localStorage.removeItem(s),localStorage.setItem(r,JSON.stringify(e)),{fullReclaim:!1}}}else ve(e.storageKeys);return{fullReclaim:!0}},ve=e=>{localStorage.removeItem(e.queue),localStorage.removeItem(e.inProgress),localStorage.removeItem(e.reclaimEnd),localStorage.removeItem(e.reclaimStart),localStorage.removeItem(e.ack)};var ye=async(e,t)=>{if("string"!=typeof e||0===e.length)return{fullReclaims:0,partialReclaims:0,failedReclaims:0};const r=p()(),s=(e=>Object.keys(localStorage).filter(t=>t.startsWith(e)).map(e=>e.split(".")).filter(t=>{if(3===t.length&&t[0]===e&&t[2]===ue.ACK)try{const e=localStorage.getItem(t.join("."));if(e){const t=parseInt(e);return de.RECLAIM_TIMEOUT+te[1]))(e).map(s=>(async(e,t)=>{const{ack:r,reclaimStart:s,reclaimEnd:i}=e.storageKeys,n=Date.now();if(localStorage.setItem(s,e.reclaimProcessId),localStorage.setItem(r,n.toString()),await ge(de.RECLAIM_WAIT),Date.now()>n+de.RECLAIM_WAIT_THRESHOLD||localStorage.getItem(s)!==e.reclaimProcessId)throw new Error("Took to long to callback, reclaim abandonded. After reclaimStart.");if(localStorage.setItem(i,e.reclaimProcessId),await ge(de.RECLAIM_WAIT),Date.now()>n+de.RECLAIM_WAIT_THRESHOLD||localStorage.getItem(s)!==e.reclaimProcessId||localStorage.getItem(i)!==e.reclaimProcessId)throw new Error("Took to long to callback, reclaim abandonded. After reclaimEnd.");return be(e,t)})({queuePrefix:e,reclaimProcessId:r,storageKeys:he(e,s)},t)),i=await Promise.allSettled(s),n=i.filter(e=>"rejected"===e.status),o=i.filter(e=>"fulfilled"===e.status).map(e=>e.value),a=o.filter(e=>e.fullReclaim),c=o.filter(e=>!e.fullReclaim);return{failedReclaims:n.length,partialReclaims:c.length,fullReclaims:a.length}};let we,Ie;!function(e){e.INDEXEDDB="indexeddb",e.MEMORY="memory"}(we||(we={})),function(e){e.IGNORE="ignore",e.ABANDON="abandon",e.EVICT="evict"}(Ie||(Ie={}));class Ee extends Error{constructor(e){super("Event Limit reached. Abandoning write to: "+e),Object.setPrototypeOf(this,Ee.prototype),this.name="AbandonWriteError"}}class Oe extends Error{constructor(e){super("Error thrown while processing events in callback: "+(e&&"object"==typeof e&&"toString"in e&&"function"==typeof e.toString&&e.toString()||"string"==typeof e&&e||"Argument passed to CallbackProcessingError was not an Error or string.")),Object.setPrototypeOf(this,Oe.prototype),this.name="CallbackProcessingError"}}class Te extends Error{constructor(e,t){super(`Method '${t}' cannot be called with policy '${e}'.`),this.name="InvalidPolicyError"}}const _e=e=>{if(e&&"object"==typeof e&&"name"in e){const t=e;return"string"==typeof t.name&&("AbandonWriteError"===t.name||"CallbackProcessingError"===t.name||"InvalidPolicyError"===t.name)}return!1};var Se=r(22),ke=r.n(Se);const Pe=(e,t,{id:r,retryAttempts:s,timeToProcessOffset:i})=>({item:e,id:r||p()(),retryAttempts:s||0,timeToBeProcessedAfter:Date.now()+(i||0),namespace:t,timeAdded:Date.now()}),Ae=e=>({logger:e.logger||console,useMemory:e.useMemory||!1,maxAttempts:e.maxAttempts||10,maxEventLimit:e.maxEventLimit||5e3}),De=e=>new Promise((t,r)=>{e.onsuccess=e=>{t(e)},e.onerror=e=>{r(e)}}),je=(e,t)=>{try{"function"==typeof e.commit&&e.commit()}catch(e){throw t.error("Failed to force commit transaction:",e),e}return(e=>new Promise((t,r)=>{e.oncomplete=()=>{t()},e.onerror=e=>{r(e)},e.onabort=e=>{r(e)}}))(e)},Ce=(e,t)=>{e.onerror=e=>{t.warn("Error thrown from request:",e)}};class Ne{constructor(e,t,r,s){if(m()(this,"deleteOldestNEvents",async(e,t)=>{var r;const s=e.index("namespace-timeAdded"),i=IDBKeyRange.bound([this.namespace,0],[this.namespace,Date.now()]),n=s.getAllKeys(i,t),o=await De(n),a=null==o||null===(r=o.target)||void 0===r?void 0:r.result;if(a&&Array.isArray(a)&&a.length>0)try{const t=a.map(t=>this.deleteItemHandler(e,t));await Promise.all(t)}catch(e){throw this.logger.warn("Failed to delete items from indexeddb.",e),e}}),!(e>0))throw Error("Event Limit has to be set higher than 1");this.eventLimit=e,this.namespace=t,this.logger=r,this.deleteItemHandler=s}async insertItems(e,t,r=Ie.ABANDON){const s=[...t];let i=0;switch(r){case Ie.ABANDON:await this.throwIfNotEnoughSpace(e,t.length);break;case Ie.EVICT:i=await this.evictIfNotEnoughSpace(e,t.length);break;case Ie.IGNORE:await this.calculateHowManyEventsWeCanAdd(e,s)}const n=s.map(t=>De(e.add(t)));return await Promise.all(n),await je(e.transaction,this.logger),{items:s,numberOfEvictedItems:i}}async throwIfNotEnoughSpace(e,t){const r=await this.calculateFreeSpace(e);if(rnew Promise(async(e,t)=>{window.setTimeout(()=>t(new Error("Failed to create Indexeddb connection in time.")),15e3);const r=window.indexedDB.open("analytics-web-client",1);r.onupgradeneeded=e=>{if(0!==e.oldVersion)throw new Error("We cannot upgarde the database. Do not do this.");const t=r.result.createObjectStore("analytics-resilience",{keyPath:"id"});t.createIndex("timeToBeProcessedAfter","timeToBeProcessedAfter",{unique:!1}),t.createIndex("retryAttempts","retryAttempts",{unique:!1}),t.createIndex("timeAdded","timeAdded",{unique:!1}),t.createIndex("namespace-timeAdded",["namespace","timeAdded"],{unique:!1})};try{return await De(r),e(r.result)}catch(e){this.logger.error("IndexedDB failed to initialise.",e),t(new Error("IndexedDB failed to initialise: "+e.message))}})),m()(this,"addItem",async(e,t={},r=Ie.ABANDON)=>{const{logger:s,namespace:i}=this,n=Pe(e,i,t),{objectStore:o}=await this.getObjectStoreAndTransaction("readwrite");if(r===Ie.IGNORE)throw new Te(r,"IndexedDbConnector#addItem");try{if(!n.namespace||0===n.namespace.length||"string"!=typeof n.namespace)throw new Error("Namespace not specified");const e=await this.globalEventLimitGuard.insertItems(o,[n],r);if(1===e.items.length)return{item:e.items[0],numberOfEvictedItems:e.numberOfEvictedItems};throw new Error("Incorrect number of items added. Expected: 1, got: "+e.items.length)}catch(e){if(_e(e))throw e;throw s.log("Failed to add item to table",e),new Error("Request to add item to table failed")}}),m()(this,"bulkAddItem",async(e,t=Ie.ABANDON)=>{const{logger:r,namespace:s}=this,i=e.map(e=>{let{item:t}=e,r=ke()(e,Me);return Pe(t,s,r)}),{objectStore:n}=await this.getObjectStoreAndTransaction("readwrite");try{return await this.globalEventLimitGuard.insertItems(n,i,t)}catch(e){if(_e(e))throw e;throw r.log("Failed to add item to table",e),new Error("Request to add item to table failed")}}),m()(this,"getItems",async(e=7)=>{const t=e>0?e:7,{logger:r}=this,s=this.options.maxAttempts,{transaction:i,objectStore:n}=await this.getObjectStoreAndTransaction("readwrite"),o=n.index("timeToBeProcessedAfter"),a=IDBKeyRange.upperBound(Date.now()),c=o.openCursor(a),l=await new Promise(async(e,i)=>{const n=[];let o=0;c.onerror=e=>{r.error("Failed to open cursor:",e),i("Failed to open cursor")},c.onsuccess=i=>{const a=i.target.result;if(a){const i=function(e){for(var t=1;t=s){++o;const e=a.delete();Ce(e,r)}else{const e=a.update(c);Ce(e,r)}n.length{const{transaction:t,objectStore:r}=await this.getObjectStoreAndTransaction("readwrite");try{const s=e.map(e=>this.deleteItem(r,e));await je(t,this.logger),await Promise.all(s)}catch(e){throw this.logger.warn("Failed to delete items from indexeddb.",e),e}}),m()(this,"getItemCount",async()=>{const{transaction:e,objectStore:t}=await this.getObjectStoreAndTransaction("readonly"),r=t.index("timeToBeProcessedAfter"),s=IDBKeyRange.upperBound(Date.now()),i=r.count(s),n=await De(i);return await je(e,this.logger),n.target.result}),m()(this,"processItems",async(e,t=7)=>{const r=await this.getItems(t),{items:s}=r,i=ke()(r,Re);try{const t=await e(s,i),r=s.map(e=>e.id);return await this.deleteItems(r),t}catch(e){throw new Oe(e)}}),m()(this,"deleteItem",async(e,t)=>{const{logger:r}=this;try{await De(e.delete(t))}catch(e){throw r.error("Failed to delete item:",t,e),e}}),m()(this,"getObjectStoreAndTransaction",async e=>{const t=(await this.db).transaction("analytics-resilience",e),r=t.objectStore("analytics-resilience");return{transaction:t,objectStore:r}}),this.options=Ae(t),this.namespace=e,this.logger=this.options.logger,!window.indexedDB)throw this.logger.warn("Browser doesn't support a IndexedDB."),new Error("IndexedDB not supported");this.db=this.startDB(),this.globalEventLimitGuard=new Ne(this.options.maxEventLimit,this.namespace,this.logger,this.deleteItem)}storeType(){return we.INDEXEDDB}}class Ue{constructor(e,t){if(m()(this,"insertItemsToMemoryStore",(e,t)=>{switch(t){case Ie.ABANDON:return this.handleAbandonIfLimitWillExceedPolicy(e);case Ie.EVICT:return Promise.resolve(this.handleEvictOldestIfLimitExceededPolicy(e));case Ie.IGNORE:return this.handleAddAsManyAsPossible(e)}}),!(e>0))throw Error("Event Limit has to be set higher than 1");this.eventLimit=e,this.memoryItemHandlers=t}async handleAbandonIfLimitWillExceedPolicy(e){if(await this.memoryItemHandlers.getItemCount()+e.length>this.eventLimit)throw new Ee(we.MEMORY);return this.memoryItemHandlers.addItems(e),{items:e,numberOfEvictedItems:0}}handleEvictOldestIfLimitExceededPolicy(e){this.memoryItemHandlers.addItems(e);return{items:e,numberOfEvictedItems:this.memoryItemHandlers.evictEventsIfNeeded(this.eventLimit)}}async handleAddAsManyAsPossible(e){const t=this.eventLimit-await this.memoryItemHandlers.getItemCount(),r=t>e.length?e:e.slice(0,t);return this.memoryItemHandlers.addItems(r),{items:r,numberOfEvictedItems:0}}}const Fe=["item"],Be=["items"];function He(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function We(e){for(var t=1;t{let{item:t}=e,r=ke()(e,Fe);return Pe(t,this.namespace,r)});return this.bulkAddItemWrapperType(r,t)}bulkAddItemWrapperType(e,t=Ie.ABANDON){return Promise.resolve(this.globalEventLimitGuard.insertItemsToMemoryStore(e,t))}getItems(e=7){return Promise.resolve(this.synchronousGetItems(e))}synchronousGetItems(e=7){const t=e>0?e:7,r=Date.now(),s=[],i=[];for(let e of this.memoryStore)if(e.timeToBeProcessedAfter<=r&&(s.push(We({},e)),e.timeToBeProcessedAfter+=6e4,e.retryAttempts+=1,e.retryAttempts>=this.options.maxAttempts&&i.push(e)),s.length>=t)break;return i.forEach(e=>{const t=this.memoryStore.indexOf(e);this.memoryStore.splice(t,1)}),{items:s,numberOfDeletedItems:i.length}}deleteItems(e){return this.memoryStore=this.memoryStore.filter(t=>!e.includes(t.id)),Promise.resolve(void 0)}getItemCount(){const e=Date.now(),t=this.memoryStore.filter(t=>t.timeToBeProcessedAfter<=e).length;return Promise.resolve(t)}async processItems(e,t){const r=this.synchronousGetItems(t),{items:s}=r,i=ke()(r,Be),n=s.map(e=>e.id);try{const t=await e(s,i);return await this.deleteItems(n),t}catch(e){throw new Oe(e)}}storeType(){return we.MEMORY}addItems(e){this.memoryStore.push(...e),this.memoryStore.sort((function(e,t){return e.timeAdded-t.timeAdded}))}evictEventsIfNeeded(e){const t=this.memoryStore.length;if(t>e){const r=t-e;return this.memoryStore.splice(0,r),r}return 0}}var Ge=class{constructor(e,t={}){if(this.namespace=e,this.options=Ae(t),!e||0===e.length||"string"!=typeof e)throw new Error("Invalid namespace provided");this.resilience=this.getResilienceMechanism(e,t)}getResilienceMechanism(e,t){if(!t.useMemory)try{return new Le(e,t)}catch(e){var r;null===(r=t.logger)||void 0===r||r.warn("Attempted to create IndexedDbResilience but failed. Using memory instead.")}return new $e(this.namespace,t)}addItem(e,t,r=Ie.ABANDON){return this.runOrFailOver(()=>this.resilience.addItem(e,t,r))}bulkAddItem(e,t=Ie.ABANDON){return this.runOrFailOver(()=>this.resilience.bulkAddItem(e,t))}getItems(e){return this.runOrFailOver(()=>this.resilience.getItems(e))}deleteItems(e){return this.runOrFailOver(()=>this.resilience.deleteItems(e))}getItemCount(){return this.runOrFailOver(()=>this.resilience.getItemCount())}processItems(e,t){return this.runOrFailOver(()=>this.resilience.processItems(e,t))}storeType(){return this.resilience.storeType()}async runOrFailOver(e){try{return await e()}catch(t){if(_e(t))throw t;return this.resilience.storeType()===we.INDEXEDDB&&await this.failOver(),e()}}async failOver(){const e=this.resilience,t=new $e(this.namespace,this.options);this.resilience=t;try{const{items:r}=await e.getItems(this.options.maxEventLimit);if(r.length>0){const s=(await t.bulkAddItemWrapperType(r,Ie.IGNORE)).items.map(e=>e.id);await e.deleteItems(s)}}catch(e){this.options.logger.warn("Unexpected error from ResilienceDb, switching to MemoryDb")}}};let Ke,Ve;!function(e){e.INDEXEDDB="indexeddb",e.MEMORY="memory"}(Ke||(Ke={})),function(e){e[e.ONLINE=0]="ONLINE",e[e.OFFLINE=1]="OFFLINE"}(Ve||(Ve={}));class ze{constructor(){m()(this,"itemsDiscardedByRetry",0),m()(this,"eventCount",0),m()(this,"itemsDiscardedByOverflow",0),m()(this,"resilienceMechanism",Ke.INDEXEDDB),m()(this,"localstorageNumberOfQueuesPurged",0),m()(this,"localstorageNumberOfFullReclaims",0),m()(this,"localstorageNumberOfPartialReclaims",0),m()(this,"localstorageNumberOfFailedReclaims",0)}addToItemsDiscardedByRetryCounter(e=1){this.itemsDiscardedByRetry+=e}addToEventCount(){this.eventCount++}addToItemsDiscardedByOverflowCounter(e=1){this.itemsDiscardedByOverflow+=e}setResilienceMechanism(e){this.resilienceMechanism=e}addToReclaimMetrics(e){this.localstorageNumberOfFullReclaims+=e.fullReclaims,this.localstorageNumberOfPartialReclaims+=e.partialReclaims,this.localstorageNumberOfFailedReclaims+=e.failedReclaims}addToPurgedQueuesMetrics(e){this.localstorageNumberOfQueuesPurged+=e}subtractFromMetrics(e){this.itemsDiscardedByRetry=this.subtractFromCount(this.itemsDiscardedByRetry,e.itemsDiscardedByRetry),this.eventCount=this.subtractFromCount(this.eventCount,e.eventCount),this.itemsDiscardedByOverflow=this.subtractFromCount(this.itemsDiscardedByOverflow,e.itemsDiscardedByOverflow),this.localstorageNumberOfFullReclaims=this.subtractFromCount(this.localstorageNumberOfFullReclaims,e.fullReclaims),this.localstorageNumberOfPartialReclaims=this.subtractFromCount(this.localstorageNumberOfPartialReclaims,e.partialReclaims),this.localstorageNumberOfFailedReclaims=this.subtractFromCount(this.localstorageNumberOfFailedReclaims,e.failedReclaims),this.localstorageNumberOfQueuesPurged=this.subtractFromCount(this.localstorageNumberOfQueuesPurged,e.localstorageQueuesPurged)}subtractFromCount(e,t){return Math.max(e-(t||0),0)}getMetricsPayload(){return{itemsDiscardedByRetry:this.itemsDiscardedByRetry,eventCount:this.eventCount,itemsDiscardedByOverflow:this.itemsDiscardedByOverflow,resilienceMechanism:this.resilienceMechanism,localstorageQueuesPurged:this.localstorageNumberOfQueuesPurged,fullReclaims:this.localstorageNumberOfFullReclaims,partialReclaims:this.localstorageNumberOfPartialReclaims,failedReclaims:this.localstorageNumberOfFailedReclaims}}}let qe=null;var Qe=()=>(qe||(qe=new ze),qe);class Je{constructor(e){window.addEventListener("offline",()=>e(Ve.OFFLINE)),window.addEventListener("online",()=>e(Ve.ONLINE))}getNetworkStatus(){return window.navigator.onLine?Ve.ONLINE:Ve.OFFLINE}}let Xe,Ye,Ze;!function(e){e.IDLE="idle",e.RUNNING="running",e.COMPLETED="completed",e.TIMED_OUT="timedOut"}(Xe||(Xe={})),function(e){e.EXECUTE="execute",e.COMPLETE="complete",e.TIMEOUT="timeout"}(Ye||(Ye={}));class et{constructor(e){if(m()(this,"timeoutHandle",void 0),m()(this,"callbackStatus",Xe.IDLE),!(e>0))throw new Error("CallbackWithTimeout requires timeout period higher than 0");this.timeoutPeriod=e}transitionCallbackStatus(e,t){switch(e){case Xe.IDLE:case Xe.TIMED_OUT:case Xe.COMPLETED:t===Ye.EXECUTE&&(this.callbackStatus=Xe.RUNNING);break;case Xe.RUNNING:switch(t){case Ye.COMPLETE:this.callbackStatus=Xe.COMPLETED;break;case Ye.TIMEOUT:this.callbackStatus=Xe.TIMED_OUT}break;default:this.callbackStatus=e}}executeCallbackWithTimeout(e,t,r){this.transitionCallbackStatus(this.callbackStatus,Ye.EXECUTE),this.timeoutHandle=window.setTimeout(()=>{this.transitionCallbackStatus(this.callbackStatus,Ye.TIMEOUT),r()},this.timeoutPeriod),e(e=>{this.cancelTimeout(),this.getCallbackStatus()!==Xe.TIMED_OUT&&(this.transitionCallbackStatus(this.callbackStatus,Ye.COMPLETE),t(e))})}getCallbackStatus(){return this.callbackStatus}cancelTimeout(){this.timeoutPeriod>0&&this.timeoutHandle&&(window.clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0)}}!function(e){e[e.NOOP=0]="NOOP",e[e.SUCCESS=1]="SUCCESS",e[e.ERROR=2]="ERROR"}(Ze||(Ze={}));const tt=1e3,rt=3e4,st=2,it=0,nt=500,ot=5e3;let at;!function(e){e[e.NONE=0]="NONE",e[e.IMMEDIATE=1]="IMMEDIATE",e[e.WAIT=2]="WAIT"}(at||(at={}));class ct{constructor(e,t){m()(this,"schedule",({immediate:e}={immediate:!1})=>{this.operationInFlight?e?this.queuedSchedule=at.IMMEDIATE:this.queuedSchedule!==at.IMMEDIATE&&(this.queuedSchedule=at.WAIT):(e||this.options.waitInterval<=0)&&0===this.failureCount?(this.clearTimeout(),this.run()):this.failureCount>0&&null===this.scheduledTimeout?this.scheduledTimeout=window.setTimeout(this.run,this.calculateBackoff()):null===this.scheduledTimeout&&(this.scheduledTimeout=window.setTimeout(this.run,this.options.waitInterval))}),m()(this,"stop",()=>{this.clearTimeout(),this.queuedSchedule=at.NONE}),m()(this,"getFailureCount",()=>this.failureCount),m()(this,"getCallbackStatus",()=>this.callbackTimer.getCallbackStatus()),m()(this,"clearTimeout",()=>{null!==this.scheduledTimeout&&(window.clearTimeout(this.scheduledTimeout),this.scheduledTimeout=null)}),m()(this,"run",()=>{this.operationInFlight=!0,this.clearTimeout();try{this.callbackTimer.executeCallbackWithTimeout(this.callback,this.done,()=>this.done(Ze.ERROR))}catch(e){this.done(e)}}),m()(this,"done",e=>{this.operationInFlight=!1,e===Ze.ERROR||this.callbackTimer.getCallbackStatus()===Xe.TIMED_OUT?(this.failureCount++,this.clearTimeout()):e===Ze.SUCCESS&&(this.failureCount=0),this.processQueuedSchedule()}),m()(this,"processQueuedSchedule",()=>{if(this.queuedSchedule!==at.NONE){const e=this.queuedSchedule===at.IMMEDIATE;this.queuedSchedule=at.NONE,this.schedule({immediate:e})}else this.failureCount>0&&this.schedule()}),m()(this,"calculateBackoff",()=>{const{minRetryDelay:e,maxRetryDelay:t,backoffFactor:r,backoffJitterPercentage:s}=this.options;let i=e*r**this.failureCount;if(s){const e=Math.random(),t=Math.floor(e*s*i);Math.floor(10*e)<5?i-=t:i+=t}return Number(Math.min(i,t).toPrecision(1))}),this.options={minRetryDelay:e.minRetryDelay||tt,maxRetryDelay:e.maxRetryDelay||rt,backoffFactor:e.backoffFactor||st,backoffJitterPercentage:e.backoffJitterPercentage||it,waitInterval:void 0!==e.waitInterval?e.waitInterval:nt,callbackTimeoutPeriod:e.callbackTimeoutPeriod||ot},this.scheduledTimeout=null,this.failureCount=0,this.callback=t,this.operationInFlight=!1,this.queuedSchedule=at.NONE,this.callbackTimer=new et(this.options.callbackTimeoutPeriod)}}function lt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function ut(e){for(var t=1;t{e===Ve.OFFLINE?this.scheduler.stop():this.checkEventCountAndReschedule()})}start(e){this.batchFlushCallback=e,this.longPollingScheduler.schedule()}stop(){this.scheduler.stop(),this.longPollingScheduler.stop()}async addItem(e){const t=JSON.parse(JSON.stringify(e)),{numberOfEvictedItems:r}=await this.resilience.addItem(t,{},Ie.EVICT);this.scheduler.schedule(),this.metricsCollector.addToEventCount(),r>0&&this.metricsCollector.addToItemsDiscardedByOverflowCounter(r)}getGlobalRetryCount(){return this.scheduler.getFailureCount()}async scheduleCallback(e){if(this.networkStatus.getNetworkStatus()!==Ve.OFFLINE)try{e(await this.resilience.processItems(this.flush.bind(this),this.options.batchFlushSize))}catch(t){if("CallbackProcessingError"===t.name)return void e(Ze.ERROR)}finally{await this.checkEventCountAndReschedule()}else e(Ze.NOOP)}async checkEventCountAndReschedule(){const e=await this.resilience.getItemCount();e>0&&this.scheduler.schedule({immediate:e>=this.options.batchFlushSize})}async scheduleLongCallBack(e){const t=(e=>{if("string"!=typeof e||0===e.length)return 0;try{const t=Object.keys(localStorage).filter(t=>t&&t.startsWith(e+".")||!1).map(e=>e.split(".")).filter(e=>3===e.length&&me.includes(e[2])).reduce((e,t)=>{const[,r,s]=t;return void 0===e[r]&&(e[r]={}),e[r][s]=!0,e},{}),r=Object.keys(t).filter(e=>!0!==t[e][ue.ACK]);return r.forEach(t=>{const{queue:r,inProgress:s,reclaimStart:i,reclaimEnd:n}=he(e,t);localStorage.removeItem(s),localStorage.removeItem(r),localStorage.removeItem(i),localStorage.removeItem(n)}),r.length}catch(e){}return 0})(this.queuePrefix);this.metricsCollector.addToPurgedQueuesMetrics(t);const r=await ye(this.queuePrefix,async e=>{const t=e.map(e=>({item:e.item,retryAttempts:e.attemptNumber,id:e.id})),{items:r}=await this.resilience.bulkAddItem(t,Ie.IGNORE);return r.length===t.length?{status:"successful"}:{status:"partial",acceptedItemIds:r.map(e=>e.id)}});this.metricsCollector.addToReclaimMetrics(r),await this.checkEventCountAndReschedule(),e(Ze.SUCCESS),this.longPollingScheduler.schedule()}flush(e,t){this.metricsCollector.setResilienceMechanism(this.resilience.storeType());const{batchFlushCallback:r}=this;if(!r)throw new Error("batchFlushCallback has not been set. Call PullBatchableQueue#start first.");return new Promise((s,i)=>{if(e.length<=0)return void s(Ze.NOOP);const n=e.map(e=>{const t=e.item;return e.retryAttempts>0&&t.msg&&(t.msg._metadata||(t.msg._metadata={}),t.msg._metadata.failedAttempts=e.retryAttempts),t});r(n,e=>{e?(t.numberOfDeletedItems>0&&this.metricsCollector.addToItemsDiscardedByRetryCounter(t.numberOfDeletedItems),i(e)):s(Ze.SUCCESS)})})}buildOptions(e){return{backoffFactor:(null==e?void 0:e.backoffFactor)||ht,backoffJitterPercentage:void 0!==(null==e?void 0:e.backoffJitterPercentage)?e.backoffJitterPercentage:mt,batchFlushSize:(null==e?void 0:e.batchFlushSize)||ft,flushBeforeUnload:(null==e?void 0:e.flushBeforeUnload)||pt,flushWaitMs:(null==e?void 0:e.flushWaitMs)||gt,maxItems:(null==e?void 0:e.maxItems)||vt,maxAttempts:(null==e?void 0:e.maxAttempts)||bt,maxRetryDelay:(null==e?void 0:e.maxRetryDelay)||yt,minRetryDelay:(null==e?void 0:e.minRetryDelay)||wt}}}let Et,Ot,Tt;function _t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function St(e){for(var t=1;tfunction(e,t){if(!(t&&t instanceof Function))return e;if(e.msg.type===Et.PAGE||e.msg.type===Et.TRACK){const r=t();r&&Array.isArray(r)&&(e.msg.properties=St(St({},e.msg.properties),{},{xid:r}))}else if(e.msg.traits&&e.msg.type===Et.IDENTIFY){const r=t();r&&Array.isArray(r)&&(e.msg.traits=St(St({},e.msg.traits),{},{xid:r}))}return e}(e,r))}catch(t){return e}}!function(e){e.IDENTIFY="identify",e.PAGE="page",e.TRACK="track"}(Et||(Et={})),function(e){e.XC="xc",e.UID="uid"}(Ot||(Ot={})),function(e){e.NEW="NEW",e.CHANGED="CHANGED",e.EXISTING="EXISTING",e.TIMEOUT="TIMEOUT",e.ERROR="ERROR",e.UNAVAILABLE="UNAVAILABLE",e.MALFORMED="MALFORMED",e.UNKNOWN="UNKNOWN"}(Tt||(Tt={}));var Pt=r(100);function At(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}const Dt=async e=>{var t;const r=null===(t=jt(e))||void 0===t?void 0:t.signal,s=Ct(e.url),i=await fetch(e.url,function(e){for(var t=1;t=500&&i.status<600)throw new Error(`HTTP Error ${i.status} (${i.statusText})`);return i},jt=e=>{if(e.abortController)return e.abortController;if(e.timeout){const t=new AbortController;return setTimeout(()=>{t.abort()},e.timeout),t}},Ct=Object(Pt.a)(e=>new URL(e).origin===location.origin?{}:{mode:"cors",credentials:"include"});var Nt=r(63),Mt=r(461),Rt=r(56);function xt(e,t){var r=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return r<0?-1:r>0?1:r}var Lt=r(326),Ut=r.n(Lt);const Ft={expires:365,secure:"https:"===window.location.protocol,path:"/"};var Bt=new class{constructor(){m()(this,"_data",{}),m()(this,"length",0),m()(this,"setItem",(e,t)=>(this._data[e]=t,this.length=Object.keys(this._data).length,t)),m()(this,"getItem",e=>e in this._data?this._data[e]:null),m()(this,"removeItem",e=>(e in this._data&&delete this._data[e],this.length=Object.keys(this._data).length,null)),m()(this,"clear",()=>{this._data={},this.length=0}),m()(this,"key",e=>Object.keys(this._data)[e])}};function Ht(e){if(!e)return!1;try{const t="awc.storage.support";e.setItem(t,"test_value");const r=e.getItem(t);return e.removeItem(t),"test_value"===r}catch(e){return!1}}class Wt{constructor(e,t={}){m()(this,"getStore",()=>this._store),m()(this,"getItem",e=>this._store.getItem(this.createKey(e))),m()(this,"removeItem",e=>this._store.removeItem(this.createKey(e))),m()(this,"setItem",(e,t)=>{try{this._store.setItem(this.createKey(e),t)}catch(r){(function(e){let t=!1;if(e.code)switch(e.code){case 22:t=!0;break;case 1014:"NS_ERROR_DOM_QUOTA_REACHED"===e.name&&(t=!0)}else-2147024882===e.number&&(t=!0);return t})(r)&&(this.swapToInMemory(),this._store.setItem(this.createKey(e),t))}}),m()(this,"swapToInMemory",()=>{if(this._store===Bt)return;const e=Object.keys(this._store||{});let t;Ht(window.awcInMemoryStorageFallback)?t=window.awcInMemoryStorageFallback:(t=Bt,window.awcInMemoryStorageFallback||(window.awcInMemoryStorageFallback=Bt)),e.forEach(e=>{if(0===e.indexOf(this.getPrefix())){const r=this._store.getItem(e);r&&t.setItem(e,r)}}),this._store=t}),m()(this,"clear",()=>this._store.clear()),m()(this,"key",e=>this._store.key(e)),m()(this,"getPrefix",()=>this._prefix),m()(this,"createKey",e=>this._prefix?`${this.getPrefix()}.${e}`:e),this.options=t;const r=[];(void 0===t.useStoragePrefix||t.useStoragePrefix)&&r.push("awc"),t.envPrefix&&t.envPrefix!==g.PROD&&r.push(t.envPrefix),this._prefix=r.join("-"),Ht(e)?this._store=e:this.swapToInMemory()}}var $t=class extends Wt{constructor(e){let t;try{t=window.localStorage||Bt}catch(e){t=Bt}super(t,e)}};class Gt{constructor(){this.safeStorage=new $t({useStoragePrefix:!1})}set(e,t){return this.safeStorage.setItem(e,t),t}get(e){return this.safeStorage.getItem(e)||void 0}remove(e){this.safeStorage.removeItem(e)}}const Kt=Object(Pt.a)(()=>{const{hostname:e}=location,t=e.split(".");for(let e=1;e<=t.length;e++){const r="."+t.slice(-1*e).join(".");if(Ut.a.set("__awc_tld_test__","tld_test",{domain:r}),"tld_test"===Ut.a.get("__awc_tld_test__"))return Ut.a.remove("__awc_tld_test__"),r}return e});function Vt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function zt(e){for(var t=1;t=7)&&this.setAnonymousId(t),t}{const e=this.cookie.get("ajs_anonymous_id");if(e){const t=JSON.parse(e);return this.store.setItem("ajs_anonymous_id",e),t}}const t=p()();return this.setAnonymousId(t),t}setAnonymousId(e){return this.cookie.set("ajs_anonymous_id",JSON.stringify(e)),this.lastAnonymousIdCookieUpdate=Date.now(),this.store.setItem("ajs_anonymous_id",JSON.stringify(e))}}var Jt=r(1322),Xt=r.n(Jt);function Yt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Zt(e){for(var t=1;t{const t=tr(e);return Xt()(t)},tr=e=>{const t={};return Object.keys(e).forEach(r=>{const s=rr(e,r);void 0!==s&&(Array.isArray(s)?t[r]=s.map(e=>e):t[r]="object"==typeof s&&null!==s?tr(s):s)}),t},rr=(e,t)=>e[t];function sr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function ir(e){for(var t=1;t{const r=this.resilienceQueue.getGlobalRetryCount(),s=this.metrics.getMetricsPayload(),i=ir(ir({},s),{},{httpRetryCount:r});for(let e in i)0===i[e]&&delete i[e];const n=await this.attachXIDs(e),o=(new Date).toISOString(),a={batch:n.map(e=>(e.msg.sentAt=o,e.msg)),sentAt:o,metadata:i};try{const e=await Dt({url:this.gasv3BatchUrl,batch:a,timeout:this.options.requestTimeout});this.metrics.subtractFromMetrics(s),t(null,e)}catch(e){t(e,null)}}),this.user=new Qt,this.options=ir(ir({},e),{},{requestTimeout:e.requestTimeout||1e4,retryQueueOptions:e.retryQueueOptions||{},logger:e.logger||console}),this.xidPromiseCallback=e.xidPromiseGetter(),this.gasv3BatchUrl=`https://${e.apiHost}/batch`,this.metrics=Qe(),this.resilienceQueue=((e,t,r,s)=>new It(e,t,r||{},s))(e.retryQueuePrefix,e.product,this.options.retryQueueOptions,this.options.logger),this.resilienceQueue.start(this.sendEvents)}getUser(){return this.user}async track(e,t,r,s){const i=ir(ir({},this.buildBaseEvent(r,Et.TRACK)),{},{type:Et.TRACK,properties:er(t),event:e}),n=ir(ir({},i),{},{messageId:this.createMessageId()}),o=this.packageEvent(n);await this.resilienceQueue.addItem(o),s&&s()}async page(e,t,r,s){const i=ir(ir({},this.buildBaseEvent(r,Et.PAGE)),{},{type:Et.PAGE,properties:er(t),name:e}),n=ir(ir({},i),{},{messageId:this.createMessageId()}),o=this.packageEvent(n);await this.resilienceQueue.addItem(o),s&&s()}async identify(e,t,r,s){const i=ir(ir({},this.buildBaseEvent(r,Et.IDENTIFY)),{},{type:Et.IDENTIFY,traits:er(t)}),n=ir(ir({},i),{},{messageId:this.createMessageId()}),o=this.packageEvent(n);await this.resilienceQueue.addItem(o),s&&s()}buildBaseEvent(e,t){return{context:(e=>Zt(Zt({},e.context),{},{userAgent:navigator.userAgent}))(er(e)),timestamp:(new Date).toISOString(),type:t,userId:this.user.getUserId(),anonymousId:this.user.getAnonymousId()}}createMessageId(){return"ajs-"+p()()}packageEvent(e){const{apiHost:t}=this.options;return{headers:{"Content-Type":"text/plain"},msg:e,url:`https://${t}/${e.type.charAt(0)}`}}async attachXIDs(e){return this.xidPromiseCallback?kt(e,this.xidPromiseCallback):Promise.resolve(e)}}var or=r(489);const ar=e=>window.history.replaceState({},"",e);var cr=(e,t=ar)=>{const r=window.location.href,s=window.location.hash,i=""!==s?r.replace(s,""):r,{url:n,query:o}=Object(or.parseUrl)(i),a=(c=o,l=e,Object.keys(c).filter(e=>l(c[e],e)).reduce((e,t)=>(e[t]=c[t],e),{}));var c,l;if(Object.keys(a).length>0){const r=((e,t)=>Object.keys(e).filter(r=>!t(e[r],r)).reduce((t,r)=>(t[r]=e[r],t),{}))(o,e);if(Object.keys(r).length>0){t(`${n}?${Object(or.stringify)(r)}${s}`)}else t(`${n}${s}`)}return a};class lr{constructor(){m()(this,"handleOriginParameters",(e,t)=>{const r=Object.keys(e);if(!(r.length>0))throw new Error("Empty parameter mapping provided");const s=r.filter(e=>Object.values(_).indexOf(e)<0);if(s.length>0)throw new Error(`Invalid Origin Tracing Parameter(s) supplied: ${s.join()}!`);const i=cr((e,t)=>r.indexOf(t)>=0,t);return Object.keys(i).map(t=>({[t]:e[t](i[t])})).reduce((e,t)=>Object.assign(e,t),{})}),this._originStore={}}}const ur=/^\d+$/;class dr{constructor(e={}){m()(this,"_generateNewSessionId",()=>{const e=Date.now().toString();return this._safeLocalStorage.setItem("session.id",e),e}),m()(this,"_updateSessionExpiry",()=>{const e=Date.now()+this._sessionExpiryTime;return this._safeLocalStorage.setItem("session.expiry",e.toString()),e}),m()(this,"_debouncedUpdateSessionExpiry",e=>{const{_updateSessionExpiry:t}=this;if(e{t()},this._sessionExpiryDebounce)}),this._sessionExpiryTime=e.sessionExpiryTime||18e5,this._sessionExpiryDebounce=e.sessionExpiryDebounce||5e3,this._sessionExpiryDebounceThresholdPercentage=e.sessionExpiryDebounceThresholdPercentage||.9,this._safeLocalStorage=new $t}getCurrentSessionId(){const e=this._safeLocalStorage.getItem("session.id"),t=parseInt(this._safeLocalStorage.getItem("session.expiry")||"0",10)||0;return this._debouncedUpdateSessionExpiry(t),!e||t<=Date.now()||Number.isNaN(t)?this._generateNewSessionId():ur.test(e)?e:this._generateNewSessionId()}}var hr=class extends Wt{constructor(e){let t;try{t=window.sessionStorage||Bt}catch(e){t=Bt}super(t,e)}};class mr{constructor(){m()(this,"_generateNewTabId",()=>{const e=p()();return this._safeSessionStorage.setItem("tab.id",e),e}),this._safeSessionStorage=new hr}getCurrentTabId(){let e=this._safeSessionStorage.getItem("tab.id");return e||(e=this._generateNewTabId()),e}}function fr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function pr(e){for(var t=1;tnull===this._safeSessionStorage.getItem("taskSessions")||null===this._safeSessionStorage.getItem(gr)||parseInt(this._safeSessionStorage.getItem(gr)||"0",10)t.split("awc.")[1]),m()(this,"_isTaskSessionQueryParam",(e,t)=>t.startsWith("awc.")),m()(this,"getAllTaskSessions",()=>{try{return JSON.parse(this._safeSessionStorage.getItem("taskSessions")||"")}catch(e){return{}}}),m()(this,"_writeToSessionStorage",e=>{try{this._safeSessionStorage.setItem("taskSessions",JSON.stringify(e))}catch(e){}}),m()(this,"_appendTaskSessions",e=>{const t=this.getAllTaskSessions(),r=null===t?e:Object.assign(t,e);this._writeToSessionStorage(r)}),m()(this,"_safelyRemoveKey",(e,t)=>null===e?{}:(delete e[t],e)),m()(this,"createTaskSession",e=>{const t=p()(),r={};return r[e]=t,this._appendTaskSessions(r),t}),m()(this,"createTaskSessionWithProvidedId",(e,t)=>{if("string"!=typeof t)throw new TypeError("invalid taskSessionId, must be string");const r={};r[e]=t,this._appendTaskSessions(r)}),m()(this,"completeTaskSession",e=>{const t=this.getAllTaskSessions(),r=this._safelyRemoveKey(t,e);this._writeToSessionStorage(r)}),m()(this,"formatTaskSessionQueryString",({uri:e,includedTaskSessions:t})=>{const{url:r,query:s}=Object(or.parseUrl)(e),i=this.getAllTaskSessions(),n=t?(o=i,t.reduce((e,t)=>(t in o&&(e[t]=o[t]),e),{})):re(i,Object.values(_));var o;if(0===Object.keys(n).length)return e;const a=pr(pr({},te(n,(e,t)=>"awc."+t)),s);return`${r}?${Object(or.stringify)(a)}`}),m()(this,"stripQueryParameters",()=>{const e=te(cr(this._isTaskSessionQueryParam),this._removeTaskSessionPrefix);this._appendTaskSessions(e)});const e=Date.now();this._safeSessionStorage=new hr;try{this._taskSessionsNotRecentlyInitialised(e)&&(this._writeToSessionStorage({}),this._safeSessionStorage.setItem(gr,e.toString()))}catch(e){}}}var vr=class{constructor(){m()(this,"_bind",()=>{window.testAnalytics||(window.testAnalytics={eventCache:[],events:()=>window.testAnalytics.eventCache,clear:()=>{window.testAnalytics.eventCache=[],localStorage.removeItem("awc.ui.viewed.last.sent"),localStorage.removeItem("awc-staging.ui.viewed.last.sent"),localStorage.removeItem("awc-dev.ui.viewed.last.sent"),localStorage.removeItem("awc-local.ui.viewed.last.sent")}})}),m()(this,"_cache",e=>{window.testAnalytics.eventCache.length>=100&&(window.testAnalytics.eventCache=window.testAnalytics.eventCache.slice(1,window.testAnalytics.eventCache.length)),window.testAnalytics.eventCache.push(e)}),m()(this,"_shouldCacheEvent",()=>this._isDebugCookieEnabled),m()(this,"saveEvent",e=>{e&&this._shouldCacheEvent()&&(window.testAnalytics||this._bind(),e.tags instanceof Array?e.tags.push("synthetic"):e.tags=["synthetic"],this._cache(e))}),this._isDebugCookieEnabled=(()=>{try{return JSON.parse(Ut.a.get("atlassian_analytics_debug")||"false")}catch(e){Ut.a.remove("atlassian_analytics_debug")}return!1})(),this._isDebugCookieEnabled&&this._bind()}};const yr=["embeddedProduct"];function wr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Ir(e){for(var t=1;t{this._startInterval(),this._bindEventListeners()}),m()(this,"stop",()=>{this._stopInterval(),this._unbindEventListeners()}),m()(this,"resetTimers",()=>{this._intervalId&&(this.stop(),this.start())}),m()(this,"_bindEventListeners",()=>{window.addEventListener("focus",this._focusListener),window.addEventListener("blur",this._blurListener)}),m()(this,"_unbindEventListeners",()=>{window.removeEventListener("focus",this._focusListener),window.removeEventListener("blur",this._blurListener)}),m()(this,"_startInterval",()=>{clearInterval(this._intervalId),this._intervalId=setInterval(this._handleInterval,this._delay)}),m()(this,"_stopInterval",()=>{this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)}),m()(this,"_getProductKey",(e,t)=>{let r=e;return t&&(r+="-"+t),r}),m()(this,"_getLastSentTimestamp",(e,t,r)=>(((this._parseLocalStorageData()||{})[r]||{})[t]||{})[e]||null),m()(this,"_parseLocalStorageData",()=>{const e=this._safeLocalStorage.getItem(this._storageKey);try{return JSON.parse(e||"")}catch(e){return this._safeLocalStorage.removeItem(this._storageKey),null}}),m()(this,"_setLastSentTimestamp",(e,t,r)=>{const s=this._parseLocalStorageData()||{},i=s[r]||{},n=i[t]||{};n[e]=Date.now(),i[t]=n,s[r]=i,this._safeLocalStorage.setItem(this._storageKey,JSON.stringify(s))}),m()(this,"_shouldSendEvent",(e,t,r,s)=>{if(!document.hasFocus())return!1;if(t!==w.NONE&&!r||!s)return!1;return Date.now()-this._getLastSentTimestamp(e,r,s)>this._throttle}),m()(this,"_handleInterval",()=>{const e=this._getContext(),{embeddedProduct:t}=e,r=ke()(e,yr);this._sendEvent(this._product,r),t&&this._sendEvent(t,r,!0)}),m()(this,"_sendEvent",(e,t,r=!1)=>{const{subproduct:s,tenantIdType:i,tenantId:n,userId:o,lastScreenEvent:a,attributes:c}=t,l=this._getProductKey(e,s);if(this._shouldSendEvent(l,i,n,o)){this._setLastSentTimestamp(l,n,o);const t=this._createEvent(e,s,r,a,c);this._onEvent(t)}}),m()(this,"_createEvent",(e,t,r,s,i)=>{const n={product:e,source:"ui",action:"viewed",actionSubject:"ui",attributes:i};return r&&(n.subproduct=null,n.version=null,n.attributes=Ir(Ir({},n.attributes),{},{embeddedInEnv:this._productInfo.env,embeddedInProduct:this._productInfo.product,embeddedInSubproduct:t,embeddedInVersion:this._productInfo.version,embeddedInOrigin:this._productInfo.origin,embeddedInPlatform:this._productInfo.platform})),s&&(n.attributes=Ir(Ir({},n.attributes),{},{lastScreenEvent:{name:s.name,attributes:s.attributes}})),n}),!e)throw new Error("Missing productInfo");if(!e.product)throw new Error("Missing productInfo.product");if(!t)throw new Error("Missing getContext callback");if("function"!=typeof t)throw new Error("Invalid getContext, must be function");if(!r)throw new Error("Missing onEvent callback");if("function"!=typeof r)throw new Error("Invalid onEvent, must be function");this._productInfo=e,this._product=e.product,this._getContext=t,this._onEvent=r,this._delay=s.delay||2e3,this._throttle=s.throttle||36e5,this._storageKey=s.storageKey||"ui.viewed.last.sent",this._safeLocalStorage=new $t({envPrefix:this._productInfo.env}),this._focusListener=()=>{this._startInterval()},this._blurListener=()=>{this._stopInterval()}}}function Or(e,t){return e&&"function"==typeof e?()=>{e(t)}:null}let Tr,_r;!function(e){e.XC="xc",e.UID="uid"}(Tr||(Tr={})),function(e){e.NEW="NEW",e.CHANGED="CHANGED",e.EXISTING="EXISTING",e.TIMEOUT="TIMEOUT",e.ERROR="ERROR",e.UNAVAILABLE="UNAVAILABLE",e.MALFORMED="MALFORMED",e.UNKNOWN="UNKNOWN"}(_r||(_r={}));const Sr=(e,t)=>{if(e&&t&&"function"==typeof t){const e=()=>new Promise(e=>{setTimeout(()=>e(()=>[{type:Tr.XC,state:"TIMEOUT"},{type:Tr.UID,state:"TIMEOUT"}]),5e3)}),r=()=>t().catch(()=>()=>[{type:Tr.XC,state:"UNKNOWN"},{type:Tr.UID,state:"UNKNOWN"}]);return Promise.race([r(),e()])}};function kr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Pr(e){for(var t=1;tnull==e||e),m()(this,"_selectHost",({useStargate:e,env:t,useLegacyUrl:r})=>e?r?t===g.PROD?"api-private.atlassian.com/gasv3/api/v1":"api-private.stg.atlassian.com/gasv3/api/v1":window.location.host+"/gateway/api/gasv3/api/v1":t===g.PROD?"as.atlassian.com/api/v1":"as.staging.atl-paas.net/api/v1"),m()(this,"_endsWith",(e,t)=>-1!==e.indexOf(t,e.length-t.length)),m()(this,"_changeInternalUserId",(e,t)=>{this.eventProcessor.getUser().setUserId(e),t&&t!==this.eventProcessor.getUser().getAnonymousId()&&this.eventProcessor.getUser().setAnonymousId(t)}),m()(this,"_createSubproductGetter",e=>N(e,"Cannot get subproduct from the callback. Proceeding without it.")),m()(this,"_createEmbeddedProductGetter",e=>N(e,"Cannot get embeddedProduct from the callback. Proceeding without it.")),m()(this,"_getLastScreenEvent",()=>{try{return JSON.parse(this._safeSessionStorage.getItem("last.screen.event")||"")}catch(e){return this._safeSessionStorage.removeItem("last.screen.event"),null}}),m()(this,"_setLastScreenEvent",e=>{this._safeSessionStorage.setItem("last.screen.event",JSON.stringify({name:e.name,attributes:e.attributes}))}),m()(this,"_shouldEventBeDelayed",e=>{if(!e.tags||-1===e.tags.indexOf("measurement"))return!1;const t=!1!==e.highPriority;return this._isDelayingLowPriorityEvents&&!t}),m()(this,"_fireEvent",(e,t,r,s)=>{switch(t.eventType){case b.UI:case b.OPERATIONAL:case b.TRACK:return this.eventProcessor.track(e,t,r,s);case b.SCREEN:return this.eventProcessor.page(e,t,r,s);case b.IDENTIFY:return this.eventProcessor.identify(e,t,r,s);default:throw new Error("No handler has been defined for events of type "+t.eventType)}}),m()(this,"_fireDelayedEvent",(e,t,r,s)=>{try{this._changeInternalUserId(s.userId,s.anonymousId),t.tags=[...t.tags||[],"sentWithDelay"],this._fireEvent(e,t,r,void 0)}finally{this._changeInternalUserId(this._userInfo.userId,this._userInfo.anonymousId)}}),m()(this,"_delayEvent",(e,t,r,s,i)=>{this._delayQueue.push(e,t,r,s),i&&i()}),m()(this,"_processEvent",(e,t,r,s)=>(this._testingCache.saveEvent(t),this._shouldEventBeDelayed(t)?(this._delayEvent(e,t,r,this._userInfo,s),Promise.resolve()):this._fireEvent(e,t,r,s))),m()(this,"setEmbeddedProduct",e=>{this._productInfo.embeddedProduct=this._createEmbeddedProductGetter(e),this.resetUIViewedTimers()}),m()(this,"clearEmbeddedProduct",()=>{this._productInfo.embeddedProduct=this._createEmbeddedProductGetter(null)}),m()(this,"setSubproduct",e=>{this._productInfo.subproduct=this._createSubproductGetter(e),this.resetUIViewedTimers()}),m()(this,"setOriginTracingHandlers",e=>{const t=this.originTracing.handleOriginParameters(e,this._historyReplaceFn);Object.keys(t).forEach(e=>{void 0!==t[e].taskSessionId&&this.task.createTaskSessionWithProvidedId(e,t[e].taskSessionId)});const r={};return Object.keys(t).forEach(e=>{t[e].originTracingAttributes?r[e]=t[e].originTracingAttributes:console.warn(`Handling method for origin parameter ${e} has not returned any attributes`)}),Object.keys(t).length>0?this.sendOperationalEvent({action:"landed",actionSubject:"origin",source:"webClient",attributes:{originTracesLanded:r}},()=>{}):Promise.resolve()}),m()(this,"setTenantInfo",(e,t)=>{if(!e)throw new Error("Missing tenantIdType");if(e!==w.NONE&&!t)throw new Error("Missing tenantId");if(!k(w,e))throw new Error(`Invalid tenantIdType '${e}', must be an tenantType: [${S(w)}]`);this._tenantInfo={tenantIdType:e,tenantId:t}}),m()(this,"clearTenantInfo",()=>{this._tenantInfo={}}),m()(this,"setOrgInfo",e=>{if(!e)throw new Error("Missing orgId");this._orgInfo={orgId:e}}),m()(this,"clearOrgInfo",()=>{this._orgInfo={}}),m()(this,"setUserInfo",(e,t)=>{!function(e,t){if(!e)throw new Error("Missing userIdType");if(!t)throw new Error("Missing userId");if(!k(I,e))throw new Error(`Invalid userIdType '${e}', must be an userType: [${S(I)}]`)}(e,t),this._changeInternalUserId(t),this._userInfo={userIdType:e,userId:t,anonymousId:this.eventProcessor.getUser().getAnonymousId()}}),m()(this,"clearUserInfo",()=>{this._changeInternalUserId(void 0),this._userInfo={anonymousId:this.eventProcessor.getUser().getAnonymousId()}}),m()(this,"setUIViewedAttributes",e=>{if(!e)throw new Error("Missing uiViewedAttributes");if("object"!=typeof e||Array.isArray(e))throw new Error("Invalid uiViewedAttributes type, should be a non array object");this._uiViewedAttributes=Pr({},e)}),m()(this,"clearUIViewedAttributes",()=>{this._uiViewedAttributes={}}),m()(this,"sendIdentifyEvent",(e,t,r)=>{this.setUserInfo(e,t);const s={userIdType:e,eventType:b.IDENTIFY};return this._processEvent(t,s,this._context,r)}),m()(this,"sendPageEvent",(e,t)=>this.sendScreenEvent(e,t)),m()(this,"sendScreenEvent",(e,t,r)=>{let s,i,n,o;"object"==typeof e?(s=e.name,i=e.attributes,n=e.containers,o=e.tags):(s=e,i=r),function(e){if(!e)throw new Error("Missing name")}(s),X(n);const a=z(this._productInfo,this._tenantInfo,this._userInfo,i,e.nonPrivacySafeAttributes,o,this._tabTracking.getCurrentTabId(),this._sessionTracking.getCurrentSessionId(),this.task.getAllTaskSessions(),this._orgInfo,this._pageLoadId,n),c=Pr({name:s},a);return this._setLastScreenEvent(c),this._processEvent(s,a,this._context,Or(t,c))}),m()(this,"sendTrackEvent",(e,t)=>{!function(e){Z(e)}(e);const r=Q(this._productInfo,this._tenantInfo,this._userInfo,e,b.TRACK,this._tabTracking.getCurrentTabId(),this._sessionTracking.getCurrentSessionId(),this.task.getAllTaskSessions(),this._orgInfo,this._pageLoadId);return this._processEvent(q(e),r,this._context,Or(t,r))}),m()(this,"sendUIEvent",(e,t)=>{!function(e){Z(e)}(e);const r=Q(this._productInfo,this._tenantInfo,this._userInfo,e,b.UI,this._tabTracking.getCurrentTabId(),this._sessionTracking.getCurrentSessionId(),this.task.getAllTaskSessions(),this._orgInfo,this._pageLoadId);return this._processEvent(q(e),r,this._context,Or(t,r))}),m()(this,"sendOperationalEvent",(e,t)=>{!function(e){Z(e)}(e);const r=Q(this._productInfo,this._tenantInfo,this._userInfo,e,b.OPERATIONAL,this._tabTracking.getCurrentTabId(),this._sessionTracking.getCurrentSessionId(),this.task.getAllTaskSessions(),this._orgInfo,this._pageLoadId);return this._processEvent(q(e),r,this._context,Or(t,r))}),m()(this,"startUIViewedEvent",e=>{this.stopUIViewedEvent(),this._uiViewedEvent=new Er(this._productInfo,()=>({embeddedProduct:this._productInfo.embeddedProduct(),subproduct:this._productInfo.subproduct(),tenantIdType:this._tenantInfo.tenantIdType,tenantId:this._tenantInfo.tenantId,userId:this._userInfo.userId,lastScreenEvent:this._getLastScreenEvent(),attributes:this._uiViewedAttributes}),t=>this.sendUIEvent(t,e)),this._uiViewedEvent.start()}),m()(this,"stopUIViewedEvent",()=>{this._uiViewedEvent&&(this._uiViewedEvent.stop(),this._uiViewedEvent=null)}),m()(this,"resetUIViewedTimers",()=>{this._uiViewedEvent&&this._uiViewedEvent.resetTimers()}),m()(this,"startApdexEvent",e=>{this._apdexEvent.start(e)}),m()(this,"getApdexStart",e=>this._apdexEvent.getStart(e)),m()(this,"stopApdexEvent",(e,t)=>{this._apdexEvent.stop(e,t)}),m()(this,"startLowPriorityEventDelay",e=>{if(void 0!==e&&(Number.isNaN(e)||e<=0))throw new Error(`Invalid timeout period: ${e}, must be a number greater than 0`);this._delayTimeout&&clearTimeout(this._delayTimeout);const t=e?Math.min(e,1e4):1e4;this._delayTimeout=setTimeout(()=>this.stopLowPriorityEventDelay(),t),this._delayQueue.cancelFlush(),this._isDelayingLowPriorityEvents=!0}),m()(this,"stopLowPriorityEventDelay",()=>{this._delayTimeout&&(clearTimeout(this._delayTimeout),this._delayTimeout=null),this._delayQueue.startFlush(),this._isDelayingLowPriorityEvents=!1}),m()(this,"onEvent",(e,t)=>{if(!t)throw new Error("Missing analyticsData");if(!t.eventType)throw new Error("Missing analyticsData.eventType");if(t.eventType===b.TRACK)return this.sendTrackEvent(t);if(t.eventType===b.UI)return this.sendUIEvent(t);if(t.eventType===b.OPERATIONAL)return this.sendOperationalEvent(t);if(t.eventType===b.SCREEN)return this.sendScreenEvent(t.name,null,t.attributes);if(t.eventType===b.IDENTIFY)return this.sendIdentifyEvent(t.userIdType,t.userId);throw new Error(`Invalid analyticsData.eventType '${t.eventType}', must be an eventType: [${S(b)}]`)}),!e)throw new Error("Missing productInfo");if(!e.env)throw new Error("Missing productInfo.env");if(!e.product)throw new Error("Missing productInfo.product");if(!k(g,e.env))throw new Error(`Invalid productInfo.env '${e.env}', must be an envType: [${S(g)}]`);if(e.origin){if(!k(y,e.origin))throw new Error(`Invalid productInfo.origin '${e.origin}', must be an originType: [${S(y)}]`)}else e.origin=y.WEB;e.platform?function(e){if(!k(v,e.platform))throw new Error(`Invalid productInfo.platform '${e.platform}', must be a platformType: [${S(v)}]`);if(e.origin===y.DESKTOP&&!k(O,e.platform))throw new Error(`Invalid productInfo.platform '${e.platform}', must be one of [mac, linux, windows]`);if(e.origin===y.WEB&&!k(T,e.platform))throw new Error(`Invalid productInfo.platform '${e.platform}', must be one of [web, mobileWeb]`)}(e):e.platform=e.origin===y.WEB?v.WEB:v.DESKTOP,this.logger=t.logger||console,this._productInfo=Pr(Pr({},e),{},{subproduct:this._createSubproductGetter(e.subproduct),embeddedProduct:this._createEmbeddedProductGetter(e.embeddedProduct)}),this._tenantInfo={},this._orgInfo={},this._uiViewedAttributes={},this._context=function(e){const t=window.screen||{};return{context:{locale:e.locale,screen:{width:t.width,height:t.height,density:window.devicePixelRatio},library:{name:"analytics.js",version:"4.0.0"}}}}(this._productInfo),this._safeSessionStorage=new hr;const r=this._useStargate(t.useStargate),s=t.apiHost||this._selectHost({useStargate:r,env:e.env,useLegacyUrl:t.useLegacyUrl}),i={maxRetryDelay:6e4,minRetryDelay:t.minRetryDelay||1e3,backoffFactor:2,flushWaitMs:t.flushWaitInterval,flushBeforeUnload:t.flushBeforeUnload},n="awc-"+e.env;this.eventProcessor=new nr({apiHost:s,product:e.product,retryQueuePrefix:n,retryQueueOptions:i,xidPromiseGetter:()=>Sr(t.xidConsent,t.xidPromiseFn),logger:this.logger}),this._userInfo={anonymousId:this.eventProcessor.getUser().getAnonymousId()},this._pageVisibility=new P,this._tabTracking=new mr,this._sessionTracking=new dr({sessionExpiryTime:t.sessionExpiryTime}),this.task=new br,this.originTracing=new lr,this._apdexEvent=new C(this.sendOperationalEvent,this._pageVisibility),this._historyReplaceFn="function"==typeof t.historyReplaceFn?t.historyReplaceFn:ar,this._delayQueue=new le(this._fireDelayedEvent,t.delayQueueCompressors),this._testingCache=new vr,this._pageLoadId=p()()}}var Dr=r(333),jr=r.n(Dr);function Cr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Nr(e){for(var t=1;t{if(jr.a.active)throw new Error("DwellTimeHelper should only be initialised once per page load.");this._initDwellTimeCounterAndPolling(),window.addEventListener("beforeunload",()=>{this.stop()})}),m()(this,"stop",()=>{jr.a.active&&this._sendDwellEvent(this._eventData,this._searchSessionId,!0),jr.a.stopAllTimers(),jr.a.resetAllRecordedPageTimes(),jr.a.timeElapsedCallbacks=[]}),m()(this,"newPage",(e,t)=>{ee(e),this.stop(),this._eventData=e,this._searchSessionId=t,this._initDwellTimeCounterAndPolling()}),m()(this,"_initDwellTimeCounterAndPolling",()=>{jr.a.initialize({idleTimeoutInSeconds:this._timing.idleTimeout}),this._pollDwellTime(this._timing.initialPollInterval,this._searchSessionId,this._eventData)}),m()(this,"_pollDwellTime",(e,t,r)=>{jr.a.callAfterTimeElapsedInSeconds(e,()=>{this._sendDwellEvent(r,t,!1),this._pollDwellTime(e*this._timing.pollBackoffRate,t,r)})}),m()(this,"_sendDwellEvent",(e,t,r)=>{const s={dwellTime:jr.a.getTimeOnCurrentPageInMilliseconds(),searchReferrer:t,finalDwellEvent:r};this._trackCallback({action:"dwelled",actionSubject:e.actionSubject,actionSubjectId:e.actionSubjectId,source:e.source,containerType:e.containerType,containerId:e.containerId,containers:e.containers,objectType:e.objectType,objectId:e.objectId,attributes:Nr(Nr({},s),e.attributes),tags:e.tags})}),!e)throw new Error("trackCallback is required for DwellTimeHelper");ee(t),this._trackCallback=e,this._eventData=t,this._searchSessionId=r,this._timing=Nr(Nr({},Mr),s)}}var xr=r(1323);function Lr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Ur(e){for(var t=1;te+e};class Br{constructor(e,t,r,s){if(m()(this,"start",()=>{this.browserInteractionTime.startTimer(),this.browserInteractionTime.addTimeIntervalEllapsedCallback({callback:e=>this._sendDwellEvent(this._eventData,this._searchSessionId,e,!1),timeInMilliseconds:this._timing.initialPollInterval,multiplier:this._timing.multiplierCallback}),window.addEventListener("beforeunload",this._onBeforeUnload)}),m()(this,"stop",()=>{this.browserInteractionTime.isRunning()&&this._sendDwellEvent(this._eventData,this._searchSessionId,this.browserInteractionTime.getTimeInMilliseconds(),!0),this.browserInteractionTime.stopTimer()}),m()(this,"newPage",(e,t)=>{ee(e),this.stop(),this.browserInteractionTime.reset(),this.setEventData(e),this.setSearchSessionId(t),this.start()}),m()(this,"setEventData",e=>{this._eventData=e}),m()(this,"getEventData",()=>this._eventData),m()(this,"setSearchSessionId",e=>{this._searchSessionId=e}),m()(this,"getSearchSessionId",()=>this._searchSessionId),m()(this,"destroy",()=>{this.browserInteractionTime.destroy(),window.removeEventListener("beforeunload",this._onBeforeUnload)}),m()(this,"_onBeforeUnload",()=>{this.stop(),this.destroy()}),m()(this,"_sendDwellEvent",(e,t,r,s)=>{const i={dwellTime:r,searchReferrer:t,finalDwellEvent:s};this._trackCallback({action:"dwelled",actionSubject:e.actionSubject,actionSubjectId:e.actionSubjectId,source:e.source,containerType:e.containerType,containerId:e.containerId,objectType:e.objectType,objectId:e.objectId,attributes:Ur(Ur({},i),e.attributes),tags:e.tags})}),!e)throw new Error("trackCallback is required for DwellTimeHelper");ee(t),this._trackCallback=e,this._eventData=t,this._searchSessionId=r,this._timing=Ur(Ur({},Fr),s),this.browserInteractionTime=new xr.a({idleTimeoutMs:this._timing.idleTimeout,checkCallbacksIntervalMs:500})}}function Hr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function Wr(e){for(var t=1;t0)&&(r.numberOfTimesToInvoke-=1,r.callback())}e.startTimer()},triggerUserHasLeftPage:function(){if(e.active)for(var t=0;t0)&&(r.numberOfTimesToInvoke-=1,r.callback())}e.stopAllTimers()},callAfterTimeElapsedInSeconds:function(t,r){e.timeElapsedCallbacks.push({timeInSeconds:t,callback:r,pending:!0})},checkState:function(){for(var t=0;te.timeElapsedCallbacks[t].timeInSeconds&&(e.timeElapsedCallbacks[t].callback(),e.timeElapsedCallbacks[t].pending=!1);!1===e.idle&&e.currentIdleTimeMs>e.idleTimeoutMs?(e.idle=!0,e.triggerUserHasLeftPage()):e.currentIdleTimeMs+=e.checkStateRateMs},visibilityChangeEventName:void 0,hiddenPropName:void 0,listenForVisibilityEvents:function(){void 0!==document.hidden?(e.hiddenPropName="hidden",e.visibilityChangeEventName="visibilitychange"):void 0!==document.mozHidden?(e.hiddenPropName="mozHidden",e.visibilityChangeEventName="mozvisibilitychange"):void 0!==document.msHidden?(e.hiddenPropName="msHidden",e.visibilityChangeEventName="msvisibilitychange"):void 0!==document.webkitHidden&&(e.hiddenPropName="webkitHidden",e.visibilityChangeEventName="webkitvisibilitychange"),document.addEventListener(e.visibilityChangeEventName,(function(){document[e.hiddenPropName]?e.triggerUserHasLeftPage():e.triggerUserHasReturned()}),!1),window.addEventListener("blur",(function(){e.triggerUserHasLeftPage()})),window.addEventListener("focus",(function(){e.triggerUserHasReturned()})),document.addEventListener("mousemove",(function(){e.resetIdleCountdown()})),document.addEventListener("keyup",(function(){e.resetIdleCountdown()})),document.addEventListener("touchstart",(function(){e.resetIdleCountdown()})),window.addEventListener("scroll",(function(){e.resetIdleCountdown()})),setInterval((function(){e.checkState()}),e.checkStateRateMs)},websocket:void 0,websocketHost:void 0,setUpWebsocket:function(t){if(window.WebSocket&&t){var r=t.websocketHost;try{e.websocket=new WebSocket(r),window.onbeforeunload=function(r){e.sendCurrentTime(t.appId)},e.websocket.onopen=function(){e.sendInitWsRequest(t.appId)},e.websocket.onerror=function(e){console&&console.log("Error occurred in websocket connection: "+e)},e.websocket.onmessage=function(e){console&&console.log(e.data)}}catch(e){console&&console.error("Failed to connect to websocket host. Error:"+e)}}return this},websocketSend:function(t){e.websocket.send(JSON.stringify(t))},sendCurrentTime:function(t){var r={type:"INSERT_TIME",appId:t,timeOnPageMs:e.getTimeOnCurrentPageInMilliseconds(),pageName:e.currentPageName};e.websocketSend(r)},sendInitWsRequest:function(t){var r={type:"INIT",appId:t};e.websocketSend(r)},initialize:function(t){var r=e.idleTimeoutMs||30,s=e.currentPageName||"default-page-name",i=void 0;t&&(r=t.idleTimeoutInSeconds||r,s=t.currentPageName||s,i=t.websocketOptions),e.setIdleDurationInSeconds(r).setCurrentPageName(s).setUpWebsocket(i).listenForVisibilityEvents(),e.startTimer()}};return e}))}).call(this)},489:function(e,t,r){"use strict";var s=r(1936),i=r(596),n=r(1096);function o(e,t){return t.encode?t.strict?s(e):encodeURIComponent(e):e}function a(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function c(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,s){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===s[e]&&(s[e]={}),s[e][t[1]]=r):s[e]=r};case"bracket":return function(e,r,s){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==s[e]?s[e]=[].concat(s[e],r):s[e]=[r]:s[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),s=Object.create(null);return"string"!=typeof e?s:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach((function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),o=t.length>0?t.join("="):void 0;o=void 0===o?null:n(o),r(n(i),o,s)})),Object.keys(s).sort().reduce((function(e,t){var r=s[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((function(e,t){return Number(e)-Number(t)})).map((function(e){return t[e]})):t}(r):e[t]=r,e}),Object.create(null))):s}t.extract=a,t.parse=c,t.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,s){return null===r?[o(t,e),"[",s,"]"].join(""):[o(t,e),"[",o(s,e),"]=",o(r,e)].join("")};case"bracket":return function(t,r){return null===r?o(t,e):[o(t,e),"[]=",o(r,e)].join("")};default:return function(t,r){return null===r?o(t,e):[o(t,e),"=",o(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map((function(s){var i=e[s];if(void 0===i)return"";if(null===i)return o(s,t);if(Array.isArray(i)){var n=[];return i.slice().forEach((function(e){void 0!==e&&n.push(r(s,e,n.length))})),n.join("&")}return o(s,t)+"="+o(i,t)})).filter((function(e){return e.length>0})).join("&"):""},t.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:c(a(e),t)}}},59:function(e,t){e.exports=jQuery}},[[1934,1,0]]]); //# sourceMappingURL=globals-eb94077f92dde0c5a5a0.chunk.js.map