z-monitor-react 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ "use strict";function e(e){return(new TextEncoder).encode(e)}function t(e){let t="";for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const n=()=>"undefined"!=typeof window;function o(e){if(null==e)return null;try{var t,n;return{message:null!==(t=null==e?void 0:e.message)&&void 0!==t?t:String(e),stack:null!==(n=null==e?void 0:e.stack)&&void 0!==n?n:void 0}}catch{return{message:String(e)}}}function r(e,t="log"){"function"==typeof console[t]?console[t](e):console.log(e)}function s(e){return!e}const i=(e,t)=>{let n=Object.prototype.toString;return"undefined"!=typeof Element&&e instanceof Element?"element":{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[n.call(e)]===t};function a(e,t=!1){return e.innerHTML?e.outerHTML.replace(e.innerHTML,t?e.innerText.slice(0,15):""):e.outerHTML}function l(e){return-1===["[object Window]","[object HTMLDocument]","[object HTMLHtmlElement]","[object HTMLBodyElement]"].indexOf(e.toString())}function c(e){return e.id?"#"+e.id:e.getAttribute("class")?"."+e.getAttribute("class").replace(" ","."):e.getAttribute("style")?"("+e.getAttribute("style")+")":""}function d(e){let t="";for(let n=Math.min(e.length-1,5);n>=0;n--)l(e[n])&&(t=t?`${e[n].localName}${c(e[n])} > ${t}`:`${e[n].localName}${c(e[n])}`);return t}const u={CLICK:{value:"UI.CLICK",text:"UI点击"},RES_ERROR:{value:"RES.ERROR",text:"资源加载错误"},AJAX_SUCCESS:{value:"AJAX.SUCCESS",text:"请求成功"},AJAX_FAIL:{value:"AJAX.FAIL",text:"请求失败"},CODE_ERROR:{value:"CODE.ERROR",text:"代码错误"},PROMISE_ERROR:{text:"promise.reject的错误",value:"PROMISE.ERROR"},CONSOLE:{value:"CONSOLE",text:"控制台打印"},CUSTOM:{value:"CUSTOM",text:"自定义日志"},USERINFO:{value:"USERINFO",text:"用户信息"},VideoRecord:{value:"VideoRecord",text:"视频回放"},PERFORMANCE:{value:"PERFORMANCE",text:"页面性能"}},h={ERROR:{value:1,text:"严重"},WARN:{value:2,text:"警告"},INFO:{value:3,text:"正常行为"}},p="PLUGIN_ERROR",m="SESSION_FAILED";class g{constructor({mt:e,name:t},n){this.mt=e,this.allOptions=e.options||{},this.name=t,this.customMethod=n.customMethod||null,this.isClose=!1}get TYPES(){return this.mt.TYPES}get LEVELS(){return this.mt.LEVELS}addCommonData(e,t,n){this.mt[e]?this.mt.addCommonData(e,t,n):r("monitor 实例找不到设置参数","error")}send(e,...t){const n=Date.now();!function(e){let t=()=>setTimeout(e,0);if("function"==typeof requestIdleCallback)t=()=>{requestIdleCallback(e)};else if("function"==typeof MessageChannel){const n=new MessageChannel;n.port1.onmessage=()=>e(),t=()=>n.port2.postMessage(null)}return t}((()=>{if(this.customMethod){const o=this.customMethod({time:n,...e},t);if(s(o))return;e=o}this.mt.send({time:n,...e})}))()}}function f(e,t){return null==t?void 0:t.some((t=>null==e?void 0:e.includes(t)))}class I{constructor({mt:e}){this.mt=e}init(e){this.url=e.url+"/monitor/add",this.method=e.requestConfig.method,this.headers=e.requestConfig.headers,this.customMethod=e.customMethod||null,e.url||this.customMethod||console.error("url or customMethod is required")}async request(e,t,n){if("undefined"==typeof window||!window.log_report){if("undefined"!=typeof window&&(window.log_report=!0),this.mt.beforeReport){let t=this.mt.beforeReport(e);if(s(t))return;e=t}this.customMethod?this.customMethod(e,t,n):this.report(e,t,n)}}shouldUseBeacon(e){return"function"==typeof navigator.sendBeacon&&new Blob([e]).size<=61440}shouldUseFetch(){return"function"==typeof fetch}reportWithBeacon(e){const t=new Blob([e],{type:"application/json"}),n=navigator.sendBeacon(this.url,t);if(n)return n;console.warn("sendBeacon failed, falling back to other methods")}async reportWithFetch(e){const t=await fetch(this.url,{method:this.method,headers:this.headers,body:e,keepalive:!0,signal:AbortSignal.timeout(5e3),priority:"low"});return{status:t.status,responseText:await t.text()}}async report(n,r,s){let i=JSON.stringify({platform:this.mt.platformName,projectId:this.mt.key,sessionId:this.mt.sessionId,data:n});const a=this.mt.options.reportEncryptSecret;if(a)try{"undefined"!=typeof crypto&&crypto.subtle?i=await async function(n,o){if("undefined"==typeof crypto||!crypto.subtle)throw new Error("当前环境不支持 Web Crypto(需 HTTPS 或 localhost)");if(!o||"string"!=typeof o)throw new Error("reportEncryptSecret 无效");const r=await async function(t){const n=await crypto.subtle.digest("SHA-256",e(t));return new Uint8Array(n)}(o),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,tagLength:128},s,e(n)),l=new Uint8Array(a);return JSON.stringify({v:1,encrypted:!0,alg:"AES-256-GCM",iv:t(i),data:t(l)})}(i,a):console.warn("埋点上报:当前环境不支持加密,已发送明文")}catch(e){console.warn("埋点上报加密失败,使用明文:",o(e))}try{let e;e=this.shouldUseFetch()?await this.reportWithFetch(i):await this.customRequest({method:this.method,url:this.url,headers:this.headers,data:i}),r&&r(e)}catch(e){s&&s(e),console.error("Request failed:",o(e))}}customRequest({method:e="GET",url:t,params:n={},data:o=null,headers:r={}}){return new Promise(((s,i)=>{const a=new XMLHttpRequest,l=new URLSearchParams(n).toString(),c=l?`${t}?${l}`:t;if(a.open(e,c,!0),r)for(const[e,t]of Object.entries(r))a.setRequestHeader(e,t);if(a.onload=function(){if(a.status>=200&&a.status<300)try{const e=JSON.parse(a.responseText);s({status:a.status,data:e,error:null})}catch(e){s({status:a.status,data:null,error:e})}else i(new Error(`Request failed with status ${a.status}: ${a.statusText}`))},a.onerror=function(){i(new Error("Network error: Failed to send request"))},a.ontimeout=function(){i(new Error("Request timeout"))},o)if("application/json"===r["Content-Type"])a.send("string"==typeof o?o:JSON.stringify(o));else{const e=new FormData;for(const[t,n]of Object.entries(o))e.append(t,n);a.send(e)}else a.send()}))}}const C="z-monitor-session-id";class y{constructor({mt:e},t){this.data=[],this.mt=e,this.HTTP_FAIL_COUNT=0,this.SESSION_RETRY_COUNT=0,this.MAX_SESSION_RETRY=3,this.MAX_HTTP_FAIL=t.MAX_HTTP_FAIL||20,this.max=t.max||20,this.type=t.type||"num",this.time=t.time||6e4,this.customMethod=t.customMethod||null,this.eventHandlers={unloadHandler:null,visibilityHandler:null},this.STORAGE_KEY=`monitor_not_uploaded_${this.mt.appName}`,this.unloadEvent="undefined"!=typeof window&&"onpagehide"in window?"pagehide":"beforeunload"}set isClose(e){e&&(this.cancelInterval(),this.clear())}setData(e){this.data=e}init(){n()&&(this.initUnloadHandler(),this.restoreUnsentData(),this.listenUnload(),"num"!==this.type&&this.openInterval())}initUnloadHandler(){this.eventHandlers.unloadHandler=e=>{var t;if("undefined"!=typeof localStorage&&("pagehide"!==this.unloadEvent||!e.persisted)&&null!==(t=this.data)&&void 0!==t&&t.length){const e=JSON.stringify(this.data);localStorage.setItem(this.STORAGE_KEY,e)}},this.eventHandlers.visibilityHandler=()=>{"undefined"!=typeof document&&"hidden"===document.visibilityState&&this.uploadData()}}restoreUnsentData(){if("undefined"!=typeof localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const t=JSON.parse(e);Array.isArray(t)&&(this.data=t.concat(this.data)),localStorage.removeItem(this.STORAGE_KEY)}else this.data=[]}catch(e){console.error("恢复未上报数据失败:",o(e))}}listenUnload(){"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener(this.unloadEvent,this.eventHandlers.unloadHandler),document.addEventListener("visibilitychange",this.eventHandlers.visibilityHandler))}openInterval(){this.cancelInterval(),this.interval=setInterval((()=>{this.uploadData()}),this.time)}cancelInterval(){window.clearInterval(this.interval),this.interval=null}push(e){if(!this.isClose){if(this.customMethod){let t=this.customMethod(e,[this]);if(s(t))return;e=t}this.data.push(e),"time"!==this.type&&this.data.length/this.max%1==0&&this.uploadData()}}async uploadData(){if(!this.data.length)return;const e=this.data.slice(0,this.data.length),t=e.length;this.mt.plugins.http.request(e,(async e=>{"undefined"!=typeof window&&(window.log_report=!1),[200,201].includes(e.status)?(this.data=this.data.slice(t,this.data.length),this.HTTP_FAIL_COUNT=0):this.handleUploadError(e.status)}),(e=>{console.error("日志上报失败:",o(e)),"undefined"!=typeof window&&(window.log_report=!1),this.handleUploadError(null)}))}async handleSessionError(){if(this.mt.emit("error",m),this.SESSION_RETRY_COUNT>=this.MAX_SESSION_RETRY)return console.error("重试次数达到上限,关闭日志收集"),void this.mt.close();this.SESSION_RETRY_COUNT++,console.warn(`SessionId 失效,尝试重新获取 (${this.SESSION_RETRY_COUNT}/${this.MAX_SESSION_RETRY})`);try{"undefined"!=typeof sessionStorage&&sessionStorage.removeItem(C),await this.mt.initSessionId(this.mt.options,!0),this.SESSION_RETRY_COUNT=0,this.uploadData()}catch(e){console.error("重新获取 sessionId 失败:",o(e)),this.mt.emit("error","SESSION_INIT_FAILED")}}handleUploadError(e){403===e?this.handleSessionError():(this.mt.emit("error","HTTP_FAIL"),this.HTTP_FAIL_COUNT++,this.HTTP_FAIL_COUNT>=this.MAX_HTTP_FAIL&&(console.error("重试次数达到上限,关闭日志收集"),this.mt.close()))}clear(){this.data=[],"undefined"!=typeof window&&window.removeEventListener(this.unloadEvent,this.eventHandlers.unloadHandler),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",this.eventHandlers.visibilityHandler)}}var v;function S(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function b(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function A(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(w).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function w(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=A(e.styleSheet)||t}catch(e){}return t}!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"}(v||(v={}));var E=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function R(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,s=e.maskInputFn,i=r||"";return(t[n.toLowerCase()]||t[o])&&(i=s?s(i):"*".repeat(i.length)),i}var k,M,T="__rrweb_original__",N=1,O=new RegExp("[^a-z0-9-_:]");function L(){return N++}var x=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,F=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,D=/^(data:)([^,]*),(.*)/i;function U(e,t){return(e||"").replace(x,(function(e,n,o,r,s,i){var a,l=o||s||i,c=n||r||"";if(!l)return e;if(!F.test(l))return"url(".concat(c).concat(l).concat(c,")");if(D.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=t.split("/"),u=l.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var m=p[h];"."!==m&&(".."===m?d.pop():d.push(m))}return"url(".concat(c).concat(d.join("/")).concat(c,")")}))}var _=/^[^ \t\n\r\u000c]+/,V=/^[, \t\n\r\u000c]+/;function W(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function B(){var e=document.createElement("a");return e.href="",e.href}function G(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?W(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(V),!(n>=t.length);){var s=o(_);if(","===s.slice(-1))s=W(e,s.substring(0,s.length-1)),r.push(s);else{var i="";s=W(e,s);for(var a=!1;;){var l=t.charAt(n);if(""===l){r.push((s+i).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+i).trim());break}"("===l&&(a=!0)}i+=l,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?U(o,B()):"object"===t&&"data"===n&&o?W(e,o):o:W(e,o)}function Z(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&Z(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&Z(e.parentNode,t,n)}function Y(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(Z(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function P(e){return void 0===e?"":e.toLowerCase()}function K(e,t){var n,o=t.doc,r=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,l=t.maskTextSelector,c=t.skipChild,d=void 0!==c&&c,u=t.inlineStylesheet,h=void 0===u||u,p=t.maskInputOptions,m=void 0===p?{}:p,g=t.maskTextFn,f=t.maskInputFn,I=t.slimDOMOptions,C=t.dataURLOptions,y=void 0===C?{}:C,w=t.inlineImages,E=void 0!==w&&w,N=t.recordCanvas,x=void 0!==N&&N,F=t.onSerialize,D=t.onIframeLoad,_=t.iframeLoadTimeout,V=void 0===_?5e3:_,W=t.onStylesheetLoad,Z=t.stylesheetLoadTimeout,H=void 0===Z?5e3:Z,J=t.keepIframeSrcFn,j=void 0===J?function(){return!1}:J,X=t.newlyAddedElement,z=void 0!==X&&X,q=t.preserveWhiteSpace,Q=void 0===q||q,$=function(e,t){var n=t.doc,o=t.mirror,r=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,l=t.inlineStylesheet,c=t.maskInputOptions,d=void 0===c?{}:c,u=t.maskTextFn,h=t.maskInputFn,p=t.dataURLOptions,m=void 0===p?{}:p,g=t.inlineImages,f=t.recordCanvas,I=t.keepIframeSrcFn,C=t.newlyAddedElement,y=void 0!==C&&C,S=function(e,t){if(t.hasNode(e)){var n=t.getId(e);return 1===n?void 0:n}}(n,o);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:v.Document,childNodes:[],compatMode:e.compatMode}:{type:v.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:v.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:S};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,o=t.inlineStylesheet,r=t.maskInputOptions,s=void 0===r?{}:r,i=t.maskInputFn,a=t.dataURLOptions,l=void 0===a?{}:a,c=t.inlineImages,d=t.recordCanvas,u=t.keepIframeSrcFn,h=t.newlyAddedElement,p=void 0!==h&&h,m=t.rootId,g=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,t.blockClass,t.blockSelector),f=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return O.test(t)?"div":t}(e),I={},C=e.attributes.length,y=0;y<C;y++){var S=e.attributes[y];I[S.name]=G(n,f,S.name,S.value)}if("link"===f&&o){var b=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),w=null;b&&(w=A(b)),w&&(delete I.rel,delete I.href,I._cssText=U(w,b.href))}if("style"===f&&e.sheet&&!(e.innerText||e.textContent||"").trim().length&&(w=A(e.sheet))&&(I._cssText=U(w,B())),"input"===f||"textarea"===f||"select"===f){var E=e.value,N=e.checked;"radio"!==I.type&&"checkbox"!==I.type&&"submit"!==I.type&&"button"!==I.type&&E?I.value=R({type:I.type,tagName:f,value:E,maskInputOptions:s,maskInputFn:i}):N&&(I.checked=N)}if("option"===f&&(e.selected&&!s.select?I.selected=!0:delete I.selected),"canvas"===f&&d)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,s=T in r?r[T]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(I.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){var L=e.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,L!==x.toDataURL(l.type,l.quality)&&(I.rr_dataURL=L)}if("img"===f&&c){k||(k=n.createElement("canvas"),M=k.getContext("2d"));var F=e,D=F.crossOrigin;F.crossOrigin="anonymous";var _=function(){try{k.width=F.naturalWidth,k.height=F.naturalHeight,M.drawImage(F,0,0),I.rr_dataURL=k.toDataURL(l.type,l.quality)}catch(e){console.warn("Cannot inline img src=".concat(F.currentSrc,"! Error: ").concat(e))}D?I.crossOrigin=D:F.removeAttribute("crossorigin")};F.complete&&0!==F.naturalWidth?_():F.onload=_}if("audio"!==f&&"video"!==f||(I.rr_mediaState=e.paused?"paused":"played",I.rr_mediaCurrentTime=e.currentTime),p||(e.scrollLeft&&(I.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(I.rr_scrollTop=e.scrollTop)),g){var V=e.getBoundingClientRect(),W=V.width,Z=V.height;I={class:I.class,rr_width:"".concat(W,"px"),rr_height:"".concat(Z,"px")}}return"iframe"!==f||u(I.src)||(e.contentDocument||(I.rr_src=I.src),delete I.src),{type:v.Element,tagName:f,attributes:I,childNodes:[],isSVG:(Y=e,Boolean("svg"===Y.tagName||Y.ownerSVGElement)||void 0),needBlock:g,rootId:m};var Y}(e,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:h,dataURLOptions:m,inlineImages:g,recordCanvas:f,keepIframeSrcFn:I,newlyAddedElement:y,rootId:S});case e.TEXT_NODE:return function(e,t){var n,o,r=t.maskTextClass,s=t.maskTextSelector,i=t.maskTextFn,a=t.rootId,l=e.parentNode&&e.parentNode.tagName,c=e.textContent,d="STYLE"===l||void 0,u="SCRIPT"===l||void 0;if(d&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(o=e.parentNode.sheet).cssRules?Array.from(o.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=U(c,B())}return u&&(c="SCRIPT_PLACEHOLDER"),!d&&!u&&c&&Y(e,r,s)&&(c=i?i(c):c.replace(/[\S]/g,"*")),{type:v.Text,textContent:c||"",isStyle:d,rootId:a}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:u,rootId:S});case e.CDATA_SECTION_NODE:return{type:v.CDATA,textContent:"",rootId:S};case e.COMMENT_NODE:return{type:v.Comment,textContent:e.textContent||"",rootId:S};default:return!1}}(e,{doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,dataURLOptions:y,inlineImages:E,recordCanvas:x,keepIframeSrcFn:j,newlyAddedElement:z});if(!$)return console.warn(e,"not serialized"),null;n=r.hasNode(e)?r.getId(e):!function(e,t){if(t.comment&&e.type===v.Comment)return!0;if(e.type===v.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(P(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===P(e.attributes.name)||"icon"===P(e.attributes.rel)||"apple-touch-icon"===P(e.attributes.rel)||"shortcut icon"===P(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&P(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(P(e.attributes.property).match(/^(og|twitter|fb):/)||P(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===P(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===P(e.attributes.name)||"googlebot"===P(e.attributes.name)||"bingbot"===P(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===P(e.attributes.name)||"generator"===P(e.attributes.name)||"framework"===P(e.attributes.name)||"publisher"===P(e.attributes.name)||"progid"===P(e.attributes.name)||P(e.attributes.property).match(/^article:/)||P(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===P(e.attributes.name)||"yandex-verification"===P(e.attributes.name)||"csrf-token"===P(e.attributes.name)||"p:domain_verify"===P(e.attributes.name)||"verify-v1"===P(e.attributes.name)||"verification"===P(e.attributes.name)||"shopify-checkout-api-token"===P(e.attributes.name)))return!0}}return!1}($,I)&&(Q||$.type!==v.Text||$.isStyle||$.textContent.replace(/^\s+|\s+$/gm,"").length)?L():-2;var ee=Object.assign($,{id:n});if(r.add(e,ee),-2===n)return null;F&&F(e);var te=!d;if(ee.type===v.Element){te=te&&!ee.needBlock,delete ee.needBlock;var ne=e.shadowRoot;ne&&b(ne)&&(ee.isShadowHost=!0)}if((ee.type===v.Document||ee.type===v.Element)&&te){I.headWhitespace&&ee.type===v.Element&&"head"===ee.tagName&&(Q=!1);for(var oe={doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j},re=0,se=Array.from(e.childNodes);re<se.length;re++)(le=K(se[re],oe))&&ee.childNodes.push(le);if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var ie=0,ae=Array.from(e.shadowRoot.childNodes);ie<ae.length;ie++){var le;(le=K(ae[ie],oe))&&(b(e.shadowRoot)&&(le.isShadow=!0),ee.childNodes.push(le))}}return e.parentNode&&S(e.parentNode)&&b(e.parentNode)&&(ee.isShadow=!0),ee.type===v.Element&&"iframe"===ee.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var i="about:blank";if(o.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&D){var n=K(t,{doc:t,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j});n&&D(e,n)}}),V),ee.type===v.Element&&"link"===ee.tagName&&"stylesheet"===ee.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var s=setTimeout((function(){r||(t(),r=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),r=!0,t()}))}}(e,(function(){if(W){var t=K(e,{doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j});t&&W(e,t)}}),H),ee}function H(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const J="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let j={map:{},getId:()=>(console.error(J),-1),getNode:()=>(console.error(J),null),removeNodeFromMap(){console.error(J)},has:()=>(console.error(J),!1),reset(){console.error(J)}};function X(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),l=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(l,s)):o||!1===n.trailing||(o=setTimeout((()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(l,s)}),a))}}function z(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>z(e,t,s||{},!0)}function q(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}function Q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function $(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function ee(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(Z(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function te(e,t){return-2===t.getId(e)}function ne(e,t){if(S(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ne(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function re(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function se(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ie(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:(e,t,n)=>("map"===t&&console.error(J),Reflect.get(e,t,n))}));class ae{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var le=(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))(le||{}),ce=(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))(ce||{}),de=(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))(de||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{});function he(e){return"__ln"in e}class pe{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&he(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&he(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const me=(e,t)=>`${e}@${t}`;class ge{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=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new pe,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,s,i,a;let l=null;(null===(s=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(l=o.getRootNode().host);let c=l;for(;(null===(a=null===(i=null==c?void 0:c.getRootNode)||void 0===i?void 0:i.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(o)||c&&this.doc.contains(c));if(!o.parentNode||d)return;const u=S(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),h=n(o);if(-1===u||-1===h)return t.addNode(o);const p=K(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{re(e,this.mirror)&&this.iframeManager.addIframe(e),se(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ie(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});p&&e.push({parentId:u,nextId:h,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))Ie(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ye(this.droppedSet,e)||Ie(this.removes,e,this.mirror)?ye(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!te(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;ee(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Y(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=R({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),ee(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(r[e]=""===s?o:[o,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=G(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(ee(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),o=S(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);ee(e.target,this.blockClass,this.blockSelector,!1)||te(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(fe(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ne(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[me(n,o)]?fe(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!S(e.target)||!b(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(te(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[me(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);ee(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function fe(e,t){e.delete(t),t.childNodes.forEach((t=>fe(e,t)))}function Ie(e,t,n){return 0!==e.length&&Ce(e,t,n)}function Ce(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some((e=>e.id===r))||Ce(e,o,n)}function ye(e,t){return 0!==e.size&&ve(e,t)}function ve(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ve(e,n))}const Se=[],be="undefined"!=typeof CSSGroupingRule,Ae="undefined"!=typeof CSSMediaRule,we="undefined"!=typeof CSSSupportsRule,Ee="undefined"!=typeof CSSConditionRule;function Re(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(t){return e.target}}function ke(e,t){var n,o;const r=new ge;Se.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Me({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return H("scroll",X((s=>{const i=Re(s);if(!i||ee(i,o,r,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Te(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const Ne=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function Le(e){return function(e,t){if(be&&e.parentRule instanceof CSSGroupingRule||Ae&&e.parentRule instanceof CSSMediaRule||we&&e.parentRule instanceof CSSSupportsRule||Ee&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function xe(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function Fe({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null===(e=l.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=l.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function De(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const o=ke(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const l=X((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),c=X((e=>{const t=Re(e),{clientX:n,clientY:r}=oe(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-i}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?ce.Drag:e instanceof MouseEvent?ce.MouseMove:ce.TouchMove)}),r,{trailing:!1}),d=[H("mousemove",c,n),H("touchmove",c,n),H("drag",c,n)];return()=>{d.forEach((e=>e()))}}(e),s=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(de).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),l=(t=>s=>{const i=Re(s);if(ee(i,o,r,!0))return;const a=oe(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(i),{clientX:c,clientY:d}=a;e({type:de[t],id:l,x:c,y:d})})(s);a.push(H(i,l,t))})),()=>{a.forEach((e=>e()))}}(e),i=Me(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return H("resize",X((()=>{const o=Q(),r=$();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)}),200),window)}(e),l=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(e){let n=Re(e);const l=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||Ne.indexOf(n.tagName)<0||ee(n,o,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=R({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Te({text:h,isChecked:p,userTriggered:l},c));const m=n.name;"radio"===d&&m&&p&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&u(e,Te({text:e.value,isChecked:!p,userTriggered:!1},c))}))}function u(t,o){const r=Oe.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){Oe.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const h=("last"===l.input?["change"]:["input","change"]).map((e=>H(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),g=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map((e=>z(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const s=s=>X((r=>{const i=Re(r);if(!i||ee(i,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=i;e({type:s,id:o.getId(i),currentTime:a,volume:l,muted:c,playbackRate:d})}),r.media||500),i=[H("play",s(0)),H("pause",s(1)),H("seeked",s(2)),H("volumechange",s(3)),H("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,s){const{id:i,styleId:a}=xe(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:s}]}),r.apply(this,[o,s])};const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:i}=xe(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,removes:[{index:o}]}),s.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:s}=xe(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replace:o}),i.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:s}=xe(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replaceSync:o}),a.apply(this,[o])});const l={};be?l.CSSGroupingRule=o.CSSGroupingRule:(Ae&&(l.CSSMediaRule=o.CSSMediaRule),Ee&&(l.CSSConditionRule=o.CSSConditionRule),we&&(l.CSSSupportsRule=o.CSSSupportsRule));const c={};return Object.entries(l).forEach((([o,r])=>{c[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:i,styleId:a}=xe(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:[...Le(this),s||0]}]}),c[o].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:i}=xe(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Le(this),r]}]}),c[o].deleteRule.apply(this,[r])}})),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach((([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule}))}}(e,{win:n}),u=Fe(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,i,a){var l;if(n.has(r))return s.apply(this,[r,i,a]);const{id:c,styleId:d}=xe(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(c&&-1!==c||d&&-1!==d)&&e({id:c,styleId:d,set:{property:r,value:i,priority:a},index:Le(this.parentRule)}),s.apply(this,[r,i,a])};const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return i.apply(this,[r]);const{id:a,styleId:l}=xe(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,remove:{property:r},index:Le(this.parentRule)}),i.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=q(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}}));return o.push((()=>{n.FontFace=s})),o.push(i),()=>{o.forEach((e=>e()))}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:l,endContainer:c,endOffset:d}=s;ee(i,o,r,!0)||ee(c,o,r,!0)||a.push({start:n.getId(i),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),H("selectionchange",a)}(e),g=[];for(const t of e.plugins)g.push(t.observer(t.callback,n,t.options));return()=>{Se.forEach((e=>e.reset())),o.disconnect(),r(),s(),i(),a(),l(),c(),d(),u(),h(),p(),m(),g.forEach((e=>e()))}}class Ue{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,o)))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;return o.get(t)||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class _e{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Ue(L),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ue(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case le.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:le.IncrementalSnapshot,data:{source:ce.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case le.Meta:case le.Load:case le.DomContentLoaded:return!1;case le.Plugin:return t;case le.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case le.IncrementalSnapshot:switch(t.data.source){case ce.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ce.Drag:case ce.TouchMove:case ce.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ce.ViewportResize:return!1;case ce.MediaInteraction:case ce.MouseInteraction:case ce.Scroll:case ce.CanvasMutation:case ce.Input:return this.replaceIds(t.data,e,["id"]),t;case ce.StyleSheetRule:case ce.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ce.Font:return t;case ce.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ce.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class Ve{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(q(Element.prototype,"attachShadow",(function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}})))}addShadowRoot(e,t){b(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ke(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Me(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Fe({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(q(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */for(var We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Be="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ge=0;Ge<64;Ge++)Be[We.charCodeAt(Ge)]=Ge;const Ze=new Map,Ye=(e,t,n)=>{if(!e||!He(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Ze.get(e);return n||(n=new Map,Ze.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function Pe(e,t,n){if(e instanceof Array)return e.map((e=>Pe(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),o=n.length,r="";for(t=0;t<o;t+=3)r+=We[n[t]>>2],r+=We[(3&n[t])<<4|n[t+1]>>4],r+=We[(15&n[t+1])<<2|n[t+2]>>6],r+=We[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Pe(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Pe(e.data,t,n),e.width,e.height]}:He(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ye(e,t,n)}:e}const Ke=(e,t,n)=>[...e].map((e=>Pe(e,t,n))),He=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Je(e,t,n){const o=[];try{const r=q(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...r){return ee(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}}));o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function je(e,t,n,o,r,s,i){const a=[],l=Object.getOwnPropertyNames(e);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const l=q(e,s,(function(e){return function(...a){const l=e.apply(this,a);if(Ye(l,i,this),!ee(this.canvas,o,r,!0)){const e=Ke([...a],i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return l}}));a.push(l)}catch(o){const r=z(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var Xe=null;try{var ze="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Xe=ze.Worker}catch(e){}var qe,Qe=(qe="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=","[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(e){var t=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),n=t.indexOf("\n",10)+1,o=t.substring(n)+"";return function(e){return new Xe(o,Object.assign({},e,{eval:!0}))}}(qe):function(e){var t;return function(n){return t=t||function(e){var t=function(e){return atob(e)}(e),n=t.indexOf("\n",10)+1,o=t.substring(n)+"",r=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(r)}(e),new Worker(t,n)}}(qe));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:i})}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(e,t,n,o,r){const s=Je(t,n,o),i=new Map,a=new Qe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:ue["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{ee(t,n,o,!0)||e.push(t)})),e})().forEach((e=>{return t=this,o=function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])},new((n=void 0)||(n=Promise))((function(e,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(t){var o;t.done?e(t.value):(o=t.value,o instanceof n?o:new n((function(e){e(o)}))).then(s,i)}a((o=o.apply(t,[])).next())}));var t,n,o}))),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Je(e,t,n),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=q(t.CanvasRenderingContext2D.prototype,i,(function(r){return function(...s){return ee(this.canvas,n,o,!0)||setTimeout((()=>{const n=Ke([...s],t,this);e(this.canvas,{type:ue["2D"],property:i,args:n})}),0),r.apply(this,s)}}));r.push(s)}catch(n){const o=z(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:ue["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...je(t.WebGLRenderingContext.prototype,ue.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...je(t.WebGL2RenderingContext.prototype,ue.WebGL2,e,n,o,0,t)),()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const o=n.map((e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t})),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ae,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},o=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);o.push({styleId:e,rules:n.map(((e,t)=>({rule:w(e),index:t})))})}n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,ot,rt,st=!1;const it=new E;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:m,hooks:g,packFn:f,sampling:I={},dataURLOptions:C={},mousemoveWait:y,recordCanvas:v=!1,recordCrossOriginIframes:S=!1,userTriggeredOnInput:b=!1,collectFonts:A=!1,inlineImages:w=!1,plugins:R,keepIframeSrcFn:k=()=>!1,ignoreCSSAttributes:M=new Set([])}=e,T=!S||window.parent===window;let N=!1;if(!T)try{window.parent.document,N=!1}catch(e){N=!0}if(T&&!t)throw new Error("emit function is required");void 0!==y&&void 0===I.mousemove&&(I.mousemove=y),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},L=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const D=e=>{for(const t of R||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};nt=(e,r)=>{var s;if(!(null===(s=Se[0])||void 0===s?void 0:s.isFrozen())||e.type===le.FullSnapshot||e.type===le.IncrementalSnapshot&&e.data.source===ce.Mutation||Se.forEach((e=>e.unfreeze())),T)null==t||t(D(e),r);else if(N){const t={type:"rrweb",event:D(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===le.FullSnapshot)x=e,F=0;else if(e.type===le.IncrementalSnapshot){if(e.data.source===ce.Mutation&&e.data.isAttachIframe)return;F++;const t=o&&F>=o,r=n&&e.timestamp-x.timestamp>n;(t||r)&&ot(!0)}};const U=e=>{nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Mutation},e)}))},_=e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Scroll},e)})),V=e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.CanvasMutation},e)})),W=new et({mutationCb:U,adoptedStyleSheetCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.AdoptedStyleSheet},e)}))}),B=new _e({mirror:it,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:S,wrappedEmit:nt});for(const e of R||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:B.crossOriginIframeMirror,crossOriginIframeStyleMirror:B.crossOriginIframeStyleMirror});rt=new $e({recordCanvas:v,mutationCb:V,win:window,blockClass:r,blockSelector:s,mirror:it,sampling:I.canvas,dataURLOptions:C});const G=new Ve({mutationCb:U,scrollCb:_,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:O,dataURLOptions:C,maskTextFn:m,maskInputFn:p,recordCanvas:v,inlineImages:w,sampling:I,slimDOMOptions:L,iframeManager:B,stylesheetManager:W,canvasManager:rt,keepIframeSrcFn:k},mirror:it});ot=(e=!1)=>{var t,n,o,i,d,u;nt(tt({type:le.Meta,data:{href:window.location.href,width:$(),height:Q()}}),e),W.reset(),Se.forEach((e=>e.lock()));const h=function(e,t){var n=t,o=n.mirror,r=void 0===o?new E:o,s=n.blockClass,i=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,u=n.recordCanvas,h=n.maskAllInputs,p=void 0!==h&&h,m=n.slimDOM,g=void 0!==m&&m,f=n.keepIframeSrcFn;return K(e,{doc:e,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===i?null:i,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===p?{password:!0}:p,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===g,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===g?{}:g,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==u&&u,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:it,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:O,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:v,inlineImages:w,onSerialize:e=>{re(e,it)&&B.addIframe(e),se(e,it)&&W.trackLinkElement(e),ie(e)&&G.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{B.attachIframe(e,t),G.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:k});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:le.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),Se.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(H("DOMContentLoaded",(()=>{nt(tt({type:le.DomContentLoaded,data:{}}))})));const t=e=>{var t;return De({mutationCb:U,mousemoveCb:(e,t)=>nt(tt({type:le.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.MouseInteraction},e)})),scrollCb:_,viewportResizeCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.ViewportResize},e)})),inputCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Input},e)})),mediaInteractionCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.StyleDeclaration},e)})),canvasMutationCb:V,fontCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Font},e)})),selectionCb:e=>{nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Selection},e)}))},blockClass:r,ignoreClass:i,maskTextClass:a,maskTextSelector:l,maskInputOptions:O,inlineStylesheet:c,sampling:I,recordCanvas:v,inlineImages:w,userTriggeredOnInput:b,collectFonts:A,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:k,blockSelector:s,slimDOMOptions:L,dataURLOptions:C,mirror:it,iframeManager:B,stylesheetManager:W,shadowDomManager:G,canvasManager:rt,ignoreCSSAttributes:M,plugins:(null===(t=null==R?void 0:R.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:le.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},g)};B.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{ot(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(H("load",(()=>{nt(tt({type:le.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:le.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{Se.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");ot(e)},at.mirror=it;const lt={ajax:{req:!0,excludeUrls:[],customMethod:e=>e},log:{type:"time",time:3e4,MAX_HTTP_FAIL:3,customMethod:null},click:{isPartial:!1,globalDebounce:void 0,partialAttribute:"data-monitor",debounceAttribute:"data-monitor-debounce"},http:{isCustomRequest:!1,requestConfig:{method:"POST",headers:{"Content-Type":"application/json"}},customMethod:null},userInfo:{getData:null},videoRecord:{waitTime:2e3,checkoutEveryNth:300,customRecordId:""},pagePerformance:{entryTypes:["paint","resource","longtask","first-input","largest-contentful-paint"]}};class ct{constructor(e){console.log("Monitor加载..."),e.key?(this.key=e.key,this.log=null,this.plugins={},this.options=e,this.commonParams=[],this.events={},this.platform=null,this.platformName=null,this.sessionId=null,this.retryCount=0,this.MAX_RETRY_COUNT=3,this.baseInfo=null,this.beforeReport=e.beforeReport||null,this.sampleRate=function(e){if(null==e||""===e)return 1;const t=Number(e);return Number.isFinite(t)?t<=0?0:t>=1?1:t:(r("sampleRate 无效,使用默认 1","warn"),1)}(e.sampleRate),this.sampleMode="event"===e.sampleMode?"event":"session",this.sampleRate>=1?this._sampleAllowed=!0:this.sampleRate<=0?this._sampleAllowed=!1:this._sampleAllowed=Math.random()<this.sampleRate,this.init(e)):console.error("没有设置key值,请传递一个唯一的key值保证功能使用")}async init(e){if(n()){console.log("Monitor init"),this.initGlobal(),this.initBaseInfo(),this.initOptions(e),this.initClass(e);try{await this.initSessionId(e)}catch(e){var t;console.error(null!==(t=null==e?void 0:e.message)&&void 0!==t?t:"SessionId init failed")}}}async initSessionId(e,t=!1){if(n())try{var r;if(!t){if(this.sessionId)return;const e="undefined"!=typeof sessionStorage?sessionStorage.getItem(C):null;if(e)return void(this.sessionId=e)}const n=await this.plugins.http.customRequest({method:"GET",url:(e.url||"http://43.136.119.247")+"/session/id"});if(!n||null===(r=n.data)||void 0===r||!r.sessionId)throw new Error("无效的响应数据");var s;this.sessionId=null===(s=n.data)||void 0===s?void 0:s.sessionId,"undefined"!=typeof sessionStorage&&sessionStorage.setItem(C,this.sessionId),console.log("SessionId 初始化成功:",this.sessionId)}catch(t){if(this.retryCount++,console.error(`SessionId 初始化失败,重试次数: ${this.retryCount}`,o(t)),!(this.retryCount<this.MAX_RETRY_COUNT))throw console.error("重试次数达到上限,关闭埋点功能"),this.close(),this.emit("error",m),new Error("初始失败:无法获取 sessionId");console.log("重试中..."),await this.initSessionId(e,!0)}}initGlobal(){this.TYPES={...u},this.LEVELS={...h}}initOptions(){this.appName=this.key+"-Monitor"}initBaseInfo(){if(!n())return;const e=(new Date).getTimezoneOffset(),t=(e>0?"-":"+")+Math.floor(Math.abs(e)/60),o="undefined"!=typeof navigator?navigator:{},r=o.connection||o.mozConnection||o.webkitConnection||{};this.baseInfo={timezone:t,language:o.language||o.userLanguage||"en",deviceInfo:{userAgent:o.userAgent||"",networkInfo:{downlink:r.downlink,effectiveType:r.effectiveType,type:r.type,rtt:r.rtt,saveData:r.saveData}}}}initClass(){this.pluginCall("log",y),this.pluginCall("http",I)}isInnerPlugins(e){return["log","http"].includes(e)}pluginCall(e,t){try{let n=function(e,t){return e&&e[t]||{}}(this.options.plugins,e);this.plugins[e]=new t({mt:this,options:this.options,name:e},n);const o=this.plugins[e];"http"===e&&(n={...n,url:this.options.url}),o.init&&o.init(n)}catch(t){console.warn("插件注册错误",e,o(t)),this.emit("error",p)}}pluginDestroy(e){this.plugins[e]?(this.plugins[e].isClose=!0,this.plugins[e].destroy&&this.plugins[e].destroy(),setTimeout((()=>{delete this.plugins[e]}))):console.error(`插件${e}不存在`)}close(){this.plugins.log.isClose=!0;for(let e in this.plugins)this.isInnerPlugins(e)||this.pluginDestroy(e)}addCommonData(e,t,n){!function(e){return null!=e}(n)?r(`${t} 必须要设置`):this[e][t]?r(`${t} 已经存在,其值为${this[e][t]}`):this[e][t]=n}assignConfig(e){return{...this.getCommonConfig(e),...e}}shouldSample(){return this.sampleRate>=1||!(this.sampleRate<=0)&&("session"===this.sampleMode?this._sampleAllowed:Math.random()<this.sampleRate)}send(e){this.shouldSample()&&(e=this.assignConfig(e),this.plugins.log.push(e))}getCommonConfig(){var e,t,o,s;if(!n())return{info:{pageTitle:"",pageUrl:"",timezone:"",language:"",deviceInfo:{},locationInfo:{}}};this.initBaseInfo();let a={info:{pageTitle:"undefined"!=typeof document?document.title:"",pageUrl:"undefined"!=typeof window?window.location.href:"",timezone:null===(e=this.baseInfo)||void 0===e?void 0:e.timezone,language:null===(t=this.baseInfo)||void 0===t?void 0:t.language,deviceInfo:(null===(o=this.baseInfo)||void 0===o?void 0:o.deviceInfo)||{},locationInfo:(null===(s=this.baseInfo)||void 0===s?void 0:s.locationInfo)||{}}};const l=this.commonParams.length;if(l)for(let e=0;e<=l-1;e++){const t=this.commonParams[e](a);i(t,"object")?a=t:r(`setCommonConfig 传递函数需要\n${this.commonParams[e].toString()}\n返回值不是 object 类型`,"warn")}return a}setCommonConfig(e){i(e,"function")?this.commonParams.push(e):r("setCommonConfig 方法必须要传递函数类型","error")}emit(e,t){this.events[e]&&this.events[e](t)}on(e,t){this.events[e]=t}off(e){delete this.events[e]}clear(){this.plugins.log.clear()}}function dt(e,t){return e?t?(t.platformName="React",t.platform=e,function(n){var o;const r=null===(o=t.plugins.platform_error)||void 0===o?void 0:o.ErrorBoundary;function s(t){return r?e.createElement(r,{fallback:t.fallback},e.createElement(n,t)):(console.warn("错误边界不可用, 已跳过"),e.createElement(n,t))}return s.displayName=`withErrorBoundary(${n.displayName||n.name||"Component"})`,s}):console.error("必须要传入monitor实例"):console.error("必须要传入React")}class ut extends g{init(){if("React"!==this.mt.platformName)return console.error("检测当前不是react app环境,必须调用register(React)(monitor)注册");console.log("React Error init");const e=this.mt.platform,t=this;class n extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){((e,n)=>{t.isClose||t.send({type:t.TYPES.CODE_ERROR,level:t.LEVELS.ERROR,data:{message:e.message,stack:n.componentStack,targetType:"组件边界错误",vmName:n.componentName}})})(e,n)}render(){return this.state.hasError?this.props.fallback||e.createElement("h1",null,"Something went wrong."):this.props.children}}this.ErrorBoundary=n}}class ht extends g{init(){if("React"!==this.mt.platformName)return console.error("检测当前不是react app环境,必须调用register(React)(monitor)注册");this.addCommonData("TYPES","ROUTER",{text:"页面跳转",value:"ROUTER.CHANGE"})}sendRouteChange(e,t){this.isClose||this.send({type:this.TYPES.ROUTER,level:this.LEVELS.INFO,data:{fromPath:t.pathname||t,toPath:e.pathname||e,fromTitle:t.name||("undefined"!=typeof document?document.title:"")}})}}function pt(e,t,n,o){var r,s,i;const a="undefined"!=typeof window&&window.__NEXT_DATA__&&document.getElementById("__next"),l=null!==(r=null!==(s=null==n||null===(i=n.location)||void 0===i?void 0:i.pathname)&&void 0!==s?s:o)&&void 0!==r?r:"",[c,d]=t.useState(l),u=t.useRef(!1);t.useEffect((()=>{var t,r;if(!e||"undefined"==typeof window)return;const s=null==e||null===(t=e.plugins)||void 0===t?void 0:t.routerChange,i=null==e||null===(r=e.plugins)||void 0===r?void 0:r.pagePerformance;if(!s)return;if(void 0!==o){const e=null!=o?o:"";return u.current?void(c!==e&&(s.sendRouteChange({pathname:e},{pathname:c}),i&&(i.stopRouteMonitoring(c),i.startRouteMonitoring(e)),d(e))):(u.current=!0,s.sendRouteChange({pathname:e},{pathname:"",name:"initial"}),i&&i.startRouteMonitoring(e),void d(e))}if(!n)return;const l=(e,t)=>{const n="string"==typeof e?{pathname:e}:e,o="string"==typeof t?{pathname:t}:t;s.sendRouteChange(n,o),i&&(c!==(n.pathname||e)&&i.stopRouteMonitoring(c),i.startRouteMonitoring(n.pathname||e))};if(a){const e=(e,{shallow:t})=>{t||l(e,c)};return n.events.on("routeChangeComplete",e),()=>n.events.off("routeChangeComplete",e)}{const e=n.listen((e=>{l(e.pathname,c),d(e.pathname)}));return()=>e()}}),[e,a,n,o,c])}class mt extends g{init(e={}){"undefined"!=typeof window&&(this.observers=new Map,this.currentRoute=null,this.entryTypes=e.entryTypes||["navigation","resource"],this.startRouteMonitoring(window.location.pathname))}startRouteMonitoring(e){var t;if("undefined"==typeof window||"undefined"==typeof PerformanceObserver)return;if(null!==(t=this.observers)&&void 0!==t&&t.has(e))return;const n=new PerformanceObserver((e=>{e.getEntries().forEach((e=>{this.send({type:this.TYPES.PERFORMANCE,level:this.LEVELS.INFO,data:e})}))}));n.observe({entryTypes:this.entryTypes}),this.observers.set(e,n),this.currentRoute=e}stopRouteMonitoring(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e))}destroy(){this.observers.forEach((e=>e.disconnect())),this.observers.clear()}}function gt(e){if("react"===e)return{register:dt,ERROR:ut,RouterMonitorPlugin:ht,PerformanceMonitorPlugin:mt,useRouterMonitor:pt}}const ft={url:"http://43.136.119.247",platform:"react",key:"z-app",trackList:["userInfo"]},It={click:class extends g{init(e){"undefined"!=typeof window&&(console.log("Click init"),this.options=e,this.debounceMap=new Map,this.clickEvent=e=>this.handleClick(e),window.addEventListener("mouseup",this.clickEvent))}handleClick(e){try{const t=e.target,{isPartial:n,partialAttribute:o,debounceAttribute:r,globalDebounce:s}=this.options;if(!l(t))return;const i=function(e,t){let n=e;for(;n;){if(n.hasAttribute(t))return n;n=n.parentElement}return null}(t,o);if(n&&!i)return;if(this.debounceMap.has(i))return;const c=s||function(e,t){let n=e;for(;n;){const e=n.getAttribute(t);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0)return t}n=n.parentElement}return null}(i,r);c&&function(e,t,n){const o=Math.min(t,5e3);if(n.size>=1e3){const e=n.keys().next().value;n.delete(e)}n.set(e,Date.now()),setTimeout((()=>{n.delete(e)}),o)}(i,c,this.debounceMap);const u=function(e){return e.path||e.composedPath&&e.composedPath()||""}(e);this.send({type:this.TYPES.CLICK,level:this.LEVELS.INFO,data:{target:a(u[0],!0),path:d(u)}})}catch(e){this.mt.emit("error",p,e),this.destroy()}}destroy(){this.debounceMap.clear(),"undefined"!=typeof window&&window.removeEventListener("mouseup",this.clickEvent)}},ERROR:class extends g{init(e){"undefined"!=typeof window&&(console.log("error init"),this.options=e,this.errorEvent=e=>this.handleError(e),window.addEventListener("error",this.errorEvent,!0))}handleErrorType(e){var t,n,o,r,s,i,a,l,c,d,u;let h="错误";return"VIDEO"===(null==e||null===(t=e.target)||void 0===t?void 0:t.tagName)||"SOURCE"===(null==e||null===(n=e.target)||void 0===n?void 0:n.tagName)&&"VIDEO"===(null==e||null===(o=e.target)||void 0===o||null===(r=o.parentElement)||void 0===r?void 0:r.tagName)?h="错误-视频资源加载异常":"IMG"===(null==e||null===(s=e.target)||void 0===s?void 0:s.tagName)?h="错误-图片资源加载异常":"AUDIO"===(null==e||null===(i=e.target)||void 0===i?void 0:i.tagName)||"SOURCE"===(null==e||null===(a=e.target)||void 0===a?void 0:a.tagName)&&"AUDIO"===(null==e||null===(l=e.target)||void 0===l||null===(c=l.parentElement)||void 0===c?void 0:c.tagName)?h="错误-音频资源加载异常":"SCRIPT"===(null==e||null===(d=e.target)||void 0===d?void 0:d.tagName)?h="错误-脚本资源加载异常":"STYLE"===(null==e||null===(u=e.target)||void 0===u?void 0:u.tagName)&&(h="错误-样式资源加载异常"),h}handleError(e){var t,n,o,r,s,i,a;const l=null!==(t=null!==(n=e.message)&&void 0!==n?n:null===(o=e.reason)||void 0===o?void 0:o.message)&&void 0!==t?t:null,c=null!==(r=null!==(s=null===(i=e.error)||void 0===i?void 0:i.stack)&&void 0!==s?s:null===(a=e.reason)||void 0===a?void 0:a.stack)&&void 0!==r?r:null,d=this.handleErrorType(e);this.send({type:this.TYPES.CODE_ERROR,level:this.LEVELS.ERROR,data:{message:l,stack:c,targetType:d}})}destroy(){"undefined"!=typeof window&&window.removeEventListener("error",this.errorEvent)}},reject_error:class extends g{init(e){"undefined"!=typeof window&&(console.log("reject init"),this.options=e,this.errorEvent=e=>this.handleError(e),window.addEventListener("unhandledrejection",this.errorEvent,!0))}handleError(e){const{reason:t={}}=e,{message:n=null,stack:o=null}=t;this.send({type:this.TYPES.CODE_ERROR,level:this.LEVELS.ERROR,data:{message:n,stack:o,targetType:"异步错误"}})}destroy(){"undefined"!=typeof window&&window.removeEventListener("unhandledrejection",this.errorEvent)}},count:class extends g{init(){if(console.log("COUNT init"),this._lastStorySend={},!this.isClose){this.addCommonData("TYPES","COUNT",{text:"点击统计",value:"UI.COUNT"}),this.addCommonData("TYPES","STORY",{text:"用户故事",value:"UI.STORY"});const e=this;this.mt.startRecord=(...t)=>e.startRecord(...t),this.mt.endRecord=(...t)=>e.endRecord(...t),this.mt.count=(...t)=>e.count(...t)}}_shouldSkipStory(e,t){const n=`${e}_${t}`,o=Date.now(),r=this._lastStorySend[n];return!!(r&&o-r<100)||(this._lastStorySend[n]=o,!1)}startRecord(e,t={},n=null){if(this._shouldSkipStory(e,0))return;const o={type:this.TYPES.STORY,level:this.LEVELS.INFO,data:{name:e,storyEnd:0,isStory:1,...t}};n&&(o.time=n),this.send(o)}endRecord(e){this._shouldSkipStory(e,1)||this.send({type:this.TYPES.STORY,level:this.LEVELS.INFO,data:{name:e,storyEnd:1,isStory:1}})}count(e,t={}){this.send({type:this.TYPES.COUNT,level:this.LEVELS.INFO,data:{name:e,isStory:0,...t}})}destroy(){this._lastStorySend={},this.mt.startRecord=()=>{},this.mt.endRecord=()=>{},this.mt.count=()=>{}}}},Ct={ajax:class extends g{init(e={}){console.log("AJAX init"),this.requestURL="",this.finalOptions={req:!0,res:!1,...e},this.listenXhr(),this.listenFetch()}listenXhr(){if("undefined"==typeof XMLHttpRequest)return;const e=this,{req:t,res:n,excludeUrls:o}=this.finalOptions,r=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(...t){return e.isClose||(this.startTime=Date.now(),this.requestURL=t[1]),r.apply(this,t)};const s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(...r){if(!e.isClose){const s=r[0],i=this.responseURL||this.requestURL;this.addEventListener("readystatechange",(function(){if(f(i,o))return;const r=Date.now()-this.startTime+"ms",a={url:i+` [${this.status}]`,interval:r};t&&s&&(a.req=s),i||0!==this.status?4===this.readyState&&(n&&this.responseText&&(a.res=this.responseText),this.status>=200&&this.status<300?e.send({type:e.TYPES.AJAX_SUCCESS,level:e.LEVELS.INFO,time:this.startTime,data:a},this):e.send({type:e.TYPES.AJAX_FAIL,level:e.LEVELS.ERROR,time:this.startTime,data:a},this)):e.send({type:e.TYPES.AJAX_FAIL,level:e.LEVELS.ERROR,time:this.startTime,data:a},this)}))}return s.apply(this,r)}}listenFetch(){if("undefined"==typeof window)return;const e=window.fetch;if(!e)return;const t=this,{req:n,res:o,excludeUrls:r}=this.finalOptions;window.fetch=async(s,i={})=>{if(t.isClose)return e(s,i);const a=function(e){if(!e)return"";if("string"==typeof e)return e;if("string"==typeof(null==e?void 0:e.url))return e.url;if("string"==typeof(null==e?void 0:e.href))return e.href;try{return String(e)}catch{return""}}(s);if(f(a,r))return e(s,i);const l=Date.now(),c=i.body||null;let d={url:a?`${a} [fetch]`:"[fetch]",interval:""};n&&c&&(d.req=c);try{const n=await e(s,i),r=n.clone(),c=await r.text();d.interval=Date.now()-l+"ms",o&&c&&(d.res=c);const u=a||n.url||"";return d.url=u?`${u} [${n.status}]`:`[${n.status}]`,n.status>=200&&n.status<300?t.send({type:t.TYPES.AJAX_SUCCESS,level:t.LEVELS.INFO,time:l,data:d}):t.send({type:t.TYPES.AJAX_FAIL,level:t.LEVELS.ERROR,time:l,data:d}),n}catch(e){throw d.interval=Date.now()-l+"ms",d.url=a?`${a} [0]`:"[0]",t.send({type:t.TYPES.AJAX_FAIL,level:t.LEVELS.ERROR,time:l,data:d}),e}}}},videoRecord:class extends g{init(e){this.options=e,console.log("init dataRecord"),this.reWriteCustomMethods(),this.eventsMatrix=[[]],this.startVideoRecord()}reWriteCustomMethods(){const e=this.mt.plugins.ajax.customMethod;this.mt.plugins.ajax.customMethod=(...t)=>{const[n,[o]]=t;if(-1===JSON.parse(o.responseText).code||200!=o.status){const e=this.createRecordId();n.recordId=e,setTimeout((()=>{this.waitPostRecord(e)}),500)}return e.apply(this,t),n}}startVideoRecord(){const e=this;at({emit(t,n){n&&(e.eventsMatrix.push([]),e.eventsMatrix.length>=3&&e.eventsMatrix.splice(0,1)),e.eventsMatrix[e.eventsMatrix.length-1].push(t)},checkoutEveryNth:this.options.checkoutEveryNth})}waitPostRecord(e){const t=this.endVideoRecord();if(!t)return;const n=[{type:this.TYPES.VideoRecord,level:this.LEVELS.INFO,recordId:e,recordData:t}];this.mt.plugins.http.request(n,(e=>{console.log(e)}))}endVideoRecord(){let e=[...this.eventsMatrix[this.eventsMatrix.length-1]];return e.length<50&&2===this.eventsMatrix.length&&(e=[].concat(...this.eventsMatrix)),!(e.length<50)&&JSON.stringify({events:e})}createRecordId(){return(new Date).getTime().toString()+"-"+this.options.customRecordId}},userInfo:class extends g{init(e){this.options=e,console.log("init userinfo")}async getUserInfo(){return this.options.getData?this.options.getData()||null:console.error("getData is required")}},pagePerformance:null};module.exports=function(e,{history:t,pathname:n}={},r={},s={}){const i="undefined"!=typeof window,a=e.useRef(null),l=e.useRef((({children:t})=>e.createElement(e.Fragment,null,t))),c={...ft,...r},{register:d,ERROR:u,RouterMonitorPlugin:h,useRouterMonitor:p,PerformanceMonitorPlugin:m}=gt(c.platform);if(i&&!a.current)try{var g,f;const o={};for(const e in lt)o[e]={...lt[e],...s[e]};const r=null!==(g=c.trackList)&&void 0!==g&&g.includes("pagePerformance")&&null!=o&&o.pagePerformance?{enabled:!0,entryTypes:o.pagePerformance.entryTypes}:null,i={url:c.url,key:c.key,reportEncryptSecret:c.reportEncryptSecret,sampleRate:c.sampleRate,sampleMode:c.sampleMode,plugins:{http:o.http,log:o.log,click:o.click}},p=new ct(i),I=d(e,p);Object.entries(It).forEach((([e,t])=>{p.pluginCall(e,t)})),p.pluginCall("platform_error",u),null===(f=c.trackList)||void 0===f||f.forEach((e=>{Ct[e]&&o[e]&&(i.plugins[e]=o[e],p.pluginCall(e,Ct[e]))})),e&&(t||void 0!==n)&&p.pluginCall("routerChange",h),r&&p.pluginCall("pagePerformance",m),l.current=I((({children:t})=>e.createElement(e.Fragment,null,t))),a.current=p}catch(e){console.error("[Z-Monitor] Initialization failed:",{error:o(e),config:{...c,trackList:c.trackList},platform:c.platform})}return p(a.current,e,t,n),{MonitorWrapper:l.current,mt:a.current}};
@@ -0,0 +1,15 @@
1
+ function e(e){return(new TextEncoder).encode(e)}function t(e){let t="";for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const n=()=>"undefined"!=typeof window;function o(e){if(null==e)return null;try{var t,n;return{message:null!==(t=null==e?void 0:e.message)&&void 0!==t?t:String(e),stack:null!==(n=null==e?void 0:e.stack)&&void 0!==n?n:void 0}}catch{return{message:String(e)}}}function r(e,t="log"){"function"==typeof console[t]?console[t](e):console.log(e)}function s(e){return!e}const i=(e,t)=>{let n=Object.prototype.toString;return"undefined"!=typeof Element&&e instanceof Element?"element":{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[n.call(e)]===t};function a(e,t=!1){return e.innerHTML?e.outerHTML.replace(e.innerHTML,t?e.innerText.slice(0,15):""):e.outerHTML}function l(e){return-1===["[object Window]","[object HTMLDocument]","[object HTMLHtmlElement]","[object HTMLBodyElement]"].indexOf(e.toString())}function c(e){return e.id?"#"+e.id:e.getAttribute("class")?"."+e.getAttribute("class").replace(" ","."):e.getAttribute("style")?"("+e.getAttribute("style")+")":""}function d(e){let t="";for(let n=Math.min(e.length-1,5);n>=0;n--)l(e[n])&&(t=t?`${e[n].localName}${c(e[n])} > ${t}`:`${e[n].localName}${c(e[n])}`);return t}const u={CLICK:{value:"UI.CLICK",text:"UI点击"},RES_ERROR:{value:"RES.ERROR",text:"资源加载错误"},AJAX_SUCCESS:{value:"AJAX.SUCCESS",text:"请求成功"},AJAX_FAIL:{value:"AJAX.FAIL",text:"请求失败"},CODE_ERROR:{value:"CODE.ERROR",text:"代码错误"},PROMISE_ERROR:{text:"promise.reject的错误",value:"PROMISE.ERROR"},CONSOLE:{value:"CONSOLE",text:"控制台打印"},CUSTOM:{value:"CUSTOM",text:"自定义日志"},USERINFO:{value:"USERINFO",text:"用户信息"},VideoRecord:{value:"VideoRecord",text:"视频回放"},PERFORMANCE:{value:"PERFORMANCE",text:"页面性能"}},h={ERROR:{value:1,text:"严重"},WARN:{value:2,text:"警告"},INFO:{value:3,text:"正常行为"}},p="PLUGIN_ERROR",m="SESSION_FAILED";class g{constructor({mt:e,name:t},n){this.mt=e,this.allOptions=e.options||{},this.name=t,this.customMethod=n.customMethod||null,this.isClose=!1}get TYPES(){return this.mt.TYPES}get LEVELS(){return this.mt.LEVELS}addCommonData(e,t,n){this.mt[e]?this.mt.addCommonData(e,t,n):r("monitor 实例找不到设置参数","error")}send(e,...t){const n=Date.now();!function(e){let t=()=>setTimeout(e,0);if("function"==typeof requestIdleCallback)t=()=>{requestIdleCallback(e)};else if("function"==typeof MessageChannel){const n=new MessageChannel;n.port1.onmessage=()=>e(),t=()=>n.port2.postMessage(null)}return t}((()=>{if(this.customMethod){const o=this.customMethod({time:n,...e},t);if(s(o))return;e=o}this.mt.send({time:n,...e})}))()}}function f(e,t){return null==t?void 0:t.some((t=>null==e?void 0:e.includes(t)))}class I{constructor({mt:e}){this.mt=e}init(e){this.url=e.url+"/monitor/add",this.method=e.requestConfig.method,this.headers=e.requestConfig.headers,this.customMethod=e.customMethod||null,e.url||this.customMethod||console.error("url or customMethod is required")}async request(e,t,n){if("undefined"==typeof window||!window.log_report){if("undefined"!=typeof window&&(window.log_report=!0),this.mt.beforeReport){let t=this.mt.beforeReport(e);if(s(t))return;e=t}this.customMethod?this.customMethod(e,t,n):this.report(e,t,n)}}shouldUseBeacon(e){return"function"==typeof navigator.sendBeacon&&new Blob([e]).size<=61440}shouldUseFetch(){return"function"==typeof fetch}reportWithBeacon(e){const t=new Blob([e],{type:"application/json"}),n=navigator.sendBeacon(this.url,t);if(n)return n;console.warn("sendBeacon failed, falling back to other methods")}async reportWithFetch(e){const t=await fetch(this.url,{method:this.method,headers:this.headers,body:e,keepalive:!0,signal:AbortSignal.timeout(5e3),priority:"low"});return{status:t.status,responseText:await t.text()}}async report(n,r,s){let i=JSON.stringify({platform:this.mt.platformName,projectId:this.mt.key,sessionId:this.mt.sessionId,data:n});const a=this.mt.options.reportEncryptSecret;if(a)try{"undefined"!=typeof crypto&&crypto.subtle?i=await async function(n,o){if("undefined"==typeof crypto||!crypto.subtle)throw new Error("当前环境不支持 Web Crypto(需 HTTPS 或 localhost)");if(!o||"string"!=typeof o)throw new Error("reportEncryptSecret 无效");const r=await async function(t){const n=await crypto.subtle.digest("SHA-256",e(t));return new Uint8Array(n)}(o),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,tagLength:128},s,e(n)),l=new Uint8Array(a);return JSON.stringify({v:1,encrypted:!0,alg:"AES-256-GCM",iv:t(i),data:t(l)})}(i,a):console.warn("埋点上报:当前环境不支持加密,已发送明文")}catch(e){console.warn("埋点上报加密失败,使用明文:",o(e))}try{let e;e=this.shouldUseFetch()?await this.reportWithFetch(i):await this.customRequest({method:this.method,url:this.url,headers:this.headers,data:i}),r&&r(e)}catch(e){s&&s(e),console.error("Request failed:",o(e))}}customRequest({method:e="GET",url:t,params:n={},data:o=null,headers:r={}}){return new Promise(((s,i)=>{const a=new XMLHttpRequest,l=new URLSearchParams(n).toString(),c=l?`${t}?${l}`:t;if(a.open(e,c,!0),r)for(const[e,t]of Object.entries(r))a.setRequestHeader(e,t);if(a.onload=function(){if(a.status>=200&&a.status<300)try{const e=JSON.parse(a.responseText);s({status:a.status,data:e,error:null})}catch(e){s({status:a.status,data:null,error:e})}else i(new Error(`Request failed with status ${a.status}: ${a.statusText}`))},a.onerror=function(){i(new Error("Network error: Failed to send request"))},a.ontimeout=function(){i(new Error("Request timeout"))},o)if("application/json"===r["Content-Type"])a.send("string"==typeof o?o:JSON.stringify(o));else{const e=new FormData;for(const[t,n]of Object.entries(o))e.append(t,n);a.send(e)}else a.send()}))}}const C="z-monitor-session-id";class y{constructor({mt:e},t){this.data=[],this.mt=e,this.HTTP_FAIL_COUNT=0,this.SESSION_RETRY_COUNT=0,this.MAX_SESSION_RETRY=3,this.MAX_HTTP_FAIL=t.MAX_HTTP_FAIL||20,this.max=t.max||20,this.type=t.type||"num",this.time=t.time||6e4,this.customMethod=t.customMethod||null,this.eventHandlers={unloadHandler:null,visibilityHandler:null},this.STORAGE_KEY=`monitor_not_uploaded_${this.mt.appName}`,this.unloadEvent="undefined"!=typeof window&&"onpagehide"in window?"pagehide":"beforeunload"}set isClose(e){e&&(this.cancelInterval(),this.clear())}setData(e){this.data=e}init(){n()&&(this.initUnloadHandler(),this.restoreUnsentData(),this.listenUnload(),"num"!==this.type&&this.openInterval())}initUnloadHandler(){this.eventHandlers.unloadHandler=e=>{var t;if("undefined"!=typeof localStorage&&("pagehide"!==this.unloadEvent||!e.persisted)&&null!==(t=this.data)&&void 0!==t&&t.length){const e=JSON.stringify(this.data);localStorage.setItem(this.STORAGE_KEY,e)}},this.eventHandlers.visibilityHandler=()=>{"undefined"!=typeof document&&"hidden"===document.visibilityState&&this.uploadData()}}restoreUnsentData(){if("undefined"!=typeof localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const t=JSON.parse(e);Array.isArray(t)&&(this.data=t.concat(this.data)),localStorage.removeItem(this.STORAGE_KEY)}else this.data=[]}catch(e){console.error("恢复未上报数据失败:",o(e))}}listenUnload(){"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener(this.unloadEvent,this.eventHandlers.unloadHandler),document.addEventListener("visibilitychange",this.eventHandlers.visibilityHandler))}openInterval(){this.cancelInterval(),this.interval=setInterval((()=>{this.uploadData()}),this.time)}cancelInterval(){window.clearInterval(this.interval),this.interval=null}push(e){if(!this.isClose){if(this.customMethod){let t=this.customMethod(e,[this]);if(s(t))return;e=t}this.data.push(e),"time"!==this.type&&this.data.length/this.max%1==0&&this.uploadData()}}async uploadData(){if(!this.data.length)return;const e=this.data.slice(0,this.data.length),t=e.length;this.mt.plugins.http.request(e,(async e=>{"undefined"!=typeof window&&(window.log_report=!1),[200,201].includes(e.status)?(this.data=this.data.slice(t,this.data.length),this.HTTP_FAIL_COUNT=0):this.handleUploadError(e.status)}),(e=>{console.error("日志上报失败:",o(e)),"undefined"!=typeof window&&(window.log_report=!1),this.handleUploadError(null)}))}async handleSessionError(){if(this.mt.emit("error",m),this.SESSION_RETRY_COUNT>=this.MAX_SESSION_RETRY)return console.error("重试次数达到上限,关闭日志收集"),void this.mt.close();this.SESSION_RETRY_COUNT++,console.warn(`SessionId 失效,尝试重新获取 (${this.SESSION_RETRY_COUNT}/${this.MAX_SESSION_RETRY})`);try{"undefined"!=typeof sessionStorage&&sessionStorage.removeItem(C),await this.mt.initSessionId(this.mt.options,!0),this.SESSION_RETRY_COUNT=0,this.uploadData()}catch(e){console.error("重新获取 sessionId 失败:",o(e)),this.mt.emit("error","SESSION_INIT_FAILED")}}handleUploadError(e){403===e?this.handleSessionError():(this.mt.emit("error","HTTP_FAIL"),this.HTTP_FAIL_COUNT++,this.HTTP_FAIL_COUNT>=this.MAX_HTTP_FAIL&&(console.error("重试次数达到上限,关闭日志收集"),this.mt.close()))}clear(){this.data=[],"undefined"!=typeof window&&window.removeEventListener(this.unloadEvent,this.eventHandlers.unloadHandler),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",this.eventHandlers.visibilityHandler)}}var v;function S(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function b(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function A(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(w).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function w(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=A(e.styleSheet)||t}catch(e){}return t}!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"}(v||(v={}));var E=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function R(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,s=e.maskInputFn,i=r||"";return(t[n.toLowerCase()]||t[o])&&(i=s?s(i):"*".repeat(i.length)),i}var k,M,T="__rrweb_original__",N=1,O=new RegExp("[^a-z0-9-_:]");function L(){return N++}var x=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,F=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,D=/^(data:)([^,]*),(.*)/i;function U(e,t){return(e||"").replace(x,(function(e,n,o,r,s,i){var a,l=o||s||i,c=n||r||"";if(!l)return e;if(!F.test(l))return"url(".concat(c).concat(l).concat(c,")");if(D.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=t.split("/"),u=l.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var m=p[h];"."!==m&&(".."===m?d.pop():d.push(m))}return"url(".concat(c).concat(d.join("/")).concat(c,")")}))}var _=/^[^ \t\n\r\u000c]+/,V=/^[, \t\n\r\u000c]+/;function W(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function B(){var e=document.createElement("a");return e.href="",e.href}function G(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?W(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(V),!(n>=t.length);){var s=o(_);if(","===s.slice(-1))s=W(e,s.substring(0,s.length-1)),r.push(s);else{var i="";s=W(e,s);for(var a=!1;;){var l=t.charAt(n);if(""===l){r.push((s+i).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+i).trim());break}"("===l&&(a=!0)}i+=l,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?U(o,B()):"object"===t&&"data"===n&&o?W(e,o):o:W(e,o)}function Z(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&Z(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&Z(e.parentNode,t,n)}function Y(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(Z(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function P(e){return void 0===e?"":e.toLowerCase()}function K(e,t){var n,o=t.doc,r=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,l=t.maskTextSelector,c=t.skipChild,d=void 0!==c&&c,u=t.inlineStylesheet,h=void 0===u||u,p=t.maskInputOptions,m=void 0===p?{}:p,g=t.maskTextFn,f=t.maskInputFn,I=t.slimDOMOptions,C=t.dataURLOptions,y=void 0===C?{}:C,w=t.inlineImages,E=void 0!==w&&w,N=t.recordCanvas,x=void 0!==N&&N,F=t.onSerialize,D=t.onIframeLoad,_=t.iframeLoadTimeout,V=void 0===_?5e3:_,W=t.onStylesheetLoad,Z=t.stylesheetLoadTimeout,H=void 0===Z?5e3:Z,J=t.keepIframeSrcFn,j=void 0===J?function(){return!1}:J,X=t.newlyAddedElement,z=void 0!==X&&X,q=t.preserveWhiteSpace,Q=void 0===q||q,$=function(e,t){var n=t.doc,o=t.mirror,r=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,l=t.inlineStylesheet,c=t.maskInputOptions,d=void 0===c?{}:c,u=t.maskTextFn,h=t.maskInputFn,p=t.dataURLOptions,m=void 0===p?{}:p,g=t.inlineImages,f=t.recordCanvas,I=t.keepIframeSrcFn,C=t.newlyAddedElement,y=void 0!==C&&C,S=function(e,t){if(t.hasNode(e)){var n=t.getId(e);return 1===n?void 0:n}}(n,o);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:v.Document,childNodes:[],compatMode:e.compatMode}:{type:v.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:v.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:S};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,o=t.inlineStylesheet,r=t.maskInputOptions,s=void 0===r?{}:r,i=t.maskInputFn,a=t.dataURLOptions,l=void 0===a?{}:a,c=t.inlineImages,d=t.recordCanvas,u=t.keepIframeSrcFn,h=t.newlyAddedElement,p=void 0!==h&&h,m=t.rootId,g=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,t.blockClass,t.blockSelector),f=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return O.test(t)?"div":t}(e),I={},C=e.attributes.length,y=0;y<C;y++){var S=e.attributes[y];I[S.name]=G(n,f,S.name,S.value)}if("link"===f&&o){var b=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),w=null;b&&(w=A(b)),w&&(delete I.rel,delete I.href,I._cssText=U(w,b.href))}if("style"===f&&e.sheet&&!(e.innerText||e.textContent||"").trim().length&&(w=A(e.sheet))&&(I._cssText=U(w,B())),"input"===f||"textarea"===f||"select"===f){var E=e.value,N=e.checked;"radio"!==I.type&&"checkbox"!==I.type&&"submit"!==I.type&&"button"!==I.type&&E?I.value=R({type:I.type,tagName:f,value:E,maskInputOptions:s,maskInputFn:i}):N&&(I.checked=N)}if("option"===f&&(e.selected&&!s.select?I.selected=!0:delete I.selected),"canvas"===f&&d)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,s=T in r?r[T]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(I.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){var L=e.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,L!==x.toDataURL(l.type,l.quality)&&(I.rr_dataURL=L)}if("img"===f&&c){k||(k=n.createElement("canvas"),M=k.getContext("2d"));var F=e,D=F.crossOrigin;F.crossOrigin="anonymous";var _=function(){try{k.width=F.naturalWidth,k.height=F.naturalHeight,M.drawImage(F,0,0),I.rr_dataURL=k.toDataURL(l.type,l.quality)}catch(e){console.warn("Cannot inline img src=".concat(F.currentSrc,"! Error: ").concat(e))}D?I.crossOrigin=D:F.removeAttribute("crossorigin")};F.complete&&0!==F.naturalWidth?_():F.onload=_}if("audio"!==f&&"video"!==f||(I.rr_mediaState=e.paused?"paused":"played",I.rr_mediaCurrentTime=e.currentTime),p||(e.scrollLeft&&(I.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(I.rr_scrollTop=e.scrollTop)),g){var V=e.getBoundingClientRect(),W=V.width,Z=V.height;I={class:I.class,rr_width:"".concat(W,"px"),rr_height:"".concat(Z,"px")}}return"iframe"!==f||u(I.src)||(e.contentDocument||(I.rr_src=I.src),delete I.src),{type:v.Element,tagName:f,attributes:I,childNodes:[],isSVG:(Y=e,Boolean("svg"===Y.tagName||Y.ownerSVGElement)||void 0),needBlock:g,rootId:m};var Y}(e,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:h,dataURLOptions:m,inlineImages:g,recordCanvas:f,keepIframeSrcFn:I,newlyAddedElement:y,rootId:S});case e.TEXT_NODE:return function(e,t){var n,o,r=t.maskTextClass,s=t.maskTextSelector,i=t.maskTextFn,a=t.rootId,l=e.parentNode&&e.parentNode.tagName,c=e.textContent,d="STYLE"===l||void 0,u="SCRIPT"===l||void 0;if(d&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(o=e.parentNode.sheet).cssRules?Array.from(o.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=U(c,B())}return u&&(c="SCRIPT_PLACEHOLDER"),!d&&!u&&c&&Y(e,r,s)&&(c=i?i(c):c.replace(/[\S]/g,"*")),{type:v.Text,textContent:c||"",isStyle:d,rootId:a}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:u,rootId:S});case e.CDATA_SECTION_NODE:return{type:v.CDATA,textContent:"",rootId:S};case e.COMMENT_NODE:return{type:v.Comment,textContent:e.textContent||"",rootId:S};default:return!1}}(e,{doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,dataURLOptions:y,inlineImages:E,recordCanvas:x,keepIframeSrcFn:j,newlyAddedElement:z});if(!$)return console.warn(e,"not serialized"),null;n=r.hasNode(e)?r.getId(e):!function(e,t){if(t.comment&&e.type===v.Comment)return!0;if(e.type===v.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(P(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===P(e.attributes.name)||"icon"===P(e.attributes.rel)||"apple-touch-icon"===P(e.attributes.rel)||"shortcut icon"===P(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&P(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(P(e.attributes.property).match(/^(og|twitter|fb):/)||P(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===P(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===P(e.attributes.name)||"googlebot"===P(e.attributes.name)||"bingbot"===P(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===P(e.attributes.name)||"generator"===P(e.attributes.name)||"framework"===P(e.attributes.name)||"publisher"===P(e.attributes.name)||"progid"===P(e.attributes.name)||P(e.attributes.property).match(/^article:/)||P(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===P(e.attributes.name)||"yandex-verification"===P(e.attributes.name)||"csrf-token"===P(e.attributes.name)||"p:domain_verify"===P(e.attributes.name)||"verify-v1"===P(e.attributes.name)||"verification"===P(e.attributes.name)||"shopify-checkout-api-token"===P(e.attributes.name)))return!0}}return!1}($,I)&&(Q||$.type!==v.Text||$.isStyle||$.textContent.replace(/^\s+|\s+$/gm,"").length)?L():-2;var ee=Object.assign($,{id:n});if(r.add(e,ee),-2===n)return null;F&&F(e);var te=!d;if(ee.type===v.Element){te=te&&!ee.needBlock,delete ee.needBlock;var ne=e.shadowRoot;ne&&b(ne)&&(ee.isShadowHost=!0)}if((ee.type===v.Document||ee.type===v.Element)&&te){I.headWhitespace&&ee.type===v.Element&&"head"===ee.tagName&&(Q=!1);for(var oe={doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j},re=0,se=Array.from(e.childNodes);re<se.length;re++)(le=K(se[re],oe))&&ee.childNodes.push(le);if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var ie=0,ae=Array.from(e.shadowRoot.childNodes);ie<ae.length;ie++){var le;(le=K(ae[ie],oe))&&(b(e.shadowRoot)&&(le.isShadow=!0),ee.childNodes.push(le))}}return e.parentNode&&S(e.parentNode)&&b(e.parentNode)&&(ee.isShadow=!0),ee.type===v.Element&&"iframe"===ee.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var i="about:blank";if(o.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&D){var n=K(t,{doc:t,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j});n&&D(e,n)}}),V),ee.type===v.Element&&"link"===ee.tagName&&"stylesheet"===ee.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var s=setTimeout((function(){r||(t(),r=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),r=!0,t()}))}}(e,(function(){if(W){var t=K(e,{doc:o,mirror:r,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:m,maskTextFn:g,maskInputFn:f,slimDOMOptions:I,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:Q,onSerialize:F,onIframeLoad:D,iframeLoadTimeout:V,onStylesheetLoad:W,stylesheetLoadTimeout:H,keepIframeSrcFn:j});t&&W(e,t)}}),H),ee}function H(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const J="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let j={map:{},getId:()=>(console.error(J),-1),getNode:()=>(console.error(J),null),removeNodeFromMap(){console.error(J)},has:()=>(console.error(J),!1),reset(){console.error(J)}};function X(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),l=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(l,s)):o||!1===n.trailing||(o=setTimeout((()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(l,s)}),a))}}function z(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>z(e,t,s||{},!0)}function q(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}function Q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function $(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function ee(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(Z(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function te(e,t){return-2===t.getId(e)}function ne(e,t){if(S(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||ne(e.parentNode,t))}function oe(e){return Boolean(e.changedTouches)}function re(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function se(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ie(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:(e,t,n)=>("map"===t&&console.error(J),Reflect.get(e,t,n))}));class ae{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var le=(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))(le||{}),ce=(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))(ce||{}),de=(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))(de||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{});function he(e){return"__ln"in e}class pe{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&he(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&he(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const me=(e,t)=>`${e}@${t}`;class ge{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=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new pe,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,s,i,a;let l=null;(null===(s=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(l=o.getRootNode().host);let c=l;for(;(null===(a=null===(i=null==c?void 0:c.getRootNode)||void 0===i?void 0:i.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(o)||c&&this.doc.contains(c));if(!o.parentNode||d)return;const u=S(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),h=n(o);if(-1===u||-1===h)return t.addNode(o);const p=K(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{re(e,this.mirror)&&this.iframeManager.addIframe(e),se(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ie(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});p&&e.push({parentId:u,nextId:h,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))Ie(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ye(this.droppedSet,e)||Ie(this.removes,e,this.mirror)?ye(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!te(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;ee(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Y(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=R({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),ee(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(r[e]=""===s?o:[o,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=G(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(ee(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),o=S(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);ee(e.target,this.blockClass,this.blockSelector,!1)||te(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(fe(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ne(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[me(n,o)]?fe(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!S(e.target)||!b(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(te(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[me(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);ee(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function fe(e,t){e.delete(t),t.childNodes.forEach((t=>fe(e,t)))}function Ie(e,t,n){return 0!==e.length&&Ce(e,t,n)}function Ce(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some((e=>e.id===r))||Ce(e,o,n)}function ye(e,t){return 0!==e.size&&ve(e,t)}function ve(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ve(e,n))}const Se=[],be="undefined"!=typeof CSSGroupingRule,Ae="undefined"!=typeof CSSMediaRule,we="undefined"!=typeof CSSSupportsRule,Ee="undefined"!=typeof CSSConditionRule;function Re(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(t){return e.target}}function ke(e,t){var n,o;const r=new ge;Se.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Me({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return H("scroll",X((s=>{const i=Re(s);if(!i||ee(i,o,r,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Te(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const Ne=["INPUT","TEXTAREA","SELECT"],Oe=new WeakMap;function Le(e){return function(e,t){if(be&&e.parentRule instanceof CSSGroupingRule||Ae&&e.parentRule instanceof CSSMediaRule||we&&e.parentRule instanceof CSSSupportsRule||Ee&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function xe(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function Fe({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null===(e=l.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=l.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function De(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const o=ke(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const l=X((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),c=X((e=>{const t=Re(e),{clientX:n,clientY:r}=oe(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-i}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?ce.Drag:e instanceof MouseEvent?ce.MouseMove:ce.TouchMove)}),r,{trailing:!1}),d=[H("mousemove",c,n),H("touchmove",c,n),H("drag",c,n)];return()=>{d.forEach((e=>e()))}}(e),s=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(de).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),l=(t=>s=>{const i=Re(s);if(ee(i,o,r,!0))return;const a=oe(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(i),{clientX:c,clientY:d}=a;e({type:de[t],id:l,x:c,y:d})})(s);a.push(H(i,l,t))})),()=>{a.forEach((e=>e()))}}(e),i=Me(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return H("resize",X((()=>{const o=Q(),r=$();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)}),200),window)}(e),l=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(e){let n=Re(e);const l=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||Ne.indexOf(n.tagName)<0||ee(n,o,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=R({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Te({text:h,isChecked:p,userTriggered:l},c));const m=n.name;"radio"===d&&m&&p&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&u(e,Te({text:e.value,isChecked:!p,userTriggered:!1},c))}))}function u(t,o){const r=Oe.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){Oe.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const h=("last"===l.input?["change"]:["input","change"]).map((e=>H(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),g=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map((e=>z(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const s=s=>X((r=>{const i=Re(r);if(!i||ee(i,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=i;e({type:s,id:o.getId(i),currentTime:a,volume:l,muted:c,playbackRate:d})}),r.media||500),i=[H("play",s(0)),H("pause",s(1)),H("seeked",s(2)),H("volumechange",s(3)),H("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,s){const{id:i,styleId:a}=xe(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:s}]}),r.apply(this,[o,s])};const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:i}=xe(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,removes:[{index:o}]}),s.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:s}=xe(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replace:o}),i.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:s}=xe(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replaceSync:o}),a.apply(this,[o])});const l={};be?l.CSSGroupingRule=o.CSSGroupingRule:(Ae&&(l.CSSMediaRule=o.CSSMediaRule),Ee&&(l.CSSConditionRule=o.CSSConditionRule),we&&(l.CSSSupportsRule=o.CSSSupportsRule));const c={};return Object.entries(l).forEach((([o,r])=>{c[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:i,styleId:a}=xe(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:[...Le(this),s||0]}]}),c[o].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:i}=xe(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Le(this),r]}]}),c[o].deleteRule.apply(this,[r])}})),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach((([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule}))}}(e,{win:n}),u=Fe(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,i,a){var l;if(n.has(r))return s.apply(this,[r,i,a]);const{id:c,styleId:d}=xe(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(c&&-1!==c||d&&-1!==d)&&e({id:c,styleId:d,set:{property:r,value:i,priority:a},index:Le(this.parentRule)}),s.apply(this,[r,i,a])};const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return i.apply(this,[r]);const{id:a,styleId:l}=xe(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,remove:{property:r},index:Le(this.parentRule)}),i.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=q(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}}));return o.push((()=>{n.FontFace=s})),o.push(i),()=>{o.forEach((e=>e()))}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:l,endContainer:c,endOffset:d}=s;ee(i,o,r,!0)||ee(c,o,r,!0)||a.push({start:n.getId(i),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),H("selectionchange",a)}(e),g=[];for(const t of e.plugins)g.push(t.observer(t.callback,n,t.options));return()=>{Se.forEach((e=>e.reset())),o.disconnect(),r(),s(),i(),a(),l(),c(),d(),u(),h(),p(),m(),g.forEach((e=>e()))}}class Ue{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,o)))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;return o.get(t)||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class _e{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Ue(L),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ue(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case le.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:le.IncrementalSnapshot,data:{source:ce.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case le.Meta:case le.Load:case le.DomContentLoaded:return!1;case le.Plugin:return t;case le.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case le.IncrementalSnapshot:switch(t.data.source){case ce.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ce.Drag:case ce.TouchMove:case ce.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ce.ViewportResize:return!1;case ce.MediaInteraction:case ce.MouseInteraction:case ce.Scroll:case ce.CanvasMutation:case ce.Input:return this.replaceIds(t.data,e,["id"]),t;case ce.StyleSheetRule:case ce.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ce.Font:return t;case ce.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ce.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class Ve{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(q(Element.prototype,"attachShadow",(function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}})))}addShadowRoot(e,t){b(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ke(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Me(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Fe({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(q(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */for(var We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Be="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ge=0;Ge<64;Ge++)Be[We.charCodeAt(Ge)]=Ge;const Ze=new Map,Ye=(e,t,n)=>{if(!e||!He(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Ze.get(e);return n||(n=new Map,Ze.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function Pe(e,t,n){if(e instanceof Array)return e.map((e=>Pe(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),o=n.length,r="";for(t=0;t<o;t+=3)r+=We[n[t]>>2],r+=We[(3&n[t])<<4|n[t+1]>>4],r+=We[(15&n[t+1])<<2|n[t+2]>>6],r+=We[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Pe(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[Pe(e.data,t,n),e.width,e.height]}:He(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Ye(e,t,n)}:e}const Ke=(e,t,n)=>[...e].map((e=>Pe(e,t,n))),He=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Je(e,t,n){const o=[];try{const r=q(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...r){return ee(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}}));o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function je(e,t,n,o,r,s,i){const a=[],l=Object.getOwnPropertyNames(e);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const l=q(e,s,(function(e){return function(...a){const l=e.apply(this,a);if(Ye(l,i,this),!ee(this.canvas,o,r,!0)){const e=Ke([...a],i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return l}}));a.push(l)}catch(o){const r=z(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var Xe=null;try{var ze="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Xe=ze.Worker}catch(e){}var qe,Qe=(qe="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=","[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(e){var t=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),n=t.indexOf("\n",10)+1,o=t.substring(n)+"";return function(e){return new Xe(o,Object.assign({},e,{eval:!0}))}}(qe):function(e){var t;return function(n){return t=t||function(e){var t=function(e){return atob(e)}(e),n=t.indexOf("\n",10)+1,o=t.substring(n)+"",r=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(r)}(e),new Worker(t,n)}}(qe));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:i})}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(e,t,n,o,r){const s=Je(t,n,o),i=new Map,a=new Qe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:ue["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{ee(t,n,o,!0)||e.push(t)})),e})().forEach((e=>{return t=this,o=function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])},new((n=void 0)||(n=Promise))((function(e,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(t){var o;t.done?e(t.value):(o=t.value,o instanceof n?o:new n((function(e){e(o)}))).then(s,i)}a((o=o.apply(t,[])).next())}));var t,n,o}))),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Je(e,t,n),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=q(t.CanvasRenderingContext2D.prototype,i,(function(r){return function(...s){return ee(this.canvas,n,o,!0)||setTimeout((()=>{const n=Ke([...s],t,this);e(this.canvas,{type:ue["2D"],property:i,args:n})}),0),r.apply(this,s)}}));r.push(s)}catch(n){const o=z(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:ue["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...je(t.WebGLRenderingContext.prototype,ue.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...je(t.WebGL2RenderingContext.prototype,ue.WebGL2,e,n,o,0,t)),()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const o=n.map((e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t})),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ae,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},o=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);o.push({styleId:e,rules:n.map(((e,t)=>({rule:w(e),index:t})))})}n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,ot,rt,st=!1;const it=new E;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:m,hooks:g,packFn:f,sampling:I={},dataURLOptions:C={},mousemoveWait:y,recordCanvas:v=!1,recordCrossOriginIframes:S=!1,userTriggeredOnInput:b=!1,collectFonts:A=!1,inlineImages:w=!1,plugins:R,keepIframeSrcFn:k=()=>!1,ignoreCSSAttributes:M=new Set([])}=e,T=!S||window.parent===window;let N=!1;if(!T)try{window.parent.document,N=!1}catch(e){N=!0}if(T&&!t)throw new Error("emit function is required");void 0!==y&&void 0===I.mousemove&&(I.mousemove=y),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},L=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const D=e=>{for(const t of R||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};nt=(e,r)=>{var s;if(!(null===(s=Se[0])||void 0===s?void 0:s.isFrozen())||e.type===le.FullSnapshot||e.type===le.IncrementalSnapshot&&e.data.source===ce.Mutation||Se.forEach((e=>e.unfreeze())),T)null==t||t(D(e),r);else if(N){const t={type:"rrweb",event:D(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===le.FullSnapshot)x=e,F=0;else if(e.type===le.IncrementalSnapshot){if(e.data.source===ce.Mutation&&e.data.isAttachIframe)return;F++;const t=o&&F>=o,r=n&&e.timestamp-x.timestamp>n;(t||r)&&ot(!0)}};const U=e=>{nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Mutation},e)}))},_=e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Scroll},e)})),V=e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.CanvasMutation},e)})),W=new et({mutationCb:U,adoptedStyleSheetCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.AdoptedStyleSheet},e)}))}),B=new _e({mirror:it,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:S,wrappedEmit:nt});for(const e of R||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:B.crossOriginIframeMirror,crossOriginIframeStyleMirror:B.crossOriginIframeStyleMirror});rt=new $e({recordCanvas:v,mutationCb:V,win:window,blockClass:r,blockSelector:s,mirror:it,sampling:I.canvas,dataURLOptions:C});const G=new Ve({mutationCb:U,scrollCb:_,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:O,dataURLOptions:C,maskTextFn:m,maskInputFn:p,recordCanvas:v,inlineImages:w,sampling:I,slimDOMOptions:L,iframeManager:B,stylesheetManager:W,canvasManager:rt,keepIframeSrcFn:k},mirror:it});ot=(e=!1)=>{var t,n,o,i,d,u;nt(tt({type:le.Meta,data:{href:window.location.href,width:$(),height:Q()}}),e),W.reset(),Se.forEach((e=>e.lock()));const h=function(e,t){var n=t,o=n.mirror,r=void 0===o?new E:o,s=n.blockClass,i=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,u=n.recordCanvas,h=n.maskAllInputs,p=void 0!==h&&h,m=n.slimDOM,g=void 0!==m&&m,f=n.keepIframeSrcFn;return K(e,{doc:e,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===i?null:i,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===p?{password:!0}:p,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===g,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===g?{}:g,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==u&&u,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:it,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:O,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:v,inlineImages:w,onSerialize:e=>{re(e,it)&&B.addIframe(e),se(e,it)&&W.trackLinkElement(e),ie(e)&&G.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{B.attachIframe(e,t),G.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:k});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:le.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),Se.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(H("DOMContentLoaded",(()=>{nt(tt({type:le.DomContentLoaded,data:{}}))})));const t=e=>{var t;return De({mutationCb:U,mousemoveCb:(e,t)=>nt(tt({type:le.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.MouseInteraction},e)})),scrollCb:_,viewportResizeCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.ViewportResize},e)})),inputCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Input},e)})),mediaInteractionCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.StyleDeclaration},e)})),canvasMutationCb:V,fontCb:e=>nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Font},e)})),selectionCb:e=>{nt(tt({type:le.IncrementalSnapshot,data:Object.assign({source:ce.Selection},e)}))},blockClass:r,ignoreClass:i,maskTextClass:a,maskTextSelector:l,maskInputOptions:O,inlineStylesheet:c,sampling:I,recordCanvas:v,inlineImages:w,userTriggeredOnInput:b,collectFonts:A,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:k,blockSelector:s,slimDOMOptions:L,dataURLOptions:C,mirror:it,iframeManager:B,stylesheetManager:W,shadowDomManager:G,canvasManager:rt,ignoreCSSAttributes:M,plugins:(null===(t=null==R?void 0:R.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:le.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},g)};B.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{ot(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(H("load",(()=>{nt(tt({type:le.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:le.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{Se.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");ot(e)},at.mirror=it;const lt={ajax:{req:!0,excludeUrls:[],customMethod:e=>e},log:{type:"time",time:3e4,MAX_HTTP_FAIL:3,customMethod:null},click:{isPartial:!1,globalDebounce:void 0,partialAttribute:"data-monitor",debounceAttribute:"data-monitor-debounce"},http:{isCustomRequest:!1,requestConfig:{method:"POST",headers:{"Content-Type":"application/json"}},customMethod:null},userInfo:{getData:null},videoRecord:{waitTime:2e3,checkoutEveryNth:300,customRecordId:""},pagePerformance:{entryTypes:["paint","resource","longtask","first-input","largest-contentful-paint"]}};class ct{constructor(e){console.log("Monitor加载..."),e.key?(this.key=e.key,this.log=null,this.plugins={},this.options=e,this.commonParams=[],this.events={},this.platform=null,this.platformName=null,this.sessionId=null,this.retryCount=0,this.MAX_RETRY_COUNT=3,this.baseInfo=null,this.beforeReport=e.beforeReport||null,this.sampleRate=function(e){if(null==e||""===e)return 1;const t=Number(e);return Number.isFinite(t)?t<=0?0:t>=1?1:t:(r("sampleRate 无效,使用默认 1","warn"),1)}(e.sampleRate),this.sampleMode="event"===e.sampleMode?"event":"session",this.sampleRate>=1?this._sampleAllowed=!0:this.sampleRate<=0?this._sampleAllowed=!1:this._sampleAllowed=Math.random()<this.sampleRate,this.init(e)):console.error("没有设置key值,请传递一个唯一的key值保证功能使用")}async init(e){if(n()){console.log("Monitor init"),this.initGlobal(),this.initBaseInfo(),this.initOptions(e),this.initClass(e);try{await this.initSessionId(e)}catch(e){var t;console.error(null!==(t=null==e?void 0:e.message)&&void 0!==t?t:"SessionId init failed")}}}async initSessionId(e,t=!1){if(n())try{var r;if(!t){if(this.sessionId)return;const e="undefined"!=typeof sessionStorage?sessionStorage.getItem(C):null;if(e)return void(this.sessionId=e)}const n=await this.plugins.http.customRequest({method:"GET",url:(e.url||"http://43.136.119.247")+"/session/id"});if(!n||null===(r=n.data)||void 0===r||!r.sessionId)throw new Error("无效的响应数据");var s;this.sessionId=null===(s=n.data)||void 0===s?void 0:s.sessionId,"undefined"!=typeof sessionStorage&&sessionStorage.setItem(C,this.sessionId),console.log("SessionId 初始化成功:",this.sessionId)}catch(t){if(this.retryCount++,console.error(`SessionId 初始化失败,重试次数: ${this.retryCount}`,o(t)),!(this.retryCount<this.MAX_RETRY_COUNT))throw console.error("重试次数达到上限,关闭埋点功能"),this.close(),this.emit("error",m),new Error("初始失败:无法获取 sessionId");console.log("重试中..."),await this.initSessionId(e,!0)}}initGlobal(){this.TYPES={...u},this.LEVELS={...h}}initOptions(){this.appName=this.key+"-Monitor"}initBaseInfo(){if(!n())return;const e=(new Date).getTimezoneOffset(),t=(e>0?"-":"+")+Math.floor(Math.abs(e)/60),o="undefined"!=typeof navigator?navigator:{},r=o.connection||o.mozConnection||o.webkitConnection||{};this.baseInfo={timezone:t,language:o.language||o.userLanguage||"en",deviceInfo:{userAgent:o.userAgent||"",networkInfo:{downlink:r.downlink,effectiveType:r.effectiveType,type:r.type,rtt:r.rtt,saveData:r.saveData}}}}initClass(){this.pluginCall("log",y),this.pluginCall("http",I)}isInnerPlugins(e){return["log","http"].includes(e)}pluginCall(e,t){try{let n=function(e,t){return e&&e[t]||{}}(this.options.plugins,e);this.plugins[e]=new t({mt:this,options:this.options,name:e},n);const o=this.plugins[e];"http"===e&&(n={...n,url:this.options.url}),o.init&&o.init(n)}catch(t){console.warn("插件注册错误",e,o(t)),this.emit("error",p)}}pluginDestroy(e){this.plugins[e]?(this.plugins[e].isClose=!0,this.plugins[e].destroy&&this.plugins[e].destroy(),setTimeout((()=>{delete this.plugins[e]}))):console.error(`插件${e}不存在`)}close(){this.plugins.log.isClose=!0;for(let e in this.plugins)this.isInnerPlugins(e)||this.pluginDestroy(e)}addCommonData(e,t,n){!function(e){return null!=e}(n)?r(`${t} 必须要设置`):this[e][t]?r(`${t} 已经存在,其值为${this[e][t]}`):this[e][t]=n}assignConfig(e){return{...this.getCommonConfig(e),...e}}shouldSample(){return this.sampleRate>=1||!(this.sampleRate<=0)&&("session"===this.sampleMode?this._sampleAllowed:Math.random()<this.sampleRate)}send(e){this.shouldSample()&&(e=this.assignConfig(e),this.plugins.log.push(e))}getCommonConfig(){var e,t,o,s;if(!n())return{info:{pageTitle:"",pageUrl:"",timezone:"",language:"",deviceInfo:{},locationInfo:{}}};this.initBaseInfo();let a={info:{pageTitle:"undefined"!=typeof document?document.title:"",pageUrl:"undefined"!=typeof window?window.location.href:"",timezone:null===(e=this.baseInfo)||void 0===e?void 0:e.timezone,language:null===(t=this.baseInfo)||void 0===t?void 0:t.language,deviceInfo:(null===(o=this.baseInfo)||void 0===o?void 0:o.deviceInfo)||{},locationInfo:(null===(s=this.baseInfo)||void 0===s?void 0:s.locationInfo)||{}}};const l=this.commonParams.length;if(l)for(let e=0;e<=l-1;e++){const t=this.commonParams[e](a);i(t,"object")?a=t:r(`setCommonConfig 传递函数需要\n${this.commonParams[e].toString()}\n返回值不是 object 类型`,"warn")}return a}setCommonConfig(e){i(e,"function")?this.commonParams.push(e):r("setCommonConfig 方法必须要传递函数类型","error")}emit(e,t){this.events[e]&&this.events[e](t)}on(e,t){this.events[e]=t}off(e){delete this.events[e]}clear(){this.plugins.log.clear()}}function dt(e,t){return e?t?(t.platformName="React",t.platform=e,function(n){var o;const r=null===(o=t.plugins.platform_error)||void 0===o?void 0:o.ErrorBoundary;function s(t){return r?e.createElement(r,{fallback:t.fallback},e.createElement(n,t)):(console.warn("错误边界不可用, 已跳过"),e.createElement(n,t))}return s.displayName=`withErrorBoundary(${n.displayName||n.name||"Component"})`,s}):console.error("必须要传入monitor实例"):console.error("必须要传入React")}class ut extends g{init(){if("React"!==this.mt.platformName)return console.error("检测当前不是react app环境,必须调用register(React)(monitor)注册");console.log("React Error init");const e=this.mt.platform,t=this;class n extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){((e,n)=>{t.isClose||t.send({type:t.TYPES.CODE_ERROR,level:t.LEVELS.ERROR,data:{message:e.message,stack:n.componentStack,targetType:"组件边界错误",vmName:n.componentName}})})(e,n)}render(){return this.state.hasError?this.props.fallback||e.createElement("h1",null,"Something went wrong."):this.props.children}}this.ErrorBoundary=n}}class ht extends g{init(){if("React"!==this.mt.platformName)return console.error("检测当前不是react app环境,必须调用register(React)(monitor)注册");this.addCommonData("TYPES","ROUTER",{text:"页面跳转",value:"ROUTER.CHANGE"})}sendRouteChange(e,t){this.isClose||this.send({type:this.TYPES.ROUTER,level:this.LEVELS.INFO,data:{fromPath:t.pathname||t,toPath:e.pathname||e,fromTitle:t.name||("undefined"!=typeof document?document.title:"")}})}}function pt(e,t,n,o){var r,s,i;const a="undefined"!=typeof window&&window.__NEXT_DATA__&&document.getElementById("__next"),l=null!==(r=null!==(s=null==n||null===(i=n.location)||void 0===i?void 0:i.pathname)&&void 0!==s?s:o)&&void 0!==r?r:"",[c,d]=t.useState(l),u=t.useRef(!1);t.useEffect((()=>{var t,r;if(!e||"undefined"==typeof window)return;const s=null==e||null===(t=e.plugins)||void 0===t?void 0:t.routerChange,i=null==e||null===(r=e.plugins)||void 0===r?void 0:r.pagePerformance;if(!s)return;if(void 0!==o){const e=null!=o?o:"";return u.current?void(c!==e&&(s.sendRouteChange({pathname:e},{pathname:c}),i&&(i.stopRouteMonitoring(c),i.startRouteMonitoring(e)),d(e))):(u.current=!0,s.sendRouteChange({pathname:e},{pathname:"",name:"initial"}),i&&i.startRouteMonitoring(e),void d(e))}if(!n)return;const l=(e,t)=>{const n="string"==typeof e?{pathname:e}:e,o="string"==typeof t?{pathname:t}:t;s.sendRouteChange(n,o),i&&(c!==(n.pathname||e)&&i.stopRouteMonitoring(c),i.startRouteMonitoring(n.pathname||e))};if(a){const e=(e,{shallow:t})=>{t||l(e,c)};return n.events.on("routeChangeComplete",e),()=>n.events.off("routeChangeComplete",e)}{const e=n.listen((e=>{l(e.pathname,c),d(e.pathname)}));return()=>e()}}),[e,a,n,o,c])}class mt extends g{init(e={}){"undefined"!=typeof window&&(this.observers=new Map,this.currentRoute=null,this.entryTypes=e.entryTypes||["navigation","resource"],this.startRouteMonitoring(window.location.pathname))}startRouteMonitoring(e){var t;if("undefined"==typeof window||"undefined"==typeof PerformanceObserver)return;if(null!==(t=this.observers)&&void 0!==t&&t.has(e))return;const n=new PerformanceObserver((e=>{e.getEntries().forEach((e=>{this.send({type:this.TYPES.PERFORMANCE,level:this.LEVELS.INFO,data:e})}))}));n.observe({entryTypes:this.entryTypes}),this.observers.set(e,n),this.currentRoute=e}stopRouteMonitoring(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e))}destroy(){this.observers.forEach((e=>e.disconnect())),this.observers.clear()}}function gt(e){if("react"===e)return{register:dt,ERROR:ut,RouterMonitorPlugin:ht,PerformanceMonitorPlugin:mt,useRouterMonitor:pt}}const ft={url:"http://43.136.119.247",platform:"react",key:"z-app",trackList:["userInfo"]},It={click:class extends g{init(e){"undefined"!=typeof window&&(console.log("Click init"),this.options=e,this.debounceMap=new Map,this.clickEvent=e=>this.handleClick(e),window.addEventListener("mouseup",this.clickEvent))}handleClick(e){try{const t=e.target,{isPartial:n,partialAttribute:o,debounceAttribute:r,globalDebounce:s}=this.options;if(!l(t))return;const i=function(e,t){let n=e;for(;n;){if(n.hasAttribute(t))return n;n=n.parentElement}return null}(t,o);if(n&&!i)return;if(this.debounceMap.has(i))return;const c=s||function(e,t){let n=e;for(;n;){const e=n.getAttribute(t);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0)return t}n=n.parentElement}return null}(i,r);c&&function(e,t,n){const o=Math.min(t,5e3);if(n.size>=1e3){const e=n.keys().next().value;n.delete(e)}n.set(e,Date.now()),setTimeout((()=>{n.delete(e)}),o)}(i,c,this.debounceMap);const u=function(e){return e.path||e.composedPath&&e.composedPath()||""}(e);this.send({type:this.TYPES.CLICK,level:this.LEVELS.INFO,data:{target:a(u[0],!0),path:d(u)}})}catch(e){this.mt.emit("error",p,e),this.destroy()}}destroy(){this.debounceMap.clear(),"undefined"!=typeof window&&window.removeEventListener("mouseup",this.clickEvent)}},ERROR:class extends g{init(e){"undefined"!=typeof window&&(console.log("error init"),this.options=e,this.errorEvent=e=>this.handleError(e),window.addEventListener("error",this.errorEvent,!0))}handleErrorType(e){var t,n,o,r,s,i,a,l,c,d,u;let h="错误";return"VIDEO"===(null==e||null===(t=e.target)||void 0===t?void 0:t.tagName)||"SOURCE"===(null==e||null===(n=e.target)||void 0===n?void 0:n.tagName)&&"VIDEO"===(null==e||null===(o=e.target)||void 0===o||null===(r=o.parentElement)||void 0===r?void 0:r.tagName)?h="错误-视频资源加载异常":"IMG"===(null==e||null===(s=e.target)||void 0===s?void 0:s.tagName)?h="错误-图片资源加载异常":"AUDIO"===(null==e||null===(i=e.target)||void 0===i?void 0:i.tagName)||"SOURCE"===(null==e||null===(a=e.target)||void 0===a?void 0:a.tagName)&&"AUDIO"===(null==e||null===(l=e.target)||void 0===l||null===(c=l.parentElement)||void 0===c?void 0:c.tagName)?h="错误-音频资源加载异常":"SCRIPT"===(null==e||null===(d=e.target)||void 0===d?void 0:d.tagName)?h="错误-脚本资源加载异常":"STYLE"===(null==e||null===(u=e.target)||void 0===u?void 0:u.tagName)&&(h="错误-样式资源加载异常"),h}handleError(e){var t,n,o,r,s,i,a;const l=null!==(t=null!==(n=e.message)&&void 0!==n?n:null===(o=e.reason)||void 0===o?void 0:o.message)&&void 0!==t?t:null,c=null!==(r=null!==(s=null===(i=e.error)||void 0===i?void 0:i.stack)&&void 0!==s?s:null===(a=e.reason)||void 0===a?void 0:a.stack)&&void 0!==r?r:null,d=this.handleErrorType(e);this.send({type:this.TYPES.CODE_ERROR,level:this.LEVELS.ERROR,data:{message:l,stack:c,targetType:d}})}destroy(){"undefined"!=typeof window&&window.removeEventListener("error",this.errorEvent)}},reject_error:class extends g{init(e){"undefined"!=typeof window&&(console.log("reject init"),this.options=e,this.errorEvent=e=>this.handleError(e),window.addEventListener("unhandledrejection",this.errorEvent,!0))}handleError(e){const{reason:t={}}=e,{message:n=null,stack:o=null}=t;this.send({type:this.TYPES.CODE_ERROR,level:this.LEVELS.ERROR,data:{message:n,stack:o,targetType:"异步错误"}})}destroy(){"undefined"!=typeof window&&window.removeEventListener("unhandledrejection",this.errorEvent)}},count:class extends g{init(){if(console.log("COUNT init"),this._lastStorySend={},!this.isClose){this.addCommonData("TYPES","COUNT",{text:"点击统计",value:"UI.COUNT"}),this.addCommonData("TYPES","STORY",{text:"用户故事",value:"UI.STORY"});const e=this;this.mt.startRecord=(...t)=>e.startRecord(...t),this.mt.endRecord=(...t)=>e.endRecord(...t),this.mt.count=(...t)=>e.count(...t)}}_shouldSkipStory(e,t){const n=`${e}_${t}`,o=Date.now(),r=this._lastStorySend[n];return!!(r&&o-r<100)||(this._lastStorySend[n]=o,!1)}startRecord(e,t={},n=null){if(this._shouldSkipStory(e,0))return;const o={type:this.TYPES.STORY,level:this.LEVELS.INFO,data:{name:e,storyEnd:0,isStory:1,...t}};n&&(o.time=n),this.send(o)}endRecord(e){this._shouldSkipStory(e,1)||this.send({type:this.TYPES.STORY,level:this.LEVELS.INFO,data:{name:e,storyEnd:1,isStory:1}})}count(e,t={}){this.send({type:this.TYPES.COUNT,level:this.LEVELS.INFO,data:{name:e,isStory:0,...t}})}destroy(){this._lastStorySend={},this.mt.startRecord=()=>{},this.mt.endRecord=()=>{},this.mt.count=()=>{}}}},Ct={ajax:class extends g{init(e={}){console.log("AJAX init"),this.requestURL="",this.finalOptions={req:!0,res:!1,...e},this.listenXhr(),this.listenFetch()}listenXhr(){if("undefined"==typeof XMLHttpRequest)return;const e=this,{req:t,res:n,excludeUrls:o}=this.finalOptions,r=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(...t){return e.isClose||(this.startTime=Date.now(),this.requestURL=t[1]),r.apply(this,t)};const s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(...r){if(!e.isClose){const s=r[0],i=this.responseURL||this.requestURL;this.addEventListener("readystatechange",(function(){if(f(i,o))return;const r=Date.now()-this.startTime+"ms",a={url:i+` [${this.status}]`,interval:r};t&&s&&(a.req=s),i||0!==this.status?4===this.readyState&&(n&&this.responseText&&(a.res=this.responseText),this.status>=200&&this.status<300?e.send({type:e.TYPES.AJAX_SUCCESS,level:e.LEVELS.INFO,time:this.startTime,data:a},this):e.send({type:e.TYPES.AJAX_FAIL,level:e.LEVELS.ERROR,time:this.startTime,data:a},this)):e.send({type:e.TYPES.AJAX_FAIL,level:e.LEVELS.ERROR,time:this.startTime,data:a},this)}))}return s.apply(this,r)}}listenFetch(){if("undefined"==typeof window)return;const e=window.fetch;if(!e)return;const t=this,{req:n,res:o,excludeUrls:r}=this.finalOptions;window.fetch=async(s,i={})=>{if(t.isClose)return e(s,i);const a=function(e){if(!e)return"";if("string"==typeof e)return e;if("string"==typeof(null==e?void 0:e.url))return e.url;if("string"==typeof(null==e?void 0:e.href))return e.href;try{return String(e)}catch{return""}}(s);if(f(a,r))return e(s,i);const l=Date.now(),c=i.body||null;let d={url:a?`${a} [fetch]`:"[fetch]",interval:""};n&&c&&(d.req=c);try{const n=await e(s,i),r=n.clone(),c=await r.text();d.interval=Date.now()-l+"ms",o&&c&&(d.res=c);const u=a||n.url||"";return d.url=u?`${u} [${n.status}]`:`[${n.status}]`,n.status>=200&&n.status<300?t.send({type:t.TYPES.AJAX_SUCCESS,level:t.LEVELS.INFO,time:l,data:d}):t.send({type:t.TYPES.AJAX_FAIL,level:t.LEVELS.ERROR,time:l,data:d}),n}catch(e){throw d.interval=Date.now()-l+"ms",d.url=a?`${a} [0]`:"[0]",t.send({type:t.TYPES.AJAX_FAIL,level:t.LEVELS.ERROR,time:l,data:d}),e}}}},videoRecord:class extends g{init(e){this.options=e,console.log("init dataRecord"),this.reWriteCustomMethods(),this.eventsMatrix=[[]],this.startVideoRecord()}reWriteCustomMethods(){const e=this.mt.plugins.ajax.customMethod;this.mt.plugins.ajax.customMethod=(...t)=>{const[n,[o]]=t;if(-1===JSON.parse(o.responseText).code||200!=o.status){const e=this.createRecordId();n.recordId=e,setTimeout((()=>{this.waitPostRecord(e)}),500)}return e.apply(this,t),n}}startVideoRecord(){const e=this;at({emit(t,n){n&&(e.eventsMatrix.push([]),e.eventsMatrix.length>=3&&e.eventsMatrix.splice(0,1)),e.eventsMatrix[e.eventsMatrix.length-1].push(t)},checkoutEveryNth:this.options.checkoutEveryNth})}waitPostRecord(e){const t=this.endVideoRecord();if(!t)return;const n=[{type:this.TYPES.VideoRecord,level:this.LEVELS.INFO,recordId:e,recordData:t}];this.mt.plugins.http.request(n,(e=>{console.log(e)}))}endVideoRecord(){let e=[...this.eventsMatrix[this.eventsMatrix.length-1]];return e.length<50&&2===this.eventsMatrix.length&&(e=[].concat(...this.eventsMatrix)),!(e.length<50)&&JSON.stringify({events:e})}createRecordId(){return(new Date).getTime().toString()+"-"+this.options.customRecordId}},userInfo:class extends g{init(e){this.options=e,console.log("init userinfo")}async getUserInfo(){return this.options.getData?this.options.getData()||null:console.error("getData is required")}},pagePerformance:null};function yt(e,{history:t,pathname:n}={},r={},s={}){const i="undefined"!=typeof window,a=e.useRef(null),l=e.useRef((({children:t})=>e.createElement(e.Fragment,null,t))),c={...ft,...r},{register:d,ERROR:u,RouterMonitorPlugin:h,useRouterMonitor:p,PerformanceMonitorPlugin:m}=gt(c.platform);if(i&&!a.current)try{var g,f;const o={};for(const e in lt)o[e]={...lt[e],...s[e]};const r=null!==(g=c.trackList)&&void 0!==g&&g.includes("pagePerformance")&&null!=o&&o.pagePerformance?{enabled:!0,entryTypes:o.pagePerformance.entryTypes}:null,i={url:c.url,key:c.key,reportEncryptSecret:c.reportEncryptSecret,sampleRate:c.sampleRate,sampleMode:c.sampleMode,plugins:{http:o.http,log:o.log,click:o.click}},p=new ct(i),I=d(e,p);Object.entries(It).forEach((([e,t])=>{p.pluginCall(e,t)})),p.pluginCall("platform_error",u),null===(f=c.trackList)||void 0===f||f.forEach((e=>{Ct[e]&&o[e]&&(i.plugins[e]=o[e],p.pluginCall(e,Ct[e]))})),e&&(t||void 0!==n)&&p.pluginCall("routerChange",h),r&&p.pluginCall("pagePerformance",m),l.current=I((({children:t})=>e.createElement(e.Fragment,null,t))),a.current=p}catch(e){console.error("[Z-Monitor] Initialization failed:",{error:o(e),config:{...c,trackList:c.trackList},platform:c.platform})}return p(a.current,e,t,n),{MonitorWrapper:l.current,mt:a.current}}export{yt as default};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "z-monitor-react",
3
+ "version": "0.2.2",
4
+ "description": "z-monitor react lib",
5
+ "type": "module",
6
+ "files": [
7
+ "dist/*",
8
+ "type.d.ts"
9
+ ],
10
+ "main": "./dist/index.cjs.min.js",
11
+ "module": "./dist/index.esm.min.js",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./type.d.ts",
15
+ "import": "./dist/index.esm.min.js",
16
+ "require": "./dist/index.cjs.min.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "types": "type.d.ts",
21
+ "sideEffects": false,
22
+ "devDependencies": {
23
+ "z-monitor-core": "^0.2.1"
24
+ },
25
+ "keywords": [
26
+ "monitor",
27
+ "react"
28
+ ],
29
+ "author": "",
30
+ "license": "ISC",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "rollup -c",
36
+ "test": "echo \"Error: no test specified\" && exit 1"
37
+ }
38
+ }
package/readme.md ADDED
@@ -0,0 +1,231 @@
1
+ ## 一款轻量、高性能、可扩展的前端埋点 SDK,用于自动化和手动收集用户行为、性能数据与错误信息,并上报至你的数据分析平台。
2
+
3
+ ## ✨ 特性
4
+
5
+ - 🛠 开箱即用:简单配置,快速集成,自动收集常见用户行为(如 PV/UV、点击、曝光、错误等)。
6
+ - 🚀 高性能:采用 fetch(low优先级) 和批量上报机制,对页面性能影响小。
7
+ - 📦 轻量无依赖:核心包体积仅 <90>KB。
8
+ - 🔧 高度可定制:支持自定义事件、扩展字段、生命周期钩子。
9
+ - 🌐 跨框架兼容:支持 React、Vue,不同框架安装不同的子包。
10
+ - 🔒 SSR 兼容:核心通过 `isBrowser()` 检测环境,服务端仅注册不初始化,客户端 hydration 后自动完成采集与上报。
11
+ - 📉 采样率:支持 `sampleRate` / `sampleMode`,按页面或按事件控制埋点上报比例。
12
+
13
+ ## 📦 安装
14
+
15
+ 使用 NPM/YARN/PNPM(推荐)
16
+
17
+ ```javascript
18
+ // 选择你的包管理器
19
+ npm install z-monitor-react
20
+ // 或
21
+ yarn add z-monitor-react
22
+ // 或
23
+ pnpm add z-monitor-react
24
+ ```
25
+
26
+ ## 🚀 快速开始
27
+
28
+ 1. 初始化
29
+
30
+ ```javascript
31
+ import useMonitor from 'z-monitor-react'
32
+
33
+ const { MonitorWrapper, mt } = useMonitor(
34
+ React,
35
+ {
36
+ history: History, // history实例对象
37
+ },
38
+ {
39
+ url: '服务器地址',
40
+ platform: 'react', // 项目对应框架
41
+ key: 'z-admin', // 唯一key
42
+ // sampleRate: 0.1, // 可选:0~1,埋点采样比例;默认 1 全量
43
+ // sampleMode: 'session', // 可选:'session'(默认,单页只判定一次)| 'event'(逐条随机)
44
+ trackList: ['userInfo', 'ajax', 'pagePerformance'], // 可选,要采集的信息
45
+ },
46
+ {
47
+ ajax: {
48
+ excludeUrls: [
49
+ /*要排除监控的地址*/
50
+ ],
51
+ },
52
+ userInfo: {
53
+ // 采集的用户信息
54
+ getData: () => {
55
+ const store = useStore()
56
+ return {
57
+ userId: store.state.user.userInfo.nick,
58
+ userName: store.state.user.userInfo.nick,
59
+ }
60
+ },
61
+ },
62
+ log: {
63
+ type: 'num', // 批量上报触发类型
64
+ max: 5, // 超过此值上报
65
+ },
66
+ }
67
+ )
68
+ ```
69
+
70
+ 2. 自动采集
71
+
72
+ 初始化后,SDK会自动收集以下数据
73
+ - 用户点击(Click):自动记录点击元素的选择器路径
74
+ - 路由跳转(RouteChange):自动记录路由跳转路径、标题和时间
75
+ - 错误监控(Error):捕获 JavaScript 执行错误、异步错误、资源加载失败
76
+ - 基础信息(BaseInfo):记录当前页面标题、地址、用户设备信息、网络状态、时区、语言等基础信息
77
+ - AJAX(Xhr):记录通过xhr发起的请求,启用该记录需要参数的trackList上加ajax
78
+ - 用户信息数据(UserInfo):通过用户自定义方法获取的用户信息,启用该记录需要用户传入自定义获取方法和trackList上加userInfo
79
+ - 页面性能(PagePerformance):记录当前页面性能数据,启用该记录需要参数的trackList上加pagePerformance
80
+
81
+ 3. 手动上报自定义事件
82
+
83
+ ```jsx
84
+ // 创建Context
85
+ export const MtContext = React.createContext(null)
86
+
87
+ // 应用顶层使用MtContext进行实例值传递
88
+ <MtContext.Provider value={mt}>{ children }</MtContext.Provider>
89
+
90
+ // 获取monitor实例
91
+ const monitor = useContext(MtContext)
92
+
93
+ // 记录用户故事
94
+ monitor.startRecord('story name', /* 自定义数据 */, /* 记录时间 */)
95
+ monitor.endRecord('story name')
96
+
97
+ // 记录自定义事件
98
+ monitor.count('name', /* 自定义数据 */)
99
+
100
+ ```
101
+
102
+ ## 🖥️ Next.js 使用方式
103
+
104
+ SDK 已做 SSR 兼容:服务端执行时 `isBrowser()` 为 false,各插件的 `init()` 会直接 return;客户端 hydration 后自动完成初始化与上报。React 包通过 `window.__NEXT_DATA__` 自动识别 Next.js 环境,采用 `router.events` 监听路由变化(Pages Router)。
105
+
106
+ ### 1. Pages Router 初始化
107
+
108
+ 在 `pages/_app.js`(或 `_app.tsx`)中:
109
+
110
+ ```jsx
111
+ import React from 'react'
112
+ import useMonitor from 'z-monitor-react'
113
+ import { useRouter } from 'next/router'
114
+
115
+ const MtContext = React.createContext(null)
116
+
117
+ export default function MyApp({ Component, pageProps }) {
118
+ const router = useRouter()
119
+ const { MonitorWrapper, mt } = useMonitor(
120
+ React,
121
+ { history: router },
122
+ {
123
+ url: '你的上报服务地址',
124
+ platform: 'react',
125
+ key: 'your-project-key',
126
+ // sampleRate: 0.1,
127
+ // sampleMode: 'session',
128
+ trackList: ['userInfo', 'ajax', 'pagePerformance'],
129
+ },
130
+ {
131
+ ajax: { excludeUrls: ['/api/health', '/_next/'] },
132
+ userInfo: {
133
+ getData: () => ({ userId: '', userName: '' }),
134
+ },
135
+ log: { type: 'num', max: 5 },
136
+ }
137
+ )
138
+
139
+ return (
140
+ <MtContext.Provider value={mt}>
141
+ <MonitorWrapper>
142
+ <Component {...pageProps} />
143
+ </MonitorWrapper>
144
+ </MtContext.Provider>
145
+ )
146
+ }
147
+
148
+ export { MtContext }
149
+ ```
150
+
151
+ ### 2. 在组件中手动上报
152
+
153
+ ```jsx
154
+ import { useContext } from 'react'
155
+ import { MtContext } from '../pages/_app'
156
+
157
+ function MyComponent() {
158
+ const monitor = useContext(MtContext)
159
+
160
+ const handleClick = () => {
161
+ monitor.count('button_click', { buttonId: 'submit' })
162
+ }
163
+
164
+ return <button onClick={handleClick}>点击</button>
165
+ }
166
+ ```
167
+
168
+ ### 3. App Router 说明
169
+
170
+ 若使用 Next.js 13+ App Router,需在客户端组件中初始化(`'use client'`),并传入pathname
171
+
172
+ ## ⚙️ 核心配置
173
+
174
+ | 参数 | 类型 | 默认值 | 描述 |
175
+ | :-----------------: | :------: | :-----: | :------------------------------------------------------------------------------------: |
176
+ | url | string | | 必填,上报服务端地址 |
177
+ | platform | string | | 必填,前端框架名称(Vue2、Vue3、React) |
178
+ | key | string | | 必填,项目唯一key |
179
+ | trackList | string[] | | 选填,可选采集的信息:userInfo、ajax、pagePerformance |
180
+ | sampleRate | number | 1 | 选填,埋点采样比例 0~1;`1` 全量,`0` 不上报;非法值按 `1` 处理 |
181
+ | sampleMode | string | session | 选填,`session`:当前页生命周期内只随机一次;`event`:每条埋点独立按 `sampleRate` 随机 |
182
+ | reportEncryptSecret | string | | 选填,与后端约定相同密钥时,`/monitor/add` 请求体使用 AES-256-GCM 加密 |
183
+ | history/pathname | Object | | 必填,路由实例(React Router 的 history / Next.js 的 pathname) |
184
+ | pluginConfig | Object | | 选填,插件配置 |
185
+ | pluginConfig.ajax | Object | | 选填,插件配置-AJAX |
186
+
187
+ ```typescript
188
+ // pluginConfig 全部可选参数
189
+ interface pluginConfig {
190
+ /** ajax请求插件配置 */
191
+ ajax: {
192
+ req: boolean // 是否开启对请求参数的记录
193
+ res: boolean // 是否开启对响应数据的记录
194
+ customMethod: (data: any, [ajax]: [any?]) => any // 自定义处理ajax数据方法
195
+ }
196
+ /** log记录插件配置 */
197
+ log: {
198
+ type: 'time' | 'num' | 'hybrid' // time:用时间来控制上传频率;num:用采集次数控制;hybrid:同时控制
199
+ time: number // x毫秒上传一次日志
200
+ max: number // 超过x条数据触发上传日志
201
+ MAX_HTTP_FAIL: number // 超过x次失败关闭监控,服务端接口可能错误
202
+ customMethod: (item: any) => any // 自定义处理日志数据
203
+ }
204
+ /** click点击插件配置 */
205
+ click: {
206
+ isPartial: boolean // 是否通过埋点标识属性来采集
207
+ globalDebounce: number // 设定全部元素的采集防抖-毫秒值
208
+ partialAttribute: string // 埋点标识属性名称
209
+ debounceAttribute: string // 防抖时长标识属性名称,获取该标识的值作为该元素的点击采集防抖-毫秒值
210
+ }
211
+ /** http插件配置 */
212
+ http: {
213
+ isCustomRequest: boolean // 是否启用自定义请求
214
+ requestConfig: {
215
+ method: 'POST' | 'GET' | 'PUT'
216
+ headers: {
217
+ // 常见headers配置
218
+ }
219
+ }
220
+ customMethod: (data: any, done: any, errCatch: any) => any // 自定义请求,data为采集上报的参数数据,done为成功回调,errCatch为失败回调
221
+ }
222
+ /** userInfo插件配置 */
223
+ userInfo: {
224
+ getData: () => any // 自定义获取用户数据
225
+ }
226
+ /** pagePerformance插件配置 */
227
+ pagePerformance: {
228
+ entryTypes: Array<string> // 要采集的性能数据类型(paint、resource、longtask等常见浏览器性能数据类型)
229
+ }
230
+ }
231
+ ```
package/type.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ export as namespace Monitor
2
+
3
+ // Monitor-React函数
4
+ export function useMonitor(
5
+ React: any,
6
+ options?: { history?: any },
7
+ configs?: DEFAULT_CONFIG,
8
+ pluginConfig?: PLUGIN_CONFIG
9
+ ): {
10
+ MonitorWrapper: React.ComponentType<{ children: React.ReactNode }>
11
+ mt: any
12
+ }
13
+
14
+ // Monitor-React插件配置
15
+ export interface DEFAULT_CONFIG {
16
+ key: string
17
+ url: string
18
+ platform: string
19
+ trackList?: string[]
20
+ pluginConfig?: PLUGIN_CONFIG
21
+ Router?: any
22
+ /** 与后端约定相同字符串时,上报 `/monitor/add` 的 body 将使用 AES-256-GCM 加密 */
23
+ reportEncryptSecret?: string
24
+ /** 采样率 0~1,默认 1 全量 */
25
+ sampleRate?: number
26
+ /**
27
+ * `session`(默认):当前页生命周期内是否上报只判定一次,便于近似「按访问采样」;
28
+ * `event`:每条埋点独立按 sampleRate 随机
29
+ */
30
+ sampleMode?: 'session' | 'event'
31
+ }
32
+
33
+ export interface PLUGIN_CONFIG {
34
+ log?: {
35
+ type: 'time' | 'num' | 'hybrid'
36
+ time?: number
37
+ max?: number
38
+ MAX_HTTP_FAIL?: number
39
+ customMethod?: (item: any) => any
40
+ }
41
+ ajax?: {
42
+ req?: boolean
43
+ res?: boolean
44
+ customMethod?: (data: any, [ajax]: [any?]) => any
45
+ }
46
+ http?: {
47
+ isCustomRequest?: boolean
48
+ requestConfig?: {
49
+ method: 'POST' | 'GET' | 'PUT'
50
+ headers?: {
51
+ [name: string]: any
52
+ }
53
+ }
54
+ }
55
+ click?: {
56
+ isPartial?: boolean
57
+ globalDebounce?: number
58
+ partialAttribute?: string
59
+ debounceAttribute?: string
60
+ }
61
+ userInfo?: {
62
+ getData?: () => any
63
+ }
64
+ pagePerformance?: {
65
+ entryTypes?: Array<string>
66
+ }
67
+ }
68
+
69
+ export default useMonitor