@flashlog/tracker-sdk 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (function(se,Re){typeof exports=="object"&&typeof module<"u"?Re(exports):typeof define=="function"&&define.amd?define(["exports"],Re):(se=typeof globalThis<"u"?globalThis:se||self,Re(se.FlashlogBugTracker={}))})(this,function(se){"use strict";const Re=e=>{const t=e.trim();return t.length>0?t:null},Er=()=>{if(typeof window>"u")return null;const{hostname:e,protocol:t}=window.location;return e==="localhost"||e==="127.0.0.1"?`${t}//${e}:3008/api`:null},Tr=()=>{const e=Re("https://api.flashlog.app/api");if(e)return e;const t=Er();return t||"https://api.flashlog.app/api"},gt=new Set(["NETWORK_ERROR","SOCKET_ERROR","JS_ERROR","UNHANDLED_REJECTION","MANUAL_ERROR"]),We=["password","passwd","authorization","credentials","secret","token","jwt","cookie","session","csrf","passcode","otp","apiKey","accessToken","refreshToken","clientSecret","privateKey","authCode","verificationCode","sessionToken","sessionCookie","sessionSecret"],Rr=["password","passwd","authorization","secret","token","jwt","cookie","session","csrf","passcode","otp","apiKey","accessToken","refreshToken","clientSecret","privateKey","authCode","verificationCode","sessionToken","sessionCookie","sessionSecret"],v={apiUrl:Tr(),apiKey:"",debug:!1,autoCapture:!0,captureNetworkErrors:!0,captureJsErrors:!0,captureSocketErrors:!0,sessionTimeoutMs:30*60*1e3,maxActionBufferSize:50,allowNonErrorEvents:!1,captureRequestBody:!0,captureResponseBody:!0,redactKeys:We,redactUrlParams:Rr,propagateTraceHeaders:!1,traceOrigins:[],traceHeaderName:"x-flashlog-trace-id",enableSessionReplay:!0,replayFlushIntervalMs:4e4,replayMaxSegmentBytes:512*1024,replayMaxSegmentEvents:400,replayMaskAllInputs:!0,ignoredStatusCodes:[401,403],ignoredUrls:["/api/v1/integration/webhook","/api/v1/tracking-issues","/api/v1/session-replays/public/segments/upload-url","/api/v1/session-replays/public/local-upload/","/api/v1/session-replays/public/finalize","tracking.api.founder-os.ai/api/v2/tracking-session-data","googletagmanager.com","google-analytics.com","clarity.ms","facebook.com/tr"]},N={sessionId:"flashlog_tracker_session_id",sessionSeenAt:"flashlog_tracker_session_seen_at",deviceId:"flashlog_tracker_device_id",accountId:"flashlog_tracker_account_id",accountTraits:"flashlog_tracker_account_traits"},_r=e=>{if(e.scriptUrl)return e.scriptUrl;if(e.source==="package")return"package:@flashlog/tracker-sdk"},yt=async e=>{if(typeof window>"u"||typeof document>"u")return;const t=Number(e.brandId);if(!Number.isFinite(t)||t<=0)return;const r=`${(e.apiUrl||v.apiUrl).replace(/\/$/,"")}/v1/tracking-events/public/script-installations/ping`;try{const n=await fetch(r,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","x-api-key":e.apiKey},body:JSON.stringify({brand_id:t,url:window.location.href,referrer:document.referrer||void 0,script_url:_r(e)})});!n.ok&&e.debug&&console.warn("[FlashlogTracker] Installation ping failed",{status:n.status})}catch(n){e.debug&&console.warn("[FlashlogTracker] Installation ping error",n)}},ce="[redacted]",It="[omitted by privacy config]",ze=e=>{const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").trim().toLowerCase();return t?t.split(/\s+/):[]},Nr=(e,t)=>{if(t.length===0||t.length>e.length)return!1;for(let r=0;r<=e.length-t.length;r+=1)if(t.every((s,i)=>e[r+i]===s))return!0;return!1},_e=(e,t)=>{const r=ze(e);if(r.length===0)return!1;const n=r.join("");return t.some(s=>{const i=ze(s);return i.length===0?!1:i.length===1?r.includes(i[0]):n===i.join("")||Nr(r,i)})},Ct=(e,t)=>e?ze(e).join("")===t:!1,Mr=e=>e?ze(e).includes("url"):!1,Or=e=>{const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{const r=JSON.parse(e);return r&&typeof r=="object"?r:null}catch{return null}},St=(e,t)=>{let r=e.replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,`$1${ce}`).replace(/\b(Basic\s+)[A-Za-z0-9+/=-]+/gi,`$1${ce}`).replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,ce);return r!==e&&(t.redactedFieldsCount+=1),r},bt=e=>St(e,{redactedFieldsCount:0}),Lr=(e,t,r)=>{try{const n=e.startsWith("/"),s=new URL(e,"https://flashlog.local");let i=!1;return s.searchParams.forEach((o,c)=>{_e(c,t.redactUrlParams)&&(s.searchParams.set(c,ce),i=!0)}),i?(r.redactedFieldsCount+=1,n?`${s.pathname}${s.search}${s.hash}`:s.toString()):e}catch{return e}},Fr=(e,t,r,n,s=new WeakSet)=>{if(Mr(n))return Lr(e,t,r);const i=Or(e);if(i!==null){const o=Ge(i,t,r,n,s);return JSON.stringify(o)}return St(e,r)},Ge=(e,t,r,n,s=new WeakSet)=>{if(Ct(n,"requestbody")&&!t.captureRequestBody||Ct(n,"responsebody")&&!t.captureResponseBody)return r.omittedFieldsCount+=1,It;if(n&&_e(n,t.redactKeys))return r.redactedFieldsCount+=1,ce;if(typeof e=="string")return Fr(e,t,r,n,s);if(Array.isArray(e))return e.map(i=>Ge(i,t,r,void 0,s));if(!e||typeof e!="object")return e;if(s.has(e))return r.redactedFieldsCount+=1,ce;s.add(e);try{return Object.entries(e).reduce((i,[o,c])=>(i[o]=Ge(c,t,r,o,s),i),{})}finally{s.delete(e)}},xr=(e,t)=>{const r={redactedFieldsCount:0,omittedFieldsCount:0},n=Ge(e.data,t,r),s=n.privacy&&typeof n.privacy=="object"?n.privacy:{};return{...e,data:{...n,privacy:{...s,client_redaction:!0,redacted:r.redactedFieldsCount>0,redacted_fields_count:r.redactedFieldsCount,omitted_fields_count:r.omittedFieldsCount,request_body_capture:t.captureRequestBody?"redacted":"off",response_body_capture:t.captureResponseBody?"redacted":"off"}}}},Br=()=>typeof window<"u"&&window.location?window.location.href:"",Dr=120,vt=(e,t=Dr)=>e.length>t?e.slice(0,t):e,Qe=e=>{const t=e==null?void 0:e.trim();if(t)return vt(bt(t))},wt=e=>{const r=bt(e).split(/([_:.=-])/),n=r.map((s,i)=>{if(!s||/^[_:.=-]$/.test(s))return s;const c=`${i>=2?r[i-2]:""} ${s}`;return _e(s,We)||_e(c,We)?ce:s});return vt(n.join(""),80)},$e=e=>{if(!e)return"";if(e.id)return`#${wt(e.id)}`;const t=[];let r=e;for(;r&&t.length<5;){const n=typeof r.className=="string"?r.className.trim().split(/\s+/).slice(0,2).map(wt).join("."):"";t.unshift(`${r.tagName.toLowerCase()}${n?`.${n}`:""}`),r=r.parentElement}return t.join(" > ")},Ur=e=>[e.getAttribute("name"),e.getAttribute("id"),e.getAttribute("aria-label"),e.getAttribute("placeholder"),e.getAttribute("autocomplete"),e.getAttribute("type")].filter(Boolean).join(" "),Wr=e=>{const t=Ur(e);return(e.getAttribute("type")||"").toLowerCase()==="password"||_e(t,We)},ge=(e,t)=>{const r=e==null?void 0:e.trim();if(r)return Wr(t)?ce:Qe(r)},zr=e=>{const t={tagName:e==null?void 0:e.tagName,selector:$e(e)};if(!e)return t;if(e instanceof HTMLSelectElement){const r=Array.from(e.selectedOptions),n=r.map(o=>ge(o.value,e)),s=r.map(o=>ge(o.text,e)),i=e.multiple;return{...t,value:i?n:n[0],text:i?s:s[0]}}if(e instanceof HTMLInputElement){const r=e.type.toLowerCase();return r==="checkbox"||r==="radio"?{...t,checked:e.checked,value:ge(e.value,e)}:{...t,value:ge(e.value,e)}}return e instanceof HTMLTextAreaElement?{...t,value:ge(e.value,e)}:e.isContentEditable?{...t,text:ge(e.innerText,e)}:{...t,text:Qe(e.innerText)}};class Gr{constructor(t){this.actions=[],this.detachHandlers=[],this.maxSize=t}start(){if(typeof window>"u"||typeof document>"u"||this.detachHandlers.length>0)return;const t=i=>{const o=i.target;this.add("CLICK",{tagName:o==null?void 0:o.tagName,text:Qe(o==null?void 0:o.innerText),selector:$e(o)})},r=i=>{const o=i.target;this.add("INPUT_CHANGE",zr(o))},n=i=>{const o=i.target;this.add("FORM_SUBMIT",{tagName:o==null?void 0:o.tagName,selector:$e(o)})},s=()=>{this.add("VISIBILITY_CHANGE",{text:typeof document<"u"?document.visibilityState:"unknown"})};document.addEventListener("click",t,!0),document.addEventListener("input",r,!0),document.addEventListener("submit",n,!0),document.addEventListener("visibilitychange",s,!0),this.detachHandlers=[()=>document.removeEventListener("click",t,!0),()=>document.removeEventListener("input",r,!0),()=>document.removeEventListener("submit",n,!0),()=>document.removeEventListener("visibilitychange",s,!0)]}stop(){this.detachHandlers.forEach(t=>t()),this.detachHandlers=[]}add(t,r){this.actions.push({action:t,details:r,timestamp:Date.now(),url:Br()}),this.actions.length>this.maxSize&&(this.actions=this.actions.slice(-this.maxSize))}getAll(){return[...this.actions]}clear(){this.actions=[]}}const Kr=e=>{const t=[{key:"edg/",name:"Edge"},{key:"chrome/",name:"Chrome"},{key:"firefox/",name:"Firefox"},{key:"safari/",name:"Safari"}],r=e.toLowerCase();for(const n of t){const s=r.indexOf(n.key);if(s>=0){const i=r.slice(s+n.key.length).split(/[^\d.]/)[0]||"unknown";return{name:n.name,version:i}}}return{name:"Unknown",version:"unknown"}},Vr=e=>{const t=e.toLowerCase();return t.includes("windows")?"Windows":t.includes("mac os")?"MacOS":t.includes("android")?"Android":t.includes("iphone")||t.includes("ipad")||t.includes("ios")?"iOS":t.includes("linux")?"Linux":"Unknown"},Pr=()=>{if(typeof window>"u")return"Unknown";const e=window.innerWidth||0;return e<=768?"Mobile":e<=1024?"Tablet":"Desktop"},At=e=>{const t=typeof navigator<"u"?navigator:{},r=t.userAgent||"",n=Kr(r);return{os_name:Vr(r),device_type:Pr(),device_id:e,browser_name:n.name,browser_version:n.version,screen_width:typeof screen<"u"?screen.width:0,screen_height:typeof screen<"u"?screen.height:0,viewport_width:typeof window<"u"?window.innerWidth:0,viewport_height:typeof window<"u"?window.innerHeight:0,language:t.language||"unknown",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||"unknown",user_agent:r.toLowerCase()}},kt=()=>{const e={online:typeof navigator<"u"?navigator.onLine:!0},t=typeof navigator<"u"?navigator:void 0,r=t==null?void 0:t.connection;return r&&(e.connection_type=r.effectiveType,e.downlink=r.downlink,e.rtt=r.rtt,e.save_data=r.saveData),e},et=typeof window<"u"&&window.location?window.location.origin:void 0,Et=e=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const r=new Uint8Array(e);return crypto.getRandomValues(r),Array.from(r,n=>n.toString(16).padStart(2,"0")).join("")}let t="";for(let r=0;r<e;r+=1)t+=Math.floor(Math.random()*256).toString(16).padStart(2,"0");return t},Ke=()=>{const e=Et(16),t=Et(8);return{trace_id:e,span_id:t,traceparent:`00-${e}-${t}-01`}},Zr=(e={})=>{const t=typeof e.trace_id=="string"&&e.trace_id.trim()?e.trace_id.trim():null,r=typeof e.span_id=="string"&&e.span_id.trim()?e.span_id.trim():null,n=typeof e.traceparent=="string"&&e.traceparent.trim()?e.traceparent.trim():null;return t&&r?{trace_id:t,span_id:r,traceparent:n||`00-${t}-${r}-01`}:Ke()},tt=(e,t)=>({traceparent:e.traceparent,[t]:e.trace_id}),Tt=(e,t)=>{if(!t.propagateTraceHeaders||!e)return!1;try{const r=new URL(e,et),n=t.traceOrigins.map(s=>s.trim()).filter(Boolean);return n.length===0?et?r.origin===et:!0:n.some(s=>s==="*"?!0:r.origin===s||r.href.startsWith(s))}catch{return!1}},Hr="[omitted: non-json body]";class jr{constructor(t,r){this.socketMeta=new WeakMap,this.initialized=!1,this.handleWindowError=n=>{var s;this.hooks.onJsError({message:n.message||"Unknown JS error",filename:n.filename||"",lineno:n.lineno||0,colno:n.colno||0,stack:((s=n.error)==null?void 0:s.stack)||"",timestamp:Date.now()})},this.handleUnhandledRejection=n=>{const s=n.reason,i=s instanceof Error?s.message:typeof s=="string"?s:"Unhandled rejection",o=s instanceof Error?s.stack:"";this.hooks.onUnhandledRejection({message:i,stack:o||"",timestamp:Date.now()})},this.config=t,this.hooks=r}start(){typeof window>"u"||this.initialized||(this.initialized=!0,this.config.captureNetworkErrors&&(this.interceptFetch(),this.interceptXhr()),this.config.captureSocketErrors&&this.interceptWebSocket(),this.config.captureJsErrors&&(window.addEventListener("error",this.handleWindowError,!0),window.addEventListener("unhandledrejection",this.handleUnhandledRejection,!0)))}stop(){typeof window>"u"||!this.initialized||(this.initialized=!1,this.originalFetch&&(window.fetch=this.originalFetch),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend),this.originalWebSocket&&(window.WebSocket=this.originalWebSocket),window.removeEventListener("error",this.handleWindowError,!0),window.removeEventListener("unhandledrejection",this.handleUnhandledRejection,!0))}shouldIgnoreUrl(t){return this.config.ignoredUrls.some(r=>t.includes(r))}shouldIgnoreStatus(t){return this.config.ignoredStatusCodes.includes(t)}truncate(t,r=3e3){if(t)return t.length<=r?t:`${t.slice(0,r)}... [truncated]`}getBodyType(t){var r,n;return t?typeof FormData<"u"&&t instanceof FormData?"FormData":typeof URLSearchParams<"u"&&t instanceof URLSearchParams?"URLSearchParams":typeof File<"u"&&t instanceof File?"File":typeof Blob<"u"&&t instanceof Blob?"Blob":typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?"ArrayBuffer":typeof ReadableStream<"u"&&t instanceof ReadableStream?"ReadableStream":typeof ArrayBuffer<"u"&&ArrayBuffer.isView(t)?((r=t.constructor)==null?void 0:r.name)||"ArrayBufferView":typeof t=="object"?((n=t.constructor)==null?void 0:n.name)||"Object":typeof t:"Unknown"}safeBodyPreview(t){if(t)return typeof t=="string"?t:JSON.stringify({body_type:this.getBodyType(t),captured:!1,reason:Hr})}attachTraceHeadersToFetchRequest(t,r,n,s){if(!Tt(n,this.config))return{input:t,init:r};if(t instanceof Request){const o=new Headers(t.headers);return new Headers(r==null?void 0:r.headers).forEach((a,d)=>{o.set(d,a)}),Object.entries(s).forEach(([a,d])=>{o.set(a,d)}),{input:new Request(t,{...r,headers:o})}}const i=new Headers(r==null?void 0:r.headers);return Object.entries(s).forEach(([o,c])=>{i.set(o,c)}),{input:t,init:{...r||{},headers:i}}}interceptFetch(){if(typeof window.fetch!="function")return;const t=this;this.originalFetch=window.fetch,window.fetch=async function(n,s){const i=Date.now(),o=(s==null?void 0:s.method)||"GET",c=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t.shouldIgnoreUrl(c))return t.originalFetch.call(window,n,s);const a=t.safeBodyPreview(s==null?void 0:s.body),d=Ke(),l=tt(d,t.config.traceHeaderName),u=t.attachTraceHeadersToFetchRequest(n,s,c,l);try{const p=await t.originalFetch.call(window,u.input,u.init),f=Date.now()-i;if((p.ok||t.shouldIgnoreStatus(p.status))&&t.hooks.onNetworkActivity({type:"fetch",url:c,method:o.toUpperCase(),status:p.status,statusText:p.statusText,duration_ms:f,trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),!p.ok&&p.status>=400&&!t.shouldIgnoreStatus(p.status)){let h;try{h=await p.clone().text()}catch{h="[unreadable]"}t.hooks.onNetworkError({type:"fetch",url:c,method:o.toUpperCase(),status:p.status,statusText:p.statusText,duration_ms:f,request_body:t.truncate(a),response_body:t.truncate(h),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()})}return p}catch(p){throw t.hooks.onNetworkError({type:"fetch",url:c,method:o.toUpperCase(),status:0,statusText:"NETWORK_ERROR",duration_ms:Date.now()-i,request_body:t.truncate(a),response_body:t.truncate(p instanceof Error?p.message:String(p)),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),p}}}interceptXhr(){const t=this;this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=function(n,s,i,o,c){const a=s instanceof URL?s.toString():String(s);return this.__flashlog_meta={method:(n||"GET").toUpperCase(),url:a},t.originalXhrOpen.call(this,n,s,i??!0,o??null,c??null)},XMLHttpRequest.prototype.send=function(n){const s=this,i=s.__flashlog_meta||{};if(t.shouldIgnoreUrl(i.url||""))return t.originalXhrSend.call(this,n);const o=Date.now(),c=t.safeBodyPreview(n),a=Ke(),d=tt(a,t.config.traceHeaderName);return Tt(i.url||"",t.config)&&Object.entries(d).forEach(([l,u])=>{try{s.setRequestHeader(l,u)}catch{t.hooks.debug&&console.warn("[FlashlogTracker] Failed to attach trace header",{key:l,url:i.url})}}),s.addEventListener("loadend",()=>{const l=s.status||0;(l>=200&&l<400||t.shouldIgnoreStatus(l))&&t.hooks.onNetworkActivity({type:"xhr",url:i.url,method:i.method||"GET",status:l,statusText:s.statusText||"HTTP_RESULT",duration_ms:Date.now()-o,trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()}),l>=400&&!t.shouldIgnoreStatus(l)&&t.hooks.onNetworkError({type:"xhr",url:i.url,method:i.method||"GET",status:l,statusText:s.statusText||"HTTP_ERROR",duration_ms:Date.now()-o,request_body:t.truncate(c),response_body:t.truncate(s.responseText||""),trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()})}),s.addEventListener("error",()=>{t.hooks.onNetworkError({type:"xhr",url:i.url,method:i.method||"GET",status:0,statusText:"NETWORK_ERROR",duration_ms:Date.now()-o,request_body:t.truncate(c),response_body:"XHR network error",trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()})}),t.originalXhrSend.call(this,n)}}interceptWebSocket(){if(typeof window.WebSocket!="function")return;const t=this;this.originalWebSocket=window.WebSocket;const r=this.originalWebSocket,n=function(i,o){const c=i instanceof URL?i.toString():String(i),a=o!==void 0?new r(i,o):new r(i);return t.shouldIgnoreUrl(c)||(t.socketMeta.set(a,{url:c,createdAt:Date.now(),openedAt:null}),a.addEventListener("open",()=>{const d=t.socketMeta.get(a);d&&(d.openedAt=Date.now())}),a.addEventListener("error",()=>{const d=t.socketMeta.get(a),l=(d==null?void 0:d.openedAt)||(d==null?void 0:d.createdAt)||Date.now();t.hooks.onSocketError({type:"websocket",phase:"error",url:(d==null?void 0:d.url)||c,method:"CONNECT",status:0,statusText:"WEBSOCKET_ERROR",duration_ms:Date.now()-l,timestamp:Date.now()})}),a.addEventListener("close",d=>{if(d.code===1e3||d.code===1001)return;const l=t.socketMeta.get(a),u=(l==null?void 0:l.openedAt)||(l==null?void 0:l.createdAt)||Date.now();t.hooks.onSocketError({type:"websocket",phase:"close",url:(l==null?void 0:l.url)||c,method:"CONNECT",status:0,socket_close_code:d.code,statusText:d.reason||"WEBSOCKET_CLOSED_ABNORMALLY",was_clean:d.wasClean,duration_ms:Date.now()-u,timestamp:Date.now()})})),a};n.prototype=r.prototype,Object.defineProperty(n,"CONNECTING",{value:r.CONNECTING}),Object.defineProperty(n,"OPEN",{value:r.OPEN}),Object.defineProperty(n,"CLOSING",{value:r.CLOSING}),Object.defineProperty(n,"CLOSED",{value:r.CLOSED}),window.WebSocket=n}}var F;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(F||(F={}));function Jr(e){return e.nodeType===e.ELEMENT_NODE}function Ne(e){var t=e==null?void 0:e.host;return(t==null?void 0:t.shadowRoot)===e}function Me(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function qr(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function rt(e){try{var t=e.rules||e.cssRules;return t?qr(Array.from(t).map(Rt).join("")):null}catch{return null}}function Rt(e){var t=e.cssText;if(Yr(e))try{t=rt(e.styleSheet)||t}catch{}return t}function Yr(e){return"styleSheet"in e}var _t=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var r;if(!t)return-1;var n=(r=this.getMeta(t))===null||r===void 0?void 0:r.id;return n??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var r=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(s){return r.removeNodeFromMap(s)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,r){var n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)},e.prototype.replace=function(t,r){var n=this.getNode(t);if(n){var s=this.nodeMetaMap.get(n);s&&this.nodeMetaMap.set(r,s)}this.idNodeMap.set(t,r)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Xr(){return new _t}function nt(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,s=e.value,i=e.maskInputFn,o=s||"";return(t[r.toLowerCase()]||t[n])&&(i?o=i(o):o="*".repeat(o.length)),o}var Nt="__rrweb_original__";function Qr(e){var t=e.getContext("2d");if(!t)return!0;for(var r=50,n=0;n<e.width;n+=r)for(var s=0;s<e.height;s+=r){var i=t.getImageData,o=Nt in i?i[Nt]:i,c=new Uint32Array(o.call(t,n,s,Math.min(r,e.width-n),Math.min(r,e.height-s)).data.buffer);if(c.some(function(a){return a!==0}))return!1}return!0}var $r=1,en=new RegExp("[^a-z0-9-_:]"),Oe=-2;function Mt(){return $r++}function tn(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return en.test(t)?"div":t}function rn(e){return e.cssRules?Array.from(e.cssRules).map(function(t){return t.cssText||""}).join(""):""}function nn(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var ye,Ot,sn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,on=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,an=/^(data:)([^,]*),(.*)/i;function Ve(e,t){return(e||"").replace(sn,function(r,n,s,i,o,c){var a=s||o||c,d=n||i||"";if(!a)return r;if(!on.test(a)||an.test(a))return"url(".concat(d).concat(a).concat(d,")");if(a[0]==="/")return"url(".concat(d).concat(nn(t)+a).concat(d,")");var l=t.split("/"),u=a.split("/");l.pop();for(var p=0,f=u;p<f.length;p++){var h=f[p];h!=="."&&(h===".."?l.pop():l.push(h))}return"url(".concat(d).concat(l.join("/")).concat(d,")")})}var cn=/^[^ \t\n\r\u000c]+/,dn=/^[, \t\n\r\u000c]+/;function ln(e,t){if(t.trim()==="")return t;var r=0;function n(d){var l,u=d.exec(t.substring(r));return u?(l=u[0],r+=l.length,l):""}for(var s=[];n(dn),!(r>=t.length);){var i=n(cn);if(i.slice(-1)===",")i=Ie(e,i.substring(0,i.length-1)),s.push(i);else{var o="";i=Ie(e,i);for(var c=!1;;){var a=t.charAt(r);if(a===""){s.push((i+o).trim());break}else if(c)a===")"&&(c=!1);else if(a===","){r+=1,s.push((i+o).trim());break}else a==="("&&(c=!0);o+=a,r+=1}}}return s.join(", ")}function Ie(e,t){if(!t||t.trim()==="")return t;var r=e.createElement("a");return r.href=t,r.href}function un(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function st(){var e=document.createElement("a");return e.href="",e.href}function Lt(e,t,r,n){return r==="src"||r==="href"&&n&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n&&n[0]!=="#"||r==="background"&&n&&(t==="table"||t==="td"||t==="th")?Ie(e,n):r==="srcset"&&n?ln(e,n):r==="style"&&n?Ve(n,st()):t==="object"&&r==="data"&&n?Ie(e,n):n}function hn(e,t,r){if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var s=e.classList[n];if(t.test(s))return!0}return r?e.matches(r):!1}function Pe(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Pe(e.parentNode,t,r):!1;for(var n=e.classList.length;n--;){var s=e.classList[n];if(t.test(s))return!0}return r?Pe(e.parentNode,t,r):!1}function Ft(e,t,r){var n=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(n===null)return!1;if(typeof t=="string"){if(n.classList.contains(t)||n.closest(".".concat(t)))return!0}else if(Pe(n,t,!0))return!0;return!!(r&&(n.matches(r)||n.closest(r)))}function pn(e,t,r){var n=e.contentWindow;if(n){var s=!1,i;try{i=n.document.readyState}catch{return}if(i!=="complete"){var o=setTimeout(function(){s||(t(),s=!0)},r);e.addEventListener("load",function(){clearTimeout(o),s=!0,t()});return}var c="about:blank";if(n.location.href!==c||e.src===c||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function fn(e,t,r){var n=!1,s;try{s=e.sheet}catch{return}if(!s){var i=setTimeout(function(){n||(t(),n=!0)},r);e.addEventListener("load",function(){clearTimeout(i),n=!0,t()})}}function mn(e,t){var r=t.doc,n=t.mirror,s=t.blockClass,i=t.blockSelector,o=t.maskTextClass,c=t.maskTextSelector,a=t.inlineStylesheet,d=t.maskInputOptions,l=d===void 0?{}:d,u=t.maskTextFn,p=t.maskInputFn,f=t.dataURLOptions,h=f===void 0?{}:f,y=t.inlineImages,S=t.recordCanvas,C=t.keepIframeSrcFn,m=t.newlyAddedElement,g=m===void 0?!1:m,k=gn(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:F.Document,childNodes:[],compatMode:e.compatMode}:{type:F.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:F.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:k};case e.ELEMENT_NODE:return In(e,{doc:r,blockClass:s,blockSelector:i,inlineStylesheet:a,maskInputOptions:l,maskInputFn:p,dataURLOptions:h,inlineImages:y,recordCanvas:S,keepIframeSrcFn:C,newlyAddedElement:g,rootId:k});case e.TEXT_NODE:return yn(e,{maskTextClass:o,maskTextSelector:c,maskTextFn:u,rootId:k});case e.CDATA_SECTION_NODE:return{type:F.CDATA,textContent:"",rootId:k};case e.COMMENT_NODE:return{type:F.Comment,textContent:e.textContent||"",rootId:k};default:return!1}}function gn(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function yn(e,t){var r,n=t.maskTextClass,s=t.maskTextSelector,i=t.maskTextFn,o=t.rootId,c=e.parentNode&&e.parentNode.tagName,a=e.textContent,d=c==="STYLE"?!0:void 0,l=c==="SCRIPT"?!0:void 0;if(d&&a){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(a=rn(e.parentNode.sheet))}catch(u){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u),e)}a=Ve(a,st())}return l&&(a="SCRIPT_PLACEHOLDER"),!d&&!l&&a&&Ft(e,n,s)&&(a=i?i(a):a.replace(/[\S]/g,"*")),{type:F.Text,textContent:a||"",isStyle:d,rootId:o}}function In(e,t){for(var r=t.doc,n=t.blockClass,s=t.blockSelector,i=t.inlineStylesheet,o=t.maskInputOptions,c=o===void 0?{}:o,a=t.maskInputFn,d=t.dataURLOptions,l=d===void 0?{}:d,u=t.inlineImages,p=t.recordCanvas,f=t.keepIframeSrcFn,h=t.newlyAddedElement,y=h===void 0?!1:h,S=t.rootId,C=hn(e,n,s),m=tn(e),g={},k=e.attributes.length,z=0;z<k;z++){var x=e.attributes[z];g[x.name]=Lt(r,m,x.name,x.value)}if(m==="link"&&i){var B=Array.from(r.styleSheets).find(function(q){return q.href===e.href}),T=null;B&&(T=rt(B)),T&&(delete g.rel,delete g.href,g._cssText=Ve(T,B.href))}if(m==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var T=rt(e.sheet);T&&(g._cssText=Ve(T,st()))}if(m==="input"||m==="textarea"||m==="select"){var H=e.value,j=e.checked;g.type!=="radio"&&g.type!=="checkbox"&&g.type!=="submit"&&g.type!=="button"&&H?g.value=nt({type:g.type,tagName:m,value:H,maskInputOptions:c,maskInputFn:a}):j&&(g.checked=j)}if(m==="option"&&(e.selected&&!c.select?g.selected=!0:delete g.selected),m==="canvas"&&p){if(e.__context==="2d")Qr(e)||(g.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){var X=e.toDataURL(l.type,l.quality),Q=document.createElement("canvas");Q.width=e.width,Q.height=e.height;var $=Q.toDataURL(l.type,l.quality);X!==$&&(g.rr_dataURL=X)}}if(m==="img"&&u){ye||(ye=r.createElement("canvas"),Ot=ye.getContext("2d"));var L=e,J=L.crossOrigin;L.crossOrigin="anonymous";var re=function(){try{ye.width=L.naturalWidth,ye.height=L.naturalHeight,Ot.drawImage(L,0,0),g.rr_dataURL=ye.toDataURL(l.type,l.quality)}catch(q){console.warn("Cannot inline img src=".concat(L.currentSrc,"! Error: ").concat(q))}J?g.crossOrigin=J:L.removeAttribute("crossorigin")};L.complete&&L.naturalWidth!==0?re():L.onload=re}if((m==="audio"||m==="video")&&(g.rr_mediaState=e.paused?"paused":"played",g.rr_mediaCurrentTime=e.currentTime),y||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop)),C){var ie=e.getBoundingClientRect(),ae=ie.width,V=ie.height;g={class:g.class,rr_width:"".concat(ae,"px"),rr_height:"".concat(V,"px")}}return m==="iframe"&&!f(g.src)&&(e.contentDocument||(g.rr_src=g.src),delete g.src),{type:F.Element,tagName:m,attributes:g,childNodes:[],isSVG:un(e)||void 0,needBlock:C,rootId:S}}function E(e){return e===void 0?"":e.toLowerCase()}function Cn(e,t){if(t.comment&&e.type===F.Comment)return!0;if(e.type===F.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&e.attributes.rel==="preload"&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(E(e.attributes.name).match(/^msapplication-tile(image|color)$/)||E(e.attributes.name)==="application-name"||E(e.attributes.rel)==="icon"||E(e.attributes.rel)==="apple-touch-icon"||E(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&E(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(E(e.attributes.property).match(/^(og|twitter|fb):/)||E(e.attributes.name).match(/^(og|twitter):/)||E(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(E(e.attributes.name)==="robots"||E(e.attributes.name)==="googlebot"||E(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(E(e.attributes.name)==="author"||E(e.attributes.name)==="generator"||E(e.attributes.name)==="framework"||E(e.attributes.name)==="publisher"||E(e.attributes.name)==="progid"||E(e.attributes.property).match(/^article:/)||E(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(E(e.attributes.name)==="google-site-verification"||E(e.attributes.name)==="yandex-verification"||E(e.attributes.name)==="csrf-token"||E(e.attributes.name)==="p:domain_verify"||E(e.attributes.name)==="verify-v1"||E(e.attributes.name)==="verification"||E(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function Ce(e,t){var r=t.doc,n=t.mirror,s=t.blockClass,i=t.blockSelector,o=t.maskTextClass,c=t.maskTextSelector,a=t.skipChild,d=a===void 0?!1:a,l=t.inlineStylesheet,u=l===void 0?!0:l,p=t.maskInputOptions,f=p===void 0?{}:p,h=t.maskTextFn,y=t.maskInputFn,S=t.slimDOMOptions,C=t.dataURLOptions,m=C===void 0?{}:C,g=t.inlineImages,k=g===void 0?!1:g,z=t.recordCanvas,x=z===void 0?!1:z,B=t.onSerialize,T=t.onIframeLoad,H=t.iframeLoadTimeout,j=H===void 0?5e3:H,X=t.onStylesheetLoad,Q=t.stylesheetLoadTimeout,$=Q===void 0?5e3:Q,L=t.keepIframeSrcFn,J=L===void 0?function(){return!1}:L,re=t.newlyAddedElement,ie=re===void 0?!1:re,ae=t.preserveWhiteSpace,V=ae===void 0?!0:ae,q=mn(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:f,maskTextFn:h,maskInputFn:y,dataURLOptions:m,inlineImages:k,recordCanvas:x,keepIframeSrcFn:J,newlyAddedElement:ie});if(!q)return console.warn(e,"not serialized"),null;var le;n.hasNode(e)?le=n.getId(e):Cn(q,S)||!V&&q.type===F.Text&&!q.isStyle&&!q.textContent.replace(/^\s+|\s+$/gm,"").length?le=Oe:le=Mt();var M=Object.assign(q,{id:le});if(n.add(e,M),le===Oe)return null;B&&B(e);var ne=!d;if(M.type===F.Element){ne=ne&&!M.needBlock,delete M.needBlock;var oe=e.shadowRoot;oe&&Me(oe)&&(M.isShadowHost=!0)}if((M.type===F.Document||M.type===F.Element)&&ne){S.headWhitespace&&M.type===F.Element&&M.tagName==="head"&&(V=!1);for(var Te={doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:d,inlineStylesheet:u,maskInputOptions:f,maskTextFn:h,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:B,onIframeLoad:T,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J},I=0,G=Array.from(e.childNodes);I<G.length;I++){var P=G[I],R=Ce(P,Te);R&&M.childNodes.push(R)}if(Jr(e)&&e.shadowRoot)for(var Y=0,A=Array.from(e.shadowRoot.childNodes);Y<A.length;Y++){var P=A[Y],R=Ce(P,Te);R&&(Me(e.shadowRoot)&&(R.isShadow=!0),M.childNodes.push(R))}}return e.parentNode&&Ne(e.parentNode)&&Me(e.parentNode)&&(M.isShadow=!0),M.type===F.Element&&M.tagName==="iframe"&&pn(e,function(){var Z=e.contentDocument;if(Z&&T){var Ue=Ce(Z,{doc:Z,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:h,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:B,onIframeLoad:T,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J});Ue&&T(e,Ue)}},j),M.type===F.Element&&M.tagName==="link"&&M.attributes.rel==="stylesheet"&&fn(e,function(){if(X){var Z=Ce(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:h,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:B,onIframeLoad:T,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J});Z&&X(e,Z)}},$),M}function Sn(e,t){var r=t||{},n=r.mirror,s=n===void 0?new _t:n,i=r.blockClass,o=i===void 0?"rr-block":i,c=r.blockSelector,a=c===void 0?null:c,d=r.maskTextClass,l=d===void 0?"rr-mask":d,u=r.maskTextSelector,p=u===void 0?null:u,f=r.inlineStylesheet,h=f===void 0?!0:f,y=r.inlineImages,S=y===void 0?!1:y,C=r.recordCanvas,m=C===void 0?!1:C,g=r.maskAllInputs,k=g===void 0?!1:g,z=r.maskTextFn,x=r.maskInputFn,B=r.slimDOM,T=B===void 0?!1:B,H=r.dataURLOptions,j=r.preserveWhiteSpace,X=r.onSerialize,Q=r.onIframeLoad,$=r.iframeLoadTimeout,L=r.onStylesheetLoad,J=r.stylesheetLoadTimeout,re=r.keepIframeSrcFn,ie=re===void 0?function(){return!1}:re,ae=k===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:k===!1?{password:!0}:k,V=T===!0||T==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:T==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:T===!1?{}:T;return Ce(e,{doc:e,mirror:s,blockClass:o,blockSelector:a,maskTextClass:l,maskTextSelector:p,skipChild:!1,inlineStylesheet:h,maskInputOptions:ae,maskTextFn:z,maskInputFn:x,slimDOMOptions:V,dataURLOptions:H,inlineImages:S,recordCanvas:m,preserveWhiteSpace:j,onSerialize:X,onIframeLoad:Q,iframeLoadTimeout:$,onStylesheetLoad:L,stylesheetLoadTimeout:J,keepIframeSrcFn:ie,newlyAddedElement:!1})}function U(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const Se=`Please stop import mirror directly. Instead of that,\r
1
+ (function(Re,Te){typeof exports=="object"&&typeof module<"u"?module.exports=Te():typeof define=="function"&&define.amd?define(Te):(Re=typeof globalThis<"u"?globalThis:Re||self,Re.FlashlogBugTracker=Te())})(this,function(){"use strict";const Re=e=>{const t=e.trim();return t.length>0?t:null},Te=()=>{if(typeof window>"u")return null;const{hostname:e,protocol:t}=window.location;return e==="localhost"||e==="127.0.0.1"?`${t}//${e}:3008/api`:null},Ar=()=>{const e=Re("http://localhost:3008/api");if(e)return e;const t=Te();return t||"https://api.flashlog.app/api"},gt=new Set(["NETWORK_ERROR","SOCKET_ERROR","JS_ERROR","UNHANDLED_REJECTION","MANUAL_ERROR"]),Ue=["password","passwd","authorization","credentials","secret","token","jwt","cookie","session","csrf","passcode","otp","apiKey","accessToken","refreshToken","clientSecret","privateKey","authCode","verificationCode","sessionToken","sessionCookie","sessionSecret"],kr=["password","passwd","authorization","secret","token","jwt","cookie","session","csrf","passcode","otp","apiKey","accessToken","refreshToken","clientSecret","privateKey","authCode","verificationCode","sessionToken","sessionCookie","sessionSecret"],w={apiUrl:Ar(),apiKey:"",debug:!1,autoCapture:!0,captureNetworkErrors:!0,captureJsErrors:!0,captureSocketErrors:!0,sessionTimeoutMs:30*60*1e3,maxActionBufferSize:50,allowNonErrorEvents:!1,captureRequestBody:!0,captureResponseBody:!0,redactKeys:Ue,redactUrlParams:kr,propagateTraceHeaders:!1,traceOrigins:[],traceHeaderName:"x-flashlog-trace-id",enableSessionReplay:!0,replayFlushIntervalMs:4e4,replayMaxSegmentBytes:512*1024,replayMaxSegmentEvents:400,replayMaskAllInputs:!0,ignoredStatusCodes:[401,403],ignoredUrls:["/api/v1/integration/webhook","/api/v1/tracking-issues","/api/v1/session-replays/public/segments/upload-url","/api/v1/session-replays/public/local-upload/","/api/v1/session-replays/public/finalize","tracking.api.founder-os.ai/api/v2/tracking-session-data","googletagmanager.com","google-analytics.com","clarity.ms","facebook.com/tr"]},N={sessionId:"flashlog_tracker_session_id",sessionSeenAt:"flashlog_tracker_session_seen_at",deviceId:"flashlog_tracker_device_id",accountId:"flashlog_tracker_account_id",accountTraits:"flashlog_tracker_account_traits"},Er=e=>{if(e.scriptUrl)return e.scriptUrl;if(e.source==="package")return"package:@flashlog/tracker-sdk"},yt=async e=>{if(typeof window>"u"||typeof document>"u")return;const t=Number(e.brandId);if(!Number.isFinite(t)||t<=0)return;const r=`${(e.apiUrl||w.apiUrl).replace(/\/$/,"")}/v1/tracking-events/public/script-installations/ping`;try{const n=await fetch(r,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","x-api-key":e.apiKey},body:JSON.stringify({brand_id:t,url:window.location.href,referrer:document.referrer||void 0,script_url:Er(e)})});!n.ok&&e.debug&&console.warn("[FlashlogTracker] Installation ping failed",{status:n.status})}catch(n){e.debug&&console.warn("[FlashlogTracker] Installation ping error",n)}},ae="[redacted]",It="[omitted by privacy config]",We=e=>{const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").trim().toLowerCase();return t?t.split(/\s+/):[]},Rr=(e,t)=>{if(t.length===0||t.length>e.length)return!1;for(let r=0;r<=e.length-t.length;r+=1)if(t.every((s,i)=>e[r+i]===s))return!0;return!1},_e=(e,t)=>{const r=We(e);if(r.length===0)return!1;const n=r.join("");return t.some(s=>{const i=We(s);return i.length===0?!1:i.length===1?r.includes(i[0]):n===i.join("")||Rr(r,i)})},Ct=(e,t)=>e?We(e).join("")===t:!1,Tr=e=>e?We(e).includes("url"):!1,_r=e=>{const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{const r=JSON.parse(e);return r&&typeof r=="object"?r:null}catch{return null}},St=(e,t)=>{let r=e.replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,`$1${ae}`).replace(/\b(Basic\s+)[A-Za-z0-9+/=-]+/gi,`$1${ae}`).replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,ae);return r!==e&&(t.redactedFieldsCount+=1),r},bt=e=>St(e,{redactedFieldsCount:0}),Nr=(e,t,r)=>{try{const n=e.startsWith("/"),s=new URL(e,"https://flashlog.local");let i=!1;return s.searchParams.forEach((o,c)=>{_e(c,t.redactUrlParams)&&(s.searchParams.set(c,ae),i=!0)}),i?(r.redactedFieldsCount+=1,n?`${s.pathname}${s.search}${s.hash}`:s.toString()):e}catch{return e}},Mr=(e,t,r,n,s=new WeakSet)=>{if(Tr(n))return Nr(e,t,r);const i=_r(e);if(i!==null){const o=ze(i,t,r,n,s);return JSON.stringify(o)}return St(e,r)},ze=(e,t,r,n,s=new WeakSet)=>{if(Ct(n,"requestbody")&&!t.captureRequestBody||Ct(n,"responsebody")&&!t.captureResponseBody)return r.omittedFieldsCount+=1,It;if(n&&_e(n,t.redactKeys))return r.redactedFieldsCount+=1,ae;if(typeof e=="string")return Mr(e,t,r,n,s);if(Array.isArray(e))return e.map(i=>ze(i,t,r,void 0,s));if(!e||typeof e!="object")return e;if(s.has(e))return r.redactedFieldsCount+=1,ae;s.add(e);try{return Object.entries(e).reduce((i,[o,c])=>(i[o]=ze(c,t,r,o,s),i),{})}finally{s.delete(e)}},Or=(e,t)=>{const r={redactedFieldsCount:0,omittedFieldsCount:0},n=ze(e.data,t,r),s=n.privacy&&typeof n.privacy=="object"?n.privacy:{};return{...e,data:{...n,privacy:{...s,client_redaction:!0,redacted:r.redactedFieldsCount>0,redacted_fields_count:r.redactedFieldsCount,omitted_fields_count:r.omittedFieldsCount,request_body_capture:t.captureRequestBody?"redacted":"off",response_body_capture:t.captureResponseBody?"redacted":"off"}}}},Lr=()=>typeof window<"u"&&window.location?window.location.href:"",Fr=120,vt=(e,t=Fr)=>e.length>t?e.slice(0,t):e,Qe=e=>{const t=e==null?void 0:e.trim();if(t)return vt(bt(t))},wt=e=>{const r=bt(e).split(/([_:.=-])/),n=r.map((s,i)=>{if(!s||/^[_:.=-]$/.test(s))return s;const c=`${i>=2?r[i-2]:""} ${s}`;return _e(s,Ue)||_e(c,Ue)?ae:s});return vt(n.join(""),80)},$e=e=>{if(!e)return"";if(e.id)return`#${wt(e.id)}`;const t=[];let r=e;for(;r&&t.length<5;){const n=typeof r.className=="string"?r.className.trim().split(/\s+/).slice(0,2).map(wt).join("."):"";t.unshift(`${r.tagName.toLowerCase()}${n?`.${n}`:""}`),r=r.parentElement}return t.join(" > ")},xr=e=>[e.getAttribute("name"),e.getAttribute("id"),e.getAttribute("aria-label"),e.getAttribute("placeholder"),e.getAttribute("autocomplete"),e.getAttribute("type")].filter(Boolean).join(" "),Br=e=>{const t=xr(e);return(e.getAttribute("type")||"").toLowerCase()==="password"||_e(t,Ue)},me=(e,t)=>{const r=e==null?void 0:e.trim();if(r)return Br(t)?ae:Qe(r)},Dr=e=>{const t={tagName:e==null?void 0:e.tagName,selector:$e(e)};if(!e)return t;if(e instanceof HTMLSelectElement){const r=Array.from(e.selectedOptions),n=r.map(o=>me(o.value,e)),s=r.map(o=>me(o.text,e)),i=e.multiple;return{...t,value:i?n:n[0],text:i?s:s[0]}}if(e instanceof HTMLInputElement){const r=e.type.toLowerCase();return r==="checkbox"||r==="radio"?{...t,checked:e.checked,value:me(e.value,e)}:{...t,value:me(e.value,e)}}return e instanceof HTMLTextAreaElement?{...t,value:me(e.value,e)}:e.isContentEditable?{...t,text:me(e.innerText,e)}:{...t,text:Qe(e.innerText)}};class Ur{constructor(t){this.actions=[],this.detachHandlers=[],this.maxSize=t}start(){if(typeof window>"u"||typeof document>"u"||this.detachHandlers.length>0)return;const t=i=>{const o=i.target;this.add("CLICK",{tagName:o==null?void 0:o.tagName,text:Qe(o==null?void 0:o.innerText),selector:$e(o)})},r=i=>{const o=i.target;this.add("INPUT_CHANGE",Dr(o))},n=i=>{const o=i.target;this.add("FORM_SUBMIT",{tagName:o==null?void 0:o.tagName,selector:$e(o)})},s=()=>{this.add("VISIBILITY_CHANGE",{text:typeof document<"u"?document.visibilityState:"unknown"})};document.addEventListener("click",t,!0),document.addEventListener("input",r,!0),document.addEventListener("submit",n,!0),document.addEventListener("visibilitychange",s,!0),this.detachHandlers=[()=>document.removeEventListener("click",t,!0),()=>document.removeEventListener("input",r,!0),()=>document.removeEventListener("submit",n,!0),()=>document.removeEventListener("visibilitychange",s,!0)]}stop(){this.detachHandlers.forEach(t=>t()),this.detachHandlers=[]}add(t,r){this.actions.push({action:t,details:r,timestamp:Date.now(),url:Lr()}),this.actions.length>this.maxSize&&(this.actions=this.actions.slice(-this.maxSize))}getAll(){return[...this.actions]}clear(){this.actions=[]}}const Wr=e=>{const t=[{key:"edg/",name:"Edge"},{key:"chrome/",name:"Chrome"},{key:"firefox/",name:"Firefox"},{key:"safari/",name:"Safari"}],r=e.toLowerCase();for(const n of t){const s=r.indexOf(n.key);if(s>=0){const i=r.slice(s+n.key.length).split(/[^\d.]/)[0]||"unknown";return{name:n.name,version:i}}}return{name:"Unknown",version:"unknown"}},zr=e=>{const t=e.toLowerCase();return t.includes("windows")?"Windows":t.includes("mac os")?"MacOS":t.includes("android")?"Android":t.includes("iphone")||t.includes("ipad")||t.includes("ios")?"iOS":t.includes("linux")?"Linux":"Unknown"},Gr=()=>{if(typeof window>"u")return"Unknown";const e=window.innerWidth||0;return e<=768?"Mobile":e<=1024?"Tablet":"Desktop"},At=e=>{const t=typeof navigator<"u"?navigator:{},r=t.userAgent||"",n=Wr(r);return{os_name:zr(r),device_type:Gr(),device_id:e,browser_name:n.name,browser_version:n.version,screen_width:typeof screen<"u"?screen.width:0,screen_height:typeof screen<"u"?screen.height:0,viewport_width:typeof window<"u"?window.innerWidth:0,viewport_height:typeof window<"u"?window.innerHeight:0,language:t.language||"unknown",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||"unknown",user_agent:r.toLowerCase()}},kt=()=>{const e={online:typeof navigator<"u"?navigator.onLine:!0},t=typeof navigator<"u"?navigator:void 0,r=t==null?void 0:t.connection;return r&&(e.connection_type=r.effectiveType,e.downlink=r.downlink,e.rtt=r.rtt,e.save_data=r.saveData),e},et=typeof window<"u"&&window.location?window.location.origin:void 0,Et=e=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const r=new Uint8Array(e);return crypto.getRandomValues(r),Array.from(r,n=>n.toString(16).padStart(2,"0")).join("")}let t="";for(let r=0;r<e;r+=1)t+=Math.floor(Math.random()*256).toString(16).padStart(2,"0");return t},Ge=()=>{const e=Et(16),t=Et(8);return{trace_id:e,span_id:t,traceparent:`00-${e}-${t}-01`}},Kr=(e={})=>{const t=typeof e.trace_id=="string"&&e.trace_id.trim()?e.trace_id.trim():null,r=typeof e.span_id=="string"&&e.span_id.trim()?e.span_id.trim():null,n=typeof e.traceparent=="string"&&e.traceparent.trim()?e.traceparent.trim():null;return t&&r?{trace_id:t,span_id:r,traceparent:n||`00-${t}-${r}-01`}:Ge()},tt=(e,t)=>({traceparent:e.traceparent,[t]:e.trace_id}),Rt=(e,t)=>{if(!t.propagateTraceHeaders||!e)return!1;try{const r=new URL(e,et),n=t.traceOrigins.map(s=>s.trim()).filter(Boolean);return n.length===0?et?r.origin===et:!0:n.some(s=>s==="*"?!0:r.origin===s||r.href.startsWith(s))}catch{return!1}},Vr="[omitted: non-json body]";class Pr{constructor(t,r){this.socketMeta=new WeakMap,this.initialized=!1,this.handleWindowError=n=>{var s;this.hooks.onJsError({message:n.message||"Unknown JS error",filename:n.filename||"",lineno:n.lineno||0,colno:n.colno||0,stack:((s=n.error)==null?void 0:s.stack)||"",timestamp:Date.now()})},this.handleUnhandledRejection=n=>{const s=n.reason,i=s instanceof Error?s.message:typeof s=="string"?s:"Unhandled rejection",o=s instanceof Error?s.stack:"";this.hooks.onUnhandledRejection({message:i,stack:o||"",timestamp:Date.now()})},this.config=t,this.hooks=r}start(){typeof window>"u"||this.initialized||(this.initialized=!0,this.config.captureNetworkErrors&&(this.interceptFetch(),this.interceptXhr()),this.config.captureSocketErrors&&this.interceptWebSocket(),this.config.captureJsErrors&&(window.addEventListener("error",this.handleWindowError,!0),window.addEventListener("unhandledrejection",this.handleUnhandledRejection,!0)))}stop(){typeof window>"u"||!this.initialized||(this.initialized=!1,this.originalFetch&&(window.fetch=this.originalFetch),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend),this.originalWebSocket&&(window.WebSocket=this.originalWebSocket),window.removeEventListener("error",this.handleWindowError,!0),window.removeEventListener("unhandledrejection",this.handleUnhandledRejection,!0))}shouldIgnoreUrl(t){return this.config.ignoredUrls.some(r=>t.includes(r))}shouldIgnoreStatus(t){return this.config.ignoredStatusCodes.includes(t)}truncate(t,r=3e3){if(t)return t.length<=r?t:`${t.slice(0,r)}... [truncated]`}getBodyType(t){var r,n;return t?typeof FormData<"u"&&t instanceof FormData?"FormData":typeof URLSearchParams<"u"&&t instanceof URLSearchParams?"URLSearchParams":typeof File<"u"&&t instanceof File?"File":typeof Blob<"u"&&t instanceof Blob?"Blob":typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?"ArrayBuffer":typeof ReadableStream<"u"&&t instanceof ReadableStream?"ReadableStream":typeof ArrayBuffer<"u"&&ArrayBuffer.isView(t)?((r=t.constructor)==null?void 0:r.name)||"ArrayBufferView":typeof t=="object"?((n=t.constructor)==null?void 0:n.name)||"Object":typeof t:"Unknown"}safeBodyPreview(t){if(t)return typeof t=="string"?t:JSON.stringify({body_type:this.getBodyType(t),captured:!1,reason:Vr})}attachTraceHeadersToFetchRequest(t,r,n,s){if(!Rt(n,this.config))return{input:t,init:r};if(t instanceof Request){const o=new Headers(t.headers);return new Headers(r==null?void 0:r.headers).forEach((a,d)=>{o.set(d,a)}),Object.entries(s).forEach(([a,d])=>{o.set(a,d)}),{input:new Request(t,{...r,headers:o})}}const i=new Headers(r==null?void 0:r.headers);return Object.entries(s).forEach(([o,c])=>{i.set(o,c)}),{input:t,init:{...r||{},headers:i}}}interceptFetch(){if(typeof window.fetch!="function")return;const t=this;this.originalFetch=window.fetch,window.fetch=async function(n,s){const i=Date.now(),o=(s==null?void 0:s.method)||"GET",c=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t.shouldIgnoreUrl(c))return t.originalFetch.call(window,n,s);const a=t.safeBodyPreview(s==null?void 0:s.body),d=Ge(),l=tt(d,t.config.traceHeaderName),u=t.attachTraceHeadersToFetchRequest(n,s,c,l);try{const h=await t.originalFetch.call(window,u.input,u.init),f=Date.now()-i;if((h.ok||t.shouldIgnoreStatus(h.status))&&t.hooks.onNetworkActivity({type:"fetch",url:c,method:o.toUpperCase(),status:h.status,statusText:h.statusText,duration_ms:f,trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),!h.ok&&h.status>=400&&!t.shouldIgnoreStatus(h.status)){let p;try{p=await h.clone().text()}catch{p="[unreadable]"}t.hooks.onNetworkError({type:"fetch",url:c,method:o.toUpperCase(),status:h.status,statusText:h.statusText,duration_ms:f,request_body:t.truncate(a),response_body:t.truncate(p),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()})}return h}catch(h){throw t.hooks.onNetworkError({type:"fetch",url:c,method:o.toUpperCase(),status:0,statusText:"NETWORK_ERROR",duration_ms:Date.now()-i,request_body:t.truncate(a),response_body:t.truncate(h instanceof Error?h.message:String(h)),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),h}}}interceptXhr(){const t=this;this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=function(n,s,i,o,c){const a=s instanceof URL?s.toString():String(s);return this.__flashlog_meta={method:(n||"GET").toUpperCase(),url:a},t.originalXhrOpen.call(this,n,s,i??!0,o??null,c??null)},XMLHttpRequest.prototype.send=function(n){const s=this,i=s.__flashlog_meta||{};if(t.shouldIgnoreUrl(i.url||""))return t.originalXhrSend.call(this,n);const o=Date.now(),c=t.safeBodyPreview(n),a=Ge(),d=tt(a,t.config.traceHeaderName);return Rt(i.url||"",t.config)&&Object.entries(d).forEach(([l,u])=>{try{s.setRequestHeader(l,u)}catch{t.hooks.debug&&console.warn("[FlashlogTracker] Failed to attach trace header",{key:l,url:i.url})}}),s.addEventListener("loadend",()=>{const l=s.status||0;(l>=200&&l<400||t.shouldIgnoreStatus(l))&&t.hooks.onNetworkActivity({type:"xhr",url:i.url,method:i.method||"GET",status:l,statusText:s.statusText||"HTTP_RESULT",duration_ms:Date.now()-o,trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()}),l>=400&&!t.shouldIgnoreStatus(l)&&t.hooks.onNetworkError({type:"xhr",url:i.url,method:i.method||"GET",status:l,statusText:s.statusText||"HTTP_ERROR",duration_ms:Date.now()-o,request_body:t.truncate(c),response_body:t.truncate(s.responseText||""),trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()})}),s.addEventListener("error",()=>{t.hooks.onNetworkError({type:"xhr",url:i.url,method:i.method||"GET",status:0,statusText:"NETWORK_ERROR",duration_ms:Date.now()-o,request_body:t.truncate(c),response_body:"XHR network error",trace_id:a.trace_id,span_id:a.span_id,traceparent:a.traceparent,timestamp:Date.now()})}),t.originalXhrSend.call(this,n)}}interceptWebSocket(){if(typeof window.WebSocket!="function")return;const t=this;this.originalWebSocket=window.WebSocket;const r=this.originalWebSocket,n=function(i,o){const c=i instanceof URL?i.toString():String(i),a=o!==void 0?new r(i,o):new r(i);return t.shouldIgnoreUrl(c)||(t.socketMeta.set(a,{url:c,createdAt:Date.now(),openedAt:null}),a.addEventListener("open",()=>{const d=t.socketMeta.get(a);d&&(d.openedAt=Date.now())}),a.addEventListener("error",()=>{const d=t.socketMeta.get(a),l=(d==null?void 0:d.openedAt)||(d==null?void 0:d.createdAt)||Date.now();t.hooks.onSocketError({type:"websocket",phase:"error",url:(d==null?void 0:d.url)||c,method:"CONNECT",status:0,statusText:"WEBSOCKET_ERROR",duration_ms:Date.now()-l,timestamp:Date.now()})}),a.addEventListener("close",d=>{if(d.code===1e3||d.code===1001)return;const l=t.socketMeta.get(a),u=(l==null?void 0:l.openedAt)||(l==null?void 0:l.createdAt)||Date.now();t.hooks.onSocketError({type:"websocket",phase:"close",url:(l==null?void 0:l.url)||c,method:"CONNECT",status:0,socket_close_code:d.code,statusText:d.reason||"WEBSOCKET_CLOSED_ABNORMALLY",was_clean:d.wasClean,duration_ms:Date.now()-u,timestamp:Date.now()})})),a};n.prototype=r.prototype,Object.defineProperty(n,"CONNECTING",{value:r.CONNECTING}),Object.defineProperty(n,"OPEN",{value:r.OPEN}),Object.defineProperty(n,"CLOSING",{value:r.CLOSING}),Object.defineProperty(n,"CLOSED",{value:r.CLOSED}),window.WebSocket=n}}var x;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(x||(x={}));function Zr(e){return e.nodeType===e.ELEMENT_NODE}function Ne(e){var t=e==null?void 0:e.host;return(t==null?void 0:t.shadowRoot)===e}function Me(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function Hr(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function rt(e){try{var t=e.rules||e.cssRules;return t?Hr(Array.from(t).map(Tt).join("")):null}catch{return null}}function Tt(e){var t=e.cssText;if(jr(e))try{t=rt(e.styleSheet)||t}catch{}return t}function jr(e){return"styleSheet"in e}var _t=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var r;if(!t)return-1;var n=(r=this.getMeta(t))===null||r===void 0?void 0:r.id;return n??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var r=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(s){return r.removeNodeFromMap(s)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,r){var n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)},e.prototype.replace=function(t,r){var n=this.getNode(t);if(n){var s=this.nodeMetaMap.get(n);s&&this.nodeMetaMap.set(r,s)}this.idNodeMap.set(t,r)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Jr(){return new _t}function nt(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,s=e.value,i=e.maskInputFn,o=s||"";return(t[r.toLowerCase()]||t[n])&&(i?o=i(o):o="*".repeat(o.length)),o}var Nt="__rrweb_original__";function qr(e){var t=e.getContext("2d");if(!t)return!0;for(var r=50,n=0;n<e.width;n+=r)for(var s=0;s<e.height;s+=r){var i=t.getImageData,o=Nt in i?i[Nt]:i,c=new Uint32Array(o.call(t,n,s,Math.min(r,e.width-n),Math.min(r,e.height-s)).data.buffer);if(c.some(function(a){return a!==0}))return!1}return!0}var Yr=1,Xr=new RegExp("[^a-z0-9-_:]"),Oe=-2;function Mt(){return Yr++}function Qr(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return Xr.test(t)?"div":t}function $r(e){return e.cssRules?Array.from(e.cssRules).map(function(t){return t.cssText||""}).join(""):""}function en(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var ge,Ot,tn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,rn=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,nn=/^(data:)([^,]*),(.*)/i;function Ke(e,t){return(e||"").replace(tn,function(r,n,s,i,o,c){var a=s||o||c,d=n||i||"";if(!a)return r;if(!rn.test(a)||nn.test(a))return"url(".concat(d).concat(a).concat(d,")");if(a[0]==="/")return"url(".concat(d).concat(en(t)+a).concat(d,")");var l=t.split("/"),u=a.split("/");l.pop();for(var h=0,f=u;h<f.length;h++){var p=f[h];p!=="."&&(p===".."?l.pop():l.push(p))}return"url(".concat(d).concat(l.join("/")).concat(d,")")})}var sn=/^[^ \t\n\r\u000c]+/,on=/^[, \t\n\r\u000c]+/;function an(e,t){if(t.trim()==="")return t;var r=0;function n(d){var l,u=d.exec(t.substring(r));return u?(l=u[0],r+=l.length,l):""}for(var s=[];n(on),!(r>=t.length);){var i=n(sn);if(i.slice(-1)===",")i=ye(e,i.substring(0,i.length-1)),s.push(i);else{var o="";i=ye(e,i);for(var c=!1;;){var a=t.charAt(r);if(a===""){s.push((i+o).trim());break}else if(c)a===")"&&(c=!1);else if(a===","){r+=1,s.push((i+o).trim());break}else a==="("&&(c=!0);o+=a,r+=1}}}return s.join(", ")}function ye(e,t){if(!t||t.trim()==="")return t;var r=e.createElement("a");return r.href=t,r.href}function cn(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function st(){var e=document.createElement("a");return e.href="",e.href}function Lt(e,t,r,n){return r==="src"||r==="href"&&n&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n&&n[0]!=="#"||r==="background"&&n&&(t==="table"||t==="td"||t==="th")?ye(e,n):r==="srcset"&&n?an(e,n):r==="style"&&n?Ke(n,st()):t==="object"&&r==="data"&&n?ye(e,n):n}function dn(e,t,r){if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var s=e.classList[n];if(t.test(s))return!0}return r?e.matches(r):!1}function Ve(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Ve(e.parentNode,t,r):!1;for(var n=e.classList.length;n--;){var s=e.classList[n];if(t.test(s))return!0}return r?Ve(e.parentNode,t,r):!1}function Ft(e,t,r){var n=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(n===null)return!1;if(typeof t=="string"){if(n.classList.contains(t)||n.closest(".".concat(t)))return!0}else if(Ve(n,t,!0))return!0;return!!(r&&(n.matches(r)||n.closest(r)))}function ln(e,t,r){var n=e.contentWindow;if(n){var s=!1,i;try{i=n.document.readyState}catch{return}if(i!=="complete"){var o=setTimeout(function(){s||(t(),s=!0)},r);e.addEventListener("load",function(){clearTimeout(o),s=!0,t()});return}var c="about:blank";if(n.location.href!==c||e.src===c||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function un(e,t,r){var n=!1,s;try{s=e.sheet}catch{return}if(!s){var i=setTimeout(function(){n||(t(),n=!0)},r);e.addEventListener("load",function(){clearTimeout(i),n=!0,t()})}}function pn(e,t){var r=t.doc,n=t.mirror,s=t.blockClass,i=t.blockSelector,o=t.maskTextClass,c=t.maskTextSelector,a=t.inlineStylesheet,d=t.maskInputOptions,l=d===void 0?{}:d,u=t.maskTextFn,h=t.maskInputFn,f=t.dataURLOptions,p=f===void 0?{}:f,y=t.inlineImages,S=t.recordCanvas,C=t.keepIframeSrcFn,m=t.newlyAddedElement,g=m===void 0?!1:m,k=hn(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:x.Document,childNodes:[],compatMode:e.compatMode}:{type:x.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:x.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:k};case e.ELEMENT_NODE:return mn(e,{doc:r,blockClass:s,blockSelector:i,inlineStylesheet:a,maskInputOptions:l,maskInputFn:h,dataURLOptions:p,inlineImages:y,recordCanvas:S,keepIframeSrcFn:C,newlyAddedElement:g,rootId:k});case e.TEXT_NODE:return fn(e,{maskTextClass:o,maskTextSelector:c,maskTextFn:u,rootId:k});case e.CDATA_SECTION_NODE:return{type:x.CDATA,textContent:"",rootId:k};case e.COMMENT_NODE:return{type:x.Comment,textContent:e.textContent||"",rootId:k};default:return!1}}function hn(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function fn(e,t){var r,n=t.maskTextClass,s=t.maskTextSelector,i=t.maskTextFn,o=t.rootId,c=e.parentNode&&e.parentNode.tagName,a=e.textContent,d=c==="STYLE"?!0:void 0,l=c==="SCRIPT"?!0:void 0;if(d&&a){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(a=$r(e.parentNode.sheet))}catch(u){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u),e)}a=Ke(a,st())}return l&&(a="SCRIPT_PLACEHOLDER"),!d&&!l&&a&&Ft(e,n,s)&&(a=i?i(a):a.replace(/[\S]/g,"*")),{type:x.Text,textContent:a||"",isStyle:d,rootId:o}}function mn(e,t){for(var r=t.doc,n=t.blockClass,s=t.blockSelector,i=t.inlineStylesheet,o=t.maskInputOptions,c=o===void 0?{}:o,a=t.maskInputFn,d=t.dataURLOptions,l=d===void 0?{}:d,u=t.inlineImages,h=t.recordCanvas,f=t.keepIframeSrcFn,p=t.newlyAddedElement,y=p===void 0?!1:p,S=t.rootId,C=dn(e,n,s),m=Qr(e),g={},k=e.attributes.length,z=0;z<k;z++){var B=e.attributes[z];g[B.name]=Lt(r,m,B.name,B.value)}if(m==="link"&&i){var D=Array.from(r.styleSheets).find(function(q){return q.href===e.href}),R=null;D&&(R=rt(D)),R&&(delete g.rel,delete g.href,g._cssText=Ke(R,D.href))}if(m==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var R=rt(e.sheet);R&&(g._cssText=Ke(R,st()))}if(m==="input"||m==="textarea"||m==="select"){var H=e.value,j=e.checked;g.type!=="radio"&&g.type!=="checkbox"&&g.type!=="submit"&&g.type!=="button"&&H?g.value=nt({type:g.type,tagName:m,value:H,maskInputOptions:c,maskInputFn:a}):j&&(g.checked=j)}if(m==="option"&&(e.selected&&!c.select?g.selected=!0:delete g.selected),m==="canvas"&&h){if(e.__context==="2d")qr(e)||(g.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){var X=e.toDataURL(l.type,l.quality),Q=document.createElement("canvas");Q.width=e.width,Q.height=e.height;var $=Q.toDataURL(l.type,l.quality);X!==$&&(g.rr_dataURL=X)}}if(m==="img"&&u){ge||(ge=r.createElement("canvas"),Ot=ge.getContext("2d"));var F=e,J=F.crossOrigin;F.crossOrigin="anonymous";var re=function(){try{ge.width=F.naturalWidth,ge.height=F.naturalHeight,Ot.drawImage(F,0,0),g.rr_dataURL=ge.toDataURL(l.type,l.quality)}catch(q){console.warn("Cannot inline img src=".concat(F.currentSrc,"! Error: ").concat(q))}J?g.crossOrigin=J:F.removeAttribute("crossorigin")};F.complete&&F.naturalWidth!==0?re():F.onload=re}if((m==="audio"||m==="video")&&(g.rr_mediaState=e.paused?"paused":"played",g.rr_mediaCurrentTime=e.currentTime),y||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop)),C){var se=e.getBoundingClientRect(),oe=se.width,V=se.height;g={class:g.class,rr_width:"".concat(oe,"px"),rr_height:"".concat(V,"px")}}return m==="iframe"&&!f(g.src)&&(e.contentDocument||(g.rr_src=g.src),delete g.src),{type:x.Element,tagName:m,attributes:g,childNodes:[],isSVG:cn(e)||void 0,needBlock:C,rootId:S}}function E(e){return e===void 0?"":e.toLowerCase()}function gn(e,t){if(t.comment&&e.type===x.Comment)return!0;if(e.type===x.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&e.attributes.rel==="preload"&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(E(e.attributes.name).match(/^msapplication-tile(image|color)$/)||E(e.attributes.name)==="application-name"||E(e.attributes.rel)==="icon"||E(e.attributes.rel)==="apple-touch-icon"||E(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&E(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(E(e.attributes.property).match(/^(og|twitter|fb):/)||E(e.attributes.name).match(/^(og|twitter):/)||E(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(E(e.attributes.name)==="robots"||E(e.attributes.name)==="googlebot"||E(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(E(e.attributes.name)==="author"||E(e.attributes.name)==="generator"||E(e.attributes.name)==="framework"||E(e.attributes.name)==="publisher"||E(e.attributes.name)==="progid"||E(e.attributes.property).match(/^article:/)||E(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(E(e.attributes.name)==="google-site-verification"||E(e.attributes.name)==="yandex-verification"||E(e.attributes.name)==="csrf-token"||E(e.attributes.name)==="p:domain_verify"||E(e.attributes.name)==="verify-v1"||E(e.attributes.name)==="verification"||E(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function Ie(e,t){var r=t.doc,n=t.mirror,s=t.blockClass,i=t.blockSelector,o=t.maskTextClass,c=t.maskTextSelector,a=t.skipChild,d=a===void 0?!1:a,l=t.inlineStylesheet,u=l===void 0?!0:l,h=t.maskInputOptions,f=h===void 0?{}:h,p=t.maskTextFn,y=t.maskInputFn,S=t.slimDOMOptions,C=t.dataURLOptions,m=C===void 0?{}:C,g=t.inlineImages,k=g===void 0?!1:g,z=t.recordCanvas,B=z===void 0?!1:z,D=t.onSerialize,R=t.onIframeLoad,H=t.iframeLoadTimeout,j=H===void 0?5e3:H,X=t.onStylesheetLoad,Q=t.stylesheetLoadTimeout,$=Q===void 0?5e3:Q,F=t.keepIframeSrcFn,J=F===void 0?function(){return!1}:F,re=t.newlyAddedElement,se=re===void 0?!1:re,oe=t.preserveWhiteSpace,V=oe===void 0?!0:oe,q=pn(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,dataURLOptions:m,inlineImages:k,recordCanvas:B,keepIframeSrcFn:J,newlyAddedElement:se});if(!q)return console.warn(e,"not serialized"),null;var de;n.hasNode(e)?de=n.getId(e):gn(q,S)||!V&&q.type===x.Text&&!q.isStyle&&!q.textContent.replace(/^\s+|\s+$/gm,"").length?de=Oe:de=Mt();var M=Object.assign(q,{id:de});if(n.add(e,M),de===Oe)return null;D&&D(e);var ne=!d;if(M.type===x.Element){ne=ne&&!M.needBlock,delete M.needBlock;var ie=e.shadowRoot;ie&&Me(ie)&&(M.isShadowHost=!0)}if((M.type===x.Document||M.type===x.Element)&&ne){S.headWhitespace&&M.type===x.Element&&M.tagName==="head"&&(V=!1);for(var Ee={doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:d,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:B,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:R,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J},I=0,G=Array.from(e.childNodes);I<G.length;I++){var P=G[I],T=Ie(P,Ee);T&&M.childNodes.push(T)}if(Zr(e)&&e.shadowRoot)for(var Y=0,A=Array.from(e.shadowRoot.childNodes);Y<A.length;Y++){var P=A[Y],T=Ie(P,Ee);T&&(Me(e.shadowRoot)&&(T.isShadow=!0),M.childNodes.push(T))}}return e.parentNode&&Ne(e.parentNode)&&Me(e.parentNode)&&(M.isShadow=!0),M.type===x.Element&&M.tagName==="iframe"&&ln(e,function(){var Z=e.contentDocument;if(Z&&R){var De=Ie(Z,{doc:Z,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:B,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:R,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J});De&&R(e,De)}},j),M.type===x.Element&&M.tagName==="link"&&M.attributes.rel==="stylesheet"&&un(e,function(){if(X){var Z=Ie(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:B,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:R,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J});Z&&X(e,Z)}},$),M}function yn(e,t){var r=t||{},n=r.mirror,s=n===void 0?new _t:n,i=r.blockClass,o=i===void 0?"rr-block":i,c=r.blockSelector,a=c===void 0?null:c,d=r.maskTextClass,l=d===void 0?"rr-mask":d,u=r.maskTextSelector,h=u===void 0?null:u,f=r.inlineStylesheet,p=f===void 0?!0:f,y=r.inlineImages,S=y===void 0?!1:y,C=r.recordCanvas,m=C===void 0?!1:C,g=r.maskAllInputs,k=g===void 0?!1:g,z=r.maskTextFn,B=r.maskInputFn,D=r.slimDOM,R=D===void 0?!1:D,H=r.dataURLOptions,j=r.preserveWhiteSpace,X=r.onSerialize,Q=r.onIframeLoad,$=r.iframeLoadTimeout,F=r.onStylesheetLoad,J=r.stylesheetLoadTimeout,re=r.keepIframeSrcFn,se=re===void 0?function(){return!1}:re,oe=k===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:k===!1?{password:!0}:k,V=R===!0||R==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:R==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:R===!1?{}:R;return Ie(e,{doc:e,mirror:s,blockClass:o,blockSelector:a,maskTextClass:l,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:oe,maskTextFn:z,maskInputFn:B,slimDOMOptions:V,dataURLOptions:H,inlineImages:S,recordCanvas:m,preserveWhiteSpace:j,onSerialize:X,onIframeLoad:Q,iframeLoadTimeout:$,onStylesheetLoad:F,stylesheetLoadTimeout:J,keepIframeSrcFn:se,newlyAddedElement:!1})}function U(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const Ce=`Please stop import mirror directly. Instead of that,\r
2
2
  now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
3
- or you can use record.mirror to access the mirror instance during recording.`;let xt={map:{},getId(){return console.error(Se),-1},getNode(){return console.error(Se),null},removeNodeFromMap(){console.error(Se)},has(){return console.error(Se),!1},reset(){console.error(Se)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(xt=new Proxy(xt,{get(e,t,r){return t==="map"&&console.error(Se),Reflect.get(e,t,r)}}));function Le(e,t,r={}){let n=null,s=0;return function(...i){const o=Date.now();!s&&r.leading===!1&&(s=o);const c=t-(o-s),a=this;c<=0||c>t?(n&&(clearTimeout(n),n=null),s=o,e.apply(a,i)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{s=r.leading===!1?0:Date.now(),n=null,e.apply(a,i)},c))}}function Ze(e,t,r,n,s=window){const i=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(o){setTimeout(()=>{r.set.call(this,o)},0),i&&i.set&&i.set.call(this,o)}}),()=>Ze(e,t,i||{},!0)}function ue(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],s=r(n);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=s,()=>{e[t]=n}}catch{return()=>{}}}function Bt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Dt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function W(e,t,r,n){if(!e)return!1;const s=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!s)return!1;if(typeof t=="string"){if(s.classList.contains(t)||n&&s.closest("."+t)!==null)return!0}else if(Pe(s,t,n))return!0;return!!(r&&(e.matches(r)||n&&s.closest(r)!==null))}function bn(e,t){return t.getId(e)!==-1}function it(e,t){return t.getId(e)===Oe}function Ut(e,t){if(Ne(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Ut(e.parentNode,t):!0:!0}function Wt(e){return!!e.changedTouches}function vn(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function zt(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gt(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Kt(e){return!!(e!=null&&e.shadowRoot)}class wn{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!==null&&r!==void 0?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var w=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(w||{}),b=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(b||{}),ot=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ot||{}),be=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(be||{});function Vt(e){return"__ln"in e}class An{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Vt(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&Vt(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next&&(r.next.previous=r.previous)):(this.head=r.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const Pt=(e,t)=>`${e}@${t}`;class kn{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],r=new An,n=c=>{let a=c,d=Oe;for(;d===Oe;)a=a&&a.nextSibling,d=a&&this.mirror.getId(a);return d},s=c=>{var a,d,l,u;let p=null;((d=(a=c.getRootNode)===null||a===void 0?void 0:a.call(c))===null||d===void 0?void 0:d.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host&&(p=c.getRootNode().host);let f=p;for(;((u=(l=f==null?void 0:f.getRootNode)===null||l===void 0?void 0:l.call(f))===null||u===void 0?void 0:u.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&f.getRootNode().host;)f=f.getRootNode().host;const h=!this.doc.contains(c)&&(!f||!this.doc.contains(f));if(!c.parentNode||h)return;const y=Ne(c.parentNode)?this.mirror.getId(p):this.mirror.getId(c.parentNode),S=n(c);if(y===-1||S===-1)return r.addNode(c);const C=Ce(c,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:m=>{zt(m,this.mirror)&&this.iframeManager.addIframe(m),Gt(m,this.mirror)&&this.stylesheetManager.trackLinkElement(m),Kt(c)&&this.shadowDomManager.addShadowRoot(c.shadowRoot,this.doc)},onIframeLoad:(m,g)=>{this.iframeManager.attachIframe(m,g),this.shadowDomManager.observeAttachShadow(m)},onStylesheetLoad:(m,g)=>{this.stylesheetManager.attachLinkElement(m,g)}});C&&t.push({parentId:y,nextId:S,node:C})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const c of Array.from(this.movedSet.values()))Zt(this.removes,c,this.mirror)&&!this.movedSet.has(c.parentNode)||s(c);for(const c of Array.from(this.addedSet.values()))!jt(this.droppedSet,c)&&!Zt(this.removes,c,this.mirror)||jt(this.movedSet,c)?s(c):this.droppedSet.add(c);let i=null;for(;r.length;){let c=null;if(i){const a=this.mirror.getId(i.value.parentNode),d=n(i.value);a!==-1&&d!==-1&&(c=i)}if(!c)for(let a=r.length-1;a>=0;a--){const d=r.get(a);if(d){const l=this.mirror.getId(d.value.parentNode);if(n(d.value)===-1)continue;if(l!==-1){c=d;break}else{const p=d.value;if(p.parentNode&&p.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const f=p.parentNode.host;if(this.mirror.getId(f)!==-1){c=d;break}}}}}if(!c){for(;r.head;)r.removeNode(r.head.value);break}i=c.previous,r.removeNode(c.value),s(c.value)}const o={texts:this.texts.map(c=>({id:this.mirror.getId(c.node),value:c.value})).filter(c=>this.mirror.has(c.id)),attributes:this.attributes.map(c=>({id:this.mirror.getId(c.node),attributes:c.attributes})).filter(c=>this.mirror.has(c.id)),removes:this.removes,adds:t};!o.texts.length&&!o.attributes.length&&!o.removes.length&&!o.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))},this.processMutation=t=>{if(!it(t.target,this.mirror))switch(t.type){case"characterData":{const r=t.target.textContent;!W(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:Ft(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.target.getAttribute(t.attributeName);if(t.attributeName==="value"&&(n=nt({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),W(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let s=this.attributes.find(i=>i.node===t.target);if(r.tagName==="IFRAME"&&t.attributeName==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)t.attributeName="rr_src";else return;if(s||(s={node:t.target,attributes:{}},this.attributes.push(s)),t.attributeName==="style"){const i=this.doc.createElement("span");t.oldValue&&i.setAttribute("style",t.oldValue),(s.attributes.style===void 0||s.attributes.style===null)&&(s.attributes.style={});const o=s.attributes.style;for(const c of Array.from(r.style)){const a=r.style.getPropertyValue(c),d=r.style.getPropertyPriority(c);(a!==i.style.getPropertyValue(c)||d!==i.style.getPropertyPriority(c))&&(d===""?o[c]=a:o[c]=[a,d])}for(const c of Array.from(i.style))r.style.getPropertyValue(c)===""&&(o[c]=!1)}else s.attributes[t.attributeName]=Lt(this.doc,r.tagName,t.attributeName,n);break}case"childList":{if(W(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),s=Ne(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);W(t.target,this.blockClass,this.blockSelector,!1)||it(r,this.mirror)||!bn(r,this.mirror)||(this.addedSet.has(r)?(at(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||Ut(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Pt(n,s)]?at(this.movedSet,r):this.removes.push({parentId:s,id:n,isShadow:Ne(t.target)&&Me(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,r)=>{if(this.mirror.hasNode(t)){if(it(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[Pt(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);W(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(n=>this.genAdds(n))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function at(e,t){e.delete(t),t.childNodes.forEach(r=>at(e,r))}function Zt(e,t,r){return e.length===0?!1:Ht(e,t,r)}function Ht(e,t,r){const{parentNode:n}=t;if(!n)return!1;const s=r.getId(n);return e.some(i=>i.id===s)?!0:Ht(e,n,r)}function jt(e,t){return e.size===0?!1:Jt(e,t)}function Jt(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:Jt(e,r):!1}const he=[],qt=typeof CSSGroupingRule<"u",Yt=typeof CSSMediaRule<"u",Xt=typeof CSSSupportsRule<"u",Qt=typeof CSSConditionRule<"u";function Fe(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function $t(e,t){var r,n;const s=new kn;he.push(s),s.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const o=(n=(r=window==null?void 0:window.Zone)===null||r===void 0?void 0:r.__symbol__)===null||n===void 0?void 0:n.call(r,"MutationObserver");o&&window[o]&&(i=window[o]);const c=new i(s.processMutations.bind(s));return c.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),c}function En({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const s=typeof t.mousemove=="number"?t.mousemove:50,i=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let o=[],c;const a=Le(u=>{const p=Date.now()-c;e(o.map(f=>(f.timeOffset-=p,f)),u),o=[],c=null},i),d=Le(u=>{const p=Fe(u),{clientX:f,clientY:h}=Wt(u)?u.changedTouches[0]:u;c||(c=Date.now()),o.push({x:f,y:h,id:n.getId(p),timeOffset:Date.now()-c}),a(typeof DragEvent<"u"&&u instanceof DragEvent?b.Drag:u instanceof MouseEvent?b.MouseMove:b.TouchMove)},s,{trailing:!1}),l=[U("mousemove",d,r),U("touchmove",d,r),U("drag",d,r)];return()=>{l.forEach(u=>u())}}function Tn({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const o=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,c=[],a=d=>l=>{const u=Fe(l);if(W(u,n,s,!0))return;const p=Wt(l)?l.changedTouches[0]:l;if(!p)return;const f=r.getId(u),{clientX:h,clientY:y}=p;e({type:ot[d],id:f,x:h,y})};return Object.keys(ot).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&o[d]!==!1).forEach(d=>{const l=d.toLowerCase(),u=a(d);c.push(U(l,u,t))}),()=>{c.forEach(d=>d())}}function er({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){const o=Le(c=>{const a=Fe(c);if(!a||W(a,n,s,!0))return;const d=r.getId(a);if(a===t){const l=t.scrollingElement||t.documentElement;e({id:d,x:l.scrollLeft,y:l.scrollTop})}else e({id:d,x:a.scrollLeft,y:a.scrollTop})},i.scroll||100);return U("scroll",o,t)}function Rn({viewportResizeCb:e}){let t=-1,r=-1;const n=Le(()=>{const s=Bt(),i=Dt();(t!==s||r!==i)&&(e({width:Number(i),height:Number(s)}),t=s,r=i)},200);return U("resize",n,window)}function tr(e,t){const r=Object.assign({},e);return t||delete r.userTriggered,r}const _n=["INPUT","TEXTAREA","SELECT"],rr=new WeakMap;function Nn({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,ignoreClass:i,maskInputOptions:o,maskInputFn:c,sampling:a,userTriggeredOnInput:d}){function l(C){let m=Fe(C);const g=C.isTrusted;if(m&&m.tagName==="OPTION"&&(m=m.parentElement),!m||!m.tagName||_n.indexOf(m.tagName)<0||W(m,n,s,!0))return;const k=m.type;if(m.classList.contains(i))return;let z=m.value,x=!1;k==="radio"||k==="checkbox"?x=m.checked:(o[m.tagName.toLowerCase()]||o[k])&&(z=nt({maskInputOptions:o,tagName:m.tagName,type:k,value:z,maskInputFn:c})),u(m,tr({text:z,isChecked:x,userTriggered:g},d));const B=m.name;k==="radio"&&B&&x&&t.querySelectorAll(`input[type="radio"][name="${B}"]`).forEach(T=>{T!==m&&u(T,tr({text:T.value,isChecked:!x,userTriggered:!1},d))})}function u(C,m){const g=rr.get(C);if(!g||g.text!==m.text||g.isChecked!==m.isChecked){rr.set(C,m);const k=r.getId(C);e(Object.assign(Object.assign({},m),{id:k}))}}const f=(a.input==="last"?["change"]:["input","change"]).map(C=>U(C,l,t)),h=t.defaultView;if(!h)return()=>{f.forEach(C=>C())};const y=h.Object.getOwnPropertyDescriptor(h.HTMLInputElement.prototype,"value"),S=[[h.HTMLInputElement.prototype,"value"],[h.HTMLInputElement.prototype,"checked"],[h.HTMLSelectElement.prototype,"value"],[h.HTMLTextAreaElement.prototype,"value"],[h.HTMLSelectElement.prototype,"selectedIndex"],[h.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&f.push(...S.map(C=>Ze(C[0],C[1],{set(){l({target:this})}},!1,h))),()=>{f.forEach(C=>C())}}function He(e){const t=[];function r(n,s){if(qt&&n.parentRule instanceof CSSGroupingRule||Yt&&n.parentRule instanceof CSSMediaRule||Xt&&n.parentRule instanceof CSSSupportsRule||Qt&&n.parentRule instanceof CSSConditionRule){const o=Array.from(n.parentRule.cssRules).indexOf(n);s.unshift(o)}else if(n.parentStyleSheet){const o=Array.from(n.parentStyleSheet.cssRules).indexOf(n);s.unshift(o)}return s}return r(e,t)}function de(e,t,r){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=r.getId(e),{styleId:s,id:n}):{}}function Mn({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){const s=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(l,u){const{id:p,styleId:f}=de(this,t,r.styleMirror);return(p&&p!==-1||f&&f!==-1)&&e({id:p,styleId:f,adds:[{rule:l,index:u}]}),s.apply(this,[l,u])};const i=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(l){const{id:u,styleId:p}=de(this,t,r.styleMirror);return(u&&u!==-1||p&&p!==-1)&&e({id:u,styleId:p,removes:[{index:l}]}),i.apply(this,[l])};let o;n.CSSStyleSheet.prototype.replace&&(o=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(l){const{id:u,styleId:p}=de(this,t,r.styleMirror);return(u&&u!==-1||p&&p!==-1)&&e({id:u,styleId:p,replace:l}),o.apply(this,[l])});let c;n.CSSStyleSheet.prototype.replaceSync&&(c=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(l){const{id:u,styleId:p}=de(this,t,r.styleMirror);return(u&&u!==-1||p&&p!==-1)&&e({id:u,styleId:p,replaceSync:l}),c.apply(this,[l])});const a={};qt?a.CSSGroupingRule=n.CSSGroupingRule:(Yt&&(a.CSSMediaRule=n.CSSMediaRule),Qt&&(a.CSSConditionRule=n.CSSConditionRule),Xt&&(a.CSSSupportsRule=n.CSSSupportsRule));const d={};return Object.entries(a).forEach(([l,u])=>{d[l]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=function(p,f){const{id:h,styleId:y}=de(this.parentStyleSheet,t,r.styleMirror);return(h&&h!==-1||y&&y!==-1)&&e({id:h,styleId:y,adds:[{rule:p,index:[...He(this),f||0]}]}),d[l].insertRule.apply(this,[p,f])},u.prototype.deleteRule=function(p){const{id:f,styleId:h}=de(this.parentStyleSheet,t,r.styleMirror);return(f&&f!==-1||h&&h!==-1)&&e({id:f,styleId:h,removes:[{index:[...He(this),p]}]}),d[l].deleteRule.apply(this,[p])}}),()=>{n.CSSStyleSheet.prototype.insertRule=s,n.CSSStyleSheet.prototype.deleteRule=i,o&&(n.CSSStyleSheet.prototype.replace=o),c&&(n.CSSStyleSheet.prototype.replaceSync=c),Object.entries(a).forEach(([l,u])=>{u.prototype.insertRule=d[l].insertRule,u.prototype.deleteRule=d[l].deleteRule})}}function nr({mirror:e,stylesheetManager:t},r){var n,s,i;let o=null;r.nodeName==="#document"?o=e.getId(r):o=e.getId(r.host);const c=r.nodeName==="#document"?(n=r.defaultView)===null||n===void 0?void 0:n.Document:(i=(s=r.ownerDocument)===null||s===void 0?void 0:s.defaultView)===null||i===void 0?void 0:i.ShadowRoot,a=Object.getOwnPropertyDescriptor(c==null?void 0:c.prototype,"adoptedStyleSheets");return o===null||o===-1||!c||!a?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var d;return(d=a.get)===null||d===void 0?void 0:d.call(this)},set(d){var l;const u=(l=a.set)===null||l===void 0?void 0:l.call(this,d);if(o!==null&&o!==-1)try{t.adoptStyleSheets(d,o)}catch{}return u}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})}function On({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:s}){const i=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=function(c,a,d){var l;if(r.has(c))return i.apply(this,[c,a,d]);const{id:u,styleId:p}=de((l=this.parentRule)===null||l===void 0?void 0:l.parentStyleSheet,t,n.styleMirror);return(u&&u!==-1||p&&p!==-1)&&e({id:u,styleId:p,set:{property:c,value:a,priority:d},index:He(this.parentRule)}),i.apply(this,[c,a,d])};const o=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=function(c){var a;if(r.has(c))return o.apply(this,[c]);const{id:d,styleId:l}=de((a=this.parentRule)===null||a===void 0?void 0:a.parentStyleSheet,t,n.styleMirror);return(d&&d!==-1||l&&l!==-1)&&e({id:d,styleId:l,remove:{property:c},index:He(this.parentRule)}),o.apply(this,[c])},()=>{s.CSSStyleDeclaration.prototype.setProperty=i,s.CSSStyleDeclaration.prototype.removeProperty=o}}function Ln({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:s}){const i=c=>Le(a=>{const d=Fe(a);if(!d||W(d,t,r,!0))return;const{currentTime:l,volume:u,muted:p,playbackRate:f}=d;e({type:c,id:n.getId(d),currentTime:l,volume:u,muted:p,playbackRate:f})},s.media||500),o=[U("play",i(0)),U("pause",i(1)),U("seeked",i(2)),U("volumechange",i(3)),U("ratechange",i(4))];return()=>{o.forEach(c=>c())}}function Fn({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],s=new WeakMap,i=r.FontFace;r.FontFace=function(a,d,l){const u=new i(a,d,l);return s.set(u,{family:a,buffer:typeof d!="string",descriptors:l,fontSource:typeof d=="string"?d:JSON.stringify(Array.from(new Uint8Array(d)))}),u};const o=ue(t.fonts,"add",function(c){return function(a){return setTimeout(()=>{const d=s.get(a);d&&(e(d),s.delete(a))},0),c.apply(this,[a])}});return n.push(()=>{r.FontFace=i}),n.push(o),()=>{n.forEach(c=>c())}}function xn(e){const{doc:t,mirror:r,blockClass:n,blockSelector:s,selectionCb:i}=e;let o=!0;const c=()=>{const a=t.getSelection();if(!a||o&&(a!=null&&a.isCollapsed))return;o=a.isCollapsed||!1;const d=[],l=a.rangeCount||0;for(let u=0;u<l;u++){const p=a.getRangeAt(u),{startContainer:f,startOffset:h,endContainer:y,endOffset:S}=p;W(f,n,s,!0)||W(y,n,s,!0)||d.push({start:r.getId(f),startOffset:h,end:r.getId(y),endOffset:S})}i({ranges:d})};return c(),U("selectionchange",c)}function Bn(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:s,scrollCb:i,viewportResizeCb:o,inputCb:c,mediaInteractionCb:a,styleSheetRuleCb:d,styleDeclarationCb:l,canvasMutationCb:u,fontCb:p,selectionCb:f}=e;e.mutationCb=(...h)=>{t.mutation&&t.mutation(...h),r(...h)},e.mousemoveCb=(...h)=>{t.mousemove&&t.mousemove(...h),n(...h)},e.mouseInteractionCb=(...h)=>{t.mouseInteraction&&t.mouseInteraction(...h),s(...h)},e.scrollCb=(...h)=>{t.scroll&&t.scroll(...h),i(...h)},e.viewportResizeCb=(...h)=>{t.viewportResize&&t.viewportResize(...h),o(...h)},e.inputCb=(...h)=>{t.input&&t.input(...h),c(...h)},e.mediaInteractionCb=(...h)=>{t.mediaInteaction&&t.mediaInteaction(...h),a(...h)},e.styleSheetRuleCb=(...h)=>{t.styleSheetRule&&t.styleSheetRule(...h),d(...h)},e.styleDeclarationCb=(...h)=>{t.styleDeclaration&&t.styleDeclaration(...h),l(...h)},e.canvasMutationCb=(...h)=>{t.canvasMutation&&t.canvasMutation(...h),u(...h)},e.fontCb=(...h)=>{t.font&&t.font(...h),p(...h)},e.selectionCb=(...h)=>{t.selection&&t.selection(...h),f(...h)}}function Dn(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};Bn(e,t);const n=$t(e,e.doc),s=En(e),i=Tn(e),o=er(e),c=Rn(e),a=Nn(e),d=Ln(e),l=Mn(e,{win:r}),u=nr(e,e.doc),p=On(e,{win:r}),f=e.collectFonts?Fn(e):()=>{},h=xn(e),y=[];for(const S of e.plugins)y.push(S.observer(S.callback,r,S.options));return()=>{he.forEach(S=>S.reset()),n.disconnect(),s(),i(),o(),c(),a(),d(),l(),u(),p(),f(),h(),y.forEach(S=>S())}}class sr{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,s){const i=n||this.getIdToRemoteIdMap(t),o=s||this.getRemoteIdToIdMap(t);let c=i.get(r);return c||(c=this.generateIdFn(),i.set(r,c),o.set(c,r)),c}getIds(t,r){const n=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,n,s))}getRemoteId(t,r,n){const s=n||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;const i=s.get(r);return i||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getRemoteId(t,s,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Un{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new sr(Mt),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new sr(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)===null||n===void 0||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if(t.data.type==="rrweb"){if(!t.source)return;const n=this.crossOriginIframeMap.get(t.source);if(!n)return;const s=this.transformCrossOriginEvent(n,t.data.event);s&&this.wrappedEmit(s,t.data.isCheckout)}}transformCrossOriginEvent(t,r){var n;switch(r.type){case w.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t),{timestamp:r.timestamp,type:w.IncrementalSnapshot,data:{source:b.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case w.Meta:case w.Load:case w.DomContentLoaded:return!1;case w.Plugin:return r;case w.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case w.IncrementalSnapshot:switch(r.data.source){case b.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,t)}),r.data.removes.forEach(s=>{this.replaceIds(s,t,["parentId","id"])}),r.data.attributes.forEach(s=>{this.replaceIds(s,t,["id"])}),r.data.texts.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case b.Drag:case b.TouchMove:case b.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case b.ViewportResize:return!1;case b.MediaInteraction:case b.MouseInteraction:case b.Scroll:case b.CanvasMutation:case b.Input:return this.replaceIds(r.data,t,["id"]),r;case b.StyleSheetRule:case b.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case b.Font:return r;case b.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,t,["start","end"])}),r;case b.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)===null||n===void 0||n.forEach(s=>{this.replaceStyleIds(s,t,["styleId"])}),r}}}replace(t,r,n,s){for(const i of s)!Array.isArray(r[i])&&typeof r[i]!="number"||(Array.isArray(r[i])?r[i]=t.getIds(n,r[i]):r[i]=t.getId(n,r[i]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}}class Wn{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const r=this;this.restorePatches.push(ue(Element.prototype,"attachShadow",function(n){return function(s){const i=n.call(this,s);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,r){Me(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),$t(Object.assign(Object.assign({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),er(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),nr({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const r=this;this.restorePatches.push(ue(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(s){const i=n.call(this,s);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,t.contentDocument),i}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}/*! *****************************************************************************
3
+ or you can use record.mirror to access the mirror instance during recording.`;let xt={map:{},getId(){return console.error(Ce),-1},getNode(){return console.error(Ce),null},removeNodeFromMap(){console.error(Ce)},has(){return console.error(Ce),!1},reset(){console.error(Ce)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(xt=new Proxy(xt,{get(e,t,r){return t==="map"&&console.error(Ce),Reflect.get(e,t,r)}}));function Le(e,t,r={}){let n=null,s=0;return function(...i){const o=Date.now();!s&&r.leading===!1&&(s=o);const c=t-(o-s),a=this;c<=0||c>t?(n&&(clearTimeout(n),n=null),s=o,e.apply(a,i)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{s=r.leading===!1?0:Date.now(),n=null,e.apply(a,i)},c))}}function Pe(e,t,r,n,s=window){const i=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(o){setTimeout(()=>{r.set.call(this,o)},0),i&&i.set&&i.set.call(this,o)}}),()=>Pe(e,t,i||{},!0)}function le(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],s=r(n);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=s,()=>{e[t]=n}}catch{return()=>{}}}function Bt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Dt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function W(e,t,r,n){if(!e)return!1;const s=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!s)return!1;if(typeof t=="string"){if(s.classList.contains(t)||n&&s.closest("."+t)!==null)return!0}else if(Ve(s,t,n))return!0;return!!(r&&(e.matches(r)||n&&s.closest(r)!==null))}function In(e,t){return t.getId(e)!==-1}function it(e,t){return t.getId(e)===Oe}function Ut(e,t){if(Ne(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Ut(e.parentNode,t):!0:!0}function Wt(e){return!!e.changedTouches}function Cn(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function zt(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gt(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Kt(e){return!!(e!=null&&e.shadowRoot)}class Sn{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!==null&&r!==void 0?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var v=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(v||{}),b=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(b||{}),ot=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ot||{}),Se=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Se||{});function Vt(e){return"__ln"in e}class bn{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Vt(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&Vt(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next&&(r.next.previous=r.previous)):(this.head=r.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const Pt=(e,t)=>`${e}@${t}`;class vn{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],r=new bn,n=c=>{let a=c,d=Oe;for(;d===Oe;)a=a&&a.nextSibling,d=a&&this.mirror.getId(a);return d},s=c=>{var a,d,l,u;let h=null;((d=(a=c.getRootNode)===null||a===void 0?void 0:a.call(c))===null||d===void 0?void 0:d.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host&&(h=c.getRootNode().host);let f=h;for(;((u=(l=f==null?void 0:f.getRootNode)===null||l===void 0?void 0:l.call(f))===null||u===void 0?void 0:u.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&f.getRootNode().host;)f=f.getRootNode().host;const p=!this.doc.contains(c)&&(!f||!this.doc.contains(f));if(!c.parentNode||p)return;const y=Ne(c.parentNode)?this.mirror.getId(h):this.mirror.getId(c.parentNode),S=n(c);if(y===-1||S===-1)return r.addNode(c);const C=Ie(c,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:m=>{zt(m,this.mirror)&&this.iframeManager.addIframe(m),Gt(m,this.mirror)&&this.stylesheetManager.trackLinkElement(m),Kt(c)&&this.shadowDomManager.addShadowRoot(c.shadowRoot,this.doc)},onIframeLoad:(m,g)=>{this.iframeManager.attachIframe(m,g),this.shadowDomManager.observeAttachShadow(m)},onStylesheetLoad:(m,g)=>{this.stylesheetManager.attachLinkElement(m,g)}});C&&t.push({parentId:y,nextId:S,node:C})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const c of Array.from(this.movedSet.values()))Zt(this.removes,c,this.mirror)&&!this.movedSet.has(c.parentNode)||s(c);for(const c of Array.from(this.addedSet.values()))!jt(this.droppedSet,c)&&!Zt(this.removes,c,this.mirror)||jt(this.movedSet,c)?s(c):this.droppedSet.add(c);let i=null;for(;r.length;){let c=null;if(i){const a=this.mirror.getId(i.value.parentNode),d=n(i.value);a!==-1&&d!==-1&&(c=i)}if(!c)for(let a=r.length-1;a>=0;a--){const d=r.get(a);if(d){const l=this.mirror.getId(d.value.parentNode);if(n(d.value)===-1)continue;if(l!==-1){c=d;break}else{const h=d.value;if(h.parentNode&&h.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const f=h.parentNode.host;if(this.mirror.getId(f)!==-1){c=d;break}}}}}if(!c){for(;r.head;)r.removeNode(r.head.value);break}i=c.previous,r.removeNode(c.value),s(c.value)}const o={texts:this.texts.map(c=>({id:this.mirror.getId(c.node),value:c.value})).filter(c=>this.mirror.has(c.id)),attributes:this.attributes.map(c=>({id:this.mirror.getId(c.node),attributes:c.attributes})).filter(c=>this.mirror.has(c.id)),removes:this.removes,adds:t};!o.texts.length&&!o.attributes.length&&!o.removes.length&&!o.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))},this.processMutation=t=>{if(!it(t.target,this.mirror))switch(t.type){case"characterData":{const r=t.target.textContent;!W(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:Ft(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.target.getAttribute(t.attributeName);if(t.attributeName==="value"&&(n=nt({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),W(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let s=this.attributes.find(i=>i.node===t.target);if(r.tagName==="IFRAME"&&t.attributeName==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)t.attributeName="rr_src";else return;if(s||(s={node:t.target,attributes:{}},this.attributes.push(s)),t.attributeName==="style"){const i=this.doc.createElement("span");t.oldValue&&i.setAttribute("style",t.oldValue),(s.attributes.style===void 0||s.attributes.style===null)&&(s.attributes.style={});const o=s.attributes.style;for(const c of Array.from(r.style)){const a=r.style.getPropertyValue(c),d=r.style.getPropertyPriority(c);(a!==i.style.getPropertyValue(c)||d!==i.style.getPropertyPriority(c))&&(d===""?o[c]=a:o[c]=[a,d])}for(const c of Array.from(i.style))r.style.getPropertyValue(c)===""&&(o[c]=!1)}else s.attributes[t.attributeName]=Lt(this.doc,r.tagName,t.attributeName,n);break}case"childList":{if(W(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),s=Ne(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);W(t.target,this.blockClass,this.blockSelector,!1)||it(r,this.mirror)||!In(r,this.mirror)||(this.addedSet.has(r)?(at(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||Ut(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Pt(n,s)]?at(this.movedSet,r):this.removes.push({parentId:s,id:n,isShadow:Ne(t.target)&&Me(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,r)=>{if(this.mirror.hasNode(t)){if(it(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[Pt(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);W(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(n=>this.genAdds(n))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function at(e,t){e.delete(t),t.childNodes.forEach(r=>at(e,r))}function Zt(e,t,r){return e.length===0?!1:Ht(e,t,r)}function Ht(e,t,r){const{parentNode:n}=t;if(!n)return!1;const s=r.getId(n);return e.some(i=>i.id===s)?!0:Ht(e,n,r)}function jt(e,t){return e.size===0?!1:Jt(e,t)}function Jt(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:Jt(e,r):!1}const ue=[],qt=typeof CSSGroupingRule<"u",Yt=typeof CSSMediaRule<"u",Xt=typeof CSSSupportsRule<"u",Qt=typeof CSSConditionRule<"u";function Fe(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function $t(e,t){var r,n;const s=new vn;ue.push(s),s.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const o=(n=(r=window==null?void 0:window.Zone)===null||r===void 0?void 0:r.__symbol__)===null||n===void 0?void 0:n.call(r,"MutationObserver");o&&window[o]&&(i=window[o]);const c=new i(s.processMutations.bind(s));return c.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),c}function wn({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const s=typeof t.mousemove=="number"?t.mousemove:50,i=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let o=[],c;const a=Le(u=>{const h=Date.now()-c;e(o.map(f=>(f.timeOffset-=h,f)),u),o=[],c=null},i),d=Le(u=>{const h=Fe(u),{clientX:f,clientY:p}=Wt(u)?u.changedTouches[0]:u;c||(c=Date.now()),o.push({x:f,y:p,id:n.getId(h),timeOffset:Date.now()-c}),a(typeof DragEvent<"u"&&u instanceof DragEvent?b.Drag:u instanceof MouseEvent?b.MouseMove:b.TouchMove)},s,{trailing:!1}),l=[U("mousemove",d,r),U("touchmove",d,r),U("drag",d,r)];return()=>{l.forEach(u=>u())}}function An({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const o=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,c=[],a=d=>l=>{const u=Fe(l);if(W(u,n,s,!0))return;const h=Wt(l)?l.changedTouches[0]:l;if(!h)return;const f=r.getId(u),{clientX:p,clientY:y}=h;e({type:ot[d],id:f,x:p,y})};return Object.keys(ot).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&o[d]!==!1).forEach(d=>{const l=d.toLowerCase(),u=a(d);c.push(U(l,u,t))}),()=>{c.forEach(d=>d())}}function er({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){const o=Le(c=>{const a=Fe(c);if(!a||W(a,n,s,!0))return;const d=r.getId(a);if(a===t){const l=t.scrollingElement||t.documentElement;e({id:d,x:l.scrollLeft,y:l.scrollTop})}else e({id:d,x:a.scrollLeft,y:a.scrollTop})},i.scroll||100);return U("scroll",o,t)}function kn({viewportResizeCb:e}){let t=-1,r=-1;const n=Le(()=>{const s=Bt(),i=Dt();(t!==s||r!==i)&&(e({width:Number(i),height:Number(s)}),t=s,r=i)},200);return U("resize",n,window)}function tr(e,t){const r=Object.assign({},e);return t||delete r.userTriggered,r}const En=["INPUT","TEXTAREA","SELECT"],rr=new WeakMap;function Rn({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,ignoreClass:i,maskInputOptions:o,maskInputFn:c,sampling:a,userTriggeredOnInput:d}){function l(C){let m=Fe(C);const g=C.isTrusted;if(m&&m.tagName==="OPTION"&&(m=m.parentElement),!m||!m.tagName||En.indexOf(m.tagName)<0||W(m,n,s,!0))return;const k=m.type;if(m.classList.contains(i))return;let z=m.value,B=!1;k==="radio"||k==="checkbox"?B=m.checked:(o[m.tagName.toLowerCase()]||o[k])&&(z=nt({maskInputOptions:o,tagName:m.tagName,type:k,value:z,maskInputFn:c})),u(m,tr({text:z,isChecked:B,userTriggered:g},d));const D=m.name;k==="radio"&&D&&B&&t.querySelectorAll(`input[type="radio"][name="${D}"]`).forEach(R=>{R!==m&&u(R,tr({text:R.value,isChecked:!B,userTriggered:!1},d))})}function u(C,m){const g=rr.get(C);if(!g||g.text!==m.text||g.isChecked!==m.isChecked){rr.set(C,m);const k=r.getId(C);e(Object.assign(Object.assign({},m),{id:k}))}}const f=(a.input==="last"?["change"]:["input","change"]).map(C=>U(C,l,t)),p=t.defaultView;if(!p)return()=>{f.forEach(C=>C())};const y=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),S=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&f.push(...S.map(C=>Pe(C[0],C[1],{set(){l({target:this})}},!1,p))),()=>{f.forEach(C=>C())}}function Ze(e){const t=[];function r(n,s){if(qt&&n.parentRule instanceof CSSGroupingRule||Yt&&n.parentRule instanceof CSSMediaRule||Xt&&n.parentRule instanceof CSSSupportsRule||Qt&&n.parentRule instanceof CSSConditionRule){const o=Array.from(n.parentRule.cssRules).indexOf(n);s.unshift(o)}else if(n.parentStyleSheet){const o=Array.from(n.parentStyleSheet.cssRules).indexOf(n);s.unshift(o)}return s}return r(e,t)}function ce(e,t,r){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=r.getId(e),{styleId:s,id:n}):{}}function Tn({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){const s=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(l,u){const{id:h,styleId:f}=ce(this,t,r.styleMirror);return(h&&h!==-1||f&&f!==-1)&&e({id:h,styleId:f,adds:[{rule:l,index:u}]}),s.apply(this,[l,u])};const i=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(l){const{id:u,styleId:h}=ce(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,removes:[{index:l}]}),i.apply(this,[l])};let o;n.CSSStyleSheet.prototype.replace&&(o=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(l){const{id:u,styleId:h}=ce(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replace:l}),o.apply(this,[l])});let c;n.CSSStyleSheet.prototype.replaceSync&&(c=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(l){const{id:u,styleId:h}=ce(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replaceSync:l}),c.apply(this,[l])});const a={};qt?a.CSSGroupingRule=n.CSSGroupingRule:(Yt&&(a.CSSMediaRule=n.CSSMediaRule),Qt&&(a.CSSConditionRule=n.CSSConditionRule),Xt&&(a.CSSSupportsRule=n.CSSSupportsRule));const d={};return Object.entries(a).forEach(([l,u])=>{d[l]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=function(h,f){const{id:p,styleId:y}=ce(this.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||y&&y!==-1)&&e({id:p,styleId:y,adds:[{rule:h,index:[...Ze(this),f||0]}]}),d[l].insertRule.apply(this,[h,f])},u.prototype.deleteRule=function(h){const{id:f,styleId:p}=ce(this.parentStyleSheet,t,r.styleMirror);return(f&&f!==-1||p&&p!==-1)&&e({id:f,styleId:p,removes:[{index:[...Ze(this),h]}]}),d[l].deleteRule.apply(this,[h])}}),()=>{n.CSSStyleSheet.prototype.insertRule=s,n.CSSStyleSheet.prototype.deleteRule=i,o&&(n.CSSStyleSheet.prototype.replace=o),c&&(n.CSSStyleSheet.prototype.replaceSync=c),Object.entries(a).forEach(([l,u])=>{u.prototype.insertRule=d[l].insertRule,u.prototype.deleteRule=d[l].deleteRule})}}function nr({mirror:e,stylesheetManager:t},r){var n,s,i;let o=null;r.nodeName==="#document"?o=e.getId(r):o=e.getId(r.host);const c=r.nodeName==="#document"?(n=r.defaultView)===null||n===void 0?void 0:n.Document:(i=(s=r.ownerDocument)===null||s===void 0?void 0:s.defaultView)===null||i===void 0?void 0:i.ShadowRoot,a=Object.getOwnPropertyDescriptor(c==null?void 0:c.prototype,"adoptedStyleSheets");return o===null||o===-1||!c||!a?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var d;return(d=a.get)===null||d===void 0?void 0:d.call(this)},set(d){var l;const u=(l=a.set)===null||l===void 0?void 0:l.call(this,d);if(o!==null&&o!==-1)try{t.adoptStyleSheets(d,o)}catch{}return u}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})}function _n({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:s}){const i=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=function(c,a,d){var l;if(r.has(c))return i.apply(this,[c,a,d]);const{id:u,styleId:h}=ce((l=this.parentRule)===null||l===void 0?void 0:l.parentStyleSheet,t,n.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,set:{property:c,value:a,priority:d},index:Ze(this.parentRule)}),i.apply(this,[c,a,d])};const o=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=function(c){var a;if(r.has(c))return o.apply(this,[c]);const{id:d,styleId:l}=ce((a=this.parentRule)===null||a===void 0?void 0:a.parentStyleSheet,t,n.styleMirror);return(d&&d!==-1||l&&l!==-1)&&e({id:d,styleId:l,remove:{property:c},index:Ze(this.parentRule)}),o.apply(this,[c])},()=>{s.CSSStyleDeclaration.prototype.setProperty=i,s.CSSStyleDeclaration.prototype.removeProperty=o}}function Nn({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:s}){const i=c=>Le(a=>{const d=Fe(a);if(!d||W(d,t,r,!0))return;const{currentTime:l,volume:u,muted:h,playbackRate:f}=d;e({type:c,id:n.getId(d),currentTime:l,volume:u,muted:h,playbackRate:f})},s.media||500),o=[U("play",i(0)),U("pause",i(1)),U("seeked",i(2)),U("volumechange",i(3)),U("ratechange",i(4))];return()=>{o.forEach(c=>c())}}function Mn({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],s=new WeakMap,i=r.FontFace;r.FontFace=function(a,d,l){const u=new i(a,d,l);return s.set(u,{family:a,buffer:typeof d!="string",descriptors:l,fontSource:typeof d=="string"?d:JSON.stringify(Array.from(new Uint8Array(d)))}),u};const o=le(t.fonts,"add",function(c){return function(a){return setTimeout(()=>{const d=s.get(a);d&&(e(d),s.delete(a))},0),c.apply(this,[a])}});return n.push(()=>{r.FontFace=i}),n.push(o),()=>{n.forEach(c=>c())}}function On(e){const{doc:t,mirror:r,blockClass:n,blockSelector:s,selectionCb:i}=e;let o=!0;const c=()=>{const a=t.getSelection();if(!a||o&&(a!=null&&a.isCollapsed))return;o=a.isCollapsed||!1;const d=[],l=a.rangeCount||0;for(let u=0;u<l;u++){const h=a.getRangeAt(u),{startContainer:f,startOffset:p,endContainer:y,endOffset:S}=h;W(f,n,s,!0)||W(y,n,s,!0)||d.push({start:r.getId(f),startOffset:p,end:r.getId(y),endOffset:S})}i({ranges:d})};return c(),U("selectionchange",c)}function Ln(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:s,scrollCb:i,viewportResizeCb:o,inputCb:c,mediaInteractionCb:a,styleSheetRuleCb:d,styleDeclarationCb:l,canvasMutationCb:u,fontCb:h,selectionCb:f}=e;e.mutationCb=(...p)=>{t.mutation&&t.mutation(...p),r(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),n(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),s(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),i(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),o(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),c(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),a(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),d(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),l(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),u(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),h(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),f(...p)}}function Fn(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};Ln(e,t);const n=$t(e,e.doc),s=wn(e),i=An(e),o=er(e),c=kn(e),a=Rn(e),d=Nn(e),l=Tn(e,{win:r}),u=nr(e,e.doc),h=_n(e,{win:r}),f=e.collectFonts?Mn(e):()=>{},p=On(e),y=[];for(const S of e.plugins)y.push(S.observer(S.callback,r,S.options));return()=>{ue.forEach(S=>S.reset()),n.disconnect(),s(),i(),o(),c(),a(),d(),l(),u(),h(),f(),p(),y.forEach(S=>S())}}class sr{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,s){const i=n||this.getIdToRemoteIdMap(t),o=s||this.getRemoteIdToIdMap(t);let c=i.get(r);return c||(c=this.generateIdFn(),i.set(r,c),o.set(c,r)),c}getIds(t,r){const n=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,n,s))}getRemoteId(t,r,n){const s=n||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;const i=s.get(r);return i||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getRemoteId(t,s,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class xn{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new sr(Mt),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new sr(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)===null||n===void 0||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if(t.data.type==="rrweb"){if(!t.source)return;const n=this.crossOriginIframeMap.get(t.source);if(!n)return;const s=this.transformCrossOriginEvent(n,t.data.event);s&&this.wrappedEmit(s,t.data.isCheckout)}}transformCrossOriginEvent(t,r){var n;switch(r.type){case v.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t),{timestamp:r.timestamp,type:v.IncrementalSnapshot,data:{source:b.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case v.Meta:case v.Load:case v.DomContentLoaded:return!1;case v.Plugin:return r;case v.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case v.IncrementalSnapshot:switch(r.data.source){case b.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,t)}),r.data.removes.forEach(s=>{this.replaceIds(s,t,["parentId","id"])}),r.data.attributes.forEach(s=>{this.replaceIds(s,t,["id"])}),r.data.texts.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case b.Drag:case b.TouchMove:case b.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case b.ViewportResize:return!1;case b.MediaInteraction:case b.MouseInteraction:case b.Scroll:case b.CanvasMutation:case b.Input:return this.replaceIds(r.data,t,["id"]),r;case b.StyleSheetRule:case b.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case b.Font:return r;case b.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,t,["start","end"])}),r;case b.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)===null||n===void 0||n.forEach(s=>{this.replaceStyleIds(s,t,["styleId"])}),r}}}replace(t,r,n,s){for(const i of s)!Array.isArray(r[i])&&typeof r[i]!="number"||(Array.isArray(r[i])?r[i]=t.getIds(n,r[i]):r[i]=t.getId(n,r[i]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}}class Bn{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const r=this;this.restorePatches.push(le(Element.prototype,"attachShadow",function(n){return function(s){const i=n.call(this,s);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,r){Me(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),$t(Object.assign(Object.assign({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),er(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),nr({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const r=this;this.restorePatches.push(le(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(s){const i=n.call(this,s);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,t.contentDocument),i}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}/*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
5
5
 
6
6
  Permission to use, copy, modify, and/or distribute this software for any
@@ -13,15 +13,15 @@ or you can use record.mirror to access the mirror instance during recording.`;le
13
13
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */function zn(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function Gn(e,t,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(l){try{d(n.next(l))}catch(u){o(u)}}function a(l){try{d(n.throw(l))}catch(u){o(u)}}function d(l){l.done?i(l.value):s(l.value).then(c,a)}d((n=n.apply(e,[])).next())})}for(var ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kn=typeof Uint8Array>"u"?[]:new Uint8Array(256),je=0;je<ve.length;je++)Kn[ve.charCodeAt(je)]=je;var Vn=function(e){var t=new Uint8Array(e),r,n=t.length,s="";for(r=0;r<n;r+=3)s+=ve[t[r]>>2],s+=ve[(t[r]&3)<<4|t[r+1]>>4],s+=ve[(t[r+1]&15)<<2|t[r+2]>>6],s+=ve[t[r+2]&63];return n%3===2?s=s.substring(0,s.length-1)+"=":n%3===1&&(s=s.substring(0,s.length-2)+"=="),s};const ir=new Map;function Pn(e,t){let r=ir.get(e);return r||(r=new Map,ir.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const or=(e,t,r)=>{if(!e||!(cr(e,t)||typeof e=="object"))return;const n=e.constructor.name,s=Pn(r,n);let i=s.indexOf(e);return i===-1&&(i=s.length,s.push(e)),i};function Je(e,t,r){if(e instanceof Array)return e.map(n=>Je(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,s=Vn(e);return{rr_type:n,base64:s}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Je(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:s}=e;return{rr_type:n,src:s}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",s=e.toDataURL();return{rr_type:n,src:s}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Je(e.data,t,r),e.width,e.height]};if(cr(e,t)||typeof e=="object"){const n=e.constructor.name,s=or(e,t,r);return{rr_type:n,index:s}}}}return e}const ar=(e,t,r)=>[...e].map(n=>Je(n,t,r)),cr=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);function Zn(e,t,r,n){const s=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of i)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!="function")continue;const c=ue(t.CanvasRenderingContext2D.prototype,o,function(a){return function(...d){return W(this.canvas,r,n,!0)||setTimeout(()=>{const l=ar([...d],t,this);e(this.canvas,{type:be["2D"],property:o,args:l})},0),a.apply(this,d)}});s.push(c)}catch{const a=Ze(t.CanvasRenderingContext2D.prototype,o,{set(d){e(this.canvas,{type:be["2D"],property:o,args:[d],setter:!0})}});s.push(a)}return()=>{s.forEach(o=>o())}}function dr(e,t,r){const n=[];try{const s=ue(e.HTMLCanvasElement.prototype,"getContext",function(i){return function(o,...c){return W(this,t,r,!0)||"__context"in this||(this.__context=o),i.apply(this,[o,...c])}});n.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(s=>s())}}function lr(e,t,r,n,s,i,o){const c=[],a=Object.getOwnPropertyNames(e);for(const d of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))try{if(typeof e[d]!="function")continue;const l=ue(e,d,function(u){return function(...p){const f=u.apply(this,p);if(or(f,o,this),!W(this.canvas,n,s,!0)){const h=ar([...p],o,this),y={type:t,property:d,args:h};r(this.canvas,y)}return f}});c.push(l)}catch{const u=Ze(e,d,{set(p){r(this.canvas,{type:t,property:d,args:[p],setter:!0})}});c.push(u)}return c}function Hn(e,t,r,n,s){const i=[];return i.push(...lr(t.WebGLRenderingContext.prototype,be.WebGL,e,r,n,s,t)),typeof t.WebGL2RenderingContext<"u"&&i.push(...lr(t.WebGL2RenderingContext.prototype,be.WebGL2,e,r,n,s,t)),()=>{i.forEach(o=>o())}}var ur=null;try{var jn=typeof module<"u"&&typeof module.require=="function"&&module.require("worker_threads")||typeof __non_webpack_require__=="function"&&__non_webpack_require__("worker_threads")||typeof require=="function"&&require("worker_threads");ur=jn.Worker}catch{}function Jn(e,t){return Buffer.from(e,"base64").toString("utf8")}function qn(e,t,r){var n=Jn(e),s=n.indexOf(`
17
- `,10)+1,i=n.substring(s)+"";return function(c){return new ur(i,Object.assign({},c,{eval:!0}))}}function Yn(e,t){var r=atob(e);return r}function Xn(e,t,r){var n=Yn(e),s=n.indexOf(`
18
- `,10)+1,i=n.substring(s)+"",o=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(o)}function Qn(e,t,r){var n;return function(i){return n=n||Xn(e),new Worker(n,i)}}var $n=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";function es(){return $n}function ts(e,t,r){return es()?qn(e):Qn(e)}var rs=ts("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=");class ns{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(d)};const{sampling:r="all",win:n,blockClass:s,blockSelector:i,recordCanvas:o,dataURLOptions:c}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,o&&r==="all"&&this.initCanvasMutationObserver(n,s,i),o&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,i,{dataURLOptions:c})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,s,i){const o=dr(r,n,s),c=new Map,a=new rs;a.onmessage=h=>{const{id:y}=h.data;if(c.set(y,!1),!("base64"in h.data))return;const{base64:S,type:C,width:m,height:g}=h.data;this.mutationCb({id:y,type:be["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:S}],type:C}]},0,0]}]})};const d=1e3/t;let l=0,u;const p=()=>{const h=[];return r.document.querySelectorAll("canvas").forEach(y=>{W(y,n,s,!0)||h.push(y)}),h},f=h=>{if(l&&h-l<d){u=requestAnimationFrame(f);return}l=h,p().forEach(y=>Gn(this,void 0,void 0,function*(){var S;const C=this.mirror.getId(y);if(c.get(C))return;if(c.set(C,!0),["webgl","webgl2"].includes(y.__context)){const g=y.getContext(y.__context);((S=g==null?void 0:g.getContextAttributes())===null||S===void 0?void 0:S.preserveDrawingBuffer)===!1&&(g==null||g.clear(g.COLOR_BUFFER_BIT))}const m=yield createImageBitmap(y);a.postMessage({id:C,bitmap:m,width:y.width,height:y.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{o(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=dr(t,r,n),i=Zn(this.processMutation.bind(this),t,r,n),o=Hn(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{s(),i(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const s=n.map(o=>zn(o,["type"])),{type:i}=n[0];this.mutationCb({id:r,type:i,commands:s}),this.pendingCanvasMutations.delete(t)}}class ss{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new wn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},s=[];for(const i of t){let o;if(this.styleMirror.has(i))o=this.styleMirror.getId(i);else{o=this.styleMirror.add(i);const c=Array.from(i.rules||CSSRule);s.push({styleId:o,rules:c.map((a,d)=>({rule:Rt(a),index:d}))})}n.styleIds.push(o)}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function O(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let _,qe,ct,Ye=!1;const ee=Xr();function we(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:o="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:a=null,inlineStylesheet:d=!0,maskAllInputs:l,maskInputOptions:u,slimDOMOptions:p,maskInputFn:f,maskTextFn:h,hooks:y,packFn:S,sampling:C={},dataURLOptions:m={},mousemoveWait:g,recordCanvas:k=!1,recordCrossOriginIframes:z=!1,userTriggeredOnInput:x=!1,collectFonts:B=!1,inlineImages:T=!1,plugins:H,keepIframeSrcFn:j=()=>!1,ignoreCSSAttributes:X=new Set([])}=e,Q=z?window.parent===window:!0;let $=!1;if(!Q)try{window.parent.document,$=!1}catch{$=!0}if(Q&&!t)throw new Error("emit function is required");g!==void 0&&C.mousemove===void 0&&(C.mousemove=g),ee.reset();const L=l===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u!==void 0?u:{password:!0},J=p===!0||p==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:p==="all",headMetaDescKeywords:p==="all"}:p||{};vn();let re,ie=0;const ae=I=>{for(const G of H||[])G.eventProcessor&&(I=G.eventProcessor(I));return S&&(I=S(I)),I};_=(I,G)=>{var P;if(!((P=he[0])===null||P===void 0)&&P.isFrozen()&&I.type!==w.FullSnapshot&&!(I.type===w.IncrementalSnapshot&&I.data.source===b.Mutation)&&he.forEach(R=>R.unfreeze()),Q)t==null||t(ae(I),G);else if($){const R={type:"rrweb",event:ae(I),isCheckout:G};window.parent.postMessage(R,"*")}if(I.type===w.FullSnapshot)re=I,ie=0;else if(I.type===w.IncrementalSnapshot){if(I.data.source===b.Mutation&&I.data.isAttachIframe)return;ie++;const R=n&&ie>=n,Y=r&&I.timestamp-re.timestamp>r;(R||Y)&&qe(!0)}};const V=I=>{_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Mutation},I)}))},q=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Scroll},I)})),le=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.CanvasMutation},I)})),M=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.AdoptedStyleSheet},I)})),ne=new ss({mutationCb:V,adoptedStyleSheetCb:M}),oe=new Un({mirror:ee,mutationCb:V,stylesheetManager:ne,recordCrossOriginIframes:z,wrappedEmit:_});for(const I of H||[])I.getMirror&&I.getMirror({nodeMirror:ee,crossOriginIframeMirror:oe.crossOriginIframeMirror,crossOriginIframeStyleMirror:oe.crossOriginIframeStyleMirror});ct=new ns({recordCanvas:k,mutationCb:le,win:window,blockClass:s,blockSelector:i,mirror:ee,sampling:C.canvas,dataURLOptions:m});const Te=new Wn({mutationCb:V,scrollCb:q,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:a,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:m,maskTextFn:h,maskInputFn:f,recordCanvas:k,inlineImages:T,sampling:C,slimDOMOptions:J,iframeManager:oe,stylesheetManager:ne,canvasManager:ct,keepIframeSrcFn:j},mirror:ee});qe=(I=!1)=>{var G,P,R,Y,A,Z;_(O({type:w.Meta,data:{href:window.location.href,width:Dt(),height:Bt()}}),I),ne.reset(),he.forEach(K=>K.lock());const Ue=Sn(document,{mirror:ee,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:a,inlineStylesheet:d,maskAllInputs:L,maskTextFn:h,slimDOM:J,dataURLOptions:m,recordCanvas:k,inlineImages:T,onSerialize:K=>{zt(K,ee)&&oe.addIframe(K),Gt(K,ee)&&ne.trackLinkElement(K),Kt(K)&&Te.addShadowRoot(K.shadowRoot,document)},onIframeLoad:(K,mt)=>{oe.attachIframe(K,mt),Te.observeAttachShadow(K)},onStylesheetLoad:(K,mt)=>{ne.attachLinkElement(K,mt)},keepIframeSrcFn:j});if(!Ue)return console.warn("Failed to snapshot the document");_(O({type:w.FullSnapshot,data:{node:Ue,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:(document==null?void 0:document.documentElement.scrollLeft)||((P=(G=document==null?void 0:document.body)===null||G===void 0?void 0:G.parentElement)===null||P===void 0?void 0:P.scrollLeft)||((R=document==null?void 0:document.body)===null||R===void 0?void 0:R.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:(document==null?void 0:document.documentElement.scrollTop)||((A=(Y=document==null?void 0:document.body)===null||Y===void 0?void 0:Y.parentElement)===null||A===void 0?void 0:A.scrollTop)||((Z=document==null?void 0:document.body)===null||Z===void 0?void 0:Z.scrollTop)||0}}})),he.forEach(K=>K.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ne.adoptStyleSheets(document.adoptedStyleSheets,ee.getId(document))};try{const I=[];I.push(U("DOMContentLoaded",()=>{_(O({type:w.DomContentLoaded,data:{}}))}));const G=R=>{var Y;return Dn({mutationCb:V,mousemoveCb:(A,Z)=>_(O({type:w.IncrementalSnapshot,data:{source:Z,positions:A}})),mouseInteractionCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.MouseInteraction},A)})),scrollCb:q,viewportResizeCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.ViewportResize},A)})),inputCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Input},A)})),mediaInteractionCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.MediaInteraction},A)})),styleSheetRuleCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.StyleSheetRule},A)})),styleDeclarationCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.StyleDeclaration},A)})),canvasMutationCb:le,fontCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Font},A)})),selectionCb:A=>{_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Selection},A)}))},blockClass:s,ignoreClass:o,maskTextClass:c,maskTextSelector:a,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:k,inlineImages:T,userTriggeredOnInput:x,collectFonts:B,doc:R,maskInputFn:f,maskTextFn:h,keepIframeSrcFn:j,blockSelector:i,slimDOMOptions:J,dataURLOptions:m,mirror:ee,iframeManager:oe,stylesheetManager:ne,shadowDomManager:Te,canvasManager:ct,ignoreCSSAttributes:X,plugins:((Y=H==null?void 0:H.filter(A=>A.observer))===null||Y===void 0?void 0:Y.map(A=>({observer:A.observer,options:A.options,callback:Z=>_(O({type:w.Plugin,data:{plugin:A.name,payload:Z}}))})))||[]},y)};oe.addLoadListener(R=>{I.push(G(R.contentDocument))});const P=()=>{qe(),I.push(G(document)),Ye=!0};return document.readyState==="interactive"||document.readyState==="complete"?P():I.push(U("load",()=>{_(O({type:w.Load,data:{}})),P()},window)),()=>{I.forEach(R=>R()),Ye=!1}}catch(I){console.warn(I)}}we.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");_(O({type:w.Custom,data:{tag:e,payload:t}}))},we.freezePage=()=>{he.forEach(e=>e.freeze())},we.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");qe(e)},we.mirror=ee;const{addCustomEvent:is}=we;class Ae{constructor(t){this.fileName=t.fileName||"",this.functionName=t.functionName||"",this.lineNumber=t.lineNumber,this.columnNumber=t.columnNumber}toString(){const t=this.lineNumber||"",r=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${t}:${r})`:`${this.fileName}:${t}:${r}`}}const os=/(^|@)\S+:\d+/,hr=/^\s*at .*(\S+:\d+|\(native\))/m,as=/^(eval@)?(\[native code])?$/,pr={parse:function(e){if(!e)return[];if(typeof e.stacktrace<"u"||typeof e["opera#sourceloc"]<"u")return this.parseOpera(e);if(e.stack&&e.stack.match(hr))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];const r=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!r)throw new Error(`Cannot parse given url: ${e}`);return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
19
- `).filter(function(r){return!!r.match(hr)},this).map(function(r){r.indexOf("(eval ")>-1&&(r=r.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let n=r.replace(/^\s+/,"").replace(/\(eval code/g,"(");const s=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=s?n.replace(s[0],""):n;const i=n.split(/\s+/).slice(1),o=this.extractLocation(s?s[1]:i.pop()),c=i.join(" ")||void 0,a=["eval","<anonymous>"].indexOf(o[0])>-1?void 0:o[0];return new Ae({functionName:c,fileName:a,lineNumber:o[1],columnNumber:o[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
20
- `).filter(function(r){return!r.match(as)},this).map(function(r){if(r.indexOf(" > eval")>-1&&(r=r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),r.indexOf("@")===-1&&r.indexOf(":")===-1)return new Ae({functionName:r});{const n=/((.*".+"[^@]*)?[^@]*)(?:@)/,s=r.match(n),i=s&&s[1]?s[1]:void 0,o=this.extractLocation(r.replace(n,""));return new Ae({functionName:i,fileName:o[0],lineNumber:o[1],columnNumber:o[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
16
+ ***************************************************************************** */function Dn(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function Un(e,t,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(l){try{d(n.next(l))}catch(u){o(u)}}function a(l){try{d(n.throw(l))}catch(u){o(u)}}function d(l){l.done?i(l.value):s(l.value).then(c,a)}d((n=n.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wn=typeof Uint8Array>"u"?[]:new Uint8Array(256),He=0;He<be.length;He++)Wn[be.charCodeAt(He)]=He;var zn=function(e){var t=new Uint8Array(e),r,n=t.length,s="";for(r=0;r<n;r+=3)s+=be[t[r]>>2],s+=be[(t[r]&3)<<4|t[r+1]>>4],s+=be[(t[r+1]&15)<<2|t[r+2]>>6],s+=be[t[r+2]&63];return n%3===2?s=s.substring(0,s.length-1)+"=":n%3===1&&(s=s.substring(0,s.length-2)+"=="),s};const ir=new Map;function Gn(e,t){let r=ir.get(e);return r||(r=new Map,ir.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const or=(e,t,r)=>{if(!e||!(cr(e,t)||typeof e=="object"))return;const n=e.constructor.name,s=Gn(r,n);let i=s.indexOf(e);return i===-1&&(i=s.length,s.push(e)),i};function je(e,t,r){if(e instanceof Array)return e.map(n=>je(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,s=zn(e);return{rr_type:n,base64:s}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[je(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:s}=e;return{rr_type:n,src:s}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",s=e.toDataURL();return{rr_type:n,src:s}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[je(e.data,t,r),e.width,e.height]};if(cr(e,t)||typeof e=="object"){const n=e.constructor.name,s=or(e,t,r);return{rr_type:n,index:s}}}}return e}const ar=(e,t,r)=>[...e].map(n=>je(n,t,r)),cr=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);function Kn(e,t,r,n){const s=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of i)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!="function")continue;const c=le(t.CanvasRenderingContext2D.prototype,o,function(a){return function(...d){return W(this.canvas,r,n,!0)||setTimeout(()=>{const l=ar([...d],t,this);e(this.canvas,{type:Se["2D"],property:o,args:l})},0),a.apply(this,d)}});s.push(c)}catch{const a=Pe(t.CanvasRenderingContext2D.prototype,o,{set(d){e(this.canvas,{type:Se["2D"],property:o,args:[d],setter:!0})}});s.push(a)}return()=>{s.forEach(o=>o())}}function dr(e,t,r){const n=[];try{const s=le(e.HTMLCanvasElement.prototype,"getContext",function(i){return function(o,...c){return W(this,t,r,!0)||"__context"in this||(this.__context=o),i.apply(this,[o,...c])}});n.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(s=>s())}}function lr(e,t,r,n,s,i,o){const c=[],a=Object.getOwnPropertyNames(e);for(const d of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))try{if(typeof e[d]!="function")continue;const l=le(e,d,function(u){return function(...h){const f=u.apply(this,h);if(or(f,o,this),!W(this.canvas,n,s,!0)){const p=ar([...h],o,this),y={type:t,property:d,args:p};r(this.canvas,y)}return f}});c.push(l)}catch{const u=Pe(e,d,{set(h){r(this.canvas,{type:t,property:d,args:[h],setter:!0})}});c.push(u)}return c}function Vn(e,t,r,n,s){const i=[];return i.push(...lr(t.WebGLRenderingContext.prototype,Se.WebGL,e,r,n,s,t)),typeof t.WebGL2RenderingContext<"u"&&i.push(...lr(t.WebGL2RenderingContext.prototype,Se.WebGL2,e,r,n,s,t)),()=>{i.forEach(o=>o())}}var ur=null;try{var Pn=typeof module<"u"&&typeof module.require=="function"&&module.require("worker_threads")||typeof __non_webpack_require__=="function"&&__non_webpack_require__("worker_threads")||typeof require=="function"&&require("worker_threads");ur=Pn.Worker}catch{}function Zn(e,t){return Buffer.from(e,"base64").toString("utf8")}function Hn(e,t,r){var n=Zn(e),s=n.indexOf(`
17
+ `,10)+1,i=n.substring(s)+"";return function(c){return new ur(i,Object.assign({},c,{eval:!0}))}}function jn(e,t){var r=atob(e);return r}function Jn(e,t,r){var n=jn(e),s=n.indexOf(`
18
+ `,10)+1,i=n.substring(s)+"",o=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(o)}function qn(e,t,r){var n;return function(i){return n=n||Jn(e),new Worker(n,i)}}var Yn=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";function Xn(){return Yn}function Qn(e,t,r){return Xn()?Hn(e):qn(e)}var $n=Qn("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=");class es{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(d)};const{sampling:r="all",win:n,blockClass:s,blockSelector:i,recordCanvas:o,dataURLOptions:c}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,o&&r==="all"&&this.initCanvasMutationObserver(n,s,i),o&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,i,{dataURLOptions:c})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,s,i){const o=dr(r,n,s),c=new Map,a=new $n;a.onmessage=p=>{const{id:y}=p.data;if(c.set(y,!1),!("base64"in p.data))return;const{base64:S,type:C,width:m,height:g}=p.data;this.mutationCb({id:y,type:Se["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:S}],type:C}]},0,0]}]})};const d=1e3/t;let l=0,u;const h=()=>{const p=[];return r.document.querySelectorAll("canvas").forEach(y=>{W(y,n,s,!0)||p.push(y)}),p},f=p=>{if(l&&p-l<d){u=requestAnimationFrame(f);return}l=p,h().forEach(y=>Un(this,void 0,void 0,function*(){var S;const C=this.mirror.getId(y);if(c.get(C))return;if(c.set(C,!0),["webgl","webgl2"].includes(y.__context)){const g=y.getContext(y.__context);((S=g==null?void 0:g.getContextAttributes())===null||S===void 0?void 0:S.preserveDrawingBuffer)===!1&&(g==null||g.clear(g.COLOR_BUFFER_BIT))}const m=yield createImageBitmap(y);a.postMessage({id:C,bitmap:m,width:y.width,height:y.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{o(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=dr(t,r,n),i=Kn(this.processMutation.bind(this),t,r,n),o=Vn(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{s(),i(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const s=n.map(o=>Dn(o,["type"])),{type:i}=n[0];this.mutationCb({id:r,type:i,commands:s}),this.pendingCanvasMutations.delete(t)}}class ts{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Sn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},s=[];for(const i of t){let o;if(this.styleMirror.has(i))o=this.styleMirror.getId(i);else{o=this.styleMirror.add(i);const c=Array.from(i.rules||CSSRule);s.push({styleId:o,rules:c.map((a,d)=>({rule:Tt(a),index:d}))})}n.styleIds.push(o)}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function O(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let _,Je,ct,qe=!1;const ee=Jr();function ve(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:o="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:a=null,inlineStylesheet:d=!0,maskAllInputs:l,maskInputOptions:u,slimDOMOptions:h,maskInputFn:f,maskTextFn:p,hooks:y,packFn:S,sampling:C={},dataURLOptions:m={},mousemoveWait:g,recordCanvas:k=!1,recordCrossOriginIframes:z=!1,userTriggeredOnInput:B=!1,collectFonts:D=!1,inlineImages:R=!1,plugins:H,keepIframeSrcFn:j=()=>!1,ignoreCSSAttributes:X=new Set([])}=e,Q=z?window.parent===window:!0;let $=!1;if(!Q)try{window.parent.document,$=!1}catch{$=!0}if(Q&&!t)throw new Error("emit function is required");g!==void 0&&C.mousemove===void 0&&(C.mousemove=g),ee.reset();const F=l===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u!==void 0?u:{password:!0},J=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};Cn();let re,se=0;const oe=I=>{for(const G of H||[])G.eventProcessor&&(I=G.eventProcessor(I));return S&&(I=S(I)),I};_=(I,G)=>{var P;if(!((P=ue[0])===null||P===void 0)&&P.isFrozen()&&I.type!==v.FullSnapshot&&!(I.type===v.IncrementalSnapshot&&I.data.source===b.Mutation)&&ue.forEach(T=>T.unfreeze()),Q)t==null||t(oe(I),G);else if($){const T={type:"rrweb",event:oe(I),isCheckout:G};window.parent.postMessage(T,"*")}if(I.type===v.FullSnapshot)re=I,se=0;else if(I.type===v.IncrementalSnapshot){if(I.data.source===b.Mutation&&I.data.isAttachIframe)return;se++;const T=n&&se>=n,Y=r&&I.timestamp-re.timestamp>r;(T||Y)&&Je(!0)}};const V=I=>{_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.Mutation},I)}))},q=I=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.Scroll},I)})),de=I=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.CanvasMutation},I)})),M=I=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.AdoptedStyleSheet},I)})),ne=new ts({mutationCb:V,adoptedStyleSheetCb:M}),ie=new xn({mirror:ee,mutationCb:V,stylesheetManager:ne,recordCrossOriginIframes:z,wrappedEmit:_});for(const I of H||[])I.getMirror&&I.getMirror({nodeMirror:ee,crossOriginIframeMirror:ie.crossOriginIframeMirror,crossOriginIframeStyleMirror:ie.crossOriginIframeStyleMirror});ct=new es({recordCanvas:k,mutationCb:de,win:window,blockClass:s,blockSelector:i,mirror:ee,sampling:C.canvas,dataURLOptions:m});const Ee=new Bn({mutationCb:V,scrollCb:q,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:a,inlineStylesheet:d,maskInputOptions:F,dataURLOptions:m,maskTextFn:p,maskInputFn:f,recordCanvas:k,inlineImages:R,sampling:C,slimDOMOptions:J,iframeManager:ie,stylesheetManager:ne,canvasManager:ct,keepIframeSrcFn:j},mirror:ee});Je=(I=!1)=>{var G,P,T,Y,A,Z;_(O({type:v.Meta,data:{href:window.location.href,width:Dt(),height:Bt()}}),I),ne.reset(),ue.forEach(K=>K.lock());const De=yn(document,{mirror:ee,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:a,inlineStylesheet:d,maskAllInputs:F,maskTextFn:p,slimDOM:J,dataURLOptions:m,recordCanvas:k,inlineImages:R,onSerialize:K=>{zt(K,ee)&&ie.addIframe(K),Gt(K,ee)&&ne.trackLinkElement(K),Kt(K)&&Ee.addShadowRoot(K.shadowRoot,document)},onIframeLoad:(K,mt)=>{ie.attachIframe(K,mt),Ee.observeAttachShadow(K)},onStylesheetLoad:(K,mt)=>{ne.attachLinkElement(K,mt)},keepIframeSrcFn:j});if(!De)return console.warn("Failed to snapshot the document");_(O({type:v.FullSnapshot,data:{node:De,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:(document==null?void 0:document.documentElement.scrollLeft)||((P=(G=document==null?void 0:document.body)===null||G===void 0?void 0:G.parentElement)===null||P===void 0?void 0:P.scrollLeft)||((T=document==null?void 0:document.body)===null||T===void 0?void 0:T.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:(document==null?void 0:document.documentElement.scrollTop)||((A=(Y=document==null?void 0:document.body)===null||Y===void 0?void 0:Y.parentElement)===null||A===void 0?void 0:A.scrollTop)||((Z=document==null?void 0:document.body)===null||Z===void 0?void 0:Z.scrollTop)||0}}})),ue.forEach(K=>K.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ne.adoptStyleSheets(document.adoptedStyleSheets,ee.getId(document))};try{const I=[];I.push(U("DOMContentLoaded",()=>{_(O({type:v.DomContentLoaded,data:{}}))}));const G=T=>{var Y;return Fn({mutationCb:V,mousemoveCb:(A,Z)=>_(O({type:v.IncrementalSnapshot,data:{source:Z,positions:A}})),mouseInteractionCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.MouseInteraction},A)})),scrollCb:q,viewportResizeCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.ViewportResize},A)})),inputCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.Input},A)})),mediaInteractionCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.MediaInteraction},A)})),styleSheetRuleCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.StyleSheetRule},A)})),styleDeclarationCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.StyleDeclaration},A)})),canvasMutationCb:de,fontCb:A=>_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.Font},A)})),selectionCb:A=>{_(O({type:v.IncrementalSnapshot,data:Object.assign({source:b.Selection},A)}))},blockClass:s,ignoreClass:o,maskTextClass:c,maskTextSelector:a,maskInputOptions:F,inlineStylesheet:d,sampling:C,recordCanvas:k,inlineImages:R,userTriggeredOnInput:B,collectFonts:D,doc:T,maskInputFn:f,maskTextFn:p,keepIframeSrcFn:j,blockSelector:i,slimDOMOptions:J,dataURLOptions:m,mirror:ee,iframeManager:ie,stylesheetManager:ne,shadowDomManager:Ee,canvasManager:ct,ignoreCSSAttributes:X,plugins:((Y=H==null?void 0:H.filter(A=>A.observer))===null||Y===void 0?void 0:Y.map(A=>({observer:A.observer,options:A.options,callback:Z=>_(O({type:v.Plugin,data:{plugin:A.name,payload:Z}}))})))||[]},y)};ie.addLoadListener(T=>{I.push(G(T.contentDocument))});const P=()=>{Je(),I.push(G(document)),qe=!0};return document.readyState==="interactive"||document.readyState==="complete"?P():I.push(U("load",()=>{_(O({type:v.Load,data:{}})),P()},window)),()=>{I.forEach(T=>T()),qe=!1}}catch(I){console.warn(I)}}ve.addCustomEvent=(e,t)=>{if(!qe)throw new Error("please add custom event after start recording");_(O({type:v.Custom,data:{tag:e,payload:t}}))},ve.freezePage=()=>{ue.forEach(e=>e.freeze())},ve.takeFullSnapshot=e=>{if(!qe)throw new Error("please take full snapshot after start recording");Je(e)},ve.mirror=ee;const{addCustomEvent:rs}=ve;class we{constructor(t){this.fileName=t.fileName||"",this.functionName=t.functionName||"",this.lineNumber=t.lineNumber,this.columnNumber=t.columnNumber}toString(){const t=this.lineNumber||"",r=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${t}:${r})`:`${this.fileName}:${t}:${r}`}}const ns=/(^|@)\S+:\d+/,pr=/^\s*at .*(\S+:\d+|\(native\))/m,ss=/^(eval@)?(\[native code])?$/,hr={parse:function(e){if(!e)return[];if(typeof e.stacktrace<"u"||typeof e["opera#sourceloc"]<"u")return this.parseOpera(e);if(e.stack&&e.stack.match(pr))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];const r=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!r)throw new Error(`Cannot parse given url: ${e}`);return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
19
+ `).filter(function(r){return!!r.match(pr)},this).map(function(r){r.indexOf("(eval ")>-1&&(r=r.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let n=r.replace(/^\s+/,"").replace(/\(eval code/g,"(");const s=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=s?n.replace(s[0],""):n;const i=n.split(/\s+/).slice(1),o=this.extractLocation(s?s[1]:i.pop()),c=i.join(" ")||void 0,a=["eval","<anonymous>"].indexOf(o[0])>-1?void 0:o[0];return new we({functionName:c,fileName:a,lineNumber:o[1],columnNumber:o[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
20
+ `).filter(function(r){return!r.match(ss)},this).map(function(r){if(r.indexOf(" > eval")>-1&&(r=r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),r.indexOf("@")===-1&&r.indexOf(":")===-1)return new we({functionName:r});{const n=/((.*".+"[^@]*)?[^@]*)(?:@)/,s=r.match(n),i=s&&s[1]?s[1]:void 0,o=this.extractLocation(r.replace(n,""));return new we({functionName:i,fileName:o[0],lineNumber:o[1],columnNumber:o[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
21
21
  `)>-1&&e.message.split(`
22
22
  `).length>e.stacktrace.split(`
23
23
  `).length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split(`
24
- `),n=[];for(let s=2,i=r.length;s<i;s+=2){const o=t.exec(r[s]);o&&n.push(new Ae({fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera10:function(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split(`
25
- `),n=[];for(let s=0,i=r.length;s<i;s+=2){const o=t.exec(r[s]);o&&n.push(new Ae({functionName:o[3]||void 0,fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera11:function(e){return e.stack.split(`
26
- `).filter(function(r){return!!r.match(os)&&!r.match(/^Error created at/)},this).map(function(r){const n=r.split("@"),s=this.extractLocation(n.pop()),o=(n.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Ae({functionName:o,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})},this)}};function cs(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let r=e.localName;if(!r)break;r=r.toLowerCase();const n=e.parentElement,s=[];if(n.children&&n.children.length>0)for(let i=0;i<n.children.length;i++){const o=n.children[i];o.localName&&o.localName.toLowerCase&&o.localName.toLowerCase()===r&&s.push(o)}s.length>1&&(r+=`:eq(${s.indexOf(e)})`),t=r+(t?">"+t:""),e=n}return t}function dt(e){return Object.prototype.toString.call(e)==="[object Object]"}function fr(e,t){if(t===0)return!0;const r=Object.keys(e);for(const n of r)if(dt(e[n])&&fr(e[n],t-1))return!0;return!1}function lt(e,t){const r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);const n=[],s=[];return JSON.stringify(e,function(c,a){if(n.length>0){const d=n.indexOf(this);~d?n.splice(d+1):n.push(this),~d?s.splice(d,1/0,c):s.push(c),~n.indexOf(a)&&(n[0]===a?a="[Circular ~]":a="[Circular ~."+s.slice(0,n.indexOf(a)).join(".")+"]")}else n.push(a);if(a===null)return a;if(a===void 0)return"undefined";if(i(a))return o(a);if(a instanceof Event){const d={};for(const l in a){const u=a[l];Array.isArray(u)?d[l]=cs(u.length?u[0]:null):d[l]=u}return d}else{if(a instanceof Node)return a instanceof HTMLElement?a?a.outerHTML:"":a.nodeName;if(a instanceof Error)return a.stack?a.stack+`
27
- End of stack for Error object`:a.name+": "+a.message}return a});function i(c){return!!(dt(c)&&Object.keys(c).length>r.numOfKeysLimit||typeof c=="function"||dt(c)&&fr(c,r.depthOfLimit))}function o(c){let a=c.toString();return r.stringLengthLimit&&a.length>r.stringLengthLimit&&(a=`${a.slice(0,r.stringLengthLimit)}...`),a}}const mr={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function ds(e,t,r){const n=r?Object.assign({},mr,r):mr,s=n.logger;if(!s)return()=>{};let i;typeof s=="string"?i=t[s]:i=s;let o=0;const c=[];if(n.level.includes("error")&&window){const d=l=>{const u=l.message,p=l.error,f=pr.parse(p).map(y=>y.toString()),h=[lt(u,n.stringifyOptions)];e({level:"error",trace:f,payload:h})};window.addEventListener("error",d),c.push(()=>{window&&window.removeEventListener("error",d)})}for(const d of n.level)c.push(a(i,d));return()=>{c.forEach(d=>d())};function a(d,l){return d[l]?ue(d,l,u=>(...p)=>{u.apply(this,p);try{const f=pr.parse(new Error).map(y=>y.toString()).splice(1),h=p.map(y=>lt(y,n.stringifyOptions));o++,o<n.lengthThreshold?e({level:l,trace:f,payload:h}):o===n.lengthThreshold&&e({level:"warn",trace:[],payload:[lt("The number of log records reached the threshold.")]})}catch(f){u("rrweb logger error:",f,...p)}}):()=>{}}}const ls="rrweb/console@1",us=e=>({name:ls,observer:ds,options:e}),hs="application/json",ps="flashlog",fs=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,xe=()=>typeof window<"u"&&window.location?window.location.href:"",gr=e=>new Date(typeof e=="number"?e:Date.now()).toISOString(),ut=async e=>{try{return await e.json()}catch{return null}};class yr extends Error{constructor(t){super(t),this.name="ReplayQuotaError"}}class Ir extends Error{constructor(t){super(t),this.name="ReplaySegmentTooLargeError"}}class ms{constructor(){this.config=null,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.flushTimer=null,this.replaySessionId=null,this.segmentSequence=0}async start(t){await this.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),!(typeof window>"u"||typeof document>"u")&&(this.config=t,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.replaySessionId=null,this.segmentSequence=0,this.stopRecording=we({emit:r=>this.pushEvent(r),collectFonts:!0,inlineStylesheet:!0,maskAllInputs:t.maskAllInputs,userTriggeredOnInput:!0,plugins:[us()]})||void 0,this.bindLifecycleListeners(),this.flushTimer=window.setInterval(()=>{this.flush("interval")},t.flushIntervalMs),this.addCustomEvent("session-start",{session_id:t.sessionId,brand_id:t.brandId,device_id:t.deviceId,page_url:xe(),started_at:new Date().toISOString()}))}async flush(t="manual",r){if(this.flushInFlight)return this.flushInFlight;if(!this.config||this.finalized)return null;const n=this.takePendingSegment();if(!n)return null;let s=!1;return this.flushInFlight=this.uploadSegment(n,t,(r==null?void 0:r.keepalive)===!0).then(i=>(s=!0,i)).catch(i=>i instanceof yr?(this.currentBytes=0,this.currentEvents=[],this.finalized=!0,this.stopCapture(),this.debug("Replay capture stopped by server quota",{message:i.message,reason:t,segmentId:n.segmentId}),null):i instanceof Ir?(s=!0,this.debug("Replay event skipped because it exceeds the upload limit",{message:i.message,reason:t,segmentId:n.segmentId,sizeBytes:n.sizeBytes}),null):(this.restorePendingSegment(n),this.debug("Replay upload failed",{message:i instanceof Error?i.message:String(i),reason:t,segmentId:n.segmentId}),null)).finally(()=>{this.flushInFlight=null,s&&this.currentEvents.length>0&&this.flush("buffer-threshold")}),this.flushInFlight}async finalize(t="manual",r){if(!this.config||this.finalized)return null;this.addCustomEvent("session-finalize",{reason:t,page_url:xe(),session_id:this.config.sessionId,timestamp:new Date().toISOString()}),this.stopCapture();let n=null;for(;this.flushInFlight||this.currentEvents.length>0;){const a=await this.flush(t,{keepalive:(r==null?void 0:r.keepalive)===!0});if(!a){if(this.flushInFlight)continue;break}n=a}if(this.replaySessionId=(n==null?void 0:n.replay_session_id)||this.replaySessionId,this.finalized=!0,!this.replaySessionId)return this.config=null,null;const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/finalize`,o=await fetch(i,{body:JSON.stringify({brand_id:s.brandId,device_id:s.deviceId,finalized_reason:t,page_url:xe(),replay_session_id:this.replaySessionId,session_id:s.sessionId}),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:(r==null?void 0:r.keepalive)===!0,method:"POST"}).catch(a=>(this.debug("Replay finalize failed",{message:a instanceof Error?a.message:String(a),reason:t}),null));if(this.config=null,!o)return null;const c=await ut(o);return o.ok?(c==null?void 0:c.data)||null:(this.debug("Replay finalize returned non-200",{message:(c==null?void 0:c.message)||`HTTP ${o.status}`,reason:t}),null)}async dispose(t){if((t==null?void 0:t.finalize)===!0&&!!this.config&&!this.finalized){await this.finalize((t==null?void 0:t.reason)||"dispose",{keepalive:(t==null?void 0:t.keepalive)===!0}).catch(()=>null);return}this.stopCapture(),this.config=null,this.currentBytes=0,this.currentEvents=[],this.flushInFlight=null,this.finalized=!0,this.replaySessionId=null,this.segmentSequence=0}addCustomEvent(t,r){if(!(!this.config||this.finalized))try{is(`${ps}:${t}`,r)}catch(n){this.debug("Replay custom event skipped",{message:n instanceof Error?n.message:String(n),tag:t})}}bindLifecycleListeners(){if(typeof window>"u"||typeof document>"u")return;const t=()=>{document.visibilityState==="hidden"&&this.flush("visibility-hidden",{keepalive:!0})},r=()=>{this.finalize("pagehide",{keepalive:!0})},n=()=>{this.flush("beforeunload",{keepalive:!0})};document.addEventListener("visibilitychange",t,!0),window.addEventListener("pagehide",r),window.addEventListener("beforeunload",n),this.detachListeners=[()=>document.removeEventListener("visibilitychange",t,!0),()=>window.removeEventListener("pagehide",r),()=>window.removeEventListener("beforeunload",n)]}debug(t,r){var n;(n=this.config)!=null&&n.debug&&console.log("[FlashlogTracker][Replay]",t,r||{})}pushEvent(t){!this.config||this.finalized||(this.currentEvents.push(t),this.currentBytes+=this.estimateEventSize(t),this.isBufferAtThreshold()&&this.flush("buffer-threshold"))}isBufferAtThreshold(){return!!(this.config&&(this.currentBytes>=this.config.maxSegmentBytes||this.currentEvents.length>=this.config.maxSegmentEvents))}estimateEventSize(t){try{const r=JSON.stringify(t);return typeof TextEncoder>"u"?r.length:new TextEncoder().encode(r).byteLength}catch{return 0}}nextSegmentId(t){return`segment-${String(t).padStart(6,"0")}-${fs()}`}restorePendingSegment(t){this.currentEvents=[...t.events,...this.currentEvents],this.currentBytes+=t.sizeBytes,this.segmentSequence=Math.min(this.segmentSequence,t.sequenceNumber)}stopCapture(){var t;(t=this.stopRecording)==null||t.call(this),this.stopRecording=void 0,this.flushTimer!==null&&typeof window<"u"&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.detachListeners.forEach(r=>r()),this.detachListeners=[]}takePendingSegment(){var i,o;if(!this.config||this.currentEvents.length===0)return null;let t=0,r=0;for(const c of this.currentEvents){const a=this.estimateEventSize(c),d=t>0&&r+a>this.config.maxSegmentBytes,l=t>=this.config.maxSegmentEvents;if(d||l)break;t+=1,r+=a}const n=this.currentEvents.splice(0,Math.max(t,1));t===0&&(r=this.estimateEventSize(n[0]));const s=this.segmentSequence;return this.currentBytes=Math.max(0,this.currentBytes-r),this.segmentSequence+=1,{endedAt:gr((i=n[n.length-1])==null?void 0:i.timestamp),eventCount:n.length,events:n,segmentId:this.nextSegmentId(s),sequenceNumber:s,sizeBytes:r,startedAt:gr((o=n[0])==null?void 0:o.timestamp)}}async uploadSegment(t,r,n){var f;if(!this.config)throw new Error("Replay recorder is not configured");const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/segments/upload-url`,o={brand_id:s.brandId,content_type:hs,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),replay_session_id:this.replaySessionId,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt,upload_reason:r},c=await fetch(i,{body:JSON.stringify(o),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:n,method:"POST"}),a=await ut(c);if(!c.ok||!((f=a==null?void 0:a.data)!=null&&f.upload_url)){const h=a==null?void 0:a.message,y=typeof h=="object"&&h?h.code:a==null?void 0:a.code,S=typeof h=="object"&&h?h.message:h;throw c.status===403&&typeof y=="string"&&y.startsWith("REPLAY_")?new yr(S||"Replay capture quota exhausted"):new Error(S||`Failed to create replay upload URL (${c.status})`)}this.replaySessionId=a.data.replay_session_id||this.replaySessionId;const d=JSON.stringify({events:t.events,meta:{brand_id:s.brandId,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),reason:r,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt},source:"flashlog-tracker-sdk",type:"rrweb-event-segment",version:1}),l=typeof TextEncoder>"u"?d.length:new TextEncoder().encode(d).byteLength;if(l>a.data.max_bytes)throw new Ir(`Replay segment is ${l} bytes; upload limit is ${a.data.max_bytes} bytes`);const u=await fetch(a.data.upload_url,{body:d,headers:{"Content-Type":"application/octet-stream"},keepalive:n,method:a.data.method||"PUT"}),p=await ut(u);if(!u.ok||!(p!=null&&p.data))throw new Error((p==null?void 0:p.message)||`Replay segment upload failed (${u.status})`);return this.debug("Replay segment uploaded",{objectKey:p.data.object_key,reason:r,segmentId:p.data.segment_id,sequenceNumber:p.data.sequence_number}),p.data}}const ht=()=>typeof window<"u"&&typeof window.localStorage<"u",Cr=()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=Date.now().toString(36),t=Math.random().toString(36).slice(2,12);return`${e}-${t}`},pe=e=>ht()?window.localStorage.getItem(e):null,fe=(e,t)=>{ht()&&window.localStorage.setItem(e,t)},ke=e=>{ht()&&window.localStorage.removeItem(e)},gs=e=>{const t=pe(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},ys=(e,t)=>{fe(e,JSON.stringify(t))},Sr=()=>{const e=pe(N.deviceId);if(e)return e;const t=Cr();return fe(N.deviceId,t),t},br=e=>{const t=Date.now(),r=pe(N.sessionId),n=pe(N.sessionSeenAt),s=n?Number(n):NaN,i=Number.isFinite(s)&&t-s<=e;if(r&&i)return fe(N.sessionSeenAt,String(t)),r;const o=Cr();return fe(N.sessionId,o),fe(N.sessionSeenAt,String(t)),o},Is=()=>{fe(N.sessionSeenAt,String(Date.now()))},Cs=()=>pe(N.sessionId),Ss=()=>pe(N.deviceId),bs=(e,t)=>{if(fe(N.accountId,e),t&&Object.keys(t).length>0){ys(N.accountTraits,t);return}ke(N.accountTraits)},vs=()=>pe(N.accountId),ws=()=>gs(N.accountTraits),vr=()=>{ke(N.accountId),ke(N.accountTraits)},As=()=>{ke(N.sessionId),ke(N.sessionSeenAt),ke(N.deviceId),vr()},wr=(e,t)=>Array.from(new Set([...e,...t||[]])),ks=e=>{var t,r;return{apiUrl:((t=e==null?void 0:e.apiUrl)==null?void 0:t.trim())||v.apiUrl,apiKey:(e==null?void 0:e.apiKey)??v.apiKey,debug:(e==null?void 0:e.debug)??v.debug,autoCapture:(e==null?void 0:e.autoCapture)??v.autoCapture,captureNetworkErrors:(e==null?void 0:e.captureNetworkErrors)??v.captureNetworkErrors,captureJsErrors:(e==null?void 0:e.captureJsErrors)??v.captureJsErrors,captureSocketErrors:(e==null?void 0:e.captureSocketErrors)??v.captureSocketErrors,sessionTimeoutMs:(e==null?void 0:e.sessionTimeoutMs)??v.sessionTimeoutMs,maxActionBufferSize:(e==null?void 0:e.maxActionBufferSize)??v.maxActionBufferSize,allowNonErrorEvents:(e==null?void 0:e.allowNonErrorEvents)??v.allowNonErrorEvents,ignoredStatusCodes:(e==null?void 0:e.ignoredStatusCodes)||v.ignoredStatusCodes,ignoredUrls:(e==null?void 0:e.ignoredUrls)||v.ignoredUrls,captureRequestBody:(e==null?void 0:e.captureRequestBody)??v.captureRequestBody,captureResponseBody:(e==null?void 0:e.captureResponseBody)??v.captureResponseBody,redactKeys:wr(v.redactKeys,e==null?void 0:e.redactKeys),redactUrlParams:wr(v.redactUrlParams,e==null?void 0:e.redactUrlParams),propagateTraceHeaders:(e==null?void 0:e.propagateTraceHeaders)??v.propagateTraceHeaders,traceOrigins:(e==null?void 0:e.traceOrigins)||v.traceOrigins,traceHeaderName:((r=e==null?void 0:e.traceHeaderName)==null?void 0:r.trim())||v.traceHeaderName,enableSessionReplay:(e==null?void 0:e.enableSessionReplay)??v.enableSessionReplay,replayFlushIntervalMs:(e==null?void 0:e.replayFlushIntervalMs)??v.replayFlushIntervalMs,replayMaxSegmentBytes:(e==null?void 0:e.replayMaxSegmentBytes)??v.replayMaxSegmentBytes,replayMaxSegmentEvents:(e==null?void 0:e.replayMaxSegmentEvents)??v.replayMaxSegmentEvents,replayMaskAllInputs:(e==null?void 0:e.replayMaskAllInputs)??v.replayMaskAllInputs}},D=()=>typeof window<"u"&&window.location?window.location.href:"",me=()=>typeof document<"u"&&document.title||"",Es=new Set(["beacon","fetch","xmlhttprequest"]),Ee=1e4,Xe=()=>typeof performance<"u"&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now(),Ts=e=>{const t=String(e.initiatorType||"").toLowerCase(),r=String(e.name||"").toLowerCase();return t==="fetch"||t==="xmlhttprequest"||t==="beacon"?"xhr":t==="css"||t==="link"||r.endsWith(".css")||r.includes(".css?")?"css":t==="script"||r.endsWith(".js")||r.includes(".js?")?"js":t==="img"||t==="image"||/\.(png|jpg|jpeg|gif|svg|webp|avif|ico)(\?|$)/.test(r)?"images":t==="font"||/\.(woff|woff2|ttf|otf|eot)(\?|$)/.test(r)?"fonts":"other"},Rs=e=>{if(!(e!=null&&e.name))return!1;if(e.entryType==="navigation")return!0;const t=String(e.initiatorType||"").toLowerCase();return Es.has(t)?!1:!/^wss?:/i.test(e.name)},_s=e=>{const t=Number(e.responseStatus);if(Number.isFinite(t)&&t>0)return t;if(e.entryType==="navigation")return 200;const r=Number(e.transferSize||0),n=Number(e.encodedBodySize||0),s=Number(e.decodedBodySize||0);return r>0||n>0||s>0?200:null},Ns=e=>Math.round(Xe()+Math.max(0,Number(e.startTime||0))),pt=e=>Math.round(e/(1024*1024)*10)/10,Ms=()=>{if(typeof performance>"u")return null;const e=performance.memory;if(!e)return null;const t=Number(e.usedJSHeapSize||0),r=Number(e.totalJSHeapSize||0),n=Number(e.jsHeapSizeLimit||0);return t<=0&&r<=0&&n<=0?null:{js_heap_limit_mb:pt(n),total_js_heap_mb:pt(r),used_js_heap_mb:pt(t)}},Os=()=>{if(typeof performance>"u")return null;const e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByName("first-contentful-paint")[0];if(!e&&!t)return null;const r={};return e&&(r.dom_content_loaded_ms=Math.round(e.domContentLoadedEventEnd||0),r.load_event_ms=Math.round(e.loadEventEnd||0),r.response_end_ms=Math.round(e.responseEnd||0),r.dom_complete_ms=Math.round(e.domComplete||0),r.transfer_size=Math.round(e.transferSize||0)),t&&(r.first_contentful_paint_ms=Math.round(t.startTime||0)),Object.keys(r).length>0?r:null};class Ar{constructor(){this.config=v,this.brandId=null,this.sessionId=null,this.deviceId=null,this.accountId=null,this.accountTraits=null,this.errorCapture=null,this.initialized=!1,this.performanceObservers=[],this.performanceSampleTimer=null,this.pendingLongTaskMs=0,this.resourceObserver=null,this.replayResourceKeys=new Set,this.nextPerformanceSampleAt=0,this.actionBuffer=new Gr(v.maxActionBufferSize),this.replayRecorder=new ms}async init(t,r){var i;const n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error("[FlashlogTracker] Invalid brand id");const s=ks(r);if(!s.apiKey||!s.apiKey.trim())throw new Error("[FlashlogTracker] Missing api key");this.config={...s,apiKey:s.apiKey.trim()},this.brandId=n,this.sessionId=br(this.config.sessionTimeoutMs),this.deviceId=Sr(),this.accountId=vs(),this.accountTraits=ws(),this.actionBuffer.stop(),this.actionBuffer.clear(),this.actionBuffer.start(),this.stopReplayResourceCapture(),await this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),(i=this.errorCapture)==null||i.stop(),this.errorCapture=null,this.config.autoCapture&&(this.errorCapture=new jr(this.config,{debug:this.config.debug,onNetworkActivity:o=>{this.replayRecorder.addCustomEvent("network-activity",{...o,page_title:me(),session_id:this.sessionId,url_bug_happened:D()})},onNetworkError:o=>{this.trackInternal("NETWORK_ERROR",{...o,error_type:"network_error",url_bug_happened:D(),url:String(o.url||"")})},onSocketError:o=>{this.trackInternal("SOCKET_ERROR",{...o,error_type:"socket_error",url_bug_happened:D(),url:String(o.url||"")})},onJsError:o=>{this.trackInternal("JS_ERROR",{...o,error_type:"js_error",url_bug_happened:D(),url:D()})},onUnhandledRejection:o=>{this.trackInternal("UNHANDLED_REJECTION",{...o,error_type:"unhandled_rejection",url_bug_happened:D(),url:D()})}}),this.errorCapture.start()),this.config.enableSessionReplay&&(await this.replayRecorder.start({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,deviceId:this.deviceId,flushIntervalMs:this.config.replayFlushIntervalMs,maskAllInputs:this.config.replayMaskAllInputs,maxSegmentBytes:this.config.replayMaxSegmentBytes,maxSegmentEvents:this.config.replayMaxSegmentEvents,sessionId:this.sessionId}),this.recordReplaySessionContext("init"),this.startReplayResourceCapture(),this.startReplayPerformanceCapture()),this.initialized=!0,yt({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,source:"package"}),this.config.debug&&console.log("[FlashlogTracker] Initialized",{brandId:this.brandId,apiUrl:this.config.apiUrl})}async track(t,r={}){return!this.config.allowNonErrorEvents&&!gt.has(t)?(this.config.debug&&console.warn("[FlashlogTracker] Ignored non-error event",{eventName:t}),!1):this.trackInternal(t,r)}async reportError(t,r={}){const n=t instanceof Error?t.message:String(t),s=t instanceof Error?t.stack:void 0;return this.trackInternal("MANUAL_ERROR",{message:n,stack:s,context:r,error_type:"manual_error",url_bug_happened:D(),url:D(),timestamp:Date.now()})}addUserAction(t,r){this.actionBuffer.add(t,r),this.replayRecorder.addCustomEvent("user-action",{action:t,details:r||null,session_id:this.sessionId,timestamp:Date.now(),url:D()})}identify(t,r={}){const n=String(t||"").trim();if(!n)throw new Error("[FlashlogTracker] identify requires a non-empty account id");this.accountId=n,this.accountTraits=Object.keys(r).length>0?r:null,bs(n,this.accountTraits||void 0),this.recordReplaySessionContext("identify")}clearIdentity(){this.accountId=null,this.accountTraits=null,vr(),this.recordReplaySessionContext("clear-identity")}getTraceHeaders(){return tt(Ke(),this.config.traceHeaderName)}getSessionId(){return this.sessionId||Cs()}getDeviceId(){return this.deviceId||Ss()}async flushReplay(t="manual"){return this.replayRecorder.flush(t)}async finalizeReplay(t="manual"){return this.captureReplayPerformanceSample("finalize"),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.finalize(t)}reset(){var t;(t=this.errorCapture)==null||t.stop(),this.errorCapture=null,this.actionBuffer.stop(),this.actionBuffer.clear(),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reset"}),As(),this.initialized=!1,this.brandId=null,this.sessionId=null,this.deviceId=null}buildPayload(t,r,n){if(!this.brandId||!this.sessionId||!this.deviceId)return null;const s={actions:this.actionBuffer.getAll(),device_info:At(this.deviceId),network_status:kt(),url_bug_happened:r.url_bug_happened||D(),trace_id:n.trace_id,span_id:n.span_id,traceparent:n.traceparent,...this.accountId?{account_id:this.accountId}:{},...this.accountTraits?{account_traits:this.accountTraits}:{},...r};return{event_name:t,session_id:this.sessionId,brand_id:this.brandId,data:s}}async trackInternal(t,r){if(!this.initialized)return this.config.debug&&console.warn("[FlashlogTracker] Not initialized"),!1;Is(),this.sessionId||(this.sessionId=br(this.config.sessionTimeoutMs)),this.deviceId||(this.deviceId=Sr());const n=Zr(r),s=this.buildPayload(t,r,n);if(!s)return!1;const i=xr(s,this.config),o=typeof i.data.status=="number"?i.data.status:typeof i.data.http_status=="number"?i.data.http_status:null,c=typeof i.data.method=="string"?i.data.method.toUpperCase():typeof i.data.http_method=="string"?i.data.http_method.toUpperCase():null,a=typeof i.data.request_url=="string"?i.data.request_url:typeof i.data.url=="string"?i.data.url:null;this.replayRecorder.addCustomEvent("tracking-event",{...i.data,event_name:t,error_type:typeof i.data.error_type=="string"?i.data.error_type:null,http_method:c,http_status:o,method:c,page_title:me(),request_url:a,session_id:s.session_id,timestamp:typeof i.data.timestamp=="number"?i.data.timestamp:Date.now()});try{const d={"Content-Type":"application/json","x-api-key":this.config.apiKey},l=`${this.config.apiUrl.replace(/\/$/,"")}/v1/integration/webhook`,u=await fetch(l,{method:"POST",headers:d,body:JSON.stringify(i)});return u.ok?(gt.has(t)&&this.replayRecorder.flush("tracked-error"),!0):(this.config.debug&&console.error("[FlashlogTracker] Track failed",{eventName:t,status:u.status}),!1)}catch(d){return this.config.debug&&console.error("[FlashlogTracker] Track error",d),!1}}recordReplaySessionContext(t){!this.config.enableSessionReplay||!this.sessionId||!this.deviceId||this.replayRecorder.addCustomEvent("session-context",{account_id:this.accountId,account_traits:this.accountTraits,device_info:At(this.deviceId),network_status:kt(),page_title:me(),page_url:D(),performance:Os(),reason:t,session_id:this.sessionId,timestamp:Date.now()})}stopReplayResourceCapture(){var t;(t=this.resourceObserver)==null||t.disconnect(),this.resourceObserver=null,this.replayResourceKeys.clear()}stopReplayPerformanceCapture(){this.performanceObservers.forEach(t=>t.disconnect()),this.performanceObservers=[],this.performanceSampleTimer!==null&&typeof window<"u"&&(window.clearTimeout(this.performanceSampleTimer),this.performanceSampleTimer=null),this.pendingLongTaskMs=0,this.nextPerformanceSampleAt=0}startReplayResourceCapture(){if(this.stopReplayResourceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u")&&(this.captureReplayResourceEntries(performance.getEntriesByType("navigation"),"buffered"),this.captureReplayResourceEntries(performance.getEntriesByType("resource"),"buffered"),!(typeof PerformanceObserver>"u")))try{this.resourceObserver=new PerformanceObserver(t=>{this.captureReplayResourceEntries(t.getEntries(),"observed")}),this.resourceObserver.observe({entryTypes:["resource"]})}catch{this.resourceObserver=null}}startReplayPerformanceCapture(){this.stopReplayPerformanceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u"||typeof window>"u")&&(this.observeReplayLongTasks(),this.observeReplayLayoutShifts(),this.nextPerformanceSampleAt=performance.now(),this.captureReplayPerformanceSample("start"),this.scheduleReplayPerformanceSample())}scheduleReplayPerformanceSample(){typeof window>"u"||typeof performance>"u"||!this.config.enableSessionReplay||!this.sessionId||(this.performanceSampleTimer=window.setTimeout(()=>{this.captureReplayPerformanceSample("interval"),this.scheduleReplayPerformanceSample()},Ee))}captureReplayPerformanceSample(t){if(!this.sessionId||typeof performance>"u"||!this.config.enableSessionReplay)return;const r=performance.now(),n=this.nextPerformanceSampleAt||r,s=Math.max(0,r-n);this.nextPerformanceSampleAt=r+Ee;const i=Math.min(100,Math.round(Math.min(Ee,s)/Ee*100+Math.min(Ee,this.pendingLongTaskMs)/Ee*100)),o=Ms();this.pendingLongTaskMs=0,this.replayRecorder.addCustomEvent("performance-sample",{cpu_usage_pct:i,js_heap_limit_mb:(o==null?void 0:o.js_heap_limit_mb)??null,memory_mb:(o==null?void 0:o.used_js_heap_mb)??null,page_title:me(),page_url:D(),reason:t,session_id:this.sessionId,timestamp:Math.round(Xe()+r),total_memory_mb:(o==null?void 0:o.total_js_heap_mb)??null})}observeReplayLongTasks(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Math.round(Number(n.duration||0));s<=0||(this.pendingLongTaskMs+=s,this.replayRecorder.addCustomEvent("long-task",{duration_ms:s,name:n.name||"longtask",page_title:me(),page_url:D(),session_id:this.sessionId,start_time_ms:Math.round(Number(n.startTime||0)),timestamp:Math.round(Xe()+Number(n.startTime||performance.now()))}))})});t.observe({type:"longtask",buffered:!0}),this.performanceObservers.push(t)}catch{}}observeReplayLayoutShifts(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Number(n.value||0);!Number.isFinite(s)||s<=0||n.hadRecentInput||this.replayRecorder.addCustomEvent("layout-shift",{page_title:me(),page_url:D(),session_id:this.sessionId,timestamp:Math.round(Xe()+Number(n.startTime||performance.now())),value:Math.round(s*1e4)/1e4})})});t.observe({type:"layout-shift",buffered:!0}),this.performanceObservers.push(t)}catch{}}captureReplayResourceEntries(t,r){this.sessionId&&t.forEach(n=>{if(!Rs(n))return;const s=[n.entryType,n.name,Math.round(Number(n.startTime||0)),Math.round(Number(n.duration||0)),String(n.initiatorType||"")].join("|");this.replayResourceKeys.has(s)||(this.replayResourceKeys.add(s),this.replayRecorder.addCustomEvent("resource-entry",{capture_mode:r,duration_ms:Math.round(Number(n.duration||0)),encoded_body_size:Math.round(Number(n.encodedBodySize||0)),entry_type:n.entryType,initiator_type:String(n.initiatorType||""),method:"GET",page_title:me(),page_url:D(),request_url:n.name,resource_type:Ts(n),response_end_ms:Math.round(Number(n.responseEnd||0)),session_id:this.sessionId,status:_s(n),timestamp:Ns(n),transfer_size:Math.round(Number(n.transferSize||0)),url:n.name}))})}}const kr=()=>new Ar,Be=kr(),Ls=Be,te=(e,t)=>e===void 0?t:e==="true",De=(e,t)=>{if(!e)return t;const r=Number(e);return Number.isFinite(r)?r:t},ft=e=>{if(!e)return;const t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:void 0},Fs=()=>{if(typeof document>"u")return null;if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.src.includes("tracker.umd.js"))return r}return null},xs=async()=>{if(typeof window>"u"||typeof document>"u")return;const e=Fs();if(!e||e.dataset.autoInit!=="true")return;const t=e.dataset.productId||e.dataset.brandId,r=e.dataset.apiKey,n=te(e.dataset.debug,!1);if(t){if(!r){console.error("[FlashlogTracker] Auto init failed: missing data-api-key");return}try{await Be.init(t,{apiUrl:e.dataset.apiUrl,apiKey:r,debug:n,autoCapture:te(e.dataset.autoCapture,!0),captureNetworkErrors:te(e.dataset.captureNetworkErrors,!0),captureJsErrors:te(e.dataset.captureJsErrors,!0),captureSocketErrors:te(e.dataset.captureSocketErrors,!0),allowNonErrorEvents:te(e.dataset.allowNonErrorEvents,!1),sessionTimeoutMs:De(e.dataset.sessionTimeoutMs,30*60*1e3),maxActionBufferSize:De(e.dataset.maxActionBufferSize,50),captureRequestBody:te(e.dataset.captureRequestBody,!0),captureResponseBody:te(e.dataset.captureResponseBody,!0),propagateTraceHeaders:te(e.dataset.propagateTraceHeaders,!1),traceOrigins:ft(e.dataset.traceOrigins),traceHeaderName:e.dataset.traceHeaderName,redactKeys:ft(e.dataset.redactKeys),redactUrlParams:ft(e.dataset.redactUrlParams),enableSessionReplay:te(e.dataset.enableSessionReplay,!0),replayFlushIntervalMs:De(e.dataset.replayFlushIntervalMs,v.replayFlushIntervalMs),replayMaxSegmentBytes:De(e.dataset.replayMaxSegmentBytes,v.replayMaxSegmentBytes),replayMaxSegmentEvents:De(e.dataset.replayMaxSegmentEvents,v.replayMaxSegmentEvents),replayMaskAllInputs:te(e.dataset.replayMaskAllInputs,v.replayMaskAllInputs)}),yt({apiUrl:e.dataset.apiUrl,apiKey:r,brandId:t,source:"script",scriptUrl:e.src,debug:n})}catch(s){console.error("[FlashlogTracker] Auto init failed",s)}}};typeof window<"u"&&(window.FlashlogBugTracker=Be,window.Tracker||(window.Tracker=Be),xs()),se.DEFAULT_CONFIG=v,se.FlashlogTrackerLite=Ar,se.createTracker=kr,se.default=Be,se.flashlogTracker=Ls,Object.defineProperties(se,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
24
+ `),n=[];for(let s=2,i=r.length;s<i;s+=2){const o=t.exec(r[s]);o&&n.push(new we({fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera10:function(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split(`
25
+ `),n=[];for(let s=0,i=r.length;s<i;s+=2){const o=t.exec(r[s]);o&&n.push(new we({functionName:o[3]||void 0,fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera11:function(e){return e.stack.split(`
26
+ `).filter(function(r){return!!r.match(ns)&&!r.match(/^Error created at/)},this).map(function(r){const n=r.split("@"),s=this.extractLocation(n.pop()),o=(n.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new we({functionName:o,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})},this)}};function is(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let r=e.localName;if(!r)break;r=r.toLowerCase();const n=e.parentElement,s=[];if(n.children&&n.children.length>0)for(let i=0;i<n.children.length;i++){const o=n.children[i];o.localName&&o.localName.toLowerCase&&o.localName.toLowerCase()===r&&s.push(o)}s.length>1&&(r+=`:eq(${s.indexOf(e)})`),t=r+(t?">"+t:""),e=n}return t}function dt(e){return Object.prototype.toString.call(e)==="[object Object]"}function fr(e,t){if(t===0)return!0;const r=Object.keys(e);for(const n of r)if(dt(e[n])&&fr(e[n],t-1))return!0;return!1}function lt(e,t){const r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);const n=[],s=[];return JSON.stringify(e,function(c,a){if(n.length>0){const d=n.indexOf(this);~d?n.splice(d+1):n.push(this),~d?s.splice(d,1/0,c):s.push(c),~n.indexOf(a)&&(n[0]===a?a="[Circular ~]":a="[Circular ~."+s.slice(0,n.indexOf(a)).join(".")+"]")}else n.push(a);if(a===null)return a;if(a===void 0)return"undefined";if(i(a))return o(a);if(a instanceof Event){const d={};for(const l in a){const u=a[l];Array.isArray(u)?d[l]=is(u.length?u[0]:null):d[l]=u}return d}else{if(a instanceof Node)return a instanceof HTMLElement?a?a.outerHTML:"":a.nodeName;if(a instanceof Error)return a.stack?a.stack+`
27
+ End of stack for Error object`:a.name+": "+a.message}return a});function i(c){return!!(dt(c)&&Object.keys(c).length>r.numOfKeysLimit||typeof c=="function"||dt(c)&&fr(c,r.depthOfLimit))}function o(c){let a=c.toString();return r.stringLengthLimit&&a.length>r.stringLengthLimit&&(a=`${a.slice(0,r.stringLengthLimit)}...`),a}}const mr={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function os(e,t,r){const n=r?Object.assign({},mr,r):mr,s=n.logger;if(!s)return()=>{};let i;typeof s=="string"?i=t[s]:i=s;let o=0;const c=[];if(n.level.includes("error")&&window){const d=l=>{const u=l.message,h=l.error,f=hr.parse(h).map(y=>y.toString()),p=[lt(u,n.stringifyOptions)];e({level:"error",trace:f,payload:p})};window.addEventListener("error",d),c.push(()=>{window&&window.removeEventListener("error",d)})}for(const d of n.level)c.push(a(i,d));return()=>{c.forEach(d=>d())};function a(d,l){return d[l]?le(d,l,u=>(...h)=>{u.apply(this,h);try{const f=hr.parse(new Error).map(y=>y.toString()).splice(1),p=h.map(y=>lt(y,n.stringifyOptions));o++,o<n.lengthThreshold?e({level:l,trace:f,payload:p}):o===n.lengthThreshold&&e({level:"warn",trace:[],payload:[lt("The number of log records reached the threshold.")]})}catch(f){u("rrweb logger error:",f,...h)}}):()=>{}}}const as="rrweb/console@1",cs=e=>({name:as,observer:os,options:e}),ds="application/json",ls="flashlog",us=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,xe=()=>typeof window<"u"&&window.location?window.location.href:"",gr=e=>new Date(typeof e=="number"?e:Date.now()).toISOString(),ut=async e=>{try{return await e.json()}catch{return null}};class yr extends Error{constructor(t){super(t),this.name="ReplayQuotaError"}}class Ir extends Error{constructor(t){super(t),this.name="ReplaySegmentTooLargeError"}}class ps{constructor(){this.config=null,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.flushTimer=null,this.replaySessionId=null,this.segmentSequence=0}async start(t){await this.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),!(typeof window>"u"||typeof document>"u")&&(this.config=t,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.replaySessionId=null,this.segmentSequence=0,this.stopRecording=ve({emit:r=>this.pushEvent(r),collectFonts:!0,inlineStylesheet:!0,maskAllInputs:t.maskAllInputs,userTriggeredOnInput:!0,plugins:[cs()]})||void 0,this.bindLifecycleListeners(),this.flushTimer=window.setInterval(()=>{this.flush("interval")},t.flushIntervalMs),this.addCustomEvent("session-start",{session_id:t.sessionId,brand_id:t.brandId,device_id:t.deviceId,page_url:xe(),started_at:new Date().toISOString()}))}async flush(t="manual",r){if(this.flushInFlight)return this.flushInFlight;if(!this.config||this.finalized)return null;const n=this.takePendingSegment();if(!n)return null;let s=!1;return this.flushInFlight=this.uploadSegment(n,t,(r==null?void 0:r.keepalive)===!0).then(i=>(s=!0,i)).catch(i=>i instanceof yr?(this.currentBytes=0,this.currentEvents=[],this.finalized=!0,this.stopCapture(),this.debug("Replay capture stopped by server quota",{message:i.message,reason:t,segmentId:n.segmentId}),null):i instanceof Ir?(s=!0,this.debug("Replay event skipped because it exceeds the upload limit",{message:i.message,reason:t,segmentId:n.segmentId,sizeBytes:n.sizeBytes}),null):(this.restorePendingSegment(n),this.debug("Replay upload failed",{message:i instanceof Error?i.message:String(i),reason:t,segmentId:n.segmentId}),null)).finally(()=>{this.flushInFlight=null,s&&this.currentEvents.length>0&&this.flush("buffer-threshold")}),this.flushInFlight}async finalize(t="manual",r){if(!this.config||this.finalized)return null;this.addCustomEvent("session-finalize",{reason:t,page_url:xe(),session_id:this.config.sessionId,timestamp:new Date().toISOString()}),this.stopCapture();let n=null;for(;this.flushInFlight||this.currentEvents.length>0;){const a=await this.flush(t,{keepalive:(r==null?void 0:r.keepalive)===!0});if(!a){if(this.flushInFlight)continue;break}n=a}if(this.replaySessionId=(n==null?void 0:n.replay_session_id)||this.replaySessionId,this.finalized=!0,!this.replaySessionId)return this.config=null,null;const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/finalize`,o=await fetch(i,{body:JSON.stringify({brand_id:s.brandId,device_id:s.deviceId,finalized_reason:t,page_url:xe(),replay_session_id:this.replaySessionId,session_id:s.sessionId}),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:(r==null?void 0:r.keepalive)===!0,method:"POST"}).catch(a=>(this.debug("Replay finalize failed",{message:a instanceof Error?a.message:String(a),reason:t}),null));if(this.config=null,!o)return null;const c=await ut(o);return o.ok?(c==null?void 0:c.data)||null:(this.debug("Replay finalize returned non-200",{message:(c==null?void 0:c.message)||`HTTP ${o.status}`,reason:t}),null)}async dispose(t){if((t==null?void 0:t.finalize)===!0&&!!this.config&&!this.finalized){await this.finalize((t==null?void 0:t.reason)||"dispose",{keepalive:(t==null?void 0:t.keepalive)===!0}).catch(()=>null);return}this.stopCapture(),this.config=null,this.currentBytes=0,this.currentEvents=[],this.flushInFlight=null,this.finalized=!0,this.replaySessionId=null,this.segmentSequence=0}addCustomEvent(t,r){if(!(!this.config||this.finalized))try{rs(`${ls}:${t}`,r)}catch(n){this.debug("Replay custom event skipped",{message:n instanceof Error?n.message:String(n),tag:t})}}bindLifecycleListeners(){if(typeof window>"u"||typeof document>"u")return;const t=()=>{document.visibilityState==="hidden"&&this.flush("visibility-hidden",{keepalive:!0})},r=()=>{this.finalize("pagehide",{keepalive:!0})},n=()=>{this.flush("beforeunload",{keepalive:!0})};document.addEventListener("visibilitychange",t,!0),window.addEventListener("pagehide",r),window.addEventListener("beforeunload",n),this.detachListeners=[()=>document.removeEventListener("visibilitychange",t,!0),()=>window.removeEventListener("pagehide",r),()=>window.removeEventListener("beforeunload",n)]}debug(t,r){var n;(n=this.config)!=null&&n.debug&&console.log("[FlashlogTracker][Replay]",t,r||{})}pushEvent(t){!this.config||this.finalized||(this.currentEvents.push(t),this.currentBytes+=this.estimateEventSize(t),this.isBufferAtThreshold()&&this.flush("buffer-threshold"))}isBufferAtThreshold(){return!!(this.config&&(this.currentBytes>=this.config.maxSegmentBytes||this.currentEvents.length>=this.config.maxSegmentEvents))}estimateEventSize(t){try{const r=JSON.stringify(t);return typeof TextEncoder>"u"?r.length:new TextEncoder().encode(r).byteLength}catch{return 0}}nextSegmentId(t){return`segment-${String(t).padStart(6,"0")}-${us()}`}restorePendingSegment(t){this.currentEvents=[...t.events,...this.currentEvents],this.currentBytes+=t.sizeBytes,this.segmentSequence=Math.min(this.segmentSequence,t.sequenceNumber)}stopCapture(){var t;(t=this.stopRecording)==null||t.call(this),this.stopRecording=void 0,this.flushTimer!==null&&typeof window<"u"&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.detachListeners.forEach(r=>r()),this.detachListeners=[]}takePendingSegment(){var i,o;if(!this.config||this.currentEvents.length===0)return null;let t=0,r=0;for(const c of this.currentEvents){const a=this.estimateEventSize(c),d=t>0&&r+a>this.config.maxSegmentBytes,l=t>=this.config.maxSegmentEvents;if(d||l)break;t+=1,r+=a}const n=this.currentEvents.splice(0,Math.max(t,1));t===0&&(r=this.estimateEventSize(n[0]));const s=this.segmentSequence;return this.currentBytes=Math.max(0,this.currentBytes-r),this.segmentSequence+=1,{endedAt:gr((i=n[n.length-1])==null?void 0:i.timestamp),eventCount:n.length,events:n,segmentId:this.nextSegmentId(s),sequenceNumber:s,sizeBytes:r,startedAt:gr((o=n[0])==null?void 0:o.timestamp)}}async uploadSegment(t,r,n){var f;if(!this.config)throw new Error("Replay recorder is not configured");const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/segments/upload-url`,o={brand_id:s.brandId,content_type:ds,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),replay_session_id:this.replaySessionId,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt,upload_reason:r},c=await fetch(i,{body:JSON.stringify(o),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:n,method:"POST"}),a=await ut(c);if(!c.ok||!((f=a==null?void 0:a.data)!=null&&f.upload_url)){const p=a==null?void 0:a.message,y=typeof p=="object"&&p?p.code:a==null?void 0:a.code,S=typeof p=="object"&&p?p.message:p;throw c.status===403&&typeof y=="string"&&y.startsWith("REPLAY_")?new yr(S||"Replay capture quota exhausted"):new Error(S||`Failed to create replay upload URL (${c.status})`)}this.replaySessionId=a.data.replay_session_id||this.replaySessionId;const d=JSON.stringify({events:t.events,meta:{brand_id:s.brandId,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),reason:r,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt},source:"flashlog-tracker-sdk",type:"rrweb-event-segment",version:1}),l=typeof TextEncoder>"u"?d.length:new TextEncoder().encode(d).byteLength;if(l>a.data.max_bytes)throw new Ir(`Replay segment is ${l} bytes; upload limit is ${a.data.max_bytes} bytes`);const u=await fetch(a.data.upload_url,{body:d,headers:{"Content-Type":"application/octet-stream"},keepalive:n,method:a.data.method||"PUT"}),h=await ut(u);if(!u.ok||!(h!=null&&h.data))throw new Error((h==null?void 0:h.message)||`Replay segment upload failed (${u.status})`);return this.debug("Replay segment uploaded",{objectKey:h.data.object_key,reason:r,segmentId:h.data.segment_id,sequenceNumber:h.data.sequence_number}),h.data}}const pt=()=>typeof window<"u"&&typeof window.localStorage<"u",Cr=()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=Date.now().toString(36),t=Math.random().toString(36).slice(2,12);return`${e}-${t}`},pe=e=>pt()?window.localStorage.getItem(e):null,he=(e,t)=>{pt()&&window.localStorage.setItem(e,t)},Ae=e=>{pt()&&window.localStorage.removeItem(e)},hs=e=>{const t=pe(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},fs=(e,t)=>{he(e,JSON.stringify(t))},Sr=()=>{const e=pe(N.deviceId);if(e)return e;const t=Cr();return he(N.deviceId,t),t},br=e=>{const t=Date.now(),r=pe(N.sessionId),n=pe(N.sessionSeenAt),s=n?Number(n):NaN,i=Number.isFinite(s)&&t-s<=e;if(r&&i)return he(N.sessionSeenAt,String(t)),r;const o=Cr();return he(N.sessionId,o),he(N.sessionSeenAt,String(t)),o},ms=()=>{he(N.sessionSeenAt,String(Date.now()))},gs=()=>pe(N.sessionId),ys=()=>pe(N.deviceId),Is=(e,t)=>{if(he(N.accountId,e),t&&Object.keys(t).length>0){fs(N.accountTraits,t);return}Ae(N.accountTraits)},Cs=()=>pe(N.accountId),Ss=()=>hs(N.accountTraits),vr=()=>{Ae(N.accountId),Ae(N.accountTraits)},bs=()=>{Ae(N.sessionId),Ae(N.sessionSeenAt),Ae(N.deviceId),vr()},wr=(e,t)=>Array.from(new Set([...e,...t||[]])),vs=e=>{var t,r;return{apiUrl:((t=e==null?void 0:e.apiUrl)==null?void 0:t.trim())||w.apiUrl,apiKey:(e==null?void 0:e.apiKey)??w.apiKey,debug:(e==null?void 0:e.debug)??w.debug,autoCapture:(e==null?void 0:e.autoCapture)??w.autoCapture,captureNetworkErrors:(e==null?void 0:e.captureNetworkErrors)??w.captureNetworkErrors,captureJsErrors:(e==null?void 0:e.captureJsErrors)??w.captureJsErrors,captureSocketErrors:(e==null?void 0:e.captureSocketErrors)??w.captureSocketErrors,sessionTimeoutMs:(e==null?void 0:e.sessionTimeoutMs)??w.sessionTimeoutMs,maxActionBufferSize:(e==null?void 0:e.maxActionBufferSize)??w.maxActionBufferSize,allowNonErrorEvents:(e==null?void 0:e.allowNonErrorEvents)??w.allowNonErrorEvents,ignoredStatusCodes:(e==null?void 0:e.ignoredStatusCodes)||w.ignoredStatusCodes,ignoredUrls:(e==null?void 0:e.ignoredUrls)||w.ignoredUrls,captureRequestBody:(e==null?void 0:e.captureRequestBody)??w.captureRequestBody,captureResponseBody:(e==null?void 0:e.captureResponseBody)??w.captureResponseBody,redactKeys:wr(w.redactKeys,e==null?void 0:e.redactKeys),redactUrlParams:wr(w.redactUrlParams,e==null?void 0:e.redactUrlParams),propagateTraceHeaders:(e==null?void 0:e.propagateTraceHeaders)??w.propagateTraceHeaders,traceOrigins:(e==null?void 0:e.traceOrigins)||w.traceOrigins,traceHeaderName:((r=e==null?void 0:e.traceHeaderName)==null?void 0:r.trim())||w.traceHeaderName,enableSessionReplay:(e==null?void 0:e.enableSessionReplay)??w.enableSessionReplay,replayFlushIntervalMs:(e==null?void 0:e.replayFlushIntervalMs)??w.replayFlushIntervalMs,replayMaxSegmentBytes:(e==null?void 0:e.replayMaxSegmentBytes)??w.replayMaxSegmentBytes,replayMaxSegmentEvents:(e==null?void 0:e.replayMaxSegmentEvents)??w.replayMaxSegmentEvents,replayMaskAllInputs:(e==null?void 0:e.replayMaskAllInputs)??w.replayMaskAllInputs}},L=()=>typeof window<"u"&&window.location?window.location.href:"",fe=()=>typeof document<"u"&&document.title||"",ws=new Set(["beacon","fetch","xmlhttprequest"]),ke=1e4,Ye=()=>typeof performance<"u"&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now(),As=e=>{const t=String(e.initiatorType||"").toLowerCase(),r=String(e.name||"").toLowerCase();return t==="fetch"||t==="xmlhttprequest"||t==="beacon"?"xhr":t==="css"||t==="link"||r.endsWith(".css")||r.includes(".css?")?"css":t==="script"||r.endsWith(".js")||r.includes(".js?")?"js":t==="img"||t==="image"||/\.(png|jpg|jpeg|gif|svg|webp|avif|ico)(\?|$)/.test(r)?"images":t==="font"||/\.(woff|woff2|ttf|otf|eot)(\?|$)/.test(r)?"fonts":"other"},ks=e=>{if(!(e!=null&&e.name))return!1;if(e.entryType==="navigation")return!0;const t=String(e.initiatorType||"").toLowerCase();return ws.has(t)?!1:!/^wss?:/i.test(e.name)},Es=e=>{const t=Number(e.responseStatus);if(Number.isFinite(t)&&t>0)return t;if(e.entryType==="navigation")return 200;const r=Number(e.transferSize||0),n=Number(e.encodedBodySize||0),s=Number(e.decodedBodySize||0);return r>0||n>0||s>0?200:null},Rs=e=>Math.round(Ye()+Math.max(0,Number(e.startTime||0))),ht=e=>Math.round(e/(1024*1024)*10)/10,Ts=()=>{if(typeof performance>"u")return null;const e=performance.memory;if(!e)return null;const t=Number(e.usedJSHeapSize||0),r=Number(e.totalJSHeapSize||0),n=Number(e.jsHeapSizeLimit||0);return t<=0&&r<=0&&n<=0?null:{js_heap_limit_mb:ht(n),total_js_heap_mb:ht(r),used_js_heap_mb:ht(t)}},_s=()=>{if(typeof performance>"u")return null;const e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByName("first-contentful-paint")[0];if(!e&&!t)return null;const r={};return e&&(r.dom_content_loaded_ms=Math.round(e.domContentLoadedEventEnd||0),r.load_event_ms=Math.round(e.loadEventEnd||0),r.response_end_ms=Math.round(e.responseEnd||0),r.dom_complete_ms=Math.round(e.domComplete||0),r.transfer_size=Math.round(e.transferSize||0)),t&&(r.first_contentful_paint_ms=Math.round(t.startTime||0)),Object.keys(r).length>0?r:null};class Ns{constructor(){this.config=w,this.brandId=null,this.sessionId=null,this.deviceId=null,this.accountId=null,this.accountTraits=null,this.errorCapture=null,this.initialized=!1,this.performanceObservers=[],this.performanceSampleTimer=null,this.pendingLongTaskMs=0,this.resourceObserver=null,this.replayResourceKeys=new Set,this.nextPerformanceSampleAt=0,this.actionBuffer=new Ur(w.maxActionBufferSize),this.replayRecorder=new ps}async init(t,r){var i;const n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error("[FlashlogTracker] Invalid brand id");const s=vs(r);if(!s.apiKey||!s.apiKey.trim())throw new Error("[FlashlogTracker] Missing api key");this.config={...s,apiKey:s.apiKey.trim()},this.brandId=n,this.sessionId=br(this.config.sessionTimeoutMs),this.deviceId=Sr(),this.accountId=Cs(),this.accountTraits=Ss(),this.actionBuffer.stop(),this.actionBuffer.clear(),this.actionBuffer.start(),this.stopReplayResourceCapture(),await this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),(i=this.errorCapture)==null||i.stop(),this.errorCapture=null,this.config.autoCapture&&(this.errorCapture=new Pr(this.config,{debug:this.config.debug,onNetworkActivity:o=>{this.replayRecorder.addCustomEvent("network-activity",{...o,page_title:fe(),session_id:this.sessionId,url_bug_happened:L()})},onNetworkError:o=>{this.trackInternal("NETWORK_ERROR",{...o,error_type:"network_error",url_bug_happened:L(),url:String(o.url||"")})},onSocketError:o=>{this.trackInternal("SOCKET_ERROR",{...o,error_type:"socket_error",url_bug_happened:L(),url:String(o.url||"")})},onJsError:o=>{this.replayRecorder.addCustomEvent("js-error",{...o,session_id:this.sessionId,timestamp:Date.now(),url:L()}),this.trackInternal("JS_ERROR",{...o,error_type:"js_error",url_bug_happened:L(),url:L()})},onUnhandledRejection:o=>{this.replayRecorder.addCustomEvent("unhandled-rejection",{...o,session_id:this.sessionId,timestamp:Date.now(),url:L()}),this.trackInternal("UNHANDLED_REJECTION",{...o,error_type:"unhandled_rejection",url_bug_happened:L(),url:L()})}}),this.errorCapture.start()),this.config.enableSessionReplay&&(await this.replayRecorder.start({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,deviceId:this.deviceId,flushIntervalMs:this.config.replayFlushIntervalMs,maskAllInputs:this.config.replayMaskAllInputs,maxSegmentBytes:this.config.replayMaxSegmentBytes,maxSegmentEvents:this.config.replayMaxSegmentEvents,sessionId:this.sessionId}),this.recordReplaySessionContext("init"),this.startReplayResourceCapture(),this.startReplayPerformanceCapture()),this.initialized=!0,yt({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,source:"package"}),this.config.debug&&console.log("[FlashlogTracker] Initialized",{brandId:this.brandId,apiUrl:this.config.apiUrl})}async track(t,r={}){return!this.config.allowNonErrorEvents&&!gt.has(t)?(this.config.debug&&console.warn("[FlashlogTracker] Ignored non-error event",{eventName:t}),!1):this.trackInternal(t,r)}async reportError(t,r={}){const n=t instanceof Error?t.message:String(t),s=t instanceof Error?t.stack:void 0;return this.replayRecorder.addCustomEvent("js-error",{message:n,stack:s,context:r,error_type:"manual_error",session_id:this.sessionId,timestamp:Date.now(),url:L()}),this.trackInternal("MANUAL_ERROR",{message:n,stack:s,context:r,error_type:"manual_error",url_bug_happened:L(),url:L(),timestamp:Date.now()})}addUserAction(t,r){this.actionBuffer.add(t,r),this.replayRecorder.addCustomEvent("user-action",{action:t,details:r||null,session_id:this.sessionId,timestamp:Date.now(),url:L()})}identify(t,r={}){const n=String(t||"").trim();if(!n)throw new Error("[FlashlogTracker] identify requires a non-empty account id");this.accountId=n,this.accountTraits=Object.keys(r).length>0?r:null,Is(n,this.accountTraits||void 0),this.recordReplaySessionContext("identify")}clearIdentity(){this.accountId=null,this.accountTraits=null,vr(),this.recordReplaySessionContext("clear-identity")}getTraceHeaders(){return tt(Ge(),this.config.traceHeaderName)}getSessionId(){return this.sessionId||gs()}getDeviceId(){return this.deviceId||ys()}async flushReplay(t="manual"){return this.replayRecorder.flush(t)}async finalizeReplay(t="manual"){return this.captureReplayPerformanceSample("finalize"),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.finalize(t)}reset(){var t;(t=this.errorCapture)==null||t.stop(),this.errorCapture=null,this.actionBuffer.stop(),this.actionBuffer.clear(),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reset"}),bs(),this.initialized=!1,this.brandId=null,this.sessionId=null,this.deviceId=null}buildPayload(t,r,n){if(!this.brandId||!this.sessionId||!this.deviceId)return null;const s={actions:this.actionBuffer.getAll(),device_info:At(this.deviceId),network_status:kt(),url_bug_happened:r.url_bug_happened||L(),trace_id:n.trace_id,span_id:n.span_id,traceparent:n.traceparent,...this.accountId?{account_id:this.accountId}:{},...this.accountTraits?{account_traits:this.accountTraits}:{},...r};return{event_name:t,session_id:this.sessionId,brand_id:this.brandId,data:s}}async trackInternal(t,r){if(!this.initialized)return this.config.debug&&console.warn("[FlashlogTracker] Not initialized"),!1;ms(),this.sessionId||(this.sessionId=br(this.config.sessionTimeoutMs)),this.deviceId||(this.deviceId=Sr());const n=Kr(r),s=this.buildPayload(t,r,n);if(!s)return!1;const i=Or(s,this.config),o=typeof i.data.status=="number"?i.data.status:typeof i.data.http_status=="number"?i.data.http_status:null,c=typeof i.data.method=="string"?i.data.method.toUpperCase():typeof i.data.http_method=="string"?i.data.http_method.toUpperCase():null,a=typeof i.data.request_url=="string"?i.data.request_url:typeof i.data.url=="string"?i.data.url:null;this.replayRecorder.addCustomEvent("tracking-event",{...i.data,event_name:t,error_type:typeof i.data.error_type=="string"?i.data.error_type:null,http_method:c,http_status:o,method:c,page_title:fe(),request_url:a,session_id:s.session_id,timestamp:typeof i.data.timestamp=="number"?i.data.timestamp:Date.now()});try{const d={"Content-Type":"application/json","x-api-key":this.config.apiKey},l=`${this.config.apiUrl.replace(/\/$/,"")}/v1/integration/webhook`,u=await fetch(l,{method:"POST",headers:d,body:JSON.stringify(i)});return u.ok?(gt.has(t)&&this.replayRecorder.flush("tracked-error"),!0):(this.config.debug&&console.error("[FlashlogTracker] Track failed",{eventName:t,status:u.status}),!1)}catch(d){return this.config.debug&&console.error("[FlashlogTracker] Track error",d),!1}}recordReplaySessionContext(t){!this.config.enableSessionReplay||!this.sessionId||!this.deviceId||this.replayRecorder.addCustomEvent("session-context",{account_id:this.accountId,account_traits:this.accountTraits,device_info:At(this.deviceId),network_status:kt(),page_title:fe(),page_url:L(),performance:_s(),reason:t,session_id:this.sessionId,timestamp:Date.now()})}stopReplayResourceCapture(){var t;(t=this.resourceObserver)==null||t.disconnect(),this.resourceObserver=null,this.replayResourceKeys.clear()}stopReplayPerformanceCapture(){this.performanceObservers.forEach(t=>t.disconnect()),this.performanceObservers=[],this.performanceSampleTimer!==null&&typeof window<"u"&&(window.clearTimeout(this.performanceSampleTimer),this.performanceSampleTimer=null),this.pendingLongTaskMs=0,this.nextPerformanceSampleAt=0}startReplayResourceCapture(){if(this.stopReplayResourceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u")&&(this.captureReplayResourceEntries(performance.getEntriesByType("navigation"),"buffered"),this.captureReplayResourceEntries(performance.getEntriesByType("resource"),"buffered"),!(typeof PerformanceObserver>"u")))try{this.resourceObserver=new PerformanceObserver(t=>{this.captureReplayResourceEntries(t.getEntries(),"observed")}),this.resourceObserver.observe({entryTypes:["resource"]})}catch{this.resourceObserver=null}}startReplayPerformanceCapture(){this.stopReplayPerformanceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u"||typeof window>"u")&&(this.observeReplayLongTasks(),this.observeReplayLayoutShifts(),this.nextPerformanceSampleAt=performance.now(),this.captureReplayPerformanceSample("start"),this.scheduleReplayPerformanceSample())}scheduleReplayPerformanceSample(){typeof window>"u"||typeof performance>"u"||!this.config.enableSessionReplay||!this.sessionId||(this.performanceSampleTimer=window.setTimeout(()=>{this.captureReplayPerformanceSample("interval"),this.scheduleReplayPerformanceSample()},ke))}captureReplayPerformanceSample(t){if(!this.sessionId||typeof performance>"u"||!this.config.enableSessionReplay)return;const r=performance.now(),n=this.nextPerformanceSampleAt||r,s=Math.max(0,r-n);this.nextPerformanceSampleAt=r+ke;const i=Math.min(100,Math.round(Math.min(ke,s)/ke*100+Math.min(ke,this.pendingLongTaskMs)/ke*100)),o=Ts();this.pendingLongTaskMs=0,this.replayRecorder.addCustomEvent("performance-sample",{cpu_usage_pct:i,js_heap_limit_mb:(o==null?void 0:o.js_heap_limit_mb)??null,memory_mb:(o==null?void 0:o.used_js_heap_mb)??null,page_title:fe(),page_url:L(),reason:t,session_id:this.sessionId,timestamp:Math.round(Ye()+r),total_memory_mb:(o==null?void 0:o.total_js_heap_mb)??null})}observeReplayLongTasks(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Math.round(Number(n.duration||0));s<=0||(this.pendingLongTaskMs+=s,this.replayRecorder.addCustomEvent("long-task",{duration_ms:s,name:n.name||"longtask",page_title:fe(),page_url:L(),session_id:this.sessionId,start_time_ms:Math.round(Number(n.startTime||0)),timestamp:Math.round(Ye()+Number(n.startTime||performance.now()))}))})});t.observe({type:"longtask",buffered:!0}),this.performanceObservers.push(t)}catch{}}observeReplayLayoutShifts(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Number(n.value||0);!Number.isFinite(s)||s<=0||n.hadRecentInput||this.replayRecorder.addCustomEvent("layout-shift",{page_title:fe(),page_url:L(),session_id:this.sessionId,timestamp:Math.round(Ye()+Number(n.startTime||performance.now())),value:Math.round(s*1e4)/1e4})})});t.observe({type:"layout-shift",buffered:!0}),this.performanceObservers.push(t)}catch{}}captureReplayResourceEntries(t,r){this.sessionId&&t.forEach(n=>{if(!ks(n))return;const s=[n.entryType,n.name,Math.round(Number(n.startTime||0)),Math.round(Number(n.duration||0)),String(n.initiatorType||"")].join("|");this.replayResourceKeys.has(s)||(this.replayResourceKeys.add(s),this.replayRecorder.addCustomEvent("resource-entry",{capture_mode:r,duration_ms:Math.round(Number(n.duration||0)),encoded_body_size:Math.round(Number(n.encodedBodySize||0)),entry_type:n.entryType,initiator_type:String(n.initiatorType||""),method:"GET",page_title:fe(),page_url:L(),request_url:n.name,resource_type:As(n),response_end_ms:Math.round(Number(n.responseEnd||0)),session_id:this.sessionId,status:Es(n),timestamp:Rs(n),transfer_size:Math.round(Number(n.transferSize||0)),url:n.name}))})}}const Xe=new Ns,te=(e,t)=>e===void 0?t:e==="true",Be=(e,t)=>{if(!e)return t;const r=Number(e);return Number.isFinite(r)?r:t},ft=e=>{if(!e)return;const t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:void 0},Ms=()=>{if(typeof document>"u")return null;if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.src.includes("flashlog")||r.src.includes("tracker.umd.js")){if(r.src.includes("cxgenie")||r.src.includes("founder-os")||r.src.includes("flow-widget")||r.dataset.enableWidget!==void 0)continue;return r}}return null},Os=async()=>{if(typeof window>"u"||typeof document>"u")return;const e=Ms();if(!e||e.dataset.autoInit!=="true")return;const t=e.dataset.productId||e.dataset.brandId,r=e.dataset.apiKey,n=te(e.dataset.debug,!1);if(t){if(!r){console.error("[FlashlogTracker] Auto init failed: missing data-api-key");return}try{await Xe.init(t,{apiUrl:e.dataset.apiUrl,apiKey:r,debug:n,autoCapture:te(e.dataset.autoCapture,!0),captureNetworkErrors:te(e.dataset.captureNetworkErrors,!0),captureJsErrors:te(e.dataset.captureJsErrors,!0),captureSocketErrors:te(e.dataset.captureSocketErrors,!0),allowNonErrorEvents:te(e.dataset.allowNonErrorEvents,!1),sessionTimeoutMs:Be(e.dataset.sessionTimeoutMs,30*60*1e3),maxActionBufferSize:Be(e.dataset.maxActionBufferSize,50),captureRequestBody:te(e.dataset.captureRequestBody,!0),captureResponseBody:te(e.dataset.captureResponseBody,!0),propagateTraceHeaders:te(e.dataset.propagateTraceHeaders,!1),traceOrigins:ft(e.dataset.traceOrigins),traceHeaderName:e.dataset.traceHeaderName,redactKeys:ft(e.dataset.redactKeys),redactUrlParams:ft(e.dataset.redactUrlParams),enableSessionReplay:te(e.dataset.enableSessionReplay,!0),replayFlushIntervalMs:Be(e.dataset.replayFlushIntervalMs,w.replayFlushIntervalMs),replayMaxSegmentBytes:Be(e.dataset.replayMaxSegmentBytes,w.replayMaxSegmentBytes),replayMaxSegmentEvents:Be(e.dataset.replayMaxSegmentEvents,w.replayMaxSegmentEvents),replayMaskAllInputs:te(e.dataset.replayMaskAllInputs,w.replayMaskAllInputs)}),yt({apiUrl:e.dataset.apiUrl,apiKey:r,brandId:t,source:"script",scriptUrl:e.src,debug:n})}catch(s){console.error("[FlashlogTracker] Auto init failed",s)}}};return typeof window<"u"&&(window.FlashlogBugTracker=Xe,window.Tracker||(window.Tracker=Xe),Os()),Xe});