PageSourceSearch

https://1wqdhu.life/resources/v1/app/assets/index-wsODwus-.js

js 1wqdhu.life collected 2026-10-10 02:40:01 UTC 113,202 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DZLcKekT.js","assets/logger-B4OCWT-4.js","assets/setup-amplitude-NPqSl3xq.js","assets/observers-B1krqqfk.js"])))=>i.map(i=>d[i]);
2import{z as w,H as P,_ as T,X as F,G as ot,P as V,J as B,M as Oe,Y as me}from"./logger-B4OCWT-4.js";import{U as vr,h as G,F as hr,b as He,L as gr,C as pr,B as mr,c as ge,S as yr,r as ht,i as Sr,e as br,A as Ir,g as Er,d as ue}from"./setup-amplitude-NPqSl3xq.js";var gt=function(r){var e=0;if(r.length===0)return e;for(var t=0;t<r.length;t++){var n=r.charCodeAt(t);e=(e<<5)-e+n,e|=0}return e},Cr=(function(){function r(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return r.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(i){return this.logger.debug("Remote config localstorage failed to access: ",i),Promise.resolve(t)}if(e===null)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(i){return this.logger.debug("Remote config localstorage failed to parse: ",i),localStorage.removeItem(this.key),Promise.resolve(t)}},r.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(t){this.logger.debug("Remote config localstorage failed to set: ",t)}return Promise.resolve(!1)},r})(),Pr="https://sr-client-cfg.amplitude.com/config",wr="https://sr-client-cfg.eu.amplitude.com/config",Tr=3,De={INVALID_API_KEY:401,FORBIDDEN:403,RATE_LIMIT:429},Mr=1e3,Rr=300*1e3,kr=(function(){function r(e,t,n,i){n===void 0&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=i||(n==="US"?Pr:wr),this.logger=t,this.storage=new Cr(e,t)}return r.prototype.subscribe=function(e,t,n){var i=vr(),s={id:i,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(s),t==="all"?this.subscribeAll(s):this.subscribeWaitForRemote(s,t.timeout),i},r.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(n){return n.id===e});return t===-1?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},r.prototype.updateConfigs=function(){return w(this,void 0,void 0,function(){var e,t,n=this;return P(this,function(i){switch(i.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<Rr)?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return t=i.sent(),this.storage.setConfig(t),this.callbackInfos.forEach(function(s){n.sendCallback(s,t,"remote")}),[2]}})})},r.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?this.fetchPromise:this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null}),this.fetchPromise):(this.fetchPromise=this.fetch().then(function(t){return t.remoteConfig!==null&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},r.prototype.subscribeAll=function(e){return w(this,void 0,void 0,function(){var t,n,i,s=this;return P(this,function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then(function(l){s.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(l))),s.sendCallback(e,l,"remote"),s.storage.setConfig(l)}),n=this.storage.fetchConfig().then(function(l){return l}),[4,Promise.race([t,n])];case 1:return i=o.sent(),i!==void 0&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(i))),i.remoteConfig!==null?this.sendCallback(e,i,"cache"):this.logger.debug("Remote config client skips sending c
2allback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},r.prototype.subscribeWaitForRemote=function(e,t){return w(this,void 0,void 0,function(){var n,i,i;return P(this,function(s){switch(s.label){case 0:n=new Promise(function(o,l){setTimeout(function(){l("Timeout exceeded")},t)}),s.label=1;case 1:return s.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return i=s.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,i,"remote"),this.storage.setConfig(i),[3,5];case 3:return s.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return i=s.sent(),i.remoteConfig!==null?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,i,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,i,"remote")),[3,5];case 5:return[2]}})})},r.prototype.sendCallback=function(e,t,n){e.lastCallback=new Date;var i;e.key?i=e.key.split(".").reduce(function(s,o){return s===null?s:o in s?s[o]:null},t.remoteConfig):i=t.remoteConfig,e.callback(i,n,t.lastFetch)},r.prototype.fetch=function(e,t){return e===void 0&&(e=Tr),t===void 0&&(t=Mr),w(this,void 0,void 0,function(){var n,i,s,o,l,a,u=this;return P(this,function(f){switch(f.label){case 0:n=t/e,i={remoteConfig:null,lastFetch:new Date},s=function(c){var d,v,h,g,m,p,y;return P(this,function(S){switch(S.label){case 0:d=!0,v=new AbortController,h=setTimeout(function(){return v.abort()},t),S.label=1;case 1:return S.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:v.signal})];case 2:return g=S.sent(),g.ok?[3,4]:[4,g.text()];case 3:return m=S.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(g.status,": ").concat(m)),g.status===De.INVALID_API_KEY||g.status===De.FORBIDDEN?(o.logger.error("Remote config client fetch failed with ".concat(g.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,d=!1):g.status>=400&&g.status<500&&g.status!==De.RATE_LIMIT&&(d=!1),[3,6];case 4:return[4,g.json()];case 5:return p=S.sent(),[2,{value:{remoteConfig:p,lastFetch:new Date}}];case 6:return[3,9];case 7:return y=S.sent(),y instanceof Error&&y.name==="AbortError"?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),y),[3,9];case 8:return clearTimeout(h),[7];case 9:return d?c<e-1?[4,new Promise(function(b){return setTimeout(b,u.getJitterDelay(n))})]:[3,11]:[2,"break"];case 10:S.sent(),S.label=11;case 11:return[2]}})},o=this,l=0,f.label=1;case 1:return l<e?[5,s(l)]:[3,4];case 2:if(a=f.sent(),typeof a=="object")return[2,a.value];if(a==="break")return[3,4];f.label=3;case 3:return l++,[3,1];case 4:return[2,i]}})})},r.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},r.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),t=new URLSearchParams;return t.append("config_group",r.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(e,"?").concat(t.toString())},r.CONFIG_GROUP="browser",r})(),Xe;(function(r){r.US="US",r.EU="EU",r.STAGING="STAGING"})(Xe||(Xe={}));var qt="[Amplitude]",_r="".concat(qt," Session Replay ID"),Lr=0,xr=Xe.US,Or={enabled:!0},at=1e3,Dr="".concat(qt," Session Replay Debug"),Fr="amp-block",Bt="amp-mask",Wt="amp-unmask",Kt="https://api-sr.amplitude.com/sessions/v2/track",jt="https://api-sr.eu.amplitude.com/sessions/v2/track",zt="https://api-sr.stag2.amplitude.com/sessions/v2/track",Gt=7e5,Qe=9*1e6,Ar=/payload.*exceed/i,Nr=3e4,Ur=6e4,Je=500,Ye=10*1e3,Ze=1024,qr=1e3,Br=64*1024,Wr="X-Session-Replay-Event-Skipped",Kr="429",jr="4004",zr="4005",pt=6e4,Gr=2*Gt,Ce="amplitude-sr-iframe",se;(function(r){r.GET_SR_PROPS="get-sr-props",r.DEBUG_INFO="debug-info",r.FETCH_REQUEST="fetch-request",r.METADATA="metadata",r.TARGETING_DECISION="targeting-decision",r.REPLAY_GATE_DECISION="replay-gate-decision"})(se||(se={}));var $e=(function(){function r(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return r.prototype.getSafeMethod=function(e){var t;if(!this.logger)return(function(){});var n=this.logger[e];
2if(typeof n=="function"){var i=(t=n.__rrweb_original__)!==null&&t!==void 0?t:n;return i.bind(this.logger)}return(function(){})},r.prototype.enable=function(e){this.logger.enable(e)},r.prototype.disable=function(){this.logger.disable()},r})(),lt="medium";function Vr(r){return r.toLowerCase()}function Hr(r){var e=r.type;return r.hasAttribute("data-rr-is-password")?"password":e?Vr(e):null}function Te(r,e){return e||(r==="STAGING"?zt:r==="EU"?jt:Kt)}var Vt=function(r,e,t){switch(e){case"light":{if(r!=="input")return!1;var n=t?Hr(t):"";return n?!!(["password","hidden","email","tel"].includes(n)||t.autocomplete.startsWith("cc-")):!1}case"medium":return r==="input";case"conservative":return!0;default:return Vt(r,lt,t)}},Ht=function(r,e){var t,n,i;if(r&&e.urlMaskLevels)try{for(var s=F(e.urlMaskLevels),o=s.next();!o.done;o=s.next()){var l=o.value;if(Qt(l.match).test(r))return l.maskLevel}}catch(a){t={error:a}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return(i=e.defaultMaskLevel)!==null&&i!==void 0?i:lt},Xt=function(r,e,t,n){var i,s;if(e===void 0&&(e={defaultMaskLevel:lt}),t){if(t.closest("."+Bt))return!0;var o=((i=e.maskSelector)!==null&&i!==void 0?i:[]).some(function(a){return t.closest(a)});if(o)return!0;if(t.closest("."+Wt))return!1;var l=((s=e.unmaskSelector)!==null&&s!==void 0?s:[]).some(function(a){return t.closest(a)});if(l)return!1}return Vt(r,Ht(n,e),t)},mt=function(r,e,t){return function(n,i){return Xt(r,e,i,t?.())?n.replace(/[^\s]/g,"*"):n}},Xr=function(r,e){return function(t,n,i){var s;if(t==="style"||!((s=r?.maskAttributes)!==null&&s!==void 0?s:[]).includes(t))return n;var o=["INPUT","SELECT","TEXTAREA"].includes(i.tagName)?"input":"text";return Xt(o,r,i,e?.())?n.replace(/[^\s]/g,"*"):n}},et=function(){var r=G();return r?.location?r.location.href:""},Qr=function(r,e){return"".concat(e,"/").concat(r)},Jr=function(r){if(typeof r!="string"||r.trim()==="")return!1;var e=/^\/|^https?:\/\/[^\s]+$/;return!!e.test(r)},yt=new Map,Qt=function(r){var e=yt.get(r);if(e)return e;var t="\0TRAIL\0",n="\0MID\0",i="\0DS\0",s="\0ST\0",o="\0QU\0",l=r;l=l.replace(/\/\*\*$/,t),l=l.replace(/\/\*\*\//g,n),l=l.replace(/\*\*/g,i),l=l.replace(/\*/g,s),l=l.replace(/\?/g,o),l=l.replace(/[.+^${}()|[\]\\]/g,"\\$&"),l=l.split(t).join("(/.*)?"),l=l.split(n).join("/(.*\\/)?"),l=l.split(i).join(".*"),l=l.split(s).join(".*"),l=l.split(o).join(".");var a=new RegExp("^".concat(l,"$"));return yt.set(r,a),a},Yr=function(r){if(!r.every(function(e){return typeof e.selector=="string"&&typeof e.replacement=="string"}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!r.every(function(e){return Jr(e.selector)}))throw new Error("ugcFilterRules must be an array of objects with valid globs")},Re=function(r,e){var t,n;try{for(var i=F(e),s=i.next();!s.done;s=i.next()){var o=s.value,l=Qt(o.selector);if(l.test(r))return r.replace(l,o.replacement)}}catch(a){t={error:a}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},Jt=function(){return w(void 0,void 0,void 0,function(){var r,e,t,n,i,s,o;return P(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),r=G(),r?[4,r.navigator.storage.estimate()]:[3,2];case 1:return e=l.sent(),t=e.usage,n=e.quota,i=e.usageDetails,s=t?Math.round(t/Ze):0,o=t&&n?Math.round((t/n+Number.EPSILON)*1e3)/1e3:0,[2,{totalStorageSize:s,percentOfQuota:o,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return l.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},Yt=function(r){var e=T({},r),t=e.apiKey;return e.apiKey="****".concat(t.substring(t.length-4)),e},Zt=function(){return{flushMaxRetries:2,logLevel:gr.Warn,loggerProvider:new He,transportProvider:new hr}},Zr=(function(r){ot(e,r);function e(t,n){var i=this,s,o,l,a,u,f,c,d,v,h,g=Zt();if(i=r.call(this,T(T({transportProvider:g.transportProvider,loggerProvider:new $e(n.loggerProvider||g.loggerProvider)},n),{apiKey:t}))||this,i.flushMaxRetries=n.flushMaxRetries!==void 0&&n.flushMaxRetries<=g.flushMaxRetries?n.flushMaxRetries:g.flushMaxRetries,i.apiKey=t,i.sampleRate=n.sampleRate||Lr,i.serverZone=n.serverZone||xr,i.configServerUrl=n.configServerUrl,i.trackServerUrl=n.trackServerUrl,i.shouldInlineStylesheet=n.shouldInlineStylesheet,i.version=n.version,i.performanceConfig=n.performanceConfig||Or,i.storeType=(s=n.storeType)!==null&&s!==void 0?s:"memory",i.applyBackgroun
2dColorToBlockedElements=(o=n.applyBackgroundColorToBlockedElements)!==null&&o!==void 0?o:!1,i.enableUrlChangePolling=(l=n.enableUrlChangePolling)!==null&&l!==void 0?l:!1,i.urlChangePollingInterval=(a=n.urlChangePollingInterval)!==null&&a!==void 0?a:at,i.captureDocumentTitle=(u=n.captureDocumentTitle)!==null&&u!==void 0?u:!1,n.fullSnapshotIntervalMs!==void 0&&(i.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),i.privacyConfig=T(T({},(f=n.privacyConfig)!==null&&f!==void 0?f:{}),{unmaskSelector:Array.from(new Set(V([".".concat(Wt)],B((d=(c=n.privacyConfig)===null||c===void 0?void 0:c.unmaskSelector)!==null&&d!==void 0?d:[]),!1)))}),n.interactionConfig&&(i.interactionConfig=n.interactionConfig,i.interactionConfig.ugcFilterRules&&Yr(i.interactionConfig.ugcFilterRules)),n.debugMode&&(i.debugMode=n.debugMode),n.useWebWorker!==void 0)i.useWebWorker=n.useWebWorker;else{var m=n;((v=m.experimental)===null||v===void 0?void 0:v.useWebWorker)!==void 0&&(i.useWebWorker=m.experimental.useWebWorker)}return i.captureAdoptedStyleSheets=(h=n.captureAdoptedStyleSheets)!==null&&h!==void 0?h:!0,n.crossOriginIframes&&(i.crossOriginIframes=n.crossOriginIframes),n.flushIntervalConfig&&(i.flushIntervalConfig=$r(n.flushIntervalConfig,i.loggerProvider)),i}return e})(pr),ve=100;function $r(r,e){var t,n,i={};if(r.minIntervalMs!==void 0&&(!Number.isFinite(r.minIntervalMs)||r.minIntervalMs<ve?(e.warn("flushIntervalConfig.minIntervalMs ".concat(r.minIntervalMs," is below floor ").concat(ve,"ms; clamping.")),i.minIntervalMs=ve):i.minIntervalMs=r.minIntervalMs),r.maxIntervalMs!==void 0&&(Number.isNaN(r.maxIntervalMs)||r.maxIntervalMs<ve?(e.warn("flushIntervalConfig.maxIntervalMs ".concat(r.maxIntervalMs," is below floor ").concat(ve,"ms; clamping.")),i.maxIntervalMs=ve):i.maxIntervalMs=r.maxIntervalMs),i.minIntervalMs!==void 0||i.maxIntervalMs!==void 0){var s=(t=i.minIntervalMs)!==null&&t!==void 0?t:Je,o=(n=i.maxIntervalMs)!==null&&n!==void 0?n:Ye;o<s&&(i.maxIntervalMs===void 0?(e.warn("flushIntervalConfig.minIntervalMs (".concat(s,") exceeds the default maxIntervalMs (").concat(Ye,"); raising max to match min.")),i.maxIntervalMs=s):i.minIntervalMs===void 0?(e.warn("flushIntervalConfig.maxIntervalMs (".concat(o,") is below the default minIntervalMs (").concat(Je,"); lowering min to match max.")),i.minIntervalMs=o):(e.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}var ke=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(ke||{}),ut=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r[r.CustomElement=16]="CustomElement",r))(ut||{}),$t=(r=>(r[r.MouseUp=0]="MouseUp",r[r.MouseDown=1]="MouseDown",r[r.Click=2]="Click",r[r.ContextMenu=3]="ContextMenu",r[r.DblClick=4]="DblClick",r[r.Focus=5]="Focus",r[r.Blur=6]="Blur",r[r.TouchStart=7]="TouchStart",r[r.TouchMove_Departed=8]="TouchMove_Departed",r[r.TouchEnd=9]="TouchEnd",r[r.TouchCancel=10]="TouchCancel",r))($t||{}),en=1500,tn=function(r,e){var t=document.createDocumentFragment(),n=function(i){if(i===void 0&&(i=[]),typeof i=="string"&&(i=[i]),i=i.filter(function(s){try{t.querySelector(s)}catch{return e.warn('[session-replay-browser] omitting selector "'.concat(s,'" because it is invalid')),!1}return!0}),i.length!==0)return i};return r.blockSelector=n(r.blockSelector),r.maskSelector=n(r.maskSelector),r.unmaskSelector=n(r.unmaskSelector),r},rn=(function(){function r(e,t){this.localConfig=t,this.remoteConfigClient=e}return r.prototype.generateJoinedConfig=function(){var e,t,n,i,s,o,l;return w(this,void 0,void 0,function(){var a,u,f,c,d,v,h,g,m,p,y,S,b,M,D,x,q,O=this;return P(this,function(A){switch(A.label){case 0:a=T({},this.localConfig),a.optOut=this.localConfig.optOut,a.captureEnabled=!0,A.label=1;case 1:return A.trys.push([1,3,,4]),[4,new Promise(function(_,E){O.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:en},function(I,k){var L;if(O.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(k,":"),JSON.stringify(I,null,2)),!I){E(new Error("No remote config received"));return}var R=I,W=R.sr_sampling_config,N=R.sr_privacy_config,U=R.sr_targeting_config,C=(L=a.interactionConfig)===null||L===void 0?void 0:L.ugcFilterRules;a.interactionConfig=R.sr_interaction_config,a.interactionConfig&&C&&(a.interactionConfig.ugcFilterRules=C),a.loggingConfig=R.sr_logging_config,(W||N||U)&&(u={},W&&(u.sr_sampling_config=W),N&&(u.sr_privacy_config=N),U&&(u.sr_targeting_config=U)),_()})})];
2case 2:return A.sent(),[3,4];case 3:return f=A.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",f),a.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:void 0}];case 4:if(!u)return[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:u}];if(c=u.sr_sampling_config,d=u.sr_privacy_config,v=u.sr_targeting_config,c&&Object.keys(c).length>0?(Object.prototype.hasOwnProperty.call(c,"capture_enabled")?a.captureEnabled=c.capture_enabled:a.captureEnabled=!1,Object.prototype.hasOwnProperty.call(c,"sample_rate")&&(a.sampleRate=c.sample_rate),Object.prototype.hasOwnProperty.call(c,"min_session_duration_ms")&&(a.minSessionDurationMs=this.sanitizeMinSessionDurationMs(c.min_session_duration_ms))):(a.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){h=(e=a.privacyConfig)!==null&&e!==void 0?e:{},g={defaultMaskLevel:(n=(t=d.defaultMaskLevel)!==null&&t!==void 0?t:h.defaultMaskLevel)!==null&&n!==void 0?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:V([],B(new Set(V(V([],B((i=h.maskAttributes)!==null&&i!==void 0?i:[]),!1),B((s=d.maskAttributes)!==null&&s!==void 0?s:[]),!1))),!1),urlMaskLevels:V(V([],B((o=d.urlMaskLevels)!==null&&o!==void 0?o:[]),!1),B((l=h.urlMaskLevels)!==null&&l!==void 0?l:[]),!1)},m=function(_){var E,I,k,L,R,W,N,U,C,z={};typeof _.blockSelector=="string"&&(_.blockSelector=[_.blockSelector]);try{for(var X=F((N=_.blockSelector)!==null&&N!==void 0?N:[]),K=X.next();!K.done;K=X.next()){var j=K.value;z[j]="block"}}catch(ee){E={error:ee}}finally{try{K&&!K.done&&(I=X.return)&&I.call(X)}finally{if(E)throw E.error}}try{for(var J=F((U=_.maskSelector)!==null&&U!==void 0?U:[]),H=J.next();!H.done;H=J.next()){var j=H.value;z[j]="mask"}}catch(ee){k={error:ee}}finally{try{H&&!H.done&&(L=J.return)&&L.call(J)}finally{if(k)throw k.error}}try{for(var $=F((C=_.unmaskSelector)!==null&&C!==void 0?C:[]),Y=$.next();!Y.done;Y=$.next()){var j=Y.value;z[j]="unmask"}}catch(ee){R={error:ee}}finally{try{Y&&!Y.done&&(W=$.return)&&W.call($)}finally{if(R)throw R.error}}return z},p=T(T({},m(h)),m(d));try{for(y=F(Object.entries(p)),S=y.next();!S.done;S=y.next())b=B(S.value,2),M=b[0],D=b[1],D==="mask"?g.maskSelector.push(M):D==="block"?g.blockSelector.push(M):D==="unmask"&&g.unmaskSelector.push(M)}catch(_){x={error:_}}finally{try{S&&!S.done&&(q=y.return)&&q.call(y)}finally{if(x)throw x.error}}a.privacyConfig=tn(g,this.localConfig.loggerProvider)}return v&&Object.keys(v).length>0&&(a.targetingConfig=v),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:Yt(a)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:u}]}})})},r.prototype.sanitizeMinSessionDurationMs=function(e){if(typeof e!="number"||!Number.isFinite(e)){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."));return}if(e<0){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring."));return}return e>Fe?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(Fe,"ms ceiling; clamping.")),Fe):e},r})(),Fe=6e4,nn=function(r,e){return w(void 0,void 0,void 0,function(){var t,n;return P(this,function(i){return t=new Zr(r,e),n=new kr(r,t.loggerProvider,t.serverZone,e.configServerUrl),[2,new rn(n,t)]})})};function St(r){if(r.type!==ke.IncrementalSnapshot)return!1;var e=r.data;return e.source===ut.Mutation&&!e.isAttachIframe}function sn(r){var e,t,n,i,s=r[0],o=new Map,l=new Map,a=new Map,u=new Map,f=new Map;r.forEach(function(C,z){var X,K,j,J,H=C.data;try{for(var $=F(H.adds),Y=$.next();!Y.done;Y=$.next()){var ee=Y.value;o.has(ee.node.id)||o.set(ee.node.id,z),l.set(ee.node.id,z),f.set(ee.node.id,ee.parentId)}}catch(Q){X={error:Q}}finally{try{Y&&!Y.done&&(K=$.return)&&K.call($)}finally{if(X)throw X.error}}try{for(var ae=F(H.removes),le=ae.next();!le.done;le=ae.next()){var te=le.value;a.has(te.id)||a.set(te.id,z),u.set(te.id,z)}}catch(Q){j={error:Q}}finally{try{le&&!le.done&&(J=ae.return)&&J.call(ae)}finally{if(j)throw j.error}}});var c=new Set,d=new Set;try{for(var v=F(o),h=v.next();!h.done;h=v.next()){var g=B(h.value,2),m=g[0],p=g[1],y=a.get(m);
2if(y!==void 0){var S=l.get(m),b=u.get(m);S>=b||(p<y?c.add(m):y<p&&d.add(m))}}}catch(C){e={error:C}}finally{try{h&&!h.done&&(t=v.return)&&t.call(v)}finally{if(e)throw e.error}}var M=new Set;if(c.size>0||d.size>0)for(var D=!0;D;){D=!1;try{for(var x=(n=void 0,F(f)),q=x.next();!q.done;q=x.next()){var O=B(q.value,2),A=O[0],_=O[1];if(!c.has(A)&&!d.has(A)&&!M.has(A)&&(c.has(_)||d.has(_)||M.has(_))){var E=a.get(A),I=o.get(A);E!==void 0&&I!==void 0&&E<I?d.add(A):E!==void 0&&I!==void 0&&E===I?M.add(A):c.add(A),D=!0}}}catch(C){n={error:C}}finally{try{q&&!q.done&&(i=x.return)&&i.call(x)}finally{if(n)throw n.error}}}var k=c.size>0||d.size>0||M.size>0,L=[];r.forEach(function(C,z){var X,K;try{for(var j=F(C.data.removes),J=j.next();!J.done;J=j.next()){var H=J.value;c.has(H.id)||d.has(H.id)&&z>=o.get(H.id)||M.has(H.id)&&(c.has(H.parentId)||d.has(H.parentId)||M.has(H.parentId))||L.push(H)}}catch($){X={error:$}}finally{try{J&&!J.done&&(K=j.return)&&K.call(j)}finally{if(X)throw X.error}}});var R=r.flatMap(function(C){return C.data.adds}),W=r.flatMap(function(C){return C.data.texts}),N=r.flatMap(function(C){return C.data.attributes}),U={source:ut.Mutation,removes:L,adds:k?R.filter(function(C){return!c.has(C.node.id)&&!d.has(C.node.id)&&!M.has(C.node.id)}):R,texts:k?W.filter(function(C){return!c.has(C.id)&&!d.has(C.id)&&!M.has(C.id)}):W,attributes:k?N.filter(function(C){return!c.has(C.id)&&!d.has(C.id)&&!M.has(C.id)}):N};return T(T({},s),{data:U})}function on(r){if(r.length<=1)return r;for(var e=[],t=0;t<r.length;){if(!St(r[t])){e.push(r[t]),t++;continue}for(var n=t+1;n<r.length&&St(r[n]);)n++;e.push(n>t+1?sn(r.slice(t,n)):r[t]),t=n}return e}var an=2e3,ln=(function(){function r(e,t,n,i,s){var o=this,l;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(d){var v=d,h=v.type,g=v.timestamp,m=v.delay,p=v.data;return m!=null?JSON.stringify({type:h,timestamp:g,delay:m,data:p}):JSON.stringify({type:h,timestamp:g,data:p})},this.addCompressedEventToManager=function(d,v){var h=new Blob([d]).size;if(h>Qe){o.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(h/1024)," KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));return}o.eventsManager&&o.deviceId&&o.eventsManager.addEvent({event:{type:"replay",data:d},sessionId:v,deviceId:o.deviceId})},this.addCompressedEvent=function(d,v){if(o.worker)try{o.worker.postMessage({event:d,sessionId:v})}catch(g){g.name==="DataCloneError"?o.worker.postMessage(JSON.stringify({event:d,sessionId:v})):o.config.loggerProvider.warn("Unexpected error while posting message to worker:",g)}else{var h=o.compressEvent(d);o.addCompressedEventToManager(h,v)}},this.flushQueue=function(){var d;for(o.pendingQueue.length>0&&(d=o.taskQueue).push.apply(d,V([],B(o.mergeMutationTasks(o.pendingQueue.splice(0))),!1));o.taskQueue.length>0;){var v=o.taskQueue.shift();if(v){var h=v.event,g=v.sessionId,m=o.compressEvent(h);o.addCompressedEventToManager(m,g)}}o.isProcessing=!1},this.terminate=function(){var d;(d=o.worker)===null||d===void 0||d.terminate()};var a=G();if(this.canUseIdleCallback=a&&"requestIdleCallback"in a,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=((l=t.performanceConfig)===null||l===void 0?void 0:l.timeout)||an,this.onFullSnapshotProcessed=s,i){t.loggerProvider.log("Enabling web worker for compression");try{var u=new Blob([i],{type:"application/javascript"}),f=URL.createObjectURL(u),c=new Worker(f);c.onerror=function(d){d.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(d.message," (").concat(d.filename,":").concat(d.lineno,")")),c.terminate(),o.worker=void 0},c.onmessage=function(d){var v=d.data,h=v.compressedEvent,g=v.sessionId;o.addCompressedEventToManager(h,g)},this.worker=c}catch(d){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",d)}}}return r.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},r.prototype.enqueueEvent=function(e,t){var n,i,s,o;if(e.type===ke.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var l=V(V([],B(this.taskQueue.splice(0)),!1),B(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var a=F(l),u=a.next();!u.done;u=a.next()){var f=u.value,c=this.compressEvent(f.event);this.addCompressedEventToManager(c,f.sessionId)}}catch(v){n={error:v}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,t),(s=this.onFullSnapshotProcessed)===null||s===void 0||s.call(this);return}this.canUseIdleCallback&&(!((o=this.config.performanceConfig)===null||o===void 0)&&o.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},r.prototype.processQueue=function(e){var t,n=this;for(this.pendingQueue.length>0&&(t=this.taskQueue).push.apply(t,V([],B(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var i=this.taskQueue.shift();if(i){var s=i.event,o=i.sessionId;this.addCompressedEvent(s,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(l){n.processQueue(l)},{timeout:this.timeout}):this.isProcessing=!1},r.prototype.mergeMutationTasks=function(e){var t,n,i;if(!(!((i=this.config.performanceConfig)===null||i===void 0)&&i.mergeMutations)||e.length<=1)return e;for(var s=[],o=0;o<e.length;){for(var l=e[o].sessionId,a=o+1;a<e.length&&e[a].sessionId===l;)a++;var u=on(e.slice(o,a).map(function(v){return v.event}));try{for(var f=(t=void 0,F(u)),c=f.next();!c.done;c=f.next()){var d=c.value;s.push({event:d,sessionId:l})}}
2catch(v){t={error:v}}finally{try{c&&!c.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}o=a}return s},r})(),un="Unexpected error occurred",cn="Network error occurred, event batch rejected",bt="Session replay event batch rejected due to exceeded retry count",re="Failed to store session replay events in IndexedDB",dn="Session replay event batch not sent due to missing device ID",fn="Session replay event batch not sent due to missing api key",Ae="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",Me="1.44.0";function vn(r,e){return w(this,void 0,void 0,function(){var t,n,i,s,o,l,a,u,f,c,d,v,h,g,m=this;return P(this,function(p){switch(p.label){case 0:return p.trys.push([0,4,,5]),t=e.CompressionStream,n=new t("gzip"),i=n.writable.getWriter(),s=n.readable.getReader(),o=[],l=(function(){return w(m,void 0,void 0,function(){var y,S,b;return P(this,function(M){switch(M.label){case 0:return[4,s.read()];case 1:if(y=M.sent(),S=y.done,b=y.value,S)return[3,3];o.push(b),M.label=2;case 2:return[3,0];case 3:return[2]}})})})(),[4,i.write(new TextEncoder().encode(r))];case 1:return p.sent(),[4,i.close()];case 2:return p.sent(),[4,l];case 3:p.sent(),a=o.reduce(function(y,S){return y+S.length},0),u=new Uint8Array(a),f=0;try{for(c=F(o),d=c.next();!d.done;d=c.next())v=d.value,u.set(v,f),f+=v.length}catch(y){h={error:y}}finally{try{d&&!d.done&&(g=c.return)&&g.call(c)}finally{if(h)throw h.error}}return[2,u];case 4:return p.sent(),[2,null];case 5:return[2]}})})}var hn=256,gn=(function(){function r(e){var t=e.trackServerUrl,n=e.loggerProvider,i=e.payloadBatcher,s=e.workerScript,o=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.flushPauseUntilMs=0,this.mergeOnNextFlush=!1,this.mergeLogFiredThisPause=!1,this.killedSessions=new Set,this.loggerProvider=n,this.payloadBatcher=i||function(f){return f},this.trackServerUrl=t,s)try{var l=new Blob([s],{type:"application/javascript"}),a=URL.createObjectURL(l),u=new Worker(a);u.onerror=function(f){var c,d;f.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(f.message," (").concat(f.filename,":").concat(f.lineno,")")),u.terminate(),o.worker=void 0;try{for(var v=F(o.pendingWorkerRequests),h=v.next();!h.done;h=v.next()){var g=B(h.value,2),m=g[1];n.warn("Session replay event send failed due to worker crash: ".concat(f.message)),m.resolve()}}catch(p){c={error:p}}finally{try{h&&!h.done&&(d=v.return)&&d.call(v)}finally{if(c)throw c.error}}o.pendingWorkerRequests.clear()},u.onmessage=function(f){var c=f.data;if(c.type==="log")n.log(c.message);else if(c.type==="warn")n.warn(c.message);else if(c.type==="payload_too_large"){var d=o.pendingWorkerRequests.get(c.id);d&&(o.handlePayloadTooLargeResponse(d.context,c.isWaf),d.resolve(),o.pendingWorkerRequests.delete(c.id))}else if(c.type==="complete"){var v=o.pendingWorkerRequests.get(c.id);v&&(c.skipCode!==void 0&&o.applyServerDirective(v.context.sessionId,c.skipCode),o.completeRequest({context:v.context}),v.resolve(),o.pendingWorkerRequests.delete(c.id))}},this.worker=u}catch(f){n.error("Failed to create track destination worker, falling back to main-thread sending:",f)}}return r.prototype.sendEventsList=function(e){this.addToQueue(T(T({},e),{attempts:0,timeout:0}))},r.prototype.sendBeacon=function(e){var t,n,i=e.events,s=e.sessionId,o=e.deviceId,l=e.apiKey,a=e.serverZone,u=64*1024,f=function(M){return new Blob([M]).size},c=i,d=JSON.stringify({version:2,events:c});if(f(d)>u){for(var v=0,h=c.length;v<h;){var g=Math.floor((v+h+1)/2);f(JSON.stringify({version:2,events:c.slice(0,g)}))<=u?v=g:h=g-1}c=c.slice(0,v),d=JSON.stringify({version:2,events:c}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(i.length," to ").concat(c.length," events"))}if(c.length!==0){var m=new URLSearchParams({device_id:o,session_id:String(s),type:"replay",api_key:l}),p="".concat(Te(a,this.trackServerUrl),"?").concat(m.toString()),y=G();try{var S=new Blob([d],{type:"application/json"}),b=(n=(t=y?.navigator)===null||t===void 0?void 0:t.sendBeacon)===null||n===void 0?void 0:n.call(t,p,S);b===!1&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch{}}},r.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=t.filter(function(s){return e.killedSessions.has(s.sessionId)?(e.completeRequest({context:s,err:Ae}),!1):s.attempts<(s.flushMaxRetries||0)?(s.attempts+=1,!0):(e.completeRequest({context:s,err:bt}),!1)});
2i.forEach(function(s){e.queue=e.queue.concat(s),e.schedule(0)})},r.prototype.schedule=function(e){var t=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),i=n>0,s=n>e?n:e;i&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},s)}},r.prototype.flush=function(e){return e===void 0&&(e=!1),w(this,void 0,void 0,function(){var t,n,i,s,o,l,a;return P(this,function(u){switch(u.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush&&(this.mergeOnNextFlush=!1,t=this.mergeQueueAfterThrottle(t)),u.label=1;case 1:u.trys.push([1,6,7,8]),n=F(t),i=n.next(),u.label=2;case 2:return i.done?[3,5]:(s=i.value,[4,this.send(s,e)]);case 3:u.sent(),u.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return o=u.sent(),l={error:o},[3,8];case 7:try{i&&!i.done&&(a=n.return)&&a.call(n)}finally{if(l)throw l.error}return[7];case 8:return[2]}})})},r.prototype.mergeQueueAfterThrottle=function(e){var t,n,i,s,o=this,l,a,u,f,c,d,v;if(e.length<=1)return e;var h=new Map;try{for(var g=F(e),m=g.next();!m.done;m=g.next()){var p=m.value,y=[p.sessionId,(l=p.deviceId)!==null&&l!==void 0?l:"",(a=p.apiKey)!==null&&a!==void 0?a:"",p.type,(u=p.serverZone)!==null&&u!==void 0?u:"",p.sampleRate,(c=(f=p.version)===null||f===void 0?void 0:f.type)!==null&&c!==void 0?c:"",(v=(d=p.version)===null||d===void 0?void 0:d.version)!==null&&v!==void 0?v:""].join("|"),S=h.get(y);S?S.push(p):h.set(y,[p])}}catch(O){t={error:O}}finally{try{m&&!m.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}var b=[],M=function(O){var A,_;if(O.length===1)return b.push(O[0]),"continue";var E=null,I=0,k=function(){E&&b.push(E),E=null,I=0},L=function(U){var C=U.events.reduce(function(K,j){return K+new Blob([j]).size},0);if(E===null)return E=T(T({},U),{events:V([],B(U.events),!1),attempts:0}),I=C,"continue";if(I+C>Gr)return k(),E=T(T({},U),{events:V([],B(U.events),!1),attempts:0}),I=C,"continue";var z=E.onComplete,X=U.onComplete;E.events=E.events.concat(U.events),I+=C,E.onComplete=function(){return w(o,void 0,void 0,function(){return P(this,function(K){switch(K.label){case 0:return[4,Promise.allSettled([z(),X()])];case 1:return K.sent(),[2]}})})}};try{for(var R=(A=void 0,F(O)),W=R.next();!W.done;W=R.next()){var N=W.value;L(N)}}catch(U){A={error:U}}finally{try{W&&!W.done&&(_=R.return)&&_.call(R)}finally{if(A)throw A.error}}k()};try{for(var D=F(h.values()),x=D.next();!x.done;x=D.next()){var q=x.value;M(q)}}catch(O){i={error:O}}finally{try{x&&!x.done&&(s=D.return)&&s.call(D)}finally{if(i)throw i.error}}return b.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(b.length," request(s)"))),b},r.prototype.send=function(e,t){return t===void 0&&(t=!0),w(this,void 0,void 0,function(){var n,i,s,o;return P(this,function(l){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:Ae})]:(n=e.apiKey,n?(i=e.deviceId,i?(s=this.payloadBatcher({version:1,events:e.events}),s.events.length===0?(this.completeRequest({context:e}),[2]):(o=this.worker,o?[2,this.sendViaWorker(o,e,s,t)]:[2,this.sendOnMainThread(n,i,e,s,t)])):[2,this.completeRequest({context:e,err:dn})]):[2,this.completeRequest({context:e,err:fn})])})})},r.prototype.sendViaWorker=function(e,t,n,i){return w(this,void 0,void 0,function(){var s,o=this;return P(this,function(l){return s="".concat(++this.sendIdCounter),[2,new Promise(function(a){var u;o.pendingWorkerRequests.set(s,{context:t,resolve:a}),e.postMessage({type:"send",id:s,payload:n,useRetry:i,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:(u=t.flushMaxRetries)!==null&&u!==void 0?u:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:et(),sdkVersion:Me}})})]})})},r.prototype.sendOnMainThread=function(e,t,n,i,s){var o,l,a,u,f,c,d;return w(this,void 0,void 0,function(){var v,h,g,m,p,y,S,b,M,D,x,q,O,A,_,_,E;return P(this,function(I){switch(I.label){case 0:v=et(),h=Me,g=n.sampleRate,m=new URLSearchParams({device_id:t,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),p="".concat((l=(o=n.version)===null||o===void 0?void 0:o.type)!==null&&l!==void 0?l:"standalone","/").concat((u=(a=n.version)===null||a===void 0?void 0:a.version)!==null&&u!==void 0?u:h),I.label=1;case 1:return I.trys.push([1,13,,14]),y=JSON.stringify(i),S=G(),S&&"CompressionStream"in S?[4,vn(y,S)]:[3,3];case 2:return M=I.sent(),[3,4];case 3:M=null,I.label=4;case 4:return b=M,D=b?b.byteLength:new Blob([y]).size,x={headers:T({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":h,"X-Client-Library":p,"X-Client-Url":v.substring(0,qr),"X-Client-Sample-Rate":"".concat(g),"X-Sampling-Hash-Alg":"xxhash32"},b?{"Content-Encoding":"gzip"}:{}),body:b??y,method:"POST",keepalive:D<=Br},q="".concat(Te(n.serverZone,this.trackServerUrl),"?").concat(m.toString()),i.events.length===0?(this.completeRequest({context:n}),[2]):[4,fetch(q,x)];case 5:if(O=I.sent(),O===null)return this.completeRequest({context:n,err:un}),[2];if(O.status>=200&&O.status<300&&(A=(d=(c=(f=O.headers)===null||f===void 0?void 0:f.get)===null||c===void 0?void 0:c.call(f,Wr))!==null&&d!==void 0?d:null,this.applyServerDirective(n.sessionId,A)),s)return[3,6];_="";try{_=JSON.stringify(O.body,null,2)}catch{}return this.completeRequest({context:n,success:"".concat(O.status,": ").concat(_)}),[3,12];case 6:if(_="",O.status!==413)return[3,10];I.label=7;case 7:return I.trys.push([7,9,,10]),[4,O.text()];case 8:return _=I.sent(),[3,10];case 9:return I.sent(),[3,10];case 10:return[4,this.handleReponse(O.status,n,_)];case 11:I.sent(),I.label=12;case 12:return[3,14];case 13:return E=I.sent(),this.completeRequest({context:n,err:E}),[3,14];case 14:return[2]}})})},r.prototype.handleReponse=function(e,t,n){return n===void 0&&(n=""),w(this,void 0,void 0,function(){var i,s;return P(this,function(o){switch(o.label){case 0:switch(i=new mr().buildStatus(e),s=i,s){case ge.Success:return[3,1];case ge.Failed:return[3,2];case ge.Timeout:return[3,2];case ge.RateLimit:return[3,2];case ge.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:return o.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,Ar.test(n)),[3,8];case 5:return e!==499?[3,7]:[4,this.handleOtherResponse(t)];case 6:return o.sent(),[3,8];case 7:this.completeRequest({context:t,err:cn}),o.label=8;case 8:return[2]}})})},r.prototype.handlePayloadTooLargeResponse=function(e,t){var n=t?"WAF (compressed payload too large)":"server (event too large)",i=Math.round(e.events.reduce(function(l,a){return l+a.length},0)/Ze);if(!t){this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(i," KB) — not retrying non-WAF 413")});return}if(e.events.length===1){this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(i," KB, 1 event) rejected by ").concat(n," — cannot split further")});return}this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(i," KB total) — splitting and retrying")),e.onComplete();var s=function(){return Promise.resolve()},o=Math.floor(e.events.length/2);this.sendEventsList(T(T({},e),{events:e.events.slice(0,o),onComplete:s})),this.sendEventsList(T(T({},e),{events:e.events.slice(o),onComplete:s}))},r.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/Ze);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},r.prototype.handleOtherResponse=function(e){return w(this,void 0,void 0,function(){var t;return P(this,function(n){switch(n.label){case 0:return t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:bt}),[2]):[4,new Promise(function(i){return setTimeout(i,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},r.prototype.completeRequest=function(e){var t=e.context,n=e.err,i=e.success;t.onComplete(),n?this.loggerProvider.warn(n):i&&this.loggerProvider.log(i)},r.prototype.applyServerDirective=function(e,t){if(t===null){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if(t===Kr){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+pt,n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(pt/1e3,"s"));return}(t===zr||t===jr)&&this.killSession(e,t)},r.prototype.killSession=function(e,t){var n,i,s,o;
2if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>hn)try{for(var l=F(this.killedSessions),a=l.next();!a.done;a=l.next()){var u=a.value;this.killedSessions.delete(u);break}}catch(h){n={error:h}}finally{try{a&&!a.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(t,"; remaining events will be dropped"));var f=[];try{for(var c=F(this.queue),d=c.next();!d.done;d=c.next()){var v=d.value;v.sessionId===e?this.completeRequest({context:v,err:Ae}):f.push(v)}}catch(h){s={error:h}}finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(s)throw s.error}}this.queue=f}},r})();const tt=(r,e)=>e.some(t=>r instanceof t);let It,Et;function pn(){return It||(It=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function mn(){return Et||(Et=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const rt=new WeakMap,Ne=new WeakMap,_e=new WeakMap;function yn(r){const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{t(fe(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return _e.set(e,r),e}function Sn(r){if(rt.has(r))return;const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{t(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});rt.set(r,e)}let nt={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return rt.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return fe(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function er(r){nt=r(nt)}function bn(r){return mn().includes(r)?function(...e){return r.apply(it(this),e),fe(this.request)}:function(...e){return fe(r.apply(it(this),e))}}function In(r){return typeof r=="function"?bn(r):(r instanceof IDBTransaction&&Sn(r),tt(r,pn())?new Proxy(r,nt):r)}function fe(r){if(r instanceof IDBRequest)return yn(r);if(Ne.has(r))return Ne.get(r);const e=In(r);return e!==r&&(Ne.set(r,e),_e.set(e,r)),e}const it=r=>_e.get(r);function tr(r,e,{blocked:t,upgrade:n,blocking:i,terminated:s}={}){const o=indexedDB.open(r,e),l=fe(o);return n&&o.addEventListener("upgradeneeded",a=>{n(fe(o.result),a.oldVersion,a.newVersion,fe(o.transaction),a)}),t&&o.addEventListener("blocked",a=>t(a.oldVersion,a.newVersion,a)),l.then(a=>{s&&a.addEventListener("close",()=>s()),i&&a.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),l}const En=["get","getKey","getAll","getAllKeys","count"],Cn=["put","add","delete","clear"],Ue=new Map;function Ct(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Ue.get(e))return Ue.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,i=Cn.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(i||En.includes(t)))return;const s=async function(o,...l){const a=this.transaction(o,i?"readwrite":"readonly");let u=a.store;return n&&(u=u.index(l.shift())),(await Promise.all([u[t](...l),i&&a.done]))[0]};return Ue.set(e,s),s}er(r=>({...r,get:(e,t,n)=>Ct(e,t)||r.get(e,t,n),has:(e,t)=>!!Ct(e,t)||r.has(e,t)}));const Pn=["continue","continuePrimaryKey","advance"],Pt={},st=new WeakMap,rr=new WeakMap,wn={get(r,e){if(!Pn.includes(e))return r[e];let t=Pt[e];return t||(t=Pt[e]=function(...n){st.set(this,rr.get(this)[e](...n))}),t}};async function*Tn(...r){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...r)),!e)return;e=e;const t=new Proxy(e,wn);for(rr.set(t,e),_e.set(t,it(e));e;)yield t,e=await(st.get(t)||e.continue()),st.delete(t)}function wt(r,e){return e===Symbol.asyncIterator&&tt(r,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&tt(r,[IDBIndex,IDBObjectStore])}er(r=>({...r,get(e,t,n){return wt(e,t)?Tn:r.get(e,t,n)},has(e,t){return wt(e,t)||r.has(e,t)}}));var nr=(function(){function r(e){var t=this,n,i,s;
2this.minInterval=Je,this.maxInterval=Ye,this.maxPersistedEventsSize=Gt,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(o,l){var a=t.getStringSize(l),u=t.getEventsArraySize(o);return u+a>=t.maxPersistedEventsSize?!0:Date.now()-t.timeAtLastSplit>t.interval&&o.length?(t.interval=Math.min(t.maxInterval,t.interval+t.minInterval),t._timeAtLastSplit=Date.now(),!0):!1},this.loggerProvider=e.loggerProvider,this.minInterval=(n=e.minInterval)!==null&&n!==void 0?n:this.minInterval,this.maxInterval=(i=e.maxInterval)!==null&&i!==void 0?i:this.maxInterval,this.maxPersistedEventsSize=(s=e.maxPersistedEventsSize)!==null&&s!==void 0?s:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(r.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),r.prototype.getStringSize=function(e){for(var t=0,n=0;n<e.length;n++){var i=e.charCodeAt(n);if(i<=127)t++;else if(i<=2047)t+=2;else if(i>=55296&&i<=56319){var s=n+1<e.length?e.charCodeAt(n+1):NaN;s>=56320&&s<=57343?(t+=4,n++):t+=3}else i>=56320&&i<=57343,t+=3}return t},r.prototype.getEventsArraySize=function(e){var t,n,i=0;try{for(var s=F(e),o=s.next();!o.done;o=s.next()){var l=o.value;i+=this.getStringSize(l)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}var a=2+Math.max(0,e.length-1)+e.length*2;return i+a},r})(),Mn=function(r){return typeof r=="object"&&r!==null&&r.name==="AbortError"},Z=function(r,e,t){Mn(t)?r.debug(e):r.warn(e)};function Rn(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}}var ne="sessionCurrentSequence",oe="sequencesToSend",kn=2e3,qe=5e3;function _n(r,e,t){return new Promise(function(n,i){var s=setTimeout(function(){return i(new Error("".concat(t," after ").concat(e,"ms")))},e);r.then(function(o){clearTimeout(s),n(o)},function(o){clearTimeout(s),i(o)})})}function Be(r,e,t){var n=setTimeout(t,e);return r.then(function(){return clearTimeout(n)},function(){return clearTimeout(n)}),function(){return clearTimeout(n)}}var Ln=function(r){var e,t;return r.objectStoreNames.contains(ne)||(t=r.createObjectStore(ne,{keyPath:"sessionId"})),r.objectStoreNames.contains(oe)||(e=r.createObjectStore(oe,{keyPath:"sequenceId",autoIncrement:!0}),e.createIndex("sessionId","sessionId")),{sequencesStore:e,currentSequenceStore:t}},xn=function(r){return w(void 0,void 0,void 0,function(){return P(this,function(e){switch(e.label){case 0:return[4,_n(tr(r,1,{upgrade:Ln}),kn,"IDB openDB timed out")];case 1:return[2,e.sent()]}})})},On=(function(r){ot(e,r);function e(t){var n=this,i;return n=r.call(this,t)||this,n.consecutiveFailures=0,n.hasTriggeredFallback=!1,n.emptyFilteredCount=0,n.getSequencesToSend=function(){return w(n,void 0,void 0,function(){var s,o,l,a,u,f,c,d,v,h,g=this;return P(this,function(m){switch(m.label){case 0:s=!1,o=!1,m.label=1;case 1:return m.trys.push([1,9,,10]),l=[],a=this.db.transaction("sequencesToSend","readwrite"),a.done.catch(function(p){!s&&!o&&(Z(g.loggerProvider,"".concat(re,": ").concat(p),p),g.recordFailure())}),u=Be(a.done,qe,function(){!s&&!o&&(o=!0,Z(g.loggerProvider,"".concat(re,": transaction timed out")),g.recordFailure())}),[4,a.store.openCursor()];case 2:f=m.sent(),m.label=3;case 3:return f?(c=f.value,d=c.sessionId,v=c.events,v.length!==0?[3,5]:(this.maybeLogEmptyFiltered("getSequencesToSend"),[4,f.delete()])):[3,8];case 4:return m.sent(),[3,6];case 5:l.push({events:v,sequenceId:f.key,sessionId:d}),m.label=6;case 6:return[4,f.continue()];case 7:return f=m.sent(),[3,3];case 8:return this.recordSuccess(),u(),[2,l];case 9:return h=m.sent(),o||(s=!0,Z(this.loggerProvider,"".concat(re,": ").concat(h),h),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},n.storeCurrentSequence=function(s){return w(n,void 0,void 0,function(){var o,l,a,u,f,c,d,v,h=this;return P(this,function(g){switch(g.label){case 0:o=!1,l=!1,g.label=1;case 1:return g.trys.push([1,5,,6]),a=this.db.transaction([ne,oe],"readwrite"),a.done.catch(function(m){!o&&!l&&(Z(h.loggerProvider,"".concat(re,": ").concat(m),m),h.recordFailure())}),u=Be(a.done,qe,function(){!o&&!l&&(l=!0,Z(h.loggerProvider,"".concat(re,": transaction timed out")),h.recordFailure())}),[4,a.objectStore(ne).get(s)];case 2:return f=g.sent(),!f||f.tabId&&f.tabId!==this.tabId?(u(),[2,void 0]):f.events.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),u(),[2,void 0]):[4,a.objectStore(oe).put({sessionId:s,events:f.events,tabId:this.tabId})];case 3:return c=g.sent(),[4,a.objectStore(ne).put({sessionId:s,events:[],tabId:this.tabId})];case 4:return g.sent(),this.recordSuccess(),u(),f.tabId,d=Oe(f,["tabId"]),[2,T(T({},d),{sessionId:s,sequenceId:c})];case 5:return v=g.sent(),l||(o=!0,Z(this.loggerProvider,"".concat(re,": ").concat(v),v),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},n.addEventToCurrentSequence=function(s,o){return w(n,void 0,void 0,function(){var l,a,u,f,c,d,v,h,g,m=this;return P(this,function(p){switch(p.label){case 0:l=!1,a=!1,p.label=1;case 1:return p.trys.push([1,15,,16]),u=this.db.transaction([ne,oe],"readwrite"),u.done.catch(function(y){!l&&!a&&(Z(m.loggerProvider,"".concat(re,": ").concat(y),y),m.recordFailure())}),f=Be(u.done,qe,function(){!l&&!a&&(a=!0,Z(m.loggerProvider,"".concat(re,": transaction timed out")),m.recordFailure())}),[4,u.objectStore(ne).get(s)];case 2:return c=p.sent(),c?.tabId&&c.tabId!==this.tabId?c.events.length>0?[4,u.objectStore(oe).put({sessionId:s,events:c.events,tabId:c.tabId})]:[3,4]:[3,6];case 3:p.sent(),p.label=4;case 4:return[4,u.objectStore(ne).put({sessionId:s,events:[o],tabId:this.tabId})];case 5:return p.sent(),this.recordSuccess(),f(),[2,void 0];case 6:return d=c,d?[3,8]:[4,u.objectStore(ne).put({sessionId:s,events:[o],tabId:this.tabId})];case 7:return p.sent(),this.recordSuccess(),f(),[2,void 0];case 8:return this.shouldSplitEventsList(d.events,o)?[3,10]:[4,u.objectStore(ne).put({sessionId:s,events:d.events.concat(o),tabId:this.tabId})];case 9:return p.sent(),this.recordSuccess(),f(),[2,void 0];case 10:return v=d.events,v.length!==0?[3,12]:(this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,u.objectStore(ne).put({sessionId:s,events:[o],tabId:this.tabId})]);case 11:return p.sent(),this.recordSuccess(),f(),[2,void 0];case 12:return[4,u.objectStore(ne).put({sessionId:s,events:[o],tabId:this.tabId})];case 13:return p.sent(),[4,u.objectStore(oe).put({sessionId:s,events:v,tabId:this.tabId})];case 14:return h=p.sent(),this.recordSuccess(),f(),[2,{events:v,sessionId:s,sequenceId:h}];case 15:return g=p.sent(),a||(l=!0,Z(this.loggerProvider,"".concat(re,": ").concat(g),g),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},n.storeSendingEvents=function(s,o){return w(n,void 0,void 0,function(){var l,a;return P(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,this.db.put(oe,{sessionId:s,events:o,tabId:this.tabId})];case 1:return l=u.sent(),this.recordSuccess(),[2,l];case 2:return a=u.sent(),Z(this.loggerProvider,"".concat(re,": ").concat(a),a),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(s,o){return w(n,void 0,void 0,function(){var l;return P(this,function(a){switch(a.label){case 0:if(!o)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.db.delete(oe,o)];case 2:return a.sent(),this.recordSuccess(),[3,4];case 3:return l=a.sent(),Z(this.loggerProvider,"".concat(re,": ").concat(l),l),this.recordFailure(),[3,4];case 4:return[2]}})})},n.db=t.db,n.tabId=t.tabId,n.onPersistentFailure=t.onPersistentFailure,n.consecutiveFailureThreshold=(i=t.consecutiveFailureThreshold)!==null&&i!==void 0?i:1,n}return e.prototype.maybeLogEmptyFiltered=function(t){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(t," (idb store)"))},e.prototype.recordFailure=function(){var t;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,(t=this.onPersistentFailure)===null||t===void 0||t.call(this))},e.prototype.recordSuccess=function(){this.consecutiveFailures=0},e.new=function(t,n){var i;return w(this,void 0,void 0,function(){var s,o,l,a,u;return P(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),s=t==="replay"?"":"_".concat(t),o="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(s),[4,xn(o)];case 1:return l=f.sent(),a=(i=n.tabId)!==null&&i!==void 0?i:Rn(),[2,new e(T(T({},n),{db:l,tabId:a}))];case 2:return u=f.sent(),Z(n.loggerProvider,"".concat(re,": ").concat(u),u),[3,3];case 3:return[2]}})})},e.prototype.getCurrentSequenceEvents=function(t){return w(this,void 0,void 0,function(){var o,l,n,i,s,o,l,a,u,f;return P(this,function(c){switch(c.label){case 0:return t?[4,this.db.get("sessionCurrentSequence",t)]:[3,2];case 1:return o=c.sent(),o?o.tabId&&o.tabId!==this.tabId?[2,void 0]:(o.tabId,l=Oe(o,["tabId"]),[2,[l]]):[2,void 0];case 2:n=[],c.label=3;case 3:return c.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:i=F.apply(void 0,[c.sent()]),s=i.next(),c.label=5;case 5:if(s.done)return[3,7];if(o=s.value,o.tabId&&o.tabId!==this.tabId)return[3,6];o.tabId,l=Oe(o,["tabId"]),n.push(l),c.label=6;case 6:return s=i.next(),[3,5];case 7:return[3,10];case 8:return a=c.sent(),u={error:a},[3,10];case 9:try{s&&!s.done&&(f=i.return)&&f.call(i)}finally{if(u)throw u.error}
2return[7];case 10:return[2,n]}})})},e})(nr),Dn=(function(r){ot(e,r);function e(){var t=r!==null&&r.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t.emptyFilteredCount=0,t}return e.prototype.resetCurrentSequence=function(t){this.sequences[t]=[]},e.prototype.addSequence=function(t){var n=this.sequenceId++,i=V([],B(this.sequences[t]),!1);return this.finalizedSequences[n]={sessionId:t,events:i},this.resetCurrentSequence(t),{sequenceId:n,events:i,sessionId:t}},e.prototype.maybeLogEmptyFiltered=function(t){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(t," (in-memory store)"))},e.prototype.getSequencesToSend=function(){return w(this,void 0,void 0,function(){var t,n,i,s,o,l,a,u,f,c;return P(this,function(d){t=[];try{for(n=F(Object.entries(this.finalizedSequences)),i=n.next();!i.done;i=n.next()){if(s=B(i.value,2),o=s[0],l=s[1],a=l.sessionId,u=l.events,u.length===0){this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(o)];continue}t.push({sequenceId:Number(o),sessionId:a,events:u})}}catch(v){f={error:v}}finally{try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(f)throw f.error}}return[2,t]})})},e.prototype.storeCurrentSequence=function(t){return w(this,void 0,void 0,function(){var n;return P(this,function(i){return n=this.sequences[t],n?n.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(t)]:[2,void 0]})})},e.prototype.addEventToCurrentSequence=function(t,n){return w(this,void 0,void 0,function(){var i;return P(this,function(s){return this.sequences[t]||this.resetCurrentSequence(t),this.shouldSplitEventsList(this.sequences[t],n)&&(this.sequences[t].length===0?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):i=this.addSequence(t)),this.sequences[t].push(n),[2,i]})})},e.prototype.storeSendingEvents=function(t,n){return w(this,void 0,void 0,function(){return P(this,function(i){return this.finalizedSequences[this.sequenceId]={sessionId:t,events:n},[2,this.sequenceId++]})})},e.prototype.cleanUpSessionEventsStore=function(t,n){return w(this,void 0,void 0,function(){return P(this,function(i){return n!==void 0&&delete this.finalizedSequences[n],[2]})})},e})(nr),Tt=function(r){var e=r.config,t=r.minInterval,n=r.maxInterval,i=r.type,s=r.payloadBatcher,o=r.storeType,l=r.trackDestinationWorkerScript,a=r.shouldSend;return w(void 0,void 0,void 0,function(){function u(_){return _===void 0&&(_=!1),w(this,void 0,void 0,function(){return P(this,function(E){return[2,f.flush(_)]})})}var f,c,d,v,h,g,m,p,y,S,b,M,D,x,q,O,A;return P(this,function(_){switch(_.label){case 0:return f=new gn(T(T({},e),{loggerProvider:e.loggerProvider,payloadBatcher:s,workerScript:l})),c=function(){return new Dn({loggerProvider:e.loggerProvider,maxInterval:n,minInterval:t})},v=!1,g=function(){return w(void 0,void 0,void 0,function(){var E,I,k;return P(this,function(L){switch(L.label){case 0:return v?(v=!1,e.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),d?[4,h.getSequencesToSend()]:[3,2]):[2];case 1:return I=L.sent(),[3,3];case 2:I=void 0,L.label=3;case 3:return E=I,h=c(),E&&d&&(k=d,E.forEach(function(R){M({sequenceId:R.sequenceId,events:R.events,sessionId:R.sessionId,deviceId:k})})),[2]}})})},m=function(){return w(void 0,void 0,void 0,function(){var E;return P(this,function(I){switch(I.label){case 0:return[4,On.new(i,{loggerProvider:e.loggerProvider,minInterval:t,maxInterval:n,apiKey:e.apiKey,onPersistentFailure:function(){g()}})];case 1:return E=I.sent(),E?(v=!0,[2,E]):(e.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,c()])}})})},o!=="idb"?[3,2]:[4,m()];case 1:return p=_.sent(),[3,3];case 2:p=c(),_.label=3;case 3:return h=p,y=[],S=0,b=function(E){if(!(E<=S)){var I=Math.min(E-S,y.length);I>0&&(y.splice(0,I),S=E)}},M=function(E){var I=E.events,k=E.sessionId,L=E.deviceId,R=E.sequenceId,W=I.map(function(C){return{event:C,bytes:new Blob([C]).size}}),N=W.filter(function(C){return C.bytes>Qe});N.length>0&&e.loggerProvider.warn("Dropping ".concat(N.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(N.map(function(C){return"".concat(Math.round(C.bytes/1024)," KB")}).join(", "),". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));var U=N.length>0?W.filter(function(C){return C.bytes<=Qe}).map(function(C){return C.event}):I;if(U.length===0){h.cleanUpSessionEventsStore(k,R).catch(function(C){e.loggerProvider.warn("Failed to clean up session replay events store:",C)});return}e.debugMode&&Jt().then(function(C){var z=C.totalStorageSize,X=C.percentOfQuota,K=C.usageDetails;e.loggerProvider.debug("Total storage size: ".concat(z," KB, percentage of quota: ").concat(X,"%, usage details: ").concat(K))}).catch(function(){}),f.sendEventsList({events:U,sessionId:k,flushMaxRetries:e.flushMaxRetries,apiKey:e.apiKey,deviceId:L,sampleRate:e.sampleRate,serverZone:e.serverZone,version:e.version,type:i,onComplete:function(){return w(void 0,void 0,void 0,function(){return P(this,function(C){switch(C.label){case 0:return[4,h.cleanUpSessionEventsStore(k,R)];case 1:return C.sent(),[2]}})})}})},D=function(E){var I=E.sessionId,k=E.deviceId;if(d=k,!(a&&!a())){var L=S+y.length;h.storeCurrentSequence(I).then(function(R){R&&(b(L),M({sequenceId:R.sequenceId,events:R.events,sessionId:R.sessionId,deviceId:k}))}).catch(function(R){e.loggerProvider.warn("Failed to get current sequence of session replay events for session:",R)})}},x=function(E){var I=E.deviceId;return w(void 0,void 0,void 0,function(){var k;return P(this,function(L){switch(L.label){case 0:return d=I,[4,h.getSequencesToSend()];case 1:return k=L.sent(),k?.length?(e.loggerProvider.log("Draining ".concat(k.length," stored sequence(s) from previous session.")),k.forEac
2h(function(R){M({sequenceId:R.sequenceId,events:R.events,sessionId:R.sessionId,deviceId:I})}),[2]):[2]}})})},q=function(E){var I=E.event,k=E.sessionId,L=E.deviceId;d=L;var R=!a||a(),W=S+y.length;y.push(I.data),h.addEventToCurrentSequence(k,I.data).then(function(N){if(N){if(!R){h.cleanUpSessionEventsStore(N.sessionId,N.sequenceId).catch(function(U){e.loggerProvider.warn("Failed to clean up dropped session replay sequence:",U)}),b(W);return}b(W),M({sequenceId:N.sequenceId,events:N.events,sessionId:N.sessionId,deviceId:L})}}).catch(function(N){e.loggerProvider.warn("Failed to add event to session replay capture:",N)})},O=function(){return V([],B(y),!1)},A=function(){b(S+y.length)},[2,{sendCurrentSequenceEvents:D,addEvent:q,sendStoredEvents:x,flush:u,getBeaconEvents:O,dropPendingBeaconEvents:A,trackDestination:f}]}})})},Mt=(function(){function r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach(function(i){n.set(i.name,i.manager)}),this.managers=n}return r.prototype.sendStoredEvents=function(e){return w(this,void 0,void 0,function(){var t;return P(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(i){t.push(i.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},r.prototype.addEvent=function(e){var t,n=e.sessionId,i=e.event,s=e.deviceId;(t=this.managers.get(i.type))===null||t===void 0||t.addEvent({sessionId:n,event:i,deviceId:s})},r.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(i){i.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},r.prototype.flush=function(e){return w(this,void 0,void 0,function(){var t;return P(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(i){t.push(i.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},r})(),ie,ct,ir;function Fn(r,e){if(ir=new Date,r.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(r.tagName.toLowerCase()==="html")return"html";var t={root:document.body,idName:function(s){return!0},className:function(s){return!0},tagName:function(s){return!0},attr:function(s,o){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};ie=T(T({},t),e),ct=An(ie.root,t);var n=Se(r,"all",function(){return Se(r,"two",function(){return Se(r,"one",function(){return Se(r,"none")})})});if(n){var i=ar(lr(n,r));return i.length>0&&(n=i[0]),Le(n)}else throw new Error("Selector was not found.")}function An(r,e){return r.nodeType===Node.DOCUMENT_NODE?r:r===e.root?r.ownerDocument:r}function Se(r,e,t){for(var n=null,i=[],s=r,o=0,l=function(){var u,f,c=new Date().getTime()-ir.getTime();if(ie.timeoutMs!==void 0&&c>ie.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var d=Ie(Nn(s))||Ie.apply(void 0,V([],B(Un(s)),!1))||Ie.apply(void 0,V([],B(qn(s)),!1))||Ie(Bn(s))||[_t()],v=Wn(s);if(e=="all")v&&(d=d.concat(d.filter(We).map(function(y){return be(y,v)})));else if(e=="two")d=d.slice(0,1),v&&(d=d.concat(d.filter(We).map(function(y){return be(y,v)})));else if(e=="one"){var h=B(d=d.slice(0,1),1),g=h[0];v&&We(g)&&(d=[be(g,v)])}else e=="none"&&(d=[_t()],v&&(d=[be(d[0],v)]));try{for(var m=(u=void 0,F(d)),p=m.next();!p.done;p=m.next()){var g=p.value;g.level=o}}catch(y){u={error:y}}finally{try{p&&!p.done&&(f=m.return)&&f.call(m)}finally{if(u)throw u.error}}if(i.push(d),i.length>=ie.seedMinLength&&(n=Rt(i,t),n))return"break";s=s.parentElement,o++};s;){var a=l();if(a==="break")break}return n||(n=Rt(i,t)),!n&&t?t():n}function Rt(r,e){var t,n,i=ar(or(r));if(i.length>ie.threshold)return e?e():null;try{for(var s=F(i),o=s.next();!o.done;o=s.next()){var l=o.value;if(sr(l))return l}}catch(a){t={error:a}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return null}function Le(r){for(var e=r[0],t=e.name,n=1;n<r.length;n++){var i=r[n].level||0;e.level===i-1?t="".concat(r[n].name," > ").concat(t):t="".concat(r[n].name," ").concat(t),e=r[n]}return t}function kt(r){return r.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function sr(r){var e=Le(r);switch(ct.querySelectorAll(e).length){case 0:throw new Error("Can't select any node with this selector: ".concat(e));case 1:return!0;default:return!1}}function Nn(r){var e=r.getAttribute("id");return e&&ie.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Un(r){var e=Array.from(r.attributes).filter(function(t){return ie.attr(t.name,t.value)});return e.map(function(t){return{name:"[".concat(CSS.escape(t.name),'="').concat(CSS.escape(t.value),'"]'),penalty:.5}})}function qn(r){var e=Array.from(r.classList).filter(ie.className);return e.map(function(t){return{name:"."+CSS.escape(t),penalty:1}})}function Bn(r){var e=r.tagName.toLowerCase();return ie.tagName(e)?{name:e,penalty:2}:null}function _t(){return{name:"*",penalty:3}}function Wn(r){var e=r.parentNode;if(!e)return null;var t=e.firstChild;if(!t)return null;for(var n=0;t&&(t.nodeType===Node.ELEMENT_NODE&&n++,t!==r);
vendor: 4,270 bytes, line 2
2)t=t.nextSibling;return n}function be(r,e){return{name:r.name+":nth-child(".concat(e,")"),penalty:r.penalty+1}}function We(r){return r.name!=="html"&&!r.name.startsWith("#")}function Ie(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=r.filter(Kn);return t.length>0?t:null}function Kn(r){return r!=null}function or(r,e){var t,n,i,s,o,l;return e===void 0&&(e=[]),P(this,function(a){switch(a.label){case 0:if(!(r.length>0))return[3,9];a.label=1;case 1:a.trys.push([1,6,7,8]),t=F(r[0]),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(i=n.value,[5,F(or(r.slice(1,r.length),e.concat(i)))]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return s=a.sent(),o={error:s},[3,8];case 7:try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(o)throw o.error}return[7];case 8:return[3,11];case 9:return[4,e];case 10:a.sent(),a.label=11;case 11:return[2]}})}function ar(r){return V([],B(r),!1).sort(function(e,t){return kt(e)-kt(t)})}function lr(r,e,t){var n,i,s;return t===void 0&&(t={counter:0,visited:new Map}),P(this,function(o){switch(o.label){case 0:if(!(r.length>2&&r.length>ie.optimizedMinLength))return[3,5];n=1,o.label=1;case 1:return n<r.length-1?t.counter>ie.maxNumberOfTries?[2]:(t.counter+=1,i=V([],B(r),!1),i.splice(n,1),s=Le(i),t.visited.has(s)?[2]:sr(i)&&jn(i,e)?[4,i]:[3,4]):[3,5];case 2:return o.sent(),t.visited.set(s,!0),[5,F(lr(i,e,t))];case 3:o.sent(),o.label=4;case 4:return n++,[3,1];case 5:return[2]}})}function jn(r,e){return ct.querySelector(Le(r))===e}var zn=36e5,Gn=function(r){var e=r.version,t=r.events,n=[];return t.forEach(function(i){var s=JSON.parse(i);s.count=1,s.type==="click"&&n.push(s)}),{version:e,events:n}},Vn=function(r){var e=r.version,t=r.events,n=[];t.forEach(function(s){var o=JSON.parse(s);o.type==="click"&&n.push(o)});var i=n.reduce(function(s,o){var l=o.x,a=o.y,u=o.selector,f=o.timestamp,c=f-f%zn,d="".concat(l,":").concat(a,":").concat(u??"",":").concat(c);return s[d]?s[d].count+=1:s[d]=T(T({},o),{timestamp:c,count:1}),s},{});return{version:e,events:Object.values(i)}},Hn=(function(){function r(e,t){var n=this;this.createHook=function(i){var s=i.eventsManager,o=i.sessionId,l=i.deviceIdFn,a=i.mirror,u=i.ugcFilterRules,f=i.performanceOptions;return function(c){if(c.type===$t.Click){var d=G();if(d){var v=d.location,h=d.innerHeight,g=d.innerWidth;if(v){var m=c.x,p=c.y;if(!(m===void 0||p===void 0)){var y=a.getNode(c.id),S;if(y)try{S=Fn(y,f)}catch{n.logger.debug("error resolving selector from finder")}var b=Re(v.href,u),M={x:m+n.scrollWatcher.currentScrollX,y:p+n.scrollWatcher.currentScrollY,selector:S,viewportHeight:h,viewportWidth:g,pageUrl:b,timestamp:Date.now(),type:"click"},D=l();D&&s.addEvent({sessionId:o,event:{type:"interaction",data:JSON.stringify(M)},deviceId:D})}}}}}},this.logger=e,this.scrollWatcher=t}return r})();function Ke(){var r=G();return r?.innerHeight||document.documentElement&&document.documentElement.clientHeight||0}function je(){var r=G();return r?.innerWidth||document.documentElement&&document.documentElement.clientWidth||0}var Xn=(function(){function r(e,t){var n=G();n&&n.navigator&&typeof n.navigator.sendBeacon=="function"?this.sendBeacon=function(i,s){try{if(n.navigator.sendBeacon(i,JSON.stringify(s)))return!0}catch{}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(i,s){var o=new XMLHttpRequest;return o.open("POST",i,!0),o.setRequestHeader("Accept","*/*"),o.send(JSON.stringify(s)),!0},this.basePageUrl=Te(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return r.prototype.send=function(e,t){var n=this.context,i=n.sessionId,s=n.type,o=new URLSearchParams({device_id:e,session_id:String(i),type:String(s),api_key:this.apiKey}),l="".concat(this.basePageUrl,"?").concat(o.toString());this.sendBeacon(l,t)||this.sendXhr(l,t)},r})(),Qn=(function(){function r(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(i){n.update(i)},this.send=function(i){return function(s){var o,l,a,u,f=i(),c=G();if(c&&f){var d=(o=c.scrollX)!==null&&o!==void 0?o:0,v=(l=c.scrollY)!==null&&l!==void 0?l:0;(d>0||v>0)&&n.update({id:1,x:d,y:v}),n.transport.send(f,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHe
2ight:Ke(),viewportWidth:je(),pageUrl:Re(c.location.href,(u=(a=n.config.interactionConfig)===null||a===void 0?void 0:a.ugcFilterRules)!==null&&u!==void 0?u:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=je(),this._maxScrollHeight=Ke(),this.config=t,this.transport=e}return r.default=function(e,t){return new r(new Xn(e,t),t)},Object.defineProperty(r.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),r.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=je();this._maxScrollX=e.x;var i=e.x+n;i>this._maxScrollWidth&&(this._maxScrollWidth=i),this.timestamp=t}if(e.y>this._maxScrollY){var s=Ke();this._maxScrollY=e.y;var o=e.y+s;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},r})(),Lt=(function(){function r(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=Qr(t,n))}return r})(),Jn="AMP_SR_START_",Yn=10,ur=1440*60*1e3,cr=function(r){return"".concat(Jn).concat(r.substring(0,Yn),"_")},dt=function(r,e){return"".concat(cr(r)).concat(e)},xe=function(){try{var r=G();return r?.localStorage}catch{return}},Zn=function(r,e,t,n){var i=xe();if(i){var s=dt(r,e);try{var o=i.getItem(s);if(o!==null){var l=Number(o);if(Number.isFinite(l)&&l>0&&l<=t&&t-l<ur)return l}return i.setItem(s,String(t)),t}catch(a){n?.debug("Failed to read/write replay start time from storage: ".concat(String(a)));return}}},$n=function(r,e,t,n){var i=xe();if(i)try{i.setItem(dt(r,e),String(t))}catch(s){n?.debug("Failed to write replay start time to storage: ".concat(String(s)))}},ei=function(r,e,t){var n=xe();if(n)try{n.removeItem(dt(r,e))}catch(i){t?.debug("Failed to remove replay start time from storage: ".concat(String(i)))}},ti=function(r,e,t){var n,i,s=xe();if(s){var o=cr(r);try{for(var l=[],a=0;a<s.length;a++){var u=s.key(a);if(!(!u||!u.startsWith(o))){var f=s.getItem(u);if(f!==null){var c=Number(f);(!Number.isFinite(c)||c<=0||e-c>=ur)&&l.push(u)}}}try{for(var d=F(l),v=d.next();!v.done;v=d.next()){var u=v.value;s.removeItem(u)}}catch(h){n={error:h}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}catch(h){t?.debug("Failed to prune stale replay start times: ".concat(String(h)))}}},ri=1e3*60*60*24*2,ni=(function(){function r(){var e=this;this.dbs={},this.createStore=function(t){return w(e,void 0,void 0,function(){return P(this,function(n){switch(n.label){case 0:return[4,tr(t,1,{upgrade:function(i){i.objectStoreNames.contains("sessionTargetingMatch")||i.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,n.sent()]}})})},this.openOrCreateDB=function(t){return w(e,void 0,void 0,function(){var n,i;return P(this,function(s){switch(s.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(n="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(n)]);case 1:return i=s.sent(),this.dbs[t]=i,[2,i]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,i=t.apiKey,s=t.sessionId;return w(e,void 0,void 0,function(){var o,l,a,u;return P(this,function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return o=f.sent(),l=String(s),[4,o.get("sessionTargetingMatch",l)];case 2:return a=f.sent(),[2,a?.targetingMatch];case 3:return u=f.sent(),Z(n,"Failed to get targeting match for session id ".concat(s,": ").concat(u),u),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,i=t.apiKey,s=t.sessionId,o=t.targetingMatch;return w(e,void 0,void 0,function(){var l,a,u,f;return P(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return l=c.sent(),a=String(s),[4,l.put("sessionTargetingMatch",{targetingMatch:o,sessionId:a,lastUpdated:Date.now()})];case 2:return u=c.sent(),[2,u];case 3:return f=c.sent(),Z(n,"Failed to store targeting match for session id ".concat(s,": ").concat(f),f),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,i=t.apiKey,s=t.currentSessionId;return w(e,void 0,void 0,function(){var o,l,a,u,f,c,d,v;return P(this,function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.openOrCreateDB(i)];case 1:return o=h.sent(),l=String(s),a=o.transaction("sessionTargetingMatch","readwrite"),[4,a.store.getAll()];case 2:u=h.sent(),f=0,h.label=3;case 3:return f<u.length?(c=u[f],d=Date.now()-c.lastUpdated,c.sessionId!==l&&d>ri?[4,a.store.delete(c.sessionId)]:[3,5]):[3,6];case 4:h.sent(),h.label=5;case 5:return f++,[3,3];case 6:return[4,a.done];case 7:return h.sent(),[3,9];case 8:return v=h.sent(),Z(n,"Failed to clear old targeting matches for sessions: ".concat(v),v),[3,9];case 9:return[2]}})})}}return r})(),ze=new ni,ii=function(r){var e=r.sessionId,t=r.targetingConfig,n=r.loggerProvider,i=r.apiKey,s=r.targetingParams,o=r.urlChange,l=o===void 0?!1:o;return w(void 0,void 0,void 0,function(){var a,u,f,c,d,v,h;return P(this,function(g){switch(g.label){case 0:return[4,ze.clearStoreOfOldSessions({loggerProvider:n,apiKey:i,currentSessionId:e})];case 1:return g.sent(),[4,ze.getTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e})];case 2:if(a=g.sent(),a===!0&&!l)return[2,!0];u=!0,g.label=3;case 3:return g.trys.push([3,6,,7]),[4,me(()=>__retry_dynamic_loader__(()=>import("./index-DZLcKekT.js")),__vite__mapDeps([0,1,2]))];case 4:return f=g.sent().evaluateTargeting,c=T(T({},s),{flag:t,sessionId:typeof e=="string"?parseInt(e,10):e,apiKey:i,loggerProvider:n}),[4,f(c)];case 5:return d=g.sent(),d&&d.sr_targeting_config&&(u=d.sr_targeting_config.key==="on"),ze.storeTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e,targetingMatch:u}),[3,7];case 6:return v=g.sent(),h=v,n.warn(h.message),[3,7];case 7:return[2,u]}})})},Pe=2654435761,we=2246822519,xt=3266489917,si=668265263,Ot=374761393;function de(r,e){return(r<<e|r>>>32-e)>>>0}function Ee(r,e){return r=r+Math.imul(e,we)>>>0,r=de(r,13),r=Math.imul(r,Pe)>>>0,r}function pe(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0}function oi(r){for(var e=[],t=0;t<r.length;t++){var n=r.charCodeAt(t);if(n>=55296&&n<=56319&&t+1<r.length){var i=r.charCodeAt(t+1);i>=56320&&i<=57343&&(n=(n-55296<<10)+(i-56320)+65536,t++)}n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<65536?e.push(224|n>>12,128|n>>6&63,128|n&63):e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63)}return new Uint8Array(e)}function ai(r,e){e===void 0&&(e=0);var t=oi(r),n=t.length,i,s=0;if(n>=16){for(var o=e+Pe+we>>>0,l=e+we>>>0,a=e>>>0,u=e-Pe>>>0;s<=n-16;)o=Ee(o,pe(t,s)),s+=4,l=Ee(l,pe(t,s)),s+=4,a=Ee(a,pe(t,s)),s+=4,u=Ee(u,pe(t,s)),s+=4;i=de(o,1)+de(l,7)+de(a,12)+de(u,18)>>>0}else i=e+Ot>>>0;for(i=i+n>>>0;s<=n-4;)i=i+Math.imul(pe(t,s),xt)>>>0,i=Math.imul(de(i,17),si)>>>0,s+=4;for(;s<n;)i=i+Math.imul(t[s],Ot)>>>0,i=Math.imul(de(i,11),Pe)>>>0,s++;return i^=i>>>15,i=Math.imul(i,we)>>>0,i^=i>>>13,i=Math.imul(i,xt)>>>0,i^=i>>>16,i>>>0}
2function li(r,e){var t=ai(r.toString()),n=t%1e6;return n/1e6<e}var Ge="__amplitude_url_tracking_patched__",Dt=new WeakMap;function dr(r,e,t){if(t===void 0&&(t={}),!r?.location)return function(){};var n=t.enablePolling,i=n===void 0?!1:n,s=t.pollingInterval,o=s===void 0?at:s;if(i){var l=function(){var b;return(b=r.location.href)!==null&&b!==void 0?b:""},a=l(),u=r.setInterval(function(){var b=l();b!==a&&(a=b,e(b))},o);return function(){u!=null&&r.clearInterval(u)}}var f=Dt.get(r);if(!f){var c=void 0,d=new Set,v=function(){var b;return(b=r.location.href)!==null&&b!==void 0?b:""},h=function(){var b=v();c!==void 0&&b===c||(c=b,d.forEach(function(M){return M(b)}))},g=function(b){var M=function(){for(var D=[],x=0;x<arguments.length;x++)D[x]=arguments[x];var q=b.apply(this,D);return h(),q};return M[Ge]=!0,M},m=r.history;if(m?.pushState){var p=Reflect.get(m,"pushState");p[Ge]||(m.pushState=g(p))}if(m?.replaceState){var y=Reflect.get(m,"replaceState");y[Ge]||(m.replaceState=g(y))}f={callbacks:d,notify:h,onPopStateOrHashChange:function(){return h()},listenersAttached:!1},Dt.set(r,f)}var S=f;return S.listenersAttached||(r.addEventListener("popstate",S.onPopStateOrHashChange),r.addEventListener("hashchange",S.onPopStateOrHashChange),S.listenersAttached=!0),S.callbacks.add(e),function(){S.callbacks.delete(e),S.callbacks.size===0&&S.listenersAttached&&(r.removeEventListener("popstate",S.onPopStateOrHashChange),r.removeEventListener("hashchange",S.onPopStateOrHashChange),S.listenersAttached=!1)}}function fr(r){return r===void 0&&(r={}),{name:"amplitude/url-tracking@1",observer:function(e,t,n){var i,s,o,l=T(T({},r),n),a=l.ugcFilterRules||[],u=(i=l.enablePolling)!==null&&i!==void 0?i:!1,f=(s=l.pollingInterval)!==null&&s!==void 0?s:at,c=(o=l.captureDocumentTitle)!==null&&o!==void 0?o:!1;if(!t)return function(){};var d=void 0,v=function(){return t.location&&t.location.href||""},h=function(){var p=t.innerHeight,y=t.innerWidth,S=t.document,b=v(),M="";c&&(M=S?.title||"");var D=a.length>0?Re(b,a):b;return{href:D,title:M,viewportHeight:p,viewportWidth:y,type:"url-change-event"}},g=function(){var p=v();if(d===void 0||p!==d){d=p;var y=h();e(y)}},m=dr(t,function(){return g()},u?{enablePolling:!0,pollingInterval:f}:{});return g(),function(){return m()}},options:r}}fr();function ui(){try{var r=G();return r?r.parent!==r:!1}catch{return!0}}var ci=(function(){function r(){this.pendingLoadListeners=new Map}return r.prototype.start=function(){var e=this,t;(t=this.mutationObserver)===null||t===void 0||t.disconnect();var n=G();n&&(this.sendToAllIframes({type:Ce,action:"start"}),this.mutationObserver=new MutationObserver(function(i){var s,o,l,a,u,f;try{for(var c=F(i),d=c.next();!d.done;d=c.next()){var v=d.value;try{for(var h=(l=void 0,F(Array.from(v.addedNodes))),g=h.next();!g.done;g=h.next()){var m=g.value;m instanceof HTMLIFrameElement?e.sendToIframeAfterLoad(m):m instanceof Element&&m.querySelectorAll("iframe").forEach(function(b){e.sendToIframeAfterLoad(b)})}}catch(b){l={error:b}}finally{try{g&&!g.done&&(a=h.return)&&a.call(h)}finally{if(l)throw l.error}}try{for(var p=(u=void 0,F(Array.from(v.removedNodes))),y=p.next();!y.done;y=p.next()){var m=y.value;if(m instanceof HTMLIFrameElement){var S=e.pendingLoadListeners.get(m);S&&(m.removeEventListener("load",S),e.pendingLoadListeners.delete(m))}}}catch(b){u={error:b}}finally{try{y&&!y.done&&(f=p.return)&&f.call(p)}finally{if(u)throw u.error}}}}catch(b){s={error:b}}finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(s)throw s.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},r.prototype.stop=function(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(t,n){n.removeEventListener("load",t)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:Ce,action:"stop"})},r.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:Ce,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},r.prototype.sendToAllIframes=function(e){var t=this,n=document.querySelectorAll("iframe");
2n.forEach(function(i){return t.sendToIframe(i,e)})},r.prototype.sendToIframe=function(e,t){var n;try{(n=e.contentWindow)===null||n===void 0||n.postMessage(t,"*")}catch{}},r})();function di(r){var e=G();if(!e)return function(){};var t=e.parent;function n(i){if(i.source===t){var s=i.data;s?.type===Ce&&(s.action==="start"?r.onStart():s.action==="stop"&&r.onStop())}}return e.addEventListener("message",n),function(){return e.removeEventListener("message",n)}}var fi=(function(){function r(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeCoordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=G();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){if(e.recordCancelCallback&&e.recordFunction)try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn("Failed to take full snapshot on focus:",t)}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var n;(n=e.eventCompressor)===null||n===void 0||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(i){i(t)})},this.evaluateTargetingAndCapture=function(t,n,i,s){return n===void 0&&(n=!1),i===void 0&&(i=!1),s===void 0&&(s=!1),w(e,void 0,void 0,function(){var o,l,a,u,f,c,d,v,h,g,m,p,y;return P(this,function(S){switch(S.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig)if(n)this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");else return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];return this.lastTargetingParams=t,o=this.config.targetingConfig,l=o&&!this.sessionTargetingMatch,l?(a=s?this.latestUrlChangeTargetingEvaluationId:void 0,u=t.event,u&&Object.values(yr).includes(u.event_type)&&(u=void 0),f=(p=(h=(v=t.page)===null||v===void 0?void 0:v.url)!==null&&h!==void 0?h:(m=(g=G())===null||g===void 0?void 0:g.location)===null||m===void 0?void 0:m.href)!==null&&p!==void 0?p:"",c=(y=t.page)!==null&&y!==void 0?y:f!==""?{url:f}:void 0,[4,ii({sessionId:this.identifiers.sessionId,targetingConfig:o,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:u,page:c},urlChange:s})]):[3,2];case 1:if(d=S.sent(),s&&a!==void 0&&a!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(a,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||d,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:u,targetingParams:t},null,2)),S.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return i||!this.recordCancelCallback?(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]):[3,5];case 4:S.sent(),S.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,i){return n===void 0&&(n={}),i===void 0&&(i=!0),w(e,void 0,void 0,function(){var s,o,l,a;return P(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),s=void 0,o=this.config,o&&t!==se.METADATA?(s={config:Yt(o),version:Me},i?[4,Jt()]:[3,2]):[3,2];case 1:l=u.sent(),s=T(T({},l),s),u.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,T(T({},n),s)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return a=u.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",a),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t,n,i;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,(t=e.networkObservers)===null||t===void 0||t.stop(),(n=e.crossOriginIframeC
2oordinator)===null||n===void 0||n.stop(),e.crossOriginIframeCoordinator=null,(i=e.crossOriginParentSignalCleanup)===null||i===void 0||i.call(e),e.crossOriginParentSignalCleanup=null}catch(o){var s=o;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(s.toString()))}},this.loggerProvider=new $e(new He)}return r.prototype.init=function(e,t){return ht(this._init(e,t))},r.prototype.setupUrlChangeListener=function(){var e=this,t,n;(t=this.urlChangeCleanup)===null||t===void 0||t.call(this);var i=G();if(i?.location){var s=!!(!((n=this.config)===null||n===void 0)&&n.targetingConfig),o=function(a){if(e.currentPageUrl=a,s){var u=++e.latestUrlChangeTargetingEvaluationId;e.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:a}},!1,!1,!0),e.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(u," for ").concat(a,"."))}},l=dr(i,o);this.urlChangeCleanup=function(){l(),e.urlChangeCleanup=null}}},r.prototype.isBelowMinSessionDuration=function(){var e,t=(e=this.config)===null||e===void 0?void 0:e.minSessionDurationMs;return t===void 0||this.sessionStartTime===void 0?!1:Date.now()-this.sessionStartTime<t},r.prototype.getCurrentPageForTargeting=function(){var e,t,n=(t=(e=G())===null||e===void 0?void 0:e.location)===null||t===void 0?void 0:t.href;return n!=null?{url:n}:void 0},r.prototype._init=function(e,t){var n,i,s,o,l,a,u,f,c,d,v,h,g,m;return w(this,void 0,void 0,function(){var p,y,S,b,M,D,x,q,O,A,_,E,I,k,L,R,W,z,N,U,C,z,X,K,j,J,H,$,Y,ee,ae,le,te=this;return P(this,function(Q){switch(Q.label){case 0:return(n=this.urlChangeCleanup)===null||n===void 0||n.call(this),this.loggerProvider=new $e(t.loggerProvider||new He),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.currentPageUrl=et(),this.identifiers=new Lt({sessionId:t.sessionId,deviceId:t.deviceId}),p=Date.now(),ti(e,p,this.loggerProvider),this.sessionStartTime=t.sessionId!==void 0&&(i=Zn(e,t.sessionId,p,this.loggerProvider))!==null&&i!==void 0?i:p,y=this,[4,nn(e,t)];case 1:return y.joinedConfigGenerator=Q.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return S=Q.sent(),b=S.joinedConfig,M=S.localConfig,D=S.remoteConfig,this.config=b,this.setMetadata(t.sessionId,b,M,D,(s=t.version)===null||s===void 0?void 0:s.version,Me,(o=t.version)===null||o===void 0?void 0:o.type),this.pageLeaveFns=[],t.sessionId&&(!((l=this.config.interactionConfig)===null||l===void 0)&&l.enabled)&&(x=Qn.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[x.send(this.getDeviceId.bind(this)).bind(x)],this.scrollHook=x.hook.bind(x),this.clickHandler=new Hn(this.loggerProvider,x)),q=[],O=this.config.storeType,O==="idb"&&!(!((a=G())===null||a===void 0)&&a.indexedDB)&&(O="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(O," for event storage.")),E=G(),this.config.useWebWorker&&E&&E.Worker?[4,me(()=>__retry_dynamic_loader__(()=>import("./index-VFFfQseQ.js")),[])]:[3,4];case 3:I=Q.sent(),k=I.compressionScript,L=I.trackDestinationScript,A=k,_=L,Q.label=4;case 4:return Q.trys.push([4,6,,7]),[4,Tt({config:this.config,type:"replay",minInterval:(u=this.config.flushIntervalConfig)===null||u===void 0?void 0:u.minIntervalMs,maxInterval:(f=this.config.flushIntervalConfig)===null||f===void 0?void 0:f.maxIntervalMs,storeType:O,trackDestinationWorkerScript:_,shouldSend:function(){return!te.isBelowMinSessionDuration()}})];case 5:return R=Q.sent(),this.rrwebEventManager=R,q.push({name:"replay",manager:R}),[3,7];case 6:return W=Q.sent(),z=W,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(z.toString())),[3,7];case 7:if(!(!((c=this.config.interactionConfig)===null||c===void 0)&&c.enabled))return[3,11];N=this.config.interactionConfig.batch?Vn:Gn,Q.label=8;case 8:return Q.trys.push([8,10,,11]),[4,Tt({config:this.config,type:"interaction",minInterval:(d=this.config.interactionConfig.trackEveryNms)!==null&&d!==void 0?d:Nr,maxInterval:Ur,payloadBatcher:N,storeType:O,trackDestinationWorkerScript:_})];case 9:return U=Q.sent(),q.push({name:"interaction",manager:U}),[3,11];case 10:return C=Q.sent(),z=C,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(z.toString())),[3,11];case 11:if(this.eventsManager=new(Mt.bind.apply(Mt,V([void 0],B(q),!1))),this.eventCompressor&&this.eventCompressor.terminate(),this.eventCompressor=new ln(this.eventsManager,this.config,this.getDeviceId(),A,function(){return te.sendEvents()}),this.pendingEmitEvents.length>0){X=this.pendingEmitEvents.splice(0);try{for(K=F(X),j=K.next();!j.done;j=K.next())J=j.value,H=J.event,$=J.sessionId,this.eventCompressor.enqueueEvent(H,$)}catch(he){ae={error:he}}finally{try{j&&!j.done&&(le=K.return)&&le.call(K)}finally{if(ae)throw ae.error}}}return this.pageLeaveFns=V(V([],B(this.pageLeaveFns),!1),[function(){var he;if(!(!te.config||!(!((he=te.identifiers)===null||he===void 0)&&he.sessionId)||!R)){var ft=R.getBeaconEvents();if(ft.length){var vt=te.getDeviceId();vt&&(te.isBelowMinSessionDuration()||R.trackDestination.sendBeacon({events:ft,sessionId:te.identifiers.sessionId,deviceId:vt,apiKey:te.config.apiKey,serverZone:te.config.serverZone}))}}}],!1),[4,this.initializeNetworkObservers()];case 12:return Q.sent(),!((v=G())===null||v===void 0)&&v.opener&&(Y=Sr(),br(Y),Y.setup(T({logger:this.loggerProvider},this.config.serverZone&&{endpoint:Ir[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return Q.sent(),ee=this.config.targetingConfig||((m=(g=(h=this.config.privacyConfig)===null||h===void 0?void 0:h.urlMaskLevels)===null||g===void 0?void 0:g.length)!==null&&m!==void 0?m:0)>0,ee&&this.setupUrlChangeListener(),[2]}})})},r.prototype.setSessionId=function(e,t){return ht(this.asyncSetSessionId(e,t))},r.prototype.asyncSetSessionId=function(e,t,n){var i,s,o;return w(this,void 0,void 0,function(){var l,a,u,f;return P(this,function(c){switch(c.label){case 0:return this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,l=this.identifiers&&this.identifiers.sessionId,l&&this.sendEvents(l),a=l!==e,a&&((i=this.rrwebEventManager)===null||i===void 0||i.dropPendingBeaconEvents()),u=t||this.getDeviceId(),this.identifiers=new Lt({sessionId:e,deviceId:u}),a&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,!((s=this.config)===null||s===void 0)&&s.apiKey&&($n(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),l!==void 0&&ei(this.config.apiKey,l,this.loggerProvider))),this.joinedConfigGenerator&&l?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2];case 1:f=c.sent().joinedConfig,this.config=f,c.label=2;case 2:return!((o=this.config)===null||o===void 0)&&o.targetingConfig?[4,this.evaluateTargetingAndCapture({userProperties:n?.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return c.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:c.sent(),c.label=6;case 6:return[2]}})})},r.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var i=this.getShouldRecord(),s={};return i&&(s=(e={},e[_r]=n.sessionReplayId?n.sessionReplayId:null,e),t.debugMode&&(s[Dr]=JSON.stringify({appHash:gt(t.apiKey).toString()}))),this.addCustomRRWebEvent(se.GET_SR_PROPS,{shouldRecord:i,eventProperties:s},this.eventCount===10),this.eventCount===10&&(this.eventCount=0),this.eventCount++,s},r.prototype.sendEvents=function(e){var t,n,i=e||((t=this.identifiers)===null||t===void 0?void 0:t.sessionId),s=this.getDeviceId();if(this.eventsManager&&i&&s){if(this.isBelowMinSessionDuration()){var o=this.sessionStartTime,l=this.config.minSessionDurationMs;this.loggerProvider.log("Session ".concat(i," not sent: duration ").concat(Date.now()-o,"ms is below minimum ").concat(l,"ms.")),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&((n=this.config)===null||n===void 0?void 0:n.minSessionDurationMs)!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var a=this.sessionStartTime!==void 0?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent(se.REPLAY_GATE_DECISION,{sessionId:i,suppressedSendCount:this.suppressedSendCount,elapsedMs:a,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:i,deviceId:s})}},r.prototype.initialize=function(e){var t;return e===void 0&&(e=!1),w(this,void 0,void 0,function(){var n;return P(this,function(i){return!((t=this.identifiers)===null||t===void 0)&&t.sessionId?(n=this.getDeviceId(),n?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()])):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},r.prototype.shouldOptOut=function(){var e,t,n;if(!((e=this.config)===null||e===void 0)&&e.instanceName){var i=Er(this.config.instanceName).identityStore;n=i.getIdentity().optOut}return n!==void 0?n:(t=this.config)===null||t===void 0?void 0:t.optOut},r.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e=!1,t="",n=!1;if(this.config.targetingConfig)this.sessionTargetingMatch?(t="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(t),e=!0,n=!0):(t="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(t),e=!1,n=!1);else{var i=li(this.identifiers.sessionId,this.config.sampleRate);i?(e=!0,n=!0):(t="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(t),e=!1,n=!1)}return this.lastShouldRecordDecision!==e&&this.config.targetingConfig&&(this.addCustomRRWebEvent(se.TARGETING_DECISION,{message:t,sessionId:this.identifiers.sessionId,matched:n,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=e),e},r.prototype.getBlockSelectors=function(){var e,t,n,i=(n=(t=(e=this.config)===null||e===void 0?void 0:e.privacyConfig)===null||t===void 0?void 0:t.blockSelector)!==null&&n!==void 0?n:[];if(i.length!==0)return i},r.prototype.getMaskTextSelectors=function(){var e,t,n=(e=this.config)===null||e===void 0?void 0:e.privacyConfig,i=n?Ht(this.currentPageUrl,n):void 0;if(i==="conservative"||!((t=n?.urlMaskLevels)===null||t===void 0)&&t.some(function(l){return l.maskLevel==="conservative"}))return"*";var s=n?.urlMaskLevels;if(n?.defaultMaskLevel==="conservative"&&s&&s.length>0)return"*";var o=n?.maskSelector;if(o)return o},r.prototype.getRecordingPlugins=function(e){var t,n,i,s,o,l;return w(this,void 0,void 0,function(){var a,u,f,c;return P(this,function(d){switch(d.label){case 0:a=[];try{u=fr({ugcFilterRules:((n=(t=this.config)===null||t===void 0?void 0:t.interactionConfig)===null||n===void 0?void 0:n.ugcFilterRules)||[],enablePolling:((i=this.config)===null||i===void 0?void 0:i.enableUrlChangePolling)||!1,pollingInterval:(s=this.config)===null||s===void 0?void 0:s.urlChangePollingInterval,captureDocumentTitle:(o=this.config)===null||o===void 0?void 0:o.captureDocumentTitle}),a.push(u)}catch(v){this.loggerProvider.warn("Failed to create URL tracking plugin:",v)}if(!(!((l=e?.console)===null||l===void 0)&&l.enabled))return[3,4];d.label=1;case 1:return d.trys.push([1,3,,4]),[4,me(()=>__retry_dynamic_loader__(()=>import("./rrweb-plugin-console-record-sPdhR0i8.js")),[])];case 2:return f=d.sent().getRecordConsolePlugin,a.push(f({level:e.console.levels})),[3,4];case 3:return c=d.sent(),this.loggerProvider.warn("Failed to load console plugin:",c),[3,4];case 4:return[2,a.length>0?a:void 0]}})})},r.prototype.getRecordFunction=function(){return w(this,void 0,void 0,function(){var e,t;return P(this,function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,me(()=>__retry_dynamic_loader__(()=>import("./rrweb-record-FZj7_RZS.js")),[])];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];case 3:return t=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}})})},r.prototype.recordEvents=function(e){return e===void 0&&(e=!0),w(this,void 0,void 0,function(){var t;return P(this,function(n){switch(n.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,n.label=1;case 1:return n.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:n.sent(),n.label=3;case 3:return this.recordEventsPendingShouldLogMetadata===null?[3,5]:(t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)]);case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},r.prototype._recordEvents=function(e){var t,n,i,s,o,l,a,u;return e===void 0&&(e=!0),w(this,void 0,void 0,function(){var f,c,d,v,h,g,m,p,y,S,b,M,D,x,q,O,A,_,E,I=this;return P(this,function(k){switch(k.label){case 0:return f=this.config,c=this.getShouldRecord(),d=(t=this.identifiers)===null||t===void 0?void 0:t.sessionId,!c||!d||!f?[2]:(this.stopRecordingEvents(),[4,this.getRecordFunction()]);case 1:return v=k.sent(),v?[4,this.initializeNetworkObservers()]:[2];case 2:k.sent(),h=(n=f.loggingConfig)===null||n===void 0?void 0:n.network,g=Te(f.serverZone,f.trackServerUrl),m=[Kt,jt,zt,g],(i=this.networkObservers)===null||i===void 0||i.start(function(L){m.some(function(R){return L.url.startsWith(R)})||I.addCustomRRWebEvent(se.FETCH_REQUEST,L)},h),p=f.interactionConfig,y=f.loggingConfig,S=p?.enabled?{mouseInteraction:this.eventsManager&&((s=this.clickHandler)===null||s===void 0?void 0:s.createHook({eventsManager:this.eventsManager,sessionId:d,deviceIdFn:this.getDeviceId.bind(this),mirror:v.mirror,ugcFilterRules:(o=p.ugcFilterRules)!==null&&o!==void 0?o:[],performanceOptions:(l=f.performanceConfig)===null||l===void 0?void 0:l.interaction})),scroll:this.scrollHook}:{},b=p?.enabled&&p.ugcFilterRules?p.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(d,".")),k.label=3;case 3:return k.trys.push([3,5,,6]),M=!!(!((a=f.crossOriginIframes)===null||a===void 0)&&a.enabled),D=((u=f.crossOriginIframes)===null||u===void 0?void 0:u.coordinateChildren)!==!1,x=M&&ui(),x&&D?(this.crossOriginParentSignalCleanup=di({onStart:function(){return I._recordEventsInChildMode(v,d,f,S)},onStop:function(){try{I.recordCancelCallback&&I.recordCancelCallback(),I.recordCancelCallback=null}catch(R){var L=R;I.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(L.toString()))}}}),[2]):(q=this,O=v,A=[T({},this.buildRRWebRecordOptions(f,S,function(L){if(I.shouldOptOut()){I.loggerProvider.log("Opting session ".concat(d," out of recording due to optOut config.")),I.stopRecordingEvents(),I.sendEvents();return}L.type===ke.Meta&&(L.data.href=Re(L.data.href,b)),I.eventCompressor?I.eventCompressor.enqueueEvent(L,d):I.pendingEmitEvents.push({event:L,sessionId:d})},"Error while capturing replay: "))],E={},[4,this.getRecordingPlugins(y)]);case 4:return q.recordCancelCallback=O.apply(void 0,[T.apply(void 0,A.concat([(E.plugins=k.sent(),E.recordCrossOriginI
2frames=M,E)]))]),M&&!x&&D&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new ci),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(se.DEBUG_INFO),e&&this.addCustomRRWebEvent(se.METADATA,this.metadata),[3,6];case 5:return _=k.sent(),this.loggerProvider.warn("Failed to initialize session replay:",_),[3,6];case 6:return[2]}})})},r.prototype.buildRRWebRecordOptions=function(e,t,n,i){var s=this,o=e.privacyConfig;return T(T({emit:n,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:Bt,blockClass:Fr,blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:mt("input",o,function(){return s.currentPageUrl}),maskTextFn:mt("text",o,function(){return s.currentPageUrl}),maskAttributeFn:Xr(o,function(){return s.currentPageUrl}),maskTextSelector:this.getMaskTextSelectors()},e.fullSnapshotIntervalMs!==void 0&&{checkoutEveryNms:e.fullSnapshotIntervalMs}),{recordCanvas:!1,captureAdoptedStyleSheets:e.captureAdoptedStyleSheets,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},errorHandler:function(l){var a=l;if(a.message.includes("insertRule")&&a.message.includes("CSSStyleSheet")||a._external_)throw a;return s.loggerProvider.warn(i,a.toString()),!0}})},r.prototype._recordEventsInChildMode=function(e,t,n,i){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e(T(T({},this.buildRRWebRecordOptions(n,i,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t,"."))}catch(s){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",s)}},r.prototype.getDeviceId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.deviceId},r.prototype.getSessionId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.sessionId},r.prototype.flush=function(e){var t;return e===void 0&&(e=!1),w(this,void 0,void 0,function(){return P(this,function(n){return[2,(t=this.eventsManager)===null||t===void 0?void 0:t.flush(e)]})})},r.prototype.shutdown=function(){var e,t;(e=this.urlChangeCleanup)===null||e===void 0||e.call(this),(t=this.crossOriginParentSignalCleanup)===null||t===void 0||t.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},r.prototype.mapSDKType=function(e){return e==="plugin"?"@amplitude/plugin-session-replay-browser":e==="segment"?"@amplitude/segment-session-replay-plugin":null},r.prototype.setMetadata=function(e,t,n,i,s,o,l){var a=e?.toString()?gt(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:i,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(l),replaySDKVersion:s,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:o}},r.prototype.initializeNetworkObservers=function(){var e,t,n;return w(this,void 0,void 0,function(){var i,s;return P(this,function(o){switch(o.label){case 0:if(!(!((n=(t=(e=this.config)===null||e===void 0?void 0:e.loggingConfig)===null||t===void 0?void 0:t.network)===null||n===void 0)&&n.enabled&&!this.networkObservers))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,me(()=>__retry_dynamic_loader__(()=>import("./observers-B1krqqfk.js")),__vite__mapDeps([3,1,2]))];case 2:return i=o.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return s=o.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",s),[3,4];case 4:return[2]}})})},r})(),ce=function(r){return function(){var e=r.config,t=e||Zt(),n=t.loggerProvider,i=t.logLevel;return{logger:n,logLevel:i}}},vi=function(){var r=new fi;return{init:ue(r.init.bind(r),"init",ce(r)),evaluateTargetingAndCapture:ue(r.evaluateTargetingAndCapture.bind(r),"evaluateTargetingAndRecord",ce(r)),setSessionId:ue(r.setSessionId.bind(r),"setSessionId",ce(r)),getSessionId:ue(r.getSessionId.bind(r),"getSessionId",ce(r)),getSessionReplayProperties:ue(r.getSessionReplayProperties.bind(r),"getSessionReplayProperties",ce(r)),flush:ue(r.flush.bind(r),"flush",ce(r)),shutdown:ue(r.shutdown.bind(r),"shutdown",ce(r))}};const ye=vi();var hi=ye.init,Ft=ye.setSessionId,At=ye.getSessionId,Ve=ye.getSessionReplayProperties,gi=ye.shutdown,Nt="1.14.0",pi=(function(){function r(e){this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.options=T({forceSessionTracking:!1},e)}return r.prototype.setup=function(e,t){var n,i,s,o,l;return w(this,void 0,void 0,function(){var a;return P(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),e?.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(Nt,".")),this.config=e,this.options.forceSessionTracking&&(typeof e.defaultTracking=="boolean"?e.defaultTracking===!1&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=T(T({},e.defaultTracking),{sessions:!0})),[4,hi(e.apiKey,{instanceName:this.config.instanceName,deviceId:(n=this.options.deviceId)!==null&&n!==void 0?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl,trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:(i=this.options.privacyConfig)===null||i===void 0?void 0:i.blockSelector,maskSelector:(s=this.options.privacyConfig)===null||s===void 0?void 0:s.maskSelector,unmaskSelector:(o=this.options.privacyConfig)===null||o===void 0?void 0:o.unmaskSelector,defaultMaskLevel:(l=this.options.privacyConfig)===null||l===void 0?void 0:l.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:Nt},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,experimental:this.options.experimental}).promise];case 1:return u.sent(),[3,3];case 2:return a=u.sent(),e?.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(a.message)),[3,3];case 3:return[2]}})})},r.prototype.execute=function(e){var t;return w(this,void 0,void 0,function(){var n,i,n,i,s;return P(this,function(o){switch(o.label){case 0:return o.trys.push([0,8,,9]),this.options.customSessionId?(n=this.options.customSessionId(e),n?n===At()?[3,2]:[4,Ft(n).promise]:[3,3]):[3,4];case 1:o.sent(),o.label=2;case 2:i=Ve(),e.event_properties=T(T({},e.event_properties),i),o.label=3;case 3:return[3,7];case 4:return n=this.config.sessionId,n&&n!==At()?[4,Ft(n).promise]:[3,6];case 5:o.sent(),o.label=6;case 6:n&&n===e.session_id&&(i=Ve(),e.event_properties=T(T({},e.event_properties),i)),o.label=7;case 7:return[2,Promise.resolve(e)];case 8:return s=o.sent(),(t=this.config)===null||t===void 0||t.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(s.message)),[2,Promise.resolve(e)];case 9:return[2]}})})},r.prototype.teardown=function(){var e;return w(this,void 0,void 0,function(){return P(this,function(t){try{gi(),this.config=null}catch(n){(e=this.config)===null||e===void 0||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(n.message))}return[2]})})},r.prototype.getSessionReplayProperties=function(){return Ve()},r})(),Ut=function(r){return new pi(r)};const Si=Object.freeze(Object.defineProperty({__proto__:null,plugin:Ut,sessionReplayPlugin:Ut},Symbol.toStringTag,{value:"Module"}));
2export{Si as i,tr as o};

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