@himetrica/replaykit 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +91 -2
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/replaykit.global.js +79 -0
- package/dist/replaykit.global.js.map +1 -0
- package/package.json +45 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";(()=>{var Kt=Object.defineProperty,ii=Object.defineProperties;var ni=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var qt=(t,e,r)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,k=(t,e)=>{for(var r in e||(e={}))Ht.call(e,r)&&qt(t,r,e[r]);if(Ne)for(var r of Ne(e))zt.call(e,r)&&qt(t,r,e[r]);return t},W=(t,e)=>ii(t,ni(e));var Gt=(t,e)=>{var r={};for(var i in t)Ht.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&Ne)for(var i of Ne(t))e.indexOf(i)<0&&zt.call(t,i)&&(r[i]=t[i]);return r};var si=(t,e)=>()=>(t&&(e=t(t=0)),e);var Vt=(t,e)=>{for(var r in e)Kt(t,r,{get:e[r],enumerable:!0})};var Qr={};Vt(Qr,{record:()=>Ee});function Ot(t){if(Be[t])return Be[t];let e=globalThis[t],r=e.prototype,i=t in dr?dr[t]:void 0,n=!!(i&&i.every(l=>{var o,c;return!!((c=(o=Object.getOwnPropertyDescriptor(r,l))==null?void 0:o.get)!=null&&c.toString().includes("[native code]"))})),s=t in hr?hr[t]:void 0,a=!!(s&&s.every(l=>{var o;return typeof r[l]=="function"&&((o=r[l])==null?void 0:o.toString().includes("[native code]"))}));if(n&&a&&!Ni())return Be[t]=e.prototype,e.prototype;try{let l=document.createElement("iframe");l.style.display="none",document.body.appendChild(l);let o=l.contentWindow;if(!o)return e.prototype;let c=o[t].prototype;if(!c)return l.remove(),r;let d=navigator.userAgent;return d.includes("Safari")&&!d.includes("Chrome")?(l.classList.add("rr-block"),l.setAttribute("__rrwebUntaintedMutationObserver",""),kr[t]=()=>l.remove()):l.remove(),Be[t]=c}catch(l){return r}}function G(t,e,r){var i,n;let s=(i=mt[t])==null?void 0:i[r];if(s)return s.call(e);let a=Ot(t),l=(n=Object.getOwnPropertyDescriptor(a,r))==null?void 0:n.get;return l?((mt[t]||(mt[t]={}))[r]=l,l.call(e)):e[r]}function Mr(t,e,r){let i=`${t}.${String(r)}`;if(gt[i])return gt[i].bind(e);let s=Ot(t)[r];return typeof s!="function"?e[r]:(gt[i]=s,s.bind(e))}function Oi(t){return G("Node",t,"ownerDocument")}function _i(t){return G("Node",t,"childNodes")}function Ai(t){return G("Node",t,"parentNode")}function Li(t){return G("Node",t,"parentElement")}function Di(t){return G("Node",t,"textContent")}function Pi(t){return G("Node",t,"firstChild")}function Fi(t){return G("Node",t,"lastChild")}function Bi(t){return G("Node",t,"nextSibling")}function Wi(t){return G("Node",t,"previousSibling")}function Ui(t,e){return Mr("Node",t,"contains")(e)}function qi(t){return Mr("Node",t,"getRootNode")()}function Ki(t){return!t||!("host"in t)?null:G("ShadowRoot",t,"host")}function Hi(t){return t.styleSheets}function zi(t){return!t||!("shadowRoot"in t)?null:G("Element",t,"shadowRoot")}function Gi(t,e){return G("Element",t,"querySelector")(e)}function Vi(t,e){return G("Element",t,"querySelectorAll")(e)}function Ir(){var t;return[Ot("MutationObserver").constructor,(t=kr.MutationObserver)!=null?t:(()=>{})]}function ue(t,e,r){try{if(!(e in t))return()=>{};let i=t[e],n=r(i);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=n,()=>{t[e]=i}}catch(i){return()=>{}}}function Er(t){return t.nodeType===t.ELEMENT_NODE}function Ce(t){let e=t&&"host"in t&&"mode"in t&&v.host(t)||null;return!!(e&&"shadowRoot"in e&&v.shadowRoot(e)===t)}function we(t){return Object.prototype.toString.call(t)==="[object ShadowRoot]"}function $i(t){return t.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}function ji(t){let{cssText:e}=t;if(e.split('"').length<3)return e;let r=["@import",`url(${JSON.stringify(t.href)})`];return t.layerName===""?r.push("layer"):t.layerName&&r.push(`layer(${t.layerName})`),t.supportsText&&r.push(`supports(${t.supportsText})`),t.media.length&&r.push(t.media.mediaText),r.join(" ")+";"}function vt(t){try{let e=t.rules||t.cssRules;if(!e)return null;let r=t.href;!r&&t.ownerNode&&(r=t.ownerNode.baseURI);let i=Array.from(e,n=>Tr(n,r)).join("");return $i(i)}catch(e){return null}}function Tr(t,e){if(Yi(t)){let r;try{r=vt(t.styleSheet)||ji(t)}catch(i){r=t.cssText}return t.styleSheet.href?$e(r,t.styleSheet.href):r}else{let r=t.cssText;return Ji(t)&&t.selectorText.includes(":")&&(r=Xi(r)),e?$e(r,e):r}}function Xi(t){let e=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return t.replace(e,"$1\\$2")}function Yi(t){return"styleSheet"in t}function Ji(t){return"selectorText"in t}function Zi(){return new ze}function Ge({element:t,maskInputOptions:e,tagName:r,type:i,value:n,maskInputFn:s}){let a=n||"",l=i&&ne(i);return(e[r.toLowerCase()]||l&&e[l])&&(s?a=s(a,t):a="*".repeat(a.length)),a}function ne(t){return t.toLowerCase()}function Qi(t){let e=t.getContext("2d");if(!e)return!0;let r=50;for(let i=0;i<t.width;i+=r)for(let n=0;n<t.height;n+=r){let s=e.getImageData,a=fr in s?s[fr]:s;if(new Uint32Array(a.call(e,i,n,Math.min(r,t.width-i),Math.min(r,t.height-n)).data.buffer).some(o=>o!==0))return!1}return!0}function Ve(t){let e=t.type;return t.hasAttribute("data-rr-is-password")?"password":e?ne(e):null}function xr(t,e){var s;let r;try{r=new URL(t,e!=null?e:window.location.href)}catch(a){return null}let i=/\.([0-9a-z]+)(?:$)/i,n=r.pathname.match(i);return(s=n==null?void 0:n[1])!=null?s:null}function en(t){let e="";return t.indexOf("//")>-1?e=t.split("/").slice(0,3).join("/"):e=t.split("/")[0],e=e.split("?")[0],e}function $e(t,e){return(t||"").replace(tn,(r,i,n,s,a,l)=>{let o=n||a||l,c=i||s||"";if(!o)return r;if(rn.test(o)||nn.test(o))return`url(${c}${o}${c})`;if(sn.test(o))return`url(${c}${o}${c})`;if(o[0]==="/")return`url(${c}${en(e)+o}${c})`;let d=o.split("#")[0],h=o.substring(d.length),p=e.split("#")[0].split("/"),f=d.split("/");p.pop();for(let m of f)m!=="."&&(m===".."?p.pop():p.push(m));return`url(${c}${p.join("/")}${h}${c})`})}function We(t,e=!1){return e?t.replace(an,""):t.replace(on,"$1")}function ln(t,e,r=!1){let i=Array.from(e.childNodes),n=[],s=0;if(i.length>1&&t&&typeof t=="string"){let a=We(t,r),l=a.length/t.length;for(let o=1;o<i.length;o++)if(i[o].textContent&&typeof i[o].textContent=="string"){let c=We(i[o].textContent,r),d=100,h=3;for(;h<c.length&&(c[h].match(/[a-zA-Z0-9]/)||c.indexOf(c.substring(0,h),1)!==-1);h++);for(;h<c.length;h++){let p=c.substring(0,h),f=a.split(p),m=-1;if(f.length===2)m=f[0].length;else if(f.length>2&&f[0]===""&&i[o-1].textContent!=="")m=a.indexOf(p,1);else if(f.length===1){if(p=p.substring(0,p.length-1),f=a.split(p),f.length<=1)return n.push(t),n;h=d+1}else h===c.length-1&&(m=a.indexOf(p));if(f.length>=2&&h>d){let u=i[o-1].textContent;if(u&&typeof u=="string"){let b=We(u).length;m=a.indexOf(p,b)}m===-1&&(m=f[0].length)}if(m!==-1){let u=Math.floor(m/l);for(;u>0&&u<t.length;){if(s+=1,s>50*i.length)return n.push(t),n;let b=We(t.substring(0,u),r);if(b.length===m){n.push(t.substring(0,u)),t=t.substring(u),a=a.substring(m);break}else b.length<m?u+=Math.max(1,Math.floor((m-b.length)/l)):u-=Math.max(1,Math.floor((b.length-m)*l))}break}}}}return n.push(t),n}function un(t,e){return ln(t,e).join("/* rr_split */")}function Or(){return cn++}function hn(t){if(t instanceof HTMLFormElement)return"form";let e=ne(t.tagName);return dn.test(e)?"div":e}function mn(t,e){if(e.trim()==="")return e;let r=0;function i(s){let a,l=s.exec(e.substring(r));return l?(a=l[0],r+=a.length,a):""}let n=[];for(;i(pn),!(r>=e.length);){let s=i(fn);if(s.slice(-1)===",")s=pe(t,s.substring(0,s.length-1)),n.push(s);else{let a="";s=pe(t,s);let l=!1;for(;;){let o=e.charAt(r);if(o===""){n.push((s+a).trim());break}else if(l)o===")"&&(l=!1);else if(o===","){r+=1,n.push((s+a).trim());break}else o==="("&&(l=!0);a+=o,r+=1}}}return n.join(", ")}function pe(t,e){return!e||e.trim()===""?e:_t(t,e)}function gn(t){return!!(t.tagName==="svg"||t.ownerSVGElement)}function _t(t,e){let r=mr.get(t);if(r||(r=t.createElement("a"),mr.set(t,r)),!e)e="";else if(e.startsWith("blob:")||e.startsWith("data:"))return e;return r.setAttribute("href",e),r.href}function _r(t,e,r,i){return i&&(r==="src"||r==="href"&&!(e==="use"&&i[0]==="#")||r==="xlink:href"&&i[0]!=="#"||r==="background"&&["table","td","th"].includes(e)?pe(t,i):r==="srcset"?mn(t,i):r==="style"?$e(i,_t(t)):e==="object"&&r==="data"?pe(t,i):i)}function Ar(t,e,r){return["video","audio"].includes(t)&&ne(e)==="autoplay"}function yn(t,e,r){try{if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(let i=t.classList.length;i--;){let n=t.classList[i];if(e.test(n))return!0}if(r)return t.matches(r)}catch(i){}return!1}function Xe(t,e,r){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return r?Xe(v.parentNode(t),e,r):!1;for(let i=t.classList.length;i--;){let n=t.classList[i];if(e.test(n))return!0}return r?Xe(v.parentNode(t),e,r):!1}function Lr(t,e,r,i){let n;if(Er(t)){if(n=t,!v.childNodes(n).length)return!1}else{if(v.parentElement(t)===null)return!1;n=v.parentElement(t)}try{if(typeof e=="string"){if(i){if(n.closest(`.${e}`))return!0}else if(n.classList.contains(e))return!0}else if(Xe(n,e,i))return!0;if(r){if(i){if(n.closest(r))return!0}else if(n.matches(r))return!0}}catch(s){}return!1}function bn(t,e,r){let i=t.contentWindow;if(!i)return;let n=!1,s;try{s=i.document.readyState}catch(l){return}if(s!=="complete"){let l=setTimeout(()=>{n||(e(),n=!0)},r);t.addEventListener("load",()=>{clearTimeout(l),n=!0,e()});return}let a="about:blank";if(i.location.href!==a||t.src===a||t.src==="")return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}function vn(t,e,r){let i=!1,n;try{n=t.sheet}catch(a){return}if(n)return;let s=setTimeout(()=>{i||(e(),i=!0)},r);t.addEventListener("load",()=>{clearTimeout(s),i=!0,e()})}function Sn(t,e){let{doc:r,mirror:i,blockClass:n,blockSelector:s,needsMask:a,inlineStylesheet:l,maskInputOptions:o={},maskTextFn:c,maskInputFn:d,dataURLOptions:h={},inlineImages:p,recordCanvas:f,keepIframeSrcFn:m,newlyAddedElement:u=!1,cssCaptured:b=!1}=e,C=Cn(r,i);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:C};case t.ELEMENT_NODE:return Rn(t,{doc:r,blockClass:n,blockSelector:s,inlineStylesheet:l,maskInputOptions:o,maskInputFn:d,dataURLOptions:h,inlineImages:p,recordCanvas:f,keepIframeSrcFn:m,newlyAddedElement:u,rootId:C});case t.TEXT_NODE:return wn(t,{doc:r,needsMask:a,maskTextFn:c,rootId:C,cssCaptured:b});case t.CDATA_SECTION_NODE:return{type:F.CDATA,textContent:"",rootId:C};case t.COMMENT_NODE:return{type:F.Comment,textContent:v.textContent(t)||"",rootId:C};default:return!1}}function Cn(t,e){if(!e.hasNode(t))return;let r=e.getId(t);return r===1?void 0:r}function wn(t,e){let{needsMask:r,maskTextFn:i,rootId:n,cssCaptured:s}=e,a=v.parentNode(t),l=a&&a.tagName,o="",c=l==="STYLE"?!0:void 0,d=l==="SCRIPT"?!0:void 0;return d?o="SCRIPT_PLACEHOLDER":s||(o=v.textContent(t),c&&o&&(o=$e(o,_t(e.doc)))),!c&&!d&&o&&r&&(o=i?i(o,v.parentElement(t)):o.replace(/[\S]/g,"*")),{type:F.Text,textContent:o||"",rootId:n}}function Rn(t,e){let{doc:r,blockClass:i,blockSelector:n,inlineStylesheet:s,maskInputOptions:a={},maskInputFn:l,dataURLOptions:o={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:h,newlyAddedElement:p=!1,rootId:f}=e,m=yn(t,i,n),u=hn(t),b={},C=t.attributes.length;for(let y=0;y<C;y++){let w=t.attributes[y];Ar(u,w.name,w.value)||(b[w.name]=_r(r,u,ne(w.name),w.value))}if(u==="link"&&s){let y=Array.from(r.styleSheets).find(O=>O.href===t.href),w=null;y&&(w=vt(y)),w&&(delete b.rel,delete b.href,b._cssText=w)}if(u==="style"&&t.sheet){let y=vt(t.sheet);y&&(t.childNodes.length>1&&(y=un(y,t)),b._cssText=y)}if(["input","textarea","select"].includes(u)){let y=t.value,w=t.checked;b.type!=="radio"&&b.type!=="checkbox"&&b.type!=="submit"&&b.type!=="button"&&y?b.value=Ge({element:t,type:Ve(t),tagName:u,value:y,maskInputOptions:a,maskInputFn:l}):w&&(b.checked=w)}if(u==="option"&&(t.selected&&!a.select?b.selected=!0:delete b.selected),u==="dialog"&&t.open&&(b.rr_open_mode=t.matches("dialog:modal")?"modal":"non-modal"),u==="canvas"&&d){if(t.__context==="2d")Qi(t)||(b.rr_dataURL=t.toDataURL(o.type,o.quality));else if(!("__context"in t)){let y=t.toDataURL(o.type,o.quality),w=r.createElement("canvas");w.width=t.width,w.height=t.height;let O=w.toDataURL(o.type,o.quality);y!==O&&(b.rr_dataURL=y)}}if(u==="img"&&c){de||(de=r.createElement("canvas"),pr=de.getContext("2d"));let y=t,w=y.currentSrc||y.getAttribute("src")||"<unknown-src>",O=y.crossOrigin,_=()=>{y.removeEventListener("load",_);try{de.width=y.naturalWidth,de.height=y.naturalHeight,pr.drawImage(y,0,0),b.rr_dataURL=de.toDataURL(o.type,o.quality)}catch(U){if(y.crossOrigin!=="anonymous"){y.crossOrigin="anonymous",y.complete&&y.naturalWidth!==0?_():y.addEventListener("load",_);return}else console.warn(`Cannot inline img src=${w}! Error: ${U}`)}y.crossOrigin==="anonymous"&&(O?b.crossOrigin=O:y.removeAttribute("crossorigin"))};y.complete&&y.naturalWidth!==0?_():y.addEventListener("load",_)}if(["audio","video"].includes(u)){let y=b;y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime,y.rr_mediaPlaybackRate=t.playbackRate,y.rr_mediaMuted=t.muted,y.rr_mediaLoop=t.loop,y.rr_mediaVolume=t.volume}if(p||(t.scrollLeft&&(b.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(b.rr_scrollTop=t.scrollTop)),m){let{width:y,height:w}=t.getBoundingClientRect();b={class:b.class,rr_width:`${y}px`,rr_height:`${w}px`}}u==="iframe"&&!h(b.src)&&(t.contentDocument||(b.rr_src=b.src),delete b.src);let S;try{customElements.get(u)&&(S=!0)}catch(y){}return{type:F.Element,tagName:u,attributes:b,childNodes:[],isSVG:gn(t)||void 0,needBlock:m,rootId:f,isCustom:S}}function N(t){return t==null?"":t.toLowerCase()}function Dr(t){return t===!0||t==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:t==="all",headMetaDescKeywords:t==="all",headTitleMutations:t==="all"}:t||{}}function kn(t,e){if(e.comment&&t.type===F.Comment)return!0;if(t.type===F.Element){if(e.script&&(t.tagName==="script"||t.tagName==="link"&&(t.attributes.rel==="preload"&&t.attributes.as==="script"||t.attributes.rel==="modulepreload")||t.tagName==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&xr(t.attributes.href)==="js"))return!0;if(e.headFavicon&&(t.tagName==="link"&&t.attributes.rel==="shortcut icon"||t.tagName==="meta"&&(N(t.attributes.name).match(/^msapplication-tile(image|color)$/)||N(t.attributes.name)==="application-name"||N(t.attributes.rel)==="icon"||N(t.attributes.rel)==="apple-touch-icon"||N(t.attributes.rel)==="shortcut icon")))return!0;if(t.tagName==="meta"){if(e.headMetaDescKeywords&&N(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(N(t.attributes.property).match(/^(og|twitter|fb):/)||N(t.attributes.name).match(/^(og|twitter):/)||N(t.attributes.name)==="pinterest"))return!0;if(e.headMetaRobots&&(N(t.attributes.name)==="robots"||N(t.attributes.name)==="googlebot"||N(t.attributes.name)==="bingbot"))return!0;if(e.headMetaHttpEquiv&&t.attributes["http-equiv"]!==void 0)return!0;if(e.headMetaAuthorship&&(N(t.attributes.name)==="author"||N(t.attributes.name)==="generator"||N(t.attributes.name)==="framework"||N(t.attributes.name)==="publisher"||N(t.attributes.name)==="progid"||N(t.attributes.property).match(/^article:/)||N(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&(N(t.attributes.name)==="google-site-verification"||N(t.attributes.name)==="yandex-verification"||N(t.attributes.name)==="csrf-token"||N(t.attributes.name)==="p:domain_verify"||N(t.attributes.name)==="verify-v1"||N(t.attributes.name)==="verification"||N(t.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function me(t,e){let{doc:r,mirror:i,blockClass:n,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:o=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:h,maskInputFn:p,slimDOMOptions:f,dataURLOptions:m={},inlineImages:u=!1,recordCanvas:b=!1,onSerialize:C,onIframeLoad:S,iframeLoadTimeout:y=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:O=5e3,keepIframeSrcFn:_=()=>!1,newlyAddedElement:U=!1,cssCaptured:Q=!1}=e,{needsMask:V}=e,{preserveWhiteSpace:X=!0}=e;V||(V=Lr(t,a,l,V===void 0));let $=Sn(t,{doc:r,mirror:i,blockClass:n,blockSelector:s,needsMask:V,inlineStylesheet:c,maskInputOptions:d,maskTextFn:h,maskInputFn:p,dataURLOptions:m,inlineImages:u,recordCanvas:b,keepIframeSrcFn:_,newlyAddedElement:U,cssCaptured:Q});if(!$)return console.warn(t,"not serialized"),null;let ee;i.hasNode(t)?ee=i.getId(t):kn($,f)||!X&&$.type===F.Text&&!$.textContent.replace(/^\s+|\s+$/gm,"").length?ee=je:ee=Or();let E=Object.assign($,{id:ee});if(i.add(t,E),ee===je)return null;C&&C(t);let be=!o;if(E.type===F.Element){be=be&&!E.needBlock,delete E.needBlock;let B=v.shadowRoot(t);B&&we(B)&&(E.isShadowHost=!0)}if((E.type===F.Document||E.type===F.Element)&&be){f.headWhitespace&&E.type===F.Element&&E.tagName==="head"&&(X=!1);let B={doc:r,mirror:i,blockClass:n,blockSelector:s,needsMask:V,maskTextClass:a,maskTextSelector:l,skipChild:o,inlineStylesheet:c,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:f,dataURLOptions:m,inlineImages:u,recordCanvas:b,preserveWhiteSpace:X,onSerialize:C,onIframeLoad:S,iframeLoadTimeout:y,onStylesheetLoad:w,stylesheetLoadTimeout:O,keepIframeSrcFn:_,cssCaptured:!1};if(!(E.type===F.Element&&E.tagName==="textarea"&&E.attributes.value!==void 0)){E.type===F.Element&&E.attributes._cssText!==void 0&&typeof E.attributes._cssText=="string"&&(B.cssCaptured=!0);for(let se of Array.from(v.childNodes(t))){let te=me(se,B);te&&E.childNodes.push(te)}}let j=null;if(Er(t)&&(j=v.shadowRoot(t)))for(let se of Array.from(v.childNodes(j))){let te=me(se,B);te&&(we(j)&&(te.isShadow=!0),E.childNodes.push(te))}}let ve=v.parentNode(t);return ve&&Ce(ve)&&we(ve)&&(E.isShadow=!0),E.type===F.Element&&E.tagName==="iframe"&&bn(t,()=>{let B=t.contentDocument;if(B&&S){let j=me(B,{doc:B,mirror:i,blockClass:n,blockSelector:s,needsMask:V,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:f,dataURLOptions:m,inlineImages:u,recordCanvas:b,preserveWhiteSpace:X,onSerialize:C,onIframeLoad:S,iframeLoadTimeout:y,onStylesheetLoad:w,stylesheetLoadTimeout:O,keepIframeSrcFn:_});j&&S(t,j)}},y),E.type===F.Element&&E.tagName==="link"&&typeof E.attributes.rel=="string"&&(E.attributes.rel==="stylesheet"||E.attributes.rel==="preload"&&typeof E.attributes.href=="string"&&xr(E.attributes.href)==="css")&&vn(t,()=>{if(w){let B=me(t,{doc:r,mirror:i,blockClass:n,blockSelector:s,needsMask:V,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:h,maskInputFn:p,slimDOMOptions:f,dataURLOptions:m,inlineImages:u,recordCanvas:b,preserveWhiteSpace:X,onSerialize:C,onIframeLoad:S,iframeLoadTimeout:y,onStylesheetLoad:w,stylesheetLoadTimeout:O,keepIframeSrcFn:_});B&&w(t,B)}},O),E}function Mn(t,e){let{mirror:r=new ze,blockClass:i="rr-block",blockSelector:n=null,maskTextClass:s="rr-mask",maskTextSelector:a=null,inlineStylesheet:l=!0,inlineImages:o=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:h,maskInputFn:p,slimDOM:f=!1,dataURLOptions:m,preserveWhiteSpace:u,onSerialize:b,onIframeLoad:C,iframeLoadTimeout:S,onStylesheetLoad:y,stylesheetLoadTimeout:w,keepIframeSrcFn:O=()=>!1}=e,_=d===!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}:d===!1?{password:!0}:d,U=Dr(f);return me(t,{doc:t,mirror:r,blockClass:i,blockSelector:n,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:_,maskTextFn:h,maskInputFn:p,slimDOMOptions:U,dataURLOptions:m,inlineImages:o,recordCanvas:c,preserveWhiteSpace:u,onSerialize:b,onIframeLoad:C,iframeLoadTimeout:S,onStylesheetLoad:y,stylesheetLoadTimeout:w,keepIframeSrcFn:O,newlyAddedElement:!1})}function q(t,e,r=document){let i={capture:!0,passive:!0};return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function Me(t,e,r={}){let i=null,n=0;return function(...s){let a=Date.now();!n&&r.leading===!1&&(n=a);let l=e-(a-n),o=this;l<=0||l>e?(i&&(clearTimeout(i),i=null),n=a,t.apply(o,s)):!i&&r.trailing!==!1&&(i=setTimeout(()=>{n=r.leading===!1?0:Date.now(),i=null,t.apply(o,s)},l))}}function Qe(t,e,r,i,n=window){let s=n.Object.getOwnPropertyDescriptor(t,e);return n.Object.defineProperty(t,e,i?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),s&&s.set&&s.set.call(this,a)}}),()=>Qe(t,e,s||{},!0)}function Pr(t){var e,r,i,n;let s=t.document;return{left:s.scrollingElement?s.scrollingElement.scrollLeft:t.pageXOffset!==void 0?t.pageXOffset:s.documentElement.scrollLeft||(s==null?void 0:s.body)&&((e=v.parentElement(s.body))==null?void 0:e.scrollLeft)||((r=s==null?void 0:s.body)==null?void 0:r.scrollLeft)||0,top:s.scrollingElement?s.scrollingElement.scrollTop:t.pageYOffset!==void 0?t.pageYOffset:(s==null?void 0:s.documentElement.scrollTop)||(s==null?void 0:s.body)&&((i=v.parentElement(s.body))==null?void 0:i.scrollTop)||((n=s==null?void 0:s.body)==null?void 0:n.scrollTop)||0}}function Fr(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Br(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Wr(t){return t?t.nodeType===t.ELEMENT_NODE?t:v.parentElement(t):null}function K(t,e,r,i){if(!t)return!1;let n=Wr(t);if(!n)return!1;try{if(typeof e=="string"){if(n.classList.contains(e)||i&&n.closest("."+e)!==null)return!0}else if(Xe(n,e,i))return!0}catch(s){}return!!(r&&(n.matches(r)||i&&n.closest(r)!==null))}function In(t,e){return e.getId(t)!==-1}function yt(t,e,r){return t.tagName==="TITLE"&&r.headTitleMutations?!0:e.getId(t)===je}function Ur(t,e){if(Ce(t))return!1;let r=e.getId(t);if(!e.has(r))return!0;let i=v.parentNode(t);return i&&i.nodeType===t.DOCUMENT_NODE?!1:i?Ur(i,e):!0}function Ct(t){return!!t.changedTouches}function En(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)}function qr(t,e){return!!(t.nodeName==="IFRAME"&&e.getMeta(t))}function Kr(t,e){return!!(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function wt(t){return t?t instanceof St&&"shadowRoot"in t?!!t.shadowRoot:!!v.shadowRoot(t):!1}function Hr(t){var e;let r=null;return"getRootNode"in t&&((e=v.getRootNode(t))==null?void 0:e.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&v.host(v.getRootNode(t))&&(r=v.host(v.getRootNode(t))),r}function Tn(t){let e=t,r;for(;r=Hr(e);)e=r;return e}function xn(t){let e=v.ownerDocument(t);if(!e)return!1;let r=Tn(t);return v.contains(e,r)}function zr(t){let e=v.ownerDocument(t);return e?v.contains(e,t)||xn(t):!1}function Mt(t,e){t.delete(e),v.childNodes(e).forEach(r=>Mt(t,r))}function Nn(t,e){let r=[t];for(;r.length;){let i=r.pop();e.has(i)||(e.add(i),v.childNodes(i).forEach(n=>r.push(n)))}}function br(t,e){return t.size===0?!1:Gr(t,e)}function Gr(t,e){if(t.has(e))return!0;let r=v.parentNode(e);return r?Gr(t,r):!1}function On(t){Re=t}function _n(){Re=void 0}function Ie(t){try{if("composedPath"in t){let e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0]}catch(e){}return t&&t.target}function Vr(t,e){let r=new kt;le.push(r),r.init(t);let[i,n]=Ir(),s=new i(M(r.processMutations.bind(r)));return s.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[s,n]}function An({mousemoveCb:t,sampling:e,doc:r,mirror:i}){if(e.mousemove===!1)return()=>{};let n=typeof e.mousemove=="number"?e.mousemove:50,s=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500,a=[],l,o=Me(M(h=>{let p=Date.now()-l;t(a.map(f=>(f.timeOffset-=p,f)),h),a=[],l=null}),s),c=M(Me(M(h=>{let p=Ie(h),{clientX:f,clientY:m}=Ct(h)?h.changedTouches[0]:h;l||(l=ke()),a.push({x:f,y:m,id:i.getId(p),timeOffset:ke()-l}),o(typeof DragEvent!="undefined"&&h instanceof DragEvent?R.Drag:h instanceof MouseEvent?R.MouseMove:R.TouchMove)}),n,{trailing:!1})),d=[q("mousemove",c,r),q("touchmove",c,r),q("drag",c,r)];return M(()=>{d.forEach(h=>h())})}function Ln({mouseInteractionCb:t,doc:e,mirror:r,blockClass:i,blockSelector:n,sampling:s}){if(s.mouseInteraction===!1)return()=>{};let a=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,l=[],o=null,c=d=>h=>{let p=Ie(h);if(K(p,i,n,!0))return;let f=null,m=d;if("pointerType"in h){switch(h.pointerType){case"mouse":f=re.Mouse;break;case"touch":f=re.Touch;break;case"pen":f=re.Pen;break}f===re.Touch?H[d]===H.MouseDown?m="TouchStart":H[d]===H.MouseUp&&(m="TouchEnd"):re.Pen}else Ct(h)&&(f=re.Touch);f!==null?(o=f,(m.startsWith("Touch")&&f===re.Touch||m.startsWith("Mouse")&&f===re.Mouse)&&(f=null)):H[d]===H.Click&&(f=o,o=null);let u=Ct(h)?h.changedTouches[0]:h;if(!u)return;let b=r.getId(p),{clientX:C,clientY:S}=u;M(t)(k({type:H[m],id:b,x:C,y:S},f!==null&&{pointerType:f}))};return Object.keys(H).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&a[d]!==!1).forEach(d=>{let h=ne(d),p=c(d);if(window.PointerEvent)switch(H[d]){case H.MouseDown:case H.MouseUp:h=h.replace("mouse","pointer");break;case H.TouchStart:case H.TouchEnd:return}l.push(q(h,p,e))}),M(()=>{l.forEach(d=>d())})}function $r({scrollCb:t,doc:e,mirror:r,blockClass:i,blockSelector:n,sampling:s}){let a=M(Me(M(l=>{let o=Ie(l);if(!o||K(o,i,n,!0))return;let c=r.getId(o);if(o===e&&e.defaultView){let d=Pr(e.defaultView);t({id:c,x:d.left,y:d.top})}else t({id:c,x:o.scrollLeft,y:o.scrollTop})}),s.scroll||100));return q("scroll",a,e)}function Dn({viewportResizeCb:t},{win:e}){let r=-1,i=-1,n=M(Me(M(()=>{let s=Fr(),a=Br();(r!==s||i!==a)&&(t({width:Number(a),height:Number(s)}),r=s,i=a)}),200));return q("resize",n,e)}function Fn({inputCb:t,doc:e,mirror:r,blockClass:i,blockSelector:n,ignoreClass:s,ignoreSelector:a,maskInputOptions:l,maskInputFn:o,sampling:c,userTriggeredOnInput:d}){function h(S){let y=Ie(S),w=S.isTrusted,O=y&&y.tagName;if(y&&O==="OPTION"&&(y=v.parentElement(y)),!y||!O||Pn.indexOf(O)<0||K(y,i,n,!0)||y.classList.contains(s)||a&&y.matches(a))return;let _=y.value,U=!1,Q=Ve(y)||"";Q==="radio"||Q==="checkbox"?U=y.checked:(l[O.toLowerCase()]||l[Q])&&(_=Ge({element:y,maskInputOptions:l,tagName:O,type:Q,value:_,maskInputFn:o})),p(y,d?{text:_,isChecked:U,userTriggered:w}:{text:_,isChecked:U});let V=y.name;Q==="radio"&&V&&U&&e.querySelectorAll(`input[type="radio"][name="${V}"]`).forEach(X=>{if(X!==y){let $=X.value;p(X,d?{text:$,isChecked:!U,userTriggered:!1}:{text:$,isChecked:!U})}})}function p(S,y){let w=vr.get(S);if(!w||w.text!==y.text||w.isChecked!==y.isChecked){vr.set(S,y);let O=r.getId(S);M(t)(W(k({},y),{id:O}))}}let m=(c.input==="last"?["change"]:["input","change"]).map(S=>q(S,M(h),e)),u=e.defaultView;if(!u)return()=>{m.forEach(S=>S())};let b=u.Object.getOwnPropertyDescriptor(u.HTMLInputElement.prototype,"value"),C=[[u.HTMLInputElement.prototype,"value"],[u.HTMLInputElement.prototype,"checked"],[u.HTMLSelectElement.prototype,"value"],[u.HTMLTextAreaElement.prototype,"value"],[u.HTMLSelectElement.prototype,"selectedIndex"],[u.HTMLOptionElement.prototype,"selected"]];return b&&b.set&&m.push(...C.map(S=>Qe(S[0],S[1],{set(){M(h)({target:this,isTrusted:!1})}},!1,u))),M(()=>{m.forEach(S=>S())})}function Ye(t){let e=[];function r(i,n){if(Ue("CSSGroupingRule")&&i.parentRule instanceof CSSGroupingRule||Ue("CSSMediaRule")&&i.parentRule instanceof CSSMediaRule||Ue("CSSSupportsRule")&&i.parentRule instanceof CSSSupportsRule||Ue("CSSConditionRule")&&i.parentRule instanceof CSSConditionRule){let a=Array.from(i.parentRule.cssRules).indexOf(i);return n.unshift(a),r(i.parentRule,n)}else if(i.parentStyleSheet){let a=Array.from(i.parentStyleSheet.cssRules).indexOf(i);n.unshift(a)}return n}return r(t,e)}function ie(t,e,r){let i,n;return t?(t.ownerNode?i=e.getId(t.ownerNode):n=r.getId(t),{styleId:n,id:i}):{}}function Bn({styleSheetRuleCb:t,mirror:e,stylesheetManager:r},{win:i}){if(!i.CSSStyleSheet||!i.CSSStyleSheet.prototype)return()=>{};let n=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=new Proxy(n,{apply:M((d,h,p)=>{let[f,m]=p,{id:u,styleId:b}=ie(h,e,r.styleMirror);return(u&&u!==-1||b&&b!==-1)&&t({id:u,styleId:b,adds:[{rule:f,index:m}]}),d.apply(h,p)})}),i.CSSStyleSheet.prototype.addRule=function(d,h,p=this.cssRules.length){let f=`${d} { ${h} }`;return i.CSSStyleSheet.prototype.insertRule.apply(this,[f,p])};let s=i.CSSStyleSheet.prototype.deleteRule;i.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:M((d,h,p)=>{let[f]=p,{id:m,styleId:u}=ie(h,e,r.styleMirror);return(m&&m!==-1||u&&u!==-1)&&t({id:m,styleId:u,removes:[{index:f}]}),d.apply(h,p)})}),i.CSSStyleSheet.prototype.removeRule=function(d){return i.CSSStyleSheet.prototype.deleteRule.apply(this,[d])};let a;i.CSSStyleSheet.prototype.replace&&(a=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:M((d,h,p)=>{let[f]=p,{id:m,styleId:u}=ie(h,e,r.styleMirror);return(m&&m!==-1||u&&u!==-1)&&t({id:m,styleId:u,replace:f}),d.apply(h,p)})}));let l;i.CSSStyleSheet.prototype.replaceSync&&(l=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:M((d,h,p)=>{let[f]=p,{id:m,styleId:u}=ie(h,e,r.styleMirror);return(m&&m!==-1||u&&u!==-1)&&t({id:m,styleId:u,replaceSync:f}),d.apply(h,p)})}));let o={};qe("CSSGroupingRule")?o.CSSGroupingRule=i.CSSGroupingRule:(qe("CSSMediaRule")&&(o.CSSMediaRule=i.CSSMediaRule),qe("CSSConditionRule")&&(o.CSSConditionRule=i.CSSConditionRule),qe("CSSSupportsRule")&&(o.CSSSupportsRule=i.CSSSupportsRule));let c={};return Object.entries(o).forEach(([d,h])=>{c[d]={insertRule:h.prototype.insertRule,deleteRule:h.prototype.deleteRule},h.prototype.insertRule=new Proxy(c[d].insertRule,{apply:M((p,f,m)=>{let[u,b]=m,{id:C,styleId:S}=ie(f.parentStyleSheet,e,r.styleMirror);return(C&&C!==-1||S&&S!==-1)&&t({id:C,styleId:S,adds:[{rule:u,index:[...Ye(f),b||0]}]}),p.apply(f,m)})}),h.prototype.deleteRule=new Proxy(c[d].deleteRule,{apply:M((p,f,m)=>{let[u]=m,{id:b,styleId:C}=ie(f.parentStyleSheet,e,r.styleMirror);return(b&&b!==-1||C&&C!==-1)&&t({id:b,styleId:C,removes:[{index:[...Ye(f),u]}]}),p.apply(f,m)})})}),M(()=>{i.CSSStyleSheet.prototype.insertRule=n,i.CSSStyleSheet.prototype.deleteRule=s,a&&(i.CSSStyleSheet.prototype.replace=a),l&&(i.CSSStyleSheet.prototype.replaceSync=l),Object.entries(o).forEach(([d,h])=>{h.prototype.insertRule=c[d].insertRule,h.prototype.deleteRule=c[d].deleteRule})})}function jr({mirror:t,stylesheetManager:e},r){var i,n,s;let a=null;r.nodeName==="#document"?a=t.getId(r):a=t.getId(v.host(r));let l=r.nodeName==="#document"?(i=r.defaultView)==null?void 0:i.Document:(s=(n=r.ownerDocument)==null?void 0:n.defaultView)==null?void 0:s.ShadowRoot,o=l!=null&&l.prototype?Object.getOwnPropertyDescriptor(l==null?void 0:l.prototype,"adoptedStyleSheets"):void 0;return a===null||a===-1||!l||!o?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:o.configurable,enumerable:o.enumerable,get(){var c;return(c=o.get)==null?void 0:c.call(this)},set(c){var d;let h=(d=o.set)==null?void 0:d.call(this,c);if(a!==null&&a!==-1)try{e.adoptStyleSheets(c,a)}catch(p){}return h}}),M(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:o.configurable,enumerable:o.enumerable,get:o.get,set:o.set})}))}function Wn({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:r,stylesheetManager:i},{win:n}){let s=n.CSSStyleDeclaration.prototype.setProperty;n.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:M((l,o,c)=>{var d;let[h,p,f]=c;if(r.has(h))return s.apply(o,[h,p,f]);let{id:m,styleId:u}=ie((d=o.parentRule)==null?void 0:d.parentStyleSheet,e,i.styleMirror);return(m&&m!==-1||u&&u!==-1)&&t({id:m,styleId:u,set:{property:h,value:p,priority:f},index:Ye(o.parentRule)}),l.apply(o,c)})});let a=n.CSSStyleDeclaration.prototype.removeProperty;return n.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:M((l,o,c)=>{var d;let[h]=c;if(r.has(h))return a.apply(o,[h]);let{id:p,styleId:f}=ie((d=o.parentRule)==null?void 0:d.parentStyleSheet,e,i.styleMirror);return(p&&p!==-1||f&&f!==-1)&&t({id:p,styleId:f,remove:{property:h},index:Ye(o.parentRule)}),l.apply(o,c)})}),M(()=>{n.CSSStyleDeclaration.prototype.setProperty=s,n.CSSStyleDeclaration.prototype.removeProperty=a})}function Un({mediaInteractionCb:t,blockClass:e,blockSelector:r,mirror:i,sampling:n,doc:s}){let a=M(o=>Me(M(c=>{let d=Ie(c);if(!d||K(d,e,r,!0))return;let{currentTime:h,volume:p,muted:f,playbackRate:m,loop:u}=d;t({type:o,id:i.getId(d),currentTime:h,volume:p,muted:f,playbackRate:m,loop:u})}),n.media||500)),l=[q("play",a(he.Play),s),q("pause",a(he.Pause),s),q("seeked",a(he.Seeked),s),q("volumechange",a(he.VolumeChange),s),q("ratechange",a(he.RateChange),s)];return M(()=>{l.forEach(o=>o())})}function qn({fontCb:t,doc:e}){let r=e.defaultView;if(!r)return()=>{};let i=[],n=new WeakMap,s=r.FontFace;r.FontFace=function(o,c,d){let h=new s(o,c,d);return n.set(h,{family:o,buffer:typeof c!="string",descriptors:d,fontSource:typeof c=="string"?c:JSON.stringify(Array.from(new Uint8Array(c)))}),h};let a=ue(e.fonts,"add",function(l){return function(o){return setTimeout(M(()=>{let c=n.get(o);c&&(t(c),n.delete(o))}),0),l.apply(this,[o])}});return i.push(()=>{r.FontFace=s}),i.push(a),M(()=>{i.forEach(l=>l())})}function Kn(t){let{doc:e,mirror:r,blockClass:i,blockSelector:n,selectionCb:s}=t,a=!0,l=M(()=>{let o=e.getSelection();if(!o||a&&(o!=null&&o.isCollapsed))return;a=o.isCollapsed||!1;let c=[],d=o.rangeCount||0;for(let h=0;h<d;h++){let p=o.getRangeAt(h),{startContainer:f,startOffset:m,endContainer:u,endOffset:b}=p;K(f,i,n,!0)||K(u,i,n,!0)||c.push({start:r.getId(f),startOffset:m,end:r.getId(u),endOffset:b})}s({ranges:c})});return l(),q("selectionchange",l)}function Hn({doc:t,customElementCb:e}){let r=t.defaultView;return!r||!r.customElements?()=>{}:ue(r.customElements,"define",function(n){return function(s,a,l){try{e({define:{name:s}})}catch(o){console.warn(`Custom element callback failed for ${s}`)}return n.apply(this,[s,a,l])}})}function zn(t,e){let{mutationCb:r,mousemoveCb:i,mouseInteractionCb:n,scrollCb:s,viewportResizeCb:a,inputCb:l,mediaInteractionCb:o,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:h,fontCb:p,selectionCb:f,customElementCb:m}=t;t.mutationCb=(...u)=>{e.mutation&&e.mutation(...u),r(...u)},t.mousemoveCb=(...u)=>{e.mousemove&&e.mousemove(...u),i(...u)},t.mouseInteractionCb=(...u)=>{e.mouseInteraction&&e.mouseInteraction(...u),n(...u)},t.scrollCb=(...u)=>{e.scroll&&e.scroll(...u),s(...u)},t.viewportResizeCb=(...u)=>{e.viewportResize&&e.viewportResize(...u),a(...u)},t.inputCb=(...u)=>{e.input&&e.input(...u),l(...u)},t.mediaInteractionCb=(...u)=>{e.mediaInteaction&&e.mediaInteaction(...u),o(...u)},t.styleSheetRuleCb=(...u)=>{e.styleSheetRule&&e.styleSheetRule(...u),c(...u)},t.styleDeclarationCb=(...u)=>{e.styleDeclaration&&e.styleDeclaration(...u),d(...u)},t.canvasMutationCb=(...u)=>{e.canvasMutation&&e.canvasMutation(...u),h(...u)},t.fontCb=(...u)=>{e.font&&e.font(...u),p(...u)},t.selectionCb=(...u)=>{e.selection&&e.selection(...u),f(...u)},t.customElementCb=(...u)=>{e.customElement&&e.customElement(...u),m(...u)}}function Gn(t,e={}){let r=t.doc.defaultView;if(!r)return()=>{};zn(t,e);let i,n=()=>{};t.recordDOM&&([i,n]=Vr(t,t.doc));let s=An(t),a=Ln(t),l=$r(t),o=Dn(t,{win:r}),c=Fn(t),d=Un(t),h=()=>{},p=()=>{},f=()=>{},m=()=>{};t.recordDOM&&(h=Bn(t,{win:r}),p=jr(t,t.doc),f=Wn(t,{win:r}),t.collectFonts&&(m=qn(t)));let u=Kn(t),b=Hn(t),C=[];for(let S of t.plugins)C.push(S.observer(S.callback,r,S.options));return M(()=>{le.forEach(S=>S.reset()),i==null||i.disconnect(),n(),s(),a(),l(),o(),c(),d(),h(),p(),f(),m(),u(),b(),C.forEach(S=>S())})}function Ue(t){return typeof window[t]!="undefined"}function qe(t){return!!(typeof window[t]!="undefined"&&window[t].prototype&&"insertRule"in window[t].prototype&&"deleteRule"in window[t].prototype)}function jn(t,e){let r=Sr.get(t);return r||(r=new Map,Sr.set(t,r)),r.has(e)||r.set(e,[]),r.get(e)}function Ke(t,e,r){if(t instanceof Array)return t.map(i=>Ke(i,e,r));if(t===null)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){let i=t.constructor.name,n=$n(t);return{rr_type:i,base64:n}}else{if(t instanceof DataView)return{rr_type:t.constructor.name,args:[Ke(t.buffer,e,r),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){let i=t.constructor.name,{src:n}=t;return{rr_type:i,src:n}}else if(t instanceof HTMLCanvasElement){let i="HTMLImageElement",n=t.toDataURL();return{rr_type:i,src:n}}else{if(t instanceof ImageData)return{rr_type:t.constructor.name,args:[Ke(t.data,e,r),t.width,t.height]};if(Jr(t,e)||typeof t=="object"){let i=t.constructor.name,n=Xr(t,e,r);return{rr_type:i,index:n}}}}return t}function Xn(t,e,r,i){let n=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(let a of s)try{if(typeof e.CanvasRenderingContext2D.prototype[a]!="function")continue;let l=ue(e.CanvasRenderingContext2D.prototype,a,function(o){return function(...c){return K(this.canvas,r,i,!0)||setTimeout(()=>{let d=Yr(c,e,this);t(this.canvas,{type:ye["2D"],property:a,args:d})},0),o.apply(this,c)}});n.push(l)}catch(l){let o=Qe(e.CanvasRenderingContext2D.prototype,a,{set(c){t(this.canvas,{type:ye["2D"],property:a,args:[c],setter:!0})}});n.push(o)}return()=>{n.forEach(a=>a())}}function Yn(t){return t==="experimental-webgl"?"webgl":t}function Cr(t,e,r,i){let n=[];try{let s=ue(t.HTMLCanvasElement.prototype,"getContext",function(a){return function(l,...o){if(!K(this,e,r,!0)){let c=Yn(l);if("__context"in this||(this.__context=c),i&&["webgl","webgl2"].includes(c))if(o[0]&&typeof o[0]=="object"){let d=o[0];d.preserveDrawingBuffer||(d.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[l,...o])}});n.push(s)}catch(s){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(s=>s())}}function wr(t,e,r,i,n,s){let a=[],l=Object.getOwnPropertyNames(t);for(let o of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if(typeof t[o]!="function")continue;let c=ue(t,o,function(d){return function(...h){let p=d.apply(this,h);if(Xr(p,s,this),"tagName"in this.canvas&&!K(this.canvas,i,n,!0)){let f=Yr(h,s,this),m={type:e,property:o,args:f};r(this.canvas,m)}return p}});a.push(c)}catch(c){let d=Qe(t,o,{set(h){r(this.canvas,{type:e,property:o,args:[h],setter:!0})}});a.push(d)}return a}function Jn(t,e,r,i){let n=[];return typeof e.WebGLRenderingContext!="undefined"&&n.push(...wr(e.WebGLRenderingContext.prototype,ye.WebGL,t,r,i,e)),typeof e.WebGL2RenderingContext!="undefined"&&n.push(...wr(e.WebGL2RenderingContext.prototype,ye.WebGL2,t,r,i,e)),()=>{n.forEach(s=>s())}}function Zn(t){let e;try{if(e=Rr&&(self.URL||self.webkitURL).createObjectURL(Rr),!e)throw"";let r=new Worker(e,{name:t==null?void 0:t.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),r}catch(r){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Zr),{name:t==null?void 0:t.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Ee(t={}){let{emit:e,checkoutEveryNms:r,checkoutEveryNth:i,blockClass:n="rr-block",blockSelector:s=null,ignoreClass:a="rr-ignore",ignoreSelector:l=null,maskTextClass:o="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:p,slimDOMOptions:f,maskInputFn:m,maskTextFn:u,hooks:b,packFn:C,sampling:S={},dataURLOptions:y={},mousemoveWait:w,recordDOM:O=!0,recordCanvas:_=!1,recordCrossOriginIframes:U=!1,recordAfter:Q=t.recordAfter==="DOMContentLoaded"?t.recordAfter:"load",userTriggeredOnInput:V=!1,collectFonts:X=!1,inlineImages:$=!1,plugins:ee,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:be=new Set([]),errorHandler:ve}=t;On(ve);let B=U?window.parent===window:!0,j=!1;if(!B)try{window.parent.document&&(j=!1)}catch(T){j=!0}if(B&&!e)throw new Error("emit function is required");if(!B&&!j)return()=>{};w!==void 0&&S.mousemove===void 0&&(S.mousemove=w),Z.reset();let se=h===!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}:p!==void 0?p:{password:!0},te=Dr(f);En();let Ft,nt=0,Bt=T=>{for(let Y of ee||[])Y.eventProcessor&&(T=Y.eventProcessor(T));return C&&!j&&(T=C(T)),T};D=(T,Y)=>{var A;let L=T;if(L.timestamp=ke(),(A=le[0])!=null&&A.isFrozen()&&L.type!==I.FullSnapshot&&!(L.type===I.IncrementalSnapshot&&L.data.source===R.Mutation)&&le.forEach(z=>z.unfreeze()),B)e==null||e(Bt(L),Y);else if(j){let z={type:"rrweb",event:Bt(L),origin:window.location.origin,isCheckout:Y};window.parent.postMessage(z,"*")}if(L.type===I.FullSnapshot)Ft=L,nt=0;else if(L.type===I.IncrementalSnapshot){if(L.data.source===R.Mutation&&L.data.isAttachIframe)return;nt++;let z=i&&nt>=i,x=r&&L.timestamp-Ft.timestamp>r;(z||x)&&He(!0)}};let Te=T=>{D({type:I.IncrementalSnapshot,data:k({source:R.Mutation},T)})},Wt=T=>D({type:I.IncrementalSnapshot,data:k({source:R.Scroll},T)}),Ut=T=>D({type:I.IncrementalSnapshot,data:k({source:R.CanvasMutation},T)}),ri=T=>D({type:I.IncrementalSnapshot,data:k({source:R.AdoptedStyleSheet},T)}),oe=new xt({mutationCb:Te,adoptedStyleSheetCb:ri}),ae=new It({mirror:Z,mutationCb:Te,stylesheetManager:oe,recordCrossOriginIframes:U,wrappedEmit:D});for(let T of ee||[])T.getMirror&&T.getMirror({nodeMirror:Z,crossOriginIframeMirror:ae.crossOriginIframeMirror,crossOriginIframeStyleMirror:ae.crossOriginIframeStyleMirror});let st=new Nt;bt=new Tt({recordCanvas:_,mutationCb:Ut,win:window,blockClass:n,blockSelector:s,mirror:Z,sampling:S.canvas,dataURLOptions:y});let xe=new Et({mutationCb:Te,scrollCb:Wt,bypassOptions:{blockClass:n,blockSelector:s,maskTextClass:o,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:se,dataURLOptions:y,maskTextFn:u,maskInputFn:m,recordCanvas:_,inlineImages:$,sampling:S,slimDOMOptions:te,iframeManager:ae,stylesheetManager:oe,canvasManager:bt,keepIframeSrcFn:E,processedNodeManager:st},mirror:Z});He=(T=!1)=>{if(!O)return;D({type:I.Meta,data:{href:window.location.href,width:Br(),height:Fr()}},T),oe.reset(),xe.init(),le.forEach(A=>A.lock());let Y=Mn(document,{mirror:Z,blockClass:n,blockSelector:s,maskTextClass:o,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:se,maskTextFn:u,maskInputFn:m,slimDOM:te,dataURLOptions:y,recordCanvas:_,inlineImages:$,onSerialize:A=>{qr(A,Z)&&ae.addIframe(A),Kr(A,Z)&&oe.trackLinkElement(A),wt(A)&&xe.addShadowRoot(v.shadowRoot(A),document)},onIframeLoad:(A,L)=>{ae.attachIframe(A,L),xe.observeAttachShadow(A)},onStylesheetLoad:(A,L)=>{oe.attachLinkElement(A,L)},keepIframeSrcFn:E});if(!Y)return console.warn("Failed to snapshot the document");D({type:I.FullSnapshot,data:{node:Y,initialOffset:Pr(window)}},T),le.forEach(A=>A.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&oe.adoptStyleSheets(document.adoptedStyleSheets,Z.getId(document))};try{let T=[],Y=L=>{var z;return M(Gn)({mutationCb:Te,mousemoveCb:(x,ot)=>D({type:I.IncrementalSnapshot,data:{source:ot,positions:x}}),mouseInteractionCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.MouseInteraction},x)}),scrollCb:Wt,viewportResizeCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.ViewportResize},x)}),inputCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.Input},x)}),mediaInteractionCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.MediaInteraction},x)}),styleSheetRuleCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.StyleSheetRule},x)}),styleDeclarationCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.StyleDeclaration},x)}),canvasMutationCb:Ut,fontCb:x=>D({type:I.IncrementalSnapshot,data:k({source:R.Font},x)}),selectionCb:x=>{D({type:I.IncrementalSnapshot,data:k({source:R.Selection},x)})},customElementCb:x=>{D({type:I.IncrementalSnapshot,data:k({source:R.CustomElement},x)})},blockClass:n,ignoreClass:a,ignoreSelector:l,maskTextClass:o,maskTextSelector:c,maskInputOptions:se,inlineStylesheet:d,sampling:S,recordDOM:O,recordCanvas:_,inlineImages:$,userTriggeredOnInput:V,collectFonts:X,doc:L,maskInputFn:m,maskTextFn:u,keepIframeSrcFn:E,blockSelector:s,slimDOMOptions:te,dataURLOptions:y,mirror:Z,iframeManager:ae,stylesheetManager:oe,shadowDomManager:xe,processedNodeManager:st,canvasManager:bt,ignoreCSSAttributes:be,plugins:((z=ee==null?void 0:ee.filter(x=>x.observer))==null?void 0:z.map(x=>({observer:x.observer,options:x.options,callback:ot=>D({type:I.Plugin,data:{plugin:x.name,payload:ot}})})))||[]},b)};ae.addLoadListener(L=>{try{T.push(Y(L.contentDocument))}catch(z){console.warn(z)}});let A=()=>{He(),T.push(Y(document)),Ze=!0};return["interactive","complete"].includes(document.readyState)?A():(T.push(q("DOMContentLoaded",()=>{D({type:I.DomContentLoaded,data:{}}),Q==="DOMContentLoaded"&&A()})),T.push(q("load",()=>{D({type:I.Load,data:{}}),Q==="load"&&A()},window))),()=>{T.forEach(L=>{try{L()}catch(z){String(z).toLowerCase().includes("cross-origin")||console.warn(z)}}),st.destroy(),Ze=!1,_n()}}catch(T){console.warn(T)}}var Ti,xi,g,cr,I,R,H,re,ye,he,F,dr,hr,Be,kr,Ni,mt,gt,ke,v,ze,fr,tn,rn,nn,sn,Nr,on,an,cn,dn,je,de,pr,fn,pn,mr,St,fe,gr,Rt,yr,kt,Re,M,le,Pn,vr,Je,It,Et,ge,Vn,Se,$n,Sr,Xr,Yr,Jr,Zr,Rr,Tt,xt,Nt,D,He,bt,Ze,Z,ei=si(()=>{"use strict";Ti=Object.defineProperty,xi=(t,e,r)=>e in t?Ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g=(t,e,r)=>xi(t,typeof e!="symbol"?e+"":e,r),I=(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.Asset=7]="Asset",t))(I||{}),R=(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[t.CustomElement=16]="CustomElement",t))(R||{}),H=(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))(H||{}),re=(t=>(t[t.Mouse=0]="Mouse",t[t.Pen=1]="Pen",t[t.Touch=2]="Touch",t))(re||{}),ye=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(ye||{}),he=(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))(he||{}),F=(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",t))(F||{}),dr={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument","firstChild","lastChild","nextSibling","previousSibling"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},hr={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Be={},kr={},Ni=()=>!!globalThis.Zone;mt={};gt={};ke=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(ke=()=>new Date().getTime());v={ownerDocument:Oi,childNodes:_i,parentNode:Ai,parentElement:Li,textContent:Di,firstChild:Pi,lastChild:Fi,nextSibling:Bi,previousSibling:Wi,contains:Ui,getRootNode:qi,host:Ki,styleSheets:Hi,shadowRoot:zi,querySelector:Gi,querySelectorAll:Vi,nowTimestamp:ke,mutationObserverCtor:Ir,patch:ue};ze=class{constructor(){g(this,"idNodeMap",new Map),g(this,"nodeMetaMap",new WeakMap)}getId(e){var r;if(!e)return-1;let i=(r=this.getMeta(e))==null?void 0:r.id;return i!=null?i:-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){let r=this.getId(e);this.idNodeMap.delete(r),e.childNodes&&e.childNodes.forEach(i=>this.removeNodeFromMap(i))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,r){let i=r.id;this.idNodeMap.set(i,e),this.nodeMetaMap.set(e,r)}replace(e,r){let i=this.getNode(e);if(i){let n=this.nodeMetaMap.get(i);n&&this.nodeMetaMap.set(r,n)}this.idNodeMap.set(e,r)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};fr="__rrweb_original__";tn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,rn=/^(?:[a-z+]+:)?\/\//i,nn=/^www\..*/i,sn=/^(data:)([^,]*),(.*)/i;Nr="(?:/\\*[^*]*\\*/)|[\\s;]",on=new RegExp(`${Nr}|\\b(0)px?`,"g"),an=new RegExp(Nr,"g");cn=1,dn=new RegExp("[^a-z0-9-_:]"),je=-2;fn=/^[^ \t\n\r\u000c]+/,pn=/^[, \t\n\r\u000c]+/;mr=new WeakMap;St=class t{constructor(...e){g(this,"parentElement",null),g(this,"parentNode",null),g(this,"ownerDocument"),g(this,"firstChild",null),g(this,"lastChild",null),g(this,"previousSibling",null),g(this,"nextSibling",null),g(this,"ELEMENT_NODE",1),g(this,"TEXT_NODE",3),g(this,"nodeType"),g(this,"nodeName"),g(this,"RRNodeType")}get childNodes(){let e=[],r=this.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}contains(e){if(e instanceof t){if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0}else return!1;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};fe=`Please stop import mirror directly. Instead of that,\r
|
|
2
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
3
|
+
or you can use record.mirror to access the mirror instance during recording.`,gr={map:{},getId(){return console.error(fe),-1},getNode(){return console.error(fe),null},removeNodeFromMap(){console.error(fe)},has(){return console.error(fe),!1},reset(){console.error(fe)}};typeof window!="undefined"&&window.Proxy&&window.Reflect&&(gr=new Proxy(gr,{get(t,e,r){return e==="map"&&console.error(fe),Reflect.get(t,e,r)}}));Rt=class{constructor(){g(this,"id",1),g(this,"styleIDMap",new WeakMap),g(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 i;return r===void 0?i=this.id++:i=r,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};yr=(t,e)=>`${t}@${e}`,kt=class{constructor(){g(this,"frozen",!1),g(this,"locked",!1),g(this,"texts",[]),g(this,"attributes",[]),g(this,"attributeMap",new WeakMap),g(this,"removes",[]),g(this,"mapRemoves",[]),g(this,"movedMap",{}),g(this,"addedSet",new Set),g(this,"movedSet",new Set),g(this,"droppedSet",new Set),g(this,"removesSubTreeCache",new Set),g(this,"mutationCb"),g(this,"blockClass"),g(this,"blockSelector"),g(this,"maskTextClass"),g(this,"maskTextSelector"),g(this,"inlineStylesheet"),g(this,"maskInputOptions"),g(this,"maskTextFn"),g(this,"maskInputFn"),g(this,"keepIframeSrcFn"),g(this,"recordCanvas"),g(this,"inlineImages"),g(this,"slimDOMOptions"),g(this,"dataURLOptions"),g(this,"doc"),g(this,"mirror"),g(this,"iframeManager"),g(this,"stylesheetManager"),g(this,"shadowDomManager"),g(this,"canvasManager"),g(this,"processedNodeManager"),g(this,"unattachedDoc"),g(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),g(this,"emit",()=>{if(this.frozen||this.locked)return;let e=[],r=new Set;for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let p of this.movedSet){let f=v.parentNode(p);this.removesSubTreeCache.has(f)&&!this.movedSet.has(f)||this.addedSet.add(p)}let i=null,n=null,s=-1,a=null,l=!1,o=new Set,c=this.addedSet.values(),d=c.next();for(;this.addedSet.size;){if(i!==null&&this.addedSet.has(v.previousSibling(i)))a=i,i=v.previousSibling(i);else{for(this.addedSet.has(d.value)||(d=c.next()),i=d.value;;){if(n=v.parentNode(i),this.addedSet.has(n)){i=n;continue}break}if(o.has(n))n=null;else if(n){if(zr(n)?(l=br(this.droppedSet,n)||this.removesSubTreeCache.has(n),l&&br(this.movedSet,i)&&(l=!1)):l=!0,this.addedSet.has(v.lastChild(n)))i=v.lastChild(n),a=null;else for(;;){if(a=v.nextSibling(i),this.addedSet.has(a)){i=a;continue}break}if(s=Ce(n)?this.mirror.getId(Hr(i)):this.mirror.getId(n),s===-1&&n.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let u=v.host(n);s=this.mirror.getId(u)}}}if(this.addedSet.delete(i),!n||s===-1){o.add(i);continue}else if(l){this.droppedSet.add(i);continue}let p=!1;if(i.nodeType===Node.TEXT_NODE){let u=n.tagName;if(u==="TEXTAREA")continue;u==="STYLE"&&r.has(s)&&(p=!0)}let f=a?this.mirror.getId(a):null;for(;f===je;)a=a&&v.nextSibling(a),f=a&&this.mirror.getId(a);if(f===-1){console.warn("Couldn't record new node. Couldn't find mirror id for nextSibling:",a),i=null;continue}let m=me(i,{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:u=>{qr(u,this.mirror)&&this.iframeManager.addIframe(u),Kr(u,this.mirror)&&this.stylesheetManager.trackLinkElement(u),wt(i)&&this.shadowDomManager.addShadowRoot(v.shadowRoot(i),this.doc)},onIframeLoad:(u,b)=>{this.iframeManager.attachIframe(u,b),this.shadowDomManager.observeAttachShadow(u)},onStylesheetLoad:(u,b)=>{this.stylesheetManager.attachLinkElement(u,b)},cssCaptured:p});m&&(e.push({parentId:s,nextId:f,node:m}),r.add(m.id))}let h={texts:this.texts.map(p=>{let f=p.node,m=v.parentNode(f);return m&&m.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(m),{id:this.mirror.getId(f),value:p.value}}).filter(p=>!r.has(p.id)).filter(p=>this.mirror.has(p.id)),attributes:this.attributes.map(p=>{let{attributes:f}=p;if(typeof f.style=="string"){let m=JSON.stringify(p.styleDiff),u=JSON.stringify(p._unchangedStyles);m.length<f.style.length&&(m+u).split("var(").length===f.style.split("var(").length&&(f.style=p.styleDiff)}return{id:this.mirror.getId(p.node),attributes:f}}).filter(p=>!r.has(p.id)).filter(p=>this.mirror.has(p.id)),removes:this.removes,adds:e};!h.texts.length&&!h.attributes.length&&!h.removes.length&&!h.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(h))}),g(this,"genTextAreaValueMutation",e=>{let r=this.attributeMap.get(e);r||(r={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(e,r));let i=Array.from(v.childNodes(e),n=>v.textContent(n)||"").join("");r.attributes.value=Ge({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Ve(e),value:i,maskInputFn:this.maskInputFn})}),g(this,"processMutation",e=>{if(!yt(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{let r=v.textContent(e.target);!K(e.target,this.blockClass,this.blockSelector,!1)&&r!==e.oldValue&&this.texts.push({value:Lr(e.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,Wr(e.target)):r.replace(/[\S]/g,"*"):r,node:e.target});break}case"attributes":{let r=e.target,i=ne(r.tagName),n=e.attributeName,s=e.target.getAttribute(n);if(n==="value"){let l=Ve(r);s=Ge({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:l,value:s,maskInputFn:this.maskInputFn})}if(K(e.target,this.blockClass,this.blockSelector,!1)||s===e.oldValue)return;let a=this.attributeMap.get(e.target);if(i==="iframe"&&n==="src"&&!this.keepIframeSrcFn(s))if(!r.contentDocument)n="rr_src";else return;if(a||(a={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(a),this.attributeMap.set(e.target,a)),n==="type"&&i==="input"&&(e.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ar(i,n))if(a.attributes[n]=_r(this.doc,i,ne(n),s),n==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(o){this.unattachedDoc=this.doc}let l=this.unattachedDoc.createElement("span");e.oldValue&&l.setAttribute("style",e.oldValue);for(let o of Array.from(r.style)){let c=r.style.getPropertyValue(o),d=r.style.getPropertyPriority(o);c!==l.style.getPropertyValue(o)||d!==l.style.getPropertyPriority(o)?d===""?a.styleDiff[o]=c:a.styleDiff[o]=[c,d]:a._unchangedStyles[o]=[c,d]}for(let o of Array.from(l.style))r.style.getPropertyValue(o)===""&&(a.styleDiff[o]=!1)}else n==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?a.attributes.rr_open_mode="modal":a.attributes.rr_open_mode="non-modal");break}case"childList":{if(K(e.target,this.blockClass,this.blockSelector,!0))return;if(e.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(e.target);return}e.addedNodes.forEach(r=>this.genAdds(r,e.target)),e.removedNodes.forEach(r=>{let i=this.mirror.getId(r),n=Ce(e.target)?this.mirror.getId(v.host(e.target)):this.mirror.getId(e.target);K(e.target,this.blockClass,this.blockSelector,!1)||yt(r,this.mirror,this.slimDOMOptions)||!In(r,this.mirror)||(this.addedSet.has(r)?(Mt(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(e.target)&&i===-1||Ur(e.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[yr(i,n)]?Mt(this.movedSet,r):(this.removes.push({parentId:n,id:i,isShadow:Ce(e.target)&&we(e.target)?!0:void 0}),Nn(r,this.removesSubTreeCache))),this.mapRemoves.push(r))});break}}}),g(this,"genAdds",(e,r)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!(this.addedSet.has(e)||this.movedSet.has(e))){if(this.mirror.hasNode(e)){if(yt(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let i=null;r&&this.mirror.hasNode(r)&&(i=this.mirror.getId(r)),i&&i!==-1&&(this.movedMap[yr(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);K(e,this.blockClass,this.blockSelector,!1)||(v.childNodes(e).forEach(i=>this.genAdds(i)),wt(e)&&v.childNodes(v.shadowRoot(e)).forEach(i=>{this.processedNodeManager.add(i,this),this.genAdds(i,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(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()}};M=t=>Re?(...r)=>{try{return t(...r)}catch(i){if(Re&&Re(i)===!0)return;throw i}}:t,le=[];Pn=["INPUT","TEXTAREA","SELECT"],vr=new WeakMap;Je=class{constructor(e){g(this,"iframeIdToRemoteIdMap",new WeakMap),g(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=e}getId(e,r,i,n){let s=i||this.getIdToRemoteIdMap(e),a=n||this.getRemoteIdToIdMap(e),l=s.get(r);return l||(l=this.generateIdFn(),s.set(r,l),a.set(l,r)),l}getIds(e,r){let i=this.getIdToRemoteIdMap(e),n=this.getRemoteIdToIdMap(e);return r.map(s=>this.getId(e,s,i,n))}getRemoteId(e,r,i){let n=i||this.getRemoteIdToIdMap(e);if(typeof r!="number")return r;let s=n.get(r);return s||-1}getRemoteIds(e,r){let i=this.getRemoteIdToIdMap(e);return r.map(n=>this.getRemoteId(e,n,i))}reset(e){if(!e){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let r=this.iframeIdToRemoteIdMap.get(e);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(e,r)),r}getRemoteIdToIdMap(e){let r=this.iframeRemoteIdToIdMap.get(e);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(e,r)),r}},It=class{constructor(e){g(this,"iframes",new WeakMap),g(this,"crossOriginIframeMap",new WeakMap),g(this,"crossOriginIframeMirror",new Je(Or)),g(this,"crossOriginIframeStyleMirror"),g(this,"crossOriginIframeRootIdMap",new WeakMap),g(this,"mirror"),g(this,"mutationCb"),g(this,"wrappedEmit"),g(this,"loadListener"),g(this,"stylesheetManager"),g(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Je(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,r){var i,n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((i=e.contentWindow)==null||i.addEventListener("message",this.handleMessage.bind(this))),(n=this.loadListener)==null||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){let r=e;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!e.source)return;let n=this.crossOriginIframeMap.get(e.source);if(!n)return;let s=this.transformCrossOriginEvent(n,r.data.event);s&&this.wrappedEmit(s,r.data.isCheckout)}transformCrossOriginEvent(e,r){var i;switch(r.type){case I.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(r.data.node,e);let n=r.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(r.data.node,n),{timestamp:r.timestamp,type:I.IncrementalSnapshot,data:{source:R.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case I.Meta:case I.Load:case I.DomContentLoaded:return!1;case I.Plugin:return r;case I.Custom:return this.replaceIds(r.data.payload,e,["id","parentId","previousId","nextId"]),r;case I.IncrementalSnapshot:switch(r.data.source){case R.Mutation:return r.data.adds.forEach(n=>{this.replaceIds(n,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(n.node,e);let s=this.crossOriginIframeRootIdMap.get(e);s&&this.patchRootIdOnNode(n.node,s)}),r.data.removes.forEach(n=>{this.replaceIds(n,e,["parentId","id"])}),r.data.attributes.forEach(n=>{this.replaceIds(n,e,["id"])}),r.data.texts.forEach(n=>{this.replaceIds(n,e,["id"])}),r;case R.Drag:case R.TouchMove:case R.MouseMove:return r.data.positions.forEach(n=>{this.replaceIds(n,e,["id"])}),r;case R.ViewportResize:return!1;case R.MediaInteraction:case R.MouseInteraction:case R.Scroll:case R.CanvasMutation:case R.Input:return this.replaceIds(r.data,e,["id"]),r;case R.StyleSheetRule:case R.StyleDeclaration:return this.replaceIds(r.data,e,["id"]),this.replaceStyleIds(r.data,e,["styleId"]),r;case R.Font:return r;case R.Selection:return r.data.ranges.forEach(n=>{this.replaceIds(n,e,["start","end"])}),r;case R.AdoptedStyleSheet:return this.replaceIds(r.data,e,["id"]),this.replaceStyleIds(r.data,e,["styleIds"]),(i=r.data.styles)==null||i.forEach(n=>{this.replaceStyleIds(n,e,["styleId"])}),r}}return!1}replace(e,r,i,n){for(let s of n)!Array.isArray(r[s])&&typeof r[s]!="number"||(Array.isArray(r[s])?r[s]=e.getIds(i,r[s]):r[s]=e.getId(i,r[s]));return r}replaceIds(e,r,i){return this.replace(this.crossOriginIframeMirror,e,r,i)}replaceStyleIds(e,r,i){return this.replace(this.crossOriginIframeStyleMirror,e,r,i)}replaceIdOnNode(e,r){this.replaceIds(e,r,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(i=>{this.replaceIdOnNode(i,r)})}patchRootIdOnNode(e,r){e.type!==F.Document&&!e.rootId&&(e.rootId=r),"childNodes"in e&&e.childNodes.forEach(i=>{this.patchRootIdOnNode(i,r)})}},Et=class{constructor(e){g(this,"shadowDoms",new WeakSet),g(this,"mutationCb"),g(this,"scrollCb"),g(this,"bypassOptions"),g(this,"mirror"),g(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,r){if(!we(e)||this.shadowDoms.has(e))return;this.shadowDoms.add(e);let[i]=Vr(W(k({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(()=>i.disconnect()),this.restoreHandlers.push($r(W(k({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(v.host(e))),this.restoreHandlers.push(jr({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){!e.contentWindow||!e.contentDocument||this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,r){let i=this;this.restoreHandlers.push(ue(e.prototype,"attachShadow",function(n){return function(s){let a=n.call(this,s),l=v.shadowRoot(this);return l&&zr(this)&&i.addShadowRoot(l,r),a}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(r){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}},ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vn=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(Se=0;Se<ge.length;Se++)Vn[ge.charCodeAt(Se)]=Se;$n=function(t){var e=new Uint8Array(t),r,i=e.length,n="";for(r=0;r<i;r+=3)n+=ge[e[r]>>2],n+=ge[(e[r]&3)<<4|e[r+1]>>4],n+=ge[(e[r+1]&15)<<2|e[r+2]>>6],n+=ge[e[r+2]&63];return i%3===2?n=n.substring(0,n.length-1)+"=":i%3===1&&(n=n.substring(0,n.length-2)+"=="),n},Sr=new Map;Xr=(t,e,r)=>{if(!t||!(Jr(t,e)||typeof t=="object"))return;let i=t.constructor.name,n=jn(r,i),s=n.indexOf(t);return s===-1&&(s=n.length,n.push(t)),s};Yr=(t,e,r)=>t.map(i=>Ke(i,e,r)),Jr=(t,e)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof e[n]=="function").find(n=>t instanceof e[n]);Zr=`(function() {
|
|
4
|
+
"use strict";
|
|
5
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6
|
+
var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
|
|
7
|
+
for (var i = 0; i < chars.length; i++) {
|
|
8
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
9
|
+
}
|
|
10
|
+
var encode = function(arraybuffer) {
|
|
11
|
+
var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
|
|
12
|
+
for (i2 = 0; i2 < len; i2 += 3) {
|
|
13
|
+
base64 += chars[bytes[i2] >> 2];
|
|
14
|
+
base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
|
|
15
|
+
base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
|
|
16
|
+
base64 += chars[bytes[i2 + 2] & 63];
|
|
17
|
+
}
|
|
18
|
+
if (len % 3 === 2) {
|
|
19
|
+
base64 = base64.substring(0, base64.length - 1) + "=";
|
|
20
|
+
} else if (len % 3 === 1) {
|
|
21
|
+
base64 = base64.substring(0, base64.length - 2) + "==";
|
|
22
|
+
}
|
|
23
|
+
return base64;
|
|
24
|
+
};
|
|
25
|
+
const lastBlobMap = /* @__PURE__ */ new Map();
|
|
26
|
+
const transparentBlobMap = /* @__PURE__ */ new Map();
|
|
27
|
+
async function getTransparentBlobFor(width, height, dataURLOptions) {
|
|
28
|
+
const id = \`\${width}-\${height}\`;
|
|
29
|
+
if ("OffscreenCanvas" in globalThis) {
|
|
30
|
+
if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);
|
|
31
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
32
|
+
offscreen.getContext("2d");
|
|
33
|
+
const blob = await offscreen.convertToBlob(dataURLOptions);
|
|
34
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
35
|
+
const base64 = encode(arrayBuffer);
|
|
36
|
+
transparentBlobMap.set(id, base64);
|
|
37
|
+
return base64;
|
|
38
|
+
} else {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const worker = self;
|
|
43
|
+
worker.onmessage = async function(e) {
|
|
44
|
+
if ("OffscreenCanvas" in globalThis) {
|
|
45
|
+
const { id, bitmap, width, height, dataURLOptions } = e.data;
|
|
46
|
+
const transparentBase64 = getTransparentBlobFor(
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
dataURLOptions
|
|
50
|
+
);
|
|
51
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
52
|
+
const ctx = offscreen.getContext("2d");
|
|
53
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
54
|
+
bitmap.close();
|
|
55
|
+
const blob = await offscreen.convertToBlob(dataURLOptions);
|
|
56
|
+
const type = blob.type;
|
|
57
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
58
|
+
const base64 = encode(arrayBuffer);
|
|
59
|
+
if (!lastBlobMap.has(id) && await transparentBase64 === base64) {
|
|
60
|
+
lastBlobMap.set(id, base64);
|
|
61
|
+
return worker.postMessage({ id });
|
|
62
|
+
}
|
|
63
|
+
if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });
|
|
64
|
+
worker.postMessage({
|
|
65
|
+
id,
|
|
66
|
+
type,
|
|
67
|
+
base64,
|
|
68
|
+
width,
|
|
69
|
+
height
|
|
70
|
+
});
|
|
71
|
+
lastBlobMap.set(id, base64);
|
|
72
|
+
} else {
|
|
73
|
+
return worker.postMessage({ id: e.data.id });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
})();
|
|
77
|
+
//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map
|
|
78
|
+
`,Rr=typeof self!="undefined"&&self.Blob&&new Blob([Zr],{type:"text/javascript;charset=utf-8"});Tt=class{constructor(e){g(this,"pendingCanvasMutations",new Map),g(this,"rafStamps",{latestId:0,invokeId:null}),g(this,"mirror"),g(this,"mutationCb"),g(this,"resetObservers"),g(this,"frozen",!1),g(this,"locked",!1),g(this,"processMutation",(o,c)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(o)||this.pendingCanvasMutations.set(o,[]),this.pendingCanvasMutations.get(o).push(c)});let{sampling:r="all",win:i,blockClass:n,blockSelector:s,recordCanvas:a,dataURLOptions:l}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,a&&r==="all"&&this.initCanvasMutationObserver(i,n,s),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,i,n,s,{dataURLOptions:l})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,r,i,n,s){let a=Cr(r,i,n,!0),l=new Map,o=new Zn;o.onmessage=m=>{let{id:u}=m.data;if(l.set(u,!1),!("base64"in m.data))return;let{base64:b,type:C,width:S,height:y}=m.data;this.mutationCb({id:u,type:ye["2D"],commands:[{property:"clearRect",args:[0,0,S,y]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:b}],type:C}]},0,0]}]})};let c=1e3/e,d=0,h,p=()=>{let m=[];return r.document.querySelectorAll("canvas").forEach(u=>{K(u,i,n,!0)||m.push(u)}),m},f=m=>{if(d&&m-d<c){h=requestAnimationFrame(f);return}d=m,p().forEach(async u=>{var b;let C=this.mirror.getId(u);if(l.get(C)||u.width===0||u.height===0)return;if(l.set(C,!0),["webgl","webgl2"].includes(u.__context)){let y=u.getContext(u.__context);((b=y==null?void 0:y.getContextAttributes())==null?void 0:b.preserveDrawingBuffer)===!1&&y.clear(y.COLOR_BUFFER_BIT)}let S=await createImageBitmap(u);o.postMessage({id:C,bitmap:S,width:u.width,height:u.height,dataURLOptions:s.dataURLOptions},[S])}),h=requestAnimationFrame(f)};h=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(h)}}initCanvasMutationObserver(e,r,i){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let n=Cr(e,r,i,!1),s=Xn(this.processMutation.bind(this),e,r,i),a=Jn(this.processMutation.bind(this),e,r,i);this.resetObservers=()=>{n(),s(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=r=>{this.rafStamps.latestId=r,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,r)=>{let i=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,i)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,r){if(this.frozen||this.locked)return;let i=this.pendingCanvasMutations.get(e);if(!i||r===-1)return;let n=i.map(a=>{let c=a,{type:l}=c;return Gt(c,["type"])}),{type:s}=i[0];this.mutationCb({id:r,type:s,commands:n}),this.pendingCanvasMutations.delete(e)}},xt=class{constructor(e){g(this,"trackedLinkElements",new WeakSet),g(this,"mutationCb"),g(this,"adoptedStyleSheetCb"),g(this,"styleMirror",new Rt),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,r){if(e.length===0)return;let i={id:r,styleIds:[]},n=[];for(let s of e){let a;this.styleMirror.has(s)?a=this.styleMirror.getId(s):(a=this.styleMirror.add(s),n.push({styleId:a,rules:Array.from(s.rules||CSSRule,(l,o)=>({rule:Tr(l,s.href),index:o}))})),i.styleIds.push(a)}n.length>0&&(i.styles=n),this.adoptedStyleSheetCb(i)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},Nt=class{constructor(){g(this,"nodeMap",new WeakMap),g(this,"active",!1)}inOtherBuffer(e,r){let i=this.nodeMap.get(e);return i&&Array.from(i).some(n=>n!==r)}add(e,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(r))}destroy(){}},Ze=!1;try{if(Array.from([1],t=>t*2)[0]!==2){let t=document.createElement("iframe");document.body.appendChild(t),Array.from=((cr=t.contentWindow)==null?void 0:cr.Array.from)||Array.from,document.body.removeChild(t)}}catch(t){console.debug("Unable to override Array.from",t)}Z=Zi();Ee.addCustomEvent=(t,e)=>{if(!Ze)throw new Error("please add custom event after start recording");D({type:I.Custom,data:{tag:t,payload:e}})};Ee.freezePage=()=>{le.forEach(t=>t.freeze())};Ee.takeFullSnapshot=t=>{if(!Ze)throw new Error("please take full snapshot after start recording");He(t)};Ee.mirror=Z});var Pt={};Vt(Pt,{consent:()=>hs,getRecordingId:()=>fs,init:()=>Dt,shutdown:()=>ps,start:()=>us,stop:()=>ds,trigger:()=>cs});var $t="hm_rk_state",Oe=class{constructor(e){this.env=e;this.cache=null}load(e){var i;if(((i=this.cache)==null?void 0:i.sid)===e)return this.cache;let r=null;try{let n=this.env.getSession($t);n&&(r=JSON.parse(n))}catch(n){r=null}return(!r||r.sid!==e||typeof r.seq!="number")&&(r={sid:e,seq:0}),this.cache=r,r}save(e){this.cache=e;try{this.env.setSession($t,JSON.stringify(e))}catch(r){}}};function at(t,e){return{startedAt:t,endedAt:t,activeMs:0,clicks:0,rageClicks:0,deadClicks:0,errors:0,pages:1,entryUrl:e}}var Yt=typeof window!="undefined"&&typeof document!="undefined";function oi(){let t=globalThis.crypto;if(t&&typeof t.randomUUID=="function")try{return t.randomUUID()}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function jt(t,e){try{return t().getItem(e)}catch(r){return null}}function Xt(t,e,r){try{r===null?t().removeItem(e):t().setItem(e,r)}catch(i){}}function ai(){if(typeof indexedDB=="undefined")return;let t=null,e=()=>t!=null?t:t=new Promise((i,n)=>{let s=indexedDB.open("himetrica-replaykit",1);s.onupgradeneeded=()=>s.result.createObjectStore("kv"),s.onsuccess=()=>i(s.result),s.onerror=()=>n(s.error)}),r=(i,n)=>e().then(s=>new Promise(a=>{let l=s.transaction("kv",i),o=n(l.objectStore("kv"));l.oncomplete=()=>a(o?o.result:void 0),l.onerror=l.onabort=()=>a(void 0)})).catch(()=>{});return{get:i=>r("readonly",n=>n.get(i)),set:(i,n)=>r("readwrite",s=>{s.put(n,i)}).then(()=>{}),del:i=>r("readwrite",n=>{n.delete(i)}).then(()=>{})}}function li(){if(!(typeof CompressionStream=="undefined"||typeof Blob=="undefined"||typeof Response=="undefined"))return t=>new Response(new Blob([t]).stream().pipeThrough(new CompressionStream("gzip"))).blob()}function Jt(){let t=typeof fetch=="function"?fetch.bind(globalThis):void 0,e=typeof navigator!="undefined"?navigator:void 0;return{now:()=>Date.now(),uuid:()=>oi(),fetch:t,sendBeacon:e&&typeof e.sendBeacon=="function"?(r,i)=>{try{return e.sendBeacon(r,new Blob([i],{type:"text/plain"}))}catch(n){return!1}}:void 0,getLocal:r=>jt(()=>localStorage,r),setLocal:(r,i)=>Xt(()=>localStorage,r,i),getSession:r=>jt(()=>sessionStorage,r),setSession:(r,i)=>Xt(()=>sessionStorage,r,i),getCookie:r=>{try{let i=document.cookie.match(new RegExp("(?:^|; )"+r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"=([^;]*)"));return i?decodeURIComponent(i[1]):null}catch(i){return null}},store:ai(),gzip:li(),setTimer:(r,i)=>setTimeout(r,i),clearTimer:r=>clearTimeout(r)}}function Zt(t){let e=t.getCookie("hm_vid")||t.getLocal("hm_visitor_id")||void 0,r=t.getCookie("hm_sid")||t.getSession("hm_session_id")||void 0;return{visitorId:e,sessionId:r}}function ui(t,e){let r=t.trim().toLowerCase();if(!r)return!1;let i=(e||"/").toLowerCase();if(!r.includes("*")){let s=r.endsWith("/")&&r.length>1?r.slice(0,-1):r;return i===s||i.startsWith(s.endsWith("/")?s:s+"/")}return new RegExp("^"+r.split("*").map(ci).join(".*")+"$").test(i)}function lt(t,e){for(let r of t)if(ui(r,e))return!0;return!1}function ci(t){return t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}function di(t){let e=3735928559,r=1103547991;for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);e=Math.imul(e^s,2654435761),r=Math.imul(r^s,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&r)+(e>>>0))/9007199254740992}function Qt(t,e){return e>0?e>=1?!0:di(t)<e:!1}function J(t){let e=t.search(/[?#]/);return e===-1?t:t.slice(0,e)}var ut="replaykit:page";function er(t,e,r){var s,a;let i=[],n=e;for(let l of t){let o;if(l.type===4)o=(s=l.data)==null?void 0:s.href;else if(l.type===5){let h=l.data;(h==null?void 0:h.tag)===ut&&(o=(a=h.payload)==null?void 0:a.href)}if(typeof o!="string"||!o)continue;let c=o.search(/[?#]/),d=(c===-1?o:o.slice(0,c)).slice(0,500);if(d!==n&&(n=d,i.push({url:d,ts:l.timestamp}),i.length>=r))break}return i}var ct=3e4,_e=3e4;function hi(t,e){return e>0&&t[e-1].type===4?e-1:e}function dt(t,e,r=ct){let i=e-r,n=-1,s=-1;for(let l=0;l<t.length;l++)if(t[l].type===2)if(s===-1&&(s=l),t[l].timestamp<=i)n=l;else break;if(n===-1&&(n=s),n===-1)return[];let a=hi(t,n);return a===0?t:t.slice(a)}function ht(t){try{return JSON.stringify(t).length}catch(e){return 0}}var Ae=class{constructor(){this.burst=null}onClick(e){let r=this.burst;if(r&&e.ts-r.lastTs<=1e3&&fi(r.first,e))return r.count++,r.lastTs=e.ts,{trigger:r.count===3,finished:null};let i=r&&r.count>=3?r:null;return this.burst={first:e,count:1,lastTs:e.ts},{trigger:!1,finished:i}}flush(e){let r=this.burst;return!r||e-r.lastTs<=1e3?null:(this.burst=null,r.count>=3?r:null)}currentCount(){var e,r;return(r=(e=this.burst)==null?void 0:e.count)!=null?r:0}};function fi(t,e){return t.target&&t.target===e.target?!0:Math.abs(t.x-e.x)<=30&&Math.abs(t.y-e.y)<=30}var tr=500;function rr(t){return t.isFormField||t.hasSelection||t.tag==="html"||t.tag==="body"?!1:t.insideInteractive||t.pointerCursor}function ir(t){return t.mutations===0&&!t.urlChanged&&!t.scrolled&&!t.focusChanged&&!t.unloading}var pi=5e3;function ft(t,e){if(!t)return 0;let r=e-t;return r>0&&r<=pi?r:0}var mi=["error","rage_click","manual"];function pt(t,e,r){return r<=0||mi.includes(t)?0:Math.max(0,r-e)}function nr(t){return!t.record||!t.canGzip||t.state.stopped||t.excluded||t.consent===!1?{kind:"off"}:t.requireConsent&&t.consent!==!0?{kind:"wait_consent"}:t.state.rid?{kind:"continue"}:t.forceTrigger?{kind:"start",trigger:t.forceTrigger}:t.checkout?{kind:"start",trigger:"checkout"}:t.sampled?{kind:"start",trigger:"sample"}:{kind:"buffer"}}function gi(t){return t>=200&&t<300?"ok":t===401?"stop":t===403?"off":t===429?"quota":t===400||t===413||t===404||t===422?"drop":"retry"}var Le=class{constructor(e,r,i){this.env=e;this.apiUrl=r;this.apiKey=i}url(e){return`${this.apiUrl}/api/t/r/${e}?apiKey=${encodeURIComponent(this.apiKey)}`}init(e){return this.post("init",e,!0)}chunk(e){return this.post("chunk",e,!0)}signals(e){return this.post("signals",e,!1)}beaconSignals(e){var r,i;return!!((i=(r=this.env).sendBeacon)!=null&&i.call(r,this.url("signals"),JSON.stringify(e)))}async put(e,r){if(!this.env.fetch)return"retry";try{let i=await this.env.fetch(e,{method:"PUT",body:r,headers:{"Content-Type":"application/gzip"}});return i.status>=200&&i.status<300?"ok":i.status===400||i.status===413?"drop":"retry"}catch(i){return"retry"}}async post(e,r,i){if(!this.env.fetch)return{outcome:"retry"};try{let n=await this.env.fetch(this.url(e),{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"text/plain"},keepalive:!1,credentials:"omit"}),s=gi(n.status);if(s!=="ok"||!i)return{outcome:s};try{return{outcome:s,data:await n.json()}}catch(a){return{outcome:"retry"}}}catch(n){return{outcome:"retry"}}}},yi=2e3,bi=6e4;function ce(t){return Math.min(bi,yi*2**Math.max(0,t-1))}var vi=5e3,Si=200,Ci=500,wi=2e3,De=class{constructor(e,r,i){this.env=e;this.api=r;this.ids=i;this.queue=[];this.timer=null;this.sentThisPage=0;this.failures=0;this.busy=!1;this.last=new Map;this.disabled=!1;this.held=!0}add(e){if(this.disabled||this.sentThisPage+this.queue.length>=Si)return;let r=`${e.type}|${e.url}|${e.selector||""}|${e.detail||""}`,i=this.last.get(r);i!==void 0&&e.ts-i<wi||(this.last.set(r,e.ts),this.queue.push(e),this.queue.length>Ci&&this.queue.shift(),!this.held&&(this.queue.length>=50?this.schedule(0):this.timer||this.schedule(vi)))}release(e){if(this.held=!1,!e){this.disable();return}this.queue.length&&this.schedule(0)}disable(){this.disabled=!0,this.queue=[],this.timer&&this.env.clearTimer(this.timer),this.timer=null}schedule(e){this.timer&&this.env.clearTimer(this.timer),this.timer=this.env.setTimer(()=>{this.timer=null,this.flush()},e)}async flush(){if(!(this.busy||this.held||this.disabled)){this.busy=!0;try{for(;this.queue.length&&!this.disabled;){let e=this.queue.slice(0,50),r=await this.api.signals(W(k({},this.ids()),{signals:e}));if(r.outcome==="ok"||r.outcome==="drop"||r.outcome==="quota"){this.queue.splice(0,e.length),this.sentThisPage+=e.length,this.failures=0;continue}if(r.outcome==="off"||r.outcome==="stop"){this.disable();return}this.failures++,this.schedule(ce(this.failures));return}}finally{this.busy=!1}}}beacon(){if(!(this.held||this.disabled||!this.queue.length))for(;this.queue.length;){let e=this.queue.slice(0,50);if(!this.api.beaconSignals(W(k({},this.ids()),{signals:e})))return;this.queue.splice(0,e.length),this.sentThisPage+=e.length}}get size(){return this.queue.length}};var lr='a[href],button,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[role="option"],[onclick]',ur="input,textarea,select,label,option,[contenteditable],[contenteditable=true]",ki=".hm-mask,[data-hm-mask],[data-hm-block],.hm-block",or=80,Mi=200;function Pe(t){let e=[],r=t;for(let i=0;r&&i<3&&r.nodeType===1;i++){let n=r.tagName.toLowerCase();if(n==="html"||n==="body")break;if(r.id&&/^[A-Za-z][\w-]{0,40}$/.test(r.id)&&!/\d{3,}/.test(r.id)){e.unshift(`${n}#${r.id}`);break}let s=(typeof r.className=="string"?r.className:"").split(/\s+/).filter(a=>a&&a.length<30&&!/\d{3,}|^css-|^sc-|__/.test(a)).slice(0,2);e.unshift(n+s.map(a=>"."+a).join("")),r=r.parentElement}return e.join(" > ")}function ar(t,e){var i,n,s;if(e||t.closest(ki)||t.closest(ur))return;let r=((n=(i=t.innerText)!=null?i:t.textContent)!=null?n:"").replace(/\s+/g," ").trim();return r?r.slice(0,or):(s=t.getAttribute("aria-label")||t.getAttribute("title")||void 0)==null?void 0:s.slice(0,or)}function Ii(t){let e=!1;try{e=getComputedStyle(t).cursor==="pointer"}catch(i){e=!1}let r=typeof getSelection=="function"?getSelection():null;return{tag:t.tagName.toLowerCase(),insideInteractive:!!t.closest(lr),isFormField:!!t.closest(ur),pointerCursor:e,hasSelection:!!r&&!r.isCollapsed&&r.toString().trim().length>0}}function Ei(t){let e=t instanceof Element?t:t instanceof Node?t.parentElement:null;return e?e.closest(lr)||e:null}var Fe=class{constructor(e){this.h=e;this.rage=new Ae;this.rageEl=null;this.rageTimer=null;this.lastHref="";this.hrefTimer=null;this.unloading=!1;this.lastScrollInput=0;this.forms=new Map;this.errorsSeen=new Set;this.off=[]}start(){this.lastHref=location.href;let e=(r,i,n=window)=>{let s={capture:!0,passive:!0};n.addEventListener(r,i,s),this.off.push(()=>n.removeEventListener(r,i,s))};e("click",r=>this.onClick(r)),e("keydown",()=>this.h.input("key",this.h.now())),e("scroll",()=>{let r=this.h.now();r-this.lastScrollInput>250&&(this.lastScrollInput=r,this.h.input("scroll",r))}),e("error",r=>{var i;return this.onError(r.message||((i=r.error)==null?void 0:i.message)||"")}),e("unhandledrejection",r=>{let i=r.reason;this.onError(typeof i=="string"?i:(i==null?void 0:i.message)||"Unhandled promise rejection")}),e("popstate",()=>this.backNav()),e("input",r=>this.onField(r.target)),e("change",r=>this.onField(r.target)),e("submit",r=>{r.target instanceof HTMLFormElement&&this.forms.delete(r.target)}),e("pageshow",()=>{this.unloading=!1}),this.hrefTimer=setInterval(()=>this.checkHref(),1e3);try{let r=performance.getEntriesByType("navigation")[0];(r==null?void 0:r.type)==="back_forward"&&this.emit({type:"back_nav",detail:J(location.href)})}catch(r){}}stop(){for(let e of this.off)e();this.off=[],this.hrefTimer&&clearInterval(this.hrefTimer),this.rageTimer&&clearTimeout(this.rageTimer),this.hrefTimer=this.rageTimer=null}pageHide(){this.unloading=!0,this.flushForms(),this.flushRage(!0)}emit(e){var r;this.h.signal(k({ts:(r=e.ts)!=null?r:this.h.now(),url:J(location.href)},e))}checkHref(){let e=location.href;if(e===this.lastHref)return;let r=this.lastHref;this.lastHref=e,J(e)!==J(r)&&this.h.navigated(J(e))}onClick(e){let r=this.h.now();this.h.input("click",r);let i=Ei(e.target);if(!i)return;let n=Pe(i),s=this.rage.onClick({x:e.clientX,y:e.clientY,ts:r,target:n});s.finished&&this.reportRage(s.finished.count,s.finished.first.ts),s.trigger&&this.h.trigger("rage_click"),this.rageEl=this.rage.currentCount()===1?i:this.rageEl,this.rageTimer&&clearTimeout(this.rageTimer),this.rageTimer=setTimeout(()=>this.flushRage(!1),1050),this.rage.currentCount()===1&&this.watchDeadClick(i,n,r)}flushRage(e){let r=this.rage.flush(e?Number.MAX_SAFE_INTEGER:this.h.now());r&&this.reportRage(r.count,r.first.ts)}reportRage(e,r){let i=this.rageEl;this.emit({type:"rage_click",ts:r,count:e,selector:i?Pe(i):void 0,text:i?ar(i,this.h.maskAllText()):void 0})}watchDeadClick(e,r,i){if(!rr(Ii(e)))return;let n=location.href,s=`${scrollX},${scrollY}`,a=document.activeElement,l=0,o=null;try{o=new MutationObserver(c=>{l+=c.length}),o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0})}catch(c){return}setTimeout(()=>{if(o==null||o.disconnect(),this.rage.currentCount()>1)return;ir({mutations:l,urlChanged:location.href!==n,scrolled:`${scrollX},${scrollY}`!==s,focusChanged:document.activeElement!==a&&document.activeElement!==e,unloading:this.unloading})&&this.emit({type:"dead_click",ts:i,selector:r,text:ar(e,this.h.maskAllText())})},tr)}onError(e){let r=(e||"Error").slice(0,Mi);this.errorsSeen.has(r)||(this.errorsSeen.add(r),this.emit({type:"error",detail:r}),this.h.trigger("error"))}backNav(){this.emit({type:"back_nav",detail:J(location.href)}),this.checkHref()}onField(e){if(!(e instanceof Element))return;let r=e.closest("form");if(!r)return;let i=e.getAttribute("name")||e.id||Pe(e),n=this.forms.get(r);n||this.forms.set(r,n=new Set),n.add(i)}flushForms(){for(let[e,r]of this.forms)!e.isConnected&&r.size===0||this.emit({type:"form_abandon",selector:Pe(e),count:r.size});this.forms.clear()}};var Qn=["[data-hm-block]",".hm-block",'[autocomplete^="cc-"]','input[type="password"]'],es=".hm-mask,[data-hm-mask]",At=null;function ts(){return At!=null?At:At=Promise.resolve().then(()=>(ei(),Qr)).then(t=>t.record)}function rs(t){return t.filter(e=>{if(!e||typeof e!="string")return!1;try{return document.createDocumentFragment().querySelector(e),!0}catch(r){return!1}})}var et=class{constructor(){this.record=null;this.stopped=!1}async start(e){var r;try{this.record=await ts()}catch(i){return!1}if(this.stopped)return!1;try{return this.stopFn=(r=this.record({emit:i=>e.emit(i),checkoutEveryNms:_e,maskAllInputs:!0,maskInputOptions:{password:!0},maskTextSelector:e.maskAllText?"*":es,blockSelector:rs([...Qn,...e.blockSelectors]).join(","),recordCanvas:!1,recordCrossOriginIframes:!1,inlineImages:!1,collectFonts:!1,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:!0},sampling:{mousemove:50,scroll:150,input:"last"}}))!=null?r:void 0,!!this.stopFn}catch(i){return!1}}snapshot(){var e;try{(e=this.record)==null||e.takeFullSnapshot(!0)}catch(r){}}page(e){var r;try{(r=this.record)==null||r.addCustomEvent(ut,{href:e})}catch(i){}}stop(){var e;this.stopped=!0;try{(e=this.stopFn)==null||e.call(this)}catch(r){}this.stopFn=void 0}};var is=3e4,ns=256*1024,tt=t=>`rk:pending:${t}`,rt=class{constructor(e,r,i,n,s){this.env=e;this.api=r;this.states=i;this.ids=n;this.hooks=s;this.queue=[];this.inflight=[];this.queuedBytes=0;this.timer=null;this.retryTimer=null;this.failures=0;this.busy=!1;this.stopped=!1;this.epoch=0;this.parked=!1;this.lastPage="";this.lastPageRid=""}state(){return this.states.load(this.ids.sid)}async restorePending(){let e=this.env.store;if(!e)return;let r=await e.get(tt(this.ids.sid));if(!r)return;await e.del(tt(this.ids.sid));let i=this.state();!i.rid||r.rid!==i.rid||!Array.isArray(r.events)||r.events.length===0||(this.queue=r.events.concat(this.queue),this.queuedBytes+=r.events.reduce((n,s)=>n+ht(s),0),this.schedule(0))}add(e){this.stopped||(this.queue.push(e),this.queuedBytes+=ht(e),this.queuedBytes>=ns?this.schedule(0):this.timer||this.schedule(is))}addMany(e){for(let r of e)this.add(r)}schedule(e){this.timer&&this.env.clearTimer(this.timer),this.timer=this.env.setTimer(()=>{this.timer=null,this.flush()},e)}async flush(){if(this.busy||this.stopped)return;let e=this.epoch;this.busy=!0;try{for(;!this.stopped&&e===this.epoch&&(this.inflight.length>0||this.queue.length>0);)if(this.inflight.length===0&&(this.inflight=this.queue,this.queue=[],this.queuedBytes=0),!await this.sendInflight())return}finally{this.busy=!1}}async sendInflight(){var d,h,p;(h=(d=this.hooks).beforeChunk)==null||h.call(d);let e=this.state();if(!e.rid||!e.trigger||!e.stats)return!1;if(e.seq>=600)return this.stop("limit"),!1;let r=this.env.gzip;if(!r)return this.stop("off"),!1;let i={v:1,rid:e.rid,seq:e.seq,events:this.inflight},n=await r(JSON.stringify(i));if(n.size>2097152){if(this.inflight.length>1){let f=Math.ceil(this.inflight.length/2);return this.queue=this.inflight.slice(f).concat(this.queue),this.inflight=this.inflight.slice(0,f),!0}return this.stop("limit"),!1}let s=this.lastPageRid===e.rid?this.lastPage:"",a=er(this.inflight,s,50),l=await this.api.chunk({rid:e.rid,sid:this.ids.sid,vid:this.ids.vid,seq:e.seq,bytes:n.size,trigger:e.trigger,stats:e.stats,pages:a});if(l.outcome==="drop")return this.inflight=[],!0;if(l.outcome==="quota")return this.stop("quota"),!1;if(l.outcome==="off"||l.outcome==="stop")return this.stop("off"),!1;if(l.outcome!=="ok"||!((p=l.data)!=null&&p.url))return this.retryLater(),!1;let o=await this.api.put(l.data.url,n);if(o==="drop")return this.inflight=[],!0;if(o!=="ok")return this.retryLater(),!1;this.failures=0,this.inflight=[],a.length&&(this.lastPage=a[a.length-1].url,this.lastPageRid=e.rid);let c=this.state();return c.rid===e.rid&&this.states.save(W(k({},c),{seq:e.seq+1})),this.parked&&(this.queue.length?this.persist():this.unpersist()),!0}retryLater(){this.failures++,this.retryTimer&&this.env.clearTimer(this.retryTimer),this.retryTimer=this.env.setTimer(()=>{this.retryTimer=null,this.flush()},ce(this.failures))}stop(e){this.stopped=!0,this.queue=[],this.inflight=[],this.queuedBytes=0,this.clearTimers(),this.hooks.onStop(e)}clearTimers(){this.timer&&this.env.clearTimer(this.timer),this.retryTimer&&this.env.clearTimer(this.retryTimer),this.timer=this.retryTimer=null}persist(){let e=this.env.store,r=this.state(),i=this.inflight.concat(this.queue);!e||!r.rid||i.length===0||this.stopped||(this.parked=!0,e.set(tt(this.ids.sid),{rid:r.rid,events:i}))}unpersist(){var e;this.parked&&(this.parked=!1,(e=this.env.store)==null||e.del(tt(this.ids.sid)))}discard(){this.epoch++,this.stopped=!0,this.queue=[],this.inflight=[],this.queuedBytes=0,this.clearTimers(),this.unpersist()}get pendingEvents(){return this.queue.length+this.inflight.length}};var ti="hm_rk_consent",Lt=t=>`rk:buf:${t}`,os=500,as=15e3,ls=3,it=class{constructor(e,r=Jt()){this.options=e;this.ids=null;this.queue=null;this.collector=null;this.recorder=null;this.uploader=null;this.init=null;this.config=null;this.mode="idle";this.buffer=[];this.recent=[];this.stats=null;this.lastInputTs=0;this.earlyTrigger=null;this.pending=null;this.pendingGen=0;this.baseVisibleMs=0;this.pageVisibleMs=0;this.visibleSince=null;this.destroyed=!1;this.offWindow=[];this.env=r;let i=(e.apiUrl||"https://app.himetrica.com").replace(/\/+$/,"");this.api=new Le(r,i,e.apiKey),this.states=new Oe(r)}log(...e){this.options.debug&&console.debug("[ReplayKit]",...e)}start(){if(!Yt||!this.options.apiKey)return;let e=location.hostname;if(!this.options.allowLocalhost&&(e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".localhost"))){this.log("localhost: idle (allowLocalhost to enable)");return}this.trackVisibility();let r=this.env.now(),i=()=>{if(this.destroyed)return;let n=Zt(this.env);n.sessionId&&n.visitorId?(this.ids={sid:n.sessionId,vid:n.visitorId},this.boot()):this.env.now()-r<as?this.env.setTimer(i,os):this.log("no tracker ids on this page: idle")};i()}boot(){var r;let e=this.ids;this.baseVisibleMs=(r=this.states.load(e.sid).visibleMs)!=null?r:0,this.queue=new De(this.env,this.api,()=>W(k({},e),{rid:this.mode==="live"?this.state().rid:void 0})),this.collector=new Fe({now:()=>this.env.now(),maskAllText:()=>{var i,n;return(n=(i=this.config)==null?void 0:i.maskAllText)!=null?n:!0},signal:i=>this.onSignal(i),trigger:i=>this.trigger(i),input:(i,n)=>this.onInput(i,n),navigated:i=>this.onNavigate(i)}),this.collector.start(),this.listenPage(),this.callInit(1)}state(){return this.states.load(this.ids.sid)}async callInit(e){var n;let r=this.ids,i=await this.api.init({sid:r.sid,vid:r.vid,url:J(location.href)});if(!this.destroyed){if(i.outcome==="ok"&&i.data)return this.applyInit(i.data);if(i.outcome==="retry"&&e<ls){this.env.setTimer(()=>{this.callInit(e+1)},ce(e));return}if(this.log("init refused:",i.outcome),i.outcome==="quota"){(n=this.queue)==null||n.release(!0),this.mode="off";return}this.shutdown()}}applyInit(e){if(this.init=e,this.config=e.config,this.queue.release(e.signals),!e.signals&&!e.record){this.shutdown();return}this.decide()}consentValue(){let e=this.env.getLocal(ti);return e==="1"?!0:e==="0"?!1:null}triggerEnabled(e){var r;return e==="manual"||e==="sample"?!0:!!((r=this.config)!=null&&r.triggers.includes(e))}pathExcluded(){var e,r;return lt((r=(e=this.config)==null?void 0:e.excludePaths)!=null?r:[],location.pathname)}onCheckoutPath(){var e,r;return this.triggerEnabled("checkout")&<((r=(e=this.config)==null?void 0:e.checkoutPaths)!=null?r:[],location.pathname)}decide(){var i;if(!this.init||!this.config)return;let e=this.state(),r=nr({record:this.init.record,canGzip:!!this.env.gzip,state:e,excluded:this.pathExcluded(),requireConsent:this.config.requireConsent,consent:this.consentValue(),forceTrigger:this.init.forceTrigger,sampled:Qt(this.ids.sid,this.config.sampleRate),checkout:this.onCheckoutPath()});if(this.log("page:",r.kind,r.kind==="start"?r.trigger:""),r.kind==="off"||r.kind==="wait_consent"){this.mode=r.kind;return}if(r.kind==="continue"){this.mode="live";let n=(i=e.stats)!=null?i:at(this.env.now(),J(location.href));this.stats=W(k({},n),{pages:n.pages+1}),this.makeUploader(),this.uploader.restorePending(),this.startRecorder();return}this.mode="buffer",this.restoreParkedBuffer().then(async()=>{if(this.mode!=="buffer"||(await this.startRecorder(),this.mode!=="buffer"))return;let n=r.kind==="start"?r.trigger:this.earlyTrigger;this.earlyTrigger=null,n&&this.triggerEnabled(n)&&this.requestPromote(n)})}async restoreParkedBuffer(){let e=this.env.store;if(!e)return;let r=Lt(this.ids.sid),i=await e.get(r);if(!i)return;e.del(r),this.env.now()-i.at<ct+_e&&Array.isArray(i.events)&&i.events.length&&(this.buffer=i.events.concat(this.buffer))}async startRecorder(){var i,n,s,a;if(this.recorder)return;let e=this.recorder=new et;!await e.start({blockSelectors:(n=(i=this.config)==null?void 0:i.blockSelectors)!=null?n:[],maskAllText:(a=(s=this.config)==null?void 0:s.maskAllText)!=null?a:!1,emit:l=>this.onEvent(l)})&&this.recorder===e&&(this.log("rrweb failed to start"),this.recorder=null,this.mode="off")}onEvent(e){if(this.mode==="buffer"){this.buffer.push(e),e.type===2&&(this.buffer=dt(this.buffer,this.env.now()));return}this.mode==="live"&&this.uploader&&(this.stats&&(this.stats.endedAt=Math.max(this.stats.endedAt,e.timestamp)),this.uploader.add(e))}makeUploader(){this.uploader=new rt(this.env,this.api,this.states,this.ids,{onStop:e=>this.stopRecording(e),beforeChunk:()=>this.saveStats()})}saveStats(){if(!this.stats||this.mode!=="live")return;let e=this.state();e.rid&&this.states.save(W(k({},e),{stats:this.stats}))}trigger(e){var r;if(!(this.destroyed||!this.ids)){if(!this.init){this.earlyTrigger||(this.earlyTrigger=e);return}if(!(this.mode!=="buffer"||!this.triggerEnabled(e))){if(!this.recorder){(r=this.earlyTrigger)!=null||(this.earlyTrigger=e);return}this.requestPromote(e)}}}trackVisibility(){document.visibilityState==="visible"&&(this.visibleSince=this.env.now());let e=()=>{let r=this.env.now();document.visibilityState==="hidden"?(this.visibleSince!==null&&(this.pageVisibleMs+=r-this.visibleSince),this.visibleSince=null):this.visibleSince===null&&(this.visibleSince=r,this.pending&&this.schedulePending())};document.addEventListener("visibilitychange",e),this.offWindow.push(()=>document.removeEventListener("visibilitychange",e))}visibleMs(){let e=this.visibleSince!==null?this.env.now()-this.visibleSince:0;return this.baseVisibleMs+this.pageVisibleMs+e}requestPromote(e){var i,n,s;let r=pt(e,this.visibleMs(),(n=(i=this.config)==null?void 0:i.minDurationMs)!=null?n:0);if(r===0){this.pending=null,this.promote(e);return}(s=this.pending)!=null||(this.pending=e),this.log("waiting for the minimum duration:",e,r,"ms"),this.schedulePending()}schedulePending(){var n,s;let e=this.pending;if(!e)return;let r=++this.pendingGen,i=pt(e,this.visibleMs(),(s=(n=this.config)==null?void 0:n.minDurationMs)!=null?s:0);this.env.setTimer(()=>{r!==this.pendingGen||this.pending!==e||this.mode!=="buffer"||this.destroyed||this.visibleSince!==null&&this.requestPromote(e)},Math.max(i,50))}promote(e){var l;let r=this.env.now(),i=this.buffer;this.buffer=[];let n=i.length?i[0].timestamp:r,s=at(n,J(location.href));s.endedAt=Math.max(i.length?i[i.length-1].timestamp:r,r),this.pending=null;let a=0;for(let o of this.recent)o.ts<n||(o.k==="click"?s.clicks++:o.k==="rage"?s.rageClicks++:o.k==="dead"?s.deadClicks++:o.k==="error"&&s.errors++,(o.k==="click"||o.k==="input")&&(s.activeMs+=ft(a,o.ts),a=o.ts));this.recent=[],this.stats=s,this.states.save(W(k({},this.state()),{rid:this.env.uuid(),seq:0,trigger:e,stats:s,stopped:void 0})),this.mode="live",this.log("recording:",e),this.makeUploader(),this.uploader.addMany(i),i.length||(l=this.recorder)==null||l.snapshot(),this.uploader.flush()}stopRecording(e){var i;this.log("recording stopped:",e),(i=this.recorder)==null||i.stop(),this.recorder=null,this.mode="off",this.buffer=[];let r=this.state();this.states.save(W(k({},r),{stopped:e}))}onSignal(e){var r;if(this.mode==="live"&&this.stats)e.type==="rage_click"?this.stats.rageClicks++:e.type==="dead_click"?this.stats.deadClicks++:e.type==="error"&&this.stats.errors++;else if(this.mode==="buffer"||this.mode==="idle"){let i=e.type==="rage_click"?"rage":e.type==="dead_click"?"dead":e.type==="error"?"error":null;i&&this.pushRecent(i,e.ts)}(r=this.queue)==null||r.add(e)}onInput(e,r){this.mode==="live"&&this.stats?(this.stats.activeMs+=ft(this.lastInputTs,r),e==="click"&&this.stats.clicks++):(this.mode==="buffer"||this.mode==="idle")&&this.pushRecent(e==="click"?"click":"input",r),this.lastInputTs=r}pushRecent(e,r){this.recent.push({k:e,ts:r}),this.recent.length>1e3&&this.recent.splice(0,this.recent.length-1e3)}onNavigate(e){var i,n,s;if(!this.init||!this.config)return;this.mode==="live"&&this.stats&&this.stats.pages++;let r=this.pathExcluded();if(r&&(this.mode==="live"||this.mode==="buffer")){(i=this.recorder)==null||i.stop(),this.recorder=null,this.mode==="buffer"&&(this.buffer=[]),(n=this.uploader)==null||n.flush(),this.mode="off";return}if(!r&&this.mode==="off"&&!this.state().stopped){this.uploader=null,this.decide();return}(s=this.recorder)==null||s.page(e),this.onCheckoutPath()&&this.trigger("checkout")}listenPage(){let e=n=>{var s,a,l;if(n&&((s=this.collector)==null||s.pageHide()),this.states.save(W(k({},this.state()),{visibleMs:this.visibleMs()})),(a=this.queue)==null||a.beacon(),this.mode==="live")this.saveStats(),(l=this.uploader)==null||l.persist();else if(this.mode==="buffer"&&this.buffer.length&&this.env.store){let o=dt(this.buffer,this.env.now());this.env.store.set(Lt(this.ids.sid),{at:this.env.now(),events:o})}},r=()=>{var n;document.visibilityState==="hidden"?e(!1):(n=this.uploader)==null||n.unpersist()},i=()=>e(!0);document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",i),this.offWindow.push(()=>document.removeEventListener("visibilitychange",r),()=>window.removeEventListener("pagehide",i))}manualStart(e){if(this.ids){if(e&&this.log("manual trigger:",e),this.state().stopped==="manual"){this.states.save(W(k({},this.state()),{stopped:void 0,rid:void 0,seq:0,trigger:void 0,stats:void 0})),this.uploader=null,this.earlyTrigger="manual",this.decide();return}this.trigger("manual")}}manualStop(){var e,r;this.ids&&((e=this.recorder)==null||e.stop(),this.recorder=null,this.buffer=[],this.mode==="live"&&(this.saveStats(),(r=this.uploader)==null||r.flush()),this.mode="off",this.states.save(W(k({},this.state()),{stopped:"manual"})))}consent(e){var r,i,n;if(this.env.setLocal(ti,e?"1":"0"),!!this.ids){if(e){this.mode==="wait_consent"&&this.decide();return}(r=this.recorder)==null||r.stop(),this.recorder=null,this.buffer=[],(i=this.uploader)==null||i.discard(),(n=this.env.store)==null||n.del(Lt(this.ids.sid)),this.mode="off"}}recordingId(){var e;return this.mode==="live"&&this.ids&&(e=this.state().rid)!=null?e:null}shutdown(){var e,r,i;(e=this.collector)==null||e.stop(),(r=this.queue)==null||r.disable(),(i=this.recorder)==null||i.stop(),this.recorder=null,this.mode="off"}destroy(){this.destroyed=!0,this.shutdown();for(let e of this.offWindow)e();this.offWindow=[]}};var P=null;function Dt(t){P||(P=new it(t),P.start())}function us(){P==null||P.manualStart()}function cs(t){P==null||P.manualStart(t)}function ds(){P==null||P.manualStop()}function hs(t){if(P)P.consent(t);else try{localStorage.setItem("hm_rk_consent",t?"1":"0")}catch(e){}}function fs(){var t;return(t=P==null?void 0:P.recordingId())!=null?t:null}function ps(){P==null||P.destroy(),P=null}if(typeof window!="undefined"){window.ReplayKit=Pt;let t=document.currentScript,e=t==null?void 0:t.dataset;e!=null&&e.apiKey&&Dt({apiKey:e.apiKey,apiUrl:e.apiUrl||void 0,allowLocalhost:e.allowLocalhost==="true",debug:e.debug==="true"})}})();
|
|
79
|
+
//# sourceMappingURL=replaykit.global.js.map
|