overcentric
Version:
Overcentric watches your website, product, and users - and tells you what matters and what to do about it.
1 lines • 97.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).overcentric={})}(this,function(e){"use strict";const t="undefined"!=typeof window?window.location.hostname.replace(/^www\./,""):"";var n,r=Object.defineProperty,o=(e,t,n)=>((e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),i=(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[e.Asset=7]="Asset",e))(i||{}),s=(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[e.CustomElement=16]="CustomElement",e))(s||{}),a=(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))(a||{}),c=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(c||{}),l=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(l||{}),d=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(d||{}),u=(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",e))(u||{});const h={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},p={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},m={},f={};function g(e){if(m[e])return m[e];const t=globalThis[e],n=t.prototype,r=e in h?h[e]:void 0,o=!(!r||!r.every(e=>{var t,r;return!!(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:(""+r).includes("[native code]"))})),i=e in p?p[e]:void 0,s=!(!i||!i.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:(""+t).includes("[native code]"))}));if(o&&s&&!globalThis.Zone)return m[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;if(!i)return r.remove(),n;const s=navigator.userAgent;return s.includes("Safari")&&!s.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),f[e]=()=>r.remove()):r.remove(),m[e]=i}catch{return n}}const y={};function b(e,t,n){var r;const o=`${e}.${n+""}`;if(y[o])return y[o].call(t);const i=g(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(y[o]=s,s.call(t)):t[n]}const v={};function w(e,t,n){const r=`${e}.${n+""}`;if(v[r])return v[r].bind(t);const o=g(e)[n];return"function"!=typeof o?t[n]:(v[r]=o,o.bind(t))}function S(){return[g("MutationObserver").constructor,f.MutationObserver??(()=>{})]}let I=Date.now;function C(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}/[1-9][0-9]{12}/.test(""+Date.now())||(I=()=>(new Date).getTime());const k={ownerDocument:function(e){return b("Node",e,"ownerDocument")},childNodes:function(e){return b("Node",e,"childNodes")},parentNode:function(e){return b("Node",e,"parentNode")},parentElement:function(e){return b("Node",e,"parentElement")},textContent:function(e){return b("Node",e,"textContent")},contains:function(e,t){return w("Node",e,"contains")(t)},getRootNode:function(e){return w("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?b("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?b("Element",e,"shadowRoot"):null},querySelector:function(e,t){return b("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return b("Element",e,"querySelectorAll")(t)},nowTimestamp:I,mutationObserverCtor:S,patch:C};function M(e){return e.nodeType===e.ELEMENT_NODE}function E(e){const t=e&&"host"in e&&"mode"in e&&k.host(e)||null;return!(!t||!("shadowRoot"in t)||k.shadowRoot(t)!==e)}function T(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function R(e){try{const n=e.rules||e.cssRules;if(!n)return null;let r=e.href;!r&&e.ownerNode&&(r=e.ownerNode.baseURI);const o=Array.from(n,e=>O(e,r)).join("");return(t=o).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),t}catch(e){return null}var t}function O(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=R(e.styleSheet)||function(e){const{cssText:t}=e;if(3>t.split('"').length)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?W(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=n.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?W(n,t):n}}class x{constructor(){o(this,"idNodeMap",new Map),o(this,"nodeMetaMap",new WeakMap)}getId(e){var t;if(!e)return-1;return(null==(t=this.getMeta(e))?void 0:t.id)??-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function L({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let s=o||"";const a=r&&N(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=i?i(s,e):"*".repeat(s.length)),s}function N(e){return e.toLowerCase()}const D="__rrweb_original__";function _(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?N(t):null}function A(e,t){let n;try{n=new URL(e,window.location.href)}catch(e){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}const F=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,P=/^(?:[a-z+]+:)?\/\//i,U=/^www\..*/i,$=/^(data:)([^,]*),(.*)/i;function W(e,t){return(e||"").replace(F,(e,n,r,o,i,s)=>{const a=r||i||s,c=n||o||"";if(!a)return e;if(P.test(a)||U.test(a))return`url(${c}${a}${c})`;if($.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${c})`;const l=t.split("/"),d=a.split("/");l.pop();for(const e of d)"."!==e&&(".."===e?l.pop():l.push(e));return`url(${c}${l.join("/")}${c})`})}function j(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function z(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),o=[];let i=0;if(r.length>1&&e&&"string"==typeof e){let t=j(e,n);const s=t.length/e.length;for(let a=1;r.length>a;a++)if(r[a].textContent&&"string"==typeof r[a].textContent){const c=j(r[a].textContent,n),l=100;let d=3;for(;c.length>d&&(c[d].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,d),1));d++);for(;c.length>d;d++){let u=c.substring(0,d),h=t.split(u),p=-1;if(2===h.length)p=h[0].length;else if(h.length>2&&""===h[0]&&""!==r[a-1].textContent)p=t.indexOf(u,1);else if(1===h.length){if(u=u.substring(0,u.length-1),h=t.split(u),1>=h.length)return o.push(e),o;d=l+1}else d===c.length-1&&(p=t.indexOf(u));if(h.length>=2&&d>l){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=j(e).length;p=t.indexOf(u,n)}-1===p&&(p=h[0].length)}if(-1!==p){let a=Math.floor(p/s);for(;a>0&&e.length>a;){if(i+=1,i>50*r.length)return o.push(e),o;const c=j(e.substring(0,a),n);if(c.length===p){o.push(e.substring(0,a)),e=e.substring(a),t=t.substring(p);break}p>c.length?a+=Math.max(1,Math.floor((p-c.length)/s)):a-=Math.max(1,Math.floor((c.length-p)*s))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}let B=1;const H=RegExp("[^a-z0-9-_:]");function q(){return B++}let V,G;const X=/^[^ \t\n\r\u000c]+/,J=/^[, \t\n\r\u000c]+/;const Y=new WeakMap;function K(e,t){return t&&""!==t.trim()?Q(e,t):t}function Z(e){return!("svg"!==e.tagName&&!e.ownerSVGElement)}function Q(e,t){let n=Y.get(e);if(n||(n=e.createElement("a"),Y.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function ee(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?K(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r(J),t.length>n;){let i=r(X);if(","===i.slice(-1))i=K(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=K(e,i);let s=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?W(r,Q(e)):"object"===t&&"data"===n?K(e,r):r:r}function te(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function ne(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ne(k.parentNode(e),t,n);for(let n=e.classList.length;n--;){if(t.test(e.classList[n]))return!0}return!!n&&ne(k.parentNode(e),t,n)}function re(e,t,n,r){let o;if(M(e)){if(o=e,!k.childNodes(o).length)return!1}else{if(null===k.parentElement(e))return!1;o=k.parentElement(e)}try{if("string"==typeof t){if(r){if(o.closest("."+t))return!0}else if(o.classList.contains(t))return!0}else if(ne(o,t,r))return!0;if(n)if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}catch(e){}return!1}function oe(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:s,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:l,maskInputFn:d,dataURLOptions:h={},inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g=!1,cssCaptured:y=!1}=t,b=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:u.Document,childNodes:[],compatMode:e.compatMode}:{type:u.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:i,maskInputOptions:s={},maskInputFn:a,dataURLOptions:c={},inlineImages:l,recordCanvas:d,keepIframeSrcFn:h,newlyAddedElement:p=!1,rootId:m}=t,f=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;)if(t.test(e.classList[n]))return!0;if(n)return e.matches(n)}catch(e){}return!1}(e,r,o),g=function(e){if(e instanceof HTMLFormElement)return"form";const t=N(e.tagName);return H.test(t)?"div":t}(e);let y={};const b=e.attributes.length;for(let t=0;b>t;t++){const r=e.attributes[t];te(g,r.name)||(y[r.name]=ee(n,g,N(r.name),r.value))}if("link"===g&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=R(t)),r&&(delete y.rel,delete y.href,y._cssText=r)}if("style"===g&&e.sheet){let t=R(e.sheet);t&&(e.childNodes.length>1&&(t=z(t,e)),y._cssText=t)}if(["input","textarea","select"].includes(g)){const t=e.value,n=e.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&t?y.value=L({element:e,type:_(e),tagName:g,value:t,maskInputOptions:s,maskInputFn:a}):n&&(y.checked=n)}"option"===g&&(e.selected&&!s.select?y.selected=!0:delete y.selected);"dialog"===g&&e.open&&(y.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===g&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;e.width>n;n+=50)for(let r=0;e.height>r;r+=50){const o=t.getImageData;if(new Uint32Array((D in o?o[D]:o).call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(y.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height;t!==r.toDataURL(c.type,c.quality)&&(y.rr_dataURL=t)}if("img"===g&&l){V||(V=n.createElement("canvas"),G=V.getContext("2d"));const t=e,r=t.currentSrc||t.getAttribute("src")||"<unknown-src>",o=t.crossOrigin,i=()=>{t.removeEventListener("load",i);try{V.width=t.naturalWidth,V.height=t.naturalHeight,G.drawImage(t,0,0),y.rr_dataURL=V.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i));console.warn(`Cannot inline img src=${r}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(o?y.crossOrigin=o:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?i():t.addEventListener("load",i)}if(["audio","video"].includes(g)){const t=y;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:n}=e.getBoundingClientRect();y={class:y.class,rr_width:t+"px",rr_height:n+"px"}}"iframe"!==g||h(y.src)||(e.contentDocument||(y.rr_src=y.src),delete y.src);let v;try{customElements.get(g)&&(v=!0)}catch(e){}return{type:u.Element,tagName:g,attributes:y,childNodes:[],isSVG:Z(e)||void 0,needBlock:f,rootId:m,isCustom:v}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:d,dataURLOptions:h,inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g,rootId:b});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,s=k.parentNode(e),a=s&&s.tagName;let c="";const l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?c="SCRIPT_PLACEHOLDER":i||(c=k.textContent(e),l&&c&&(c=W(c,Q(t.doc))));!l&&!d&&c&&n&&(c=r?r(c,k.parentElement(e)):c.replace(/[\S]/g,"*"));return{type:u.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:s,maskTextFn:l,rootId:b,cssCaptured:y});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:u.Comment,textContent:k.textContent(e)||"",rootId:b};default:return!1}}function ie(e){return null==e?"":e.toLowerCase()}function se(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function ae(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:s,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:d={},maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f={},inlineImages:g=!1,recordCanvas:y=!1,onSerialize:b,onIframeLoad:v,iframeLoadTimeout:w=5e3,onStylesheetLoad:S,stylesheetLoadTimeout:I=5e3,keepIframeSrcFn:C=()=>!1,newlyAddedElement:R=!1,cssCaptured:O=!1}=t;let{needsMask:x}=t,{preserveWhiteSpace:L=!0}=t;if(!x){x=re(e,s,a,void 0===x)}const N=oe(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:x,inlineStylesheet:l,maskInputOptions:d,maskTextFn:h,maskInputFn:p,dataURLOptions:f,inlineImages:g,recordCanvas:y,keepIframeSrcFn:C,newlyAddedElement:R,cssCaptured:O});if(!N)return console.warn(e,"not serialized"),null;let D;D=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===u.Comment)return!0;if(e.type===u.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===A(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(ie(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===ie(e.attributes.name)||"icon"===ie(e.attributes.rel)||"apple-touch-icon"===ie(e.attributes.rel)||"shortcut icon"===ie(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&ie(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(ie(e.attributes.property).match(/^(og|twitter|fb):/)||ie(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===ie(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===ie(e.attributes.name)||"googlebot"===ie(e.attributes.name)||"bingbot"===ie(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===ie(e.attributes.name)||"generator"===ie(e.attributes.name)||"framework"===ie(e.attributes.name)||"publisher"===ie(e.attributes.name)||"progid"===ie(e.attributes.name)||ie(e.attributes.property).match(/^article:/)||ie(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===ie(e.attributes.name)||"yandex-verification"===ie(e.attributes.name)||"csrf-token"===ie(e.attributes.name)||"p:domain_verify"===ie(e.attributes.name)||"verify-v1"===ie(e.attributes.name)||"verification"===ie(e.attributes.name)||"shopify-checkout-api-token"===ie(e.attributes.name)))return!0}}return!1}(N,m)||!L&&N.type===u.Text&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?-2:q();const _=Object.assign(N,{id:D});if(r.add(e,_),-2===D)return null;b&&b(e);let F=!c;if(_.type===u.Element){F=F&&!_.needBlock,delete _.needBlock;const t=k.shadowRoot(e);t&&T(t)&&(_.isShadowHost=!0)}if((_.type===u.Document||_.type===u.Element)&&F){m.headWhitespace&&_.type===u.Element&&"head"===_.tagName&&(L=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:x,maskTextClass:s,maskTextSelector:a,skipChild:c,inlineStylesheet:l,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:y,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:v,iframeLoadTimeout:w,onStylesheetLoad:S,stylesheetLoadTimeout:I,keepIframeSrcFn:C,cssCaptured:!1};if(_.type===u.Element&&"textarea"===_.tagName&&void 0!==_.attributes.value);else{_.type===u.Element&&void 0!==_.attributes._cssText&&"string"==typeof _.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(k.childNodes(e))){const e=ae(n,t);e&&_.childNodes.push(e)}}let E=null;if(M(e)&&(E=k.shadowRoot(e)))for(const e of Array.from(k.childNodes(E))){const n=ae(e,t);n&&(T(E)&&(n.isShadow=!0),_.childNodes.push(n))}}const P=k.parentNode(e);return P&&E(P)&&T(P)&&(_.isShadow=!0),_.type===u.Element&&"iframe"===_.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(e){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!0,t()})}const s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&v){const n=ae(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:x,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:y,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:v,iframeLoadTimeout:w,onStylesheetLoad:S,stylesheetLoadTimeout:I,keepIframeSrcFn:C});n&&v(e,n)}},w),_.type===u.Element&&"link"===_.tagName&&"string"==typeof _.attributes.rel&&("stylesheet"===_.attributes.rel||"preload"===_.attributes.rel&&"string"==typeof _.attributes.href&&"css"===A(_.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(e){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(S){const t=ae(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:x,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:y,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:v,iframeLoadTimeout:w,onStylesheetLoad:S,stylesheetLoadTimeout:I,keepIframeSrcFn:C});t&&S(e,t)}},I),_}class ce{constructor(...e){o(this,"parentElement",null),o(this,"parentNode",null),o(this,"ownerDocument"),o(this,"firstChild",null),o(this,"lastChild",null),o(this,"previousSibling",null),o(this,"nextSibling",null),o(this,"ELEMENT_NODE",1),o(this,"TEXT_NODE",3),o(this,"nodeType"),o(this,"nodeName"),o(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(!(e instanceof ce))return!1;if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function le(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const de="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 ue={map:{},getId:()=>(console.error(de),-1),getNode:()=>(console.error(de),null),removeNodeFromMap(){console.error(de)},has:()=>(console.error(de),!1),reset(){console.error(de)}};function he(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;0>=a||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},a))}}function pe(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>pe(e,t,i||{},!0)}function me(e){var t,n,r,o;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null==(t=k.parentElement(i.body))?void 0:t.scrollLeft)||(null==(n=null==i?void 0:i.body)?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null==(r=k.parentElement(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function fe(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ge(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function ye(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:k.parentElement(e)}function be(e,t,n,r){if(!e)return!1;const o=ye(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(ne(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function ve(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function we(e,t){if(E(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=k.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||we(r,t))}function Se(e){return!!e.changedTouches}function Ie(e,t){return!("IFRAME"!==e.nodeName||!t.getMeta(e))}function Ce(e,t){return!("LINK"!==e.nodeName||e.nodeType!==e.ELEMENT_NODE||!e.getAttribute||"stylesheet"!==e.getAttribute("rel")||!t.getMeta(e))}function ke(e){return!!e&&(e instanceof ce&&"shadowRoot"in e?!!e.shadowRoot:!!k.shadowRoot(e))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(ue=new Proxy(ue,{get:(e,t,n)=>("map"===t&&console.error(de),Reflect.get(e,t,n))}));class Me{constructor(){o(this,"id",1),o(this,"styleIDMap",new WeakMap),o(this,"idStyleMap",new Map)}getId(e){return this.styleIDMap.get(e)??-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++}}function Ee(e){var t;let n=null;return"getRootNode"in e&&(null==(t=k.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&k.host(k.getRootNode(e))&&(n=k.host(k.getRootNode(e))),n}function Te(e){const t=k.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=Ee(n);)n=t;return n}(e);return k.contains(t,n)}function Re(e){const t=k.ownerDocument(e);return!!t&&(k.contains(t,e)||Te(e))}function Oe(e){return"__ln"in e}class xe{constructor(){o(this,"length",0),o(this,"head",null),o(this,"tail",null)}get(e){if(e>=this.length)throw Error("Position outside of list range");let t=this.head;for(let n=0;e>n;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&&Oe(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&&Oe(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;null===t.next&&(this.tail=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.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const Le=(e,t)=>`${e}@${t}`;class Ne{constructor(){o(this,"frozen",!1),o(this,"locked",!1),o(this,"texts",[]),o(this,"attributes",[]),o(this,"attributeMap",new WeakMap),o(this,"removes",[]),o(this,"mapRemoves",[]),o(this,"movedMap",{}),o(this,"addedSet",new Set),o(this,"movedSet",new Set),o(this,"droppedSet",new Set),o(this,"removesSubTreeCache",new Set),o(this,"mutationCb"),o(this,"blockClass"),o(this,"blockSelector"),o(this,"maskTextClass"),o(this,"maskTextSelector"),o(this,"inlineStylesheet"),o(this,"maskInputOptions"),o(this,"maskTextFn"),o(this,"maskInputFn"),o(this,"keepIframeSrcFn"),o(this,"recordCanvas"),o(this,"inlineImages"),o(this,"slimDOMOptions"),o(this,"dataURLOptions"),o(this,"doc"),o(this,"mirror"),o(this,"iframeManager"),o(this,"stylesheetManager"),o(this,"shadowDomManager"),o(this,"canvasManager"),o(this,"processedNodeManager"),o(this,"unattachedDoc"),o(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),o(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new xe,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{const i=k.parentNode(o);if(!i||!Re(o))return;let s=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(s=!0)}const a=E(i)?this.mirror.getId(Ee(o)):this.mirror.getId(i),c=r(o);if(-1===a||-1===c)return n.addNode(o);const l=ae(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=>{Ie(e,this.mirror)&&this.iframeManager.addIframe(e),Ce(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ke(o)&&this.shadowDomManager.addShadowRoot(k.shadowRoot(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});l&&(e.push({parentId:a,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)_e(this.removesSubTreeCache,e)&&!this.movedSet.has(k.parentNode(e))||o(e);for(const e of this.addedSet)Ae(this.droppedSet,e)||_e(this.removesSubTreeCache,e)?Ae(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(k.parentNode(i.value)),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(k.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=k.parentNode(n.value);if(t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const r=k.host(t);if(-1!==this.mirror.getId(r)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=k.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);t.style.length>n.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).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.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(s))}),o(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(k.childNodes(e),e=>k.textContent(e)||"").join("");t.attributes.value=L({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:_(e),value:n,maskInputFn:this.maskInputFn})}),o(this,"processMutation",e=>{if(!ve(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=k.textContent(e.target);be(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:re(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,ye(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=_(t);r=L({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(be(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributeMap.get(e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!te(t.tagName,n))if(o.attributes[n]=ee(this.doc,N(t.tagName),N(n),r),"style"===n){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const n=this.unattachedDoc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);r!==n.style.getPropertyValue(e)||i!==n.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?r:[r,i]:o._unchangedStyles[e]=[r,i]}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}else"open"===n&&"DIALOG"===t.tagName&&(o.attributes.rr_open_mode=t.matches("dialog:modal")?"modal":"non-modal");break}case"childList":if(be(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=E(e.target)?this.mirror.getId(k.host(e.target)):this.mirror.getId(e.target);be(e.target,this.blockClass,this.blockSelector,!1)||ve(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(De(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||we(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Le(n,r)]?De(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!E(e.target)||!T(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),k.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),o(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(ve(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Le(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);be(e,this.blockClass,this.blockSelector,!1)||(k.childNodes(e).forEach(e=>this.genAdds(e)),ke(e)&&k.childNodes(k.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].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 De(e,t){e.delete(t),k.childNodes(t).forEach(t=>De(e,t))}function _e(e,t,n){return 0!==e.size&&function(e,t){const n=k.parentNode(t);return!!n&&e.has(n)}(e,t)}function Ae(e,t){return 0!==e.size&&Fe(e,t)}function Fe(e,t){const n=k.parentNode(t);return!!n&&(!!e.has(n)||Fe(e,n))}let Pe;const Ue=e=>{if(!Pe)return e;return(...t)=>{try{return e(...t)}catch(e){if(Pe&&!0===Pe(e))return;throw e}}},$e=[];function We(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]}catch{}return e&&e.target}function je(e,t){const n=new Ne;$e.push(n),n.init(e);const[r,o]=S(),i=new r(Ue(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function ze({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,l=[];let d=null;return Object.keys(a).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{let s=N(i);const u=(t=>i=>{const s=We(i);if(be(s,r,o,!0))return;let l=null,u=t;if("pointerType"in i){switch(i.pointerType){case"mouse":l=c.Mouse;break;case"touch":l=c.Touch;break;case"pen":l=c.Pen}l===c.Touch&&(a[t]===a.MouseDown?u="TouchStart":a[t]===a.MouseUp&&(u="TouchEnd"))}else Se(i)&&(l=c.Touch);null!==l?(d=l,(u.startsWith("Touch")&&l===c.Touch||u.startsWith("Mouse")&&l===c.Mouse)&&(l=null)):a[t]===a.Click&&(l=d,d=null);const h=Se(i)?i.changedTouches[0]:i;if(!h)return;const p=n.getId(s),{clientX:m,clientY:f}=h;Ue(e)({type:a[u],id:p,x:m,y:f,...null!==l&&{pointerType:l}})})(i);if(window.PointerEvent)switch(a[i]){case a.MouseDown:case a.MouseUp:s=s.replace("mouse","pointer");break;case a.TouchStart:case a.TouchEnd:return}l.push(le(s,u,t))}),Ue(()=>{l.forEach(e=>e())})}function Be({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return le("scroll",Ue(he(Ue(i=>{const s=We(i);if(!s||be(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=me(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100)),t)}const He=["INPUT","TEXTAREA","SELECT"],qe=new WeakMap;function Ve(e){return function e(t,n){if(Ye("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Ye("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Ye("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Ye("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const r=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(r),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function Ge(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Xe({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s=e.getId("#document"===n.nodeName?n:k.host(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(i=null==(o=n.ownerDocument)?void 0:o.defaultView)?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=c.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return r}}),Ue(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Je(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...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.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=je(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let a,c=[];const l=he(Ue(t=>{const n=Date.now()-a;e(c.map(e=>(e.timeOffset-=n,e)),t),c=[],a=null}),i),d=Ue(he(Ue(e=>{const t=We(e),{clientX:n,clientY:o}=Se(e)?e.changedTouches[0]:e;a||(a=I()),c.push({x:n,y:o,id:r.getId(t),timeOffset:I()-a}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?s.Drag:e instanceof MouseEvent?s.MouseMove:s.TouchMove)}),o,{trailing:!1})),u=[le("mousemove",d,n),le("touchmove",d,n),le("drag",d,n)];return Ue(()=>{u.forEach(e=>e())})}(e),a=ze(e),c=Be(e),l=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return le("resize",Ue(he(Ue(()=>{const t=fe(),o=ge();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)}),200)),t)}(e,{win:n}),u=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function u(e){let n=We(e);const l=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=k.parentElement(n)),!n||!u||0>He.indexOf(u)||be(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let p=n.value,m=!1;const f=_(n)||"";"radio"===f||"checkbox"===f?m=n.checked:(a[u.toLowerCase()]||a[f])&&(p=L({element:n,maskInputOptions:a,tagName:u,type:f,value:p,maskInputFn:c})),h(n,d?{text:p,isChecked:m,userTriggered:l}:{text:p,isChecked:m});const g=n.name;"radio"===f&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;h(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function h(t,r){const o=qe.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){qe.set(t,r);const o=n.getId(t);Ue(e)({...r,id:o})}}const p=("last"===l.input?["change"]:["input","change"]).map(e=>le(e,Ue(u),t)),m=t.defaultView;if(!m)return()=>{p.forEach(e=>e())};const f=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value");return f&&f.set&&p.push(...[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]].map(e=>pe(e[0],e[1],{set(){Ue(u)({target:this,isTrusted:!1})}},!1,m))),Ue(()=>{p.forEach(e=>e())})}(e),h=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=Ue(i=>he(Ue(o=>{const s=We(o);if(!s||be(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d,loop:u}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:d,loop:u})}),o.media||500)),a=[le("play",s(d.Play),i),le("pause",s(d.Pause),i),le("seeked",s(d.Seeked),i),le("volumechange",s(d.VolumeChange),i),le("ratechange",s(d.RateChange),i)];return Ue(()=>{a.forEach(e=>e())})}(e);let p=()=>{},m=()=>{},f=()=>{},g=()=>{};e.recordDOM&&(p=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Ue((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Ge(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){return r.CSSStyleSheet.prototype.insertRule.call(this,`${e} { ${t} }`,n)};const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Ue((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Ge(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.call(this,e)},r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Ue((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Ge(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Ue((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Ge(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)})}));const c={};Ke("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(Ke("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),Ke("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),Ke("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Ue((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Ge(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...Ve(o),a||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Ue((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Ge(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...Ve(o),s]}]}),r.apply(o,i)})})}),Ue(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),m=Xe(e,e.doc),f=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Ue((o,s,a)=>{var c;const[l,d,u]=a;if(n.has(l))return i.call(s,l,d,u);const{id:h,styleId:p}=Ge(null==(c=s.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:l,value:d,priority:u},index:Ve(s.parentRule)}),o.apply(s,a)})});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Ue((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.call(i,l);const{id:d,styleId:u}=Ge(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:l},index:Ve(i.parentRule)}),o.apply(i,a)})}),Ue(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(g=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=C(t.fonts,"add",function(t){return function(n){return setTimeout(Ue(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.call(this,n)}});return r.push(()=>{n.FontFace=i}),r.push(s),Ue(()=>{r.forEach(e=>e())})}(e)));const y=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=Ue(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;c>t;t++){const i=e.getRangeAt(t),{startContainer:s,startOffset:c,endContainer:l,endOffset:d}=i;be(s,r,o,!0)||be(l,r,o,!0)||a.push({start:n.getId(s),startOffset:c,end:n.getId(l),endOffset:d})}i({ranges:a})});return a(),le("selectionchange",a)}(e),b=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?C(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(e){console.warn("Custom element callback failed for "+n)}return e.call(this,n,r,o)}}):()=>{}}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return Ue(()=>{$e.forEach(e=>e.reset()),null==r||r.disconnect(),o(),i(),a(),c(),l(),u(),h(),p(),m(),f(),g(),y(),b(),v.forEach(e=>e())})}function Ye(e){return void 0!==window[e]}function Ke(e){return!!(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Ze{constructor(e){o(this,"iframeIdToRemoteIdMap",new WeakMap),o(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.