@flashlog/tracker-sdk 0.1.1 → 0.1.2
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.
- package/dist/tracker.es.js +383 -383
- package/dist/tracker.umd.js +1 -1
- package/package.json +1 -1
package/dist/tracker.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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("http://localhost:3008/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:1e4,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(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:1e4,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
|
|
2
2
|
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
3
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}}/*! *****************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|