rrweb
Version:
record and replay the web
4 lines • 157 kB
JavaScript
var rrweb=function(ee){"use strict";var F;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(F||(F={}));function rr(t){return t.nodeType===t.ELEMENT_NODE}function je(t){var e=t?.host;return Boolean(e?.shadowRoot===t)}function Ve(t){return Object.prototype.toString.call(t)==="[object ShadowRoot]"}function jn(t){return t.includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t}function ft(t){try{var e=t.rules||t.cssRules;return e?jn(Array.from(e).map(nr).join("")):null}catch{return null}}function nr(t){var e=t.cssText;if(Vn(t))try{e=ft(t.styleSheet)||e}catch{}return e}function Vn(t){return"styleSheet"in t}var gt=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(e){var r;if(!e)return-1;var n=(r=this.getMeta(e))===null||r===void 0?void 0:r.id;return n??-1},t.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},t.prototype.removeNodeFromMap=function(e){var r=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(o){return r.removeNodeFromMap(o)})},t.prototype.has=function(e){return this.idNodeMap.has(e)},t.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},t.prototype.add=function(e,r){var n=r.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,r)},t.prototype.replace=function(e,r){var n=this.getNode(e);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(r,o)}this.idNodeMap.set(e,r)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function or(){return new gt}function yt(t){var e=t.maskInputOptions,r=t.tagName,n=t.type,o=t.value,s=t.maskInputFn,i=o||"";return(e[r.toLowerCase()]||e[n])&&(s?i=s(i):i="*".repeat(i.length)),i}var ir="__rrweb_original__";function Bn(t){var e=t.getContext("2d");if(!e)return!0;for(var r=50,n=0;n<t.width;n+=r)for(var o=0;o<t.height;o+=r){var s=e.getImageData,i=ir in s?s[ir]:s,l=new Uint32Array(i.call(e,n,o,Math.min(r,t.width-n),Math.min(r,t.height-o)).data.buffer);if(l.some(function(a){return a!==0}))return!1}return!0}var Gn=1,zn=new RegExp("[^a-z0-9-_:]"),Be=-2;function sr(){return Gn++}function Hn(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return zn.test(e)?"div":e}function Yn(t){return t.cssRules?Array.from(t.cssRules).map(function(e){return e.cssText||""}).join(""):""}function Xn(t){var e="";return t.indexOf("//")>-1?e=t.split("/").slice(0,3).join("/"):e=t.split("/")[0],e=e.split("?")[0],e}var De,ar,Zn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Kn=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,Jn=/^(data:)([^,]*),(.*)/i;function et(t,e){return(t||"").replace(Zn,function(r,n,o,s,i,l){var a=o||i||l,c=n||s||"";if(!a)return r;if(!Kn.test(a)||Jn.test(a))return"url(".concat(c).concat(a).concat(c,")");if(a[0]==="/")return"url(".concat(c).concat(Xn(e)+a).concat(c,")");var u=e.split("/"),d=a.split("/");u.pop();for(var h=0,p=d;h<p.length;h++){var m=p[h];m!=="."&&(m===".."?u.pop():u.push(m))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var Qn=/^[^ \t\n\r\u000c]+/,qn=/^[, \t\n\r\u000c]+/;function eo(t,e){if(e.trim()==="")return e;var r=0;function n(c){var u,d=c.exec(e.substring(r));return d?(u=d[0],r+=u.length,u):""}for(var o=[];n(qn),!(r>=e.length);){var s=n(Qn);if(s.slice(-1)===",")s=tt(t,s.substring(0,s.length-1)),o.push(s);else{var i="";s=tt(t,s);for(var l=!1;;){var a=e.charAt(r);if(a===""){o.push((s+i).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){r+=1,o.push((s+i).trim());break}else a==="("&&(l=!0);i+=a,r+=1}}}return o.join(", ")}function tt(t,e){if(!e||e.trim()==="")return e;var r=t.createElement("a");return r.href=e,r.href}function to(t){return Boolean(t.tagName==="svg"||t.ownerSVGElement)}function vt(){var t=document.createElement("a");return t.href="",t.href}function lr(t,e,r,n){return r==="src"||r==="href"&&n&&!(e==="use"&&n[0]==="#")||r==="xlink:href"&&n&&n[0]!=="#"||r==="background"&&n&&(e==="table"||e==="td"||e==="th")?tt(t,n):r==="srcset"&&n?eo(t,n):r==="style"&&n?et(n,vt()):e==="object"&&r==="data"&&n?tt(t,n):n}function ro(t,e,r){if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(var n=t.classList.length;n--;){var o=t.classList[n];if(e.test(o))return!0}return r?t.matches(r):!1}function rt(t,e,r){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return r?rt(t.parentNode,e,r):!1;for(var n=t.classList.length;n--;){var o=t.classList[n];if(e.test(o))return!0}return r?rt(t.parentNode,e,r):!1}function cr(t,e,r){var n=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(n===null)return!1;if(typeof e=="string"){if(n.classList.contains(e)||n.closest(".".concat(e)))return!0}else if(rt(n,e,!0))return!0;return!!(r&&(n.matches(r)||n.closest(r)))}function no(t,e,r){var n=t.contentWindow;if(n){var o=!1,s;try{s=n.document.readyState}catch{return}if(s!=="complete"){var i=setTimeout(function(){o||(e(),o=!0)},r);t.addEventListener("load",function(){clearTimeout(i),o=!0,e()});return}var l="about:blank";if(n.location.href!==l||t.src===l||t.src==="")return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}}function oo(t,e,r){var n=!1,o;try{o=t.sheet}catch{return}if(!o){var s=setTimeout(function(){n||(e(),n=!0)},r);t.addEventListener("load",function(){clearTimeout(s),n=!0,e()})}}function io(t,e){var r=e.doc,n=e.mirror,o=e.blockClass,s=e.blockSelector,i=e.maskTextClass,l=e.maskTextSelector,a=e.inlineStylesheet,c=e.maskInputOptions,u=c===void 0?{}:c,d=e.maskTextFn,h=e.maskInputFn,p=e.dataURLOptions,m=p===void 0?{}:p,y=e.inlineImages,v=e.recordCanvas,f=e.keepIframeSrcFn,g=e.newlyAddedElement,b=g===void 0?!1:g,N=so(r,n);switch(t.nodeType){case t.DOCUMENT_NODE:return t.compatMode!=="CSS1Compat"?{type:F.Document,childNodes:[],compatMode:t.compatMode}:{type:F.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:F.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:N};case t.ELEMENT_NODE:return lo(t,{doc:r,blockClass:o,blockSelector:s,inlineStylesheet:a,maskInputOptions:u,maskInputFn:h,dataURLOptions:m,inlineImages:y,recordCanvas:v,keepIframeSrcFn:f,newlyAddedElement:b,rootId:N});case t.TEXT_NODE:return ao(t,{maskTextClass:i,maskTextSelector:l,maskTextFn:d,rootId:N});case t.CDATA_SECTION_NODE:return{type:F.CDATA,textContent:"",rootId:N};case t.COMMENT_NODE:return{type:F.Comment,textContent:t.textContent||"",rootId:N};default:return!1}}function so(t,e){if(e.hasNode(t)){var r=e.getId(t);return r===1?void 0:r}}function ao(t,e){var r,n=e.maskTextClass,o=e.maskTextSelector,s=e.maskTextFn,i=e.rootId,l=t.parentNode&&t.parentNode.tagName,a=t.textContent,c=l==="STYLE"?!0:void 0,u=l==="SCRIPT"?!0:void 0;if(c&&a){try{t.nextSibling||t.previousSibling||!((r=t.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(a=Yn(t.parentNode.sheet))}catch(d){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(d),t)}a=et(a,vt())}return u&&(a="SCRIPT_PLACEHOLDER"),!c&&!u&&a&&cr(t,n,o)&&(a=s?s(a):a.replace(/[\S]/g,"*")),{type:F.Text,textContent:a||"",isStyle:c,rootId:i}}function lo(t,e){for(var r=e.doc,n=e.blockClass,o=e.blockSelector,s=e.inlineStylesheet,i=e.maskInputOptions,l=i===void 0?{}:i,a=e.maskInputFn,c=e.dataURLOptions,u=c===void 0?{}:c,d=e.inlineImages,h=e.recordCanvas,p=e.keepIframeSrcFn,m=e.newlyAddedElement,y=m===void 0?!1:m,v=e.rootId,f=ro(t,n,o),g=Hn(t),b={},N=t.attributes.length,R=0;R<N;R++){var k=t.attributes[R];b[k.name]=lr(r,g,k.name,k.value)}if(g==="link"&&s){var x=Array.from(r.styleSheets).find(function(S){return S.href===t.href}),E=null;x&&(E=ft(x)),E&&(delete b.rel,delete b.href,b._cssText=et(E,x.href))}if(g==="style"&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){var E=ft(t.sheet);E&&(b._cssText=et(E,vt()))}if(g==="input"||g==="textarea"||g==="select"){var H=t.value,W=t.checked;b.type!=="radio"&&b.type!=="checkbox"&&b.type!=="submit"&&b.type!=="button"&&H?b.value=yt({type:b.type,tagName:g,value:H,maskInputOptions:l,maskInputFn:a}):W&&(b.checked=W)}if(g==="option"&&(t.selected&&!l.select?b.selected=!0:delete b.selected),g==="canvas"&&h){if(t.__context==="2d")Bn(t)||(b.rr_dataURL=t.toDataURL(u.type,u.quality));else if(!("__context"in t)){var Z=t.toDataURL(u.type,u.quality),P=document.createElement("canvas");P.width=t.width,P.height=t.height;var B=P.toDataURL(u.type,u.quality);Z!==B&&(b.rr_dataURL=Z)}}if(g==="img"&&d){De||(De=r.createElement("canvas"),ar=De.getContext("2d"));var L=t,U=L.crossOrigin;L.crossOrigin="anonymous";var A=function(){try{De.width=L.naturalWidth,De.height=L.naturalHeight,ar.drawImage(L,0,0),b.rr_dataURL=De.toDataURL(u.type,u.quality)}catch(S){console.warn("Cannot inline img src=".concat(L.currentSrc,"! Error: ").concat(S))}U?b.crossOrigin=U:L.removeAttribute("crossorigin")};L.complete&&L.naturalWidth!==0?A():L.onload=A}if((g==="audio"||g==="video")&&(b.rr_mediaState=t.paused?"paused":"played",b.rr_mediaCurrentTime=t.currentTime),y||(t.scrollLeft&&(b.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(b.rr_scrollTop=t.scrollTop)),f){var D=t.getBoundingClientRect(),z=D.width,w=D.height;b={class:b.class,rr_width:"".concat(z,"px"),rr_height:"".concat(w,"px")}}return g==="iframe"&&!p(b.src)&&(t.contentDocument||(b.rr_src=b.src),delete b.src),{type:F.Element,tagName:g,attributes:b,childNodes:[],isSVG:to(t)||void 0,needBlock:f,rootId:v}}function Y(t){return t===void 0?"":t.toLowerCase()}function co(t,e){return!!(e.comment&&t.type===F.Comment||t.type===F.Element&&(e.script&&(t.tagName==="script"||t.tagName==="link"&&t.attributes.rel==="preload"&&t.attributes.as==="script"||t.tagName==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&t.attributes.href.endsWith(".js"))||e.headFavicon&&(t.tagName==="link"&&t.attributes.rel==="shortcut icon"||t.tagName==="meta"&&(Y(t.attributes.name).match(/^msapplication-tile(image|color)$/)||Y(t.attributes.name)==="application-name"||Y(t.attributes.rel)==="icon"||Y(t.attributes.rel)==="apple-touch-icon"||Y(t.attributes.rel)==="shortcut icon"))||t.tagName==="meta"&&(e.headMetaDescKeywords&&Y(t.attributes.name).match(/^description|keywords$/)||e.headMetaSocial&&(Y(t.attributes.property).match(/^(og|twitter|fb):/)||Y(t.attributes.name).match(/^(og|twitter):/)||Y(t.attributes.name)==="pinterest")||e.headMetaRobots&&(Y(t.attributes.name)==="robots"||Y(t.attributes.name)==="googlebot"||Y(t.attributes.name)==="bingbot")||e.headMetaHttpEquiv&&t.attributes["http-equiv"]!==void 0||e.headMetaAuthorship&&(Y(t.attributes.name)==="author"||Y(t.attributes.name)==="generator"||Y(t.attributes.name)==="framework"||Y(t.attributes.name)==="publisher"||Y(t.attributes.name)==="progid"||Y(t.attributes.property).match(/^article:/)||Y(t.attributes.property).match(/^product:/))||e.headMetaVerification&&(Y(t.attributes.name)==="google-site-verification"||Y(t.attributes.name)==="yandex-verification"||Y(t.attributes.name)==="csrf-token"||Y(t.attributes.name)==="p:domain_verify"||Y(t.attributes.name)==="verify-v1"||Y(t.attributes.name)==="verification"||Y(t.attributes.name)==="shopify-checkout-api-token"))))}function Oe(t,e){var r=e.doc,n=e.mirror,o=e.blockClass,s=e.blockSelector,i=e.maskTextClass,l=e.maskTextSelector,a=e.skipChild,c=a===void 0?!1:a,u=e.inlineStylesheet,d=u===void 0?!0:u,h=e.maskInputOptions,p=h===void 0?{}:h,m=e.maskTextFn,y=e.maskInputFn,v=e.slimDOMOptions,f=e.dataURLOptions,g=f===void 0?{}:f,b=e.inlineImages,N=b===void 0?!1:b,R=e.recordCanvas,k=R===void 0?!1:R,x=e.onSerialize,E=e.onIframeLoad,H=e.iframeLoadTimeout,W=H===void 0?5e3:H,Z=e.onStylesheetLoad,P=e.stylesheetLoadTimeout,B=P===void 0?5e3:P,L=e.keepIframeSrcFn,U=L===void 0?function(){return!1}:L,A=e.newlyAddedElement,D=A===void 0?!1:A,z=e.preserveWhiteSpace,w=z===void 0?!0:z,S=io(t,{doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:y,dataURLOptions:g,inlineImages:N,recordCanvas:k,keepIframeSrcFn:U,newlyAddedElement:D});if(!S)return console.warn(t,"not serialized"),null;var M;n.hasNode(t)?M=n.getId(t):co(S,v)||!w&&S.type===F.Text&&!S.isStyle&&!S.textContent.replace(/^\s+|\s+$/gm,"").length?M=Be:M=sr();var I=Object.assign(S,{id:M});if(n.add(t,I),M===Be)return null;x&&x(t);var $=!c;if(I.type===F.Element){$=$&&!I.needBlock,delete I.needBlock;var G=t.shadowRoot;G&&Ve(G)&&(I.isShadowHost=!0)}if((I.type===F.Document||I.type===F.Element)&&$){v.headWhitespace&&I.type===F.Element&&I.tagName==="head"&&(w=!1);for(var K={doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:c,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:y,slimDOMOptions:v,dataURLOptions:g,inlineImages:N,recordCanvas:k,preserveWhiteSpace:w,onSerialize:x,onIframeLoad:E,iframeLoadTimeout:W,onStylesheetLoad:Z,stylesheetLoadTimeout:B,keepIframeSrcFn:U},O=0,te=Array.from(t.childNodes);O<te.length;O++){var ne=te[O],J=Oe(ne,K);J&&I.childNodes.push(J)}if(rr(t)&&t.shadowRoot)for(var de=0,j=Array.from(t.shadowRoot.childNodes);de<j.length;de++){var ne=j[de],J=Oe(ne,K);J&&(Ve(t.shadowRoot)&&(J.isShadow=!0),I.childNodes.push(J))}}return t.parentNode&&je(t.parentNode)&&Ve(t.parentNode)&&(I.isShadow=!0),I.type===F.Element&&I.tagName==="iframe"&&no(t,function(){var ce=t.contentDocument;if(ce&&E){var qe=Oe(ce,{doc:ce,mirror:n,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:y,slimDOMOptions:v,dataURLOptions:g,inlineImages:N,recordCanvas:k,preserveWhiteSpace:w,onSerialize:x,onIframeLoad:E,iframeLoadTimeout:W,onStylesheetLoad:Z,stylesheetLoadTimeout:B,keepIframeSrcFn:U});qe&&E(t,qe)}},W),I.type===F.Element&&I.tagName==="link"&&I.attributes.rel==="stylesheet"&&oo(t,function(){if(Z){var ce=Oe(t,{doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:y,slimDOMOptions:v,dataURLOptions:g,inlineImages:N,recordCanvas:k,preserveWhiteSpace:w,onSerialize:x,onIframeLoad:E,iframeLoadTimeout:W,onStylesheetLoad:Z,stylesheetLoadTimeout:B,keepIframeSrcFn:U});ce&&Z(t,ce)}},B),I}function uo(t,e){var r=e||{},n=r.mirror,o=n===void 0?new gt:n,s=r.blockClass,i=s===void 0?"rr-block":s,l=r.blockSelector,a=l===void 0?null:l,c=r.maskTextClass,u=c===void 0?"rr-mask":c,d=r.maskTextSelector,h=d===void 0?null:d,p=r.inlineStylesheet,m=p===void 0?!0:p,y=r.inlineImages,v=y===void 0?!1:y,f=r.recordCanvas,g=f===void 0?!1:f,b=r.maskAllInputs,N=b===void 0?!1:b,R=r.maskTextFn,k=r.maskInputFn,x=r.slimDOM,E=x===void 0?!1:x,H=r.dataURLOptions,W=r.preserveWhiteSpace,Z=r.onSerialize,P=r.onIframeLoad,B=r.iframeLoadTimeout,L=r.onStylesheetLoad,U=r.stylesheetLoadTimeout,A=r.keepIframeSrcFn,D=A===void 0?function(){return!1}:A,z=N===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:N===!1?{password:!0}:N,w=E===!0||E==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:E==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:E===!1?{}:E;return Oe(t,{doc:t,mirror:o,blockClass:i,blockSelector:a,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:m,maskInputOptions:z,maskTextFn:R,maskInputFn:k,slimDOMOptions:w,dataURLOptions:H,inlineImages:v,recordCanvas:g,preserveWhiteSpace:W,onSerialize:Z,onIframeLoad:P,iframeLoadTimeout:B,onStylesheetLoad:L,stylesheetLoadTimeout:U,keepIframeSrcFn:D,newlyAddedElement:!1})}var ur=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function ho(t,e){e===void 0&&(e={});var r=1,n=1;function o(w){var S=w.match(/\n/g);S&&(r+=S.length);var M=w.lastIndexOf(`
`);n=M===-1?n+w.length:w.length-M}function s(){var w={line:r,column:n};return function(S){return S.position=new i(w),m(),S}}var i=function(){function w(S){this.start=S,this.end={line:r,column:n},this.source=e.source}return w}();i.prototype.content=t;var l=[];function a(w){var S=new Error("".concat(e.source||"",":").concat(r,":").concat(n,": ").concat(w));if(S.reason=w,S.filename=e.source,S.line=r,S.column=n,S.source=t,e.silent)l.push(S);else throw S}function c(){var w=h();return{type:"stylesheet",stylesheet:{source:e.source,rules:w,parsingErrors:l}}}function u(){return p(/^{\s*/)}function d(){return p(/^}/)}function h(){var w,S=[];for(m(),y(S);t.length&&t.charAt(0)!=="}"&&(w=D()||z());)w!==!1&&(S.push(w),y(S));return S}function p(w){var S=w.exec(t);if(S){var M=S[0];return o(M),t=t.slice(M.length),S}}function m(){p(/^\s*/)}function y(w){w===void 0&&(w=[]);for(var S;S=v();)S!==!1&&w.push(S),S=v();return w}function v(){var w=s();if(!(t.charAt(0)!=="/"||t.charAt(1)!=="*")){for(var S=2;t.charAt(S)!==""&&(t.charAt(S)!=="*"||t.charAt(S+1)!=="/");)++S;if(S+=2,t.charAt(S-1)==="")return a("End of comment missing");var M=t.slice(2,S-2);return n+=2,o(M),t=t.slice(S),n+=2,w({type:"comment",comment:M})}}function f(){var w=p(/^([^{]+)/);if(w)return ve(w[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(S){return S.replace(/,/g,"\u200C")}).split(/\s*(?![^(]*\)),\s*/).map(function(S){return S.replace(/\u200C/g,",")})}function g(){var w=s(),S=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(S){var M=ve(S[0]);if(!p(/^:\s*/))return a("property missing ':'");var I=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),$=w({type:"declaration",property:M.replace(ur,""),value:I?ve(I[0]).replace(ur,""):""});return p(/^[;\s]*/),$}}function b(){var w=[];if(!u())return a("missing '{'");y(w);for(var S;S=g();)S!==!1&&(w.push(S),y(w)),S=g();return d()?w:a("missing '}'")}function N(){for(var w,S=[],M=s();w=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)S.push(w[1]),p(/^,\s*/);if(S.length)return M({type:"keyframe",values:S,declarations:b()})}function R(){var w=s(),S=p(/^@([-\w]+)?keyframes\s*/);if(S){var M=S[1];if(S=p(/^([-\w]+)\s*/),!S)return a("@keyframes missing name");var I=S[1];if(!u())return a("@keyframes missing '{'");for(var $,G=y();$=N();)G.push($),G=G.concat(y());return d()?w({type:"keyframes",name:I,vendor:M,keyframes:G}):a("@keyframes missing '}'")}}function k(){var w=s(),S=p(/^@supports *([^{]+)/);if(S){var M=ve(S[1]);if(!u())return a("@supports missing '{'");var I=y().concat(h());return d()?w({type:"supports",supports:M,rules:I}):a("@supports missing '}'")}}function x(){var w=s(),S=p(/^@host\s*/);if(S){if(!u())return a("@host missing '{'");var M=y().concat(h());return d()?w({type:"host",rules:M}):a("@host missing '}'")}}function E(){var w=s(),S=p(/^@media *([^{]+)/);if(S){var M=ve(S[1]);if(!u())return a("@media missing '{'");var I=y().concat(h());return d()?w({type:"media",media:M,rules:I}):a("@media missing '}'")}}function H(){var w=s(),S=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(S)return w({type:"custom-media",name:ve(S[1]),media:ve(S[2])})}function W(){var w=s(),S=p(/^@page */);if(S){var M=f()||[];if(!u())return a("@page missing '{'");for(var I=y(),$;$=g();)I.push($),I=I.concat(y());return d()?w({type:"page",selectors:M,declarations:I}):a("@page missing '}'")}}function Z(){var w=s(),S=p(/^@([-\w]+)?document *([^{]+)/);if(S){var M=ve(S[1]),I=ve(S[2]);if(!u())return a("@document missing '{'");var $=y().concat(h());return d()?w({type:"document",document:I,vendor:M,rules:$}):a("@document missing '}'")}}function P(){var w=s(),S=p(/^@font-face\s*/);if(S){if(!u())return a("@font-face missing '{'");for(var M=y(),I;I=g();)M.push(I),M=M.concat(y());return d()?w({type:"font-face",declarations:M}):a("@font-face missing '}'")}}var B=A("import"),L=A("charset"),U=A("namespace");function A(w){var S=new RegExp("^@"+w+"\\s*([^;]+);");return function(){var M=s(),I=p(S);if(I){var $={type:w};return $[w]=I[1].trim(),M($)}}}function D(){if(t[0]==="@")return R()||E()||H()||k()||B()||L()||U()||Z()||W()||x()||P()}function z(){var w=s(),S=f();return S?(y(),w({type:"rule",selectors:S,declarations:b()})):a("selector missing")}return bt(c())}function ve(t){return t?t.replace(/^\s+|\s+$/g,""):""}function bt(t,e){for(var r=t&&typeof t.type=="string",n=r?t:e,o=0,s=Object.keys(t);o<s.length;o++){var i=s[o],l=t[i];Array.isArray(l)?l.forEach(function(a){bt(a,n)}):l&&typeof l=="object"&&bt(l,n)}return r&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:e||null}),t}var dr={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function po(t){var e=dr[t.tagName]?dr[t.tagName]:t.tagName;return e==="link"&&t.attributes._cssText&&(e="style"),e}function mo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var hr=/([^\\]):hover/,fo=new RegExp(hr.source,"g");function pr(t,e){var r=e?.stylesWithHoverClass.get(t);if(r)return r;var n=ho(t,{silent:!0});if(!n.stylesheet)return t;var o=[];if(n.stylesheet.rules.forEach(function(l){"selectors"in l&&(l.selectors||[]).forEach(function(a){hr.test(a)&&o.push(a)})}),o.length===0)return t;var s=new RegExp(o.filter(function(l,a){return o.indexOf(l)===a}).sort(function(l,a){return a.length-l.length}).map(function(l){return mo(l)}).join("|"),"g"),i=t.replace(s,function(l){var a=l.replace(fo,"$1.\\:hover");return"".concat(l,", ").concat(a)});return e?.stylesWithHoverClass.set(t,i),i}function mr(){var t=new Map;return{stylesWithHoverClass:t}}function go(t,e){var r=e.doc,n=e.hackCss,o=e.cache;switch(t.type){case F.Document:return r.implementation.createDocument(null,"",null);case F.DocumentType:return r.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case F.Element:{var s=po(t),i;t.isSVG?i=r.createElementNS("http://www.w3.org/2000/svg",s):i=r.createElement(s);var l={};for(var a in t.attributes)if(Object.prototype.hasOwnProperty.call(t.attributes,a)){var c=t.attributes[a];if(!(s==="option"&&a==="selected"&&c===!1)){if(c===!0&&(c=""),a.startsWith("rr_")){l[a]=c;continue}var u=s==="textarea"&&a==="value",d=s==="style"&&a==="_cssText";if(d&&n&&typeof c=="string"&&(c=pr(c,o)),(u||d)&&typeof c=="string"){for(var h=r.createTextNode(c),p=0,m=Array.from(i.childNodes);p<m.length;p++){var y=m[p];y.nodeType===i.TEXT_NODE&&i.removeChild(y)}i.appendChild(h);continue}try{if(t.isSVG&&a==="xlink:href")i.setAttributeNS("http://www.w3.org/1999/xlink",a,c.toString());else if(a==="onload"||a==="onclick"||a.substring(0,7)==="onmouse")i.setAttribute("_"+a,c.toString());else if(s==="meta"&&t.attributes["http-equiv"]==="Content-Security-Policy"&&a==="content"){i.setAttribute("csp-content",c.toString());continue}else s==="link"&&t.attributes.rel==="preload"&&t.attributes.as==="script"||s==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&t.attributes.href.endsWith(".js")||(s==="img"&&t.attributes.srcset&&t.attributes.rr_dataURL?i.setAttribute("rrweb-original-srcset",t.attributes.srcset):i.setAttribute(a,c.toString()))}catch{}}}var v=function(g){var b=l[g];if(s==="canvas"&&g==="rr_dataURL"){var N=document.createElement("img");N.onload=function(){var k=i.getContext("2d");k&&k.drawImage(N,0,0,N.width,N.height)},N.src=b.toString(),i.RRNodeType&&(i.rr_dataURL=b.toString())}else if(s==="img"&&g==="rr_dataURL"){var R=i;R.currentSrc.startsWith("data:")||(R.setAttribute("rrweb-original-src",t.attributes.src),R.src=b.toString())}if(g==="rr_width")i.style.width=b.toString();else if(g==="rr_height")i.style.height=b.toString();else if(g==="rr_mediaCurrentTime"&&typeof b=="number")i.currentTime=b;else if(g==="rr_mediaState")switch(b){case"played":i.play().catch(function(k){return console.warn("media playback error",k)});break;case"paused":i.pause();break}};for(var f in l)v(f);if(t.isShadowHost)if(!i.shadowRoot)i.attachShadow({mode:"open"});else for(;i.shadowRoot.firstChild;)i.shadowRoot.removeChild(i.shadowRoot.firstChild);return i}case F.Text:return r.createTextNode(t.isStyle&&n?pr(t.textContent,o):t.textContent);case F.CDATA:return r.createCDATASection(t.textContent);case F.Comment:return r.createComment(t.textContent);default:return null}}function Ge(t,e){var r=e.doc,n=e.mirror,o=e.skipChild,s=o===void 0?!1:o,i=e.hackCss,l=i===void 0?!0:i,a=e.afterAppend,c=e.cache,u=go(t,{doc:r,hackCss:l,cache:c});if(!u)return null;if(t.rootId&&n.getNode(t.rootId)!==r&&n.replace(t.rootId,r),t.type===F.Document&&(r.close(),r.open(),t.compatMode==="BackCompat"&&t.childNodes&&t.childNodes[0].type!==F.DocumentType&&(t.childNodes[0].type===F.Element&&"xmlns"in t.childNodes[0].attributes&&t.childNodes[0].attributes.xmlns==="http://www.w3.org/1999/xhtml"?r.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):r.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),u=r),n.add(u,t),(t.type===F.Document||t.type===F.Element)&&!s)for(var d=0,h=t.childNodes;d<h.length;d++){var p=h[d],m=Ge(p,{doc:r,mirror:n,skipChild:!1,hackCss:l,afterAppend:a,cache:c});if(!m){console.warn("Failed to rebuild",p);continue}p.isShadow&&rr(u)&&u.shadowRoot?u.shadowRoot.appendChild(m):u.appendChild(m),a&&a(m,p.id)}return u}function yo(t,e){function r(i){e(i)}for(var n=0,o=t.getIds();n<o.length;n++){var s=o[n];t.has(s)&&r(t.getNode(s))}}function vo(t,e){var r=e.getMeta(t);if(r?.type===F.Element){var n=t;for(var o in r.attributes)if(Object.prototype.hasOwnProperty.call(r.attributes,o)&&o.startsWith("rr_")){var s=r.attributes[o];o==="rr_scrollLeft"&&(n.scrollLeft=s),o==="rr_scrollTop"&&(n.scrollTop=s)}}}function bo(t,e){var r=e.doc,n=e.onVisit,o=e.hackCss,s=o===void 0?!0:o,i=e.afterAppend,l=e.cache,a=e.mirror,c=a===void 0?new gt:a,u=Ge(t,{doc:r,mirror:c,skipChild:!1,hackCss:s,afterAppend:i,cache:l});return yo(c,function(d){n&&n(d),vo(d,c)}),u}function ae(t,e,r=document){const n={capture:!0,passive:!0};return r.addEventListener(t,e,n),()=>r.removeEventListener(t,e,n)}const xe=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;ee.mirror={map:{},getId(){return console.error(xe),-1},getNode(){return console.error(xe),null},removeNodeFromMap(){console.error(xe)},has(){return console.error(xe),!1},reset(){console.error(xe)}},typeof window<"u"&&window.Proxy&&window.Reflect&&(ee.mirror=new Proxy(ee.mirror,{get(t,e,r){return e==="map"&&console.error(xe),Reflect.get(t,e,r)}}));function Le(t,e,r={}){let n=null,o=0;return function(...s){const i=Date.now();!o&&r.leading===!1&&(o=i);const l=e-(i-o),a=this;l<=0||l>e?(n&&(clearTimeout(n),n=null),o=i,t.apply(a,s)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{o=r.leading===!1?0:Date.now(),n=null,t.apply(a,s)},l))}}function ze(t,e,r,n,o=window){const s=o.Object.getOwnPropertyDescriptor(t,e);return o.Object.defineProperty(t,e,n?r:{set(i){setTimeout(()=>{r.set.call(this,i)},0),s&&s.set&&s.set.call(this,i)}}),()=>ze(t,e,s||{},!0)}function Ne(t,e,r){try{if(!(e in t))return()=>{};const n=t[e],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),t[e]=o,()=>{t[e]=n}}catch{return()=>{}}}function St(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function wt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function le(t,e,r,n){if(!t)return!1;const o=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!o)return!1;if(typeof e=="string"){if(o.classList.contains(e)||n&&o.closest("."+e)!==null)return!0}else if(rt(o,e,n))return!0;return!!(r&&(t.matches(r)||n&&o.closest(r)!==null))}function fr(t,e){return e.getId(t)!==-1}function nt(t,e){return e.getId(t)===Be}function Nt(t,e){if(je(t))return!1;const r=e.getId(t);return e.has(r)?t.parentNode&&t.parentNode.nodeType===t.DOCUMENT_NODE?!1:t.parentNode?Nt(t.parentNode,e):!0:!0}function Et(t){return Boolean(t.changedTouches)}function Ct(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let r=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function gr(t){const e={},r=(o,s)=>{const i={value:o,parent:s,children:[]};return e[o.node.id]=i,i},n=[];for(const o of t){const{nextId:s,parentId:i}=o;if(s&&s in e){const l=e[s];if(l.parent){const a=l.parent.children.indexOf(l);l.parent.children.splice(a,0,r(o,l.parent))}else{const a=n.indexOf(l);n.splice(a,0,r(o,null))}continue}if(i in e){const l=e[i];l.children.push(r(o,l));continue}n.push(r(o,null))}return n}function Tt(t,e){e(t.value);for(let r=t.children.length-1;r>=0;r--)Tt(t.children[r],e)}function Ae(t,e){return Boolean(t.nodeName==="IFRAME"&&e.getMeta(t))}function Mt(t,e){return Boolean(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function It(t,e){var r,n;const o=(n=(r=t.ownerDocument)==null?void 0:r.defaultView)==null?void 0:n.frameElement;if(!o||o===e)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=o.getBoundingClientRect(),i=It(o,e),l=s.height/o.clientHeight;return{x:s.x*i.relativeScale+i.x,y:s.y*i.relativeScale+i.y,relativeScale:l,absoluteScale:i.absoluteScale*l}}function Ie(t){return Boolean(t?.shadowRoot)}function Fe(t,e){const r=t[e[0]];return e.length===1?r:Fe(r.cssRules[e[1]].cssRules,e.slice(2))}function kt(t){const e=[...t],r=e.pop();return{positions:e,index:r}}function yr(t){const e=new Set,r=[];for(let n=t.length;n--;){const o=t[n];e.has(o.id)||(r.push(o),e.add(o.id))}return r}class Rt{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var r;return(r=this.styleIDMap.get(e))!=null?r:-1}has(e){return this.styleIDMap.has(e)}add(e,r){if(this.has(e))return this.getId(e);let n;return r===void 0?n=this.id++:n=r,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 So=Object.freeze({__proto__:null,on:ae,get _mirror(){return ee.mirror},throttle:Le,hookSetter:ze,patch:Ne,getWindowHeight:St,getWindowWidth:wt,isBlocked:le,isSerialized:fr,isIgnored:nt,isAncestorRemoved:Nt,isTouchEvent:Et,polyfill:Ct,queueToResolveTrees:gr,iterateResolveTree:Tt,isSerializedIframe:Ae,isSerializedStylesheet:Mt,getBaseDimension:It,hasShadowRoot:Ie,getNestedRule:Fe,getPositionsAndIndex:kt,uniqueTextMutations:yr,StyleSheetMirror:Rt}),T=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(T||{}),C=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(C||{}),ie=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(ie||{}),be=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(be||{}),Se=(t=>(t[t.Play=0]="Play",t[t.Pause=1]="Pause",t[t.Seeked=2]="Seeked",t[t.VolumeChange=3]="VolumeChange",t[t.RateChange=4]="RateChange",t))(Se||{}),V=(t=>(t.Start="start",t.Pause="pause",t.Resume="resume",t.Resize="resize",t.Finish="finish",t.FullsnapshotRebuilded="fullsnapshot-rebuilded",t.LoadStylesheetStart="load-stylesheet-start",t.LoadStylesheetEnd="load-stylesheet-end",t.SkipStart="skip-start",t.SkipEnd="skip-end",t.MouseInteraction="mouse-interaction",t.EventCast="event-cast",t.CustomEvent="custom-event",t.Flush="flush",t.StateChange="state-change",t.PlayBack="play-back",t.Destroy="destroy",t))(V||{});function vr(t){return"__ln"in t}class wo{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<e;n++)r=r?.next||null;return r}addNode(e){const r={value:e,previous:null,next:null};if(e.__ln=r,e.previousSibling&&vr(e.previousSibling)){const n=e.previousSibling.__ln.next;r.next=n,r.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(e.nextSibling&&vr(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;r.previous=n,r.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;this.length++}removeNode(e){const r=e.__ln;!this.head||(r.previous?(r.previous.next=r.next,r.next&&(r.next.previous=r.previous)):(this.head=r.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const br=(t,e)=>`${t}@${e}`;class No{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=[],r=new wo,n=l=>{let a=l,c=Be;for(;c===Be;)a=a&&a.nextSibling,c=a&&this.mirror.getId(a);return c},o=l=>{var a,c,u,d;let h=null;((c=(a=l.getRootNode)==null?void 0:a.call(l))==null?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host&&(h=l.getRootNode().host);let p=h;for(;((d=(u=p?.getRootNode)==null?void 0:u.call(p))==null?void 0:d.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&p.getRootNode().host;)p=p.getRootNode().host;const m=!this.doc.contains(l)&&(!p||!this.doc.contains(p));if(!l.parentNode||m)return;const y=je(l.parentNode)?this.mirror.getId(h):this.mirror.getId(l.parentNode),v=n(l);if(y===-1||v===-1)return r.addNode(l);const f=Oe(l,{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:g=>{Ae(g,this.mirror)&&this.iframeManager.addIframe(g),Mt(g,this.mirror)&&this.stylesheetManager.trackLinkElement(g),Ie(l)&&this.shadowDomManager.addShadowRoot(l.shadowRoot,this.doc)},onIframeLoad:(g,b)=>{this.iframeManager.attachIframe(g,b),this.shadowDomManager.observeAttachShadow(g)},onStylesheetLoad:(g,b)=>{this.stylesheetManager.attachLinkElement(g,b)}});f&&e.push({parentId:y,nextId:v,node:f})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of Array.from(this.movedSet.values()))Sr(this.removes,l,this.mirror)&&!this.movedSet.has(l.parentNode)||o(l);for(const l of Array.from(this.addedSet.values()))!Nr(this.droppedSet,l)&&!Sr(this.removes,l,this.mirror)||Nr(this.movedSet,l)?o(l):this.droppedSet.add(l);let s=null;for(;r.length;){let l=null;if(s){const a=this.mirror.getId(s.value.parentNode),c=n(s.value);a!==-1&&c!==-1&&(l=s)}if(!l)for(let a=r.length-1;a>=0;a--){const c=r.get(a);if(c){const u=this.mirror.getId(c.value.parentNode);if(n(c.value)===-1)continue;if(u!==-1){l=c;break}else{const d=c.value;if(d.parentNode&&d.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const h=d.parentNode.host;if(this.mirror.getId(h)!==-1){l=c;break}}}}}if(!l){for(;r.head;)r.removeNode(r.head.value);break}s=l.previous,r.removeNode(l.value),o(l.value)}const i={texts:this.texts.map(l=>({id:this.mirror.getId(l.node),value:l.value})).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>({id:this.mirror.getId(l.node),attributes:l.attributes})).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:e};!i.texts.length&&!i.attributes.length&&!i.removes.length&&!i.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!nt(e.target,this.mirror))switch(e.type){case"characterData":{const r=e.target.textContent;!le(e.target,this.blockClass,this.blockSelector,!1)&&r!==e.oldValue&&this.texts.push({value:cr(e.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:e.target});break}case"attributes":{const r=e.target;let n=e.target.getAttribute(e.attributeName);if(e.attributeName==="value"&&(n=yt({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),le(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find(s=>s.node===e.target);if(r.tagName==="IFRAME"&&e.attributeName==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)e.attributeName="rr_src";else return;if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),e.attributeName==="style"){const s=this.doc.createElement("span");e.oldValue&&s.setAttribute("style",e.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const i=o.attributes.style;for(const l of Array.from(r.style)){const a=r.style.getPropertyValue(l),c=r.style.getPropertyPriority(l);(a!==s.style.getPropertyValue(l)||c!==s.style.getPropertyPriority(l))&&(c===""?i[l]=a:i[l]=[a,c])}for(const l of Array.from(s.style))r.style.getPropertyValue(l)===""&&(i[l]=!1)}else o.attributes[e.attributeName]=lr(this.doc,r.tagName,e.attributeName,n);break}case"childList":{if(le(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(r=>this.genAdds(r,e.target)),e.removedNodes.forEach(r=>{const n=this.mirror.getId(r),o=je(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);le(e.target,this.blockClass,this.blockSelector,!1)||nt(r,this.mirror)||!fr(r,this.mirror)||(this.addedSet.has(r)?(Dt(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(e.target)&&n===-1||Nt(e.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[br(n,o)]?Dt(this.movedSet,r):this.removes.push({parentId:o,id:n,isShadow:je(e.target)&&Ve(e.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(e,r)=>{if(this.mirror.hasNode(e)){if(nt(e,this.mirror))return;this.movedSet.add(e);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[br(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);le(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(n=>this.genAdds(n))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(r=>{this[r]=e[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Dt(t,e){t.delete(e),e.childNodes.forEach(r=>Dt(t,r))}function Sr(t,e,r){return t.length===0?!1:wr(t,e,r)}function wr(t,e,r){const{parentNode:n}=e;if(!n)return!1;const o=r.getId(n);return t.some(s=>s.id===o)?!0:wr(t,n,r)}function Nr(t,e){return t.size===0?!1:Er(t,e)}function Er(t,e){const{parentNode:r}=e;return r?t.has(r)?!0:Er(t,r):!1}var Eo=Object.defineProperty,Co=Object.defineProperties,To=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,Mo=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable,Tr=(t,e,r)=>e in t?Eo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mr=(t,e)=>{for(var r in e||(e={}))Mo.call(e,r)&&Tr(t,r,e[r]);if(Cr)for(var r of Cr(e))Io.call(e,r)&&Tr(t,r,e[r]);return t},ko=(t,e)=>Co(t,To(e));const ke=[],Ir=typeof CSSGroupingRule<"u",kr=typeof CSSMediaRule<"u",Rr=typeof CSSSupportsRule<"u",Dr=typeof CSSConditionRule<"u";function He(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch{return t.target}}function Or(t,e){var r,n;const o=new No;ke.push(o),o.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const i=(n=(r=window?.Zone)==null?void 0:r.__symbol__)==null?void 0:n.call(r,"MutationObserver");i&&window[i]&&(s=window[i]);const l=new s(o.processMutations.bind(o));return l.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function Ro({mousemoveCb:t,sampling:e,doc:r,mirror:n}){if(e.mousemove===!1)return()=>{};const o=typeof e.mousemove=="number"?e.mousemove:50,s=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500;let i=[],l;const a=Le(d=>{const h=Date.now()-l;t(i.map(p=>(p.timeOffset-=h,p)),d),i=[],l=null},s),c=Le(d=>{const h=He(d),{clientX:p,clientY:m}=Et(d)?d.changedTouches[0]:d;l||(l=Date.now()),i.push({x:p,y:m,id:n.getId(h),timeOffset:Date.now()-l}),a(typeof DragEvent<"u"&&d instanceof DragEvent?C.Drag:d instanceof MouseEvent?C.MouseMove:C.TouchMove)},o,{trailing:!1}),u=[ae("mousemove",c,r),ae("touchmove",c,r),ae("drag",c,r)];return()=>{u.forEach(d=>d())}}function Do({mouseInteractionCb:t,doc:e,mirror:r,blockClass:n,blockSelector:o,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const i=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,l=[],a=c=>u=>{const d=He(u);if(le(d,n,o,!0))return;const h=Et(u)?u.changedTouches[0]:u;if(!h)return;const p=r.getId(d),{clientX:m,clientY:y}=h;t({type:ie[c],id:p,x:m,y})};return Object.keys(ie).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&i[c]!==!1).forEach(c=>{const u=c.toLowerCase(),d=a(c);l.push(ae(u,d,e))}),()=>{l.forEach(c=>c())}}function xr({scrollCb:t,doc:e,mirror:r,blockClass:n,blockSelector:o,sampling:s}){const i=Le(l=>{const a=He(l);if(!a||le(a,n,o,!0))return;const c=r.getId(a);if(a===e){const u=e.scrollingElement||e.documentElement;t({id:c,x:u.scrollLeft,y:u.scrollTop})}else t({id:c,x:a.scrollLeft,y:a.scrollTop})},s.scroll||100);return ae("scroll",i,e)}function Oo({viewportResizeCb:t}){let e=-1,r=-1;const n=Le(()=>{const o=St(),s=wt();(e!==o||r!==s)&&(t({width:Number(s),height:Number(o)}),e=o,r=s)},200);return ae("resize",n,window)}function Lr(t,e){const r=Mr({},t);return e||delete r.userTriggered,r}const xo=["INPUT","TEXTAREA","SELECT"],Ar=new WeakMap;function Lo({inputCb:t,doc:e,mirror:r,blockClass:n,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:l,sampling:a,userTriggeredOnInput:c}){function u(v){let f=He(v);const g=v.isTrusted;if(f&&f.tagName==="OPTION"&&(f=f.parentElement),!f||!f.tagName||xo.indexOf(f.tagName)<0||le(f,n,o,!0))return;const b=f.type;if(f.classList.contains(s))return;let N=f.value,R=!1;b==="radio"||b==="checkbox"?R=f.checked:(i[f.tagName.toLowerCase()]||i[b])&&(N=yt({maskInputOptions:i,tagName:f.tagName,type:b,value:N,maskInputFn:l})),d(f,Lr({text:N,isChecked:R,userTriggered:g},c));const k=f.name;b==="radio"&&k&&R&&e.querySelectorAll(`input[type="radio"][name="${k}"]`).forEach(x=>{x!==f&&d(x,Lr({text:x.value,isChecked:!R,userTriggered:!1},c))})}function d(v,f){const g=Ar.get(v);if(!g||g.text!==f.text||g.isChecked!==f.isChecked){Ar.set(v,f);const b=r.getId(v);t(ko(Mr({},f),{id:b}))}}const h=(a.input==="last"?["change"]:["input","change"]).map(v=>ae(v,u,e)),p=e.defaultView;if(!p)return()=>{h.forEach(v=>v())};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),y=[[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(...y.map(v=>ze(v[0],v[1],{set(){u({target:this})}},!1,p))),()=>{h.forEach(v=>v())}}function ot(t){const e=[];function r(n,o){if(Ir&&n.parentRule instanceof CSSGroupingRule||kr&&n.parentRule instanceof CSSMediaRule||Rr&&n.parentRule instanceof CSSSupportsRule||Dr&&n.parentRule instanceof CSSConditionRule){const s=Array.from(n.parentRule.cssRules).indexOf(n);o.unshift(s)}else if(n.parentStyleSheet){const s=Array.from(n.parentStyleSheet.cssRules).indexOf(n);o.unshift(s)}return o}return r(t,e)}function Ee(t,e,r){let n,o;return t?(t.ownerNode?n=e.getId(t.ownerNode):o=r.getId(t),{styleId:o,id:n}):{}}function Ao({styleSheetRuleCb:t,mirror:e,stylesheetManager:r},{win:n}){const o=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(u,d){const{id:h,styleId:p}=Ee(this,e,r.styleMirror);return(h&&h!==-1||p&&p!==-1)&&t({id:h,styleId:p,adds:[{rule:u,index:d}]}),o.apply(this,[u,d])};const s=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(u){const{id:d,styleId:h}=Ee(this,e,r.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,removes:[{index:u}]}),s.apply(this,[u])};let i;n.CSSStyleSheet.prototype.replace&&(i=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(u){const{id:d,styleId:h}=Ee(this,e,r.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,replace:u}),i.apply(this,[u])});let l;n.CSSStyleSheet.prototype.replaceSync&&(l=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(u){const{id:d,styleId:h}=Ee(this,e,r.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,replaceSync:u}),l.apply(this,[u])});const a={};Ir?a.CSSGroupingRule=n.CSSGroupingRule:(kr&&(a.CSSMediaRule=n.CSSMediaRule),Dr&&(a.CSSConditionRule=n.CSSConditionRule),Rr&&(a.CSSSupportsRule=n.CSSSupportsRule));const c={};return Object.entries(a).forEach(([u,d])=>{c[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=function(h,p){const{id:m,styleId:y}=Ee(this.parentStyleSheet,e,r.styleMirror);return(m&&m!==-1||y&&y!==-1)&&t({id:m,styleId:y,adds:[{rule:h,index:[...ot(this),p||0]}]}),c[u].insertRule.apply(this,[h,p])},d.prototype.deleteRule=function(h){const{id:p,styleId:m}=Ee(this.parentStyleSheet,e,r.styleMirror);return(p&&p!==-1||m&&m!==-1)&&t({id:p,styleId:m,removes:[{index:[...ot(this),h]}]}),c[u].deleteRule.apply(this,[h])}}),()=>{n.CSSStyleSheet.prototype.insertRule=o,n.CSSStyleSheet.prototype.deleteRule=s,i&&(n.CSSStyleSheet.prototype.replace=i),l&&(n.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([u,d])=>{d.prototype.insertRule=c[u].insertRule,d.prototype.deleteRule=c[u].deleteRule})}}function Fr({mirror:t,stylesheetManager:e},r){var n,o,s;let i=null;r.nodeName==="#document"?i=t.getId(r):i=t.getId(r.host);const l=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(s=(o=r.ownerDocument)==null?void 0:o.defaultView)==null?void 0:s.ShadowRoot,a=Object.getOwnPropertyDescriptor(l?.prototype,"adoptedStyleSheets");return i===null||i===-1||!l||!a?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var c;return(c=a.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=a.set)==null?void 0:u.call(this,c);if(i!==null&&i!==-1)try{e.adoptStyleSheets(c,i)}catch{}return d}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})}function Fo({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:r,stylesheetManager:n},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(l,a,c){var u;if(r.has(l))return s.apply(this,[l,a,c]);const{id:d,styleId:h}=Ee((u=this.parentRule)==null?void 0:u.parentStyleSheet,e,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,set:{property:l,value:a,priority:c},index:ot(this.parentRule)}),s.apply(this,[l,a,c])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(l){var a;if(r.has(l))return i.apply(this,[l]);const{id:c,styleId:u}=Ee((a=this.parentRule)==null?void 0:a.parentStyleSheet,e,n.styleMirror);return(c&&c!==-1||u&&u!==-1)&&t(