PageSourceSearch

https://readmepreview.com/public/dash/web/insights-replay.d89970b6450998587324.js

js readmepreview.com collected 2026-10-05 22:53:33 UTC 118,825 bytes, 1 lines download raw bytes

1"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[2216],{65181(e,t,n){n.d(t,{plugin:()=>Xt});var r=function(){return r=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},r.apply(this,arguments)};function i(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})}function o(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=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,c])}}}Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;var s,a=n(94221),c=n(37148),l=n(95077),u=n(78226),d=n(78356),h=n(25518),v=n(45811),g=n(90772),f=n(56482),p=n(79951),m="[Amplitude]",y="".concat(m," Session Replay ID"),b=f.e.US,S={enabled:!0},I=1e3,C="".concat(m," Session Replay Debug"),w="amp-mask",k="amp-unmask",P="https://api-sr.amplitude.com/sessions/v2/track",E="https://api-sr.eu.amplitude.com/sessions/v2/track",R="https://api-sr.stag2.amplitude.com/sessions/v2/track",x=("".concat(p.r,"_replay_unsent"),9e6),M=/payload.*exceed/i,T=1024,O="amplitude-sr-iframe";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata",e.TARGETING_DECISION="targeting-decision"}(s||(s={}));var _=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){var t;if(!this.logger)return function(){};var n=this.logger[e];return"function"==typeof n?(null!==(t=n.__rrweb_original__)&&void 0!==t?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),L="medium";var H,D=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return D(e,L,n)}},F=function(e,t){var n,r,i;if(e&&t.urlMaskLevels)try{for(var o=(0,u.Ju)(t.urlMaskLevels),s=o.next();!s.done;s=o.next()){var a=s.value;if(B(a.match).test(e))return a.maskLevel}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null!==(i=t.defaultMaskLevel)&&void 0!==i?i:L},A=function(e,t,n,r){var i,o;if(void 0===t&&(t={defaultMaskLevel:L}),n){if(n.closest("."+w))return!0;var s=(null!==(i=t.maskSelector)&&void 0!==i?i:[]).some(function(e){return n.closest(e)});if(s)return!0;if(n.closest("."+k))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some(function(e){return n.closest(e)});if(a)return!1}return D(e,F(r,t),n)},q=function(e,t,n){return function(r,i){return A(e,t,i,null==n?void 0:n())?r.replace(/[^\s]/g,"*"):r}},N=function(e,t){return function(n,r,i){var o;return"style"===n?r:(null!==(o=null==e?void 0:e.maskAttributes)&&void 0!==o?o:[]).includes(n)&&A("text",e,i,null==t?void 0:t())?r.replace(/[^\s]/g,"*"):r}},U=function(){var e=(0,c.m)();return(null==e?void 0:e.location)?e.location.href:""},j=new Map,B=function(e){var t=j.get(e);if(t)return t;var n="\0TRAIL\0",r="\0MID\0",i="\0DS\0",o="\0ST\0",s="\0QU\0",a=e;a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=a.replace(/\/\*\*$/,n)).replace(/\/\*\*\//g,r)).replace(/\*\*/g,i)).replace(/\*/g,o)).replace(/\?/g,s)).replace(/[.+^${}()|[\]\\]/g,"\\$&")).split(n).join("(/.*)?")).split(r).join("/(.*\\/)?")).split(i).join(".*")).split(o).join(".*")).split(s).join(".");var c=new RegExp("^".concat(a,"$"));return j.set(e,c),c},z=function(e,t){var n,r;try{for(var i=(0,u.Ju)(t),o=i.next();!o.done;o=i.next()){var s=o.value,a=B(s.selector);if(a.test(e))return e.replace(a,s.replacement)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},W=function(){return(0,u.sH)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s;return(0,u.YH)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),(e=(0,c.m)())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=a.sent(),n=t.usage,r=t.quota,i=t.usageDetails,o=n?Math.round(n/T):0,s=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:o,percentOfQuota:s,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return a.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},Y=function(e){var t=(0,u.Cl)({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},J=function(){return{flushMaxRetries:2,logLevel:d.$.Warn,loggerProvider:new h.V,transportProvider:new v.m}},K=function(e){function t(t,n){var r,i,o,s,a,c,l,d,h,v,g=this,f=J();if((g=e.call(this,(0,u.Cl)((0,u.Cl)({transportProvider:f.transportProvider,loggerProvider:new _(n.loggerProvider||f.loggerProvider)},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=f.flushMaxRetries?n.flushMaxRetries:f.flushMaxRetries,g.apiKey=t,g.sampleRate=n.sampleRate||0,g.serverZone=n.serverZone||b,g.configServerUrl=n.configServerUrl,g.trackServerUrl=n.trackServerUrl,g.shouldInlineStylesheet=n.shouldInlineStylesheet,g.version=n.version,g.performanceConfig=n.performanceConfig||S,g.storeType=null!==(r=n.storeType)&&void 0!==r?r:"memory",g.applyBackgroun
1dColorToBlockedElements=null!==(i=n.applyBackgroundColorToBlockedElements)&&void 0!==i&&i,g.enableUrlChangePolling=null!==(o=n.enableUrlChangePolling)&&void 0!==o&&o,g.urlChangePollingInterval=null!==(s=n.urlChangePollingInterval)&&void 0!==s?s:I,g.captureDocumentTitle=null!==(a=n.captureDocumentTitle)&&void 0!==a&&a,void 0!==n.fullSnapshotIntervalMs&&(g.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),g.privacyConfig=(0,u.Cl)((0,u.Cl)({},null!==(c=n.privacyConfig)&&void 0!==c?c:{}),{unmaskSelector:Array.from(new Set((0,u.fX)([".".concat(k)],(0,u.zs)(null!==(d=null===(l=n.privacyConfig)||void 0===l?void 0:l.unmaskSelector)&&void 0!==d?d:[]),!1)))}),n.interactionConfig&&(g.interactionConfig=n.interactionConfig,g.interactionConfig.ugcFilterRules&&function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t);var t}))throw new Error("ugcFilterRules must be an array of objects with valid globs")}(g.interactionConfig.ugcFilterRules)),n.debugMode&&(g.debugMode=n.debugMode),void 0!==n.useWebWorker)g.useWebWorker=n.useWebWorker;else{var p=n;void 0!==(null===(h=p.experimental)||void 0===h?void 0:h.useWebWorker)&&(g.useWebWorker=p.experimental.useWebWorker)}return g.captureAdoptedStyleSheets=null===(v=n.captureAdoptedStyleSheets)||void 0===v||v,n.crossOriginIframes&&(g.crossOriginIframes=n.crossOriginIframes),g}return(0,u.C6)(t,e),t}(g.TS),X=n(77788),Q=n(77631),G="https://app.amplitude.com",V={US:G,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var $="__AMPLITUDE_MESSENGER_INSTANCE__",Z="__AMPLITUDE_MESSENGER__",ee=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?G:t;this[H]=!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,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),n.timeout>0&&setTimeout(function(){s(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,i,o;this.actionHandlers.has(e)&&(null===(o=null===(i=this.logger)||void 0===i?void 0:i.warn)||void 0===o||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var a=(0,Q.Ju)(s),c=a.next();!c.done;c=a.next()){t(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return(0,Q.sH)(this,void 0,void 0,function(){var t,n,r;return(0,Q.YH)(this,function(i){switch(i.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),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,s=i.endpoint;o&&(this.logger=o),s&&this.endpoint===G&&(this.endpoint=s),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,s;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,c=null==a?void 0:a.action;if(c)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
1);else{if("ping"===c)return void r.notify({action:"pong"});var l=r.actionHandlers.get(c);if(l)l(a.data);else{var u=null!==(s=r.pendingMessages.get(c))&&void 0!==s?s:[];u.push(a.data),r.pendingMessages.set(c,u)}}}},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=(0,c.m)();(null==e?void 0:e[Z])===this&&delete e[Z]},e}();function te(e){var t,n=(0,c.m)(),r=null==n?void 0:n[Z];if("object"==typeof(t=r)&&null!==t&&$ in t&&!0===t[$])return r;var i=new ee(e);return n&&(n[Z]=i),i}H=$;var ne="__AMPLITUDE_BACKGROUND_CAPTURE__";var re=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},ie=n(75462),oe=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(oe||{}),se=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(se||{}),ae=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ae||{}),ce=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),le=n(95751),ue=401,de=403,he=429,ve=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new ce(e,t)}return e.prototype.subscribe=function(e,t,n){var r=(0,le.k)(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return(0,Q.sH)(this,void 0,void 0,function(){var e,t=this;return(0,Q.YH)(this,function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?this.fetchPromise:this.isLastFetchInvali
vendor: 1,108 bytes, line 1
1dApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null}),this.fetchPromise):(this.fetchPromise=this.fetch().then(function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},e.prototype.subscribeAll=function(e){return(0,Q.sH)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Q.YH)(this,function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending c
1allback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return(0,Q.sH)(this,void 0,void 0,function(){var n,r;return(0,Q.YH)(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),(0,Q.sH)(this,void 0,void 0,function(){var n,r,i,o,s,a,c=this;return(0,Q.YH)(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,a,l,u,d;return(0,Q.YH)(this,function(h){switch(h.label){case 0:i=!0,s=new AbortController,a=setTimeout(function(){return s.abort()},t),h.label=1;case 1:return h.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:s.signal})];case 2:return(l=h.sent()).ok?[3,4]:[4,l.text()];case 3:return u=h.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(l.status,": ").concat(u)),l.status===ue||l.status===de?(o.logger.error("Remote config client fetch failed with ".concat(l.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):l.status>=400&&l.status<500&&l.status!==he&&(i=!1),[3,6];case 4:return[4,l.json()];case 5:return[2,{value:{remoteConfig:h.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=h.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(a),[7];case 9:return i?r<e-1?[4,new Promise(function(e){return setTimeout(e,c.getJitterDelay(n))})]:[3,11]:[2,"break"];case 10:h.sent(),h.label=11;case 11:return[2]}})},o=this,s=0,l.label=1;case 1:return s<e?[5,i(s)]:[3,4];case 2:if("object"==typeof(a=l.sent()))return[2,a.value];if("break"===a)return[3,4];l.label=3;case 3:return s++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),ge=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,n,r,i,o,s;return(0,u.sH)(this,void 0,void 0,function(){var a,c,l,d,h,v,g,f,p,m,y,b,S,I,C,w,k,P=this;return(0,u.YH)(this,function(E){switch(E.label){case 0:(a=(0,u.Cl)({},this.localConfig)).optOut=this.localConfig.optOut,a.captureEnabled=!0,E.label=1;case 1:return E.trys.push([1,3,,4]),[4,new Promise(function(e,t){P.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:1500},function(n,r){var i;if(P.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(r,":"),JSON.stringify(n,null,2)),n){var o=n,s=o.sr_sampling_config,l=o.sr_privacy_config,u=o.sr_targeting_config,d=null===(i=a.interactionConfig)||void 0===i?void 0:i.ugcFilterRules;a.interactionConfig=o.sr_interaction_config,a.interactionConfig&&d&&(a.interactionConfig.ugcFilterRules=d),a.loggingConfig=o.sr_logging_config,(s||l||u)&&(c={},s&&(c.sr_sampling_config=s),l&&(c.sr_privacy_config=l),u&&(c.sr_targeting_config=u)),e()}else t(new Error("No remote config received"))})})];case 2:return E.sent(),[3,4];case 3:return l=E.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",l),a.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:void 0}];case 4:if(!c)return[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:c}];if(d=c.sr_sampling_config,h=c.sr_privacy_config,v=c.sr_targeting_config,d&&Object.keys(d).length>0?(Object.prototype.hasOwnProperty.call(d,"capture_enabled")?a.captureEnabled=d.capture_enabled:a.captureEnabled=!1,Object.prototype.hasOwnProperty.call(d,"sample_rate")&&(a.sampleRate=d.sample_rate)):(a.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),h){g=null!==(e=a.privacyConfig)&&void 0!==e?e:{},f={defaultMaskLevel:null!==(n=null!==(t=h.defaultMaskLevel)&&void 0!==t?t:g.defaultMaskLevel)&&void 0!==n?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:(0,u.fX)([],(0,u.zs)(new Set((0,u.fX)((0,u.fX)([],(0,u.zs)(null!==(r=g.maskAttributes)&&void 0!==r?r:[]),!1),(0,u.zs)(null!==(i=h.maskAttributes)&&void 0!==i?i:[]),!1))),!1),urlMaskLevels:(0,u.fX)((0,u.fX)([],(0,u.zs)(null!==(o=h.urlMaskLevels)&&void 0!==o?o:[]),!1),(0,u.zs)(null!==(s=g.urlMaskLevels)&&void 0!==s?s:[]),!1)},p=function(e){var t,n,r,i,o,s,a,c,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var h=(0,u.Ju)(null!==(a=e.blockSelector)&&void 0!==a?a:[]),v=h.next();!v.done;v=h.next()){d[v.value]="block"}}catch(e){t={error:e}}finally{try{v&&!v.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var g=(0,u.Ju)(null!==(c=e.maskSelector)&&void 0!==c?c:[]),f=g.next();!f.done;f=g.next()){d[f.value]="mask"}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=g.return)&&i.call(g)}finally{if(r)throw r.error}}try{for(var p=(0,u.Ju)(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),m=p.next();!m.done;m=p.next()){d[m.value]="unmask"}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=p.return)&&s.call(p)}finally{if(o)throw o.error}}return d},m=(0,u.Cl)((0,u.Cl)({},p(g)),p(h));try{for(y=(0,u.Ju)(Object.entries(m)),b=y.next();!b.done;b=y.next())S=(0,u.zs)(b.value,2),I=S[0],"mask"===(C=S[1])?f.maskSelector.push(I):"block"===C?f.blockSelector.push(I):"unmask"===C&&f.unmaskSelector.push(I)}catch(e){w={error:e}}finally{try{b&&!b.done&&(k=y.return)&&k.call(y)}finally{if(w)throw w.error}}a.privacyConfig=(R=f,x=this.localConfig.loggerProvider,M=document.createDocumentFragment(),T=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter(function(e){try{M.querySelector(e)}catch(t){return x.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invali
1d')),!1}return!0}),0!==e.length)return e},R.blockSelector=T(R.blockSelector),R.maskSelector=T(R.maskSelector),R.unmaskSelector=T(R.unmaskSelector),R)}return v&&Object.keys(v).length>0&&(a.targetingConfig=v),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:Y(a)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:c}]}var R,x,M,T})})},e}(),fe=function(e,t){return(0,u.sH)(void 0,void 0,void 0,function(){var n,r;return(0,u.YH)(this,function(i){return n=new K(e,t),r=new ve(e,n.loggerProvider,n.serverZone,t.configServerUrl),[2,new ge(r,n)]})})};function pe(e,t){return t||("STAGING"===e?R:"EU"===e?E:P)}function me(e){if(e.type!==oe.IncrementalSnapshot)return!1;var t=e.data;return t.source===se.Mutation&&!t.isAttachIframe}function ye(e){var t,n,r,i,o=e[0],s=new Map,a=new Map,c=new Map,l=new Map,d=new Map;e.forEach(function(e,t){var n,r,i,o,h=e.data;try{for(var v=(0,u.Ju)(h.adds),g=v.next();!g.done;g=v.next()){var f=g.value;s.has(f.node.id)||s.set(f.node.id,t),a.set(f.node.id,t),d.set(f.node.id,f.parentId)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=v.return)&&r.call(v)}finally{if(n)throw n.error}}try{for(var p=(0,u.Ju)(h.removes),m=p.next();!m.done;m=p.next()){var y=m.value;c.has(y.id)||c.set(y.id,t),l.set(y.id,t)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}});var h=new Set,v=new Set;try{for(var g=(0,u.Ju)(s),f=g.next();!f.done;f=g.next()){var p=(0,u.zs)(f.value,2),m=p[0],y=p[1],b=c.get(m);if(void 0!==b)a.get(m)>=l.get(m)||(y<b?h.add(m):b<y&&v.add(m))}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}var S=new Set;if(h.size>0||v.size>0)for(var I=!0;I;){I=!1;try{for(var C=(r=void 0,(0,u.Ju)(d)),w=C.next();!w.done;w=C.next()){var k=(0,u.zs)(w.value,2),P=k[0],E=k[1];if(!h.has(P)&&!v.has(P)&&!S.has(P)&&(h.has(E)||v.has(E)||S.has(E))){var R=c.get(P),x=s.get(P);void 0!==R&&void 0!==x&&R<x?v.add(P):void 0!==R&&void 0!==x&&R===x?S.add(P):h.add(P),I=!0}}}catch(e){r={error:e}}finally{try{w&&!w.done&&(i=C.return)&&i.call(C)}finally{if(r)throw r.error}}}var M=h.size>0||v.size>0||S.size>0,T=[];e.forEach(function(e,t){var n,r;try{for(var i=(0,u.Ju)(e.data.removes),o=i.next();!o.done;o=i.next()){var a=o.value;h.has(a.id)||(v.has(a.id)&&t>=s.get(a.id)||S.has(a.id)&&(h.has(a.parentId)||v.has(a.parentId)||S.has(a.parentId))||T.push(a))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}});var O=e.flatMap(function(e){return e.data.adds}),_=e.flatMap(function(e){return e.data.texts}),L=e.flatMap(function(e){return e.data.attributes}),H={source:se.Mutation,removes:T,adds:M?O.filter(function(e){return!h.has(e.node.id)&&!v.has(e.node.id)&&!S.has(e.node.id)}):O,texts:M?_.filter(function(e){return!h.has(e.id)&&!v.has(e.id)&&!S.has(e.id)}):_,attributes:M?L.filter(function(e){return!h.has(e.id)&&!v.has(e.id)&&!S.has(e.id)}):L};return(0,u.Cl)((0,u.Cl)({},o),{data:H})}function be(e){if(e.length<=1)return e;for(var t=[],n=0;n<e.length;)if(me(e[n])){for(var r=n+1;r<e.length&&me(e[r]);)r++;t.push(r>n+1?ye(e.slice(n,r)):e[n]),n=r}else t.push(e[n]),n++;return t}var Se=function(){function e(e,t,n,r,i){var o,s=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e,n=t.type,r=t.timestamp,i=t.delay,o=t.data;return null!=i?JSON.stringify({type:n,timestamp:r,delay:i,data:o}):JSON.stringify({type:n,timestamp:r,data:o})},this.addCompressedEventToManager=function(e,t){var n=new Blob([e]).size;n>x?s.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(n/1024)," KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.")):s.eventsManager&&s.deviceId&&s.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:s.deviceId})},this.addCompressedEvent=function(e,t){if(s.worker)try{s.worker.postMessage({event:e,sessionId:t})}catch(n){"DataCloneError"===n.name?s.worker.postMessage(JSON.stringify({event:e,sessionId:t})):s.config.loggerProvider.warn("Unexpected error while posting message to worker:",n)}else{var n=s.compressEvent(e);s.addCompressedEventToManager(n,t)}},this.flushQueue=function(){var e;
1for(s.pendingQueue.length>0&&(e=s.taskQueue).push.apply(e,(0,u.fX)([],(0,u.zs)(s.mergeMutationTasks(s.pendingQueue.splice(0))),!1));s.taskQueue.length>0;){var t=s.taskQueue.shift();if(t){var n=t.event,r=t.sessionId,i=s.compressEvent(n);s.addCompressedEventToManager(i,r)}}s.isProcessing=!1},this.terminate=function(){var e;null===(e=s.worker)||void 0===e||e.terminate()};var a=(0,c.m)();if(this.canUseIdleCallback=a&&"requestIdleCallback"in a,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null===(o=t.performanceConfig)||void 0===o?void 0:o.timeout)||2e3,this.onFullSnapshotProcessed=i,r){t.loggerProvider.log("Enabling web worker for compression");try{var l=new Blob([r],{type:"application/javascript"}),d=URL.createObjectURL(l),h=new Worker(d);h.onerror=function(e){e.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),h.terminate(),s.worker=void 0},h.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;s.addCompressedEventToManager(n,r)},this.worker=h}catch(e){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",e)}}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n,r,i,o;if(e.type===oe.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var s=(0,u.fX)((0,u.fX)([],(0,u.zs)(this.taskQueue.splice(0)),!1),(0,u.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var a=(0,u.Ju)(s),c=a.next();!c.done;c=a.next()){var l=c.value,d=this.compressEvent(l.event);this.addCompressedEventToManager(d,l.sessionId)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.isProcessing=!1}var h=this.compressEvent(e);return this.addCompressedEventToManager(h,t),void(null===(i=this.onFullSnapshotProcessed)||void 0===i||i.call(this))}this.canUseIdleCallback&&(null===(o=this.config.performanceConfig)||void 0===o?void 0:o.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){var t,n=this;for(this.pendingQueue.length>0&&(t=this.taskQueue).push.apply(t,(0,u.fX)([],(0,u.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var r=this.taskQueue.shift();if(r){var i=r.event,o=r.sessionId;this.addCompressedEvent(i,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(e){n.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e.prototype.mergeMutationTasks=function(e){var t,n,r;if(!(null===(r=this.config.performanceConfig)||void 0===r?void 0:r.mergeMutations))return e;if(e.length<=1)return e;for(var i=[],o=0;o<e.length;){for(var s=e[o].sessionId,a=o+1;a<e.length&&e[a].sessionId===s;)a++;var c=be(e.slice(o,a).map(function(e){return e.event}));try{for(var l=(t=void 0,(0,u.Ju)(c)),d=l.next();!d.done;d=l.next()){var h=d.value;i.push({event:h,sessionId:s})}}catch(e){t={error:e}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}o=a}return i},e}(),Ie=n(45730),Ce=n(48386),we="Session replay event batch rejected due to exceeded retry count",ke="Failed to store session replay events in IndexedDB",Pe="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",Ee="1.42.3";function Re(e,t){return(0,u.sH)(this,void 0,void 0,function(){var n,r,i,o,s,a,c,l,d,h,v,g,f,p,m=this;return(0,u.YH)(this,function(y){switch(y.label){case 0:return y.trys.push([0,4,,5]),n=t.CompressionStream,r=new n("gzip"),i=r.writable.getWriter(),o=r.readable.getReader(),s=[],a=(0,u.sH)(m,void 0,void 0,function(){var e,t,n;return(0,u.YH)(this,function(r){switch(r.label){case 0:return[4,o.read()];case 1:if(e=r.sent(),t=e.done,n=e.value,t)return[3,3];s.push(n),r.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,i.write((new TextEncoder).encode(e))];case 1:return y.sent(),[4,i.close()];case 2:return y.sent(),[4,a];case 3:y.sent(),c=s.reduce(function(e,t){return e+t.length},0),l=new Uint8Array(c),d=0;try{for(h=(0,u.Ju)(s),v=h.next();!v.done;v=h.next())g=v.value,l.set(g,d),d+=g.length}catch(e){f={error:e}}
1finally{try{v&&!v.done&&(p=h.return)&&p.call(h)}finally{if(f)throw f.error}}return[2,l];case 4:return y.sent(),[2,null];case 5:return[2]}})})}var xe=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher,i=e.workerScript,o=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.flushPauseUntilMs=0,this.killedSessions=new Set,this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t,i)try{var s=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(s),c=new Worker(a);c.onerror=function(e){var t,r;e.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),c.terminate(),o.worker=void 0;try{for(var i=(0,u.Ju)(o.pendingWorkerRequests),s=i.next();!s.done;s=i.next()){var a=(0,u.zs)(s.value,2)[1];n.warn("Session replay event send failed due to worker crash: ".concat(e.message)),a.resolve()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}o.pendingWorkerRequests.clear()},c.onmessage=function(e){var t=e.data;if("log"===t.type)n.log(t.message);else if("warn"===t.type)n.warn(t.message);else if("payload_too_large"===t.type){var r=o.pendingWorkerRequests.get(t.id);r&&(o.handlePayloadTooLargeResponse(r.context,t.isWaf),r.resolve(),o.pendingWorkerRequests.delete(t.id))}else if("complete"===t.type){var i=o.pendingWorkerRequests.get(t.id);i&&(void 0!==t.skipCode&&o.applyServerDirective(i.context.sessionId,t.skipCode),o.completeRequest({context:i.context}),i.resolve(),o.pendingWorkerRequests.delete(t.id))}},this.worker=c}catch(e){n.error("Failed to create track destination worker, falling back to main-thread sending:",e)}}return e.prototype.sendEventsList=function(e){this.addToQueue((0,u.Cl)((0,u.Cl)({},e),{attempts:0,timeout:0}))},e.prototype.sendBeacon=function(e){var t,n,r=e.events,i=e.sessionId,o=e.deviceId,s=e.apiKey,a=e.serverZone,l=function(e){return new Blob([e]).size},u=r,d=JSON.stringify({version:2,events:u});if(l(d)>65536){for(var h=0,v=u.length;h<v;){var g=Math.floor((h+v+1)/2);l(JSON.stringify({version:2,events:u.slice(0,g)}))<=65536?h=g:v=g-1}u=u.slice(0,h),d=JSON.stringify({version:2,events:u}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(r.length," to ").concat(u.length," events"))}if(0!==u.length){var f=new URLSearchParams({device_id:o,session_id:String(i),type:"replay",api_key:s}),p="".concat(pe(a,this.trackServerUrl),"?").concat(f.toString()),m=(0,c.m)();try{var y=new Blob([d],{type:"application/json"});!1===(null===(n=null===(t=null==m?void 0:m.navigator)||void 0===t?void 0:t.sendBeacon)||void 0===n?void 0:n.call(t,p,y))&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch(e){}}},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter(function(t){return e.killedSessions.has(t.sessionId)?(e.completeRequest({context:t,err:Pe}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:we}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),e.schedule(0)})},e.prototype.schedule=function(e){var t=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),r=n>e?n:e;this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},r)}},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,u.sH)(this,void 0,void 0,function(){var t,n,r,i,o,s,a;return(0,u.YH)(this,function(c){switch(c.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),c.label=1;case 1:c.trys.push([1,6,7,8]),n=(0,u.Ju)(t),r=n.next(),c.label=2;case 2:return r.done?[3,5]:(i=r.value,[4,this.send(i,e)]);case 3:c.sent(),c.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),s={error:o},[3,8];case 7:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}
1return[7];case 8:return[2]}})})},e.prototype.send=function(e,t){return void 0===t&&(t=!0),(0,u.sH)(this,void 0,void 0,function(){var n,r,i,o;return(0,u.YH)(this,function(s){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:Pe})]:(n=e.apiKey)?(r=e.deviceId)?0===(i=this.payloadBatcher({version:1,events:e.events})).events.length?(this.completeRequest({context:e}),[2]):(o=this.worker)?[2,this.sendViaWorker(o,e,i,t)]:[2,this.sendOnMainThread(n,r,e,i,t)]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})]})})},e.prototype.sendViaWorker=function(e,t,n,r){return(0,u.sH)(this,void 0,void 0,function(){var i,o=this;return(0,u.YH)(this,function(s){return i="".concat(++this.sendIdCounter),[2,new Promise(function(s){var a;o.pendingWorkerRequests.set(i,{context:t,resolve:s}),e.postMessage({type:"send",id:i,payload:n,useRetry:r,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:null!==(a=t.flushMaxRetries)&&void 0!==a?a:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:U(),sdkVersion:Ee}})})]})})},e.prototype.sendOnMainThread=function(e,t,n,r,i){var o,s,a,l,d,h,v;return(0,u.sH)(this,void 0,void 0,function(){var g,f,p,m,y,b,S,I,C,w,k,P,E,R,x,M;return(0,u.YH)(this,function(T){switch(T.label){case 0:g=U(),f=Ee,p=n.sampleRate,m=new URLSearchParams({device_id:t,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),y="".concat(null!==(s=null===(o=n.version)||void 0===o?void 0:o.type)&&void 0!==s?s:"standalone","/").concat(null!==(l=null===(a=n.version)||void 0===a?void 0:a.version)&&void 0!==l?l:f),T.label=1;case 1:return T.trys.push([1,13,,14]),b=JSON.stringify(r),(S=(0,c.m)())&&"CompressionStream"in S?[4,Re(b,S)]:[3,3];case 2:return C=T.sent(),[3,4];case 3:C=null,T.label=4;case 4:return w=(I=C)?I.byteLength:new Blob([b]).size,k={headers:(0,u.Cl)({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":f,"X-Client-Library":y,"X-Client-Url":g.substring(0,1e3),"X-Client-Sample-Rate":"".concat(p),"X-Sampling-Hash-Alg":"xxhash32"},I?{"Content-Encoding":"gzip"}:{}),body:null!=I?I:b,method:"POST",keepalive:w<=65536},P="".concat(pe(n.serverZone,this.trackServerUrl),"?").concat(m.toString()),[4,fetch(P,k)];case 5:if(null===(E=T.sent()))return this.completeRequest({context:n,err:"Unexpected error occurred"}),[2];if(E.status>=200&&E.status<300&&(R=null!==(v=null===(h=null===(d=E.headers)||void 0===d?void 0:d.get)||void 0===h?void 0:h.call(d,"X-Session-Replay-Event-Skipped"))&&void 0!==v?v:null,this.applyServerDirective(n.sessionId,R)),i)return[3,6];x="";try{x=JSON.stringify(E.body,null,2)}catch(e){}return this.completeRequest({context:n,success:"".concat(E.status,": ").concat(x)}),[3,12];case 6:if(x="",413!==E.status)return[3,10];T.label=7;case 7:return T.trys.push([7,9,,10]),[4,E.text()];case 8:return x=T.sent(),[3,10];case 9:return T.sent(),[3,10];case 10:return[4,this.handleReponse(E.status,n,x)];case 11:T.sent(),T.label=12;case 12:return[3,14];case 13:return M=T.sent(),this.completeRequest({context:n,err:M}),[3,14];case 14:return[2]}})})},e.prototype.handleReponse=function(e,t,n){return void 0===n&&(n=""),(0,u.sH)(this,void 0,void 0,function(){var r;return(0,u.YH)(this,function(i){switch(i.label){case 0:switch(r=(new Ie.j).buildStatus(e),r){case Ce.n.Success:return[3,1];case Ce.n.Failed:case Ce.n.Timeout:case Ce.n.RateLimit:return[3,2];case Ce.n.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:return i.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,M.test(n)),[3,8];case 5:return 499!==e?[3,7]:[4,this.handleOtherResponse(t)];case 6:return i.sent(),[3,8];case 7:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),i.label=8;case 8:return[2]}})})},e.prototype.handlePayloadTooLargeResponse=function(e,t){var n=t?"WAF (compressed payload too large)":"server (event too large)",r=Math.round(e.events.reduce(function(e,t){return e+t.length},0)/T);if(t)if(1!==e.events.length){this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(r," KB total) — splitting and retrying")),e.onComplete();var i=function(){return Promise.resolve()},o=Math.floor(e.events.length/2);this.sendEventsList((0,u.Cl)((0,u.Cl)({},e),{events:e.events.slice(0,o),onComplete:i})),this.sendEventsList((0,u.Cl)((0,u.Cl)({},e),{events:e.events.slice(o),onComplete:i}))}else this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(r," KB, 1 event) rejected by ").concat(n," — cannot split further")});else this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(r," KB) — not retrying non-WAF 413")})},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/T);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){return(0,u.sH)(this,void 0,void 0,function(){var t;return(0,u.YH)(this,function(n){switch(n.label){case 0:return t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:we}),[2]):[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e.prototype.applyServerDirective=function(e,t){if(null!==t){if("429"===t){var n=this.flushPauseUntilMs>Date.now();return this.flushPauseUntilMs=Date.now()+6e4,void(n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60,"s")))}"4005"!==t&&"4004"!==t||this.killSession(e,t)}else this.flushPauseUntilMs=0},e.prototype.killSession=function(e,t){var n,r,i,o;
1if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>256)try{for(var s=(0,u.Ju)(this.killedSessions),a=s.next();!a.done;a=s.next()){var c=a.value;this.killedSessions.delete(c);break}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(t,"; remaining events will be dropped"));var l=[];try{for(var d=(0,u.Ju)(this.queue),h=d.next();!h.done;h=d.next()){var v=h.value;v.sessionId===e?this.completeRequest({context:v,err:Pe}):l.push(v)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}this.queue=l}},e}(),Me=n(70492),Te=function(){function e(e){var t,n,r,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=7e5,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>=i.maxPersistedEventsSize||!!(Date.now()-i.timeAtLastSplit>i.interval&&e.length)&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!==(t=e.minInterval)&&void 0!==t?t:this.minInterval,this.maxInterval=null!==(n=e.maxInterval)&&void 0!==n?n:this.maxInterval,this.maxPersistedEventsSize=null!==(r=e.maxPersistedEventsSize)&&void 0!==r?r:this.maxPersistedEventsSize}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<=127)t++;else if(r<=2047)t+=2;else if(r>=55296&&r<=56319){var i=n+1<e.length?e.charCodeAt(n+1):NaN;i>=56320&&i<=57343?(t+=4,n++):t+=3}else t+=3}return t},e.prototype.getEventsArraySize=function(e){var t,n,r=0;try{for(var i=(0,u.Ju)(e),o=i.next();!o.done;o=i.next()){var s=o.value;r+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}(),Oe=function(e,t,n){var r;"object"==typeof(r=n)&&null!==r&&"AbortError"===r.name?e.debug(t):e.warn(t)};var _e="sessionCurrentSequence",Le="sequencesToSend",He=5e3;function De(e,t,n){var r=setTimeout(n,t);return e.then(function(){return clearTimeout(r)},function(){return clearTimeout(r)}),function(){return clearTimeout(r)}}var Fe,Ae,qe,Ne=function(e){var t,n;return e.objectStoreNames.contains(_e)||(n=e.createObjectStore(_e,{keyPath:"sessionId"})),e.objectStoreNames.contains(Le)||(t=e.createObjectStore(Le,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Ue=function(e){return(0,u.sH)(void 0,void 0,void 0,function(){return(0,u.YH)(this,function(t){switch(t.label){case 0:return[4,(n=(0,Me.P2)(e,1,{upgrade:Ne}),r=2e3,i="IDB openDB timed out",void 0===i&&(i="IDB operation timed out"),new Promise(function(e,t){var o=setTimeout(function(){return t(new Error("".concat(i," after ").concat(r,"ms")))},r);n.then(function(t){clearTimeout(o),e(t)},function(e){clearTimeout(o),t(e)})}))];case 1:return[2,t.sent()]}var n,r,i})})},je=function(e){function t(t){var n,r=this;return(r=e.call(this,t)||this).consecutiveFailures=0,r.hasTriggeredFallback=!1,r.getSequencesToSend=function(){return(0,u.sH)(r,void 0,void 0,function(){var e,t,n,r,i,o,s,a,c,l,d=this;return(0,u.YH)(this,function(u){switch(u.label){case 0:e=!1,t=!1,u.label=1;case 1:return u.trys.push([1,6,,7]),n=[],(r=this.db.transaction("sequencesToSend")).done.catch(function(n){e||t||(Oe(d.loggerProvider,"".concat(ke,": ").concat(n),n),d.recordFailure())}),i=De(r.done,He,function(){e||t||(t=!0,Oe(d.loggerProvider,"".concat(ke,": transaction timed out")),d.recordFailure())}),[4,r.store.openCursor()];case 2:o=u.sent(),u.label=3;case 3:return o?(s=o.value,a=s.sessionId,c=s.events,n.push({events:c,sequenceId:o.key,sessionId:a}),[4,o.continue()]):[3,5];case 4:return o=u.sent(),[3,3];case 5:return this.recordSuccess(),i(),[2,n];case 6:return l=u.sent(),t||(e=!0,Oe(this.loggerProvider,"".concat(ke,": ").concat(l),l),this.recordFailure()),[3,7];case 7:return[2,void 0]}})})},r.storeCurrentSequence=function(e){return(0,u.sH)(r,void 0,void 0,function(){var t,n,r,i,o,s,a,c,l=this;return(0,u.YH)(this,function(d){switch(d.label){case 0:t=!1,n=!1,d.label=1;case 1:return d.trys.push([1,5,,6]),(r=this.db.transaction([_e,Le],"readwrite")).done.catch(function(e){t||n||(Oe(l.loggerProvider,"".concat(ke,": ").concat(e),e),l.recordFailure())}),i=De(r.done,He,function(){t||n||(n=!0,Oe(l.loggerProvider,"".concat(ke,": transaction timed out")),l.recordFailure())}),[4,r.objectStore(_e).get(e)];case 2:return!(o=d.sent())||o.tabId&&o.tabId!==this.tabId||0===o.events.length?(i(),[2,void 0]):[4,r.objectStore(Le).put({sessionId:e,events:o.events,tabId:this.tabId})];case 3:return s=d.sent(),[4,r.objectStore(_e).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return d.sent(),this.recordSuccess(),i(),o.tabId,a=(0,u.Tt)(o,["tabId"]),[2,(0,u.Cl)((0,u.Cl)({},a),{sessionId:e,sequenceId:s})];case 5:return c=d.sent(),n||(t=!0,Oe(this.loggerProvider,"".concat(ke,": ").concat(c),c),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},r.addEventToCurrentSequence=function(e,t){return(0,u.sH)(r,void 0,void 0,function(){var n,r,i,o,s,a,c,l,d,h=this;return(0,u.YH)(this,function(u){switch(u.label){case 0:n=!1,r=!1,u.label=1;case 1:return u.trys.push([1,13,,14]),(i=this.db.transaction([_e,Le],"readwrite")).done.catch(function(e){n||r||(Oe(h.loggerProvider,"".concat(ke,": ").concat(e),e),h.recordFailure())}),o=De(i.done,He,function(){n||r||(r=!0,Oe(h.loggerProvider,"".concat(ke,": transaction timed out")),h.recordFailure())}),[4,i.objectStore(_e).get(e)];case 2:return(null==(s=u.sent())?void 0:s.tabId)&&s.tabId!==this.tabId?s.events.length>0?[4,i.objectStore(Le).put({sessionId:e,events:s.events,tabId:s.tabId})]:[3,4]:[3,6];case 3:u.sent(),u.label=4;case 4:return[4,i.objectStore(_e).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:return u.sent(),this.recordSuccess(),o(),[2,void 0];case 6:return(a=s)?[3,8]:[4,i.objectStore(_e).put({sessionId:e,events:[t],tabId:this.tabId})];case 7:return u.sent(),this.recordSuccess(),o(),[2,void 0];case 8:return this.shouldSplitEventsList(a.events,t)?[3,10]:[4,i.objectStore(_e).put({sessionId:e,events:a.events.concat(t),tabId:this.tabId})];case 9:return u.sent(),this.recordSuccess(),o(),[2,void 0];case 10:return c=a.events,[4,i.objectStore(_e).put({sessionId:e,events:[t],tabId:this.tabId})];case 11:return u.sent(),[4,i.objectStore(Le).put({sessionId:e,events:c,tabId:this.tabId})];case 12:return l=u.sent(),this.recordSuccess(),o(),[2,{events:c,sessionId:e,sequenceId:l}];case 13:return d=u.sent(),r||(n=!0,Oe(this.loggerProvider,"".concat(ke,": ").concat(d),d),this.recordFailure()),[3,14];case 14:return[2,void 0]}})})},r.storeSendingEvents=function(e,t){return(0,u.sH)(r,void 0,void 0,function(){var n,r;return(0,u.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.db.put(Le,{sessionId:e,events:t,tabId:this.tabId})];case 1:return n=i.sent(),this.recordSuccess(),[2,n];case 2:return r=i.sent(),Oe(this.loggerProvider,"".concat(ke,": ").concat(r),r),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},r.cleanUpSessionEventsStore=function(e,t){return(0,u.sH)(r,void 0,void 0,function(){var e;return(0,u.YH)(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Le,t)];case 2:return n.sent(),this.recordSuccess(),[3,4];case 3:return e=n.sent(),Oe(this.loggerProvider,"".concat(ke,": ").concat(e),e),this.recordFailure(),[3,4];case 4:return[2]}})})},r.db=t.db,r.tabId=t.tabId,r.onPersistentFailure=t.onPersistentFailure,r.consecutiveFailureThreshold=null!==(n=t.consecutiveFailureThreshold)&&void 0!==n?n:1,r}return(0,u.C6)(t,e),t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,null===(e=this.onPersistentFailure)||void 0===e||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,n){var r;return(0,u.sH)(this,void 0,void 0,function(){var i,o,s,a,c;return(0,u.YH)(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),i="replay"===e?"":"_".concat(e),o="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(i),[4,Ue(o)];case 1:return s=l.sent(),a=null!==(r=n.tabId)&&void 0!==r?r:function(){try{return crypto.randomUUID()}catch(e){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}(),[2,new t((0,u.Cl)((0,u.Cl)({},n),{db:s,tabId:a}))];case 2:return c=l.sent(),Oe(n.loggerProvider,"".concat(ke,": ").concat(c),c),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,u.sH)(this,void 0,void 0,function(){var t,n,r,i,o,s,a,c;return(0,u.YH)(this,function(l){switch(l.label){case 0:return e?[4,this.db.get("sessionCurrentSequence",e)]:[3,2];case 1:return(i=l.sent())?i.tabId&&i.tabId!==this.tabId?[2,void 0]:(i.tabId,[2,[o=(0,u.Tt)(i,["tabId"])]]):[2,void 0];case 2:t=[],l.label=3;case 3:return l.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:n=u.Ju.apply(void 0,[l.sent()]),r=n.next(),l.label=5;case 5:if(r.done)return[3,7];if((i=r.value).tabId&&i.tabId!==this.tabId)return[3,6];i.tabId,o=(0,u.Tt)(i,["tabId"]),t.push(o),l.label=6;case 6:return r=n.next(),[3,5];case 7:return[3,10];case 8:return s=l.sent(),a={error:s},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}
1return[7];case 10:return[2,t]}})})},t}(Te),Be=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return(0,u.C6)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,n=(0,u.fX)([],(0,u.zs)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},t.prototype.getSequencesToSend=function(){return(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(e){return[2,Object.entries(this.finalizedSequences).map(function(e){var t=(0,u.zs)(e,2),n=t[0],r=t[1],i=r.sessionId,o=r.events;return{sequenceId:Number(n),sessionId:i,events:o}})]})})},t.prototype.storeCurrentSequence=function(e){return(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,u.sH)(this,void 0,void 0,function(){var n;return(0,u.YH)(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},t.prototype.storeSendingEvents=function(e,t){return(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(Te),ze=function(e){var t=e.config,n=e.minInterval,r=e.maxInterval,i=e.type,o=e.payloadBatcher,s=e.storeType,a=e.trackDestinationWorkerScript;return(0,u.sH)(void 0,void 0,void 0,function(){function e(e){return void 0===e&&(e=!1),(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(t){return[2,c.flush(e)]})})}var c,l,d,h,v,g,f,p,m,y,b,S,I,C,w;return(0,u.YH)(this,function(k){switch(k.label){case 0:return c=new xe((0,u.Cl)((0,u.Cl)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:o,workerScript:a})),l=function(){return new Be({loggerProvider:t.loggerProvider,maxInterval:r,minInterval:n})},h=!1,g=function(){return(0,u.sH)(void 0,void 0,void 0,function(){var e,n,r;return(0,u.YH)(this,function(i){switch(i.label){case 0:return h?(h=!1,t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),d?[4,v.getSequencesToSend()]:[3,2]):[2];case 1:return n=i.sent(),[3,3];case 2:n=void 0,i.label=3;case 3:return e=n,v=l(),e&&d&&(r=d,e.forEach(function(e){S({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})),[2]}})})},f=function(){return(0,u.sH)(void 0,void 0,void 0,function(){var e;return(0,u.YH)(this,function(o){switch(o.label){case 0:return[4,je.new(i,{loggerProvider:t.loggerProvider,minInterval:n,maxInterval:r,apiKey:t.apiKey,onPersistentFailure:function(){g()}})];case 1:return(e=o.sent())?(h=!0,[2,e]):(t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,l()])}})})},"idb"!==s?[3,2]:[4,f()];case 1:return p=k.sent(),[3,3];case 2:p=l(),k.label=3;case 3:return v=p,m=[],y=0,b=function(e){if(!(e<=y)){var t=Math.min(e-y,m.length);t>0&&(m.splice(0,t),y=e)}},S=function(e){var n=e.events,r=e.sessionId,o=e.deviceId,s=e.sequenceId,a=n.map(function(e){return{event:e,bytes:new Blob([e]).size}}),l=a.filter(function(e){return e.bytes>x});l.length>0&&t.loggerProvider.warn("Dropping ".concat(l.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(l.map(function(e){return"".concat(Math.round(e.bytes/1024)," KB")}).join(", "),". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));var d=l.length>0?a.filter(function(e){return e.bytes<=x}).map(function(e){return e.event}):n;0!==d.length?(t.debugMode&&W().then(function(e){var n=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(i))}).catch(function(){}),c.sendEventsList({events:d,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:i,onComplete:function(){return(0,u.sH)(void 0,void 0,void 0,function(){return(0,u.YH)(this,function(e){switch(e.label){case 0:return[4,v.cleanUpSessionEventsStore(r,s)];case 1:return e.sent(),[2]}})})}})):v.cleanUpSessionEventsStore(r,s).catch(function(e){t.loggerProvider.warn("Failed to clean up session replay events store:",e)})},I=function(e){var n=e.sessionId,r=e.deviceId;d=r;var i=y+m.length;v.storeCurrentSequence(n).then(function(e){e&&(b(i),S({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r}))}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})},C=function(e){var n=e.deviceId;return(0,u.sH)(void 0,void 0,void 0,function(){var e;return(0,u.YH)(this,function(r){switch(r.label){case 0:return d=n,[4,v.getSequencesToSend()];case 1:return(null==(e=r.sent())?void 0:e.length)?(t.loggerProvider.log("Draining ".concat(e.length," stored sequence(s) from previous session.")),e.forEach(function(e){
1S({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n})}),[2]):[2]}})})},w=function(e){var n=e.event,r=e.sessionId,i=e.deviceId;d=i;var o=y+m.length;m.push(n.data),v.addEventToCurrentSequence(r,n.data).then(function(e){e&&(b(o),S({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i}))}).catch(function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)})},[2,{sendCurrentSequenceEvents:I,addEvent:w,sendStoredEvents:C,flush:e,getBeaconEvents:function(){return(0,u.fX)([],(0,u.zs)(m),!1)},trackDestination:c}]}})})},We=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach(function(e){n.set(e.name,e.manager)}),this.managers=n}return e.prototype.sendStoredEvents=function(e){return(0,u.sH)(this,void 0,void 0,function(){var t;return(0,u.YH)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,i=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},e.prototype.flush=function(e){return(0,u.sH)(this,void 0,void 0,function(){var t;return(0,u.YH)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e}();function Ye(e,t){if(qe=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};Fe=(0,u.Cl)((0,u.Cl)({},n),t),Ae=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Fe.root,n);var r=Je(e,"all",function(){return Je(e,"two",function(){return Je(e,"one",function(){return Je(e,"none")})})});if(r){var i=nt(rt(r,e));return i.length>0&&(r=i[0]),Xe(r)}throw new Error("Selector was not found.")}function Je(e,t,n){for(var r=null,i=[],o=e,s=0,a=function(){var e,a,c=(new Date).getTime()-qe.getTime();if(void 0!==Fe.timeoutMs&&c>Fe.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var l=Ze(function(e){var t=e.getAttribute("id");if(t&&Fe.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(o))||Ze.apply(void 0,(0,u.fX)([],(0,u.zs)(function(e){var t=Array.from(e.attributes).filter(function(e){return Fe.attr(e.name,e.value)});return t.map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})}(o)),!1))||Ze.apply(void 0,(0,u.fX)([],(0,u.zs)(function(e){var t=Array.from(e.classList).filter(Fe.className);return t.map(function(e){return{name:"."+CSS.escape(e),penalty:1}})}(o)),!1))||Ze(function(e){var t=e.tagName.toLowerCase();if(Fe.tagName(t))return{name:t,penalty:2};return null}(o))||[{name:"*",penalty:3}],d=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(o);if("all"==t)d&&(l=l.concat(l.filter($e).map(function(e){return Ve(e,d)})));else if("two"==t)l=l.slice(0,1),d&&(l=l.concat(l.filter($e).map(function(e){return Ve(e,d)})));else if("one"==t){var h=(0,u.zs)(l=l.slice(0,1),1)[0];d&&$e(h)&&(l=[Ve(h,d)])}else"none"==t&&(l=[{name:"*",penalty:3}],d&&(l=[Ve(l[0],d)]));try{for(var v=(e=void 0,(0,u.Ju)(l)),g=v.next();!g.done;g=v.next()){(h=g.value).level=s}}catch(t){e={error:t}}finally{try{g&&!g.done&&(a=v.return)&&a.call(v)}finally{if(e)throw e.error}}if(i.push(l),i.length>=Fe.seedMinLength&&(r=Ke(i,n)))return"break";o=o.parentElement,s++};o;){if("break"===a())break}return r||(r=Ke(i,n)),!r&&n?n():r}function Ke(e,t){var n,r,i=nt(tt(e));if(i.length>Fe.threshold)return t?t():null;try{for(var o=(0,u.Ju)(i),s=o.next();!s.done;s=o.next()){var a=s.value;if(Ge(a))return a}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null}function Xe(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var i=e[r].level||0;n=t.level===i-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function Qe(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function Ge(e){var t=Xe(e);switch(Ae.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function Ve(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function $e(e){return"html"!==e.name&&!e.name.startsWith("#")}function Ze(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(et);return n.length>0?n:null}function et(e){return null!=e}function tt(e,t){var n,r,i,o,s,a;return void 0===t&&(t=[]),(0,u.YH)(this,function(c){switch(c.label){case 0:if(!(e.length>0))return[3,9];c.label=1;case 1:c.trys.push([1,6,7,8]),n=(0,u.Ju)(e[0]),r=n.next(),c.label=2;case 2:return r.done?[3,5]:(i=r.value,[5,(0,u.Ju)(tt(e.slice(1,e.length),t.concat(i)))]);case 3:c.sent(),c.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),s={error:o},[3,8];case 7:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}
1return[7];case 8:return[3,11];case 9:return[4,t];case 10:c.sent(),c.label=11;case 11:return[2]}})}function nt(e){return(0,u.fX)([],(0,u.zs)(e),!1).sort(function(e,t){return Qe(e)-Qe(t)})}function rt(e,t,n){var r,i,o;return void 0===n&&(n={counter:0,visited:new Map}),(0,u.YH)(this,function(s){switch(s.label){case 0:if(!(e.length>2&&e.length>Fe.optimizedMinLength))return[3,5];r=1,s.label=1;case 1:return r<e.length-1?n.counter>Fe.maxNumberOfTries?[2]:(n.counter+=1,(i=(0,u.fX)([],(0,u.zs)(e),!1)).splice(r,1),o=Xe(i),n.visited.has(o)?[2]:Ge(i)&&function(e,t){return Ae.querySelector(Xe(e))===t}(i,t)?[4,i]:[3,4]):[3,5];case 2:return s.sent(),n.visited.set(o,!0),[5,(0,u.Ju)(rt(i,t,n))];case 3:s.sent(),s.label=4;case 4:return r++,[3,1];case 5:return[2]}})}var it=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)}),{version:t,events:r}},ot=function(e){var t=e.version,n=e.events,r=[];n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)});var i=r.reduce(function(e,t){var n=t.x,r=t.y,i=t.selector,o=t.timestamp,s=o-o%36e5,a="".concat(n,":").concat(r,":").concat(null!=i?i:"",":").concat(s);return e[a]?e[a].count+=1:e[a]=(0,u.Cl)((0,u.Cl)({},t),{timestamp:s,count:1}),e},{});return{version:t,events:Object.values(i)}},st=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,o=e.mirror,s=e.ugcFilterRules,a=e.performanceOptions;return function(e){if(e.type===ae.Click){var l=(0,c.m)();if(l){var u=l.location,d=l.innerHeight,h=l.innerWidth;if(u){var v=e.x,g=e.y;if(void 0!==v&&void 0!==g){var f,p=o.getNode(e.id);if(p)try{f=Ye(p,a)}catch(e){n.logger.debug("error resolving selector from finder")}var m=z(u.href,s),y={x:v+n.scrollWatcher.currentScrollX,y:g+n.scrollWatcher.currentScrollY,selector:f,viewportHeight:d,viewportWidth:h,pageUrl:m,timestamp:Date.now(),type:"click"},b=i();b&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(y)},deviceId:b})}}}}}},this.logger=e,this.scrollWatcher=t};function at(){var e=(0,c.m)();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function ct(){var e=(0,c.m)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var lt=function(){function e(e,t){var n=(0,c.m)();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=pe(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,i=n.type,o=new URLSearchParams({device_id:e,session_id:String(r),type:String(i),api_key:this.apiKey}),s="".concat(this.basePageUrl,"?").concat(o.toString());this.sendBeacon(s,t)||this.sendXhr(s,t)},e}(),ut=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,i,o,s,a=e(),l=(0,c.m)();if(l&&a){var u=null!==(r=l.scrollX)&&void 0!==r?r:0,d=null!==(i=l.scrollY)&&void 0!==i?i:0;(u>0||d>0)&&n.update({id:1,x:u,y:d}),n.transport.send(a,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:at(),viewportWidth:ct(),pageUrl:z(l.location.href,null!==(s=null===(o=n.config.interactionConfig)||void 0===o?void 0:o.ugcFilterRules)&&void 0!==s?s:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=ct(),this._maxScrollHeight=at(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new lt(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=ct();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=at();this._maxScrollY=e.y;var o=e.y+i;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},e}(),dt=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},ht=function(){var e=this;this.dbs={},this.createStore=function(t){return(0,u.sH)(e,void 0,void 0,function(){return(0,u.YH)(this,function(e){switch(e.label){case 0:return[4,(0,Me.P2)(t,1,{upgrade:function(e){e.objectStoreNames.contains("sessionTargetingMatch")||e.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return(0,u.sH)(e,void 0,void 0,function(){var e,n;return(0,u.YH)(this,function(r){switch(r.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId;return(0,u.sH)(e,void 0,void 0,function(){var e,t,o,s;return(0,u.YH)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(o=a.sent())?void 0:o.targetingMatch];case 3:return s=a.sent(),Oe(n,"Failed to get targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,o=t.targetingMatch;return(0,u.sH)(e,void 0,void 0,function(){var e,t,s;return(0,u.YH)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.put("sessionTargetingMatch",{targetingMatch:o,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,a.sent()];case 3:return s=a.sent(),Oe(n,"Failed to store targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return(0,u.sH)(e,void 0,void 0,function(){var e,t,o,s,a,c,l,d;return(0,u.YH)(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=u.sent(),t=String(i),[4,(o=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:s=u.sent(),a=0,u.label=3;case 3:return a<s.length?(c=s[a],l=Date.now()-c.lastUpdated,c.sessionId!==t&&l>1728e5?[4,o.store.delete(c.sessionId)]:[3,5]):[3,6];case 4:u.sent(),u.label=5;case 5:return a++,[3,3];case 6:return[4,o.done];case 7:return u.sent(),[3,9];case 8:return d=u.sent(),Oe(n,"Failed to clear old targeting matches for sessions: ".concat(d),d),[3,9];case 9:return[2]}})})}},vt=new ht,gt=function(e){var t=e.sessionId,r=e.targetingConfig,i=e.loggerProvider,o=e.apiKey,s=e.targetingParams,a=e.urlChange,c=void 0!==a&&a;return(0,u.sH)(void 0,void 0,void 0,function(){var e,a,l,d,h,v;return(0,u.YH)(this,function(g){switch(g.label){case 0:return[4,vt.clearStoreOfOldSessions({loggerProvider:i,apiKey:o,currentSessionId:t})];case 1:return g.sent(),[4,vt.getTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:t})];case 2:if(!0===g.sent()&&!c)return[2,!0];e=!0,g.label=3;
1case 3:return g.trys.push([3,6,,7]),[4,n.e(6656).then(n.bind(n,56656))];case 4:return a=g.sent().evaluateTargeting,l=(0,u.Cl)((0,u.Cl)({},s),{flag:r,sessionId:"string"==typeof t?parseInt(t,10):t,apiKey:o,loggerProvider:i}),[4,a(l)];case 5:return(d=g.sent())&&d.sr_targeting_config&&(e="on"===d.sr_targeting_config.key),vt.storeTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:t,targetingMatch:e}),[3,7];case 6:return h=g.sent(),v=h,i.warn(v.message),[3,7];case 7:return[2,e]}})})},ft=2654435761,pt=2246822519,mt=3266489917,yt=374761393;function bt(e,t){return(e<<t|e>>>32-t)>>>0}function St(e,t){return e=bt(e=e+Math.imul(t,pt)>>>0,13),e=Math.imul(e,ft)>>>0}function It(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Ct(e,t){void 0===t&&(t=0);var n,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=i-56320+(r-55296<<10)+65536,n++)}r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<65536?t.push(224|r>>12,128|r>>6&63,128|63&r):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}return new Uint8Array(t)}(e),i=r.length,o=0;if(i>=16){for(var s=t+ft+pt>>>0,a=t+pt>>>0,c=t>>>0,l=t-ft>>>0;o<=i-16;)s=St(s,It(r,o)),a=St(a,It(r,o+=4)),c=St(c,It(r,o+=4)),l=St(l,It(r,o+=4)),o+=4;n=bt(s,1)+bt(a,7)+bt(c,12)+bt(l,18)>>>0}else n=t+yt>>>0;for(n=n+i>>>0;o<=i-4;)n=n+Math.imul(It(r,o),mt)>>>0,n=Math.imul(bt(n,17),668265263)>>>0,o+=4;for(;o<i;)n=n+Math.imul(r[o],yt)>>>0,n=Math.imul(bt(n,11),ft)>>>0,o++;return n^=n>>>15,n=Math.imul(n,pt)>>>0,n^=n>>>13,n=Math.imul(n,mt)>>>0,(n^=n>>>16)>>>0}var wt="__amplitude_url_tracking_patched__",kt=new WeakMap;function Pt(e,t,n){if(void 0===n&&(n={}),!(null==e?void 0:e.location))return function(){};var r=n.enablePolling,i=void 0!==r&&r,o=n.pollingInterval,s=void 0===o?I:o;if(i){var a=function(){var t;return null!==(t=e.location.href)&&void 0!==t?t:""},c=a(),l=e.setInterval(function(){var e=a();e!==c&&(c=e,t(e))},s);return function(){null!=l&&e.clearInterval(l)}}var u=kt.get(e);if(!u){var d=void 0,h=new Set,v=function(){var t=function(){var t;return null!==(t=e.location.href)&&void 0!==t?t:""}();void 0!==d&&t===d||(d=t,h.forEach(function(e){return e(t)}))},g=function(e){var t=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=e.apply(this,t);return v(),r};return t[wt]=!0,t},f=e.history;if(null==f?void 0:f.pushState){var p=Reflect.get(f,"pushState");p[wt]||(f.pushState=g(p))}if(null==f?void 0:f.replaceState){var m=Reflect.get(f,"replaceState");m[wt]||(f.replaceState=g(m))}u={callbacks:h,notify:v,onPopStateOrHashChange:function(){return v()},listenersAttached:!1},kt.set(e,u)}var y=u;return y.listenersAttached||(e.addEventListener("popstate",y.onPopStateOrHashChange),e.addEventListener("hashchange",y.onPopStateOrHashChange),y.listenersAttached=!0),y.callbacks.add(t),function(){y.callbacks.delete(t),0===y.callbacks.size&&y.listenersAttached&&(e.removeEventListener("popstate",y.onPopStateOrHashChange),e.removeEventListener("hashchange",y.onPopStateOrHashChange),y.listenersAttached=!1)}}function Et(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,n,r){var i,o,s,a=(0,u.Cl)((0,u.Cl)({},e),r),c=a.ugcFilterRules||[],l=null!==(i=a.enablePolling)&&void 0!==i&&i,d=null!==(o=a.pollingInterval)&&void 0!==o?o:I,h=null!==(s=a.captureDocumentTitle)&&void 0!==s&&s;if(!n)return function(){};var v=void 0,g=function(){return n.location&&n.location.href||""},f=function(){var e=g();if(void 0===v||e!==v){v=e;var r=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=g(),o="";return h&&(o=(null==r?void 0:r.title)||""),{href:c.length>0?z(i,c):i,title:o,viewportHeight:e,viewportWidth:t,type:"url-change-event"}}();t(r)}},p=Pt(n,function(){return f()},l?{enablePolling:!0,pollingInterval:d}:{});return f(),function(){return p()}},options:e}}Et();var Rt=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e,t=this;null===(e=this.mutationObserver)||void 0===e||e.disconnect(),(0,c.m)()&&(this.sendToAllIframes({type:O,action:"start"}),this.mutationObserver=new MutationObserver(function(e){var n,r,i,o,s,a;try{for(var c=(0,u.Ju)(e),l=c.next();!l.done;l=c.next()){var d=l.value;try{for(var h=(i=void 0,(0,u.Ju)(Array.from(d.addedNodes))),v=h.next();!v.done;v=h.next()){(p=v.value)instanceof HTMLIFrameElement?t.sendToIframeAfterLoad(p):p instanceof Element&&p.querySelectorAll("iframe").forEach(function(e){t.sendToIframeAfterLoad(e)})}}catch(e){i={error:e}}finally{try{v&&!v.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}
1try{for(var g=(s=void 0,(0,u.Ju)(Array.from(d.removedNodes))),f=g.next();!f.done;f=g.next()){var p;if((p=f.value)instanceof HTMLIFrameElement){var m=t.pendingLoadListeners.get(p);m&&(p.removeEventListener("load",m),t.pendingLoadListeners.delete(p))}}}catch(e){s={error:e}}finally{try{f&&!f.done&&(a=g.return)&&a.call(g)}finally{if(s)throw s.error}}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},e.prototype.stop=function(){var e;null===(e=this.mutationObserver)||void 0===e||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener("load",e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:O,action:"stop"})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:O,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},e.prototype.sendToAllIframes=function(e){var t=this;document.querySelectorAll("iframe").forEach(function(n){return t.sendToIframe(n,e)})},e.prototype.sendToIframe=function(e,t){var n;try{null===(n=e.contentWindow)||void 0===n||n.postMessage(t,"*")}catch(e){}},e}();var xt=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeCoordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=(0,c.m)();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){if(e.recordCancelCallback&&e.recordFunction)try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn("Failed to take full snapshot on focus:",t)}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var n;null===(n=e.eventCompressor)||void 0===n||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,r,i){return void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),(0,u.sH)(e,void 0,void 0,function(){var e,o,s,l,d,h,v,g,f,p,m,y;return(0,u.YH)(this,function(u){switch(u.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig){if(!n)return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.")}return this.lastTargetingParams=t,e=this.config.targetingConfig,e&&!this.sessionTargetingMatch?(o=i?this.latestUrlChangeTargetingEvaluationId:void 0,(s=t.event)&&Object.values(a.S).includes(s.event_type)&&(s=void 0),l=null!==(m=null!==(g=null===(v=t.page)||void 0===v?void 0:v.url)&&void 0!==g?g:null===(p=null===(f=(0,c.m)())||void 0===f?void 0:f.location)||void 0===p?void 0:p.href)&&void 0!==m?m:"",d=null!==(y=t.page)&&void 0!==y?y:""!==l?{url:l}:void 0,[4,gt({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:s,page:d},urlChange:i})]):[3,2];case 1:if(h=u.sent(),i&&void 0!==o&&o!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(o,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||h,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:s,targetingParams:t},null,2)),u.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return!r&&this.recordCancelCallback?[3,5]:(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]);case 4:u.sent(),u.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,r){return void 0===n&&(n={}),void 0===r&&(r=!0),(0,u.sH)(e,void 0,void 0,function(){var e,i,o,a;return(0,u.YH)(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),e=void 0,(i=this.config)&&t!==s.METADATA?(e={config:Y(i),version:Ee},r?[4,W()]:[3,2]):[3,2];case 1:o=c.sent(),e=(0,u.Cl)((0,u.Cl)({},o),e),c.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,u.Cl)((0,u.Cl)({},n),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return a=c.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",a),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t,n,r;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null===(t=e.networkObservers)||void 0===t||t.stop(),null===(n=e.crossOriginIframeC
1oordinator)||void 0===n||n.stop(),e.crossOriginIframeCoordinator=null,null===(r=e.crossOriginParentSignalCleanup)||void 0===r||r.call(e),e.crossOriginParentSignalCleanup=null}catch(t){var i=t;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(i.toString()))}},this.loggerProvider=new _(new h.V)}return e.prototype.init=function(e,t){return(0,X.m)(this._init(e,t))},e.prototype.setupUrlChangeListener=function(){var e,t,n=this;null===(e=this.urlChangeCleanup)||void 0===e||e.call(this);var r=(0,c.m)();if(null==r?void 0:r.location){var i=!!(null===(t=this.config)||void 0===t?void 0:t.targetingConfig),o=Pt(r,function(e){if(n.currentPageUrl=e,i){var t=++n.latestUrlChangeTargetingEvaluationId;n.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:e}},!1,!1,!0),n.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(t," for ").concat(e,"."))}});this.urlChangeCleanup=function(){o(),n.urlChangeCleanup=null}}},e.prototype.getCurrentPageForTargeting=function(){var e,t,n=null===(t=null===(e=(0,c.m)())||void 0===e?void 0:e.location)||void 0===t?void 0:t.href;return null!=n?{url:n}:void 0},e.prototype._init=function(e,t){var r,i,o,s,a,l,d,v,g,f,p;return(0,u.sH)(this,void 0,void 0,function(){var m,y,b,S,I,C,w,k,P,E,R,x,M,T,O,L,H,D,F,A,q,N,j,B,z,W,Y,J,K,X=this;return(0,u.YH)(this,function(Q){switch(Q.label){case 0:return null===(r=this.urlChangeCleanup)||void 0===r||r.call(this),this.loggerProvider=new _(t.loggerProvider||new h.V),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.currentPageUrl=U(),this.identifiers=new dt({sessionId:t.sessionId,deviceId:t.deviceId}),m=this,[4,fe(e,t)];case 1:return m.joinedConfigGenerator=Q.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return y=Q.sent(),b=y.joinedConfig,S=y.localConfig,I=y.remoteConfig,this.config=b,this.setMetadata(t.sessionId,b,S,I,null===(i=t.version)||void 0===i?void 0:i.version,Ee,null===(o=t.version)||void 0===o?void 0:o.type),this.pageLeaveFns=[],t.sessionId&&(null===(s=this.config.interactionConfig)||void 0===s?void 0:s.enabled)&&(C=ut.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[C.send(this.getDeviceId.bind(this)).bind(C)],this.scrollHook=C.hook.bind(C),this.clickHandler=new st(this.loggerProvider,C)),w=[],"idb"!==(k=this.config.storeType)||(null===(a=(0,c.m)())||void 0===a?void 0:a.indexedDB)||(k="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(k," for event storage.")),R=(0,c.m)(),this.config.useWebWorker&&R&&R.Worker?[4,n.e(7052).then(n.bind(n,37052))]:[3,4];case 3:x=Q.sent(),M=x.compressionScript,T=x.trackDestinationScript,P=M,E=T,Q.label=4;case 4:return Q.trys.push([4,6,,7]),[4,ze({config:this.config,type:"replay",storeType:k,trackDestinationWorkerScript:E})];case 5:return O=Q.sent(),w.push({name:"replay",manager:O}),[3,7];case 6:return L=Q.sent(),A=L,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(A.toString())),[3,7];case 7:if(!(null===(l=this.config.interactionConfig)||void 0===l?void 0:l.enabled))return[3,11];H=this.config.interactionConfig.batch?ot:it,Q.label=8;case 8:return Q.trys.push([8,10,,11]),[4,ze({config:this.config,type:"interaction",minInterval:null!==(d=this.config.interactionConfig.trackEveryNms)&&void 0!==d?d:3e4,maxInterval:6e4,payloadBatcher:H,storeType:k,trackDestinationWorkerScript:E})];case 9:return D=Q.sent(),w.push({name:"interaction",manager:D}),[3,11];case 10:return F=Q.sent(),A=F,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(A.toString())),[3,11];case 11:if(this.eventsManager=new(We.bind.apply(We,(0,u.fX)([void 0],(0,u.zs)(w),!1))),this.eventCompressor&&this.eventCompressor.terminate(),this.eventCompressor=new Se(this.eventsManager,this.config,this.getDeviceId(),P,function(){return X.sendEvents()}),this.pendingEmitEvents.length>0){q=this.pendingEmitEvents.splice(0);try{for(N=(0,u.Ju)(q),j=N.next();!j.done;j=N.next())B=j.value,z=B.event,W=B.sessionId,this.eventCompressor.enqueueEvent(z,W)}catch(e){J={error:e}}finally{try{j&&!j.done&&(K=N.return)&&K.call(N)}finally{if(J)throw J.error}}}return this.pageLeaveFns=(0,u.fX)((0,u.fX)([],(0,u.zs)(this.pageLeaveFns),!1),[function(){var e;if(X.config&&(null===(e=X.identifiers)||void 0===e?void 0:e.sessionId)&&O){var t=O.getBeaconEvents();if(t.length){var n=X.getDeviceId();n&&O.trackDestination.sendBeacon({events:t,sessionId:X.identifiers.sessionId,deviceId:n,apiKey:X.config.apiKey,serverZone:X.config.serverZone})}}}],!1),[4,this.initializeNetworkObservers()];case 12:return Q.sent(),(null===(v=(0,c.m)())||void 0===v?void 0:v.opener)&&(function(e,t){var n,r=e;if(!0!==r[ne]){r[ne]=!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,s=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,"Backgroun
1d 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:s}),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})}}(Y=te()),Y.setup((0,u.Cl)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:V[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return Q.sent(),(this.config.targetingConfig||(null!==(p=null===(f=null===(g=this.config.privacyConfig)||void 0===g?void 0:g.urlMaskLevels)||void 0===f?void 0:f.length)&&void 0!==p?p:0)>0)&&this.setupUrlChangeListener(),[2]}})})},e.prototype.setSessionId=function(e,t){return(0,X.m)(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t,n){var r;return(0,u.sH)(this,void 0,void 0,function(){var i,o,s;return(0,u.YH)(this,function(a){switch(a.label){case 0:return this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,(i=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(i),o=t||this.getDeviceId(),this.identifiers=new dt({sessionId:e,deviceId:o}),this.joinedConfigGenerator&&i?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2];case 1:s=a.sent().joinedConfig,this.config=s,a.label=2;case 2:return(null===(r=this.config)||void 0===r?void 0:r.targetingConfig)?[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return a.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:a.sent(),a.label=6;case 6:return[2]}})})},e.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),i={};return r&&((e={})[y]=n.sessionReplayId?n.sessionReplayId:null,i=e,t.debugMode&&(i[C]=JSON.stringify({appHash:re(t.apiKey).toString()}))),this.addCustomRRWebEvent(s.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},e.prototype.sendEvents=function(e){var t,n=e||(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,u.sH)(this,void 0,void 0,function(){var n;return(0,u.YH)(this,function(r){return(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},e.prototype.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=(0,ie.w$)(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n=!1,r="",i=!1;this.config.targetingConfig?this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),n=!0,i=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),n=!1,i=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,Ct(e.toString())%1e6/1e6<t)?(n=!0,i=!0):(r="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(r),n=!1,i=!1);return this.lastShouldRecordDecision!==n&&this.config.targetingConfig&&(this.addCustomRRWebEvent(s.TARGETING_DECISION,{message:r,sessionId:this.identifiers.sessionId,matched:i,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=n),n},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n=null===(e=this.config)||void 0===e?void 0:e.privacyConfig;if("conservative"===(n?F(this.currentPageUrl,n):void 0))return"*";if(null===(t=null==n?void 0:n.urlMaskLevels)||void 0===t?void 0:t.some(function(e){return"conservative"===e.maskLevel}))return"*";var r=null==n?void 0:n.urlMaskLevels;if("conservative"===(null==n?void 0:n.defaultMaskLevel)&&r&&r.length>0)return"*";var i=null==n?void 0:n.maskSelector;return i||void 0},e.prototype.getRecordingPlugins=function(e){var t,r,i,o,s,a;return(0,u.sH)(this,void 0,void 0,function(){var c,l,d,h;return(0,u.YH)(this,function(u){switch(u.label){case 0:c=[];try{l=Et({ugcFilterRules:(null===(r=null===(t=this.config)||void 0===t?void 0:t.interactionConfig)||void 0===r?void 0:r.ugcFilterRules)||[],enablePolling:(null===(i=this.config)||void 0===i?void 0:i.enableUrlChangePolling)||!1,pollingInterval:null===(o=this.config)||void 0===o?void 0:o.urlChangePollingInterval,captureDocumentTitle:null===(s=this.config)||void 0===s?void 0:s.captureDocumentTitle}),c.push(l)}catch(e){this.loggerProvider.warn("Failed to create URL tracking plugin:",e)}if(!(null===(a=null==e?void 0:e.console)||void 0===a?void 0:a.enabled))return[3,4];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,n.e(430).then(n.bind(n,98049))];case 2:return d=u.sent().getRecordConsolePlugin,c.push(d({level:e.console.levels})),[3,4];case 3:return h=u.sent(),this.loggerProvider.warn("Failed to load console plugin:",h),[3,4];case 4:return[2,c.length>0?c:void 0]}})})},e.prototype.getRecordFunction=function(){return(0,u.sH)(this,void 0,void 0,function(){var e,t;return(0,u.YH)(this,function(r){switch(r.label){case 0:if(this.recordFunction)return[2,this.recordFunction];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.e(1129).then(n.bind(n,31129))];case 2:return e=r.sent().record,this.recordFunction=e,[2,e];case 3:return t=r.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}})})},e.prototype.recordEvents=function(e){return void 0===e&&(e=!0),(0,u.sH)(this,void 0,void 0,function(){var t;return(0,u.YH)(this,function(n){switch(n.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,n.label=1;case 1:return n.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:n.sent(),n.label=3;case 3:return null===this.recordEventsPendingShouldLogMetadata?[3,5]:(t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)]);case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},e.prototype._recordEvents=function(e){var t,n,r,i,o,a,l,d;return void 0===e&&(e=!0),(0,u.sH)(this,void 0,void 0,function(){var h,v,g,f,p,m,y,b,S,I,C,w,k,x,M,T,_,L,H,D=this;return(0,u.YH)(this,function(F){switch(F.label){case 0:return h=this.config,v=this.getShouldRecord(),g=null===(t=this.identifiers)||void 0===t?void 0:t.sessionId,v&&g&&h?(this.stopRecordingEvents(),[4,this.getRecordFunction()]):[2];case 1:return(f=F.sent())?[4,this.initializeNetworkObservers()]:[2];case 2:F.sent(),p=null===(n=h.loggingConfig)||void 0===n?void 0:n.network,m=pe(h.serverZone,h.trackServerUrl),y=[P,E,R,m],null===(r=this.networkObservers)||void 0===r||r.start(function(e){y.some(function(t){return e.url.
1startsWith(t)})||D.addCustomRRWebEvent(s.FETCH_REQUEST,e)},p),b=h.interactionConfig,S=h.loggingConfig,I=(null==b?void 0:b.enabled)?{mouseInteraction:this.eventsManager&&(null===(i=this.clickHandler)||void 0===i?void 0:i.createHook({eventsManager:this.eventsManager,sessionId:g,deviceIdFn:this.getDeviceId.bind(this),mirror:f.mirror,ugcFilterRules:null!==(o=b.ugcFilterRules)&&void 0!==o?o:[],performanceOptions:null===(a=h.performanceConfig)||void 0===a?void 0:a.interaction})),scroll:this.scrollHook}:{},C=(null==b?void 0:b.enabled)&&b.ugcFilterRules?b.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(g,".")),F.label=3;case 3:return F.trys.push([3,5,,6]),w=!!(null===(l=h.crossOriginIframes)||void 0===l?void 0:l.enabled),k=!1!==(null===(d=h.crossOriginIframes)||void 0===d?void 0:d.coordinateChildren),(x=w&&function(){try{var e=(0,c.m)();return!!e&&e.parent!==e}catch(e){return!0}}())&&k?(this.crossOriginParentSignalCleanup=function(e){var t=(0,c.m)();if(!t)return function(){};var n=t.parent;function r(t){if(t.source===n){var r=t.data;(null==r?void 0:r.type)===O&&("start"===r.action?e.onStart():"stop"===r.action&&e.onStop())}}return t.addEventListener("message",r),function(){return t.removeEventListener("message",r)}}({onStart:function(){return D._recordEventsInChildMode(f,g,h,I)},onStop:function(){try{D.recordCancelCallback&&D.recordCancelCallback(),D.recordCancelCallback=null}catch(t){var e=t;D.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))}}}),[2]):(M=this,T=f,_=[(0,u.Cl)({},this.buildRRWebRecordOptions(h,I,function(e){if(D.shouldOptOut())return D.loggerProvider.log("Opting session ".concat(g," out of recording due to optOut config.")),D.stopRecordingEvents(),void D.sendEvents();e.type===oe.Meta&&(e.data.href=z(e.data.href,C)),D.eventCompressor?D.eventCompressor.enqueueEvent(e,g):D.pendingEmitEvents.push({event:e,sessionId:g})},"Error while capturing replay: "))],H={},[4,this.getRecordingPlugins(S)]);case 4:return M.recordCancelCallback=T.apply(void 0,[u.Cl.apply(void 0,_.concat([(H.plugins=F.sent(),H.recordCrossOriginIframes=w,H)]))]),w&&!x&&k&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new Rt),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(s.DEBUG_INFO),e&&this.addCustomRRWebEvent(s.METADATA,this.metadata),[3,6];case 5:return L=F.sent(),this.loggerProvider.warn("Failed to initialize session replay:",L),[3,6];case 6:return[2]}})})},e.prototype.buildRRWebRecordOptions=function(e,t,n,r){var i=this,o=e.privacyConfig;return(0,u.Cl)((0,u.Cl)({emit:n,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:w,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:q("input",o,function(){return i.currentPageUrl}),maskTextFn:q("text",o,function(){return i.currentPageUrl}),maskAttributeFn:N(o,function(){return i.currentPageUrl}),maskTextSelector:this.getMaskTextSelectors()},void 0!==e.fullSnapshotIntervalMs&&{checkoutEveryNms:e.fullSnapshotIntervalMs}),{recordCanvas:!1,captureAdoptedStyleSheets:e.captureAdoptedStyleSheets,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},errorHandler:function(e){var t=e;if(t.message.includes("insertRule")&&t.message.includes("CSSStyleSheet"))throw t;if(t._external_)throw t;return i.loggerProvider.warn(r,t.toString()),!0}})},e.prototype._recordEventsInChildMode=function(e,t,n,r){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e((0,u.Cl)((0,u.Cl)({},this.buildRRWebRecordOptions(n,r,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t,"."))}catch(e){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",e)}},e.prototype.getDeviceId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),(0,u.sH)(this,void 0,void 0,function(){return(0,u.YH)(this,function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]})})},e.prototype.shutdown=function(){var e,t;null===(e=this.urlChangeCleanup)||void 0===e||e.call(this),null===(t=this.crossOriginParentSignalCleanup)||void 0===t||t.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},e.prototype.setMetadata=function(e,t,n,r,i,o,s){var a=(null==e?void 0:e.toString())?re(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:i,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:o}},e.prototype.initializeNetworkObservers=function(){var e,t,r;return(0,u.sH)(this,void 0,void 0,function(){var i,o;return(0,u.YH)(this,function(s){switch(s.label){case 0:if(!(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.loggingConfig)||void 0===t?void 0:t.network)||void 0===r?void 0:r.enabled)||this.networkObservers)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,n.e(2422).then(n.bind(n,22422))];case 2:return i=s.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return o=s.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},e}(),Mt=function(e){return function(){var t=e.config||J();return{logger:t.loggerProvider,logLevel:t.logLevel}}};const Tt=(Ot=new xt,{init:(0,l.nA)(Ot.init.bind(Ot),"init",Mt(Ot)),evaluateTargetingAndCapture:(0,l.nA)(Ot.evaluateTargetingAndCapture.bind(Ot),"evaluateTargetingAndRecord",Mt(Ot)),setSessionId:(0,l.nA)(Ot.setSessionId.bind(Ot),"setSessionId",Mt(Ot)),getSessionId:(0,l.nA)(Ot.getSessionId.bind(Ot),"getSessionId",Mt(Ot)),getSessionReplayProperties:(0,l.nA)(Ot.getSessionReplayProperties.bind(Ot),"getSessionReplayProperties",Mt(Ot)),flush:(0,l.nA)(Ot.flush.bind(Ot),"flush",Mt(Ot)),shutdown:(0,l.nA)(Ot.shutdown.bind(Ot),"shutdown",Mt(Ot))});var Ot,_t,Lt,Ht,Dt=Tt.init,Ft=Tt.setSessionId,At=Tt.getSessionId,qt=Tt.getSessionReplayProperties,Nt=Tt.flush,Ut=Tt.shutdown,jt=Tt.evaluateTargetingAndCapture,Bt=n(34544),zt=function(e){return void 0===e&&(e="$default_instance"),Bt.i.getInstance(e)};!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(_t||(_t={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue"}(Lt||(Lt={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(Ht||(Ht={}));var Wt=[_t.SET,_t.SET_ONCE,_t.ADD,_t.APPEND,_t.PREPEND,_t.POSTINSERT],Yt="1.30.3",Jt="".concat("[Amplitude]"," Session Replay ID"),Kt=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:Nt,getSessionId:At,getSessionReplayProperties:qt,init:Dt,setSessionId:Ft,shutdown:Ut,evaluateTargetingAndCapture:jt},this.options=r({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var n,s,a,c,l,u,d,h;return i(this,void 0,void 0,function(){var t,i,v;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),null==e||e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(Yt,".")),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=r(r({},e.defaultTracking),{sessions:!0})),t=zt(this.config.instanceName).identityStore,i=t.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!==(n=this.options.deviceId)&&void 0!==n?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl||(null===(s=this.config.remoteConfig)||void 0===s?void 0:s.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.blockSelector,maskSelector:null===(c=this.options.privacyConfig)||void 0===c?void 0:c.maskSelector,unmaskSelector:null===(l=this.options.privacyConfig)||void 0===l?void 0:l.unmaskSelector,defaultMaskLevel:null===(u=this.options.privacyConfig)||void 0===u?void 0:u.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:Yt},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!==(d=this.options.useWebWorker)&&void 0!==d?d:null===(h=this.options.experimental)||void 0===h?void 0:h.useWebWorker,userProperties:i,applyBackgroun
1dColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval,captureAdoptedStyleSheets:this.options.captureAdoptedStyleSheets,crossOriginIframes:this.options.crossOriginIframes},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return o.sent(),[3,3];case 2:return v=o.sent(),null==e||e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(v.message)),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return i(this,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return null===(t=this.config)||void 0===t||t.loggerProvider.debug("Analytics session id is changed to ".concat(e,", SR session id is ").concat(String(this.sessionReplay.getSessionId()),".")),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return i(this,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return null===(t=this.config)||void 0===t||t.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),e?(this.sessionReplay.shutdown(),[3,4]):[3,1];case 1:return null!=this.config?[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise]:[3,3];case 2:n.sent(),n.label=3;case 3:n.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t,n,s;return i(this,void 0,void 0,function(){var i,l,u,d,h;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,9,,10]),this.options.customSessionId?(i=this.options.customSessionId(e))?i===this.sessionReplay.getSessionId()?[3,2]:[4,this.sessionReplay.setSessionId(i).promise]:[3,3]:[3,4];case 1:o.sent(),o.label=2;case 2:d=this.sessionReplay.getSessionReplayProperties(),e.event_properties=r(r({},e.event_properties),d),o.label=3;case 3:return[3,8];case 4:return(i=null===(t=this.config)||void 0===t?void 0:t.sessionId)&&i!==this.sessionReplay.getSessionId()?[4,this.sessionReplay.setSessionId(i).promise]:[3,6];case 5:o.sent(),o.label=6;case 6:return i&&i===e.session_id?(l=void 0,e.event_type===a.S.IDENTIFY&&(l=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach(function(n){if(Wt.includes(n)){var i=e.user_properties&&e.user_properties[n];t=r(r({},t),i)}}),t}}(e)),u=(0,c.m)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:l,page:null!=(null===(n=null==u?void 0:u.location)||void 0===n?void 0:n.href)?{url:u.location.href}:void 0})]):[3,8];case 7:o.sent(),d=this.sessionReplay.getSessionReplayProperties(),e.event_properties=r(r({},e.event_properties),d),o.label=8;case 8:return e.event_type===a.S.IDENTIFY&&e.event_properties&&delete e.event_properties[Jt],[2,Promise.resolve(e)];case 9:return h=o.sent(),null===(s=this.config)||void 0===s||s.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(h.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return i(this,void 0,void 0,function(){return o(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null===(e=this.config)||void 0===e||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(t.message))}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.pluginName="@amplitude/plugin-session-replay-browser",e}(),Xt=function(e){return new Kt(e)}},70492(e,t,n){n.d(t,{P2:()=>f});const r=(e,t)=>t.some(t=>e instanceof t);let i,o;const s=new WeakMap,a=new WeakMap,c=new WeakMap;let l={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return s.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return v(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function u(e){l=e(l)}function d(e){return(o||(o=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(g(this),t),v(this.request)}:function(...t){return v(e.apply(g(this),t))}}function h(e){return"function"==typeof e?d(e):(e instanceof IDBTransaction&&function(e){if(s.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});s.set(e,t)}(e),r(e,i||(i=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,l):e)}function v(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(v(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",o)});return c.set(t,e),t}(e);if(a.has(e))return a.get(e);const t=h(e);return t!==e&&(a.set(e,t),c.set(t,e)),t}const g=e=>c.get(e);function f(e,t,{blocked:n,upgrade:r,blocking:i,terminated:o}={}){const s=indexedDB.open(e,t),a=v(s);return r&&s.addEventListener("upgradeneeded",e=>{r(v(s.result),e.oldVersion,e.newVersion,v(s.transaction),e)}),n&&s.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{o&&e.addEventListener("close",()=>o()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}const p=["get","getKey","getAll","getAllKeys","count"],m=["put","add","delete","clear"],y=new Map;function b(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(y.get(t))return y.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=m.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!p.includes(n))return;const o=async function(e,...t){const o=this.transaction(e,i?"readwrite":"readonly");let s=o.store;
1return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),i&&o.done]))[0]};return y.set(t,o),o}u(e=>({...e,get:(t,n,r)=>b(t,n)||e.get(t,n,r),has:(t,n)=>!!b(t,n)||e.has(t,n)}));const S=["continue","continuePrimaryKey","advance"],I={},C=new WeakMap,w=new WeakMap,k={get(e,t){if(!S.includes(t))return e[t];let n=I[t];return n||(n=I[t]=function(...e){C.set(this,w.get(this)[t](...e))}),n}};async function*P(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,k);for(w.set(n,t),c.set(n,g(t));t;)yield n,t=await(C.get(n)||t.continue()),C.delete(n)}function E(e,t){return t===Symbol.asyncIterator&&r(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&r(e,[IDBIndex,IDBObjectStore])}u(e=>({...e,get:(t,n,r)=>E(t,n)?P:e.get(t,n,r),has:(t,n)=>E(t,n)||e.has(t,n)}))},78226(e,t,n){n.d(t,{C6:()=>i,Cl:()=>o,Ju:()=>l,Tt:()=>s,YH:()=>c,fX:()=>d,sH:()=>a,zs:()=>u});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return o=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},o.apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})}function c(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=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,c])}}}Object.create;function l(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 u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.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 s}function d(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))}Object.create;"function"==typeof SuppressedError&&SuppressedError}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.