@flashlog/tracker-sdk 0.1.0
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/README.md +177 -0
- package/dist/action-buffer.d.ts +12 -0
- package/dist/constants.d.ts +12 -0
- package/dist/device.d.ts +3 -0
- package/dist/error-capture.d.ts +33 -0
- package/dist/index.d.ts +14 -0
- package/dist/installation-ping.d.ts +10 -0
- package/dist/privacy.d.ts +6 -0
- package/dist/replay-recorder.d.ts +64 -0
- package/dist/storage.d.ts +10 -0
- package/dist/trace.d.ts +5 -0
- package/dist/tracker.d.ts +45 -0
- package/dist/tracker.es.js +4247 -0
- package/dist/tracker.umd.js +27 -0
- package/dist/types.d.ts +96 -0
- package/package.json +36 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
(function(se,Ee){typeof exports=="object"&&typeof module<"u"?Ee(exports):typeof define=="function"&&define.amd?define(["exports"],Ee):(se=typeof globalThis<"u"?globalThis:se||self,Ee(se.FlashlogBugTracker={}))})(this,function(se){"use strict";const Ee=e=>{const t=e.trim();return t.length>0?t:null},kr=()=>{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},Rr=()=>{const e=Ee("https://api.flashlog.app/api");if(e)return e;const t=kr();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"],Tr=["password","passwd","authorization","secret","token","jwt","cookie","session","csrf","passcode","otp","apiKey","accessToken","refreshToken","clientSecret","privateKey","authCode","verificationCode","sessionToken","sessionCookie","sessionSecret"],v={apiUrl:Rr(),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:Tr,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"},Er=e=>{if(e.scriptUrl)return e.scriptUrl;if(e.source==="package")return"package:@flashlog/tracker-sdk"},yt=async e=>{if(typeof window>"u"||typeof document>"u")return;const t=Number(e.brandId);if(!Number.isFinite(t)||t<=0)return;const r=`${(e.apiUrl||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:Er(e)})});!n.ok&&e.debug&&console.warn("[FlashlogTracker] Installation ping failed",{status:n.status})}catch(n){e.debug&&console.warn("[FlashlogTracker] Installation ping error",n)}},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+/):[]},_r=(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("")||_r(r,i)})},Ct=(e,t)=>e?ze(e).join("")===t:!1,Nr=e=>e?ze(e).includes("url"):!1,Mr=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}),Or=(e,t,r)=>{try{const n=e.startsWith("/"),s=new URL(e,"https://flashlog.local");let i=!1;return s.searchParams.forEach((a,o)=>{_e(o,t.redactUrlParams)&&(s.searchParams.set(o,ce),i=!0)}),i?(r.redactedFieldsCount+=1,n?`${s.pathname}${s.search}${s.hash}`:s.toString()):e}catch{return e}},Lr=(e,t,r,n,s=new WeakSet)=>{if(Nr(n))return Or(e,t,r);const i=Mr(e);if(i!==null){const a=Ge(i,t,r,n,s);return JSON.stringify(a)}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 Lr(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,[a,o])=>(i[a]=Ge(o,t,r,a,s),i),{})}finally{s.delete(e)}},Fr=(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"}}}},xr=()=>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 o=`${i>=2?r[i-2]:""} ${s}`;return _e(s,We)||_e(o,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(" > ")},Br=e=>[e.getAttribute("name"),e.getAttribute("id"),e.getAttribute("aria-label"),e.getAttribute("placeholder"),e.getAttribute("autocomplete"),e.getAttribute("type")].filter(Boolean).join(" "),Ur=e=>{const t=Br(e);return(e.getAttribute("type")||"").toLowerCase()==="password"||_e(t,We)},ge=(e,t)=>{const r=e==null?void 0:e.trim();if(r)return Ur(t)?ce:Qe(r)},Wr=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(a=>ge(a.value,e)),s=r.map(a=>ge(a.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 zr{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 a=i.target;this.add("CLICK",{tagName:a==null?void 0:a.tagName,text:Qe(a==null?void 0:a.innerText),selector:$e(a)})},r=i=>{const a=i.target;this.add("INPUT_CHANGE",Wr(a))},n=i=>{const a=i.target;this.add("FORM_SUBMIT",{tagName:a==null?void 0:a.tagName,selector:$e(a)})},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:xr()}),this.actions.length>this.maxSize&&(this.actions=this.actions.slice(-this.maxSize))}getAll(){return[...this.actions]}clear(){this.actions=[]}}const Gr=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"}},Kr=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"},Vr=()=>{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=Gr(r);return{os_name:Kr(r),device_type:Vr(),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,Rt=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=Rt(16),t=Rt(8);return{trace_id:e,span_id:t,traceparent:`00-${e}-${t}-01`}},Pr=(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}},Zr="[omitted: non-json body]";class Hr{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",a=s instanceof Error?s.stack:"";this.hooks.onUnhandledRejection({message:i,stack:a||"",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:Zr})}attachTraceHeadersToFetchRequest(t,r,n,s){if(!Tt(n,this.config))return{input:t,init:r};if(t instanceof Request){const a=new Headers(t.headers);return new Headers(r==null?void 0:r.headers).forEach((c,d)=>{a.set(d,c)}),Object.entries(s).forEach(([c,d])=>{a.set(c,d)}),{input:new Request(t,{...r,headers:a})}}const i=new Headers(r==null?void 0:r.headers);return Object.entries(s).forEach(([a,o])=>{i.set(a,o)}),{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(),a=(s==null?void 0:s.method)||"GET",o=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t.shouldIgnoreUrl(o))return t.originalFetch.call(window,n,s);const c=t.safeBodyPreview(s==null?void 0:s.body),d=Ke(),l=tt(d,t.config.traceHeaderName),u=t.attachTraceHeadersToFetchRequest(n,s,o,l);try{const h=await t.originalFetch.call(window,u.input,u.init),f=Date.now()-i;if((h.ok||t.shouldIgnoreStatus(h.status))&&t.hooks.onNetworkActivity({type:"fetch",url:o,method:a.toUpperCase(),status:h.status,statusText:h.statusText,duration_ms:f,trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),!h.ok&&h.status>=400&&!t.shouldIgnoreStatus(h.status)){let p;try{p=await h.clone().text()}catch{p="[unreadable]"}t.hooks.onNetworkError({type:"fetch",url:o,method:a.toUpperCase(),status:h.status,statusText:h.statusText,duration_ms:f,request_body:t.truncate(c),response_body:t.truncate(p),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()})}return h}catch(h){throw t.hooks.onNetworkError({type:"fetch",url:o,method:a.toUpperCase(),status:0,statusText:"NETWORK_ERROR",duration_ms:Date.now()-i,request_body:t.truncate(c),response_body:t.truncate(h instanceof Error?h.message:String(h)),trace_id:d.trace_id,span_id:d.span_id,traceparent:d.traceparent,timestamp:Date.now()}),h}}}interceptXhr(){const t=this;this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=function(n,s,i,a,o){const c=s instanceof URL?s.toString():String(s);return this.__flashlog_meta={method:(n||"GET").toUpperCase(),url:c},t.originalXhrOpen.call(this,n,s,i??!0,a??null,o??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 a=Date.now(),o=t.safeBodyPreview(n),c=Ke(),d=tt(c,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()-a,trace_id:c.trace_id,span_id:c.span_id,traceparent:c.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()-a,request_body:t.truncate(o),response_body:t.truncate(s.responseText||""),trace_id:c.trace_id,span_id:c.span_id,traceparent:c.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()-a,request_body:t.truncate(o),response_body:"XHR network error",trace_id:c.trace_id,span_id:c.span_id,traceparent:c.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,a){const o=i instanceof URL?i.toString():String(i),c=a!==void 0?new r(i,a):new r(i);return t.shouldIgnoreUrl(o)||(t.socketMeta.set(c,{url:o,createdAt:Date.now(),openedAt:null}),c.addEventListener("open",()=>{const d=t.socketMeta.get(c);d&&(d.openedAt=Date.now())}),c.addEventListener("error",()=>{const d=t.socketMeta.get(c),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)||o,method:"CONNECT",status:0,statusText:"WEBSOCKET_ERROR",duration_ms:Date.now()-l,timestamp:Date.now()})}),c.addEventListener("close",d=>{if(d.code===1e3||d.code===1001)return;const l=t.socketMeta.get(c),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)||o,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()})})),c};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 Jr(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?Jr(Array.from(t).map(Et).join("")):null}catch{return null}}function Et(e){var t=e.cssText;if(qr(e))try{t=rt(e.styleSheet)||t}catch{}return t}function qr(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 Yr(){return new _t}function nt(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,s=e.value,i=e.maskInputFn,a=s||"";return(t[r.toLowerCase()]||t[n])&&(i?a=i(a):a="*".repeat(a.length)),a}var Nt="__rrweb_original__";function Xr(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,a=Nt in i?i[Nt]:i,o=new Uint32Array(a.call(t,n,s,Math.min(r,e.width-n),Math.min(r,e.height-s)).data.buffer);if(o.some(function(c){return c!==0}))return!1}return!0}var Qr=1,$r=new RegExp("[^a-z0-9-_:]"),Oe=-2;function Mt(){return Qr++}function en(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return $r.test(t)?"div":t}function tn(e){return e.cssRules?Array.from(e.cssRules).map(function(t){return t.cssText||""}).join(""):""}function rn(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,nn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,sn=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,an=/^(data:)([^,]*),(.*)/i;function Ve(e,t){return(e||"").replace(nn,function(r,n,s,i,a,o){var c=s||a||o,d=n||i||"";if(!c)return r;if(!sn.test(c)||an.test(c))return"url(".concat(d).concat(c).concat(d,")");if(c[0]==="/")return"url(".concat(d).concat(rn(t)+c).concat(d,")");var l=t.split("/"),u=c.split("/");l.pop();for(var h=0,f=u;h<f.length;h++){var p=f[h];p!=="."&&(p===".."?l.pop():l.push(p))}return"url(".concat(d).concat(l.join("/")).concat(d,")")})}var on=/^[^ \t\n\r\u000c]+/,cn=/^[, \t\n\r\u000c]+/;function dn(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(cn),!(r>=t.length);){var i=n(on);if(i.slice(-1)===",")i=Ie(e,i.substring(0,i.length-1)),s.push(i);else{var a="";i=Ie(e,i);for(var o=!1;;){var c=t.charAt(r);if(c===""){s.push((i+a).trim());break}else if(o)c===")"&&(o=!1);else if(c===","){r+=1,s.push((i+a).trim());break}else c==="("&&(o=!0);a+=c,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 ln(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?dn(e,n):r==="style"&&n?Ve(n,st()):t==="object"&&r==="data"&&n?Ie(e,n):n}function un(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 a=setTimeout(function(){s||(t(),s=!0)},r);e.addEventListener("load",function(){clearTimeout(a),s=!0,t()});return}var o="about:blank";if(n.location.href!==o||e.src===o||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function hn(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 fn(e,t){var r=t.doc,n=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,o=t.maskTextSelector,c=t.inlineStylesheet,d=t.maskInputOptions,l=d===void 0?{}:d,u=t.maskTextFn,h=t.maskInputFn,f=t.dataURLOptions,p=f===void 0?{}:f,y=t.inlineImages,S=t.recordCanvas,C=t.keepIframeSrcFn,m=t.newlyAddedElement,g=m===void 0?!1:m,k=mn(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 yn(e,{doc:r,blockClass:s,blockSelector:i,inlineStylesheet:c,maskInputOptions:l,maskInputFn:h,dataURLOptions:p,inlineImages:y,recordCanvas:S,keepIframeSrcFn:C,newlyAddedElement:g,rootId:k});case e.TEXT_NODE:return gn(e,{maskTextClass:a,maskTextSelector:o,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 mn(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function gn(e,t){var r,n=t.maskTextClass,s=t.maskTextSelector,i=t.maskTextFn,a=t.rootId,o=e.parentNode&&e.parentNode.tagName,c=e.textContent,d=o==="STYLE"?!0:void 0,l=o==="SCRIPT"?!0:void 0;if(d&&c){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(c=tn(e.parentNode.sheet))}catch(u){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u),e)}c=Ve(c,st())}return l&&(c="SCRIPT_PLACEHOLDER"),!d&&!l&&c&&Ft(e,n,s)&&(c=i?i(c):c.replace(/[\S]/g,"*")),{type:F.Text,textContent:c||"",isStyle:d,rootId:a}}function yn(e,t){for(var r=t.doc,n=t.blockClass,s=t.blockSelector,i=t.inlineStylesheet,a=t.maskInputOptions,o=a===void 0?{}:a,c=t.maskInputFn,d=t.dataURLOptions,l=d===void 0?{}:d,u=t.inlineImages,h=t.recordCanvas,f=t.keepIframeSrcFn,p=t.newlyAddedElement,y=p===void 0?!1:p,S=t.rootId,C=un(e,n,s),m=en(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 D=Array.from(r.styleSheets).find(function(q){return q.href===e.href}),T=null;D&&(T=rt(D)),T&&(delete g.rel,delete g.href,g._cssText=Ve(T,D.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:o,maskInputFn:c}):j&&(g.checked=j)}if(m==="option"&&(e.selected&&!o.select?g.selected=!0:delete g.selected),m==="canvas"&&h){if(e.__context==="2d")Xr(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(),oe=ie.width,V=ie.height;g={class:g.class,rr_width:"".concat(oe,"px"),rr_height:"".concat(V,"px")}}return m==="iframe"&&!f(g.src)&&(e.contentDocument||(g.rr_src=g.src),delete g.src),{type:F.Element,tagName:m,attributes:g,childNodes:[],isSVG:ln(e)||void 0,needBlock:C,rootId:S}}function R(e){return e===void 0?"":e.toLowerCase()}function In(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"&&(R(e.attributes.name).match(/^msapplication-tile(image|color)$/)||R(e.attributes.name)==="application-name"||R(e.attributes.rel)==="icon"||R(e.attributes.rel)==="apple-touch-icon"||R(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&R(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(R(e.attributes.property).match(/^(og|twitter|fb):/)||R(e.attributes.name).match(/^(og|twitter):/)||R(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(R(e.attributes.name)==="robots"||R(e.attributes.name)==="googlebot"||R(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(R(e.attributes.name)==="author"||R(e.attributes.name)==="generator"||R(e.attributes.name)==="framework"||R(e.attributes.name)==="publisher"||R(e.attributes.name)==="progid"||R(e.attributes.property).match(/^article:/)||R(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(R(e.attributes.name)==="google-site-verification"||R(e.attributes.name)==="yandex-verification"||R(e.attributes.name)==="csrf-token"||R(e.attributes.name)==="p:domain_verify"||R(e.attributes.name)==="verify-v1"||R(e.attributes.name)==="verification"||R(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,a=t.maskTextClass,o=t.maskTextSelector,c=t.skipChild,d=c===void 0?!1:c,l=t.inlineStylesheet,u=l===void 0?!0:l,h=t.maskInputOptions,f=h===void 0?{}:h,p=t.maskTextFn,y=t.maskInputFn,S=t.slimDOMOptions,C=t.dataURLOptions,m=C===void 0?{}:C,g=t.inlineImages,k=g===void 0?!1:g,z=t.recordCanvas,x=z===void 0?!1:z,D=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,oe=t.preserveWhiteSpace,V=oe===void 0?!0:oe,q=fn(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:o,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,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):In(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;D&&D(e);var ne=!d;if(M.type===F.Element){ne=ne&&!M.needBlock,delete M.needBlock;var ae=e.shadowRoot;ae&&Me(ae)&&(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:a,maskTextSelector:o,skipChild:d,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:T,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J},I=0,G=Array.from(e.childNodes);I<G.length;I++){var P=G[I],E=Ce(P,Te);E&&M.childNodes.push(E)}if(jr(e)&&e.shadowRoot)for(var Y=0,A=Array.from(e.shadowRoot.childNodes);Y<A.length;Y++){var P=A[Y],E=Ce(P,Te);E&&(Me(e.shadowRoot)&&(E.isShadow=!0),M.childNodes.push(E))}}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:a,maskTextSelector:o,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:D,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"&&hn(e,function(){if(X){var Z=Ce(e,{doc:r,mirror:n,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:o,skipChild:!1,inlineStylesheet:u,maskInputOptions:f,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:m,inlineImages:k,recordCanvas:x,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:T,iframeLoadTimeout:j,onStylesheetLoad:X,stylesheetLoadTimeout:$,keepIframeSrcFn:J});Z&&X(e,Z)}},$),M}function Cn(e,t){var r=t||{},n=r.mirror,s=n===void 0?new _t:n,i=r.blockClass,a=i===void 0?"rr-block":i,o=r.blockSelector,c=o===void 0?null:o,d=r.maskTextClass,l=d===void 0?"rr-mask":d,u=r.maskTextSelector,h=u===void 0?null:u,f=r.inlineStylesheet,p=f===void 0?!0:f,y=r.inlineImages,S=y===void 0?!1:y,C=r.recordCanvas,m=C===void 0?!1:C,g=r.maskAllInputs,k=g===void 0?!1:g,z=r.maskTextFn,x=r.maskInputFn,D=r.slimDOM,T=D===void 0?!1:D,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,oe=k===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:k===!1?{password:!0}:k,V=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:a,blockSelector:c,maskTextClass:l,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:oe,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
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
3
|
+
or you can use record.mirror to access the mirror instance during recording.`;let xt={map:{},getId(){return console.error(Se),-1},getNode(){return console.error(Se),null},removeNodeFromMap(){console.error(Se)},has(){return console.error(Se),!1},reset(){console.error(Se)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(xt=new Proxy(xt,{get(e,t,r){return t==="map"&&console.error(Se),Reflect.get(e,t,r)}}));function Le(e,t,r={}){let n=null,s=0;return function(...i){const a=Date.now();!s&&r.leading===!1&&(s=a);const o=t-(a-s),c=this;o<=0||o>t?(n&&(clearTimeout(n),n=null),s=a,e.apply(c,i)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{s=r.leading===!1?0:Date.now(),n=null,e.apply(c,i)},o))}}function Ze(e,t,r,n,s=window){const i=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>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 Dt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Bt(){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 Sn(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 bn(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 vn{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||{}),at=(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))(at||{}),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 wn{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 An{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 wn,n=o=>{let c=o,d=Oe;for(;d===Oe;)c=c&&c.nextSibling,d=c&&this.mirror.getId(c);return d},s=o=>{var c,d,l,u;let h=null;((d=(c=o.getRootNode)===null||c===void 0?void 0:c.call(o))===null||d===void 0?void 0:d.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(h=o.getRootNode().host);let f=h;for(;((u=(l=f==null?void 0:f.getRootNode)===null||l===void 0?void 0:l.call(f))===null||u===void 0?void 0:u.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&f.getRootNode().host;)f=f.getRootNode().host;const p=!this.doc.contains(o)&&(!f||!this.doc.contains(f));if(!o.parentNode||p)return;const y=Ne(o.parentNode)?this.mirror.getId(h):this.mirror.getId(o.parentNode),S=n(o);if(y===-1||S===-1)return r.addNode(o);const C=Ce(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:m=>{zt(m,this.mirror)&&this.iframeManager.addIframe(m),Gt(m,this.mirror)&&this.stylesheetManager.trackLinkElement(m),Kt(o)&&this.shadowDomManager.addShadowRoot(o.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 o of Array.from(this.movedSet.values()))Zt(this.removes,o,this.mirror)&&!this.movedSet.has(o.parentNode)||s(o);for(const o of Array.from(this.addedSet.values()))!jt(this.droppedSet,o)&&!Zt(this.removes,o,this.mirror)||jt(this.movedSet,o)?s(o):this.droppedSet.add(o);let i=null;for(;r.length;){let o=null;if(i){const c=this.mirror.getId(i.value.parentNode),d=n(i.value);c!==-1&&d!==-1&&(o=i)}if(!o)for(let c=r.length-1;c>=0;c--){const d=r.get(c);if(d){const l=this.mirror.getId(d.value.parentNode);if(n(d.value)===-1)continue;if(l!==-1){o=d;break}else{const h=d.value;if(h.parentNode&&h.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const f=h.parentNode.host;if(this.mirror.getId(f)!==-1){o=d;break}}}}}if(!o){for(;r.head;)r.removeNode(r.head.value);break}i=o.previous,r.removeNode(o.value),s(o.value)}const a={texts:this.texts.map(o=>({id:this.mirror.getId(o.node),value:o.value})).filter(o=>this.mirror.has(o.id)),attributes:this.attributes.map(o=>({id:this.mirror.getId(o.node),attributes:o.attributes})).filter(o=>this.mirror.has(o.id)),removes:this.removes,adds:t};!a.texts.length&&!a.attributes.length&&!a.removes.length&&!a.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(a))},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 a=s.attributes.style;for(const o of Array.from(r.style)){const c=r.style.getPropertyValue(o),d=r.style.getPropertyPriority(o);(c!==i.style.getPropertyValue(o)||d!==i.style.getPropertyPriority(o))&&(d===""?a[o]=c:a[o]=[c,d])}for(const o of Array.from(i.style))r.style.getPropertyValue(o)===""&&(a[o]=!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)||!Sn(r,this.mirror)||(this.addedSet.has(r)?(ot(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)]?ot(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 ot(e,t){e.delete(t),t.childNodes.forEach(r=>ot(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 pe=[],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 An;pe.push(s),s.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const a=(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");a&&window[a]&&(i=window[a]);const o=new i(s.processMutations.bind(s));return o.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),o}function kn({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 a=[],o;const c=Le(u=>{const h=Date.now()-o;e(a.map(f=>(f.timeOffset-=h,f)),u),a=[],o=null},i),d=Le(u=>{const h=Fe(u),{clientX:f,clientY:p}=Wt(u)?u.changedTouches[0]:u;o||(o=Date.now()),a.push({x:f,y:p,id:n.getId(h),timeOffset:Date.now()-o}),c(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 Rn({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,o=[],c=d=>l=>{const u=Fe(l);if(W(u,n,s,!0))return;const h=Wt(l)?l.changedTouches[0]:l;if(!h)return;const f=r.getId(u),{clientX:p,clientY:y}=h;e({type:at[d],id:f,x:p,y})};return Object.keys(at).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&a[d]!==!1).forEach(d=>{const l=d.toLowerCase(),u=c(d);o.push(U(l,u,t))}),()=>{o.forEach(d=>d())}}function er({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){const a=Le(o=>{const c=Fe(o);if(!c||W(c,n,s,!0))return;const d=r.getId(c);if(c===t){const l=t.scrollingElement||t.documentElement;e({id:d,x:l.scrollLeft,y:l.scrollTop})}else e({id:d,x:c.scrollLeft,y:c.scrollTop})},i.scroll||100);return U("scroll",a,t)}function Tn({viewportResizeCb:e}){let t=-1,r=-1;const n=Le(()=>{const s=Dt(),i=Bt();(t!==s||r!==i)&&(e({width:Number(i),height:Number(s)}),t=s,r=i)},200);return U("resize",n,window)}function tr(e,t){const r=Object.assign({},e);return t||delete r.userTriggered,r}const En=["INPUT","TEXTAREA","SELECT"],rr=new WeakMap;function _n({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,ignoreClass:i,maskInputOptions:a,maskInputFn:o,sampling:c,userTriggeredOnInput:d}){function l(C){let m=Fe(C);const g=C.isTrusted;if(m&&m.tagName==="OPTION"&&(m=m.parentElement),!m||!m.tagName||En.indexOf(m.tagName)<0||W(m,n,s,!0))return;const k=m.type;if(m.classList.contains(i))return;let z=m.value,x=!1;k==="radio"||k==="checkbox"?x=m.checked:(a[m.tagName.toLowerCase()]||a[k])&&(z=nt({maskInputOptions:a,tagName:m.tagName,type:k,value:z,maskInputFn:o})),u(m,tr({text:z,isChecked:x,userTriggered:g},d));const D=m.name;k==="radio"&&D&&x&&t.querySelectorAll(`input[type="radio"][name="${D}"]`).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=(c.input==="last"?["change"]:["input","change"]).map(C=>U(C,l,t)),p=t.defaultView;if(!p)return()=>{f.forEach(C=>C())};const y=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),S=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&f.push(...S.map(C=>Ze(C[0],C[1],{set(){l({target:this})}},!1,p))),()=>{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 a=Array.from(n.parentRule.cssRules).indexOf(n);s.unshift(a)}else if(n.parentStyleSheet){const a=Array.from(n.parentStyleSheet.cssRules).indexOf(n);s.unshift(a)}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 Nn({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){const s=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(l,u){const{id:h,styleId:f}=de(this,t,r.styleMirror);return(h&&h!==-1||f&&f!==-1)&&e({id:h,styleId:f,adds:[{rule:l,index:u}]}),s.apply(this,[l,u])};const i=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(l){const{id:u,styleId:h}=de(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,removes:[{index:l}]}),i.apply(this,[l])};let a;n.CSSStyleSheet.prototype.replace&&(a=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(l){const{id:u,styleId:h}=de(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replace:l}),a.apply(this,[l])});let o;n.CSSStyleSheet.prototype.replaceSync&&(o=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(l){const{id:u,styleId:h}=de(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replaceSync:l}),o.apply(this,[l])});const c={};qt?c.CSSGroupingRule=n.CSSGroupingRule:(Yt&&(c.CSSMediaRule=n.CSSMediaRule),Qt&&(c.CSSConditionRule=n.CSSConditionRule),Xt&&(c.CSSSupportsRule=n.CSSSupportsRule));const d={};return Object.entries(c).forEach(([l,u])=>{d[l]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=function(h,f){const{id:p,styleId:y}=de(this.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||y&&y!==-1)&&e({id:p,styleId:y,adds:[{rule:h,index:[...He(this),f||0]}]}),d[l].insertRule.apply(this,[h,f])},u.prototype.deleteRule=function(h){const{id:f,styleId:p}=de(this.parentStyleSheet,t,r.styleMirror);return(f&&f!==-1||p&&p!==-1)&&e({id:f,styleId:p,removes:[{index:[...He(this),h]}]}),d[l].deleteRule.apply(this,[h])}}),()=>{n.CSSStyleSheet.prototype.insertRule=s,n.CSSStyleSheet.prototype.deleteRule=i,a&&(n.CSSStyleSheet.prototype.replace=a),o&&(n.CSSStyleSheet.prototype.replaceSync=o),Object.entries(c).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 a=null;r.nodeName==="#document"?a=e.getId(r):a=e.getId(r.host);const o=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,c=Object.getOwnPropertyDescriptor(o==null?void 0:o.prototype,"adoptedStyleSheets");return a===null||a===-1||!o||!c?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var d;return(d=c.get)===null||d===void 0?void 0:d.call(this)},set(d){var l;const u=(l=c.set)===null||l===void 0?void 0:l.call(this,d);if(a!==null&&a!==-1)try{t.adoptStyleSheets(d,a)}catch{}return u}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})}function Mn({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:s}){const i=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=function(o,c,d){var l;if(r.has(o))return i.apply(this,[o,c,d]);const{id:u,styleId:h}=de((l=this.parentRule)===null||l===void 0?void 0:l.parentStyleSheet,t,n.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,set:{property:o,value:c,priority:d},index:He(this.parentRule)}),i.apply(this,[o,c,d])};const a=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=function(o){var c;if(r.has(o))return a.apply(this,[o]);const{id:d,styleId:l}=de((c=this.parentRule)===null||c===void 0?void 0:c.parentStyleSheet,t,n.styleMirror);return(d&&d!==-1||l&&l!==-1)&&e({id:d,styleId:l,remove:{property:o},index:He(this.parentRule)}),a.apply(this,[o])},()=>{s.CSSStyleDeclaration.prototype.setProperty=i,s.CSSStyleDeclaration.prototype.removeProperty=a}}function On({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:s}){const i=o=>Le(c=>{const d=Fe(c);if(!d||W(d,t,r,!0))return;const{currentTime:l,volume:u,muted:h,playbackRate:f}=d;e({type:o,id:n.getId(d),currentTime:l,volume:u,muted:h,playbackRate:f})},s.media||500),a=[U("play",i(0)),U("pause",i(1)),U("seeked",i(2)),U("volumechange",i(3)),U("ratechange",i(4))];return()=>{a.forEach(o=>o())}}function Ln({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],s=new WeakMap,i=r.FontFace;r.FontFace=function(c,d,l){const u=new i(c,d,l);return s.set(u,{family:c,buffer:typeof d!="string",descriptors:l,fontSource:typeof d=="string"?d:JSON.stringify(Array.from(new Uint8Array(d)))}),u};const a=ue(t.fonts,"add",function(o){return function(c){return setTimeout(()=>{const d=s.get(c);d&&(e(d),s.delete(c))},0),o.apply(this,[c])}});return n.push(()=>{r.FontFace=i}),n.push(a),()=>{n.forEach(o=>o())}}function Fn(e){const{doc:t,mirror:r,blockClass:n,blockSelector:s,selectionCb:i}=e;let a=!0;const o=()=>{const c=t.getSelection();if(!c||a&&(c!=null&&c.isCollapsed))return;a=c.isCollapsed||!1;const d=[],l=c.rangeCount||0;for(let u=0;u<l;u++){const h=c.getRangeAt(u),{startContainer:f,startOffset:p,endContainer:y,endOffset:S}=h;W(f,n,s,!0)||W(y,n,s,!0)||d.push({start:r.getId(f),startOffset:p,end:r.getId(y),endOffset:S})}i({ranges:d})};return o(),U("selectionchange",o)}function xn(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:s,scrollCb:i,viewportResizeCb:a,inputCb:o,mediaInteractionCb:c,styleSheetRuleCb:d,styleDeclarationCb:l,canvasMutationCb:u,fontCb:h,selectionCb:f}=e;e.mutationCb=(...p)=>{t.mutation&&t.mutation(...p),r(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),n(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),s(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),i(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),a(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),o(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),c(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),d(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),l(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),u(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),h(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),f(...p)}}function Dn(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};xn(e,t);const n=$t(e,e.doc),s=kn(e),i=Rn(e),a=er(e),o=Tn(e),c=_n(e),d=On(e),l=Nn(e,{win:r}),u=nr(e,e.doc),h=Mn(e,{win:r}),f=e.collectFonts?Ln(e):()=>{},p=Fn(e),y=[];for(const S of e.plugins)y.push(S.observer(S.callback,r,S.options));return()=>{pe.forEach(S=>S.reset()),n.disconnect(),s(),i(),a(),o(),c(),d(),l(),u(),h(),f(),p(),y.forEach(S=>S())}}class sr{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,s){const i=n||this.getIdToRemoteIdMap(t),a=s||this.getRemoteIdToIdMap(t);let o=i.get(r);return o||(o=this.generateIdFn(),i.set(r,o),a.set(o,r)),o}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 Bn{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 Un{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
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */function Wn(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r}function zn(e,t,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(l){try{d(n.next(l))}catch(u){a(u)}}function c(l){try{d(n.throw(l))}catch(u){a(u)}}function d(l){l.done?i(l.value):s(l.value).then(o,c)}d((n=n.apply(e,[])).next())})}for(var ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gn=typeof Uint8Array>"u"?[]:new Uint8Array(256),je=0;je<ve.length;je++)Gn[ve.charCodeAt(je)]=je;var Kn=function(e){var t=new Uint8Array(e),r,n=t.length,s="";for(r=0;r<n;r+=3)s+=ve[t[r]>>2],s+=ve[(t[r]&3)<<4|t[r+1]>>4],s+=ve[(t[r+1]&15)<<2|t[r+2]>>6],s+=ve[t[r+2]&63];return n%3===2?s=s.substring(0,s.length-1)+"=":n%3===1&&(s=s.substring(0,s.length-2)+"=="),s};const ir=new Map;function Vn(e,t){let r=ir.get(e);return r||(r=new Map,ir.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const ar=(e,t,r)=>{if(!e||!(cr(e,t)||typeof e=="object"))return;const n=e.constructor.name,s=Vn(r,n);let i=s.indexOf(e);return i===-1&&(i=s.length,s.push(e)),i};function Je(e,t,r){if(e instanceof Array)return e.map(n=>Je(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,s=Kn(e);return{rr_type:n,base64:s}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Je(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:s}=e;return{rr_type:n,src:s}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",s=e.toDataURL();return{rr_type:n,src:s}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Je(e.data,t,r),e.width,e.height]};if(cr(e,t)||typeof e=="object"){const n=e.constructor.name,s=ar(e,t,r);return{rr_type:n,index:s}}}}return e}const or=(e,t,r)=>[...e].map(n=>Je(n,t,r)),cr=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);function Pn(e,t,r,n){const s=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of i)try{if(typeof t.CanvasRenderingContext2D.prototype[a]!="function")continue;const o=ue(t.CanvasRenderingContext2D.prototype,a,function(c){return function(...d){return W(this.canvas,r,n,!0)||setTimeout(()=>{const l=or([...d],t,this);e(this.canvas,{type:be["2D"],property:a,args:l})},0),c.apply(this,d)}});s.push(o)}catch{const c=Ze(t.CanvasRenderingContext2D.prototype,a,{set(d){e(this.canvas,{type:be["2D"],property:a,args:[d],setter:!0})}});s.push(c)}return()=>{s.forEach(a=>a())}}function dr(e,t,r){const n=[];try{const s=ue(e.HTMLCanvasElement.prototype,"getContext",function(i){return function(a,...o){return W(this,t,r,!0)||"__context"in this||(this.__context=a),i.apply(this,[a,...o])}});n.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(s=>s())}}function lr(e,t,r,n,s,i,a){const o=[],c=Object.getOwnPropertyNames(e);for(const d of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))try{if(typeof e[d]!="function")continue;const l=ue(e,d,function(u){return function(...h){const f=u.apply(this,h);if(ar(f,a,this),!W(this.canvas,n,s,!0)){const p=or([...h],a,this),y={type:t,property:d,args:p};r(this.canvas,y)}return f}});o.push(l)}catch{const u=Ze(e,d,{set(h){r(this.canvas,{type:t,property:d,args:[h],setter:!0})}});o.push(u)}return o}function Zn(e,t,r,n,s){const i=[];return i.push(...lr(t.WebGLRenderingContext.prototype,be.WebGL,e,r,n,s,t)),typeof t.WebGL2RenderingContext<"u"&&i.push(...lr(t.WebGL2RenderingContext.prototype,be.WebGL2,e,r,n,s,t)),()=>{i.forEach(a=>a())}}var ur=null;try{var Hn=typeof module<"u"&&typeof module.require=="function"&&module.require("worker_threads")||typeof __non_webpack_require__=="function"&&__non_webpack_require__("worker_threads")||typeof require=="function"&&require("worker_threads");ur=Hn.Worker}catch{}function jn(e,t){return Buffer.from(e,"base64").toString("utf8")}function Jn(e,t,r){var n=jn(e),s=n.indexOf(`
|
|
17
|
+
`,10)+1,i=n.substring(s)+"";return function(o){return new ur(i,Object.assign({},o,{eval:!0}))}}function qn(e,t){var r=atob(e);return r}function Yn(e,t,r){var n=qn(e),s=n.indexOf(`
|
|
18
|
+
`,10)+1,i=n.substring(s)+"",a=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(a)}function Xn(e,t,r){var n;return function(i){return n=n||Yn(e),new Worker(n,i)}}var Qn=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";function $n(){return Qn}function es(e,t,r){return $n()?Jn(e):Xn(e)}var ts=es("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=");class rs{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(c,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(c)||this.pendingCanvasMutations.set(c,[]),this.pendingCanvasMutations.get(c).push(d)};const{sampling:r="all",win:n,blockClass:s,blockSelector:i,recordCanvas:a,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,s,i),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,s,i){const a=dr(r,n,s),o=new Map,c=new ts;c.onmessage=p=>{const{id:y}=p.data;if(o.set(y,!1),!("base64"in p.data))return;const{base64:S,type:C,width:m,height:g}=p.data;this.mutationCb({id:y,type:be["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:S}],type:C}]},0,0]}]})};const d=1e3/t;let l=0,u;const h=()=>{const p=[];return r.document.querySelectorAll("canvas").forEach(y=>{W(y,n,s,!0)||p.push(y)}),p},f=p=>{if(l&&p-l<d){u=requestAnimationFrame(f);return}l=p,h().forEach(y=>zn(this,void 0,void 0,function*(){var S;const C=this.mirror.getId(y);if(o.get(C))return;if(o.set(C,!0),["webgl","webgl2"].includes(y.__context)){const g=y.getContext(y.__context);((S=g==null?void 0:g.getContextAttributes())===null||S===void 0?void 0:S.preserveDrawingBuffer)===!1&&(g==null||g.clear(g.COLOR_BUFFER_BIT))}const m=yield createImageBitmap(y);c.postMessage({id:C,bitmap:m,width:y.width,height:y.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=dr(t,r,n),i=Pn(this.processMutation.bind(this),t,r,n),a=Zn(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{s(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const s=n.map(a=>Wn(a,["type"])),{type:i}=n[0];this.mutationCb({id:r,type:i,commands:s}),this.pendingCanvasMutations.delete(t)}}class ns{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new vn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},s=[];for(const i of t){let a;if(this.styleMirror.has(i))a=this.styleMirror.getId(i);else{a=this.styleMirror.add(i);const o=Array.from(i.rules||CSSRule);s.push({styleId:a,rules:o.map((c,d)=>({rule:Et(c),index:d}))})}n.styleIds.push(a)}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function O(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let _,qe,ct,Ye=!1;const ee=Yr();function we(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:o="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:l,maskInputOptions:u,slimDOMOptions:h,maskInputFn:f,maskTextFn:p,hooks:y,packFn:S,sampling:C={},dataURLOptions:m={},mousemoveWait:g,recordCanvas:k=!1,recordCrossOriginIframes:z=!1,userTriggeredOnInput:x=!1,collectFonts:D=!1,inlineImages:T=!1,plugins:H,keepIframeSrcFn:j=()=>!1,ignoreCSSAttributes:X=new Set([])}=e,Q=z?window.parent===window:!0;let $=!1;if(!Q)try{window.parent.document,$=!1}catch{$=!0}if(Q&&!t)throw new Error("emit function is required");g!==void 0&&C.mousemove===void 0&&(C.mousemove=g),ee.reset();const L=l===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u!==void 0?u:{password:!0},J=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};bn();let re,ie=0;const oe=I=>{for(const G of H||[])G.eventProcessor&&(I=G.eventProcessor(I));return S&&(I=S(I)),I};_=(I,G)=>{var P;if(!((P=pe[0])===null||P===void 0)&&P.isFrozen()&&I.type!==w.FullSnapshot&&!(I.type===w.IncrementalSnapshot&&I.data.source===b.Mutation)&&pe.forEach(E=>E.unfreeze()),Q)t==null||t(oe(I),G);else if($){const E={type:"rrweb",event:oe(I),isCheckout:G};window.parent.postMessage(E,"*")}if(I.type===w.FullSnapshot)re=I,ie=0;else if(I.type===w.IncrementalSnapshot){if(I.data.source===b.Mutation&&I.data.isAttachIframe)return;ie++;const E=n&&ie>=n,Y=r&&I.timestamp-re.timestamp>r;(E||Y)&&qe(!0)}};const V=I=>{_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Mutation},I)}))},q=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Scroll},I)})),le=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.CanvasMutation},I)})),M=I=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.AdoptedStyleSheet},I)})),ne=new ns({mutationCb:V,adoptedStyleSheetCb:M}),ae=new Bn({mirror:ee,mutationCb:V,stylesheetManager:ne,recordCrossOriginIframes:z,wrappedEmit:_});for(const I of H||[])I.getMirror&&I.getMirror({nodeMirror:ee,crossOriginIframeMirror:ae.crossOriginIframeMirror,crossOriginIframeStyleMirror:ae.crossOriginIframeStyleMirror});ct=new rs({recordCanvas:k,mutationCb:le,win:window,blockClass:s,blockSelector:i,mirror:ee,sampling:C.canvas,dataURLOptions:m});const Te=new Un({mutationCb:V,scrollCb:q,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:m,maskTextFn:p,maskInputFn:f,recordCanvas:k,inlineImages:T,sampling:C,slimDOMOptions:J,iframeManager:ae,stylesheetManager:ne,canvasManager:ct,keepIframeSrcFn:j},mirror:ee});qe=(I=!1)=>{var G,P,E,Y,A,Z;_(O({type:w.Meta,data:{href:window.location.href,width:Bt(),height:Dt()}}),I),ne.reset(),pe.forEach(K=>K.lock());const Ue=Cn(document,{mirror:ee,blockClass:s,blockSelector:i,maskTextClass:o,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:L,maskTextFn:p,slimDOM:J,dataURLOptions:m,recordCanvas:k,inlineImages:T,onSerialize:K=>{zt(K,ee)&&ae.addIframe(K),Gt(K,ee)&&ne.trackLinkElement(K),Kt(K)&&Te.addShadowRoot(K.shadowRoot,document)},onIframeLoad:(K,mt)=>{ae.attachIframe(K,mt),Te.observeAttachShadow(K)},onStylesheetLoad:(K,mt)=>{ne.attachLinkElement(K,mt)},keepIframeSrcFn:j});if(!Ue)return console.warn("Failed to snapshot the document");_(O({type:w.FullSnapshot,data:{node:Ue,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:(document==null?void 0:document.documentElement.scrollLeft)||((P=(G=document==null?void 0:document.body)===null||G===void 0?void 0:G.parentElement)===null||P===void 0?void 0:P.scrollLeft)||((E=document==null?void 0:document.body)===null||E===void 0?void 0:E.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:(document==null?void 0:document.documentElement.scrollTop)||((A=(Y=document==null?void 0:document.body)===null||Y===void 0?void 0:Y.parentElement)===null||A===void 0?void 0:A.scrollTop)||((Z=document==null?void 0:document.body)===null||Z===void 0?void 0:Z.scrollTop)||0}}})),pe.forEach(K=>K.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ne.adoptStyleSheets(document.adoptedStyleSheets,ee.getId(document))};try{const I=[];I.push(U("DOMContentLoaded",()=>{_(O({type:w.DomContentLoaded,data:{}}))}));const G=E=>{var Y;return Dn({mutationCb:V,mousemoveCb:(A,Z)=>_(O({type:w.IncrementalSnapshot,data:{source:Z,positions:A}})),mouseInteractionCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.MouseInteraction},A)})),scrollCb:q,viewportResizeCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.ViewportResize},A)})),inputCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Input},A)})),mediaInteractionCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.MediaInteraction},A)})),styleSheetRuleCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.StyleSheetRule},A)})),styleDeclarationCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.StyleDeclaration},A)})),canvasMutationCb:le,fontCb:A=>_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Font},A)})),selectionCb:A=>{_(O({type:w.IncrementalSnapshot,data:Object.assign({source:b.Selection},A)}))},blockClass:s,ignoreClass:a,maskTextClass:o,maskTextSelector:c,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:k,inlineImages:T,userTriggeredOnInput:x,collectFonts:D,doc:E,maskInputFn:f,maskTextFn:p,keepIframeSrcFn:j,blockSelector:i,slimDOMOptions:J,dataURLOptions:m,mirror:ee,iframeManager:ae,stylesheetManager:ne,shadowDomManager:Te,canvasManager:ct,ignoreCSSAttributes:X,plugins:((Y=H==null?void 0:H.filter(A=>A.observer))===null||Y===void 0?void 0:Y.map(A=>({observer:A.observer,options:A.options,callback:Z=>_(O({type:w.Plugin,data:{plugin:A.name,payload:Z}}))})))||[]},y)};ae.addLoadListener(E=>{I.push(G(E.contentDocument))});const P=()=>{qe(),I.push(G(document)),Ye=!0};return document.readyState==="interactive"||document.readyState==="complete"?P():I.push(U("load",()=>{_(O({type:w.Load,data:{}})),P()},window)),()=>{I.forEach(E=>E()),Ye=!1}}catch(I){console.warn(I)}}we.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");_(O({type:w.Custom,data:{tag:e,payload:t}}))},we.freezePage=()=>{pe.forEach(e=>e.freeze())},we.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");qe(e)},we.mirror=ee;const{addCustomEvent:ss}=we;class Ae{constructor(t){this.fileName=t.fileName||"",this.functionName=t.functionName||"",this.lineNumber=t.lineNumber,this.columnNumber=t.columnNumber}toString(){const t=this.lineNumber||"",r=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${t}:${r})`:`${this.fileName}:${t}:${r}`}}const is=/(^|@)\S+:\d+/,pr=/^\s*at .*(\S+:\d+|\(native\))/m,as=/^(eval@)?(\[native code])?$/,hr={parse:function(e){if(!e)return[];if(typeof e.stacktrace<"u"||typeof e["opera#sourceloc"]<"u")return this.parseOpera(e);if(e.stack&&e.stack.match(pr))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];const r=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!r)throw new Error(`Cannot parse given url: ${e}`);return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
|
|
19
|
+
`).filter(function(r){return!!r.match(pr)},this).map(function(r){r.indexOf("(eval ")>-1&&(r=r.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let n=r.replace(/^\s+/,"").replace(/\(eval code/g,"(");const s=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=s?n.replace(s[0],""):n;const i=n.split(/\s+/).slice(1),a=this.extractLocation(s?s[1]:i.pop()),o=i.join(" ")||void 0,c=["eval","<anonymous>"].indexOf(a[0])>-1?void 0:a[0];return new Ae({functionName:o,fileName:c,lineNumber:a[1],columnNumber:a[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
|
|
20
|
+
`).filter(function(r){return!r.match(as)},this).map(function(r){if(r.indexOf(" > eval")>-1&&(r=r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),r.indexOf("@")===-1&&r.indexOf(":")===-1)return new Ae({functionName:r});{const n=/((.*".+"[^@]*)?[^@]*)(?:@)/,s=r.match(n),i=s&&s[1]?s[1]:void 0,a=this.extractLocation(r.replace(n,""));return new Ae({functionName:i,fileName:a[0],lineNumber:a[1],columnNumber:a[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
|
|
21
|
+
`)>-1&&e.message.split(`
|
|
22
|
+
`).length>e.stacktrace.split(`
|
|
23
|
+
`).length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split(`
|
|
24
|
+
`),n=[];for(let s=2,i=r.length;s<i;s+=2){const a=t.exec(r[s]);a&&n.push(new Ae({fileName:a[2],lineNumber:parseFloat(a[1])}))}return n},parseOpera10:function(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split(`
|
|
25
|
+
`),n=[];for(let s=0,i=r.length;s<i;s+=2){const a=t.exec(r[s]);a&&n.push(new Ae({functionName:a[3]||void 0,fileName:a[2],lineNumber:parseFloat(a[1])}))}return n},parseOpera11:function(e){return e.stack.split(`
|
|
26
|
+
`).filter(function(r){return!!r.match(is)&&!r.match(/^Error created at/)},this).map(function(r){const n=r.split("@"),s=this.extractLocation(n.pop()),a=(n.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Ae({functionName:a,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})},this)}};function os(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let r=e.localName;if(!r)break;r=r.toLowerCase();const n=e.parentElement,s=[];if(n.children&&n.children.length>0)for(let i=0;i<n.children.length;i++){const a=n.children[i];a.localName&&a.localName.toLowerCase&&a.localName.toLowerCase()===r&&s.push(a)}s.length>1&&(r+=`:eq(${s.indexOf(e)})`),t=r+(t?">"+t:""),e=n}return t}function dt(e){return Object.prototype.toString.call(e)==="[object Object]"}function fr(e,t){if(t===0)return!0;const r=Object.keys(e);for(const n of r)if(dt(e[n])&&fr(e[n],t-1))return!0;return!1}function lt(e,t){const r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);const n=[],s=[];return JSON.stringify(e,function(o,c){if(n.length>0){const d=n.indexOf(this);~d?n.splice(d+1):n.push(this),~d?s.splice(d,1/0,o):s.push(o),~n.indexOf(c)&&(n[0]===c?c="[Circular ~]":c="[Circular ~."+s.slice(0,n.indexOf(c)).join(".")+"]")}else n.push(c);if(c===null)return c;if(c===void 0)return"undefined";if(i(c))return a(c);if(c instanceof Event){const d={};for(const l in c){const u=c[l];Array.isArray(u)?d[l]=os(u.length?u[0]:null):d[l]=u}return d}else{if(c instanceof Node)return c instanceof HTMLElement?c?c.outerHTML:"":c.nodeName;if(c instanceof Error)return c.stack?c.stack+`
|
|
27
|
+
End of stack for Error object`:c.name+": "+c.message}return c});function i(o){return!!(dt(o)&&Object.keys(o).length>r.numOfKeysLimit||typeof o=="function"||dt(o)&&fr(o,r.depthOfLimit))}function a(o){let c=o.toString();return r.stringLengthLimit&&c.length>r.stringLengthLimit&&(c=`${c.slice(0,r.stringLengthLimit)}...`),c}}const mr={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function cs(e,t,r){const n=r?Object.assign({},mr,r):mr,s=n.logger;if(!s)return()=>{};let i;typeof s=="string"?i=t[s]:i=s;let a=0;const o=[];if(n.level.includes("error")&&window){const d=l=>{const u=l.message,h=l.error,f=hr.parse(h).map(y=>y.toString()),p=[lt(u,n.stringifyOptions)];e({level:"error",trace:f,payload:p})};window.addEventListener("error",d),o.push(()=>{window&&window.removeEventListener("error",d)})}for(const d of n.level)o.push(c(i,d));return()=>{o.forEach(d=>d())};function c(d,l){return d[l]?ue(d,l,u=>(...h)=>{u.apply(this,h);try{const f=hr.parse(new Error).map(y=>y.toString()).splice(1),p=h.map(y=>lt(y,n.stringifyOptions));a++,a<n.lengthThreshold?e({level:l,trace:f,payload:p}):a===n.lengthThreshold&&e({level:"warn",trace:[],payload:[lt("The number of log records reached the threshold.")]})}catch(f){u("rrweb logger error:",f,...h)}}):()=>{}}}const ds="rrweb/console@1",ls=e=>({name:ds,observer:cs,options:e}),us="application/json",ps="flashlog",hs=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,xe=()=>typeof window<"u"&&window.location?window.location.href:"",gr=e=>new Date(typeof e=="number"?e:Date.now()).toISOString(),ut=async e=>{try{return await e.json()}catch{return null}};class yr extends Error{constructor(t){super(t),this.name="ReplayQuotaError"}}class fs{constructor(){this.config=null,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.flushTimer=null,this.replaySessionId=null,this.segmentSequence=0}async start(t){await this.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),!(typeof window>"u"||typeof document>"u")&&(this.config=t,this.currentBytes=0,this.currentEvents=[],this.detachListeners=[],this.finalized=!1,this.flushInFlight=null,this.replaySessionId=null,this.segmentSequence=0,this.stopRecording=we({emit:r=>this.pushEvent(r),collectFonts:!0,inlineStylesheet:!0,maskAllInputs:t.maskAllInputs,userTriggeredOnInput:!0,plugins:[ls()]})||void 0,this.bindLifecycleListeners(),this.flushTimer=window.setInterval(()=>{this.flush("interval")},t.flushIntervalMs),this.addCustomEvent("session-start",{session_id:t.sessionId,brand_id:t.brandId,device_id:t.deviceId,page_url:xe(),started_at:new Date().toISOString()}))}async flush(t="manual",r){if(this.flushInFlight)return this.flushInFlight;if(!this.config||this.finalized)return null;const n=this.takePendingSegment();return n?(this.flushInFlight=this.uploadSegment(n,t,(r==null?void 0:r.keepalive)===!0).catch(s=>s instanceof yr?(this.currentBytes=0,this.currentEvents=[],this.finalized=!0,this.stopCapture(),this.debug("Replay capture stopped by server quota",{message:s.message,reason:t,segmentId:n.segmentId}),null):(this.restorePendingSegment(n),this.debug("Replay upload failed",{message:s instanceof Error?s.message:String(s),reason:t,segmentId:n.segmentId}),null)).finally(()=>{this.flushInFlight=null}),this.flushInFlight):null}async finalize(t="manual",r){if(!this.config||this.finalized)return null;this.addCustomEvent("session-finalize",{reason:t,page_url:xe(),session_id:this.config.sessionId,timestamp:new Date().toISOString()}),this.stopCapture();const n=await this.flush(t,{keepalive:(r==null?void 0:r.keepalive)===!0});if(this.replaySessionId=(n==null?void 0:n.replay_session_id)||this.replaySessionId,this.finalized=!0,!this.replaySessionId)return this.config=null,null;const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/finalize`,a=await fetch(i,{body:JSON.stringify({brand_id:s.brandId,device_id:s.deviceId,finalized_reason:t,page_url:xe(),replay_session_id:this.replaySessionId,session_id:s.sessionId}),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:(r==null?void 0:r.keepalive)===!0,method:"POST"}).catch(c=>(this.debug("Replay finalize failed",{message:c instanceof Error?c.message:String(c),reason:t}),null));if(this.config=null,!a)return null;const o=await ut(a);return a.ok?(o==null?void 0:o.data)||null:(this.debug("Replay finalize returned non-200",{message:(o==null?void 0:o.message)||`HTTP ${a.status}`,reason:t}),null)}async dispose(t){if((t==null?void 0:t.finalize)===!0&&!!this.config&&!this.finalized){await this.finalize((t==null?void 0:t.reason)||"dispose",{keepalive:(t==null?void 0:t.keepalive)===!0}).catch(()=>null);return}this.stopCapture(),this.config=null,this.currentBytes=0,this.currentEvents=[],this.flushInFlight=null,this.finalized=!0,this.replaySessionId=null,this.segmentSequence=0}addCustomEvent(t,r){if(!(!this.config||this.finalized))try{ss(`${ps}:${t}`,r)}catch(n){this.debug("Replay custom event skipped",{message:n instanceof Error?n.message:String(n),tag:t})}}bindLifecycleListeners(){if(typeof window>"u"||typeof document>"u")return;const t=()=>{document.visibilityState==="hidden"&&this.flush("visibility-hidden",{keepalive:!0})},r=()=>{this.finalize("pagehide",{keepalive:!0})},n=()=>{this.flush("beforeunload",{keepalive:!0})};document.addEventListener("visibilitychange",t,!0),window.addEventListener("pagehide",r),window.addEventListener("beforeunload",n),this.detachListeners=[()=>document.removeEventListener("visibilitychange",t,!0),()=>window.removeEventListener("pagehide",r),()=>window.removeEventListener("beforeunload",n)]}debug(t,r){var n;(n=this.config)!=null&&n.debug&&console.log("[FlashlogTracker][Replay]",t,r||{})}pushEvent(t){!this.config||this.finalized||(this.currentEvents.push(t),this.currentBytes+=this.estimateEventSize(t),(this.currentBytes>=this.config.maxSegmentBytes||this.currentEvents.length>=this.config.maxSegmentEvents)&&this.flush("buffer-threshold"))}estimateEventSize(t){try{return JSON.stringify(t).length}catch{return 0}}nextSegmentId(t){return`segment-${String(t).padStart(6,"0")}-${hs()}`}restorePendingSegment(t){this.currentEvents=[...t.events,...this.currentEvents],this.currentBytes+=t.sizeBytes,this.segmentSequence=Math.min(this.segmentSequence,t.sequenceNumber)}stopCapture(){var t;(t=this.stopRecording)==null||t.call(this),this.stopRecording=void 0,this.flushTimer!==null&&typeof window<"u"&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.detachListeners.forEach(r=>r()),this.detachListeners=[]}takePendingSegment(){var s,i;if(this.currentEvents.length===0)return null;const t=this.currentEvents,r=this.currentBytes,n=this.segmentSequence;return this.currentEvents=[],this.currentBytes=0,this.segmentSequence+=1,{endedAt:gr((s=t[t.length-1])==null?void 0:s.timestamp),eventCount:t.length,events:t,segmentId:this.nextSegmentId(n),sequenceNumber:n,sizeBytes:r,startedAt:gr((i=t[0])==null?void 0:i.timestamp)}}async uploadSegment(t,r,n){var h;if(!this.config)throw new Error("Replay recorder is not configured");const s=this.config,i=`${s.apiUrl.replace(/\/+$/,"")}/v1/session-replays/public/segments/upload-url`,a={brand_id:s.brandId,content_type:us,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),replay_session_id:this.replaySessionId,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt,upload_reason:r},o=await fetch(i,{body:JSON.stringify(a),headers:{"Content-Type":"application/json","x-api-key":s.apiKey},keepalive:n,method:"POST"}),c=await ut(o);if(!o.ok||!((h=c==null?void 0:c.data)!=null&&h.upload_url)){const f=c==null?void 0:c.message,p=typeof f=="object"&&f?f.code:c==null?void 0:c.code,y=typeof f=="object"&&f?f.message:f;throw o.status===403&&typeof p=="string"&&p.startsWith("REPLAY_")?new yr(y||"Replay capture quota exhausted"):new Error(y||`Failed to create replay upload URL (${o.status})`)}this.replaySessionId=c.data.replay_session_id||this.replaySessionId;const d=JSON.stringify({events:t.events,meta:{brand_id:s.brandId,device_id:s.deviceId,ended_at:t.endedAt,event_count:t.eventCount,page_url:xe(),reason:r,segment_id:t.segmentId,sequence_number:t.sequenceNumber,session_id:s.sessionId,started_at:t.startedAt},source:"flashlog-tracker-sdk",type:"rrweb-event-segment",version:1}),l=await fetch(c.data.upload_url,{body:d,headers:{"Content-Type":"application/octet-stream"},keepalive:n,method:c.data.method||"PUT"}),u=await ut(l);if(!l.ok||!(u!=null&&u.data))throw new Error((u==null?void 0:u.message)||`Replay segment upload failed (${l.status})`);return this.debug("Replay segment uploaded",{objectKey:u.data.object_key,reason:r,segmentId:u.data.segment_id,sequenceNumber:u.data.sequence_number}),u.data}}const pt=()=>typeof window<"u"&&typeof window.localStorage<"u",Ir=()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=Date.now().toString(36),t=Math.random().toString(36).slice(2,12);return`${e}-${t}`},he=e=>pt()?window.localStorage.getItem(e):null,fe=(e,t)=>{pt()&&window.localStorage.setItem(e,t)},ke=e=>{pt()&&window.localStorage.removeItem(e)},ms=e=>{const t=he(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},gs=(e,t)=>{fe(e,JSON.stringify(t))},Cr=()=>{const e=he(N.deviceId);if(e)return e;const t=Ir();return fe(N.deviceId,t),t},Sr=e=>{const t=Date.now(),r=he(N.sessionId),n=he(N.sessionSeenAt),s=n?Number(n):NaN,i=Number.isFinite(s)&&t-s<=e;if(r&&i)return fe(N.sessionSeenAt,String(t)),r;const a=Ir();return fe(N.sessionId,a),fe(N.sessionSeenAt,String(t)),a},ys=()=>{fe(N.sessionSeenAt,String(Date.now()))},Is=()=>he(N.sessionId),Cs=()=>he(N.deviceId),Ss=(e,t)=>{if(fe(N.accountId,e),t&&Object.keys(t).length>0){gs(N.accountTraits,t);return}ke(N.accountTraits)},bs=()=>he(N.accountId),vs=()=>ms(N.accountTraits),br=()=>{ke(N.accountId),ke(N.accountTraits)},ws=()=>{ke(N.sessionId),ke(N.sessionSeenAt),ke(N.deviceId),br()},vr=(e,t)=>Array.from(new Set([...e,...t||[]])),As=e=>{var t,r;return{apiUrl:((t=e==null?void 0:e.apiUrl)==null?void 0:t.trim())||v.apiUrl,apiKey:(e==null?void 0:e.apiKey)??v.apiKey,debug:(e==null?void 0:e.debug)??v.debug,autoCapture:(e==null?void 0:e.autoCapture)??v.autoCapture,captureNetworkErrors:(e==null?void 0:e.captureNetworkErrors)??v.captureNetworkErrors,captureJsErrors:(e==null?void 0:e.captureJsErrors)??v.captureJsErrors,captureSocketErrors:(e==null?void 0:e.captureSocketErrors)??v.captureSocketErrors,sessionTimeoutMs:(e==null?void 0:e.sessionTimeoutMs)??v.sessionTimeoutMs,maxActionBufferSize:(e==null?void 0:e.maxActionBufferSize)??v.maxActionBufferSize,allowNonErrorEvents:(e==null?void 0:e.allowNonErrorEvents)??v.allowNonErrorEvents,ignoredStatusCodes:(e==null?void 0:e.ignoredStatusCodes)||v.ignoredStatusCodes,ignoredUrls:(e==null?void 0:e.ignoredUrls)||v.ignoredUrls,captureRequestBody:(e==null?void 0:e.captureRequestBody)??v.captureRequestBody,captureResponseBody:(e==null?void 0:e.captureResponseBody)??v.captureResponseBody,redactKeys:vr(v.redactKeys,e==null?void 0:e.redactKeys),redactUrlParams:vr(v.redactUrlParams,e==null?void 0:e.redactUrlParams),propagateTraceHeaders:(e==null?void 0:e.propagateTraceHeaders)??v.propagateTraceHeaders,traceOrigins:(e==null?void 0:e.traceOrigins)||v.traceOrigins,traceHeaderName:((r=e==null?void 0:e.traceHeaderName)==null?void 0:r.trim())||v.traceHeaderName,enableSessionReplay:(e==null?void 0:e.enableSessionReplay)??v.enableSessionReplay,replayFlushIntervalMs:(e==null?void 0:e.replayFlushIntervalMs)??v.replayFlushIntervalMs,replayMaxSegmentBytes:(e==null?void 0:e.replayMaxSegmentBytes)??v.replayMaxSegmentBytes,replayMaxSegmentEvents:(e==null?void 0:e.replayMaxSegmentEvents)??v.replayMaxSegmentEvents,replayMaskAllInputs:(e==null?void 0:e.replayMaskAllInputs)??v.replayMaskAllInputs}},B=()=>typeof window<"u"&&window.location?window.location.href:"",me=()=>typeof document<"u"&&document.title||"",ks=new Set(["beacon","fetch","xmlhttprequest"]),Re=1e3,Xe=()=>typeof performance<"u"&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now(),Rs=e=>{const t=String(e.initiatorType||"").toLowerCase(),r=String(e.name||"").toLowerCase();return t==="fetch"||t==="xmlhttprequest"||t==="beacon"?"xhr":t==="css"||t==="link"||r.endsWith(".css")||r.includes(".css?")?"css":t==="script"||r.endsWith(".js")||r.includes(".js?")?"js":t==="img"||t==="image"||/\.(png|jpg|jpeg|gif|svg|webp|avif|ico)(\?|$)/.test(r)?"images":t==="font"||/\.(woff|woff2|ttf|otf|eot)(\?|$)/.test(r)?"fonts":"other"},Ts=e=>{if(!(e!=null&&e.name))return!1;if(e.entryType==="navigation")return!0;const t=String(e.initiatorType||"").toLowerCase();return ks.has(t)?!1:!/^wss?:/i.test(e.name)},Es=e=>{const t=Number(e.responseStatus);if(Number.isFinite(t)&&t>0)return t;if(e.entryType==="navigation")return 200;const r=Number(e.transferSize||0),n=Number(e.encodedBodySize||0),s=Number(e.decodedBodySize||0);return r>0||n>0||s>0?200:null},_s=e=>Math.round(Xe()+Math.max(0,Number(e.startTime||0))),ht=e=>Math.round(e/(1024*1024)*10)/10,Ns=()=>{if(typeof performance>"u")return null;const e=performance.memory;if(!e)return null;const t=Number(e.usedJSHeapSize||0),r=Number(e.totalJSHeapSize||0),n=Number(e.jsHeapSizeLimit||0);return t<=0&&r<=0&&n<=0?null:{js_heap_limit_mb:ht(n),total_js_heap_mb:ht(r),used_js_heap_mb:ht(t)}},Ms=()=>{if(typeof performance>"u")return null;const e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByName("first-contentful-paint")[0];if(!e&&!t)return null;const r={};return e&&(r.dom_content_loaded_ms=Math.round(e.domContentLoadedEventEnd||0),r.load_event_ms=Math.round(e.loadEventEnd||0),r.response_end_ms=Math.round(e.responseEnd||0),r.dom_complete_ms=Math.round(e.domComplete||0),r.transfer_size=Math.round(e.transferSize||0)),t&&(r.first_contentful_paint_ms=Math.round(t.startTime||0)),Object.keys(r).length>0?r:null};class wr{constructor(){this.config=v,this.brandId=null,this.sessionId=null,this.deviceId=null,this.accountId=null,this.accountTraits=null,this.errorCapture=null,this.initialized=!1,this.performanceObservers=[],this.performanceSampleTimer=null,this.pendingLongTaskMs=0,this.resourceObserver=null,this.replayResourceKeys=new Set,this.nextPerformanceSampleAt=0,this.actionBuffer=new zr(v.maxActionBufferSize),this.replayRecorder=new fs}async init(t,r){var i;const n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error("[FlashlogTracker] Invalid brand id");const s=As(r);if(!s.apiKey||!s.apiKey.trim())throw new Error("[FlashlogTracker] Missing api key");this.config={...s,apiKey:s.apiKey.trim()},this.brandId=n,this.sessionId=Sr(this.config.sessionTimeoutMs),this.deviceId=Cr(),this.accountId=bs(),this.accountTraits=vs(),this.actionBuffer.stop(),this.actionBuffer.clear(),this.actionBuffer.start(),this.stopReplayResourceCapture(),await this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reinit"}),(i=this.errorCapture)==null||i.stop(),this.errorCapture=null,this.config.autoCapture&&(this.errorCapture=new Hr(this.config,{debug:this.config.debug,onNetworkActivity:a=>{this.replayRecorder.addCustomEvent("network-activity",{...a,page_title:me(),session_id:this.sessionId,url_bug_happened:B()})},onNetworkError:a=>{this.trackInternal("NETWORK_ERROR",{...a,error_type:"network_error",url_bug_happened:B(),url:String(a.url||"")})},onSocketError:a=>{this.trackInternal("SOCKET_ERROR",{...a,error_type:"socket_error",url_bug_happened:B(),url:String(a.url||"")})},onJsError:a=>{this.trackInternal("JS_ERROR",{...a,error_type:"js_error",url_bug_happened:B(),url:B()})},onUnhandledRejection:a=>{this.trackInternal("UNHANDLED_REJECTION",{...a,error_type:"unhandled_rejection",url_bug_happened:B(),url:B()})}}),this.errorCapture.start()),this.config.enableSessionReplay&&(await this.replayRecorder.start({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,deviceId:this.deviceId,flushIntervalMs:this.config.replayFlushIntervalMs,maskAllInputs:this.config.replayMaskAllInputs,maxSegmentBytes:this.config.replayMaxSegmentBytes,maxSegmentEvents:this.config.replayMaxSegmentEvents,sessionId:this.sessionId}),this.recordReplaySessionContext("init"),this.startReplayResourceCapture(),this.startReplayPerformanceCapture()),this.initialized=!0,yt({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,brandId:this.brandId,debug:this.config.debug,source:"package"}),this.config.debug&&console.log("[FlashlogTracker] Initialized",{brandId:this.brandId,apiUrl:this.config.apiUrl})}async track(t,r={}){return!this.config.allowNonErrorEvents&&!gt.has(t)?(this.config.debug&&console.warn("[FlashlogTracker] Ignored non-error event",{eventName:t}),!1):this.trackInternal(t,r)}async reportError(t,r={}){const n=t instanceof Error?t.message:String(t),s=t instanceof Error?t.stack:void 0;return this.trackInternal("MANUAL_ERROR",{message:n,stack:s,context:r,error_type:"manual_error",url_bug_happened:B(),url:B(),timestamp:Date.now()})}addUserAction(t,r){this.actionBuffer.add(t,r),this.replayRecorder.addCustomEvent("user-action",{action:t,details:r||null,session_id:this.sessionId,timestamp:Date.now(),url:B()})}identify(t,r={}){const n=String(t||"").trim();if(!n)throw new Error("[FlashlogTracker] identify requires a non-empty account id");this.accountId=n,this.accountTraits=Object.keys(r).length>0?r:null,Ss(n,this.accountTraits||void 0),this.recordReplaySessionContext("identify")}clearIdentity(){this.accountId=null,this.accountTraits=null,br(),this.recordReplaySessionContext("clear-identity")}getTraceHeaders(){return tt(Ke(),this.config.traceHeaderName)}getSessionId(){return this.sessionId||Is()}getDeviceId(){return this.deviceId||Cs()}async flushReplay(t="manual"){return this.replayRecorder.flush(t)}async finalizeReplay(t="manual"){return this.captureReplayPerformanceSample("finalize"),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.finalize(t)}reset(){var t;(t=this.errorCapture)==null||t.stop(),this.errorCapture=null,this.actionBuffer.stop(),this.actionBuffer.clear(),this.stopReplayPerformanceCapture(),this.stopReplayResourceCapture(),this.replayRecorder.dispose({finalize:!0,keepalive:!1,reason:"reset"}),ws(),this.initialized=!1,this.brandId=null,this.sessionId=null,this.deviceId=null}buildPayload(t,r,n){if(!this.brandId||!this.sessionId||!this.deviceId)return null;const s={actions:this.actionBuffer.getAll(),device_info:At(this.deviceId),network_status:kt(),url_bug_happened:r.url_bug_happened||B(),trace_id:n.trace_id,span_id:n.span_id,traceparent:n.traceparent,...this.accountId?{account_id:this.accountId}:{},...this.accountTraits?{account_traits:this.accountTraits}:{},...r};return{event_name:t,session_id:this.sessionId,brand_id:this.brandId,data:s}}async trackInternal(t,r){if(!this.initialized)return this.config.debug&&console.warn("[FlashlogTracker] Not initialized"),!1;ys(),this.sessionId||(this.sessionId=Sr(this.config.sessionTimeoutMs)),this.deviceId||(this.deviceId=Cr());const n=Pr(r),s=this.buildPayload(t,r,n);if(!s)return!1;const i=Fr(s,this.config),a=typeof i.data.status=="number"?i.data.status:typeof i.data.http_status=="number"?i.data.http_status:null,o=typeof i.data.method=="string"?i.data.method.toUpperCase():typeof i.data.http_method=="string"?i.data.http_method.toUpperCase():null,c=typeof i.data.request_url=="string"?i.data.request_url:typeof i.data.url=="string"?i.data.url:null;this.replayRecorder.addCustomEvent("tracking-event",{...i.data,event_name:t,error_type:typeof i.data.error_type=="string"?i.data.error_type:null,http_method:o,http_status:a,method:o,page_title:me(),request_url:c,session_id:s.session_id,timestamp:typeof i.data.timestamp=="number"?i.data.timestamp:Date.now()});try{const d={"Content-Type":"application/json","x-api-key":this.config.apiKey},l=`${this.config.apiUrl.replace(/\/$/,"")}/v1/integration/webhook`,u=await fetch(l,{method:"POST",headers:d,body:JSON.stringify(i)});return u.ok?(gt.has(t)&&this.replayRecorder.flush("tracked-error"),!0):(this.config.debug&&console.error("[FlashlogTracker] Track failed",{eventName:t,status:u.status}),!1)}catch(d){return this.config.debug&&console.error("[FlashlogTracker] Track error",d),!1}}recordReplaySessionContext(t){!this.config.enableSessionReplay||!this.sessionId||!this.deviceId||this.replayRecorder.addCustomEvent("session-context",{account_id:this.accountId,account_traits:this.accountTraits,device_info:At(this.deviceId),network_status:kt(),page_title:me(),page_url:B(),performance:Ms(),reason:t,session_id:this.sessionId,timestamp:Date.now()})}stopReplayResourceCapture(){var t;(t=this.resourceObserver)==null||t.disconnect(),this.resourceObserver=null,this.replayResourceKeys.clear()}stopReplayPerformanceCapture(){this.performanceObservers.forEach(t=>t.disconnect()),this.performanceObservers=[],this.performanceSampleTimer!==null&&typeof window<"u"&&(window.clearTimeout(this.performanceSampleTimer),this.performanceSampleTimer=null),this.pendingLongTaskMs=0,this.nextPerformanceSampleAt=0}startReplayResourceCapture(){if(this.stopReplayResourceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u")&&(this.captureReplayResourceEntries(performance.getEntriesByType("navigation"),"buffered"),this.captureReplayResourceEntries(performance.getEntriesByType("resource"),"buffered"),!(typeof PerformanceObserver>"u")))try{this.resourceObserver=new PerformanceObserver(t=>{this.captureReplayResourceEntries(t.getEntries(),"observed")}),this.resourceObserver.observe({entryTypes:["resource"]})}catch{this.resourceObserver=null}}startReplayPerformanceCapture(){this.stopReplayPerformanceCapture(),!(!this.config.enableSessionReplay||!this.sessionId||typeof performance>"u"||typeof window>"u")&&(this.observeReplayLongTasks(),this.observeReplayLayoutShifts(),this.nextPerformanceSampleAt=performance.now(),this.captureReplayPerformanceSample("start"),this.scheduleReplayPerformanceSample())}scheduleReplayPerformanceSample(){typeof window>"u"||typeof performance>"u"||!this.config.enableSessionReplay||!this.sessionId||(this.performanceSampleTimer=window.setTimeout(()=>{this.captureReplayPerformanceSample("interval"),this.scheduleReplayPerformanceSample()},Re))}captureReplayPerformanceSample(t){if(!this.sessionId||typeof performance>"u"||!this.config.enableSessionReplay)return;const r=performance.now(),n=this.nextPerformanceSampleAt||r,s=Math.max(0,r-n);this.nextPerformanceSampleAt=r+Re;const i=Math.min(100,Math.round(Math.min(Re,s)/Re*100+Math.min(Re,this.pendingLongTaskMs)/Re*100)),a=Ns();this.pendingLongTaskMs=0,this.replayRecorder.addCustomEvent("performance-sample",{cpu_usage_pct:i,js_heap_limit_mb:(a==null?void 0:a.js_heap_limit_mb)??null,memory_mb:(a==null?void 0:a.used_js_heap_mb)??null,page_title:me(),page_url:B(),reason:t,session_id:this.sessionId,timestamp:Math.round(Xe()+r),total_memory_mb:(a==null?void 0:a.total_js_heap_mb)??null})}observeReplayLongTasks(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Math.round(Number(n.duration||0));s<=0||(this.pendingLongTaskMs+=s,this.replayRecorder.addCustomEvent("long-task",{duration_ms:s,name:n.name||"longtask",page_title:me(),page_url:B(),session_id:this.sessionId,start_time_ms:Math.round(Number(n.startTime||0)),timestamp:Math.round(Xe()+Number(n.startTime||performance.now()))}))})});t.observe({type:"longtask",buffered:!0}),this.performanceObservers.push(t)}catch{}}observeReplayLayoutShifts(){if(!(typeof PerformanceObserver>"u"||!this.sessionId))try{const t=new PerformanceObserver(r=>{r.getEntries().forEach(n=>{const s=Number(n.value||0);!Number.isFinite(s)||s<=0||n.hadRecentInput||this.replayRecorder.addCustomEvent("layout-shift",{page_title:me(),page_url:B(),session_id:this.sessionId,timestamp:Math.round(Xe()+Number(n.startTime||performance.now())),value:Math.round(s*1e4)/1e4})})});t.observe({type:"layout-shift",buffered:!0}),this.performanceObservers.push(t)}catch{}}captureReplayResourceEntries(t,r){this.sessionId&&t.forEach(n=>{if(!Ts(n))return;const s=[n.entryType,n.name,Math.round(Number(n.startTime||0)),Math.round(Number(n.duration||0)),String(n.initiatorType||"")].join("|");this.replayResourceKeys.has(s)||(this.replayResourceKeys.add(s),this.replayRecorder.addCustomEvent("resource-entry",{capture_mode:r,duration_ms:Math.round(Number(n.duration||0)),encoded_body_size:Math.round(Number(n.encodedBodySize||0)),entry_type:n.entryType,initiator_type:String(n.initiatorType||""),method:"GET",page_title:me(),page_url:B(),request_url:n.name,resource_type:Rs(n),response_end_ms:Math.round(Number(n.responseEnd||0)),session_id:this.sessionId,status:Es(n),timestamp:_s(n),transfer_size:Math.round(Number(n.transferSize||0)),url:n.name}))})}}const Ar=()=>new wr,De=Ar(),Os=De,te=(e,t)=>e===void 0?t:e==="true",Be=(e,t)=>{if(!e)return t;const r=Number(e);return Number.isFinite(r)?r:t},ft=e=>{if(!e)return;const t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:void 0},Ls=()=>{if(typeof document>"u")return null;if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.src.includes("tracker.umd.js"))return r}return null},Fs=async()=>{if(typeof window>"u"||typeof document>"u")return;const e=Ls();if(!e||e.dataset.autoInit!=="true")return;const t=e.dataset.productId||e.dataset.brandId,r=e.dataset.apiKey,n=te(e.dataset.debug,!1);if(t){if(!r){console.error("[FlashlogTracker] Auto init failed: missing data-api-key");return}try{await De.init(t,{apiUrl:e.dataset.apiUrl,apiKey:r,debug:n,autoCapture:te(e.dataset.autoCapture,!0),captureNetworkErrors:te(e.dataset.captureNetworkErrors,!0),captureJsErrors:te(e.dataset.captureJsErrors,!0),captureSocketErrors:te(e.dataset.captureSocketErrors,!0),allowNonErrorEvents:te(e.dataset.allowNonErrorEvents,!1),sessionTimeoutMs:Be(e.dataset.sessionTimeoutMs,30*60*1e3),maxActionBufferSize:Be(e.dataset.maxActionBufferSize,50),captureRequestBody:te(e.dataset.captureRequestBody,!0),captureResponseBody:te(e.dataset.captureResponseBody,!0),propagateTraceHeaders:te(e.dataset.propagateTraceHeaders,!1),traceOrigins:ft(e.dataset.traceOrigins),traceHeaderName:e.dataset.traceHeaderName,redactKeys:ft(e.dataset.redactKeys),redactUrlParams:ft(e.dataset.redactUrlParams),enableSessionReplay:te(e.dataset.enableSessionReplay,!0),replayFlushIntervalMs:Be(e.dataset.replayFlushIntervalMs,v.replayFlushIntervalMs),replayMaxSegmentBytes:Be(e.dataset.replayMaxSegmentBytes,v.replayMaxSegmentBytes),replayMaxSegmentEvents:Be(e.dataset.replayMaxSegmentEvents,v.replayMaxSegmentEvents),replayMaskAllInputs:te(e.dataset.replayMaskAllInputs,v.replayMaskAllInputs)}),yt({apiUrl:e.dataset.apiUrl,apiKey:r,brandId:t,source:"script",scriptUrl:e.src,debug:n})}catch(s){console.error("[FlashlogTracker] Auto init failed",s)}}};typeof window<"u"&&(window.FlashlogBugTracker=De,window.Tracker||(window.Tracker=De),Fs()),se.DEFAULT_CONFIG=v,se.FlashlogTrackerLite=wr,se.createTracker=Ar,se.default=De,se.flashlogTracker=Os,Object.defineProperties(se,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface TrackerConfig {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
debug: boolean;
|
|
5
|
+
autoCapture: boolean;
|
|
6
|
+
captureNetworkErrors: boolean;
|
|
7
|
+
captureJsErrors: boolean;
|
|
8
|
+
captureSocketErrors: boolean;
|
|
9
|
+
sessionTimeoutMs: number;
|
|
10
|
+
maxActionBufferSize: number;
|
|
11
|
+
allowNonErrorEvents: boolean;
|
|
12
|
+
ignoredStatusCodes: number[];
|
|
13
|
+
ignoredUrls: string[];
|
|
14
|
+
captureRequestBody: boolean;
|
|
15
|
+
captureResponseBody: boolean;
|
|
16
|
+
redactKeys: string[];
|
|
17
|
+
redactUrlParams: string[];
|
|
18
|
+
propagateTraceHeaders: boolean;
|
|
19
|
+
traceOrigins: string[];
|
|
20
|
+
traceHeaderName: string;
|
|
21
|
+
enableSessionReplay: boolean;
|
|
22
|
+
replayFlushIntervalMs: number;
|
|
23
|
+
replayMaxSegmentBytes: number;
|
|
24
|
+
replayMaxSegmentEvents: number;
|
|
25
|
+
replayMaskAllInputs: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface UserAction {
|
|
28
|
+
action: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
url: string;
|
|
31
|
+
details?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface DeviceInfo {
|
|
34
|
+
os_name: string;
|
|
35
|
+
device_type: string;
|
|
36
|
+
device_id: string;
|
|
37
|
+
browser_name: string;
|
|
38
|
+
browser_version: string;
|
|
39
|
+
screen_width: number;
|
|
40
|
+
screen_height: number;
|
|
41
|
+
viewport_width: number;
|
|
42
|
+
viewport_height: number;
|
|
43
|
+
language: string;
|
|
44
|
+
timezone: string;
|
|
45
|
+
user_agent: string;
|
|
46
|
+
}
|
|
47
|
+
export interface NetworkStatus {
|
|
48
|
+
online: boolean;
|
|
49
|
+
connection_type?: string;
|
|
50
|
+
downlink?: number;
|
|
51
|
+
rtt?: number;
|
|
52
|
+
save_data?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface TrackerPayload {
|
|
55
|
+
event_name: string;
|
|
56
|
+
session_id: string;
|
|
57
|
+
brand_id: number;
|
|
58
|
+
data: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface TrackerTraceContext {
|
|
61
|
+
trace_id: string;
|
|
62
|
+
span_id: string;
|
|
63
|
+
traceparent: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ReplayFlushResult {
|
|
66
|
+
content_type: string;
|
|
67
|
+
object_key: string;
|
|
68
|
+
replay_session_id: string | null;
|
|
69
|
+
segment_id: string;
|
|
70
|
+
sequence_number: number;
|
|
71
|
+
session_id: string;
|
|
72
|
+
size_bytes: number;
|
|
73
|
+
storage_driver: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ReplayFinalizeResult {
|
|
76
|
+
finalized_at: string;
|
|
77
|
+
id: string;
|
|
78
|
+
segment_count: number;
|
|
79
|
+
session_id: string;
|
|
80
|
+
status: string;
|
|
81
|
+
total_size_bytes: number;
|
|
82
|
+
}
|
|
83
|
+
export interface TrackerPublicApi {
|
|
84
|
+
init(brandId: string | number, config?: Partial<TrackerConfig>): Promise<void>;
|
|
85
|
+
track(eventName: string, data?: Record<string, unknown>): Promise<boolean>;
|
|
86
|
+
reportError(error: Error | string, context?: Record<string, unknown>): Promise<boolean>;
|
|
87
|
+
addUserAction(action: string, details?: Record<string, unknown>): void;
|
|
88
|
+
identify(accountId: string, traits?: Record<string, unknown>): void;
|
|
89
|
+
clearIdentity(): void;
|
|
90
|
+
getTraceHeaders(): Record<string, string>;
|
|
91
|
+
getSessionId(): string | null;
|
|
92
|
+
getDeviceId(): string | null;
|
|
93
|
+
flushReplay(reason?: string): Promise<ReplayFlushResult | null>;
|
|
94
|
+
finalizeReplay(reason?: string): Promise<ReplayFinalizeResult | null>;
|
|
95
|
+
reset(): void;
|
|
96
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flashlog/tracker-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/tracker.umd.js",
|
|
10
|
+
"module": "./dist/tracker.es.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/tracker.es.js",
|
|
16
|
+
"default": "./dist/tracker.umd.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
24
|
+
"dev": "vite build --watch",
|
|
25
|
+
"serve": "vite preview",
|
|
26
|
+
"serve:open": "vite preview --open",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"vite": "^5.4.19"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"rrweb": "^2.0.0-alpha.4"
|
|
35
|
+
}
|
|
36
|
+
}
|