@amplitude/plugin-session-replay-browser 1.7.0-srtargeting.0 → 1.7.0-srtargeting.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var sessionReplay=function(e){"use strict";var t=function(e,n){return t=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])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),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]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var u=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:l(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),l=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},d=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),h=function(){return h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)},f=function(e,t){var n=typeof e;if(n!==typeof t)return!1;for(var r=0,o=["string","number","boolean","undefined"];r<o.length;r++){if(o[r]===n)return e===t}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var s=Array.isArray(e),i=Array.isArray(t);if(s!==i)return!1;if(!s||!i){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!f(a,c))return!1;var u=!0;return Object.keys(e).forEach((function(n){f(e[n],t[n])||(u=!1)})),u}for(var l=0;l<e.length;l++)if(!f(e[l],t[l]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var p,v,g,m,y,S,b=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=h({},this.identity.userProperties),n=h(h({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){for(var t=n.userProperties||{},r=0,o=Object.entries(e);r<o.length;r++){var s=o[r],i=s[0],a=s[1];switch(i){case"$set":for(var c=0,u=Object.entries(a);c<u.length;c++){var l=u[c],d=l[0],h=l[1];t[d]=h}break;case"$unset":for(var f=0,p=Object.keys(a);f<p.length;f++){delete t[d=p[f]]}break;case"$clearAll":t={}}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return h({},this.identity)},e.prototype.setIdentity=function(e){var t=h({},this.identity);this.identity=h({},e),f(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,w=function(){function e(){this.identityStore=new b,this.eventBridge=new d,this.applicationContextProvider=new u}return e.getInstance=function(t){return I.analyticsConnectorInstances||(I.analyticsConnectorInstances={}),I.analyticsConnectorInstances[t]||(I.analyticsConnectorInstances[t]=new e),I.analyticsConnectorInstances[t]},e}(),C=function(e){return void 0===e&&(e="$default_instance"),w.getInstance(e)},E=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0};!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"}(p||(p={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(v||(v={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(g||(g={})),function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(m||(m={})),function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(y||(y={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(S||(S={}));var M,k="".concat("AMP","_unsent"),T="https://api2.amplitude.com/2/httpapi",O=function(e){return{promise:e||Promise.resolve()}},x="Amplitude Logger ",R=function(){function e(){this.logLevel=m.None}return e.prototype.disable=function(){this.logLevel=m.None},e.prototype.enable=function(e){void 0===e&&(e=m.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Verbose||console.log("".concat(x,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Warn||console.warn("".concat(x,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Error||console.error("".concat(x,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Debug||console.log("".concat(x,"[Debug]: ").concat(e.join(" ")))},e}(),N=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:m.Warn,loggerProvider:new R,optOut:!1,serverUrl:T,serverZone:y.US,useBatch:!1}},D=function(){function e(e){var t,n,r,o;this._optOut=!1;var s=N();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:s.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||s.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||s.flushQueueSize,this.instanceName=e.instanceName||s.instanceName,this.loggerProvider=e.loggerProvider||s.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:s.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:s.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||s.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:s.useBatch,this.loggerProvider.enable(this.logLevel);var i=L(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=i.serverZone,this.serverUrl=i.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),_=function(e,t){return e===y.EU?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":T},L=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=N().serverZone),void 0===n&&(n=N().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:N().serverZone;return{serverZone:r,serverUrl:_(r,n)}},P=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},A=function(e,t,n,r,o){return void 0===o&&(o=null),function(){for(var s=[],i=0;i<arguments.length;i++)s[i]=arguments[i];var a=n(),c=a.logger,u=a.logLevel;if(u&&u<m.Debug||!u||!c)return e.apply(o,s);var l={type:"invoke public method",name:t,args:s,stacktrace:P(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(o,s);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}},F=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,s,i,a,c,u,l,d,h,f,p,v,g,m,y,b,I,w,C;if("object"!=typeof e)return null;var E=e.code||0,M=this.buildStatus(E);switch(M){case S.Success:return{status:M,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case S.Invalid:return{status:M,statusCode:E,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(s=e.missing_field)&&void 0!==s?s:"",eventsWithInvalidFields:null!==(i=e.events_with_invalid_fields)&&void 0!==i?i:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(h=e.silenced_events)&&void 0!==h?h:[],throttledDevices:null!==(f=e.throttled_devices)&&void 0!==f?f:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case S.PayloadTooLarge:return{status:M,statusCode:E,body:{error:null!==(v=e.error)&&void 0!==v?v:""}};case S.RateLimit:return{status:M,statusCode:E,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(I=e.exceeded_daily_quota_devices)&&void 0!==I?I:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case S.Timeout:default:return{status:M,statusCode:E}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?S.Success:429===e?S.RateLimit:413===e?S.PayloadTooLarge:408===e?S.Timeout:e>=400&&e<500?S.Invalid:e>=500?S.Failed:S.Unknown},e}(),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(s){switch(s.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(F),U="[Amplitude]",B="".concat(U," Session Replay ID"),q=y.US,W="".concat(U," Session Replay Debug"),z="amp-mask";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info"}(M||(M={}));var K,V=function(){return{flushMaxRetries:2,logLevel:m.Warn,loggerProvider:new R,transportProvider:new j}},G=function(e){function t(t,n){var o=this,s=V();return(o=e.call(this,r(r({transportProvider:s.transportProvider},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=s.flushMaxRetries?n.flushMaxRetries:s.flushMaxRetries,o.apiKey=t,o.sampleRate=n.sampleRate||0,o.serverZone=n.serverZone||q,o.configEndpointUrl=n.configEndpointUrl,o.shouldInlineStylesheet=n.shouldInlineStylesheet,n.privacyConfig&&(o.privacyConfig=n.privacyConfig),n.debugMode&&(o.debugMode=n.debugMode),o}return n(t,e),t}(D);function $(e){const t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function H(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function X(e){try{const n=e.rules||e.cssRules;return n?((t=Array.from(n,J).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t):null}catch(e){return null}var t}function J(e){let t;if(function(e){return"styleSheet"in e}(e))try{t=X(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return function(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}(e.cssText);return t||e.cssText}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(K||(K={}));class Y{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var t;if(!e)return-1;const n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach((e=>this.removeNodeFromMap(e)))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Z({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:s}){let i=o||"";const a=r&&Q(r);return(t[n.toLowerCase()]||a&&t[a])&&(i=s?s(i,e):"*".repeat(i.length)),i}function Q(e){return e.toLowerCase()}const ee="__rrweb_original__";function te(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Q(t):null}let ne=1;const re=new RegExp("[^a-z0-9-_:]");function oe(){return ne++}let se,ie;const ae=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ce=/^(?:[a-z+]+:)?\/\//i,ue=/^www\..*/i,le=/^(data:)([^,]*),(.*)/i;function de(e,t){return(e||"").replace(ae,((e,n,r,o,s,i)=>{const a=r||s||i,c=n||o||"";if(!a)return e;if(ce.test(a)||ue.test(a))return`url(${c}${a}${c})`;if(le.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${c})`;const u=t.split("/"),l=a.split("/");u.pop();for(const e of l)"."!==e&&(".."===e?u.pop():u.push(e));return`url(${c}${u.join("/")}${c})`}))}const he=/^[^ \t\n\r\u000c]+/,fe=/^[, \t\n\r\u000c]+/;function pe(e,t){if(!t||""===t.trim())return t;const n=e.createElement("a");return n.href=t,n.href}function ve(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function ge(){const e=document.createElement("a");return e.href="",e.href}function me(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?pe(e,r):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r(fe),!(n>=t.length);){let s=r(he);if(","===s.slice(-1))s=pe(e,s.substring(0,s.length-1)),o.push(s);else{let r="";s=pe(e,s);let i=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((s+r).trim());break}if(i)")"===e&&(i=!1);else{if(","===e){n+=1,o.push((s+r).trim());break}"("===e&&(i=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?de(r,ge()):"object"===t&&"data"===n?pe(e,r):r:pe(e,r):r}function ye(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function Se(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&Se(e.parentNode,t,n);for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}return!!n&&Se(e.parentNode,t,n)}function be(e,t,n){try{const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(`.${t}`))return!0}else if(Se(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function Ie(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,inlineStylesheet:c,maskInputOptions:u={},maskTextFn:l,maskInputFn:d,dataURLOptions:h={},inlineImages:f,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g=!1}=t,m=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:K.Document,childNodes:[],compatMode:e.compatMode}:{type:K.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:K.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:m};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:s,maskInputOptions:i={},maskInputFn:a,dataURLOptions:c={},inlineImages:u,recordCanvas:l,keepIframeSrcFn:d,newlyAddedElement:h=!1,rootId:f}=t,p=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,r,o),v=function(e){if(e instanceof HTMLFormElement)return"form";const t=Q(e.tagName);return re.test(t)?"div":t}(e);let g={};const m=e.attributes.length;for(let t=0;t<m;t++){const r=e.attributes[t];ye(v,r.name,r.value)||(g[r.name]=me(n,v,Q(r.name),r.value))}if("link"===v&&s){const t=Array.from(n.styleSheets).find((t=>t.href===e.href));let r=null;t&&(r=X(t)),r&&(delete g.rel,delete g.href,g._cssText=de(r,t.href))}if("style"===v&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const t=X(e.sheet);t&&(g._cssText=de(t,ge()))}if("input"===v||"textarea"===v||"select"===v){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Z({element:e,type:te(e),tagName:v,value:t,maskInputOptions:i,maskInputFn:a}):n&&(g.checked=n)}"option"===v&&(e.selected&&!i.select?g.selected=!0:delete g.selected);if("canvas"===v&&l)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const o=t.getImageData,s=ee in o?o[ee]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((e=>0!==e)))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),n=document.createElement("canvas");n.width=e.width,n.height=e.height;t!==n.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===v&&u){se||(se=n.createElement("canvas"),ie=se.getContext("2d"));const t=e,r=t.crossOrigin;t.crossOrigin="anonymous";const o=()=>{t.removeEventListener("load",o);try{se.width=t.naturalWidth,se.height=t.naturalHeight,ie.drawImage(t,0,0),g.rr_dataURL=se.toDataURL(c.type,c.quality)}catch(e){console.warn(`Cannot inline img src=${t.currentSrc}! Error: ${e}`)}r?g.crossOrigin=r:t.removeAttribute("crossorigin")};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}"audio"!==v&&"video"!==v||(g.rr_mediaState=e.paused?"paused":"played",g.rr_mediaCurrentTime=e.currentTime);h||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(p){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==v||d(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);return{type:K.Element,tagName:v,attributes:g,childNodes:[],isSVG:ve(e)||void 0,needBlock:p,rootId:f}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:u,maskInputFn:d,dataURLOptions:h,inlineImages:f,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g,rootId:m});case e.TEXT_NODE:return function(e,t){var n;const{maskTextClass:r,maskTextSelector:o,maskTextFn:s,rootId:i}=t,a=e.parentNode&&e.parentNode.tagName;let c=e.textContent;const u="STYLE"===a||void 0,l="SCRIPT"===a||void 0;if(u&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=X(e.parentNode.sheet))}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}c=de(c,ge())}l&&(c="SCRIPT_PLACEHOLDER");!u&&!l&&c&&be(e,r,o)&&(c=s?s(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:K.Text,textContent:c||"",isStyle:u,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:l,rootId:m});case e.CDATA_SECTION_NODE:return{type:K.CDATA,textContent:"",rootId:m};case e.COMMENT_NODE:return{type:K.Comment,textContent:e.textContent||"",rootId:m};default:return!1}}function we(e){return null==e?"":e.toLowerCase()}function Ce(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:u=!0,maskInputOptions:l={},maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p={},inlineImages:v=!1,recordCanvas:g=!1,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S=5e3,onStylesheetLoad:b,stylesheetLoadTimeout:I=5e3,keepIframeSrcFn:w=(()=>!1),newlyAddedElement:C=!1}=t;let{preserveWhiteSpace:E=!0}=t;const M=Ie(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,dataURLOptions:p,inlineImages:v,recordCanvas:g,keepIframeSrcFn:w,newlyAddedElement:C});if(!M)return console.warn(e,"not serialized"),null;let k;k=r.hasNode(e)?r.getId(e):!function(e,t){if(t.comment&&e.type===K.Comment)return!0;if(e.type===K.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(we(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===we(e.attributes.name)||"icon"===we(e.attributes.rel)||"apple-touch-icon"===we(e.attributes.rel)||"shortcut icon"===we(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&we(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(we(e.attributes.property).match(/^(og|twitter|fb):/)||we(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===we(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===we(e.attributes.name)||"googlebot"===we(e.attributes.name)||"bingbot"===we(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===we(e.attributes.name)||"generator"===we(e.attributes.name)||"framework"===we(e.attributes.name)||"publisher"===we(e.attributes.name)||"progid"===we(e.attributes.name)||we(e.attributes.property).match(/^article:/)||we(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===we(e.attributes.name)||"yandex-verification"===we(e.attributes.name)||"csrf-token"===we(e.attributes.name)||"p:domain_verify"===we(e.attributes.name)||"verify-v1"===we(e.attributes.name)||"verification"===we(e.attributes.name)||"shopify-checkout-api-token"===we(e.attributes.name)))return!0}}return!1}(M,f)&&(E||M.type!==K.Text||M.isStyle||M.textContent.replace(/^\s+|\s+$/gm,"").length)?oe():-2;const T=Object.assign(M,{id:k});if(r.add(e,T),-2===k)return null;m&&m(e);let O=!c;if(T.type===K.Element){O=O&&!T.needBlock,delete T.needBlock;const t=e.shadowRoot;t&&H(t)&&(T.isShadowHost=!0)}if((T.type===K.Document||T.type===K.Element)&&O){f.headWhitespace&&T.type===K.Element&&"head"===T.tagName&&(E=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w};if(T.type===K.Element&&"textarea"===T.tagName&&void 0!==T.attributes.value);else for(const n of Array.from(e.childNodes)){const e=Ce(n,t);e&&T.childNodes.push(e)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(const n of Array.from(e.shadowRoot.childNodes)){const r=Ce(n,t);r&&(H(e.shadowRoot)&&(r.isShadow=!0),T.childNodes.push(r))}}return e.parentNode&&$(e.parentNode)&&H(e.parentNode)&&(T.isShadow=!0),T.type===K.Element&&"iframe"===T.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"!==o){const r=setTimeout((()=>{s||(t(),s=!0)}),n);return void e.addEventListener("load",(()=>{clearTimeout(r),s=!0,t()}))}const i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,(()=>{const t=e.contentDocument;if(t&&y){const n=Ce(t,{doc:t,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w});n&&y(e,n)}}),S),T.type===K.Element&&"link"===T.tagName&&"stylesheet"===T.attributes.rel&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(e){return}if(r)return;const s=setTimeout((()=>{o||(t(),o=!0)}),n);e.addEventListener("load",(()=>{clearTimeout(s),o=!0,t()}))}(e,(()=>{if(b){const t=Ce(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w});t&&b(e,t)}}),I),T}var Ee=(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))(Ee||{}),Me=(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))(Me||{}),ke=(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))(ke||{}),Te=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Te||{}),Oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Oe||{});function xe(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Re="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Ne={map:{},getId:()=>(console.error(Re),-1),getNode:()=>(console.error(Re),null),removeNodeFromMap(){console.error(Re)},has:()=>(console.error(Re),!1),reset(){console.error(Re)}};function De(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function _e(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>_e(e,t,s||{},!0)}function Le(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Ne=new Proxy(Ne,{get:(e,t,n)=>("map"===t&&console.error(Re),Reflect.get(e,t,n))}));let Pe,Ae=Date.now;function Fe(e){var t,n,r,o,s,i;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(s=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function je(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ue(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Be(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function qe(e,t,n,r){if(!e)return!1;const o=Be(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(Se(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function We(e,t){return-2===t.getId(e)}function ze(e,t){if($(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ze(e.parentNode,t))}function Ke(e){return Boolean(e.changedTouches)}function Ve(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Ge(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $e(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(Ae=()=>(new Date).getTime());class He{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Xe(e){var t,n;let r=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Je(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=Xe(n);)n=t;return n}(e);return t.contains(n)}function Ye(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Je(e))}function Ze(e){Pe=e}function Qe(){Pe=void 0}const et=e=>{if(!Pe)return e;return(...t)=>{try{return e(...t)}catch(e){if(Pe&&!0===Pe(e))return;throw e}}};function tt(e){return(...t)=>{try{return e(...t)}catch(e){try{e._external_=!0}catch(e){}throw e}}}class nt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class rt{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new nt(oe),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new nt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case Ee.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:Ee.IncrementalSnapshot,data:{source:Me.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Ee.Meta:case Ee.Load:case Ee.DomContentLoaded:return!1;case Ee.Plugin:return t;case Ee.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Ee.IncrementalSnapshot:switch(t.data.source){case Me.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Me.Drag:case Me.TouchMove:case Me.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Me.ViewportResize:return!1;case Me.MediaInteraction:case Me.MouseInteraction:case Me.Scroll:case Me.CanvasMutation:case Me.Input:return this.replaceIds(t.data,e,["id"]),t;case Me.StyleSheetRule:case Me.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Me.Font:return t;case Me.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Me.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}patchRootIdOnNode(e,t){e.type===K.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function ot(e){return"__ln"in e}class st{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&ot(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&ot(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const it=(e,t)=>`${e}@${t}`;class at{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new st,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{if(!o.parentNode||!Ye(o)||"TEXTAREA"===o.parentNode.tagName)return;const s=$(o.parentNode)?this.mirror.getId(Xe(o)):this.mirror.getId(o.parentNode),i=r(o);if(-1===s||-1===i)return n.addNode(o);const a=Ce(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Ve(e,this.mirror)&&this.iframeManager.addIframe(e),Ge(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$e(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)ut(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)dt(this.droppedSet,e)||ut(this.removes,e,this.mirror)?dt(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=r(s.value);-1!==t&&-1!==n&&(e=s)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const r=t.parentNode.host;if(-1!==this.mirror.getId(r)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}s=e.previous,n.removeNode(e.value),o(e.value)}const i={texts:this.texts.map((e=>{const t=e.node;return"TEXTAREA"===t.parentNode.tagName&&this.genTextAreaValueMutation(t.parentNode),{id:this.mirror.getId(t),value:e.value}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.genTextAreaValueMutation=e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t)),t.attributes.value=Array.from(e.childNodes,(e=>e.textContent||"")).join("")},this.processMutation=e=>{if(!We(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;qe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:be(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,Be(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=te(t);r=Z({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(qe(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!ye(t.tagName,n)&&(o.attributes[n]=me(this.doc,Q(t.tagName),Q(n),r),"style"===n)){let n;try{n=document.implementation.createHTMLDocument()}catch(e){n=this.doc}const r=n.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const n=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||s!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===s?n:[n,s]:o._unchangedStyles[e]=[n,s]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(qe(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=$(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);qe(e.target,this.blockClass,this.blockSelector,!1)||We(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(ct(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ze(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[it(n,r)]?ct(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!$(e.target)||!H(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(We(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[it(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);qe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),$e(e)&&e.shadowRoot.childNodes.forEach((t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)})))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ct(e,t){e.delete(t),t.childNodes.forEach((t=>ct(e,t)))}function ut(e,t,n){return 0!==e.length&&lt(e,t,n)}function lt(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||lt(e,r,n)}function dt(e,t){return 0!==e.size&&ht(e,t)}function ht(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ht(e,n))}const ft=[];function pt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function vt(e,t){var n,r;const o=new at;ft.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(et(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function gt({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let c=null;return Object.keys(ke).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{let i=Q(s);const u=(t=>s=>{const i=pt(s);if(qe(i,r,o,!0))return;let a=null,u=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Te.Mouse;break;case"touch":a=Te.Touch;break;case"pen":a=Te.Pen}a===Te.Touch?ke[t]===ke.MouseDown?u="TouchStart":ke[t]===ke.MouseUp&&(u="TouchEnd"):Te.Pen}else Ke(s)&&(a=Te.Touch);null!==a?(c=a,(u.startsWith("Touch")&&a===Te.Touch||u.startsWith("Mouse")&&a===Te.Mouse)&&(a=null)):ke[t]===ke.Click&&(a=c,c=null);const l=Ke(s)?s.changedTouches[0]:s;if(!l)return;const d=n.getId(i),{clientX:h,clientY:f}=l;et(e)(Object.assign({type:ke[u],id:d,x:h,y:f},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(ke[s]){case ke.MouseDown:case ke.MouseUp:i=i.replace("mouse","pointer");break;case ke.TouchStart:case ke.TouchEnd:return}a.push(xe(i,u,t))})),et((()=>{a.forEach((e=>e()))}))}function mt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){const i=et(De(et((s=>{const i=pt(s);if(!i||qe(i,r,o,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=Fe(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})})),s.scroll||100));return xe("scroll",i,t)}function yt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const St=["INPUT","TEXTAREA","SELECT"],bt=new WeakMap;function It(e){return function(e,t){if(Mt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||Mt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||Mt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||Mt("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function wt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ct({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),et((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function Et(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:u,styleDeclarationCb:l,canvasMutationCb:d,fontCb:h,selectionCb:f}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),u(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),l(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),f(...e)}}(e,t),e.recordDOM&&(r=vt(e,e.doc));const o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=De(et((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null})),s),u=et(De(et((e=>{const t=pt(e),{clientX:n,clientY:o}=Ke(e)?e.changedTouches[0]:e;i||(i=Ae()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Ae()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Me.Drag:e instanceof MouseEvent?Me.MouseMove:Me.TouchMove)})),o,{trailing:!1})),l=[xe("mousemove",u,n),xe("touchmove",u,n),xe("drag",u,n)];return et((()=>{l.forEach((e=>e()))}))}(e),s=gt(e),i=mt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return xe("resize",et(De(et((()=>{const t=je(),o=Ue();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)})),200)),t)}(e,{win:n}),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:c,sampling:u,userTriggeredOnInput:l}){function d(e){let n=pt(e);const u=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||St.indexOf(d)<0||qe(n,r,o,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let f=n.value,p=!1;const v=te(n)||"";"radio"===v||"checkbox"===v?p=n.checked:(a[d.toLowerCase()]||a[v])&&(f=Z({element:n,maskInputOptions:a,tagName:d,type:v,value:f,maskInputFn:c})),h(n,et(yt)({text:f,isChecked:p,userTriggered:u},l));const g=n.name;"radio"===v&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&h(e,et(yt)({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function h(t,r){const o=bt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){bt.set(t,r);const o=n.getId(t);et(e)(Object.assign(Object.assign({},r),{id:o}))}}const f=("last"===u.input?["change"]:["input","change"]).map((e=>xe(e,et(d),t))),p=t.defaultView;if(!p)return()=>{f.forEach((e=>e()))};const v=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),g=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return v&&v.set&&f.push(...g.map((e=>_e(e[0],e[1],{set(){et(d)({target:this,isTrusted:!1})}},!1,p)))),et((()=>{f.forEach((e=>e()))}))}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:s}){const i=et((s=>De(et((o=>{const i=pt(o);if(!i||qe(i,t,n,!0))return;const{currentTime:a,volume:c,muted:u,playbackRate:l}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:u,playbackRate:l})})),o.media||500))),a=[xe("play",i(0),s),xe("pause",i(1),s),xe("seeked",i(2),s),xe("volumechange",i(3),s),xe("ratechange",i(4),s)];return et((()=>{a.forEach((e=>e()))}))}(e);let l=()=>{},d=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(l=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:et(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=wt(o,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:a}]}),tt((()=>r.apply(o,s)))()}))});const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:i}]}),tt((()=>r.apply(o,s)))()}))}),r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:i}),r.apply(o,s)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:i}),r.apply(o,s)}))}));const c={};kt("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(kt("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),kt("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),kt("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const u={};return Object.entries(c).forEach((([r,o])=>{u[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(u[r].insertRule,{apply:et(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=wt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:[...It(o),a||0]}]}),r.apply(o,s)}))}),o.prototype.deleteRule=new Proxy(u[r].deleteRule,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...It(o),i]}]}),r.apply(o,s)}))})})),et((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule}))}))}(e,{win:n}),d=Ct(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:et(((o,i,a)=>{var c;const[u,l,d]=a;if(n.has(u))return s.apply(i,[u,l,d]);const{id:h,styleId:f}=wt(null===(c=i.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(h&&-1!==h||f&&-1!==f)&&e({id:h,styleId:f,set:{property:u,value:l,priority:d},index:It(i.parentRule)}),o.apply(i,a)}))});const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:et(((o,s,a)=>{var c;const[u]=a;if(n.has(u))return i.apply(s,[u]);const{id:l,styleId:d}=wt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,remove:{property:u},index:It(s.parentRule)}),o.apply(s,a)}))}),et((()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}))}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Le(t.fonts,"add",(function(t){return function(n){return setTimeout(et((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),et((()=>{r.forEach((e=>e()))}))}(e)));const p=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=et((()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:u,endOffset:l}=s;qe(i,r,o,!0)||qe(u,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(u),endOffset:l})}s({ranges:a})}));return a(),xe("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return et((()=>{ft.forEach((e=>e.reset())),null==r||r.disconnect(),o(),s(),i(),a(),c(),u(),l(),d(),h(),f(),p(),v.forEach((e=>e()))}))}function Mt(e){return void 0!==window[e]}function kt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Tt(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Ot,xt,Rt,Nt=(Ot=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),r=0;r<t.length;r++)n[t.charCodeAt(r)]=r;var o=function(e){var n,r=new Uint8Array(e),o=r.length,s="";for(n=0;n<o;n+=3)s+=t[r[n]>>2],s+=t[(3&r[n])<<4|r[n+1]>>4],s+=t[(15&r[n+1])<<2|r[n+2]>>6],s+=t[63&r[n+2]];return o%3==2?s=s.substring(0,s.length-1)+"=":o%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=new Map,a=self;a.onmessage=function(t){return e(this,void 0,void 0,(function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:r,width:c,height:u,dataURLOptions:l}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(r),c=yield a.arrayBuffer(),u=o(c);return i.set(e,u),u}return""}))}(c,u,l),h=new OffscreenCanvas(c,u);h.getContext("2d").drawImage(r,0,0),r.close();const f=yield h.convertToBlob(l),p=f.type,v=yield f.arrayBuffer(),g=o(v);if(!s.has(n)&&(yield d)===g)return s.set(n,g),a.postMessage({id:n});if(s.get(n)===g)return a.postMessage({id:n});a.postMessage({id:n,type:p,base64:g,width:c,height:u}),s.set(n,g)}}))}}()},xt=null,function(e){return Rt=Rt||function(e,t){var n=function(e,t){var n=void 0===t?null:t,r=e.toString().split("\n");r.pop(),r.shift();for(var o=r[0].search(/\S/),s=/(['"])__worker_loader_strict__(['"])/g,i=0,a=r.length;i<a;++i)r[i]=r[i].substring(o).replace(s,"$1use strict$2")+"\n";return n&&r.push("//# sourceMappingURL="+n+"\n"),r}(e,t),r=new Blob(n,{type:"application/javascript"});return URL.createObjectURL(r)}(Ot,xt),new Worker(Rt,e)}),Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_t="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Lt=0;Lt<Dt.length;Lt++)_t[Dt.charCodeAt(Lt)]=Lt;const Pt=new Map;const At=(e,t,n)=>{if(!e||!Ut(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Pt.get(e);return n||(n=new Map,Pt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ft(e,t,n){if(e instanceof Array)return e.map((e=>Ft(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Dt[n[t]>>2],o+=Dt[(3&n[t])<<4|n[t+1]>>4],o+=Dt[(15&n[t+1])<<2|n[t+2]>>6],o+=Dt[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ft(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ft(e.data,t,n),e.width,e.height]}}if(Ut(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:At(e,t,n)}}return e}const jt=(e,t,n)=>[...e].map((e=>Ft(e,t,n))),Ut=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Bt(e,t,n,r){const o=[];try{const s=Le(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...s){if(!qe(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(s[0]&&"object"==typeof s[0]){const e=s[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...s])}}));o.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function qt(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Le(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(At(c,i,this),"tagName"in this.canvas&&!qe(this.canvas,r,o,!0)){const e=jt([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=_e(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}class Wt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,r,o){const s=Bt(t,n,r,!0),i=new Map,a=new Nt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:Oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let u,l=0;const d=e=>{l&&e-l<c||(l=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{qe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>Tt(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),u=requestAnimationFrame(d)};u=requestAnimationFrame(d),this.resetObservers=()=>{s(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Bt(e,t,n,!1),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Le(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return qe(this.canvas,n,r,!0)||setTimeout((()=>{const n=jt([...s],t,this);e(this.canvas,{type:Oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=_e(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:Oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...qt(t.WebGLRenderingContext.prototype,Oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...qt(t.WebGL2RenderingContext.prototype,Oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(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 o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class zt{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame((()=>{this.clear(),this.loop&&this.periodicallyClear()}))}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some((e=>e!==t))}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}class Kt{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!H(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=vt(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push((()=>n.disconnect())),this.restoreHandlers.push(mt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(Ct({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))}),0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(Le(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&Ye(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class Vt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new He,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,((e,t)=>({rule:J(e),index:t})))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Gt(e){return Object.assign(Object.assign({},e),{timestamp:Ae()})}let $t,Ht,Xt,Jt=!1;const Yt=new Y;function Zt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:p,maskTextFn:v,hooks:g,packFn:m,sampling:y={},dataURLOptions:S={},mousemoveWait:b,recordDOM:I=!0,recordCanvas:w=!1,recordCrossOriginIframes:C=!1,recordAfter:E=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:k=!1,inlineImages:T=!1,plugins:O,keepIframeSrcFn:x=(()=>!1),ignoreCSSAttributes:R=new Set([]),errorHandler:N}=e;Ze(N);const D=!C||window.parent===window;let _=!1;if(!D)try{window.parent.document&&(_=!1)}catch(e){_=!0}if(D&&!t)throw new Error("emit function is required");void 0!==b&&void 0===y.mousemove&&(y.mousemove=b),Yt.reset();const L=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},P=!0===f||"all"===f?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===f,headMetaDescKeywords:"all"===f}:f||{};let A;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const j=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return m&&!_&&(e=m(e)),e};$t=(e,o)=>{var s;if(!(null===(s=ft[0])||void 0===s?void 0:s.isFrozen())||e.type===Ee.FullSnapshot||e.type===Ee.IncrementalSnapshot&&e.data.source===Me.Mutation||ft.forEach((e=>e.unfreeze())),D)null==t||t(j(e),o);else if(_){const t={type:"rrweb",event:j(e),origin:window.location.origin,isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===Ee.FullSnapshot)A=e,F=0;else if(e.type===Ee.IncrementalSnapshot){if(e.data.source===Me.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Ht(!0)}};const U=e=>{$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Mutation},e)}))},B=e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Scroll},e)})),q=e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.CanvasMutation},e)})),W=new Vt({mutationCb:U,adoptedStyleSheetCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.AdoptedStyleSheet},e)}))}),z=new rt({mirror:Yt,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:$t});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Yt,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const K=new zt;Xt=new Wt({recordCanvas:w,mutationCb:q,win:window,blockClass:o,blockSelector:s,mirror:Yt,sampling:y.canvas,dataURLOptions:S});const V=new Kt({mutationCb:U,scrollCb:B,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskInputOptions:L,dataURLOptions:S,maskTextFn:v,maskInputFn:p,recordCanvas:w,inlineImages:T,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Xt,keepIframeSrcFn:x,processedNodeManager:K},mirror:Yt});Ht=(e=!1)=>{if(!I)return;$t(Gt({type:Ee.Meta,data:{href:window.location.href,width:Ue(),height:je()}}),e),W.reset(),V.init(),ft.forEach((e=>e.lock()));const t=function(e,t){const{mirror:n=new Y,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:s="rr-mask",maskTextSelector:i=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:u=!1,maskAllInputs:l=!1,maskTextFn:d,maskInputFn:h,slimDOM:f=!1,dataURLOptions:p,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:I=(()=>!1)}=t||{};return Ce(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===l?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===l?{password:!0}:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:!0===f||"all"===f?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===f,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===f?{}:f,dataURLOptions:p,inlineImages:c,recordCanvas:u,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:I,newlyAddedElement:!1})}(document,{mirror:Yt,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskAllInputs:L,maskTextFn:v,maskInputFn:p,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:T,onSerialize:e=>{Ve(e,Yt)&&z.addIframe(e),Ge(e,Yt)&&W.trackLinkElement(e),$e(e)&&V.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:x});if(!t)return console.warn("Failed to snapshot the document");$t(Gt({type:Ee.FullSnapshot,data:{node:t,initialOffset:Fe(window)}}),e),ft.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Yt.getId(document))};try{const e=[],t=e=>{var t;return et(Et)({mutationCb:U,mousemoveCb:(e,t)=>$t(Gt({type:Ee.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.MouseInteraction},e)})),scrollCb:B,viewportResizeCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.ViewportResize},e)})),inputCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Input},e)})),mediaInteractionCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.MediaInteraction},e)})),styleSheetRuleCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.StyleSheetRule},e)})),styleDeclarationCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.StyleDeclaration},e)})),canvasMutationCb:q,fontCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Font},e)})),selectionCb:e=>{$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Selection},e)}))},blockClass:o,ignoreClass:i,ignoreSelector:a,maskTextClass:c,maskTextSelector:u,maskInputOptions:L,inlineStylesheet:l,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:T,userTriggeredOnInput:M,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:v,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:P,dataURLOptions:S,mirror:Yt,iframeManager:z,stylesheetManager:W,shadowDomManager:V,processedNodeManager:K,canvasManager:Xt,ignoreCSSAttributes:R,plugins:(null===(t=null==O?void 0:O.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>$t(Gt({type:Ee.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},g)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Ht(),e.push(t(document)),Jt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(xe("DOMContentLoaded",(()=>{$t(Gt({type:Ee.DomContentLoaded,data:{}})),"DOMContentLoaded"===E&&n()}))),e.push(xe("load",(()=>{$t(Gt({type:Ee.Load,data:{}})),"load"===E&&n()}),window))),()=>{e.forEach((e=>e())),K.destroy(),Jt=!1,Qe()}}catch(e){console.warn(e)}}var Qt,en;Zt.addCustomEvent=(e,t)=>{if(!Jt)throw new Error("please add custom event after start recording");$t(Gt({type:Ee.Custom,data:{tag:e,payload:t}}))},Zt.freezePage=()=>{ft.forEach((e=>e.freeze()))},Zt.takeFullSnapshot=e=>{if(!Jt)throw new Error("please take full snapshot after start recording");Ht(e)},Zt.mirror=Yt,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(Qt||(Qt={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(en||(en={}));var tn=Uint8Array,nn=Uint16Array,rn=Uint32Array,on=new tn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),sn=new tn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),an=new tn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cn=function(e,t){for(var n=new nn(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new rn(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},un=cn(on,2),ln=un[0],dn=un[1];ln[28]=258,dn[258]=28;for(var hn=cn(sn,0)[1],fn=new nn(32768),pn=0;pn<32768;++pn){var vn=(43690&pn)>>>1|(21845&pn)<<1;vn=(61680&(vn=(52428&vn)>>>2|(13107&vn)<<2))>>>4|(3855&vn)<<4,fn[pn]=((65280&vn)>>>8|(255&vn)<<8)>>>1}var gn=function(e,t,n){for(var r=e.length,o=0,s=new nn(t);o<r;++o)++s[e[o]-1];var i,a=new nn(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new nn(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var u=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,h=d|(1<<l)-1;d<=h;++d)i[fn[d]>>>c]=u}else for(i=new nn(r),o=0;o<r;++o)i[o]=fn[a[e[o]-1]++]>>>15-e[o];return i},mn=new tn(288);for(pn=0;pn<144;++pn)mn[pn]=8;for(pn=144;pn<256;++pn)mn[pn]=9;for(pn=256;pn<280;++pn)mn[pn]=7;for(pn=280;pn<288;++pn)mn[pn]=8;var yn=new tn(32);for(pn=0;pn<32;++pn)yn[pn]=5;var Sn=gn(mn,9,0),bn=gn(yn,5,0),In=function(e){return(e/8>>0)+(7&e&&1)},wn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof nn?nn:e instanceof rn?rn:tn)(n-t);return r.set(e.subarray(t,n)),r},Cn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},En=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Mn=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new tn(0),0];if(1==o){var i=new tn(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],u=0,l=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=o-1;)a=n[n[u].f<n[d].f?u++:d++],c=n[u!=l&&n[u].f<n[d].f?u++:d++],n[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var f=new nn(h+1),p=kn(n[l-1],f,0);if(p>t){r=0;var v=0,g=p-t,m=1<<g;for(s.sort((function(e,t){return f[t.s]-f[e.s]||e.f-t.f}));r<o;++r){var y=s[r].s;if(!(f[y]>t))break;v+=m-(1<<p-f[y]),f[y]=t}for(v>>>=g;v>0;){var S=s[r].s;f[S]<t?v-=1<<t-f[S]++-1:++r}for(;r>=0&&v;--r){var b=s[r].s;f[b]==t&&(--f[b],++v)}p=t}return[new tn(f),p]},kn=function(e,t,n){return-1==e.s?Math.max(kn(e.l,t,n+1),kn(e.r,t,n+1)):t[e.s]=n},Tn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new nn(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},On=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},xn=function(e,t,n){var r=n.length,o=In(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Rn=function(e,t,n,r,o,s,i,a,c,u,l){Cn(t,l++,n),++o[256];for(var d=Mn(o,15),h=d[0],f=d[1],p=Mn(s,15),v=p[0],g=p[1],m=Tn(h),y=m[0],S=m[1],b=Tn(v),I=b[0],w=b[1],C=new nn(19),E=0;E<y.length;++E)C[31&y[E]]++;for(E=0;E<I.length;++E)C[31&I[E]]++;for(var M=Mn(C,7),k=M[0],T=M[1],O=19;O>4&&!k[an[O-1]];--O);var x,R,N,D,_=u+5<<3,L=On(o,mn)+On(s,yn)+i,P=On(o,h)+On(s,v)+i+14+3*O+On(C,k)+(2*C[16]+3*C[17]+7*C[18]);if(_<=L&&_<=P)return xn(t,l,e.subarray(c,c+u));if(Cn(t,l,1+(P<L)),l+=2,P<L){x=gn(h,f,0),R=h,N=gn(v,g,0),D=v;var A=gn(k,T,0);Cn(t,l,S-257),Cn(t,l+5,w-1),Cn(t,l+10,O-4),l+=14;for(E=0;E<O;++E)Cn(t,l+3*E,k[an[E]]);l+=3*O;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(E=0;E<U.length;++E){var B=31&U[E];Cn(t,l,A[B]),l+=k[B],B>15&&(Cn(t,l,U[E]>>>5&127),l+=U[E]>>>12)}}}else x=Sn,R=mn,N=bn,D=yn;for(E=0;E<a;++E)if(r[E]>255){B=r[E]>>>18&31;En(t,l,x[B+257]),l+=R[B+257],B>7&&(Cn(t,l,r[E]>>>23&31),l+=on[B]);var q=31&r[E];En(t,l,N[q]),l+=D[q],q>3&&(En(t,l,r[E]>>>5&8191),l+=sn[q])}else En(t,l,x[r[E]]),l+=R[r[E]];return En(t,l,x[256]),l+R[256]},Nn=new rn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Dn=new tn(0),_n=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new tn(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),u=0;if(!t||i<8)for(var l=0;l<=i;l+=65535){var d=l+65535;d<i?u=xn(c,u,e.subarray(l,d)):(c[l]=s,u=xn(c,u,e.subarray(l,i)))}else{for(var h=Nn[t-1],f=h>>>13,p=8191&h,v=(1<<n)-1,g=new nn(32768),m=new nn(v+1),y=Math.ceil(n/3),S=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<S)&v},I=new rn(25e3),w=new nn(288),C=new nn(32),E=0,M=0,k=(l=0,0),T=0,O=0;l<i;++l){var x=b(l),R=32767&l,N=m[x];if(g[R]=N,m[x]=R,T<=l){var D=i-l;if((E>7e3||k>24576)&&D>423){u=Rn(e,c,0,I,w,C,M,k,O,l-O,u),k=E=M=0,O=l;for(var _=0;_<286;++_)w[_]=0;for(_=0;_<30;++_)C[_]=0}var L=2,P=0,A=p,F=R-N&32767;if(D>2&&x==b(l-F))for(var j=Math.min(f,D)-1,U=Math.min(32767,l),B=Math.min(258,D);F<=U&&--A&&R!=N;){if(e[l+L]==e[l+L-F]){for(var q=0;q<B&&e[l+q]==e[l+q-F];++q);if(q>L){if(L=q,P=F,q>j)break;var W=Math.min(F,q-2),z=0;for(_=0;_<W;++_){var K=l-F+_+32768&32767,V=K-g[K]+32768&32767;V>z&&(z=V,N=K)}}}F+=(R=N)-(N=g[R])+32768&32767}if(P){I[k++]=268435456|dn[L]<<18|hn[P];var G=31&dn[L],$=31&hn[P];M+=on[G]+sn[$],++w[257+G],++C[$],T=l+L,++E}else I[k++]=e[l],++w[e[l]]}}u=Rn(e,c,s,I,w,C,M,k,O,l-O,u),s||(u=xn(c,u,Dn))}return wn(a,0,r+In(u)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Ln(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=_n(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Pn=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Ln(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new tn(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new tn(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return wn(r,0,o)}(JSON.stringify(t))),!0)};var An,Fn;(Fn=An||(An={}))[Fn.NotStarted=0]="NotStarted",Fn[Fn.Running=1]="Running",Fn[Fn.Stopped=2]="Stopped";const jn=(e,t)=>t.some((t=>e instanceof t));let Un,Bn;const qn=new WeakMap,Wn=new WeakMap,zn=new WeakMap;let Kn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return qn.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Hn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Vn(e){Kn=e(Kn)}function Gn(e){return(Bn||(Bn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Xn(this),t),Hn(this.request)}:function(...t){return Hn(e.apply(Xn(this),t))}}function $n(e){return"function"==typeof e?Gn(e):(e instanceof IDBTransaction&&function(e){if(qn.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)}));qn.set(e,t)}(e),jn(e,Un||(Un=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Kn):e)}function Hn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t(Hn(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)}));return zn.set(t,e),t}(e);if(Wn.has(e))return Wn.get(e);const t=$n(e);return t!==e&&(Wn.set(e,t),zn.set(t,e)),t}const Xn=e=>zn.get(e);function Jn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Hn(i);return r&&i.addEventListener("upgradeneeded",(e=>{r(Hn(i.result),e.oldVersion,e.newVersion,Hn(i.transaction),e)})),n&&i.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Yn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Hn(n).then((()=>{}))}const Zn=["get","getKey","getAll","getAllKeys","count"],Qn=["put","add","delete","clear"],er=new Map;function tr(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(er.get(t))return er.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Qn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Zn.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return er.set(t,s),s}Vn((e=>({...e,get:(t,n,r)=>tr(t,n)||e.get(t,n,r),has:(t,n)=>!!tr(t,n)||e.has(t,n)})));const nr=["continue","continuePrimaryKey","advance"],rr={},or=new WeakMap,sr=new WeakMap,ir={get(e,t){if(!nr.includes(t))return e[t];let n=rr[t];return n||(n=rr[t]=function(...e){or.set(this,sr.get(this)[t](...e))}),n}};async function*ar(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,ir);for(sr.set(n,t),zn.set(n,Xn(t));t;)yield n,t=await(or.get(n)||t.continue()),or.delete(n)}function cr(e,t){return t===Symbol.asyncIterator&&jn(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&jn(e,[IDBIndex,IDBObjectStore])}Vn((e=>({...e,get:(t,n,r)=>cr(t,n)?ar:e.get(t,n,r),has:(t,n)=>cr(t,n)||e.has(t,n)})));var ur,lr=function(e,t){return o(void 0,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,Jn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},dr=function(e){var t=e.loggerProvider,n=e.apiKey,i=e.configKeys;return o(void 0,void 0,void 0,(function(){var e,u,l,d,h,f,p,v,g,m;return s(this,(function(y){switch(y.label){case 0:return e="".concat(n.substring(0,10),"_amp_config"),[4,lr(e,i)];case 1:return u=y.sent(),l="".concat(n.substring(0,10),"_amp_config_meta"),[4,(S=l,o(void 0,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(S,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:d=y.sent(),y.label=3;case 3:return y.trys.push([3,8,,9]),[4,d.get("lastFetchedSessionId","sessionId")];case 4:return(h=y.sent())&&Date.now()-h>=2592e5?(u.close(),[4,Yn(e)]):[3,7];case 5:return y.sent(),[4,lr(e,i)];case 6:u=y.sent(),y.label=7;case 7:return[3,9];case 8:return f=y.sent(),t.warn("Failed to reset store: ".concat(f)),[3,9];case 9:return p=function(e,n){return o(void 0,void 0,void 0,(function(){var o,i,l,h,f,p;return s(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,d.put("lastFetchedSessionId",n,"sessionId")]:[3,2];case 1:v.sent(),v.label=2;case 2:for(h in o=function(t){var n,o;return s(this,(function(s){switch(s.label){case 0:return n=e.configs[t],o=u.transaction(t,"readwrite"),[4,Promise.all(c(c([],a(Object.keys(n).map((function(e){return o.store.put(r({},n[e]),e)}))),!1),[o.done],!1))];case 1:return s.sent(),[2]}}))},i=e.configs,l=[],i)l.push(h);f=0,v.label=3;case 3:return f<l.length?(h=l[f])in i?[5,o(h)]:[3,5]:[3,6];case 4:v.sent(),v.label=5;case 5:return f++,[3,3];case 6:return[3,8];case 7:return p=v.sent(),t.warn("Failed to store remote config: ".concat(p)),[3,8];case 8:return[2]}}))}))},v=function(){return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d.get("lastFetchedSessionId","sessionId")];case 1:return[2,n.sent()];case 2:return e=n.sent(),t.warn("Failed to fetch lastFetchedSessionId: ".concat(e)),[3,3];case 3:return[2,void 0]}}))}))},g=function(e,n){return o(void 0,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.get(e,n)];case 1:return[2,o.sent()];case 2:return r=o.sent(),t.warn("Failed to fetch remote config: ".concat(r)),[3,3];case 3:return[2,void 0]}}))}))},m=function(e){return o(void 0,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,u.getAll(e)];case 1:return[2,!!r.sent().length];case 2:return n=r.sent(),t.warn("Failed to fetch remote config: ".concat(n)),[3,3];case 3:return[2,!1]}}))}))},[2,{storeRemoteConfig:p,getRemoteConfig:g,getLastFetchedSessionId:v,remoteConfigHasValues:m}]}var S}))}))},hr="Remote config fetch rejected due to timeout after 5 seconds",fr=function(){function e(e){var t=e.localConfig,n=e.configKeys,i=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.fetchTime=0,this.getRemoteConfig=function(e,t,n){return o(i,void 0,void 0,(function(){var r,o,i,a,c;return s(this,(function(s){switch(s.label){case 0:return r=Date.now(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getLastFetchedSessionId()]:[3,3];case 1:return(o=s.sent())&&n&&o===n?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 2:return i=s.sent(),this.fetchTime=Date.now()-r,[2,i];case 3:return[4,this.fetchWithTimeout(n)];case 4:return(a=s.sent())&&(c=a.configs&&a.configs[e])?(this.fetchTime=Date.now()-r,[2,c[t]]):(this.fetchTime=Date.now()-r,[2,void 0])}}))}))},this.fetchWithTimeout=function(e){return o(i,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return o(i,void 0,void 0,(function(){var n,o,i,a,c,u;return s(this,(function(s){switch(s.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:hr})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),s.label=1;case 1:return s.trys.push([1,3,,4]),n=new URLSearchParams({api_key:this.localConfig.apiKey,config_keys:this.configKeys.join(",")}),o={headers:{"Content-Type":"application/json",Accept:"*/*"},method:"GET"},i="".concat(this.getServerUrl(),"?").concat(n.toString()),this.attempts+=1,[4,fetch(i,r(r({},o),{signal:e}))];case 2:if(null===(a=s.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new F).buildStatus(a.status)){case S.Success:return this.attempts=0,[2,this.parseAndStoreConfig(a,t)];case S.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return c=s.sent(),u=c,e.aborted?[2,this.completeRequest({err:hr})]:[2,this.completeRequest({err:u.message})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return o(i,void 0,void 0,(function(){var n=this;return s(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e,t){return o(i,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.storeRemoteConfig(n,t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return this.completeRequest({success:"Remote config successfully fetched"}),[2,n]}}))}))},this.localConfig=t,this.configKeys=n}return e.prototype.initialize=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this,[4,dr({apiKey:this.localConfig.apiKey,loggerProvider:this.localConfig.loggerProvider,configKeys:this.configKeys})];case 1:return e.remoteConfigIDBStore=t.sent(),[2]}}))}))},e.prototype.getServerUrl=function(){return this.localConfig.serverZone===y.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===y.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),pr=function(e){var t=e.localConfig,n=e.configKeys;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return[4,(e=new fr({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},vr="medium";!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ur||(ur={}));var gr,mr=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){const 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 mr(e,vr,n)}},yr=function(e,t){return function(n,r){return function(e,t,n){var r,o,s;if(void 0===t&&(t={defaultMaskLevel:vr}),n){if(n.closest("."+z))return!0;var i=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(i)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return mr(e,null!==(s=t.defaultMaskLevel)&&void 0!==s?s:vr,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Sr=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},br=function(e){return e===y.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===y.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track"},Ir=function(){return o(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),(e=E())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=s.sent(),n=t.usage,r=t.quota,o=t.usageDetails,i=n?Math.round(n/1024):0,a=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:i,percentOfQuota:a,usageDetails:JSON.stringify(o)}];case 2:return[3,4];case 3:return s.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}}))}))},wr=function(e){var t=r({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},Cr=function(){function e(e,t){this.localConfig=new G(e,t)}return e.prototype.initialize=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this,[4,pr({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){var t,n,c;return o(this,void 0,void 0,(function(){var o,u,l,d,h,f,p,v,g,m,y,S,b,I,w,C,E,M,k,T,O,x;return s(this,(function(s){switch(s.label){case 0:(o=r({},this.localConfig)).optOut=this.localConfig.optOut,o.captureEnabled=!0,s.label=1;case 1:return s.trys.push([1,6,,7]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:(o.captureEnabled=!1,[2,o]);case 2:return l=s.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return d=s.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_targeting_config",e)];case 4:return h=s.sent(),f=o,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_interaction_config",e)];case 5:return f.interactionConfig=s.sent(),(l||d)&&(u={},l&&(u.sr_sampling_config=l),d&&(u.sr_privacy_config=d),h&&(u.sr_targeting_config=h)),[3,7];case 6:return p=s.sent(),v=p,this.localConfig.loggerProvider.warn(v.message),o.captureEnabled=!1,[3,7];case 7:if(!u)return[2,o];if(g=u.sr_sampling_config,m=u.sr_privacy_config,y=u.sr_targeting_config,g&&Object.keys(g).length>0?(Object.prototype.hasOwnProperty.call(g,"capture_enabled")?o.captureEnabled=g.capture_enabled:o.captureEnabled=!1,Object.prototype.hasOwnProperty.call(g,"sample_rate")&&(o.sampleRate=g.sample_rate)):(o.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),m){S=null!==(t=o.privacyConfig)&&void 0!==t?t:{},b={defaultMaskLevel:null!==(c=null!==(n=m.defaultMaskLevel)&&void 0!==n?n:S.defaultMaskLevel)&&void 0!==c?c:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},I=function(e){var t,n,r,o,s,a,c,u,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var h=i(null!==(c=e.blockSelector)&&void 0!==c?c:[]),f=h.next();!f.done;f=h.next()){d[f.value]="block"}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var p=i(null!==(u=e.maskSelector)&&void 0!==u?u:[]),v=p.next();!v.done;v=p.next()){d[v.value]="mask"}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var g=i(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),m=g.next();!m.done;m=g.next()){d[m.value]="unmask"}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=g.return)&&a.call(g)}finally{if(s)throw s.error}}return d},w=r(r({},I(S)),I(m));try{for(C=i(Object.entries(w)),E=C.next();!E.done;E=C.next())M=a(E.value,2),k=M[0],"mask"===(T=M[1])?b.maskSelector.push(k):"block"===T?b.blockSelector.push(k):"unmask"===T&&b.unmaskSelector.push(k)}catch(e){O={error:e}}finally{try{E&&!E.done&&(x=C.return)&&x.call(C)}finally{if(O)throw O.error}}o.privacyConfig=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e}(b,this.localConfig.loggerProvider)}return y&&Object.keys(y).length>0&&(o.targetingConfig=y),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:wr(o)},null,2)),[2,o]}}))}))},e}(),Er=function(e,t){return o(void 0,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,(n=new Cr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},Mr="Session replay event batch rejected due to exceeded retry count",kr="Failed to store session replay events in IndexedDB";!function(e){e.RECORDING="recording",e.SENT="sent"}(gr||(gr={}));var Tr,Or,xr,Rr="sessionCurrentSequence",Nr="sequencesToSend",Dr=function(){var e=E();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)}}catch(e){n(e)}}))},_r=function(e){return o(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e.length>0?(10,t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},Lr=function(e){var t,n;return e.objectStoreNames.contains(Rr)||(n=e.createObjectStore(Rr,{keyPath:"sessionId"})),e.objectStoreNames.contains(Nr)||(t=e.createObjectStore(Nr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Pr=function(e){return o(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,Jn(e,1,{upgrade:Lr})];case 1:return[2,t.sent()]}}))}))},Ar=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,i=e.minInterval,a=e.maxInterval,c=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=c.maxPersistedEventsSize||!!(null!==c.timeAtLastSplit&&c.interval&&Date.now()-c.timeAtLastSplit>c.interval&&e.length)&&(c.interval=Math.min(c.maxInterval,c.interval+c.minInterval),c.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return o(c,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,null===(t=this.db)||void 0===t?void 0:t.getAll(Nr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=function(e){return o(c,void 0,void 0,(function(){var t,n,o;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),this.db?[4,this.db.get(Rr,e)]:[2,void 0];case 1:return(t=s.sent())?[4,this.db.put(Nr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=s.sent(),[4,this.db.put(Rr,{sessionId:e,events:[]})];case 3:return s.sent(),[2,r(r({},t),{sessionId:e,sequenceId:n})];case 4:return o=s.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(o)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return o(c,void 0,void 0,(function(){var n,r,o,i,a,c,u;return s(this,(function(s){switch(s.label){case 0:0===this.interval&&(this.interval=this.minInterval),s.label=1;case 1:return s.trys.push([1,11,,12]),(n=null===(u=this.db)||void 0===u?void 0:u.transaction(Rr,"readwrite"))?[4,n.store.get(e)]:[2];case 2:return(r=s.sent())?[3,4]:[4,n.store.put({sessionId:e,events:[t]})];case 3:return s.sent(),[2];case 4:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,6];case 5:return s.sent(),[3,8];case 6:return i=r.events.concat(t),[4,n.store.put({sessionId:e,events:i})];case 7:s.sent(),s.label=8;case 8:return[4,n.done];case 9:return s.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 10:return(a=s.sent())?[2,{events:o,sessionId:e,sequenceId:a}]:[2,void 0];case 11:return c=s.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(c)),[3,12];case 12:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return o(c,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(r=this.db)||void 0===r?void 0:r.put(Nr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return o(c,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,null===(n=this.db)||void 0===n?void 0:n.delete(Nr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return o(c,void 0,void 0,(function(){var t,n,r,i,a,c,u,l,d=this;return s(this,(function(h){switch(h.label){case 0:return h.trys.push([0,6,,7]),[4,Dr()];case 1:if(!(t=h.sent()))return[2];n=function(e,t){return o(d,void 0,void 0,(function(){var n,r,i=this;return s(this,(function(a){switch(a.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(a){var c=parseInt(a,10),u=n[c];if(c===t.currentSequenceId){var l=u.events.map((function(t){return o(i,void 0,void 0,(function(){return s(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));r.concat(l)}else u.status!==gr.SENT&&r.push(i.storeSendingEvents(e,u.events))})),[4,_r(r)];case 1:return a.sent(),[2]}}))}))},r="".concat(k,"_").concat(this.apiKey.substring(0,10)),h.label=2;case 2:return h.trys.push([2,4,,5]),i=t.transaction("keyval").objectStore("keyval").getAll(r),a=new Promise((function(t){i.onsuccess=function(r){return o(d,void 0,void 0,(function(){var o,i,a,c=this;return s(this,(function(s){switch(s.label){case 0:return o=r&&r.target.result,(i=o&&o[0])?(a=[],Object.keys(i).forEach((function(t){var r=parseInt(t,10),o=i[r];if(e===r)a.push(n(r,o));else{var s=o.sessionSequences;Object.keys(s).forEach((function(e){var t=parseInt(e,10);s[t].status!==gr.SENT&&a.push(c.storeSendingEvents(r,s[t].events))}))}})),[4,_r(a)]):[3,2];case 1:s.sent(),s.label=2;case 2:return t(),[2]}}))}))}})),[4,a];case 3:return h.sent(),(c=E())&&c.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return u=h.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(u)),[3,5];case 5:return[3,7];case 6:return l=h.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(l,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},this.loggerProvider=t,this.apiKey=n,this.maxInterval=null!=a?a:1e4,this.minInterval=null!=i?i:500,this.interval=0}return e.prototype.initialize=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(s){switch(s.label){case 0:return n="replay"===e?"":"_".concat(e),r="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events").concat(n),o=this,[4,Pr(r)];case 1:return o.db=s.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(t)];case 2:return s.sent(),[2]}}))}))},e}(),Fr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId,i=e.type,a=e.minInterval,c=e.maxInterval;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(o){switch(o.label){case 0:return[4,(e=new Ar({loggerProvider:t,apiKey:n,minInterval:a,maxInterval:c})).initialize(i,r)];case 1:return o.sent(),[2,e]}}))}))},jr="1.14.0-srtargeting.0",Ur=function(){function e(e){var t=e.loggerProvider,n=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t,this.payloadBatcher=n||function(e){return e}}return e.prototype.sendEventsList=function(e){this.addToQueue(r(r({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(Mr,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t=!0),o(this,void 0,void 0,(function(){var o,i,a,c,u,l,d,h,f,p,v,g,m;return s(this,(function(s){switch(s.label){case 0:if(!(o=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(i=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(y=E(),a=(null==y?void 0:y.location)?y.location.href:"",c=jr,u=e.sampleRate,l=new URLSearchParams({device_id:i,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId),type:"".concat(e.type)}),d="".concat((null===(n=e.version)||void 0===n?void 0:n.type)||"standalone","/").concat((null===(r=e.version)||void 0===r?void 0:r.version)||c),0===(h=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),f={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(o),"X-Client-Version":c,"X-Client-Library":d,"X-Client-Url":a,"X-Client-Sample-Rate":"".concat(u)},body:JSON.stringify(h),method:"POST"},p="".concat(br(e.serverZone),"?").concat(l.toString()),[4,fetch(p,f)];case 2:if(null===(v=s.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(v.status,e);else{g="";try{g=JSON.stringify(v.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(v.status,": ").concat(g)})}return[3,4];case 3:return m=s.sent(),this.completeRequest({context:e,err:m}),[3,4];case 4:return[2]}var y}))}))},e.prototype.handleReponse=function(e,t){switch((new F).buildStatus(e)){case S.Success:this.handleSuccessResponse(t);break;case S.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch with seq id ".concat(e.sequenceId," tracked successfully for session id ").concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){this.addToQueue(r(r({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(t.sequenceId),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}(),Br=function(e){var t=e.config,n=e.sessionId,r=e.minInterval,i=e.maxInterval,a=e.type,c=e.payloadBatcher;return o(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,u.flush(e)]}))}))}var u,l,d,h,f,p;return s(this,(function(v){switch(v.label){case 0:return u=new Ur({loggerProvider:t.loggerProvider,payloadBatcher:c}),[4,Fr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n,minInterval:r,maxInterval:i,type:a})];case 1:return l=v.sent(),d=function(e){var n=e.events,r=e.sessionId,o=e.deviceId,s=e.sequenceId;t.debugMode&&Ir().then((function(e){var n=e.totalStorageSize,r=e.percentOfQuota,o=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(o))})).catch((function(){})),u.sendEventsList({events:n,sequenceId:s,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:a,onComplete:l.cleanUpSessionEventsStore.bind(l)})},h=function(e){var n=e.sessionId,r=e.deviceId;l.storeCurrentSequence(n).then((function(e){e&&d({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)}))},f=function(e){var t=e.deviceId;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,l.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},p=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;l.addEventToCurrentSequence(r,n.data).then((function(e){return e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:h,addEvent:p,sendStoredEvents:f,flush:e}]}}))}))},qr=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 o(this,void 0,void 0,(function(){var t;return s(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,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},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 o(this,void 0,void 0,(function(){var t;return s(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}(),Wr=(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))(Wr||{});function zr(e,t){if(xr=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};Tr=r(r({},n),t),Or=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Tr.root,n);var o=Kr(e,"all",(function(){return Kr(e,"two",(function(){return Kr(e,"one",(function(){return Kr(e,"none")}))}))}));if(o){var s=eo(to(o,e));return s.length>0&&(o=s[0]),Gr(o)}throw new Error("Selector was not found.")}function Kr(e,t,n){for(var r=null,o=[],s=e,u=0,l=function(){var e,l,d=(new Date).getTime()-xr.getTime();if(void 0!==Tr.timeoutMs&&d>Tr.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var h=Yr(function(e){var t=e.getAttribute("id");if(t&&Tr.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(s))||Yr.apply(void 0,c([],a(function(e){var t=Array.from(e.attributes).filter((function(e){return Tr.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(s)),!1))||Yr.apply(void 0,c([],a(function(e){var t=Array.from(e.classList).filter(Tr.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(s)),!1))||Yr(function(e){var t=e.tagName.toLowerCase();if(Tr.tagName(t))return{name:t,penalty:2};return null}(s))||[{name:"*",penalty:3}],f=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}(s);if("all"==t)f&&(h=h.concat(h.filter(Jr).map((function(e){return Xr(e,f)}))));else if("two"==t)h=h.slice(0,1),f&&(h=h.concat(h.filter(Jr).map((function(e){return Xr(e,f)}))));else if("one"==t){var p=a(h=h.slice(0,1),1)[0];f&&Jr(p)&&(h=[Xr(p,f)])}else"none"==t&&(h=[{name:"*",penalty:3}],f&&(h=[Xr(h[0],f)]));try{for(var v=(e=void 0,i(h)),g=v.next();!g.done;g=v.next()){(p=g.value).level=u}}catch(t){e={error:t}}finally{try{g&&!g.done&&(l=v.return)&&l.call(v)}finally{if(e)throw e.error}}if(o.push(h),o.length>=Tr.seedMinLength&&(r=Vr(o,n)))return"break";s=s.parentElement,u++};s;){if("break"===l())break}return r||(r=Vr(o,n)),!r&&n?n():r}function Vr(e,t){var n,r,o=eo(Qr(e));if(o.length>Tr.threshold)return t?t():null;try{for(var s=i(o),a=s.next();!a.done;a=s.next()){var c=a.value;if(Hr(c))return c}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null}function Gr(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function $r(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function Hr(e){var t=Gr(e);switch(Or.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 Xr(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function Jr(e){return"html"!==e.name&&!e.name.startsWith("#")}function Yr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Zr);return n.length>0?n:null}function Zr(e){return null!=e}function Qr(e,t){var n,r,o,a,c,u;return void 0===t&&(t=[]),s(this,(function(s){switch(s.label){case 0:if(!(e.length>0))return[3,9];s.label=1;case 1:s.trys.push([1,6,7,8]),n=i(e[0]),r=n.next(),s.label=2;case 2:return r.done?[3,5]:(o=r.value,[5,i(Qr(e.slice(1,e.length),t.concat(o)))]);case 3:s.sent(),s.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),c={error:a},[3,8];case 7:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:s.sent(),s.label=11;case 11:return[2]}}))}function eo(e){return c([],a(e),!1).sort((function(e,t){return $r(e)-$r(t)}))}function to(e,t,n){var r,o,u;return void 0===n&&(n={counter:0,visited:new Map}),s(this,(function(s){switch(s.label){case 0:if(!(e.length>2&&e.length>Tr.optimizedMinLength))return[3,5];r=1,s.label=1;case 1:return r<e.length-1?n.counter>Tr.maxNumberOfTries?[2]:(n.counter+=1,(o=c([],a(e),!1)).splice(r,1),u=Gr(o),n.visited.has(u)?[2]:Hr(o)&&function(e,t){return Or.querySelector(Gr(e))===t}(o,t)?[4,o]:[3,4]):[3,5];case 2:return s.sent(),n.visited.set(u,!0),[5,i(to(o,t,n))];case 3:s.sent(),s.label=4;case 4:return r++,[3,1];case 5:return[2]}}))}var no=function(e){var t=e.version,n=e.events,o=[];n.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&o.push(t)}));var s=o.reduce((function(e,t){var n=t.x,o=t.y,s=t.selector,i=t.timestamp,a=i-i%36e5,c="".concat(n,":").concat(o,":").concat(null!=s?s:"",":").concat(a);return e[c]?e[c].count+=1:e[c]=r(r({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(s)}},ro=function(e){var t=e.eventsManager,n=e.sessionId,r=e.deviceIdFn;return function(e){if(e.type===Wr.Click){var o=E();if(o){var s=o.location,i=o.innerHeight,a=o.innerWidth;if(s){var c,u=e.x,l=e.y,d=Zt.mirror.getNode(e.id);d&&(c=zr(d));var h=Fe(o),f={x:u+h.left,y:l+h.top,selector:c,viewportHeight:i,viewportWidth:a,pageUrl:s.href,timestamp:Date.now(),type:"click"},p=r();p&&t.addEvent({sessionId:n,event:{type:"interaction",data:JSON.stringify(f)},deviceId:p})}}}}},oo=function(){function e(e,t){var n=E();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=br(t.serverZone),this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,o=n.type,s=new URLSearchParams({device_id:e,session_id:String(r),type:String(o)}),i="".concat(this.basePageUrl,"?").concat(s.toString());this.sendBeacon(i,t)||this.sendXhr(i,t)},e}(),so=je,io=Ue,ao=function(){function e(e){var t=this;this.timestamp=Date.now(),this.hook=function(e){t.update(e)},this.send=function(e){return function(n){var r=e(),o=E();o&&r&&t.transport.send(r,{maxScrollX:t._maxScrollX,maxScrollY:t._maxScrollY,maxScrollWidth:t._maxScrollWidth,maxScrollHeight:t._maxScrollHeight,viewportHeight:so(),viewportWidth:io(),pageUrl:o.location.href,timestamp:t.timestamp,type:"scroll"})}},this._maxScrollX=0,this._maxScrollY=0,this._maxScrollWidth=io(),this._maxScrollHeight=so(),this.transport=e}return e.default=function(t,n){return new e(new oo(t,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},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}),e.prototype.update=function(e){var t=Date.now();if(e.x>this._maxScrollX){var n=io();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var o=so();this._maxScrollY=e.y;var s=e.y+o;s>this._maxScrollHeight&&(this._maxScrollHeight=s),this.timestamp=t}},e}(),co=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))},uo=function(e,t){return uo=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])},uo(e,t)};var lo=function(){return lo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},lo.apply(this,arguments)};function ho(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"==typeof SuppressedError&&SuppressedError;var fo="is",po="is not",vo="contains",go="does not contain",mo="less",yo="less or equal",So="greater",bo="greater or equal",Io="version less",wo="version less or equal",Co="version greater",Eo="version greater or equal",Mo="set is",ko="set is not",To="set contains",Oo="set does not contain",xo="set contains any",Ro="set does not contain any",No="regex match",Do="regex does not match",_o=-862048943,Lo=461845907,Po=function(e,t){void 0===t&&(t=0);for(var n=function(e){for(var t=[],n=0,r=0;r<e.length;r++){var o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return Uint8Array.from(t)}(e),r=n.length,o=r>>2,s=t,i=0;i<o;i++){var a=Uo(n,i<<2);s=Ao(a,s)}var c=o<<2,u=0;switch(r-c){case 3:u^=n[c+2]<<16,u^=n[c+1]<<8,u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo);break;case 2:u^=n[c+1]<<8,u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo);break;case 1:u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo)}return Fo(s^=r)>>>0},Ao=function(e,t){var n=e,r=t;return n=Math.imul(n,_o),n=jo(n,15),n=Math.imul(n,Lo),r=jo(r^=n,13),(r=Math.imul(r,5))+-430675100|0},Fo=function(e){var t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16},jo=function(e,t,n){return void 0===n&&(n=32),t>n&&(t%=n),(e<<t|(e&4294967295<<n-t>>>0)>>>0>>>n-t>>>0)>>>0},Uo=function(e,t){void 0===t&&(t=0);var n=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return Bo(n)},Bo=function(e){return(-16777216&e)>>>24|(16711680&e)>>>8|(65280&e)<<8|(255&e)<<24},qo=function(e,t){var n,r;if(t&&0!==t.length){try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(!i||!e||"object"!=typeof e)return;e=e[i]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return e||void 0}},Wo="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),zo=function(){function e(e,t,n,r){void 0===r&&(r=void 0),this.major=e,this.minor=t,this.patch=n,this.preRelease=r}return e.parse=function(t){if(t){var n=new RegExp(Wo).exec(t);if(n){var r=Number(n[1]),o=Number(n[2]);if(!isNaN(r)&&!isNaN(o))return new e(r,o,Number(n[4])||0,n[5]||void 0)}}},e.prototype.compareTo=function(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0},e}(),Ko=function(){function e(){}return e.prototype.evaluate=function(e,t){var n,r,o={},s={context:e,result:o};try{for(var i=ho(t),a=i.next();!a.done;a=i.next()){var c=a.value,u=this.evaluateFlag(s,c);u&&(o[c.key]=u)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o},e.prototype.evaluateFlag=function(e,t){var n,r,o;try{for(var s=ho(t.segments),i=s.next();!i.done;i=s.next()){var a=i.value;if(o=this.evaluateSegment(e,t,a)){var c=lo(lo(lo({},t.metadata),a.metadata),o.metadata);o=lo(lo({},o),{metadata:c});break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o},e.prototype.evaluateSegment=function(e,t,n){var r,o,s,i;if(!n.conditions)return void 0!==(u=this.bucket(e,n))?t.variants[u]:void 0;try{for(var a=ho(n.conditions),c=a.next();!c.done;c=a.next()){var u,l=c.value,d=!0;try{for(var h=(s=void 0,ho(l)),f=h.next();!f.done;f=h.next()){var p=f.value;if(!(d=this.matchCondition(e,p)))break}}catch(e){s={error:e}}finally{try{f&&!f.done&&(i=h.return)&&i.call(h)}finally{if(s)throw s.error}}if(d)return void 0!==(u=this.bucket(e,n))?t.variants[u]:void 0}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}},e.prototype.matchCondition=function(e,t){var n=qo(e,t.selector);if(n){if(this.isSetOperator(t.op)){var r=this.coerceStringArray(n);return!!r&&this.matchSet(r,t.op,t.values)}var o=this.coerceString(n);return void 0!==o&&this.matchString(o,t.op,t.values)}return this.matchNull(t.op,t.values)},e.prototype.getHash=function(e){return Po(e)},e.prototype.bucket=function(e,t){var n,r,o,s;if(!t.bucket)return t.variant;var i=this.coerceString(qo(e,t.bucket.selector));if(!i||0===i.length)return t.variant;var a="".concat(t.bucket.salt,"/").concat(i),c=this.getHash(a),u=c%100,l=Math.floor(c/100);try{for(var d=ho(t.bucket.allocations),h=d.next();!h.done;h=d.next()){var f=h.value,p=f.range[0],v=f.range[1];if(u>=p&&u<v)try{for(var g=(o=void 0,ho(f.distributions)),m=g.next();!m.done;m=g.next()){var y=m.value,S=y.range[0],b=y.range[1];if(l>=S&&l<b)return y.variant}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=g.return)&&s.call(g)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return t.variant},e.prototype.matchNull=function(e,t){var n=this.containsNone(t);switch(e){case fo:case vo:case mo:case yo:case So:case bo:case Io:case wo:case Co:case Eo:case Mo:case To:case xo:return n;case po:case go:case Oo:case Ro:return!n;default:return!1}},e.prototype.matchSet=function(e,t,n){switch(t){case Mo:return this.setEquals(e,n);case ko:return!this.setEquals(e,n);case To:return this.matchesSetContainsAll(e,n);case Oo:return!this.matchesSetContainsAll(e,n);case xo:return this.matchesSetContainsAny(e,n);case Ro:return!this.matchesSetContainsAny(e,n);default:return!1}},e.prototype.matchString=function(e,t,n){var r=this;switch(t){case fo:return this.matchesIs(e,n);case po:return!this.matchesIs(e,n);case vo:return this.matchesContains(e,n);case go:return!this.matchesContains(e,n);case mo:case yo:case So:case bo:return this.matchesComparable(e,t,n,(function(e){return r.parseNumber(e)}),this.comparator);case Io:case wo:case Co:case Eo:return this.matchesComparable(e,t,n,(function(e){return zo.parse(e)}),this.versionComparator);case No:return this.matchesRegex(e,n);case Do:return!this.matchesRegex(e,n);default:return!1}},e.prototype.matchesIs=function(e,t){if(this.containsBooleans(t)){var n=e.toLowerCase();if("true"===n||"false"===n)return t.some((function(e){return e.toLowerCase()===n}))}return t.some((function(t){return e===t}))},e.prototype.matchesContains=function(e,t){var n,r;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.toLowerCase().includes(i.toLowerCase()))return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1},e.prototype.matchesComparable=function(e,t,n,r,o){var s=this,i=r(e),a=n.map((function(e){return r(e)})).filter((function(e){return void 0!==e}));return void 0===i||0===a.length?n.some((function(n){return s.comparator(e,t,n)})):a.some((function(e){return o(i,t,e)}))},e.prototype.comparator=function(e,t,n){switch(t){case mo:case Io:return e<n;case yo:case wo:return e<=n;case So:case Co:return e>n;case bo:case Eo:return e>=n;default:return!1}},e.prototype.versionComparator=function(e,t,n){var r=e.compareTo(n);switch(t){case mo:case Io:return r<0;case yo:case wo:return r<=0;case So:case Co:return r>0;case bo:case Eo:return r>=0;default:return!1}},e.prototype.matchesRegex=function(e,t){return t.some((function(t){return Boolean(new RegExp(t).exec(e))}))},e.prototype.containsNone=function(e){return e.some((function(e){return"(none)"===e}))},e.prototype.containsBooleans=function(e){return e.some((function(e){switch(e.toLowerCase()){case"true":case"false":return!0;default:return!1}}))},e.prototype.parseNumber=function(e){var t;return null!==(t=Number(e))&&void 0!==t?t:void 0},e.prototype.coerceString=function(e){if(e)return"object"==typeof e?JSON.stringify(e):String(e)},e.prototype.coerceStringArray=function(e){var t=this;if(Array.isArray(e))return e.map((function(e){return t.coerceString(e)})).filter(Boolean);var n=String(e);try{var r=JSON.parse(n);return Array.isArray(r)?e.map((function(e){return t.coerceString(e)})).filter(Boolean):void 0}catch(e){return}},e.prototype.isSetOperator=function(e){switch(e){case Mo:case ko:case To:case Oo:case xo:case Ro:return!0;default:return!1}},e.prototype.setEquals=function(e,t){var n=new Set(e),r=new Set(t);return n.size===r.size&&function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}(r),!1).every((function(e){return n.has(e)}))},e.prototype.matchesSetContainsAll=function(e,t){var n,r;if(e.length<t.length)return!1;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(!this.matchesIs(i,e))return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!0},e.prototype.matchesSetContainsAny=function(e,t){var n,r;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(this.matchesIs(i,e))return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1},e}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;(e=>{let t={};e.forEach(((e,n)=>t[e]=n))})(Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(e){function t(n,r){var o=e.call(this,r)||this;return o.statusCode=n,Object.setPrototypeOf(o,t.prototype),o}(function(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}uo(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)})(t,e)}(Error);var Vo=function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(t,1,{upgrade:function(e){e.objectStoreNames.contains("eventTypesForSession")||e.createObjectStore("eventTypesForSession",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}}))}))},this.openOrCreateDB=function(t){return o(e,void 0,void 0,(function(){var e,n;return s(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_targeting"),[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}}))}))},this.updateEventListForSession=function(t){var n=t.sessionId,i=t.eventType,a=t.eventTime,c=t.loggerProvider,u=t.tx;return o(e,void 0,void 0,(function(){var e,t,o,l,d,h,f;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,u.store.get(n)];case 1:return e=s.sent(),t=e?e.eventTypes:{},o=t[i]||{},l=r(r({},t),((h={})[i]=r(r({},o),((f={})[a]={event_type:i},f)),h)),[4,u.store.put({sessionId:n,eventTypes:l})];case 2:return s.sent(),[2,l];case 3:return d=s.sent(),c.warn("Failed to store events for targeting ".concat(n,": ").concat(d)),[3,4];case 4:return[2,void 0]}}))}))},this.deleteOldSessionEventTypes=function(t){var n=t.currentSessionId,r=t.loggerProvider,i=t.tx;return o(e,void 0,void 0,(function(){var e,t,o,a,c;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),[4,i.store.getAll()];case 1:e=s.sent(),t=0,s.label=2;case 2:return t<e.length?(o=e[t],a=Date.now()-o.sessionId,o.sessionId!==n&&a>1728e5?[4,i.store.delete(o.sessionId)]:[3,4]):[3,5];case 3:s.sent(),s.label=4;case 4:return t++,[3,2];case 5:return[3,7];case 6:return c=s.sent(),r.warn("Failed to clear old session events for targeting: ".concat(c)),[3,7];case 7:return[2]}}))}))},this.storeEventTypeForSession=function(t){var n=t.loggerProvider,r=t.sessionId,i=t.eventType,a=t.eventTime,c=t.apiKey;return o(e,void 0,void 0,(function(){var e,t,o,u;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,this.openOrCreateDB(c)];case 1:return e=s.sent(),(t=e.transaction("eventTypesForSession","readwrite"))?[4,this.updateEventListForSession({sessionId:r,tx:t,loggerProvider:n,eventType:i,eventTime:a})]:[2];case 2:return o=s.sent(),[4,this.deleteOldSessionEventTypes({currentSessionId:r,tx:t,loggerProvider:n})];case 3:return s.sent(),[4,t.done];case 4:return s.sent(),[2,o];case 5:return u=s.sent(),n.warn("Failed to store events for targeting ".concat(r,": ").concat(u)),[3,6];case 6:return[2,void 0]}}))}))}},Go=new Vo,$o=function(){var e=this;this.evaluateTargeting=function(t){var n=t.apiKey,r=t.loggerProvider,i=t.event,a=t.sessionId,c=t.userProperties,u=t.deviceId,l=t.flag;return o(e,void 0,void 0,(function(){var e,t,o,d;return s(this,(function(s){switch(s.label){case 0:return i&&i.time?[4,Go.storeEventTypeForSession({loggerProvider:r,apiKey:n,sessionId:a,eventType:i.event_type,eventTime:i.time})]:[3,2];case 1:return t=s.sent(),[3,3];case 2:t=void 0,s.label=3;case 3:return o=(e=t)&&new Set(Object.keys(e)),d={session_id:a,event:i,event_types:o&&Array.from(o),user:{device_id:u,user_properties:c}},[2,this.evaluationEngine.evaluate(d,[l])]}}))}))},this.evaluationEngine=new Ko},Ho=function(){var e=new $o;return{evaluateTargeting:e.evaluateTargeting.bind(e)}}().evaluateTargeting,Xo=function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(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 o(e,void 0,void 0,(function(){var e,n;return s(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 o(e,void 0,void 0,(function(){var e,t;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return[4,o.sent().get("sessionTargetingMatch",i)];case 2:return[2,null==(e=o.sent())?void 0:e.targetingMatch];case 3:return t=o.sent(),n.warn("Failed to get targeting match for session id ".concat(i,": ").concat(t)),[3,4];case 4:return[2,void 0]}}))}))},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,a=t.targetingMatch;return o(e,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return[4,t.sent().put("sessionTargetingMatch",{targetingMatch:a,sessionId:i})];case 2:return[2,t.sent()];case 3:return e=t.sent(),n.warn("Failed to store targeting match for session id ".concat(i,": ").concat(e)),[3,4];case 4:return[2,void 0]}}))}))},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return o(e,void 0,void 0,(function(){var e,t,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=s.sent(),[4,(t=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:o=s.sent(),a=0,s.label=3;case 3:return a<o.length?(c=o[a],u=Date.now()-c.sessionId,c.sessionId!==i&&u>1728e5?[4,t.store.delete(c.sessionId)]:[3,5]):[3,6];case 4:s.sent(),s.label=5;case 5:return a++,[3,3];case 6:return[4,t.done];case 7:return s.sent(),[3,9];case 8:return l=s.sent(),n.warn("Failed to clear old targeting matches for sessions: ".concat(l)),[3,9];case 9:return[2]}}))}))}},Jo=new Xo,Yo=function(e){var t=e.sessionId,n=e.targetingConfig,i=e.loggerProvider,a=e.apiKey,c=e.targetingParams;return o(void 0,void 0,void 0,(function(){var e,o,u,l;return s(this,(function(s){switch(s.label){case 0:return[4,Jo.clearStoreOfOldSessions({loggerProvider:i,apiKey:a,currentSessionId:t})];case 1:return s.sent(),[4,Jo.getTargetingMatchForSession({loggerProvider:i,apiKey:a,sessionId:t})];case 2:if(!0===s.sent())return[2,!0];e=!0,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,Ho(r(r({},c),{flag:n,sessionId:t,apiKey:a,loggerProvider:i}))];case 4:return(o=s.sent())&&o.sr_targeting_config&&(e="on"===o.sr_targeting_config.key),Jo.storeTargetingMatchForSession({loggerProvider:i,apiKey:a,sessionId:t,targetingMatch:e}),[3,6];case 5:return u=s.sent(),l=u,i.warn(l.message),[3,6];case 6:return[2,e]}}))}))},Zo=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.teardownEventListeners=function(t){var n=E();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(){e.stopRecordingEvents(),e.captureEvents()},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach((function(e){e(t)}))},this.evaluateTargetingAndCapture=function(t){return o(e,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return this.identifiers&&this.identifiers.sessionId&&this.config?!this.config.targetingConfig||this.sessionTargetingMatch?[3,2]:((e=null==t?void 0:t.event)&&Object.values(g).includes(e.event_type)&&(e=void 0),n=this,[4,Yo({sessionId:this.identifiers.sessionId,targetingConfig:this.config.targetingConfig,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:null==t?void 0:t.userProperties,event:e}})]):(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]);case 1:n.sessionTargetingMatch=r.sent(),r.label=2;case 2:return this.captureEvents(),[2]}}))}))},this.addCustomRRWebEvent=function(t,n,i){return void 0===n&&(n={}),void 0===i&&(i=!0),o(e,void 0,void 0,(function(){var e,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),e=void 0,this.config?(e={config:wr(this.config),version:jr},i?[4,Ir()]:[3,2]):[3,2];case 1:o=s.sent(),e=r(r({},o),e),s.label=2;case 2:return this.recordCancelCallback?Zt.addCustomEvent(t,r(r({},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=s.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",a),[3,4];case 4:return[2]}}))}))},this.stopRecordingEvents=function(){try{e.recordCancelCallback&&e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null}catch(n){var t=n;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new R}return e.prototype.init=function(e,t){return O(this._init(e,t))},e.prototype._init=function(e,t){var n,r,i;return o(this,void 0,void 0,(function(){var o,u,l,d,h,f;return s(this,(function(s){switch(s.label){case 0:return this.loggerProvider=t.loggerProvider||new R,Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.identifiers=new co({sessionId:t.sessionId,deviceId:t.deviceId}),o=this,[4,Er(e,t)];case 1:return o.joinedConfigGenerator=s.sent(),u=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return u.config=s.sent(),t.sessionId&&(null===(n=this.config.interactionConfig)||void 0===n?void 0:n.enabled)&&(l=ao.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[l.send(this.getDeviceId.bind(this))],this.scrollHook=l.hook.bind(l)),d=[],[4,Br({config:this.config,sessionId:this.identifiers.sessionId,type:"replay"})];case 3:return h=s.sent(),d.push({name:"replay",manager:h}),(null===(r=this.config.interactionConfig)||void 0===r?void 0:r.enabled)?[4,Br({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(i=this.config.interactionConfig.trackEveryNms)&&void 0!==i?i:3e4,maxInterval:6e4,payloadBatcher:no})]:[3,5];case 4:f=s.sent(),d.push({name:"interaction",manager:f}),s.label=5;case 5:return this.eventsManager=new(qr.bind.apply(qr,c([void 0],a(d),!1))),this.identifiers.deviceId&&this.eventsManager.sendStoredEvents({deviceId:this.identifiers.deviceId}),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),this.stopRecordingEvents(),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties})];case 6:return s.sent(),[2]}}))}))},e.prototype.setSessionId=function(e,t,n){return O(this.asyncSetSessionId(e,t,n))},e.prototype.asyncSetSessionId=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,i;return s(this,(function(s){switch(s.label){case 0:return this.stopRecordingEvents(),this.sessionTargetingMatch=!1,(r=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(r),o=t||this.getDeviceId(),this.identifiers=new co({sessionId:e,deviceId:o}),this.joinedConfigGenerator&&r?(i=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:i.config=s.sent(),s.label=2;case 2:return[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties})];case 3:return s.sent(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=Sr(this.config.apiKey).toString()),JSON.stringify({appHash:e})},e.prototype.getSessionReplayProperties=function(){var e;if(!this.config||!this.identifiers)return this.loggerProvider.error("Session replay init has not been called, cannot get session replay properties."),{};var t=this.getShouldCapture(),n={};return t&&((e={})[B]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,n=e,this.config.debugMode&&(n[W]=this.getSessionReplayDebugPropertyValue())),this.addCustomRRWebEvent(M.GET_SR_PROPS,{shouldRecord:t,eventProperties:n},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,n},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.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=C(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldCapture=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being captured 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 replay capture due to optOut config.")),!1;if(this.config.targetingConfig){if(!this.sessionTargetingMatch)return this.loggerProvider.log("Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions.")),!1;this.loggerProvider.log("Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."))}else{if(!(e=this.identifiers.sessionId,t=this.config.sampleRate,n=Sr(e.toString()),31*Math.abs(n)%1e6/1e6<t))return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of replay capture due to sample rate.")),!1;this.loggerProvider.log("Capturing replays for session ".concat(this.identifiers.sessionId," due to inclusion in sample rate."))}var e,t,n;return!0},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,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.captureEvents=function(){var e=this;if(this.recordCancelCallback)this.loggerProvider.debug("captureEvents method fired - Session Replay capture already in progress.");else{var t=this.getShouldCapture(),n=this.identifiers&&this.identifiers.sessionId;if(t&&n&&this.config){var r=this.config.privacyConfig;this.loggerProvider.log("Session Replay capture beginning."),this.recordCancelCallback=Zt({emit:function(t){if(e.shouldOptOut())return e.loggerProvider.log("Opting session ".concat(n," out of replay capture due to optOut config.")),e.stopRecordingEvents(),void e.sendEvents();var r=JSON.stringify(t),o=e.getDeviceId();e.eventsManager&&o&&e.eventsManager.addEvent({event:{type:"replay",data:r},sessionId:n,deviceId:o})},packFn:Pn,inlineStylesheet:this.config.shouldInlineStylesheet,hooks:{mouseInteraction:this.eventsManager&&ro({eventsManager:this.eventsManager,sessionId:n,deviceIdFn:this.getDeviceId.bind(this)}),scroll:this.scrollHook},maskAllInputs:!0,maskTextClass:z,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:yr("input",r),maskTextFn:yr("text",r),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(t){var n=t;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))throw n;if(n._external_)throw n;return e.loggerProvider.warn("Error while capturing replay: ",n.toString()),!0}}),this.addCustomRRWebEvent(M.DEBUG_INFO)}}},e.prototype.getDeviceId=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=C(this.config.instanceName).identityStore.getIdentity().deviceId);return n||(null===(t=this.identifiers)||void 0===t?void 0:t.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),o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e}(),Qo=function(e){return function(){var t=e.config||V();return{logger:t.loggerProvider,logLevel:t.logLevel}}},es=function(){var e=new Zo;return{init:A(e.init.bind(e),"init",Qo(e)),evaluateTargetingAndCapture:A(e.evaluateTargetingAndCapture.bind(e),"evaluateTargetingAndRecord",Qo(e)),setSessionId:A(e.setSessionId.bind(e),"setSessionId",Qo(e)),getSessionId:e.getSessionId.bind(e),getSessionReplayProperties:A(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",Qo(e)),flush:A(e.flush.bind(e),"flush",Qo(e)),shutdown:A(e.shutdown.bind(e),"shutdown",Qo(e))}}(),ts=es.init,ns=es.setSessionId,rs=es.getSessionId,os=es.evaluateTargetingAndCapture,ss=es.getSessionReplayProperties,is=es.flush,as=es.shutdown,cs=[p.SET,p.SET_ONCE,p.ADD,p.APPEND,p.PREPEND,p.POSTINSERT,p.POSTINSERT],us="1.7.0-srtargeting.0",ls="@amplitude/plugin-session-replay-enrichment-browser",ds=function(){function e(){this.name=ls,this.type="enrichment"}return e.prototype.setup=function(e,t){return o(this,void 0,void 0,(function(){return s(this,(function(t){return this.config=e,[2]}))}))},e.prototype.execute=function(e){return o(this,void 0,void 0,(function(){var t,n,o;return s(this,(function(s){switch(s.label){case 0:return this.config.sessionId&&this.config.sessionId!==rs()?(n=void 0,this.config.instanceName&&(t=C(this.config.instanceName).identityStore,n=t.getIdentity().userProperties),[4,ns(this.config.sessionId,this.config.deviceId,{userProperties:n||{}}).promise]):[3,2];case 1:s.sent(),s.label=2;case 2:return this.config.sessionId&&this.config.sessionId===e.session_id?(n=void 0,e.event_type===g.IDENTIFY&&(n=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach((function(n){if(cs.includes(n)){var o=e.user_properties&&e.user_properties[n];t=r(r({},t),o)}})),t}}(e)),[4,os({event:e,userProperties:n})]):[3,4];case 3:s.sent(),o=ss(),e.event_properties=r(r({},e.event_properties),o),s.label=4;case 4:return[2,Promise.resolve(e)]}}))}))},e}(),hs=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="destination",this.options=r({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e,t){var n,i,a,c;return o(this,void 0,void 0,(function(){var o,u;return s(this,(function(s){switch(s.label){case 0:return t?(e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(us,".")),this.clientRemove=t.remove.bind(t),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})),o=C(this.config.instanceName).identityStore,u=o.getIdentity().userProperties,[4,ts(e.apiKey,{instanceName:this.config.instanceName,deviceId:this.config.deviceId,optOut:this.config.optOut,sessionId:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(n=this.options.privacyConfig)||void 0===n?void 0:n.blockSelector,maskSelector:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.maskSelector,unmaskSelector:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.unmaskSelector,defaultMaskLevel:null===(c=this.options.privacyConfig)||void 0===c?void 0:c.defaultMaskLevel},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:us},userProperties:u}).promise]):(e.loggerProvider.error("SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK."),[2]);case 1:return s.sent(),[4,t.add(new ds).promise];case 2:return s.sent(),[2]}}))}))},e.prototype.execute=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,Promise.resolve({event:e,code:200,message:"success"})]}))}))},e.prototype.flush=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,is(!1)];case 1:return e.sent(),[2]}}))}))},e.prototype.teardown=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.clientRemove(ls).promise];case 1:return e.sent(),as(),this.config=null,this.clientRemove=null,[2]}}))}))},e.prototype.getSessionReplayProperties=function(){return ss()},e}(),fs=function(e){return new hs(e)};return e.plugin=fs,e.sessionReplayPlugin=fs,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var sessionReplay=function(e){"use strict";var t=function(e,n){return t=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])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),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]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var u=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:l(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),l=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},d=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),h=function(){return h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)},f=function(e,t){var n=typeof e;if(n!==typeof t)return!1;for(var r=0,o=["string","number","boolean","undefined"];r<o.length;r++){if(o[r]===n)return e===t}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var s=Array.isArray(e),i=Array.isArray(t);if(s!==i)return!1;if(!s||!i){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!f(a,c))return!1;var u=!0;return Object.keys(e).forEach((function(n){f(e[n],t[n])||(u=!1)})),u}for(var l=0;l<e.length;l++)if(!f(e[l],t[l]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var p,v,g,m,y,S,b=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=h({},this.identity.userProperties),n=h(h({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){for(var t=n.userProperties||{},r=0,o=Object.entries(e);r<o.length;r++){var s=o[r],i=s[0],a=s[1];switch(i){case"$set":for(var c=0,u=Object.entries(a);c<u.length;c++){var l=u[c],d=l[0],h=l[1];t[d]=h}break;case"$unset":for(var f=0,p=Object.keys(a);f<p.length;f++){delete t[d=p[f]]}break;case"$clearAll":t={}}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return h({},this.identity)},e.prototype.setIdentity=function(e){var t=h({},this.identity);this.identity=h({},e),f(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,w=function(){function e(){this.identityStore=new b,this.eventBridge=new d,this.applicationContextProvider=new u}return e.getInstance=function(t){return I.analyticsConnectorInstances||(I.analyticsConnectorInstances={}),I.analyticsConnectorInstances[t]||(I.analyticsConnectorInstances[t]=new e),I.analyticsConnectorInstances[t]},e}(),C=function(e){return void 0===e&&(e="$default_instance"),w.getInstance(e)},E=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0};!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"}(p||(p={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(v||(v={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(g||(g={})),function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(m||(m={})),function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(y||(y={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(S||(S={}));var M,k="".concat("AMP","_unsent"),T="https://api2.amplitude.com/2/httpapi",O=function(e){return{promise:e||Promise.resolve()}},x="Amplitude Logger ",R=function(){function e(){this.logLevel=m.None}return e.prototype.disable=function(){this.logLevel=m.None},e.prototype.enable=function(e){void 0===e&&(e=m.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Verbose||console.log("".concat(x,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Warn||console.warn("".concat(x,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Error||console.error("".concat(x,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<m.Debug||console.log("".concat(x,"[Debug]: ").concat(e.join(" ")))},e}(),N=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:m.Warn,loggerProvider:new R,optOut:!1,serverUrl:T,serverZone:y.US,useBatch:!1}},D=function(){function e(e){var t,n,r,o;this._optOut=!1;var s=N();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:s.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||s.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||s.flushQueueSize,this.instanceName=e.instanceName||s.instanceName,this.loggerProvider=e.loggerProvider||s.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:s.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:s.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||s.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:s.useBatch,this.loggerProvider.enable(this.logLevel);var i=L(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=i.serverZone,this.serverUrl=i.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),_=function(e,t){return e===y.EU?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":T},L=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=N().serverZone),void 0===n&&(n=N().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:N().serverZone;return{serverZone:r,serverUrl:_(r,n)}},P=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},A=function(e,t,n,r,o){return void 0===o&&(o=null),function(){for(var s=[],i=0;i<arguments.length;i++)s[i]=arguments[i];var a=n(),c=a.logger,u=a.logLevel;if(u&&u<m.Debug||!u||!c)return e.apply(o,s);var l={type:"invoke public method",name:t,args:s,stacktrace:P(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(o,s);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}},F=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,s,i,a,c,u,l,d,h,f,p,v,g,m,y,b,I,w,C;if("object"!=typeof e)return null;var E=e.code||0,M=this.buildStatus(E);switch(M){case S.Success:return{status:M,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case S.Invalid:return{status:M,statusCode:E,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(s=e.missing_field)&&void 0!==s?s:"",eventsWithInvalidFields:null!==(i=e.events_with_invalid_fields)&&void 0!==i?i:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(h=e.silenced_events)&&void 0!==h?h:[],throttledDevices:null!==(f=e.throttled_devices)&&void 0!==f?f:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case S.PayloadTooLarge:return{status:M,statusCode:E,body:{error:null!==(v=e.error)&&void 0!==v?v:""}};case S.RateLimit:return{status:M,statusCode:E,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(I=e.exceeded_daily_quota_devices)&&void 0!==I?I:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case S.Timeout:default:return{status:M,statusCode:E}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?S.Success:429===e?S.RateLimit:413===e?S.PayloadTooLarge:408===e?S.Timeout:e>=400&&e<500?S.Invalid:e>=500?S.Failed:S.Unknown},e}(),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(s){switch(s.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(F),U="[Amplitude]",B="".concat(U," Session Replay ID"),q=y.US,W="".concat(U," Session Replay Debug"),z="amp-mask";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info"}(M||(M={}));var K,V=function(){return{flushMaxRetries:2,logLevel:m.Warn,loggerProvider:new R,transportProvider:new j}},G=function(e){function t(t,n){var o=this,s=V();return(o=e.call(this,r(r({transportProvider:s.transportProvider},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=s.flushMaxRetries?n.flushMaxRetries:s.flushMaxRetries,o.apiKey=t,o.sampleRate=n.sampleRate||0,o.serverZone=n.serverZone||q,o.configEndpointUrl=n.configEndpointUrl,o.shouldInlineStylesheet=n.shouldInlineStylesheet,n.privacyConfig&&(o.privacyConfig=n.privacyConfig),n.debugMode&&(o.debugMode=n.debugMode),o}return n(t,e),t}(D);function $(e){const t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function H(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function X(e){try{const n=e.rules||e.cssRules;return n?((t=Array.from(n,J).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t):null}catch(e){return null}var t}function J(e){let t;if(function(e){return"styleSheet"in e}(e))try{t=X(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return function(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}(e.cssText);return t||e.cssText}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(K||(K={}));class Y{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var t;if(!e)return-1;const n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach((e=>this.removeNodeFromMap(e)))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Z({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:s}){let i=o||"";const a=r&&Q(r);return(t[n.toLowerCase()]||a&&t[a])&&(i=s?s(i,e):"*".repeat(i.length)),i}function Q(e){return e.toLowerCase()}const ee="__rrweb_original__";function te(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Q(t):null}let ne=1;const re=new RegExp("[^a-z0-9-_:]");function oe(){return ne++}let se,ie;const ae=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ce=/^(?:[a-z+]+:)?\/\//i,ue=/^www\..*/i,le=/^(data:)([^,]*),(.*)/i;function de(e,t){return(e||"").replace(ae,((e,n,r,o,s,i)=>{const a=r||s||i,c=n||o||"";if(!a)return e;if(ce.test(a)||ue.test(a))return`url(${c}${a}${c})`;if(le.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${c})`;const u=t.split("/"),l=a.split("/");u.pop();for(const e of l)"."!==e&&(".."===e?u.pop():u.push(e));return`url(${c}${u.join("/")}${c})`}))}const he=/^[^ \t\n\r\u000c]+/,fe=/^[, \t\n\r\u000c]+/;function pe(e,t){if(!t||""===t.trim())return t;const n=e.createElement("a");return n.href=t,n.href}function ve(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function ge(){const e=document.createElement("a");return e.href="",e.href}function me(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?pe(e,r):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r(fe),!(n>=t.length);){let s=r(he);if(","===s.slice(-1))s=pe(e,s.substring(0,s.length-1)),o.push(s);else{let r="";s=pe(e,s);let i=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((s+r).trim());break}if(i)")"===e&&(i=!1);else{if(","===e){n+=1,o.push((s+r).trim());break}"("===e&&(i=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?de(r,ge()):"object"===t&&"data"===n?pe(e,r):r:pe(e,r):r}function ye(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function Se(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&Se(e.parentNode,t,n);for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}return!!n&&Se(e.parentNode,t,n)}function be(e,t,n){try{const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(`.${t}`))return!0}else if(Se(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function Ie(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,inlineStylesheet:c,maskInputOptions:u={},maskTextFn:l,maskInputFn:d,dataURLOptions:h={},inlineImages:f,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g=!1}=t,m=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:K.Document,childNodes:[],compatMode:e.compatMode}:{type:K.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:K.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:m};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:s,maskInputOptions:i={},maskInputFn:a,dataURLOptions:c={},inlineImages:u,recordCanvas:l,keepIframeSrcFn:d,newlyAddedElement:h=!1,rootId:f}=t,p=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,r,o),v=function(e){if(e instanceof HTMLFormElement)return"form";const t=Q(e.tagName);return re.test(t)?"div":t}(e);let g={};const m=e.attributes.length;for(let t=0;t<m;t++){const r=e.attributes[t];ye(v,r.name,r.value)||(g[r.name]=me(n,v,Q(r.name),r.value))}if("link"===v&&s){const t=Array.from(n.styleSheets).find((t=>t.href===e.href));let r=null;t&&(r=X(t)),r&&(delete g.rel,delete g.href,g._cssText=de(r,t.href))}if("style"===v&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const t=X(e.sheet);t&&(g._cssText=de(t,ge()))}if("input"===v||"textarea"===v||"select"===v){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Z({element:e,type:te(e),tagName:v,value:t,maskInputOptions:i,maskInputFn:a}):n&&(g.checked=n)}"option"===v&&(e.selected&&!i.select?g.selected=!0:delete g.selected);if("canvas"===v&&l)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const o=t.getImageData,s=ee in o?o[ee]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((e=>0!==e)))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),n=document.createElement("canvas");n.width=e.width,n.height=e.height;t!==n.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===v&&u){se||(se=n.createElement("canvas"),ie=se.getContext("2d"));const t=e,r=t.crossOrigin;t.crossOrigin="anonymous";const o=()=>{t.removeEventListener("load",o);try{se.width=t.naturalWidth,se.height=t.naturalHeight,ie.drawImage(t,0,0),g.rr_dataURL=se.toDataURL(c.type,c.quality)}catch(e){console.warn(`Cannot inline img src=${t.currentSrc}! Error: ${e}`)}r?g.crossOrigin=r:t.removeAttribute("crossorigin")};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}"audio"!==v&&"video"!==v||(g.rr_mediaState=e.paused?"paused":"played",g.rr_mediaCurrentTime=e.currentTime);h||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(p){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==v||d(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);return{type:K.Element,tagName:v,attributes:g,childNodes:[],isSVG:ve(e)||void 0,needBlock:p,rootId:f}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:u,maskInputFn:d,dataURLOptions:h,inlineImages:f,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g,rootId:m});case e.TEXT_NODE:return function(e,t){var n;const{maskTextClass:r,maskTextSelector:o,maskTextFn:s,rootId:i}=t,a=e.parentNode&&e.parentNode.tagName;let c=e.textContent;const u="STYLE"===a||void 0,l="SCRIPT"===a||void 0;if(u&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=X(e.parentNode.sheet))}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}c=de(c,ge())}l&&(c="SCRIPT_PLACEHOLDER");!u&&!l&&c&&be(e,r,o)&&(c=s?s(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:K.Text,textContent:c||"",isStyle:u,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:l,rootId:m});case e.CDATA_SECTION_NODE:return{type:K.CDATA,textContent:"",rootId:m};case e.COMMENT_NODE:return{type:K.Comment,textContent:e.textContent||"",rootId:m};default:return!1}}function we(e){return null==e?"":e.toLowerCase()}function Ce(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:u=!0,maskInputOptions:l={},maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p={},inlineImages:v=!1,recordCanvas:g=!1,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S=5e3,onStylesheetLoad:b,stylesheetLoadTimeout:I=5e3,keepIframeSrcFn:w=(()=>!1),newlyAddedElement:C=!1}=t;let{preserveWhiteSpace:E=!0}=t;const M=Ie(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,dataURLOptions:p,inlineImages:v,recordCanvas:g,keepIframeSrcFn:w,newlyAddedElement:C});if(!M)return console.warn(e,"not serialized"),null;let k;k=r.hasNode(e)?r.getId(e):!function(e,t){if(t.comment&&e.type===K.Comment)return!0;if(e.type===K.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(we(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===we(e.attributes.name)||"icon"===we(e.attributes.rel)||"apple-touch-icon"===we(e.attributes.rel)||"shortcut icon"===we(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&we(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(we(e.attributes.property).match(/^(og|twitter|fb):/)||we(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===we(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===we(e.attributes.name)||"googlebot"===we(e.attributes.name)||"bingbot"===we(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===we(e.attributes.name)||"generator"===we(e.attributes.name)||"framework"===we(e.attributes.name)||"publisher"===we(e.attributes.name)||"progid"===we(e.attributes.name)||we(e.attributes.property).match(/^article:/)||we(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===we(e.attributes.name)||"yandex-verification"===we(e.attributes.name)||"csrf-token"===we(e.attributes.name)||"p:domain_verify"===we(e.attributes.name)||"verify-v1"===we(e.attributes.name)||"verification"===we(e.attributes.name)||"shopify-checkout-api-token"===we(e.attributes.name)))return!0}}return!1}(M,f)&&(E||M.type!==K.Text||M.isStyle||M.textContent.replace(/^\s+|\s+$/gm,"").length)?oe():-2;const T=Object.assign(M,{id:k});if(r.add(e,T),-2===k)return null;m&&m(e);let O=!c;if(T.type===K.Element){O=O&&!T.needBlock,delete T.needBlock;const t=e.shadowRoot;t&&H(t)&&(T.isShadowHost=!0)}if((T.type===K.Document||T.type===K.Element)&&O){f.headWhitespace&&T.type===K.Element&&"head"===T.tagName&&(E=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w};if(T.type===K.Element&&"textarea"===T.tagName&&void 0!==T.attributes.value);else for(const n of Array.from(e.childNodes)){const e=Ce(n,t);e&&T.childNodes.push(e)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(const n of Array.from(e.shadowRoot.childNodes)){const r=Ce(n,t);r&&(H(e.shadowRoot)&&(r.isShadow=!0),T.childNodes.push(r))}}return e.parentNode&&$(e.parentNode)&&H(e.parentNode)&&(T.isShadow=!0),T.type===K.Element&&"iframe"===T.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"!==o){const r=setTimeout((()=>{s||(t(),s=!0)}),n);return void e.addEventListener("load",(()=>{clearTimeout(r),s=!0,t()}))}const i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,(()=>{const t=e.contentDocument;if(t&&y){const n=Ce(t,{doc:t,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w});n&&y(e,n)}}),S),T.type===K.Element&&"link"===T.tagName&&"stylesheet"===T.attributes.rel&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(e){return}if(r)return;const s=setTimeout((()=>{o||(t(),o=!0)}),n);e.addEventListener("load",(()=>{clearTimeout(s),o=!0,t()}))}(e,(()=>{if(b){const t=Ce(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:p,inlineImages:v,recordCanvas:g,preserveWhiteSpace:E,onSerialize:m,onIframeLoad:y,iframeLoadTimeout:S,onStylesheetLoad:b,stylesheetLoadTimeout:I,keepIframeSrcFn:w});t&&b(e,t)}}),I),T}var Ee=(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))(Ee||{}),Me=(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))(Me||{}),ke=(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))(ke||{}),Te=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Te||{}),Oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Oe||{});function xe(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Re="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Ne={map:{},getId:()=>(console.error(Re),-1),getNode:()=>(console.error(Re),null),removeNodeFromMap(){console.error(Re)},has:()=>(console.error(Re),!1),reset(){console.error(Re)}};function De(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function _e(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>_e(e,t,s||{},!0)}function Le(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Ne=new Proxy(Ne,{get:(e,t,n)=>("map"===t&&console.error(Re),Reflect.get(e,t,n))}));let Pe,Ae=Date.now;function Fe(e){var t,n,r,o,s,i;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(s=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function je(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ue(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Be(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function qe(e,t,n,r){if(!e)return!1;const o=Be(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(Se(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function We(e,t){return-2===t.getId(e)}function ze(e,t){if($(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ze(e.parentNode,t))}function Ke(e){return Boolean(e.changedTouches)}function Ve(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Ge(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $e(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(Ae=()=>(new Date).getTime());class He{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Xe(e){var t,n;let r=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Je(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=Xe(n);)n=t;return n}(e);return t.contains(n)}function Ye(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Je(e))}function Ze(e){Pe=e}function Qe(){Pe=void 0}const et=e=>{if(!Pe)return e;return(...t)=>{try{return e(...t)}catch(e){if(Pe&&!0===Pe(e))return;throw e}}};function tt(e){return(...t)=>{try{return e(...t)}catch(e){try{e._external_=!0}catch(e){}throw e}}}class nt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class rt{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new nt(oe),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new nt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case Ee.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:Ee.IncrementalSnapshot,data:{source:Me.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Ee.Meta:case Ee.Load:case Ee.DomContentLoaded:return!1;case Ee.Plugin:return t;case Ee.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Ee.IncrementalSnapshot:switch(t.data.source){case Me.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Me.Drag:case Me.TouchMove:case Me.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Me.ViewportResize:return!1;case Me.MediaInteraction:case Me.MouseInteraction:case Me.Scroll:case Me.CanvasMutation:case Me.Input:return this.replaceIds(t.data,e,["id"]),t;case Me.StyleSheetRule:case Me.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Me.Font:return t;case Me.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Me.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}patchRootIdOnNode(e,t){e.type===K.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function ot(e){return"__ln"in e}class st{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&ot(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&ot(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const it=(e,t)=>`${e}@${t}`;class at{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new st,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{if(!o.parentNode||!Ye(o)||"TEXTAREA"===o.parentNode.tagName)return;const s=$(o.parentNode)?this.mirror.getId(Xe(o)):this.mirror.getId(o.parentNode),i=r(o);if(-1===s||-1===i)return n.addNode(o);const a=Ce(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Ve(e,this.mirror)&&this.iframeManager.addIframe(e),Ge(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$e(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)ut(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)dt(this.droppedSet,e)||ut(this.removes,e,this.mirror)?dt(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=r(s.value);-1!==t&&-1!==n&&(e=s)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const r=t.parentNode.host;if(-1!==this.mirror.getId(r)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}s=e.previous,n.removeNode(e.value),o(e.value)}const i={texts:this.texts.map((e=>{const t=e.node;return"TEXTAREA"===t.parentNode.tagName&&this.genTextAreaValueMutation(t.parentNode),{id:this.mirror.getId(t),value:e.value}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.genTextAreaValueMutation=e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t)),t.attributes.value=Array.from(e.childNodes,(e=>e.textContent||"")).join("")},this.processMutation=e=>{if(!We(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;qe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:be(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,Be(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=te(t);r=Z({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(qe(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!ye(t.tagName,n)&&(o.attributes[n]=me(this.doc,Q(t.tagName),Q(n),r),"style"===n)){let n;try{n=document.implementation.createHTMLDocument()}catch(e){n=this.doc}const r=n.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const n=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||s!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===s?n:[n,s]:o._unchangedStyles[e]=[n,s]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(qe(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=$(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);qe(e.target,this.blockClass,this.blockSelector,!1)||We(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(ct(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ze(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[it(n,r)]?ct(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!$(e.target)||!H(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(We(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[it(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);qe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),$e(e)&&e.shadowRoot.childNodes.forEach((t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)})))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ct(e,t){e.delete(t),t.childNodes.forEach((t=>ct(e,t)))}function ut(e,t,n){return 0!==e.length&&lt(e,t,n)}function lt(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||lt(e,r,n)}function dt(e,t){return 0!==e.size&&ht(e,t)}function ht(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ht(e,n))}const ft=[];function pt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function vt(e,t){var n,r;const o=new at;ft.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(et(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function gt({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let c=null;return Object.keys(ke).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{let i=Q(s);const u=(t=>s=>{const i=pt(s);if(qe(i,r,o,!0))return;let a=null,u=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Te.Mouse;break;case"touch":a=Te.Touch;break;case"pen":a=Te.Pen}a===Te.Touch?ke[t]===ke.MouseDown?u="TouchStart":ke[t]===ke.MouseUp&&(u="TouchEnd"):Te.Pen}else Ke(s)&&(a=Te.Touch);null!==a?(c=a,(u.startsWith("Touch")&&a===Te.Touch||u.startsWith("Mouse")&&a===Te.Mouse)&&(a=null)):ke[t]===ke.Click&&(a=c,c=null);const l=Ke(s)?s.changedTouches[0]:s;if(!l)return;const d=n.getId(i),{clientX:h,clientY:f}=l;et(e)(Object.assign({type:ke[u],id:d,x:h,y:f},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(ke[s]){case ke.MouseDown:case ke.MouseUp:i=i.replace("mouse","pointer");break;case ke.TouchStart:case ke.TouchEnd:return}a.push(xe(i,u,t))})),et((()=>{a.forEach((e=>e()))}))}function mt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){const i=et(De(et((s=>{const i=pt(s);if(!i||qe(i,r,o,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=Fe(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})})),s.scroll||100));return xe("scroll",i,t)}function yt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const St=["INPUT","TEXTAREA","SELECT"],bt=new WeakMap;function It(e){return function(e,t){if(Mt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||Mt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||Mt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||Mt("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function wt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ct({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),et((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function Et(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:u,styleDeclarationCb:l,canvasMutationCb:d,fontCb:h,selectionCb:f}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),u(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),l(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),f(...e)}}(e,t),e.recordDOM&&(r=vt(e,e.doc));const o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=De(et((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null})),s),u=et(De(et((e=>{const t=pt(e),{clientX:n,clientY:o}=Ke(e)?e.changedTouches[0]:e;i||(i=Ae()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Ae()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Me.Drag:e instanceof MouseEvent?Me.MouseMove:Me.TouchMove)})),o,{trailing:!1})),l=[xe("mousemove",u,n),xe("touchmove",u,n),xe("drag",u,n)];return et((()=>{l.forEach((e=>e()))}))}(e),s=gt(e),i=mt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return xe("resize",et(De(et((()=>{const t=je(),o=Ue();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)})),200)),t)}(e,{win:n}),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:c,sampling:u,userTriggeredOnInput:l}){function d(e){let n=pt(e);const u=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||St.indexOf(d)<0||qe(n,r,o,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let f=n.value,p=!1;const v=te(n)||"";"radio"===v||"checkbox"===v?p=n.checked:(a[d.toLowerCase()]||a[v])&&(f=Z({element:n,maskInputOptions:a,tagName:d,type:v,value:f,maskInputFn:c})),h(n,et(yt)({text:f,isChecked:p,userTriggered:u},l));const g=n.name;"radio"===v&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&h(e,et(yt)({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function h(t,r){const o=bt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){bt.set(t,r);const o=n.getId(t);et(e)(Object.assign(Object.assign({},r),{id:o}))}}const f=("last"===u.input?["change"]:["input","change"]).map((e=>xe(e,et(d),t))),p=t.defaultView;if(!p)return()=>{f.forEach((e=>e()))};const v=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),g=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return v&&v.set&&f.push(...g.map((e=>_e(e[0],e[1],{set(){et(d)({target:this,isTrusted:!1})}},!1,p)))),et((()=>{f.forEach((e=>e()))}))}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:s}){const i=et((s=>De(et((o=>{const i=pt(o);if(!i||qe(i,t,n,!0))return;const{currentTime:a,volume:c,muted:u,playbackRate:l}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:u,playbackRate:l})})),o.media||500))),a=[xe("play",i(0),s),xe("pause",i(1),s),xe("seeked",i(2),s),xe("volumechange",i(3),s),xe("ratechange",i(4),s)];return et((()=>{a.forEach((e=>e()))}))}(e);let l=()=>{},d=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(l=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:et(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=wt(o,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:a}]}),tt((()=>r.apply(o,s)))()}))});const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:i}]}),tt((()=>r.apply(o,s)))()}))}),r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:i}),r.apply(o,s)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:i}),r.apply(o,s)}))}));const c={};kt("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(kt("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),kt("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),kt("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const u={};return Object.entries(c).forEach((([r,o])=>{u[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(u[r].insertRule,{apply:et(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=wt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:[...It(o),a||0]}]}),r.apply(o,s)}))}),o.prototype.deleteRule=new Proxy(u[r].deleteRule,{apply:et(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=wt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...It(o),i]}]}),r.apply(o,s)}))})})),et((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule}))}))}(e,{win:n}),d=Ct(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:et(((o,i,a)=>{var c;const[u,l,d]=a;if(n.has(u))return s.apply(i,[u,l,d]);const{id:h,styleId:f}=wt(null===(c=i.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(h&&-1!==h||f&&-1!==f)&&e({id:h,styleId:f,set:{property:u,value:l,priority:d},index:It(i.parentRule)}),o.apply(i,a)}))});const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:et(((o,s,a)=>{var c;const[u]=a;if(n.has(u))return i.apply(s,[u]);const{id:l,styleId:d}=wt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,remove:{property:u},index:It(s.parentRule)}),o.apply(s,a)}))}),et((()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}))}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Le(t.fonts,"add",(function(t){return function(n){return setTimeout(et((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),et((()=>{r.forEach((e=>e()))}))}(e)));const p=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=et((()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:u,endOffset:l}=s;qe(i,r,o,!0)||qe(u,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(u),endOffset:l})}s({ranges:a})}));return a(),xe("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return et((()=>{ft.forEach((e=>e.reset())),null==r||r.disconnect(),o(),s(),i(),a(),c(),u(),l(),d(),h(),f(),p(),v.forEach((e=>e()))}))}function Mt(e){return void 0!==window[e]}function kt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Tt(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Ot,xt,Rt,Nt=(Ot=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),r=0;r<t.length;r++)n[t.charCodeAt(r)]=r;var o=function(e){var n,r=new Uint8Array(e),o=r.length,s="";for(n=0;n<o;n+=3)s+=t[r[n]>>2],s+=t[(3&r[n])<<4|r[n+1]>>4],s+=t[(15&r[n+1])<<2|r[n+2]>>6],s+=t[63&r[n+2]];return o%3==2?s=s.substring(0,s.length-1)+"=":o%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=new Map,a=self;a.onmessage=function(t){return e(this,void 0,void 0,(function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:r,width:c,height:u,dataURLOptions:l}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(r),c=yield a.arrayBuffer(),u=o(c);return i.set(e,u),u}return""}))}(c,u,l),h=new OffscreenCanvas(c,u);h.getContext("2d").drawImage(r,0,0),r.close();const f=yield h.convertToBlob(l),p=f.type,v=yield f.arrayBuffer(),g=o(v);if(!s.has(n)&&(yield d)===g)return s.set(n,g),a.postMessage({id:n});if(s.get(n)===g)return a.postMessage({id:n});a.postMessage({id:n,type:p,base64:g,width:c,height:u}),s.set(n,g)}}))}}()},xt=null,function(e){return Rt=Rt||function(e,t){var n=function(e,t){var n=void 0===t?null:t,r=e.toString().split("\n");r.pop(),r.shift();for(var o=r[0].search(/\S/),s=/(['"])__worker_loader_strict__(['"])/g,i=0,a=r.length;i<a;++i)r[i]=r[i].substring(o).replace(s,"$1use strict$2")+"\n";return n&&r.push("//# sourceMappingURL="+n+"\n"),r}(e,t),r=new Blob(n,{type:"application/javascript"});return URL.createObjectURL(r)}(Ot,xt),new Worker(Rt,e)}),Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_t="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Lt=0;Lt<Dt.length;Lt++)_t[Dt.charCodeAt(Lt)]=Lt;const Pt=new Map;const At=(e,t,n)=>{if(!e||!Ut(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Pt.get(e);return n||(n=new Map,Pt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ft(e,t,n){if(e instanceof Array)return e.map((e=>Ft(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Dt[n[t]>>2],o+=Dt[(3&n[t])<<4|n[t+1]>>4],o+=Dt[(15&n[t+1])<<2|n[t+2]>>6],o+=Dt[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ft(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ft(e.data,t,n),e.width,e.height]}}if(Ut(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:At(e,t,n)}}return e}const jt=(e,t,n)=>[...e].map((e=>Ft(e,t,n))),Ut=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Bt(e,t,n,r){const o=[];try{const s=Le(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...s){if(!qe(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(s[0]&&"object"==typeof s[0]){const e=s[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...s])}}));o.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function qt(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Le(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(At(c,i,this),"tagName"in this.canvas&&!qe(this.canvas,r,o,!0)){const e=jt([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=_e(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}class Wt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,r,o){const s=Bt(t,n,r,!0),i=new Map,a=new Nt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:Oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let u,l=0;const d=e=>{l&&e-l<c||(l=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{qe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>Tt(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),u=requestAnimationFrame(d)};u=requestAnimationFrame(d),this.resetObservers=()=>{s(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Bt(e,t,n,!1),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Le(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return qe(this.canvas,n,r,!0)||setTimeout((()=>{const n=jt([...s],t,this);e(this.canvas,{type:Oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=_e(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:Oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...qt(t.WebGLRenderingContext.prototype,Oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...qt(t.WebGL2RenderingContext.prototype,Oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(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 o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class zt{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame((()=>{this.clear(),this.loop&&this.periodicallyClear()}))}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some((e=>e!==t))}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}class Kt{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!H(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=vt(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push((()=>n.disconnect())),this.restoreHandlers.push(mt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(Ct({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))}),0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(Le(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&Ye(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class Vt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new He,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,((e,t)=>({rule:J(e),index:t})))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Gt(e){return Object.assign(Object.assign({},e),{timestamp:Ae()})}let $t,Ht,Xt,Jt=!1;const Yt=new Y;function Zt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:p,maskTextFn:v,hooks:g,packFn:m,sampling:y={},dataURLOptions:S={},mousemoveWait:b,recordDOM:I=!0,recordCanvas:w=!1,recordCrossOriginIframes:C=!1,recordAfter:E=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:k=!1,inlineImages:T=!1,plugins:O,keepIframeSrcFn:x=(()=>!1),ignoreCSSAttributes:R=new Set([]),errorHandler:N}=e;Ze(N);const D=!C||window.parent===window;let _=!1;if(!D)try{window.parent.document&&(_=!1)}catch(e){_=!0}if(D&&!t)throw new Error("emit function is required");void 0!==b&&void 0===y.mousemove&&(y.mousemove=b),Yt.reset();const L=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},P=!0===f||"all"===f?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===f,headMetaDescKeywords:"all"===f}:f||{};let A;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const j=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return m&&!_&&(e=m(e)),e};$t=(e,o)=>{var s;if(!(null===(s=ft[0])||void 0===s?void 0:s.isFrozen())||e.type===Ee.FullSnapshot||e.type===Ee.IncrementalSnapshot&&e.data.source===Me.Mutation||ft.forEach((e=>e.unfreeze())),D)null==t||t(j(e),o);else if(_){const t={type:"rrweb",event:j(e),origin:window.location.origin,isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===Ee.FullSnapshot)A=e,F=0;else if(e.type===Ee.IncrementalSnapshot){if(e.data.source===Me.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Ht(!0)}};const U=e=>{$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Mutation},e)}))},B=e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Scroll},e)})),q=e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.CanvasMutation},e)})),W=new Vt({mutationCb:U,adoptedStyleSheetCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.AdoptedStyleSheet},e)}))}),z=new rt({mirror:Yt,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:$t});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Yt,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const K=new zt;Xt=new Wt({recordCanvas:w,mutationCb:q,win:window,blockClass:o,blockSelector:s,mirror:Yt,sampling:y.canvas,dataURLOptions:S});const V=new Kt({mutationCb:U,scrollCb:B,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskInputOptions:L,dataURLOptions:S,maskTextFn:v,maskInputFn:p,recordCanvas:w,inlineImages:T,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Xt,keepIframeSrcFn:x,processedNodeManager:K},mirror:Yt});Ht=(e=!1)=>{if(!I)return;$t(Gt({type:Ee.Meta,data:{href:window.location.href,width:Ue(),height:je()}}),e),W.reset(),V.init(),ft.forEach((e=>e.lock()));const t=function(e,t){const{mirror:n=new Y,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:s="rr-mask",maskTextSelector:i=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:u=!1,maskAllInputs:l=!1,maskTextFn:d,maskInputFn:h,slimDOM:f=!1,dataURLOptions:p,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:I=(()=>!1)}=t||{};return Ce(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===l?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===l?{password:!0}:l,maskTextFn:d,maskInputFn:h,slimDOMOptions:!0===f||"all"===f?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===f,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===f?{}:f,dataURLOptions:p,inlineImages:c,recordCanvas:u,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:I,newlyAddedElement:!1})}(document,{mirror:Yt,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskAllInputs:L,maskTextFn:v,maskInputFn:p,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:T,onSerialize:e=>{Ve(e,Yt)&&z.addIframe(e),Ge(e,Yt)&&W.trackLinkElement(e),$e(e)&&V.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:x});if(!t)return console.warn("Failed to snapshot the document");$t(Gt({type:Ee.FullSnapshot,data:{node:t,initialOffset:Fe(window)}}),e),ft.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Yt.getId(document))};try{const e=[],t=e=>{var t;return et(Et)({mutationCb:U,mousemoveCb:(e,t)=>$t(Gt({type:Ee.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.MouseInteraction},e)})),scrollCb:B,viewportResizeCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.ViewportResize},e)})),inputCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Input},e)})),mediaInteractionCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.MediaInteraction},e)})),styleSheetRuleCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.StyleSheetRule},e)})),styleDeclarationCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.StyleDeclaration},e)})),canvasMutationCb:q,fontCb:e=>$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Font},e)})),selectionCb:e=>{$t(Gt({type:Ee.IncrementalSnapshot,data:Object.assign({source:Me.Selection},e)}))},blockClass:o,ignoreClass:i,ignoreSelector:a,maskTextClass:c,maskTextSelector:u,maskInputOptions:L,inlineStylesheet:l,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:T,userTriggeredOnInput:M,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:v,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:P,dataURLOptions:S,mirror:Yt,iframeManager:z,stylesheetManager:W,shadowDomManager:V,processedNodeManager:K,canvasManager:Xt,ignoreCSSAttributes:R,plugins:(null===(t=null==O?void 0:O.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>$t(Gt({type:Ee.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},g)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Ht(),e.push(t(document)),Jt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(xe("DOMContentLoaded",(()=>{$t(Gt({type:Ee.DomContentLoaded,data:{}})),"DOMContentLoaded"===E&&n()}))),e.push(xe("load",(()=>{$t(Gt({type:Ee.Load,data:{}})),"load"===E&&n()}),window))),()=>{e.forEach((e=>e())),K.destroy(),Jt=!1,Qe()}}catch(e){console.warn(e)}}var Qt,en;Zt.addCustomEvent=(e,t)=>{if(!Jt)throw new Error("please add custom event after start recording");$t(Gt({type:Ee.Custom,data:{tag:e,payload:t}}))},Zt.freezePage=()=>{ft.forEach((e=>e.freeze()))},Zt.takeFullSnapshot=e=>{if(!Jt)throw new Error("please take full snapshot after start recording");Ht(e)},Zt.mirror=Yt,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(Qt||(Qt={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(en||(en={}));var tn=Uint8Array,nn=Uint16Array,rn=Uint32Array,on=new tn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),sn=new tn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),an=new tn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cn=function(e,t){for(var n=new nn(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new rn(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},un=cn(on,2),ln=un[0],dn=un[1];ln[28]=258,dn[258]=28;for(var hn=cn(sn,0)[1],fn=new nn(32768),pn=0;pn<32768;++pn){var vn=(43690&pn)>>>1|(21845&pn)<<1;vn=(61680&(vn=(52428&vn)>>>2|(13107&vn)<<2))>>>4|(3855&vn)<<4,fn[pn]=((65280&vn)>>>8|(255&vn)<<8)>>>1}var gn=function(e,t,n){for(var r=e.length,o=0,s=new nn(t);o<r;++o)++s[e[o]-1];var i,a=new nn(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new nn(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var u=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,h=d|(1<<l)-1;d<=h;++d)i[fn[d]>>>c]=u}else for(i=new nn(r),o=0;o<r;++o)i[o]=fn[a[e[o]-1]++]>>>15-e[o];return i},mn=new tn(288);for(pn=0;pn<144;++pn)mn[pn]=8;for(pn=144;pn<256;++pn)mn[pn]=9;for(pn=256;pn<280;++pn)mn[pn]=7;for(pn=280;pn<288;++pn)mn[pn]=8;var yn=new tn(32);for(pn=0;pn<32;++pn)yn[pn]=5;var Sn=gn(mn,9,0),bn=gn(yn,5,0),In=function(e){return(e/8>>0)+(7&e&&1)},wn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof nn?nn:e instanceof rn?rn:tn)(n-t);return r.set(e.subarray(t,n)),r},Cn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},En=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Mn=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new tn(0),0];if(1==o){var i=new tn(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],u=0,l=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=o-1;)a=n[n[u].f<n[d].f?u++:d++],c=n[u!=l&&n[u].f<n[d].f?u++:d++],n[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var f=new nn(h+1),p=kn(n[l-1],f,0);if(p>t){r=0;var v=0,g=p-t,m=1<<g;for(s.sort((function(e,t){return f[t.s]-f[e.s]||e.f-t.f}));r<o;++r){var y=s[r].s;if(!(f[y]>t))break;v+=m-(1<<p-f[y]),f[y]=t}for(v>>>=g;v>0;){var S=s[r].s;f[S]<t?v-=1<<t-f[S]++-1:++r}for(;r>=0&&v;--r){var b=s[r].s;f[b]==t&&(--f[b],++v)}p=t}return[new tn(f),p]},kn=function(e,t,n){return-1==e.s?Math.max(kn(e.l,t,n+1),kn(e.r,t,n+1)):t[e.s]=n},Tn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new nn(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},On=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},xn=function(e,t,n){var r=n.length,o=In(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Rn=function(e,t,n,r,o,s,i,a,c,u,l){Cn(t,l++,n),++o[256];for(var d=Mn(o,15),h=d[0],f=d[1],p=Mn(s,15),v=p[0],g=p[1],m=Tn(h),y=m[0],S=m[1],b=Tn(v),I=b[0],w=b[1],C=new nn(19),E=0;E<y.length;++E)C[31&y[E]]++;for(E=0;E<I.length;++E)C[31&I[E]]++;for(var M=Mn(C,7),k=M[0],T=M[1],O=19;O>4&&!k[an[O-1]];--O);var x,R,N,D,_=u+5<<3,L=On(o,mn)+On(s,yn)+i,P=On(o,h)+On(s,v)+i+14+3*O+On(C,k)+(2*C[16]+3*C[17]+7*C[18]);if(_<=L&&_<=P)return xn(t,l,e.subarray(c,c+u));if(Cn(t,l,1+(P<L)),l+=2,P<L){x=gn(h,f,0),R=h,N=gn(v,g,0),D=v;var A=gn(k,T,0);Cn(t,l,S-257),Cn(t,l+5,w-1),Cn(t,l+10,O-4),l+=14;for(E=0;E<O;++E)Cn(t,l+3*E,k[an[E]]);l+=3*O;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(E=0;E<U.length;++E){var B=31&U[E];Cn(t,l,A[B]),l+=k[B],B>15&&(Cn(t,l,U[E]>>>5&127),l+=U[E]>>>12)}}}else x=Sn,R=mn,N=bn,D=yn;for(E=0;E<a;++E)if(r[E]>255){B=r[E]>>>18&31;En(t,l,x[B+257]),l+=R[B+257],B>7&&(Cn(t,l,r[E]>>>23&31),l+=on[B]);var q=31&r[E];En(t,l,N[q]),l+=D[q],q>3&&(En(t,l,r[E]>>>5&8191),l+=sn[q])}else En(t,l,x[r[E]]),l+=R[r[E]];return En(t,l,x[256]),l+R[256]},Nn=new rn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Dn=new tn(0),_n=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new tn(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),u=0;if(!t||i<8)for(var l=0;l<=i;l+=65535){var d=l+65535;d<i?u=xn(c,u,e.subarray(l,d)):(c[l]=s,u=xn(c,u,e.subarray(l,i)))}else{for(var h=Nn[t-1],f=h>>>13,p=8191&h,v=(1<<n)-1,g=new nn(32768),m=new nn(v+1),y=Math.ceil(n/3),S=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<S)&v},I=new rn(25e3),w=new nn(288),C=new nn(32),E=0,M=0,k=(l=0,0),T=0,O=0;l<i;++l){var x=b(l),R=32767&l,N=m[x];if(g[R]=N,m[x]=R,T<=l){var D=i-l;if((E>7e3||k>24576)&&D>423){u=Rn(e,c,0,I,w,C,M,k,O,l-O,u),k=E=M=0,O=l;for(var _=0;_<286;++_)w[_]=0;for(_=0;_<30;++_)C[_]=0}var L=2,P=0,A=p,F=R-N&32767;if(D>2&&x==b(l-F))for(var j=Math.min(f,D)-1,U=Math.min(32767,l),B=Math.min(258,D);F<=U&&--A&&R!=N;){if(e[l+L]==e[l+L-F]){for(var q=0;q<B&&e[l+q]==e[l+q-F];++q);if(q>L){if(L=q,P=F,q>j)break;var W=Math.min(F,q-2),z=0;for(_=0;_<W;++_){var K=l-F+_+32768&32767,V=K-g[K]+32768&32767;V>z&&(z=V,N=K)}}}F+=(R=N)-(N=g[R])+32768&32767}if(P){I[k++]=268435456|dn[L]<<18|hn[P];var G=31&dn[L],$=31&hn[P];M+=on[G]+sn[$],++w[257+G],++C[$],T=l+L,++E}else I[k++]=e[l],++w[e[l]]}}u=Rn(e,c,s,I,w,C,M,k,O,l-O,u),s||(u=xn(c,u,Dn))}return wn(a,0,r+In(u)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Ln(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=_n(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Pn=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Ln(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new tn(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new tn(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return wn(r,0,o)}(JSON.stringify(t))),!0)};var An,Fn;(Fn=An||(An={}))[Fn.NotStarted=0]="NotStarted",Fn[Fn.Running=1]="Running",Fn[Fn.Stopped=2]="Stopped";const jn=(e,t)=>t.some((t=>e instanceof t));let Un,Bn;const qn=new WeakMap,Wn=new WeakMap,zn=new WeakMap;let Kn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return qn.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Hn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Vn(e){Kn=e(Kn)}function Gn(e){return(Bn||(Bn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Xn(this),t),Hn(this.request)}:function(...t){return Hn(e.apply(Xn(this),t))}}function $n(e){return"function"==typeof e?Gn(e):(e instanceof IDBTransaction&&function(e){if(qn.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)}));qn.set(e,t)}(e),jn(e,Un||(Un=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Kn):e)}function Hn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t(Hn(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)}));return zn.set(t,e),t}(e);if(Wn.has(e))return Wn.get(e);const t=$n(e);return t!==e&&(Wn.set(e,t),zn.set(t,e)),t}const Xn=e=>zn.get(e);function Jn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Hn(i);return r&&i.addEventListener("upgradeneeded",(e=>{r(Hn(i.result),e.oldVersion,e.newVersion,Hn(i.transaction),e)})),n&&i.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Yn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Hn(n).then((()=>{}))}const Zn=["get","getKey","getAll","getAllKeys","count"],Qn=["put","add","delete","clear"],er=new Map;function tr(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(er.get(t))return er.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Qn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Zn.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return er.set(t,s),s}Vn((e=>({...e,get:(t,n,r)=>tr(t,n)||e.get(t,n,r),has:(t,n)=>!!tr(t,n)||e.has(t,n)})));const nr=["continue","continuePrimaryKey","advance"],rr={},or=new WeakMap,sr=new WeakMap,ir={get(e,t){if(!nr.includes(t))return e[t];let n=rr[t];return n||(n=rr[t]=function(...e){or.set(this,sr.get(this)[t](...e))}),n}};async function*ar(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,ir);for(sr.set(n,t),zn.set(n,Xn(t));t;)yield n,t=await(or.get(n)||t.continue()),or.delete(n)}function cr(e,t){return t===Symbol.asyncIterator&&jn(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&jn(e,[IDBIndex,IDBObjectStore])}Vn((e=>({...e,get:(t,n,r)=>cr(t,n)?ar:e.get(t,n,r),has:(t,n)=>cr(t,n)||e.has(t,n)})));var ur,lr=function(e,t){return o(void 0,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,Jn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},dr=function(e){var t=e.loggerProvider,n=e.apiKey,i=e.configKeys;return o(void 0,void 0,void 0,(function(){var e,u,l,d,h,f,p,v,g,m;return s(this,(function(y){switch(y.label){case 0:return e="".concat(n.substring(0,10),"_amp_config"),[4,lr(e,i)];case 1:return u=y.sent(),l="".concat(n.substring(0,10),"_amp_config_meta"),[4,(S=l,o(void 0,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(S,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:d=y.sent(),y.label=3;case 3:return y.trys.push([3,8,,9]),[4,d.get("lastFetchedSessionId","sessionId")];case 4:return(h=y.sent())&&Date.now()-h>=2592e5?(u.close(),[4,Yn(e)]):[3,7];case 5:return y.sent(),[4,lr(e,i)];case 6:u=y.sent(),y.label=7;case 7:return[3,9];case 8:return f=y.sent(),t.warn("Failed to reset store: ".concat(f)),[3,9];case 9:return p=function(e,n){return o(void 0,void 0,void 0,(function(){var o,i,l,h,f,p;return s(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,d.put("lastFetchedSessionId",n,"sessionId")]:[3,2];case 1:v.sent(),v.label=2;case 2:for(h in o=function(t){var n,o;return s(this,(function(s){switch(s.label){case 0:return n=e.configs[t],o=u.transaction(t,"readwrite"),[4,Promise.all(c(c([],a(Object.keys(n).map((function(e){return o.store.put(r({},n[e]),e)}))),!1),[o.done],!1))];case 1:return s.sent(),[2]}}))},i=e.configs,l=[],i)l.push(h);f=0,v.label=3;case 3:return f<l.length?(h=l[f])in i?[5,o(h)]:[3,5]:[3,6];case 4:v.sent(),v.label=5;case 5:return f++,[3,3];case 6:return[3,8];case 7:return p=v.sent(),t.warn("Failed to store remote config: ".concat(p)),[3,8];case 8:return[2]}}))}))},v=function(){return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d.get("lastFetchedSessionId","sessionId")];case 1:return[2,n.sent()];case 2:return e=n.sent(),t.warn("Failed to fetch lastFetchedSessionId: ".concat(e)),[3,3];case 3:return[2,void 0]}}))}))},g=function(e,n){return o(void 0,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.get(e,n)];case 1:return[2,o.sent()];case 2:return r=o.sent(),t.warn("Failed to fetch remote config: ".concat(r)),[3,3];case 3:return[2,void 0]}}))}))},m=function(e){return o(void 0,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,u.getAll(e)];case 1:return[2,!!r.sent().length];case 2:return n=r.sent(),t.warn("Failed to fetch remote config: ".concat(n)),[3,3];case 3:return[2,!1]}}))}))},[2,{storeRemoteConfig:p,getRemoteConfig:g,getLastFetchedSessionId:v,remoteConfigHasValues:m}]}var S}))}))},hr="Remote config fetch rejected due to timeout after 5 seconds",fr=function(){function e(e){var t=e.localConfig,n=e.configKeys,i=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.metrics={},this.getRemoteConfig=function(e,t,n){return o(i,void 0,void 0,(function(){var r,o,i,a,c;return s(this,(function(s){switch(s.label){case 0:return r=Date.now(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getLastFetchedSessionId()]:[3,3];case 1:return(o=s.sent())&&n&&o===n?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 2:return i=s.sent(),this.metrics.fetchTimeIDB=Date.now()-r,[2,i];case 3:return[4,this.fetchWithTimeout(n)];case 4:return(a=s.sent())&&(c=a.configs&&a.configs[e])?(this.metrics.fetchTimeAPISuccess=Date.now()-r,[2,c[t]]):(this.metrics.fetchTimeAPIFail=Date.now()-r,[2,void 0])}}))}))},this.fetchWithTimeout=function(e){return o(i,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return o(i,void 0,void 0,(function(){var n,o,i,a,c,u;return s(this,(function(s){switch(s.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:hr})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),s.label=1;case 1:return s.trys.push([1,3,,4]),n=new URLSearchParams({api_key:this.localConfig.apiKey,config_keys:this.configKeys.join(",")}),o={headers:{"Content-Type":"application/json",Accept:"*/*"},method:"GET"},i="".concat(this.getServerUrl(),"?").concat(n.toString()),this.attempts+=1,[4,fetch(i,r(r({},o),{signal:e}))];case 2:if(null===(a=s.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new F).buildStatus(a.status)){case S.Success:return this.attempts=0,[2,this.parseAndStoreConfig(a,t)];case S.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return c=s.sent(),u=c,e.aborted?[2,this.completeRequest({err:hr})]:[2,this.completeRequest({err:u.message})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return o(i,void 0,void 0,(function(){var n=this;return s(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e,t){return o(i,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.storeRemoteConfig(n,t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return this.completeRequest({success:"Remote config successfully fetched"}),[2,n]}}))}))},this.localConfig=t,this.configKeys=n}return e.prototype.initialize=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this,[4,dr({apiKey:this.localConfig.apiKey,loggerProvider:this.localConfig.loggerProvider,configKeys:this.configKeys})];case 1:return e.remoteConfigIDBStore=t.sent(),[2]}}))}))},e.prototype.getServerUrl=function(){return this.localConfig.serverZone===y.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===y.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),pr=function(e){var t=e.localConfig,n=e.configKeys;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return[4,(e=new fr({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},vr="medium";!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ur||(ur={}));var gr,mr=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){const 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 mr(e,vr,n)}},yr=function(e,t){return function(n,r){return function(e,t,n){var r,o,s;if(void 0===t&&(t={defaultMaskLevel:vr}),n){if(n.closest("."+z))return!0;var i=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(i)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return mr(e,null!==(s=t.defaultMaskLevel)&&void 0!==s?s:vr,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Sr=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},br=function(e){return e===y.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===y.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track"},Ir=function(){return o(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),(e=E())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=s.sent(),n=t.usage,r=t.quota,o=t.usageDetails,i=n?Math.round(n/1024):0,a=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:i,percentOfQuota:a,usageDetails:JSON.stringify(o)}];case 2:return[3,4];case 3:return s.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}}))}))},wr=function(e){var t=r({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},Cr=function(){function e(e,t){this.localConfig=new G(e,t)}return e.prototype.initialize=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this,[4,pr({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){var t,n,c;return o(this,void 0,void 0,(function(){var o,u,l,d,h,f,p,v,g,m,y,S,b,I,w,C,E,M,k,T,O,x;return s(this,(function(s){switch(s.label){case 0:(o=r({},this.localConfig)).optOut=this.localConfig.optOut,o.captureEnabled=!0,s.label=1;case 1:return s.trys.push([1,6,,7]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:(o.captureEnabled=!1,[2,o]);case 2:return l=s.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return d=s.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_targeting_config",e)];case 4:return h=s.sent(),f=o,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_interaction_config",e)];case 5:return f.interactionConfig=s.sent(),(l||d)&&(u={},l&&(u.sr_sampling_config=l),d&&(u.sr_privacy_config=d),h&&(u.sr_targeting_config=h)),[3,7];case 6:return p=s.sent(),v=p,this.localConfig.loggerProvider.warn(v.message),o.captureEnabled=!1,[3,7];case 7:if(!u)return[2,o];if(g=u.sr_sampling_config,m=u.sr_privacy_config,y=u.sr_targeting_config,g&&Object.keys(g).length>0?(Object.prototype.hasOwnProperty.call(g,"capture_enabled")?o.captureEnabled=g.capture_enabled:o.captureEnabled=!1,Object.prototype.hasOwnProperty.call(g,"sample_rate")&&(o.sampleRate=g.sample_rate)):(o.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),m){S=null!==(t=o.privacyConfig)&&void 0!==t?t:{},b={defaultMaskLevel:null!==(c=null!==(n=m.defaultMaskLevel)&&void 0!==n?n:S.defaultMaskLevel)&&void 0!==c?c:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},I=function(e){var t,n,r,o,s,a,c,u,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var h=i(null!==(c=e.blockSelector)&&void 0!==c?c:[]),f=h.next();!f.done;f=h.next()){d[f.value]="block"}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var p=i(null!==(u=e.maskSelector)&&void 0!==u?u:[]),v=p.next();!v.done;v=p.next()){d[v.value]="mask"}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var g=i(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),m=g.next();!m.done;m=g.next()){d[m.value]="unmask"}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=g.return)&&a.call(g)}finally{if(s)throw s.error}}return d},w=r(r({},I(S)),I(m));try{for(C=i(Object.entries(w)),E=C.next();!E.done;E=C.next())M=a(E.value,2),k=M[0],"mask"===(T=M[1])?b.maskSelector.push(k):"block"===T?b.blockSelector.push(k):"unmask"===T&&b.unmaskSelector.push(k)}catch(e){O={error:e}}finally{try{E&&!E.done&&(x=C.return)&&x.call(C)}finally{if(O)throw O.error}}o.privacyConfig=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e}(b,this.localConfig.loggerProvider)}return y&&Object.keys(y).length>0&&(o.targetingConfig=y),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:wr(o)},null,2)),[2,o]}}))}))},e}(),Er=function(e,t){return o(void 0,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,(n=new Cr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},Mr="Session replay event batch rejected due to exceeded retry count",kr="Failed to store session replay events in IndexedDB";!function(e){e.RECORDING="recording",e.SENT="sent"}(gr||(gr={}));var Tr,Or,xr,Rr="sessionCurrentSequence",Nr="sequencesToSend",Dr=function(){var e=E();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)}}catch(e){n(e)}}))},_r=function(e){return o(void 0,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e.length>0?(10,t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},Lr=function(e){var t,n;return e.objectStoreNames.contains(Rr)||(n=e.createObjectStore(Rr,{keyPath:"sessionId"})),e.objectStoreNames.contains(Nr)||(t=e.createObjectStore(Nr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Pr=function(e){return o(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,Jn(e,1,{upgrade:Lr})];case 1:return[2,t.sent()]}}))}))},Ar=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,i=e.minInterval,a=e.maxInterval,c=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=c.maxPersistedEventsSize||!!(null!==c.timeAtLastSplit&&c.interval&&Date.now()-c.timeAtLastSplit>c.interval&&e.length)&&(c.interval=Math.min(c.maxInterval,c.interval+c.minInterval),c.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return o(c,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,null===(t=this.db)||void 0===t?void 0:t.getAll(Nr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=function(e){return o(c,void 0,void 0,(function(){var t,n,o;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),this.db?[4,this.db.get(Rr,e)]:[2,void 0];case 1:return(t=s.sent())?[4,this.db.put(Nr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=s.sent(),[4,this.db.put(Rr,{sessionId:e,events:[]})];case 3:return s.sent(),[2,r(r({},t),{sessionId:e,sequenceId:n})];case 4:return o=s.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(o)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return o(c,void 0,void 0,(function(){var n,r,o,i,a,c,u;return s(this,(function(s){switch(s.label){case 0:0===this.interval&&(this.interval=this.minInterval),s.label=1;case 1:return s.trys.push([1,11,,12]),(n=null===(u=this.db)||void 0===u?void 0:u.transaction(Rr,"readwrite"))?[4,n.store.get(e)]:[2];case 2:return(r=s.sent())?[3,4]:[4,n.store.put({sessionId:e,events:[t]})];case 3:return s.sent(),[2];case 4:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,6];case 5:return s.sent(),[3,8];case 6:return i=r.events.concat(t),[4,n.store.put({sessionId:e,events:i})];case 7:s.sent(),s.label=8;case 8:return[4,n.done];case 9:return s.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 10:return(a=s.sent())?[2,{events:o,sessionId:e,sequenceId:a}]:[2,void 0];case 11:return c=s.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(c)),[3,12];case 12:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return o(c,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(r=this.db)||void 0===r?void 0:r.put(Nr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return o(c,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,null===(n=this.db)||void 0===n?void 0:n.delete(Nr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(kr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return o(c,void 0,void 0,(function(){var t,n,r,i,a,c,u,l,d=this;return s(this,(function(h){switch(h.label){case 0:return h.trys.push([0,6,,7]),[4,Dr()];case 1:if(!(t=h.sent()))return[2];n=function(e,t){return o(d,void 0,void 0,(function(){var n,r,i=this;return s(this,(function(a){switch(a.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(a){var c=parseInt(a,10),u=n[c];if(c===t.currentSequenceId){var l=u.events.map((function(t){return o(i,void 0,void 0,(function(){return s(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));r.concat(l)}else u.status!==gr.SENT&&r.push(i.storeSendingEvents(e,u.events))})),[4,_r(r)];case 1:return a.sent(),[2]}}))}))},r="".concat(k,"_").concat(this.apiKey.substring(0,10)),h.label=2;case 2:return h.trys.push([2,4,,5]),i=t.transaction("keyval").objectStore("keyval").getAll(r),a=new Promise((function(t){i.onsuccess=function(r){return o(d,void 0,void 0,(function(){var o,i,a,c=this;return s(this,(function(s){switch(s.label){case 0:return o=r&&r.target.result,(i=o&&o[0])?(a=[],Object.keys(i).forEach((function(t){var r=parseInt(t,10),o=i[r];if(e===r)a.push(n(r,o));else{var s=o.sessionSequences;Object.keys(s).forEach((function(e){var t=parseInt(e,10);s[t].status!==gr.SENT&&a.push(c.storeSendingEvents(r,s[t].events))}))}})),[4,_r(a)]):[3,2];case 1:s.sent(),s.label=2;case 2:return t(),[2]}}))}))}})),[4,a];case 3:return h.sent(),(c=E())&&c.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return u=h.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(u)),[3,5];case 5:return[3,7];case 6:return l=h.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(l,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},this.loggerProvider=t,this.apiKey=n,this.maxInterval=null!=a?a:1e4,this.minInterval=null!=i?i:500,this.interval=0}return e.prototype.initialize=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(s){switch(s.label){case 0:return n="replay"===e?"":"_".concat(e),r="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events").concat(n),o=this,[4,Pr(r)];case 1:return o.db=s.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(t)];case 2:return s.sent(),[2]}}))}))},e}(),Fr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId,i=e.type,a=e.minInterval,c=e.maxInterval;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(o){switch(o.label){case 0:return[4,(e=new Ar({loggerProvider:t,apiKey:n,minInterval:a,maxInterval:c})).initialize(i,r)];case 1:return o.sent(),[2,e]}}))}))},jr="1.14.0-srtargeting.1",Ur=function(){function e(e){var t=e.loggerProvider,n=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t,this.payloadBatcher=n||function(e){return e}}return e.prototype.sendEventsList=function(e){this.addToQueue(r(r({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(Mr,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t=!0),o(this,void 0,void 0,(function(){var o,i,a,c,u,l,d,h,f,p,v,g,m;return s(this,(function(s){switch(s.label){case 0:if(!(o=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(i=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(y=E(),a=(null==y?void 0:y.location)?y.location.href:"",c=jr,u=e.sampleRate,l=new URLSearchParams({device_id:i,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId),type:"".concat(e.type)}),d="".concat((null===(n=e.version)||void 0===n?void 0:n.type)||"standalone","/").concat((null===(r=e.version)||void 0===r?void 0:r.version)||c),0===(h=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),f={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(o),"X-Client-Version":c,"X-Client-Library":d,"X-Client-Url":a,"X-Client-Sample-Rate":"".concat(u)},body:JSON.stringify(h),method:"POST"},p="".concat(br(e.serverZone),"?").concat(l.toString()),[4,fetch(p,f)];case 2:if(null===(v=s.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(v.status,e);else{g="";try{g=JSON.stringify(v.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(v.status,": ").concat(g)})}return[3,4];case 3:return m=s.sent(),this.completeRequest({context:e,err:m}),[3,4];case 4:return[2]}var y}))}))},e.prototype.handleReponse=function(e,t){switch((new F).buildStatus(e)){case S.Success:this.handleSuccessResponse(t);break;case S.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch with seq id ".concat(e.sequenceId," tracked successfully for session id ").concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){this.addToQueue(r(r({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(t.sequenceId),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}(),Br=function(e){var t=e.config,n=e.sessionId,r=e.minInterval,i=e.maxInterval,a=e.type,c=e.payloadBatcher;return o(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,u.flush(e)]}))}))}var u,l,d,h,f,p;return s(this,(function(v){switch(v.label){case 0:return u=new Ur({loggerProvider:t.loggerProvider,payloadBatcher:c}),[4,Fr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n,minInterval:r,maxInterval:i,type:a})];case 1:return l=v.sent(),d=function(e){var n=e.events,r=e.sessionId,o=e.deviceId,s=e.sequenceId;t.debugMode&&Ir().then((function(e){var n=e.totalStorageSize,r=e.percentOfQuota,o=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(o))})).catch((function(){})),u.sendEventsList({events:n,sequenceId:s,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:a,onComplete:l.cleanUpSessionEventsStore.bind(l)})},h=function(e){var n=e.sessionId,r=e.deviceId;l.storeCurrentSequence(n).then((function(e){e&&d({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)}))},f=function(e){var t=e.deviceId;return o(void 0,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,l.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},p=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;l.addEventToCurrentSequence(r,n.data).then((function(e){return e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:h,addEvent:p,sendStoredEvents:f,flush:e}]}}))}))},qr=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 o(this,void 0,void 0,(function(){var t;return s(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,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},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 o(this,void 0,void 0,(function(){var t;return s(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}(),Wr=(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))(Wr||{});function zr(e,t){if(xr=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};Tr=r(r({},n),t),Or=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Tr.root,n);var o=Kr(e,"all",(function(){return Kr(e,"two",(function(){return Kr(e,"one",(function(){return Kr(e,"none")}))}))}));if(o){var s=eo(to(o,e));return s.length>0&&(o=s[0]),Gr(o)}throw new Error("Selector was not found.")}function Kr(e,t,n){for(var r=null,o=[],s=e,u=0,l=function(){var e,l,d=(new Date).getTime()-xr.getTime();if(void 0!==Tr.timeoutMs&&d>Tr.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var h=Yr(function(e){var t=e.getAttribute("id");if(t&&Tr.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(s))||Yr.apply(void 0,c([],a(function(e){var t=Array.from(e.attributes).filter((function(e){return Tr.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(s)),!1))||Yr.apply(void 0,c([],a(function(e){var t=Array.from(e.classList).filter(Tr.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(s)),!1))||Yr(function(e){var t=e.tagName.toLowerCase();if(Tr.tagName(t))return{name:t,penalty:2};return null}(s))||[{name:"*",penalty:3}],f=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}(s);if("all"==t)f&&(h=h.concat(h.filter(Jr).map((function(e){return Xr(e,f)}))));else if("two"==t)h=h.slice(0,1),f&&(h=h.concat(h.filter(Jr).map((function(e){return Xr(e,f)}))));else if("one"==t){var p=a(h=h.slice(0,1),1)[0];f&&Jr(p)&&(h=[Xr(p,f)])}else"none"==t&&(h=[{name:"*",penalty:3}],f&&(h=[Xr(h[0],f)]));try{for(var v=(e=void 0,i(h)),g=v.next();!g.done;g=v.next()){(p=g.value).level=u}}catch(t){e={error:t}}finally{try{g&&!g.done&&(l=v.return)&&l.call(v)}finally{if(e)throw e.error}}if(o.push(h),o.length>=Tr.seedMinLength&&(r=Vr(o,n)))return"break";s=s.parentElement,u++};s;){if("break"===l())break}return r||(r=Vr(o,n)),!r&&n?n():r}function Vr(e,t){var n,r,o=eo(Qr(e));if(o.length>Tr.threshold)return t?t():null;try{for(var s=i(o),a=s.next();!a.done;a=s.next()){var c=a.value;if(Hr(c))return c}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null}function Gr(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function $r(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function Hr(e){var t=Gr(e);switch(Or.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 Xr(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function Jr(e){return"html"!==e.name&&!e.name.startsWith("#")}function Yr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Zr);return n.length>0?n:null}function Zr(e){return null!=e}function Qr(e,t){var n,r,o,a,c,u;return void 0===t&&(t=[]),s(this,(function(s){switch(s.label){case 0:if(!(e.length>0))return[3,9];s.label=1;case 1:s.trys.push([1,6,7,8]),n=i(e[0]),r=n.next(),s.label=2;case 2:return r.done?[3,5]:(o=r.value,[5,i(Qr(e.slice(1,e.length),t.concat(o)))]);case 3:s.sent(),s.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),c={error:a},[3,8];case 7:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:s.sent(),s.label=11;case 11:return[2]}}))}function eo(e){return c([],a(e),!1).sort((function(e,t){return $r(e)-$r(t)}))}function to(e,t,n){var r,o,u;return void 0===n&&(n={counter:0,visited:new Map}),s(this,(function(s){switch(s.label){case 0:if(!(e.length>2&&e.length>Tr.optimizedMinLength))return[3,5];r=1,s.label=1;case 1:return r<e.length-1?n.counter>Tr.maxNumberOfTries?[2]:(n.counter+=1,(o=c([],a(e),!1)).splice(r,1),u=Gr(o),n.visited.has(u)?[2]:Hr(o)&&function(e,t){return Or.querySelector(Gr(e))===t}(o,t)?[4,o]:[3,4]):[3,5];case 2:return s.sent(),n.visited.set(u,!0),[5,i(to(o,t,n))];case 3:s.sent(),s.label=4;case 4:return r++,[3,1];case 5:return[2]}}))}var no=function(e){var t=e.version,n=e.events,o=[];n.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&o.push(t)}));var s=o.reduce((function(e,t){var n=t.x,o=t.y,s=t.selector,i=t.timestamp,a=i-i%36e5,c="".concat(n,":").concat(o,":").concat(null!=s?s:"",":").concat(a);return e[c]?e[c].count+=1:e[c]=r(r({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(s)}},ro=function(e){var t=e.eventsManager,n=e.sessionId,r=e.deviceIdFn;return function(e){if(e.type===Wr.Click){var o=E();if(o){var s=o.location,i=o.innerHeight,a=o.innerWidth;if(s){var c,u=e.x,l=e.y,d=Zt.mirror.getNode(e.id);d&&(c=zr(d));var h=Fe(o),f={x:u+h.left,y:l+h.top,selector:c,viewportHeight:i,viewportWidth:a,pageUrl:s.href,timestamp:Date.now(),type:"click"},p=r();p&&t.addEvent({sessionId:n,event:{type:"interaction",data:JSON.stringify(f)},deviceId:p})}}}}},oo=function(){function e(e,t){var n=E();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=br(t.serverZone),this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,o=n.type,s=new URLSearchParams({device_id:e,session_id:String(r),type:String(o)}),i="".concat(this.basePageUrl,"?").concat(s.toString());this.sendBeacon(i,t)||this.sendXhr(i,t)},e}(),so=je,io=Ue,ao=function(){function e(e){var t=this;this.timestamp=Date.now(),this.hook=function(e){t.update(e)},this.send=function(e){return function(n){var r=e(),o=E();o&&r&&t.transport.send(r,{maxScrollX:t._maxScrollX,maxScrollY:t._maxScrollY,maxScrollWidth:t._maxScrollWidth,maxScrollHeight:t._maxScrollHeight,viewportHeight:so(),viewportWidth:io(),pageUrl:o.location.href,timestamp:t.timestamp,type:"scroll"})}},this._maxScrollX=0,this._maxScrollY=0,this._maxScrollWidth=io(),this._maxScrollHeight=so(),this.transport=e}return e.default=function(t,n){return new e(new oo(t,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},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}),e.prototype.update=function(e){var t=Date.now();if(e.x>this._maxScrollX){var n=io();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var o=so();this._maxScrollY=e.y;var s=e.y+o;s>this._maxScrollHeight&&(this._maxScrollHeight=s),this.timestamp=t}},e}(),co=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))},uo=function(e,t){return uo=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])},uo(e,t)};var lo=function(){return lo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},lo.apply(this,arguments)};function ho(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"==typeof SuppressedError&&SuppressedError;var fo="is",po="is not",vo="contains",go="does not contain",mo="less",yo="less or equal",So="greater",bo="greater or equal",Io="version less",wo="version less or equal",Co="version greater",Eo="version greater or equal",Mo="set is",ko="set is not",To="set contains",Oo="set does not contain",xo="set contains any",Ro="set does not contain any",No="regex match",Do="regex does not match",_o=-862048943,Lo=461845907,Po=function(e,t){void 0===t&&(t=0);for(var n=function(e){for(var t=[],n=0,r=0;r<e.length;r++){var o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return Uint8Array.from(t)}(e),r=n.length,o=r>>2,s=t,i=0;i<o;i++){var a=Uo(n,i<<2);s=Ao(a,s)}var c=o<<2,u=0;switch(r-c){case 3:u^=n[c+2]<<16,u^=n[c+1]<<8,u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo);break;case 2:u^=n[c+1]<<8,u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo);break;case 1:u^=n[c],u=Math.imul(u,_o),u=jo(u,15),s^=u=Math.imul(u,Lo)}return Fo(s^=r)>>>0},Ao=function(e,t){var n=e,r=t;return n=Math.imul(n,_o),n=jo(n,15),n=Math.imul(n,Lo),r=jo(r^=n,13),(r=Math.imul(r,5))+-430675100|0},Fo=function(e){var t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16},jo=function(e,t,n){return void 0===n&&(n=32),t>n&&(t%=n),(e<<t|(e&4294967295<<n-t>>>0)>>>0>>>n-t>>>0)>>>0},Uo=function(e,t){void 0===t&&(t=0);var n=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return Bo(n)},Bo=function(e){return(-16777216&e)>>>24|(16711680&e)>>>8|(65280&e)<<8|(255&e)<<24},qo=function(e,t){var n,r;if(t&&0!==t.length){try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(!i||!e||"object"!=typeof e)return;e=e[i]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return e||void 0}},Wo="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),zo=function(){function e(e,t,n,r){void 0===r&&(r=void 0),this.major=e,this.minor=t,this.patch=n,this.preRelease=r}return e.parse=function(t){if(t){var n=new RegExp(Wo).exec(t);if(n){var r=Number(n[1]),o=Number(n[2]);if(!isNaN(r)&&!isNaN(o))return new e(r,o,Number(n[4])||0,n[5]||void 0)}}},e.prototype.compareTo=function(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0},e}(),Ko=function(){function e(){}return e.prototype.evaluate=function(e,t){var n,r,o={},s={context:e,result:o};try{for(var i=ho(t),a=i.next();!a.done;a=i.next()){var c=a.value,u=this.evaluateFlag(s,c);u&&(o[c.key]=u)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o},e.prototype.evaluateFlag=function(e,t){var n,r,o;try{for(var s=ho(t.segments),i=s.next();!i.done;i=s.next()){var a=i.value;if(o=this.evaluateSegment(e,t,a)){var c=lo(lo(lo({},t.metadata),a.metadata),o.metadata);o=lo(lo({},o),{metadata:c});break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o},e.prototype.evaluateSegment=function(e,t,n){var r,o,s,i;if(!n.conditions)return void 0!==(u=this.bucket(e,n))?t.variants[u]:void 0;try{for(var a=ho(n.conditions),c=a.next();!c.done;c=a.next()){var u,l=c.value,d=!0;try{for(var h=(s=void 0,ho(l)),f=h.next();!f.done;f=h.next()){var p=f.value;if(!(d=this.matchCondition(e,p)))break}}catch(e){s={error:e}}finally{try{f&&!f.done&&(i=h.return)&&i.call(h)}finally{if(s)throw s.error}}if(d)return void 0!==(u=this.bucket(e,n))?t.variants[u]:void 0}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}},e.prototype.matchCondition=function(e,t){var n=qo(e,t.selector);if(n){if(this.isSetOperator(t.op)){var r=this.coerceStringArray(n);return!!r&&this.matchSet(r,t.op,t.values)}var o=this.coerceString(n);return void 0!==o&&this.matchString(o,t.op,t.values)}return this.matchNull(t.op,t.values)},e.prototype.getHash=function(e){return Po(e)},e.prototype.bucket=function(e,t){var n,r,o,s;if(!t.bucket)return t.variant;var i=this.coerceString(qo(e,t.bucket.selector));if(!i||0===i.length)return t.variant;var a="".concat(t.bucket.salt,"/").concat(i),c=this.getHash(a),u=c%100,l=Math.floor(c/100);try{for(var d=ho(t.bucket.allocations),h=d.next();!h.done;h=d.next()){var f=h.value,p=f.range[0],v=f.range[1];if(u>=p&&u<v)try{for(var g=(o=void 0,ho(f.distributions)),m=g.next();!m.done;m=g.next()){var y=m.value,S=y.range[0],b=y.range[1];if(l>=S&&l<b)return y.variant}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=g.return)&&s.call(g)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return t.variant},e.prototype.matchNull=function(e,t){var n=this.containsNone(t);switch(e){case fo:case vo:case mo:case yo:case So:case bo:case Io:case wo:case Co:case Eo:case Mo:case To:case xo:return n;case po:case go:case Oo:case Ro:return!n;default:return!1}},e.prototype.matchSet=function(e,t,n){switch(t){case Mo:return this.setEquals(e,n);case ko:return!this.setEquals(e,n);case To:return this.matchesSetContainsAll(e,n);case Oo:return!this.matchesSetContainsAll(e,n);case xo:return this.matchesSetContainsAny(e,n);case Ro:return!this.matchesSetContainsAny(e,n);default:return!1}},e.prototype.matchString=function(e,t,n){var r=this;switch(t){case fo:return this.matchesIs(e,n);case po:return!this.matchesIs(e,n);case vo:return this.matchesContains(e,n);case go:return!this.matchesContains(e,n);case mo:case yo:case So:case bo:return this.matchesComparable(e,t,n,(function(e){return r.parseNumber(e)}),this.comparator);case Io:case wo:case Co:case Eo:return this.matchesComparable(e,t,n,(function(e){return zo.parse(e)}),this.versionComparator);case No:return this.matchesRegex(e,n);case Do:return!this.matchesRegex(e,n);default:return!1}},e.prototype.matchesIs=function(e,t){if(this.containsBooleans(t)){var n=e.toLowerCase();if("true"===n||"false"===n)return t.some((function(e){return e.toLowerCase()===n}))}return t.some((function(t){return e===t}))},e.prototype.matchesContains=function(e,t){var n,r;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.toLowerCase().includes(i.toLowerCase()))return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1},e.prototype.matchesComparable=function(e,t,n,r,o){var s=this,i=r(e),a=n.map((function(e){return r(e)})).filter((function(e){return void 0!==e}));return void 0===i||0===a.length?n.some((function(n){return s.comparator(e,t,n)})):a.some((function(e){return o(i,t,e)}))},e.prototype.comparator=function(e,t,n){switch(t){case mo:case Io:return e<n;case yo:case wo:return e<=n;case So:case Co:return e>n;case bo:case Eo:return e>=n;default:return!1}},e.prototype.versionComparator=function(e,t,n){var r=e.compareTo(n);switch(t){case mo:case Io:return r<0;case yo:case wo:return r<=0;case So:case Co:return r>0;case bo:case Eo:return r>=0;default:return!1}},e.prototype.matchesRegex=function(e,t){return t.some((function(t){return Boolean(new RegExp(t).exec(e))}))},e.prototype.containsNone=function(e){return e.some((function(e){return"(none)"===e}))},e.prototype.containsBooleans=function(e){return e.some((function(e){switch(e.toLowerCase()){case"true":case"false":return!0;default:return!1}}))},e.prototype.parseNumber=function(e){var t;return null!==(t=Number(e))&&void 0!==t?t:void 0},e.prototype.coerceString=function(e){if(e)return"object"==typeof e?JSON.stringify(e):String(e)},e.prototype.coerceStringArray=function(e){var t=this;if(Array.isArray(e))return e.map((function(e){return t.coerceString(e)})).filter(Boolean);var n=String(e);try{var r=JSON.parse(n);return Array.isArray(r)?e.map((function(e){return t.coerceString(e)})).filter(Boolean):void 0}catch(e){return}},e.prototype.isSetOperator=function(e){switch(e){case Mo:case ko:case To:case Oo:case xo:case Ro:return!0;default:return!1}},e.prototype.setEquals=function(e,t){var n=new Set(e),r=new Set(t);return n.size===r.size&&function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}(r),!1).every((function(e){return n.has(e)}))},e.prototype.matchesSetContainsAll=function(e,t){var n,r;if(e.length<t.length)return!1;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(!this.matchesIs(i,e))return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!0},e.prototype.matchesSetContainsAny=function(e,t){var n,r;try{for(var o=ho(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(this.matchesIs(i,e))return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1},e}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;(e=>{let t={};e.forEach(((e,n)=>t[e]=n))})(Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(e){function t(n,r){var o=e.call(this,r)||this;return o.statusCode=n,Object.setPrototypeOf(o,t.prototype),o}(function(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}uo(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)})(t,e)}(Error);var Vo=function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(t,1,{upgrade:function(e){e.objectStoreNames.contains("eventTypesForSession")||e.createObjectStore("eventTypesForSession",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}}))}))},this.openOrCreateDB=function(t){return o(e,void 0,void 0,(function(){var e,n;return s(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_targeting"),[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}}))}))},this.updateEventListForSession=function(t){var n=t.sessionId,i=t.eventType,a=t.eventTime,c=t.loggerProvider,u=t.tx;return o(e,void 0,void 0,(function(){var e,t,o,l,d,h,f;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,u.store.get(n)];case 1:return e=s.sent(),t=e?e.eventTypes:{},o=t[i]||{},l=r(r({},t),((h={})[i]=r(r({},o),((f={})[a]={event_type:i},f)),h)),[4,u.store.put({sessionId:n,eventTypes:l})];case 2:return s.sent(),[2,l];case 3:return d=s.sent(),c.warn("Failed to store events for targeting ".concat(n,": ").concat(d)),[3,4];case 4:return[2,void 0]}}))}))},this.deleteOldSessionEventTypes=function(t){var n=t.currentSessionId,r=t.loggerProvider,i=t.tx;return o(e,void 0,void 0,(function(){var e,t,o,a,c;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),[4,i.store.getAll()];case 1:e=s.sent(),t=0,s.label=2;case 2:return t<e.length?(o=e[t],a=Date.now()-o.sessionId,o.sessionId!==n&&a>1728e5?[4,i.store.delete(o.sessionId)]:[3,4]):[3,5];case 3:s.sent(),s.label=4;case 4:return t++,[3,2];case 5:return[3,7];case 6:return c=s.sent(),r.warn("Failed to clear old session events for targeting: ".concat(c)),[3,7];case 7:return[2]}}))}))},this.storeEventTypeForSession=function(t){var n=t.loggerProvider,r=t.sessionId,i=t.eventType,a=t.eventTime,c=t.apiKey;return o(e,void 0,void 0,(function(){var e,t,o,u;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,this.openOrCreateDB(c)];case 1:return e=s.sent(),(t=e.transaction("eventTypesForSession","readwrite"))?[4,this.updateEventListForSession({sessionId:r,tx:t,loggerProvider:n,eventType:i,eventTime:a})]:[2];case 2:return o=s.sent(),[4,this.deleteOldSessionEventTypes({currentSessionId:r,tx:t,loggerProvider:n})];case 3:return s.sent(),[4,t.done];case 4:return s.sent(),[2,o];case 5:return u=s.sent(),n.warn("Failed to store events for targeting ".concat(r,": ").concat(u)),[3,6];case 6:return[2,void 0]}}))}))}},Go=new Vo,$o=function(){var e=this;this.evaluateTargeting=function(t){var n=t.apiKey,r=t.loggerProvider,i=t.event,a=t.sessionId,c=t.userProperties,u=t.deviceId,l=t.flag;return o(e,void 0,void 0,(function(){var e,t,o,d;return s(this,(function(s){switch(s.label){case 0:return i&&i.time?[4,Go.storeEventTypeForSession({loggerProvider:r,apiKey:n,sessionId:a,eventType:i.event_type,eventTime:i.time})]:[3,2];case 1:return t=s.sent(),[3,3];case 2:t=void 0,s.label=3;case 3:return o=(e=t)&&new Set(Object.keys(e)),d={session_id:a,event:i,event_types:o&&Array.from(o),user:{device_id:u,user_properties:c}},[2,this.evaluationEngine.evaluate(d,[l])]}}))}))},this.evaluationEngine=new Ko},Ho=function(){var e=new $o;return{evaluateTargeting:e.evaluateTargeting.bind(e)}}().evaluateTargeting,Xo=function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Jn(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 o(e,void 0,void 0,(function(){var e,n;return s(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 o(e,void 0,void 0,(function(){var e,t;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return[4,o.sent().get("sessionTargetingMatch",i)];case 2:return[2,null==(e=o.sent())?void 0:e.targetingMatch];case 3:return t=o.sent(),n.warn("Failed to get targeting match for session id ".concat(i,": ").concat(t)),[3,4];case 4:return[2,void 0]}}))}))},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,a=t.targetingMatch;return o(e,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return[4,t.sent().put("sessionTargetingMatch",{targetingMatch:a,sessionId:i})];case 2:return[2,t.sent()];case 3:return e=t.sent(),n.warn("Failed to store targeting match for session id ".concat(i,": ").concat(e)),[3,4];case 4:return[2,void 0]}}))}))},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return o(e,void 0,void 0,(function(){var e,t,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=s.sent(),[4,(t=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:o=s.sent(),a=0,s.label=3;case 3:return a<o.length?(c=o[a],u=Date.now()-c.sessionId,c.sessionId!==i&&u>1728e5?[4,t.store.delete(c.sessionId)]:[3,5]):[3,6];case 4:s.sent(),s.label=5;case 5:return a++,[3,3];case 6:return[4,t.done];case 7:return s.sent(),[3,9];case 8:return l=s.sent(),n.warn("Failed to clear old targeting matches for sessions: ".concat(l)),[3,9];case 9:return[2]}}))}))}},Jo=new Xo,Yo=function(e){var t=e.sessionId,n=e.targetingConfig,i=e.loggerProvider,a=e.apiKey,c=e.targetingParams;return o(void 0,void 0,void 0,(function(){var e,o,u,l;return s(this,(function(s){switch(s.label){case 0:return[4,Jo.clearStoreOfOldSessions({loggerProvider:i,apiKey:a,currentSessionId:t})];case 1:return s.sent(),[4,Jo.getTargetingMatchForSession({loggerProvider:i,apiKey:a,sessionId:t})];case 2:if(!0===s.sent())return[2,!0];e=!0,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,Ho(r(r({},c),{flag:n,sessionId:t,apiKey:a,loggerProvider:i}))];case 4:return(o=s.sent())&&o.sr_targeting_config&&(e="on"===o.sr_targeting_config.key),Jo.storeTargetingMatchForSession({loggerProvider:i,apiKey:a,sessionId:t,targetingMatch:e}),[3,6];case 5:return u=s.sent(),l=u,i.warn(l.message),[3,6];case 6:return[2,e]}}))}))},Zo=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.teardownEventListeners=function(t){var n=E();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(){e.stopRecordingEvents(),e.captureEvents()},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach((function(e){e(t)}))},this.evaluateTargetingAndCapture=function(t){return o(e,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return this.identifiers&&this.identifiers.sessionId&&this.config?!this.config.targetingConfig||this.sessionTargetingMatch?[3,2]:((e=null==t?void 0:t.event)&&Object.values(g).includes(e.event_type)&&(e=void 0),n=this,[4,Yo({sessionId:this.identifiers.sessionId,targetingConfig:this.config.targetingConfig,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:null==t?void 0:t.userProperties,event:e}})]):(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]);case 1:n.sessionTargetingMatch=r.sent(),r.label=2;case 2:return this.captureEvents(),[2]}}))}))},this.addCustomRRWebEvent=function(t,n,i){return void 0===n&&(n={}),void 0===i&&(i=!0),o(e,void 0,void 0,(function(){var e,o,a;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),e=void 0,this.config?(e={config:wr(this.config),version:jr},i?[4,Ir()]:[3,2]):[3,2];case 1:o=s.sent(),e=r(r({},o),e),s.label=2;case 2:return this.recordCancelCallback?Zt.addCustomEvent(t,r(r({},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=s.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",a),[3,4];case 4:return[2]}}))}))},this.stopRecordingEvents=function(){try{e.recordCancelCallback&&e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null}catch(n){var t=n;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new R}return e.prototype.init=function(e,t){return O(this._init(e,t))},e.prototype._init=function(e,t){var n,r,i;return o(this,void 0,void 0,(function(){var o,u,l,d,h,f;return s(this,(function(s){switch(s.label){case 0:return this.loggerProvider=t.loggerProvider||new R,Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.identifiers=new co({sessionId:t.sessionId,deviceId:t.deviceId}),o=this,[4,Er(e,t)];case 1:return o.joinedConfigGenerator=s.sent(),u=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return u.config=s.sent(),t.sessionId&&(null===(n=this.config.interactionConfig)||void 0===n?void 0:n.enabled)&&(l=ao.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[l.send(this.getDeviceId.bind(this))],this.scrollHook=l.hook.bind(l)),d=[],[4,Br({config:this.config,sessionId:this.identifiers.sessionId,type:"replay"})];case 3:return h=s.sent(),d.push({name:"replay",manager:h}),(null===(r=this.config.interactionConfig)||void 0===r?void 0:r.enabled)?[4,Br({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(i=this.config.interactionConfig.trackEveryNms)&&void 0!==i?i:3e4,maxInterval:6e4,payloadBatcher:no})]:[3,5];case 4:f=s.sent(),d.push({name:"interaction",manager:f}),s.label=5;case 5:return this.eventsManager=new(qr.bind.apply(qr,c([void 0],a(d),!1))),this.identifiers.deviceId&&this.eventsManager.sendStoredEvents({deviceId:this.identifiers.deviceId}),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),this.stopRecordingEvents(),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties})];case 6:return s.sent(),[2]}}))}))},e.prototype.setSessionId=function(e,t,n){return O(this.asyncSetSessionId(e,t,n))},e.prototype.asyncSetSessionId=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,i;return s(this,(function(s){switch(s.label){case 0:return this.stopRecordingEvents(),this.sessionTargetingMatch=!1,(r=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(r),o=t||this.getDeviceId(),this.identifiers=new co({sessionId:e,deviceId:o}),this.joinedConfigGenerator&&r?(i=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:i.config=s.sent(),s.label=2;case 2:return[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties})];case 3:return s.sent(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=Sr(this.config.apiKey).toString()),JSON.stringify({appHash:e})},e.prototype.getSessionReplayProperties=function(){var e;if(!this.config||!this.identifiers)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var t=this.getShouldCapture(),n={};return t&&((e={})[B]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,n=e,this.config.debugMode&&(n[W]=this.getSessionReplayDebugPropertyValue())),this.addCustomRRWebEvent(M.GET_SR_PROPS,{shouldRecord:t,eventProperties:n},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,n},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.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=C(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldCapture=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being captured 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 replay capture due to optOut config.")),!1;if(this.config.targetingConfig){if(!this.sessionTargetingMatch)return this.loggerProvider.log("Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions.")),!1;this.loggerProvider.log("Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."))}else{if(!(e=this.identifiers.sessionId,t=this.config.sampleRate,n=Sr(e.toString()),31*Math.abs(n)%1e6/1e6<t))return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of replay capture due to sample rate.")),!1;this.loggerProvider.log("Capturing replays for session ".concat(this.identifiers.sessionId," due to inclusion in sample rate."))}var e,t,n;return!0},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,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.captureEvents=function(){var e=this;if(this.recordCancelCallback)this.loggerProvider.debug("captureEvents method fired - Session Replay capture already in progress.");else{var t=this.getShouldCapture(),n=this.identifiers&&this.identifiers.sessionId;if(t&&n&&this.config){var r=this.config.privacyConfig;this.loggerProvider.log("Session Replay capture beginning."),this.recordCancelCallback=Zt({emit:function(t){if(e.shouldOptOut())return e.loggerProvider.log("Opting session ".concat(n," out of replay capture due to optOut config.")),e.stopRecordingEvents(),void e.sendEvents();var r=JSON.stringify(t),o=e.getDeviceId();e.eventsManager&&o&&e.eventsManager.addEvent({event:{type:"replay",data:r},sessionId:n,deviceId:o})},packFn:Pn,inlineStylesheet:this.config.shouldInlineStylesheet,hooks:{mouseInteraction:this.eventsManager&&ro({eventsManager:this.eventsManager,sessionId:n,deviceIdFn:this.getDeviceId.bind(this)}),scroll:this.scrollHook},maskAllInputs:!0,maskTextClass:z,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:yr("input",r),maskTextFn:yr("text",r),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(t){var n=t;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))throw n;if(n._external_)throw n;return e.loggerProvider.warn("Error while capturing replay: ",n.toString()),!0}}),this.addCustomRRWebEvent(M.DEBUG_INFO)}}},e.prototype.getDeviceId=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=C(this.config.instanceName).identityStore.getIdentity().deviceId);return n||(null===(t=this.identifiers)||void 0===t?void 0:t.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),o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e}(),Qo=function(e){return function(){var t=e.config||V();return{logger:t.loggerProvider,logLevel:t.logLevel}}},es=function(){var e=new Zo;return{init:A(e.init.bind(e),"init",Qo(e)),evaluateTargetingAndCapture:A(e.evaluateTargetingAndCapture.bind(e),"evaluateTargetingAndRecord",Qo(e)),setSessionId:A(e.setSessionId.bind(e),"setSessionId",Qo(e)),getSessionId:e.getSessionId.bind(e),getSessionReplayProperties:A(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",Qo(e)),flush:A(e.flush.bind(e),"flush",Qo(e)),shutdown:A(e.shutdown.bind(e),"shutdown",Qo(e))}}(),ts=es.init,ns=es.setSessionId,rs=es.getSessionId,os=es.evaluateTargetingAndCapture,ss=es.getSessionReplayProperties;es.flush;var is=es.shutdown,as=[p.SET,p.SET_ONCE,p.ADD,p.APPEND,p.PREPEND,p.POSTINSERT,p.POSTINSERT],cs="1.7.0-srtargeting.1",us=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.options=r({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e){var t,n,i,a;return o(this,void 0,void 0,(function(){var o,c;return s(this,(function(s){switch(s.label){case 0:return e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(cs,".")),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})),o=C(this.config.instanceName).identityStore,c=o.getIdentity().userProperties,[4,ts(e.apiKey,{instanceName:this.config.instanceName,deviceId:this.config.deviceId,optOut:this.config.optOut,sessionId:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(t=this.options.privacyConfig)||void 0===t?void 0:t.blockSelector,maskSelector:null===(n=this.options.privacyConfig)||void 0===n?void 0:n.maskSelector,unmaskSelector:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.unmaskSelector,defaultMaskLevel:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:cs},userProperties:c}).promise];case 1:return s.sent(),[2]}}))}))},e.prototype.execute=function(e){return o(this,void 0,void 0,(function(){var t,n,o;return s(this,(function(s){switch(s.label){case 0:return this.config.sessionId&&this.config.sessionId!==rs()?(t=C(this.config.instanceName).identityStore,n=t.getIdentity().userProperties,[4,ns(this.config.sessionId,this.config.deviceId,{userProperties:n||{}}).promise]):[3,2];case 1:s.sent(),s.label=2;case 2:return this.config.sessionId&&this.config.sessionId===e.session_id?(n=void 0,e.event_type===g.IDENTIFY&&(n=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach((function(n){if(as.includes(n)){var o=e.user_properties&&e.user_properties[n];t=r(r({},t),o)}})),t}}(e)),[4,os({event:e,userProperties:n})]):[3,4];case 3:s.sent(),o=ss(),e.event_properties=r(r({},e.event_properties),o),s.label=4;case 4:return[2,Promise.resolve(e)]}}))}))},e.prototype.teardown=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return is(),this.config=null,[2]}))}))},e.prototype.getSessionReplayProperties=function(){return ss()},e}(),ls=function(e){return new us(e)};return e.plugin=ls,e.sessionReplayPlugin=ls,Object.defineProperty(e,"__esModule",{value:!0}),e}({});