@mime8/recorder 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atif Afzal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,37 @@
1
- # Temporary Holding Version
1
+ # @mime8/recorder
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Records real user sessions in your web app and sends them to mime8. mime8 replays them against your pull request's build and reports what the change did: screenshots, and the requests your app sends to its own backend.
4
+
5
+ ## Add it to your app
6
+
7
+ Load it before any of your app's code, as early in `<head>` as you can, so it sees the first requests:
8
+
9
+ ```html
10
+ <script src="https://cdn.jsdelivr.net/npm/@mime8/recorder@0.1.1/dist/recorder.iife.js"></script>
11
+ <script>
12
+ mime8.init({ projectKey: "pk_…" });
13
+ </script>
14
+ ```
15
+
16
+ Or install it and call `init` first thing in your entry file:
17
+
18
+ ```sh
19
+ npm install @mime8/recorder
20
+ ```
21
+
22
+ ```js
23
+ import { init } from "@mime8/recorder";
24
+
25
+ init({ projectKey: "pk_…" });
26
+ ```
27
+
28
+ ## Options
29
+
30
+ - `projectKey` (required): your project's public key.
31
+ - `collectorUrl`: where sessions are sent. Defaults to mime8's collector.
32
+ - `network.ignoreUrls`: requests and connections to these URLs are never recorded.
33
+ - `network.maxBodySize`: request and response bodies over this many bytes are recorded as omitted (1 MB by default).
34
+ - `network.redact`: more `headers`, `queryParams` and `bodyFields` to redact, added to the defaults (names containing words such as `authorization`, `cookie`, `token`, `secret`, `password`).
35
+ - `network.beforeRecord`: a function that sees each recorded request last; return it, a changed copy, or `null` to drop it.
36
+
37
+ A string matches a name exactly (ignoring case), or a URL as a prefix; a RegExp is tested; a function decides.
@@ -0,0 +1,25 @@
1
+ @mime8/recorder bundles the following third-party software.
2
+
3
+ rrweb (@rrweb/record 2.1.1), https://github.com/rrweb-io/rrweb
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors)
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
@@ -0,0 +1,78 @@
1
+ var mime8=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,r=(e,t,r)=>n(e,typeof t==`symbol`?t:t+``,r),i=(e=>(e[e.DomContentLoaded=0]=`DomContentLoaded`,e[e.Load=1]=`Load`,e[e.FullSnapshot=2]=`FullSnapshot`,e[e.IncrementalSnapshot=3]=`IncrementalSnapshot`,e[e.Meta=4]=`Meta`,e[e.Custom=5]=`Custom`,e[e.Plugin=6]=`Plugin`,e[e.Asset=7]=`Asset`,e))(i||{}),a=(e=>(e[e.Mutation=0]=`Mutation`,e[e.MouseMove=1]=`MouseMove`,e[e.MouseInteraction=2]=`MouseInteraction`,e[e.Scroll=3]=`Scroll`,e[e.ViewportResize=4]=`ViewportResize`,e[e.Input=5]=`Input`,e[e.TouchMove=6]=`TouchMove`,e[e.MediaInteraction=7]=`MediaInteraction`,e[e.StyleSheetRule=8]=`StyleSheetRule`,e[e.CanvasMutation=9]=`CanvasMutation`,e[e.Font=10]=`Font`,e[e.Log=11]=`Log`,e[e.Drag=12]=`Drag`,e[e.StyleDeclaration=13]=`StyleDeclaration`,e[e.Selection=14]=`Selection`,e[e.AdoptedStyleSheet=15]=`AdoptedStyleSheet`,e[e.CustomElement=16]=`CustomElement`,e))(a||{}),o=(e=>(e[e.MouseUp=0]=`MouseUp`,e[e.MouseDown=1]=`MouseDown`,e[e.Click=2]=`Click`,e[e.ContextMenu=3]=`ContextMenu`,e[e.DblClick=4]=`DblClick`,e[e.Focus=5]=`Focus`,e[e.Blur=6]=`Blur`,e[e.TouchStart=7]=`TouchStart`,e[e.TouchMove_Departed=8]=`TouchMove_Departed`,e[e.TouchEnd=9]=`TouchEnd`,e[e.TouchCancel=10]=`TouchCancel`,e))(o||{}),s=(e=>(e[e.Mouse=0]=`Mouse`,e[e.Pen=1]=`Pen`,e[e.Touch=2]=`Touch`,e))(s||{}),c=(e=>(e[e[`2D`]=0]=`2D`,e[e.WebGL=1]=`WebGL`,e[e.WebGL2=2]=`WebGL2`,e))(c||{}),l=(e=>(e[e.Play=0]=`Play`,e[e.Pause=1]=`Pause`,e[e.Seeked=2]=`Seeked`,e[e.VolumeChange=3]=`VolumeChange`,e[e.RateChange=4]=`RateChange`,e))(l||{}),u=(e=>(e[e.Document=0]=`Document`,e[e.DocumentType=1]=`DocumentType`,e[e.Element=2]=`Element`,e[e.Text=3]=`Text`,e[e.CDATA=4]=`CDATA`,e[e.Comment=5]=`Comment`,e))(u||{}),d={Node:[`childNodes`,`parentNode`,`parentElement`,`textContent`,`ownerDocument`],ShadowRoot:[`host`,`styleSheets`],Element:[`shadowRoot`,`querySelector`,`querySelectorAll`],MutationObserver:[]},f={Node:[`contains`,`getRootNode`],ShadowRoot:[`getSelection`],Element:[],MutationObserver:[`constructor`]},p={},m={},h=()=>!!globalThis.Zone;function g(e){if(p[e])return p[e];let t=globalThis[e],n=t.prototype,r=e in d?d[e]:void 0,i=!!(r&&r.every(e=>!!(Object.getOwnPropertyDescriptor(n,e)?.get)?.toString().includes(`[native code]`))),a=e in f?f[e]:void 0,o=!!(a&&a.every(e=>typeof n[e]==`function`&&n[e]?.toString().includes(`[native code]`)));if(i&&o&&!h())return p[e]=t.prototype,t.prototype;try{let r=document.createElement(`iframe`);r.style.display=`none`,document.body.appendChild(r);let i=r.contentWindow;if(!i)return t.prototype;let a=i[e].prototype;if(!a)return r.remove(),n;let o=navigator.userAgent;return o.includes(`Safari`)&&!o.includes(`Chrome`)?(r.classList.add(`rr-block`),r.setAttribute(`__rrwebUntaintedMutationObserver`,``),m[e]=()=>r.remove()):r.remove(),p[e]=a}catch{return n}}var _={};function v(e,t,n){let r=`${e}.${String(n)}`;if(_[r])return _[r].call(t);let i=g(e),a=Object.getOwnPropertyDescriptor(i,n)?.get;return a?(_[r]=a,a.call(t)):t[n]}var y={};function b(e,t,n){let r=`${e}.${String(n)}`;if(y[r])return y[r].bind(t);let i=g(e)[n];return typeof i==`function`?(y[r]=i,i.bind(t)):t[n]}function x(e){return v(`Node`,e,`ownerDocument`)}function S(e){return v(`Node`,e,`childNodes`)}function C(e){return v(`Node`,e,`parentNode`)}function w(e){return v(`Node`,e,`parentElement`)}function ee(e){return v(`Node`,e,`textContent`)}function T(e,t){return b(`Node`,e,`contains`)(t)}function E(e){return b(`Node`,e,`getRootNode`)()}function D(e){return!e||!(`host`in e)?null:v(`ShadowRoot`,e,`host`)}function O(e){return e.styleSheets}function k(e){return!e||!(`shadowRoot`in e)?null:v(`Element`,e,`shadowRoot`)}function A(e,t){return v(`Element`,e,`querySelector`)(t)}function te(e,t){return v(`Element`,e,`querySelectorAll`)(t)}function ne(){return[g(`MutationObserver`).constructor,m.MutationObserver??(()=>{})]}var re=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(re=()=>new Date().getTime());function j(e,t,n){try{if(!(t in e))return()=>{};let r=e[t],i=n(r);return typeof i==`function`&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var M={ownerDocument:x,childNodes:S,parentNode:C,parentElement:w,textContent:ee,contains:T,getRootNode:E,host:D,styleSheets:O,shadowRoot:k,querySelector:A,querySelectorAll:te,nowTimestamp:re,mutationObserverCtor:ne,patch:j};function N(e){return e.nodeType===e.ELEMENT_NODE}function P(e){let t=e&&`host`in e&&`mode`in e&&M.host(e)||null;return!!(t&&`shadowRoot`in t&&M.shadowRoot(t)===e)}function F(e){return Object.prototype.toString.call(e)===`[object ShadowRoot]`}function ie(e){return e.includes(` background-clip: text;`)&&!e.includes(` -webkit-background-clip: text;`)&&(e=e.replace(/\sbackground-clip:\s*text;/g,` -webkit-background-clip: text; background-clip: text;`)),e}function ae(e){let{cssText:t}=e;if(t.split(`"`).length<3)return t;let n=[`@import`,`url(${JSON.stringify(e.href)})`];return e.layerName===``?n.push(`layer`):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(` `)+`;`}function oe(e){try{let t=e.rules||e.cssRules;if(!t)return null;let n=e.href;return!n&&e.ownerNode&&(n=e.ownerNode.baseURI),ie(Array.from(t,e=>I(e,n)).join(``))}catch{return null}}function I(e,t){if(ce(e)){let t;try{t=oe(e.styleSheet)||ae(e)}catch{t=e.cssText}return e.styleSheet.href?ye(t,e.styleSheet.href):t}else{let n=e.cssText;return L(e)&&e.selectorText.includes(`:`)&&(n=se(n)),t?ye(n,t):n}}function se(e){return e.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,`$1\\$2`)}function ce(e){return`styleSheet`in e}function L(e){return`selectorText`in e}var R=class{constructor(){r(this,`idNodeMap`,new Map),r(this,`nodeMetaMap`,new WeakMap)}getId(e){return e?this.getMeta(e)?.id??-1:-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 t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){let n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){let n=this.getNode(e);if(n){let e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function le(){return new R}function z({element:e,maskInputOptions:t,tagName:n,type:r,value:i,maskInputFn:a}){let o=i||``,s=r&&B(r);return(t[n.toLowerCase()]||s&&t[s])&&(o=a?a(o,e):`*`.repeat(o.length)),o}function B(e){return e.toLowerCase()}var ue=`__rrweb_original__`;function de(e){let t=e.getContext(`2d`);if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){let i=t.getImageData,a=ue in i?i[ue]:i;if(new Uint32Array(a.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>e!==0))return!1}return!0}function fe(e){let t=e.type;return e.hasAttribute(`data-rr-is-password`)?`password`:t?B(t):null}function pe(e,t){let n;try{n=new URL(e,t??window.location.href)}catch{return null}return n.pathname.match(/\.([0-9a-z]+)(?:$)/i)?.[1]??null}function me(e){let t=``;return t=e.indexOf(`//`)>-1?e.split(`/`).slice(0,3).join(`/`):e.split(`/`)[0],t=t.split(`?`)[0],t}var he=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ge=/^(?:[a-z+]+:)?\/\//i,_e=/^www\..*/i,ve=/^(data:)([^,]*),(.*)/i;function ye(e,t){return(e||``).replace(he,(e,n,r,i,a,o)=>{let s=r||a||o,c=n||i||``;if(!s)return e;if(ge.test(s)||_e.test(s)||ve.test(s))return`url(${c}${s}${c})`;if(s[0]===`/`)return`url(${c}${me(t)+s}${c})`;let l=s.split(`#`)[0],u=s.substring(l.length),d=t.split(`#`)[0].split(`/`),f=l.split(`/`);d.pop();for(let e of f)if(e===`.`)continue;else e===`..`?d.pop():d.push(e);return`url(${c}${d.join(`/`)}${u}${c})`})}function be(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,``):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,``).replace(/0px/g,`0`)}function xe(e,t,n=!1){let r=Array.from(t.childNodes),i=[],a=0;if(r.length>1&&e&&typeof e==`string`){let t=be(e,n),o=t.length/e.length;for(let s=1;s<r.length;s++)if(r[s].textContent&&typeof r[s].textContent==`string`){let c=be(r[s].textContent,n),l=3;for(;l<c.length&&(c[l].match(/[a-zA-Z0-9]/)||c.indexOf(c.substring(0,l),1)!==-1);l++);for(;l<c.length;l++){let u=c.substring(0,l),d=t.split(u),f=-1;if(d.length===2)f=d[0].length;else if(d.length>2&&d[0]===``&&r[s-1].textContent!==``)f=t.indexOf(u,1);else if(d.length===1){if(u=u.substring(0,u.length-1),d=t.split(u),d.length<=1)return i.push(e),i;l=101}else l===c.length-1&&(f=t.indexOf(u));if(d.length>=2&&l>100){let e=r[s-1].textContent;if(e&&typeof e==`string`){let n=be(e).length;f=t.indexOf(u,n)}f===-1&&(f=d[0].length)}if(f!==-1){let s=Math.floor(f/o);for(;s>0&&s<e.length;){if(a+=1,a>50*r.length)return i.push(e),i;let c=be(e.substring(0,s),n);if(c.length===f){i.push(e.substring(0,s)),e=e.substring(s),t=t.substring(f);break}else c.length<f?s+=Math.max(1,Math.floor((f-c.length)/o)):s-=Math.max(1,Math.floor((c.length-f)*o))}break}}}}return i.push(e),i}function Se(e,t){return xe(e,t).join(`/* rr_split */`)}var Ce=1,we=RegExp(`[^a-z0-9-_:]`),Te=-2;function Ee(){return Ce++}function De(e){if(e instanceof HTMLFormElement)return`form`;let t=B(e.tagName);return we.test(t)?`div`:t}var V,Oe,ke=/^[^ \t\n\r\u000c]+/,Ae=/^[, \t\n\r\u000c]+/;function je(e,t){if(t.trim()===``)return t;let n=0;function r(e){let r,i=e.exec(t.substring(n));return i?(r=i[0],n+=r.length,r):``}let i=[];for(;r(Ae),!(n>=t.length);){let a=r(ke);if(a.slice(-1)===`,`)a=Ne(e,a.substring(0,a.length-1)),i.push(a);else{let r=``;a=Ne(e,a);let o=!1;for(;;){let e=t.charAt(n);if(e===``){i.push((a+r).trim());break}else if(o)e===`)`&&(o=!1);else if(e===`,`){n+=1,i.push((a+r).trim());break}else e===`(`&&(o=!0);r+=e,n+=1}}}return i.join(`, `)}var Me=new WeakMap;function Ne(e,t){return!t||t.trim()===``?t:Fe(e,t)}function Pe(e){return!!(e.tagName===`svg`||e.ownerSVGElement)}function Fe(e,t){let n=Me.get(e);if(n||(n=e.createElement(`a`),Me.set(e,n)),!t)t=``;else if(t.startsWith(`blob:`)||t.startsWith(`data:`))return t;return n.setAttribute(`href`,t),n.href}function Ie(e,t,n,r){return r&&(n===`src`||n===`href`&&(t!==`use`||r[0]!==`#`)||n===`xlink:href`&&r[0]!==`#`||n===`background`&&[`table`,`td`,`th`].includes(t)?Ne(e,r):n===`srcset`?je(e,r):n===`style`?ye(r,Fe(e)):t===`object`&&n===`data`?Ne(e,r):r)}function Le(e,t,n){return[`video`,`audio`].includes(e)&&t===`autoplay`}function Re(e,t,n){try{if(typeof t==`string`){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){let r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch{}return!1}function ze(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?ze(M.parentNode(e),t,n):!1;for(let n=e.classList.length;n--;){let r=e.classList[n];if(t.test(r))return!0}return n?ze(M.parentNode(e),t,n):!1}function Be(e,t,n,r){let i;if(N(e)){if(i=e,!M.childNodes(i).length)return!1}else if(M.parentElement(e)===null)return!1;else i=M.parentElement(e);try{if(typeof t==`string`){if(r){if(i.closest(`.${t}`))return!0}else if(i.classList.contains(t))return!0}else if(ze(i,t,r))return!0;if(n){if(r){if(i.closest(n))return!0}else if(i.matches(n))return!0}}catch{}return!1}function Ve(e,t,n){let r=e.contentWindow;if(!r)return;let i=!1,a;try{a=r.document.readyState}catch{return}if(a!==`complete`){let r=setTimeout(()=>{i||=(t(),!0)},n);e.addEventListener(`load`,()=>{clearTimeout(r),i=!0,t()});return}let o=`about:blank`;if(r.location.href!==o||e.src===o||e.src===``)return setTimeout(t,0),e.addEventListener(`load`,t);e.addEventListener(`load`,t)}function He(e,t,n){let r=!1,i;try{i=e.sheet}catch{return}if(i)return;let a=setTimeout(()=>{r||=(t(),!0)},n);e.addEventListener(`load`,()=>{clearTimeout(a),r=!0,t()})}function Ue(e,t){let{doc:n,mirror:r,blockClass:i,blockSelector:a,needsMask:o,inlineStylesheet:s,maskInputOptions:c={},maskTextFn:l,maskInputFn:d,dataURLOptions:f={},inlineImages:p,recordCanvas:m,keepIframeSrcFn:h,newlyAddedElement:g=!1,cssCaptured:_=!1}=t,v=We(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode===`CSS1Compat`?{type:u.Document,childNodes:[]}:{type:u.Document,childNodes:[],compatMode:e.compatMode};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:v};case e.ELEMENT_NODE:return Ke(e,{doc:n,blockClass:i,blockSelector:a,inlineStylesheet:s,maskInputOptions:c,maskInputFn:d,dataURLOptions:f,inlineImages:p,recordCanvas:m,keepIframeSrcFn:h,newlyAddedElement:g,rootId:v});case e.TEXT_NODE:return Ge(e,{doc:n,needsMask:o,maskTextFn:l,rootId:v,cssCaptured:_});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:``,rootId:v};case e.COMMENT_NODE:return{type:u.Comment,textContent:M.textContent(e)||``,rootId:v};default:return!1}}function We(e,t){if(!t.hasNode(e))return;let n=t.getId(e);return n===1?void 0:n}function Ge(e,t){let{needsMask:n,maskTextFn:r,rootId:i,cssCaptured:a}=t,o=M.parentNode(e),s=o&&o.tagName,c=``,l=s===`STYLE`||void 0,d=s===`SCRIPT`||void 0;return d?c=`SCRIPT_PLACEHOLDER`:a||(c=M.textContent(e),l&&c&&(c=ye(c,Fe(t.doc)))),!l&&!d&&c&&n&&(c=r?r(c,M.parentElement(e)):c.replace(/[\S]/g,`*`)),{type:u.Text,textContent:c||``,rootId:i}}function Ke(e,t){let{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:a,maskInputOptions:o={},maskInputFn:s,dataURLOptions:c={},inlineImages:l,recordCanvas:d,keepIframeSrcFn:f,newlyAddedElement:p=!1,rootId:m}=t,h=Re(e,r,i),g=De(e),_={},v=e.attributes.length;for(let t=0;t<v;t++){let r=e.attributes[t];Le(g,r.name,r.value)||(_[r.name]=Ie(n,g,B(r.name),r.value))}if(g===`link`&&a){let t=Array.from(n.styleSheets).find(t=>t.href===e.href),r=null;t&&(r=oe(t)),r&&(delete _.rel,delete _.href,_._cssText=r)}if(g===`style`&&e.sheet){let t=oe(e.sheet);t&&(e.childNodes.length>1&&(t=Se(t,e)),_._cssText=t)}if([`input`,`textarea`,`select`].includes(g)){let t=e.value,n=e.checked;_.type!==`radio`&&_.type!==`checkbox`&&_.type!==`submit`&&_.type!==`button`&&t?_.value=z({element:e,type:fe(e),tagName:g,value:t,maskInputOptions:o,maskInputFn:s}):n&&(_.checked=n)}if(g===`option`&&(e.selected&&!o.select?_.selected=!0:delete _.selected),g===`dialog`&&e.open&&(_.rr_open_mode=e.matches(`dialog:modal`)?`modal`:`non-modal`),g===`canvas`&&d){if(e.__context===`2d`)de(e)||(_.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!(`__context`in e)){let t=e.toDataURL(c.type,c.quality),r=n.createElement(`canvas`);r.width=e.width,r.height=e.height,t!==r.toDataURL(c.type,c.quality)&&(_.rr_dataURL=t)}}if(g===`img`&&l){V||(V=n.createElement(`canvas`),Oe=V.getContext(`2d`));let t=e,r=t.currentSrc||t.getAttribute(`src`)||`<unknown-src>`,i=t.crossOrigin,a=()=>{t.removeEventListener(`load`,a);try{V.width=t.naturalWidth,V.height=t.naturalHeight,Oe.drawImage(t,0,0),_.rr_dataURL=V.toDataURL(c.type,c.quality)}catch(e){if(t.crossOrigin!==`anonymous`){t.crossOrigin=`anonymous`,t.complete&&t.naturalWidth!==0?a():t.addEventListener(`load`,a);return}else console.warn(`Cannot inline img src=${r}! Error: ${e}`)}t.crossOrigin===`anonymous`&&(i?_.crossOrigin=i:t.removeAttribute(`crossorigin`))};t.complete&&t.naturalWidth!==0?a():t.addEventListener(`load`,a)}if([`audio`,`video`].includes(g)){let t=_;t.rr_mediaState=e.paused?`paused`:`played`,t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}if(p||(e.scrollLeft&&(_.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(_.rr_scrollTop=e.scrollTop)),h){let{width:t,height:n}=e.getBoundingClientRect();_={class:_.class,rr_width:`${t}px`,rr_height:`${n}px`}}g===`iframe`&&!f(_.src)&&(e.contentDocument||(_.rr_src=_.src),delete _.src);let y;try{customElements.get(g)&&(y=!0)}catch{}return{type:u.Element,tagName:g,attributes:_,childNodes:[],isSVG:Pe(e)||void 0,needBlock:h,rootId:m,isCustom:y}}function H(e){return e==null?``:e.toLowerCase()}function qe(e){return e===!0||e===`all`?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:e===`all`,headMetaDescKeywords:e===`all`,headTitleMutations:e===`all`}:e||{}}function Je(e,t){return!!(t.comment&&e.type===u.Comment||e.type===u.Element&&(t.script&&(e.tagName===`script`||e.tagName===`link`&&(e.attributes.rel===`preload`&&e.attributes.as===`script`||e.attributes.rel===`modulepreload`)||e.tagName===`link`&&e.attributes.rel===`prefetch`&&typeof e.attributes.href==`string`&&pe(e.attributes.href)===`js`)||t.headFavicon&&(e.tagName===`link`&&e.attributes.rel===`shortcut icon`||e.tagName===`meta`&&(H(e.attributes.name).match(/^msapplication-tile(image|color)$/)||H(e.attributes.name)===`application-name`||H(e.attributes.rel)===`icon`||H(e.attributes.rel)===`apple-touch-icon`||H(e.attributes.rel)===`shortcut icon`))||e.tagName===`meta`&&(t.headMetaDescKeywords&&H(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(H(e.attributes.property).match(/^(og|twitter|fb):/)||H(e.attributes.name).match(/^(og|twitter):/)||H(e.attributes.name)===`pinterest`)||t.headMetaRobots&&(H(e.attributes.name)===`robots`||H(e.attributes.name)===`googlebot`||H(e.attributes.name)===`bingbot`)||t.headMetaHttpEquiv&&e.attributes[`http-equiv`]!==void 0||t.headMetaAuthorship&&(H(e.attributes.name)===`author`||H(e.attributes.name)===`generator`||H(e.attributes.name)===`framework`||H(e.attributes.name)===`publisher`||H(e.attributes.name)===`progid`||H(e.attributes.property).match(/^article:/)||H(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(H(e.attributes.name)===`google-site-verification`||H(e.attributes.name)===`yandex-verification`||H(e.attributes.name)===`csrf-token`||H(e.attributes.name)===`p:domain_verify`||H(e.attributes.name)===`verify-v1`||H(e.attributes.name)===`verification`||H(e.attributes.name)===`shopify-checkout-api-token`))))}function Ye(e,t){let{doc:n,mirror:r,blockClass:i,blockSelector:a,maskTextClass:o,maskTextSelector:s,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:d={},maskTextFn:f,maskInputFn:p,slimDOMOptions:m,dataURLOptions:h={},inlineImages:g=!1,recordCanvas:_=!1,onSerialize:v,onIframeLoad:y,iframeLoadTimeout:b=5e3,onStylesheetLoad:x,stylesheetLoadTimeout:S=5e3,keepIframeSrcFn:C=()=>!1,newlyAddedElement:w=!1,cssCaptured:ee=!1}=t,{needsMask:T}=t,{preserveWhiteSpace:E=!0}=t;T||=Be(e,o,s,T===void 0);let D=Ue(e,{doc:n,mirror:r,blockClass:i,blockSelector:a,needsMask:T,inlineStylesheet:l,maskInputOptions:d,maskTextFn:f,maskInputFn:p,dataURLOptions:h,inlineImages:g,recordCanvas:_,keepIframeSrcFn:C,newlyAddedElement:w,cssCaptured:ee});if(!D)return console.warn(e,`not serialized`),null;let O;O=r.hasNode(e)?r.getId(e):Je(D,m)||!E&&D.type===u.Text&&!D.textContent.replace(/^\s+|\s+$/gm,``).length?Te:Ee();let k=Object.assign(D,{id:O});if(r.add(e,k),O===Te)return null;v&&v(e);let A=!c;if(k.type===u.Element){A&&=!k.needBlock,delete k.needBlock;let t=M.shadowRoot(e);t&&F(t)&&(k.isShadowHost=!0)}if((k.type===u.Document||k.type===u.Element)&&A){m.headWhitespace&&k.type===u.Element&&k.tagName===`head`&&(E=!1);let t={doc:n,mirror:r,blockClass:i,blockSelector:a,needsMask:T,maskTextClass:o,maskTextSelector:s,skipChild:c,inlineStylesheet:l,maskInputOptions:d,maskTextFn:f,maskInputFn:p,slimDOMOptions:m,dataURLOptions:h,inlineImages:g,recordCanvas:_,preserveWhiteSpace:E,onSerialize:v,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:x,stylesheetLoadTimeout:S,keepIframeSrcFn:C,cssCaptured:!1};if(k.type!==u.Element||k.tagName!==`textarea`||k.attributes.value===void 0){k.type===u.Element&&k.attributes._cssText!==void 0&&typeof k.attributes._cssText==`string`&&(t.cssCaptured=!0);for(let n of Array.from(M.childNodes(e))){let e=Ye(n,t);e&&k.childNodes.push(e)}}let w=null;if(N(e)&&(w=M.shadowRoot(e)))for(let e of Array.from(M.childNodes(w))){let n=Ye(e,t);n&&(F(w)&&(n.isShadow=!0),k.childNodes.push(n))}}let te=M.parentNode(e);return te&&P(te)&&F(te)&&(k.isShadow=!0),k.type===u.Element&&k.tagName===`iframe`&&Ve(e,()=>{let t=e.contentDocument;if(t&&y){let n=Ye(t,{doc:t,mirror:r,blockClass:i,blockSelector:a,needsMask:T,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:f,maskInputFn:p,slimDOMOptions:m,dataURLOptions:h,inlineImages:g,recordCanvas:_,preserveWhiteSpace:E,onSerialize:v,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:x,stylesheetLoadTimeout:S,keepIframeSrcFn:C});n&&y(e,n)}},b),k.type===u.Element&&k.tagName===`link`&&typeof k.attributes.rel==`string`&&(k.attributes.rel===`stylesheet`||k.attributes.rel===`preload`&&typeof k.attributes.href==`string`&&pe(k.attributes.href)===`css`)&&He(e,()=>{if(x){let t=Ye(e,{doc:n,mirror:r,blockClass:i,blockSelector:a,needsMask:T,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:f,maskInputFn:p,slimDOMOptions:m,dataURLOptions:h,inlineImages:g,recordCanvas:_,preserveWhiteSpace:E,onSerialize:v,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:x,stylesheetLoadTimeout:S,keepIframeSrcFn:C});t&&x(e,t)}},S),k}function Xe(e,t){let{mirror:n=new R,blockClass:r=`rr-block`,blockSelector:i=null,maskTextClass:a=`rr-mask`,maskTextSelector:o=null,inlineStylesheet:s=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:f,slimDOM:p=!1,dataURLOptions:m,preserveWhiteSpace:h,onSerialize:g,onIframeLoad:_,iframeLoadTimeout:v,onStylesheetLoad:y,stylesheetLoadTimeout:b,keepIframeSrcFn:x=()=>!1}=t;return Ye(e,{doc:e,mirror:n,blockClass:r,blockSelector:i,maskTextClass:a,maskTextSelector:o,skipChild:!1,inlineStylesheet:s,maskInputOptions:u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u===!1?{password:!0}:u,maskTextFn:d,maskInputFn:f,slimDOMOptions:qe(p),dataURLOptions:m,inlineImages:c,recordCanvas:l,preserveWhiteSpace:h,onSerialize:g,onIframeLoad:_,iframeLoadTimeout:v,onStylesheetLoad:y,stylesheetLoadTimeout:b,keepIframeSrcFn:x,newlyAddedElement:!1})}var Ze=class e{constructor(...e){r(this,`parentElement`,null),r(this,`parentNode`,null),r(this,`ownerDocument`),r(this,`firstChild`,null),r(this,`lastChild`,null),r(this,`previousSibling`,null),r(this,`nextSibling`,null),r(this,`ELEMENT_NODE`,1),r(this,`TEXT_NODE`,3),r(this,`nodeType`),r(this,`nodeName`),r(this,`RRNodeType`)}get childNodes(){let e=[],t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e)||t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`)}insertBefore(e,t){throw Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`)}removeChild(e){throw Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`)}toString(){return`RRNode`}};function U(e,t,n=document){let r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var W=`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.`,Qe={map:{},getId(){return console.error(W),-1},getNode(){return console.error(W),null},removeNodeFromMap(){console.error(W)},has(){return console.error(W),!1},reset(){console.error(W)}};typeof window<`u`&&window.Proxy&&window.Reflect&&(Qe=new Proxy(Qe,{get(e,t,n){return t===`map`&&console.error(W),Reflect.get(e,t,n)}}));function $e(e,t,n={}){let r=null,i=0;return function(...a){let o=Date.now();!i&&n.leading===!1&&(i=o);let s=t-(o-i),c=this;s<=0||s>t?(r&&=(clearTimeout(r),null),i=o,e.apply(c,a)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{i=n.leading===!1?0:Date.now(),r=null,e.apply(c,a)},s))}}function et(e,t,n,r,i=window){let a=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),a&&a.set&&a.set.call(this,e)}}),()=>et(e,t,a||{},!0)}function tt(e){let t=e.document;return{left:t.scrollingElement?t.scrollingElement.scrollLeft:e.pageXOffset===void 0?t.documentElement.scrollLeft||t?.body&&M.parentElement(t.body)?.scrollLeft||t?.body?.scrollLeft||0:e.pageXOffset,top:t.scrollingElement?t.scrollingElement.scrollTop:e.pageYOffset===void 0?t?.documentElement.scrollTop||t?.body&&M.parentElement(t.body)?.scrollTop||t?.body?.scrollTop||0:e.pageYOffset}}function nt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function rt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function it(e){return e?e.nodeType===e.ELEMENT_NODE?e:M.parentElement(e):null}function G(e,t,n,r){if(!e)return!1;let i=it(e);if(!i)return!1;try{if(typeof t==`string`){if(i.classList.contains(t)||r&&i.closest(`.`+t)!==null)return!0}else if(ze(i,t,r))return!0}catch{}return!!(n&&(i.matches(n)||r&&i.closest(n)!==null))}function at(e,t){return t.getId(e)!==-1}function ot(e,t,n){return e.tagName===`TITLE`&&n.headTitleMutations?!0:t.getId(e)===Te}function st(e,t){if(P(e))return!1;let n=t.getId(e);if(!t.has(n))return!0;let r=M.parentNode(e);return r&&r.nodeType===e.DOCUMENT_NODE?!1:!r||st(r,t)}function ct(e){return!!e.changedTouches}function lt(e=window){`NodeList`in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),`DOMTokenList`in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}function ut(e,t){return!!(e.nodeName===`IFRAME`&&t.getMeta(e))}function dt(e,t){return!!(e.nodeName===`LINK`&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute(`rel`)===`stylesheet`&&t.getMeta(e))}function ft(e){return e?e instanceof Ze&&`shadowRoot`in e?!!e.shadowRoot:!!M.shadowRoot(e):!1}var pt=class{constructor(){r(this,`id`,1),r(this,`styleIDMap`,new WeakMap),r(this,`idStyleMap`,new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=t===void 0?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function mt(e){let t=null;return`getRootNode`in e&&M.getRootNode(e)?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&M.host(M.getRootNode(e))&&(t=M.host(M.getRootNode(e))),t}function ht(e){let t=e,n;for(;n=mt(t);)t=n;return t}function gt(e){let t=M.ownerDocument(e);if(!t)return!1;let n=ht(e);return M.contains(t,n)}function _t(e){let t=M.ownerDocument(e);return t?M.contains(t,e)||gt(e):!1}function vt(e){return`__ln`in e}var yt=class{constructor(){r(this,`length`,0),r(this,`head`,null),r(this,`tail`,null)}get(e){if(e>=this.length)throw Error(`Position outside of list range`);let t=this.head;for(let n=0;n<e;n++)t=t?.next||null;return t}addNode(e){let t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&vt(e.previousSibling)){let n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&vt(e.nextSibling)&&e.nextSibling.__ln.previous){let n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;t.next===null&&(this.tail=t),this.length++}removeNode(e){let t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},bt=(e,t)=>`${e}@${t}`,xt=class{constructor(){r(this,`frozen`,!1),r(this,`locked`,!1),r(this,`texts`,[]),r(this,`attributes`,[]),r(this,`attributeMap`,new WeakMap),r(this,`removes`,[]),r(this,`mapRemoves`,[]),r(this,`movedMap`,{}),r(this,`addedSet`,new Set),r(this,`movedSet`,new Set),r(this,`droppedSet`,new Set),r(this,`removesSubTreeCache`,new Set),r(this,`mutationCb`),r(this,`blockClass`),r(this,`blockSelector`),r(this,`maskTextClass`),r(this,`maskTextSelector`),r(this,`inlineStylesheet`),r(this,`maskInputOptions`),r(this,`maskTextFn`),r(this,`maskInputFn`),r(this,`keepIframeSrcFn`),r(this,`recordCanvas`),r(this,`inlineImages`),r(this,`slimDOMOptions`),r(this,`dataURLOptions`),r(this,`doc`),r(this,`mirror`),r(this,`iframeManager`),r(this,`stylesheetManager`),r(this,`shadowDomManager`),r(this,`canvasManager`),r(this,`processedNodeManager`),r(this,`unattachedDoc`),r(this,`processMutations`,e=>{e.forEach(this.processMutation),this.emit()}),r(this,`emit`,()=>{if(this.frozen||this.locked)return;let e=[],t=new Set,n=new yt,r=e=>{let t=e,n=Te;for(;n===Te;)t&&=t.nextSibling,n=t&&this.mirror.getId(t);return n},i=i=>{let a=M.parentNode(i);if(!a||!_t(i))return;let o=!1;if(i.nodeType===Node.TEXT_NODE){let e=a.tagName;if(e===`TEXTAREA`)return;e===`STYLE`&&this.addedSet.has(a)&&(o=!0)}let s=P(a)?this.mirror.getId(mt(i)):this.mirror.getId(a),c=r(i);if(s===-1||c===-1)return n.addNode(i);let l=Ye(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:e=>{ut(e,this.mirror)&&this.iframeManager.addIframe(e),dt(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ft(i)&&this.shadowDomManager.addShadowRoot(M.shadowRoot(i),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:o});l&&(e.push({parentId:s,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let e of this.movedSet)wt(this.removesSubTreeCache,e,this.mirror)&&!this.movedSet.has(M.parentNode(e))||i(e);for(let e of this.addedSet)!Et(this.droppedSet,e)&&!wt(this.removesSubTreeCache,e,this.mirror)||Et(this.movedSet,e)?i(e):this.droppedSet.add(e);let a=null;for(;n.length;){let e=null;if(a){let t=this.mirror.getId(M.parentNode(a.value)),n=r(a.value);t!==-1&&n!==-1&&(e=a)}if(!e){let t=n.tail;for(;t;){let n=t;if(t=t.previous,n){let t=this.mirror.getId(M.parentNode(n.value));if(r(n.value)===-1)continue;if(t!==-1){e=n;break}else{let t=n.value,r=M.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let t=M.host(r);if(this.mirror.getId(t)!==-1){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}a=e.previous,n.removeNode(e.value),i(e.value)}let o={texts:this.texts.map(e=>{let t=e.node,n=M.parentNode(t);return n&&n.tagName===`TEXTAREA`&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{let{attributes:t}=e;if(typeof t.style==`string`){let n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split(`var(`).length===t.style.split(`var(`).length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};!o.texts.length&&!o.attributes.length&&!o.removes.length&&!o.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(o))}),r(this,`genTextAreaValueMutation`,e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));let n=Array.from(M.childNodes(e),e=>M.textContent(e)||``).join(``);t.attributes.value=z({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:fe(e),value:n,maskInputFn:this.maskInputFn})}),r(this,`processMutation`,e=>{if(!ot(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case`characterData`:{let t=M.textContent(e.target);!G(e.target,this.blockClass,this.blockSelector,!1)&&t!==e.oldValue&&this.texts.push({value:Be(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,it(e.target)):t.replace(/[\S]/g,`*`):t,node:e.target});break}case`attributes`:{let t=e.target,n=e.attributeName,r=e.target.getAttribute(n);if(n===`value`){let e=fe(t);r=z({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(G(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let i=this.attributeMap.get(e.target);if(t.tagName===`IFRAME`&&n===`src`&&!this.keepIframeSrcFn(r))if(!t.contentDocument)n=`rr_src`;else return;if(i||(i={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(e.target,i)),n===`type`&&t.tagName===`INPUT`&&(e.oldValue||``).toLowerCase()===`password`&&t.setAttribute(`data-rr-is-password`,`true`),!Le(t.tagName,n))if(i.attributes[n]=Ie(this.doc,B(t.tagName),B(n),r),n===`style`){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}let n=this.unattachedDoc.createElement(`span`);e.oldValue&&n.setAttribute(`style`,e.oldValue);for(let e of Array.from(t.style)){let r=t.style.getPropertyValue(e),a=t.style.getPropertyPriority(e);r!==n.style.getPropertyValue(e)||a!==n.style.getPropertyPriority(e)?a===``?i.styleDiff[e]=r:i.styleDiff[e]=[r,a]:i._unchangedStyles[e]=[r,a]}for(let e of Array.from(n.style))t.style.getPropertyValue(e)===``&&(i.styleDiff[e]=!1)}else n===`open`&&t.tagName===`DIALOG`&&(t.matches(`dialog:modal`)?i.attributes.rr_open_mode=`modal`:i.attributes.rr_open_mode=`non-modal`);break}case`childList`:if(G(e.target,this.blockClass,this.blockSelector,!0))return;if(e.target.tagName===`TEXTAREA`){this.genTextAreaValueMutation(e.target);return}e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{let n=this.mirror.getId(t),r=P(e.target)?this.mirror.getId(M.host(e.target)):this.mirror.getId(e.target);G(e.target,this.blockClass,this.blockSelector,!1)||ot(t,this.mirror,this.slimDOMOptions)||!at(t,this.mirror)||(this.addedSet.has(t)?(St(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&n===-1||st(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[bt(n,r)]?St(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:P(e.target)&&F(e.target)?!0:void 0}),Ct(t,this.removesSubTreeCache))),this.mapRemoves.push(t))});break}}),r(this,`genAdds`,(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!(this.addedSet.has(e)||this.movedSet.has(e))){if(this.mirror.hasNode(e)){if(ot(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&n!==-1&&(this.movedMap[bt(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);G(e,this.blockClass,this.blockSelector,!1)||(M.childNodes(e).forEach(e=>this.genAdds(e)),ft(e)&&M.childNodes(M.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){[`mutationCb`,`blockClass`,`blockSelector`,`maskTextClass`,`maskTextSelector`,`inlineStylesheet`,`maskInputOptions`,`maskTextFn`,`maskInputFn`,`keepIframeSrcFn`,`recordCanvas`,`inlineImages`,`slimDOMOptions`,`dataURLOptions`,`doc`,`mirror`,`iframeManager`,`stylesheetManager`,`shadowDomManager`,`canvasManager`,`processedNodeManager`].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function St(e,t){e.delete(t),M.childNodes(t).forEach(t=>St(e,t))}function Ct(e,t){let n=[e];for(;n.length;){let e=n.pop();t.has(e)||(t.add(e),M.childNodes(e).forEach(e=>n.push(e)))}}function wt(e,t,n){return e.size!==0&&Tt(e,t)}function Tt(e,t,n){let r=M.parentNode(t);return r?e.has(r):!1}function Et(e,t){return e.size!==0&&Dt(e,t)}function Dt(e,t){let n=M.parentNode(t);return n?e.has(n)?!0:Dt(e,n):!1}var Ot;function kt(e){Ot=e}function At(){Ot=void 0}var K=e=>Ot?(...t)=>{try{return e(...t)}catch(e){if(Ot&&Ot(e)===!0)return;throw e}}:e,q=[];function jt(e){try{if(`composedPath`in e){let t=e.composedPath();if(t.length)return t[0]}else if(`path`in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function Mt(e,t){let n=new xt;q.push(n),n.init(e);let[r,i]=ne(),a=new r(K(n.processMutations.bind(n)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[a,i]}function Nt({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};let i=typeof t.mousemove==`number`?t.mousemove:50,o=typeof t.mousemoveCallback==`number`?t.mousemoveCallback:500,s=[],c,l=$e(K(t=>{let n=Date.now()-c;e(s.map(e=>(e.timeOffset-=n,e)),t),s=[],c=null}),o),u=K($e(K(e=>{let t=jt(e),{clientX:n,clientY:i}=ct(e)?e.changedTouches[0]:e;c||=re(),s.push({x:n,y:i,id:r.getId(t),timeOffset:re()-c}),l(typeof DragEvent<`u`&&e instanceof DragEvent?a.Drag:e instanceof MouseEvent?a.MouseMove:a.TouchMove)}),i,{trailing:!1})),d=[U(`mousemove`,u,n),U(`touchmove`,u,n),U(`drag`,u,n)];return K(()=>{d.forEach(e=>e())})}function Pt({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:a}){if(a.mouseInteraction===!1)return()=>{};let c=a.mouseInteraction===!0||a.mouseInteraction===void 0?{}:a.mouseInteraction,l=[],u=null,d=t=>a=>{let c=jt(a);if(G(c,r,i,!0))return;let l=null,d=t;if(`pointerType`in a){switch(a.pointerType){case`mouse`:l=s.Mouse;break;case`touch`:l=s.Touch;break;case`pen`:l=s.Pen;break}l===s.Touch?o[t]===o.MouseDown?d=`TouchStart`:o[t]===o.MouseUp&&(d=`TouchEnd`):s.Pen}else ct(a)&&(l=s.Touch);l===null?o[t]===o.Click&&(l=u,u=null):(u=l,(d.startsWith(`Touch`)&&l===s.Touch||d.startsWith(`Mouse`)&&l===s.Mouse)&&(l=null));let f=ct(a)?a.changedTouches[0]:a;if(!f)return;let p=n.getId(c),{clientX:m,clientY:h}=f;K(e)({type:o[d],id:p,x:m,y:h,...l!==null&&{pointerType:l}})};return Object.keys(o).filter(e=>Number.isNaN(Number(e))&&!e.endsWith(`_Departed`)&&c[e]!==!1).forEach(e=>{let n=B(e),r=d(e);if(window.PointerEvent)switch(o[e]){case o.MouseDown:case o.MouseUp:n=n.replace(`mouse`,`pointer`);break;case o.TouchStart:case o.TouchEnd:return}l.push(U(n,r,t))}),K(()=>{l.forEach(e=>e())})}function Ft({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:a}){return U(`scroll`,K($e(K(a=>{let o=jt(a);if(!o||G(o,r,i,!0))return;let s=n.getId(o);if(o===t&&t.defaultView){let n=tt(t.defaultView);e({id:s,x:n.left,y:n.top})}else e({id:s,x:o.scrollLeft,y:o.scrollTop})}),a.scroll||100)),t)}function It({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return U(`resize`,K($e(K(()=>{let t=nt(),i=rt();(n!==t||r!==i)&&(e({width:Number(i),height:Number(t)}),n=t,r=i)}),200)),t)}var Lt=[`INPUT`,`TEXTAREA`,`SELECT`],Rt=new WeakMap;function zt({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:a,ignoreSelector:o,maskInputOptions:s,maskInputFn:c,sampling:l,userTriggeredOnInput:u}){function d(e){let n=jt(e),l=e.isTrusted,d=n&&n.tagName;if(n&&d===`OPTION`&&(n=M.parentElement(n)),!n||!d||Lt.indexOf(d)<0||G(n,r,i,!0)||n.classList.contains(a)||o&&n.matches(o))return;let p=n.value,m=!1,h=fe(n)||``;h===`radio`||h===`checkbox`?m=n.checked:(s[d.toLowerCase()]||s[h])&&(p=z({element:n,maskInputOptions:s,tagName:d,type:h,value:p,maskInputFn:c})),f(n,u?{text:p,isChecked:m,userTriggered:l}:{text:p,isChecked:m});let g=n.name;h===`radio`&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){let t=e.value;f(e,u?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function f(t,r){let i=Rt.get(t);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){Rt.set(t,r);let i=n.getId(t);K(e)({...r,id:i})}}let p=(l.input===`last`?[`change`]:[`input`,`change`]).map(e=>U(e,K(d),t)),m=t.defaultView;if(!m)return()=>{p.forEach(e=>e())};let h=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,`value`),g=[[m.HTMLInputElement.prototype,`value`],[m.HTMLInputElement.prototype,`checked`],[m.HTMLSelectElement.prototype,`value`],[m.HTMLTextAreaElement.prototype,`value`],[m.HTMLSelectElement.prototype,`selectedIndex`],[m.HTMLOptionElement.prototype,`selected`]];return h&&h.set&&p.push(...g.map(e=>et(e[0],e[1],{set(){K(d)({target:this,isTrusted:!1})}},!1,m))),K(()=>{p.forEach(e=>e())})}function Bt(e){let t=[];function n(e,t){if(Xt(`CSSGroupingRule`)&&e.parentRule instanceof CSSGroupingRule||Xt(`CSSMediaRule`)&&e.parentRule instanceof CSSMediaRule||Xt(`CSSSupportsRule`)&&e.parentRule instanceof CSSSupportsRule||Xt(`CSSConditionRule`)&&e.parentRule instanceof CSSConditionRule){let r=Array.from(e.parentRule.cssRules).indexOf(e);return t.unshift(r),n(e.parentRule,t)}else if(e.parentStyleSheet){let n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}return n(e,t)}function J(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function Vt({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};let i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:K((r,i,a)=>{let[o,s]=a,{id:c,styleId:l}=J(i,t,n.styleMirror);return(c&&c!==-1||l&&l!==-1)&&e({id:c,styleId:l,adds:[{rule:o,index:s}]}),r.apply(i,a)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){let i=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[i,n])};let a=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=new Proxy(a,{apply:K((r,i,a)=>{let[o]=a,{id:s,styleId:c}=J(i,t,n.styleMirror);return(s&&s!==-1||c&&c!==-1)&&e({id:s,styleId:c,removes:[{index:o}]}),r.apply(i,a)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])};let o;r.CSSStyleSheet.prototype.replace&&(o=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:K((r,i,a)=>{let[o]=a,{id:s,styleId:c}=J(i,t,n.styleMirror);return(s&&s!==-1||c&&c!==-1)&&e({id:s,styleId:c,replace:o}),r.apply(i,a)})}));let s;r.CSSStyleSheet.prototype.replaceSync&&(s=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(s,{apply:K((r,i,a)=>{let[o]=a,{id:s,styleId:c}=J(i,t,n.styleMirror);return(s&&s!==-1||c&&c!==-1)&&e({id:s,styleId:c,replaceSync:o}),r.apply(i,a)})}));let c={};Zt(`CSSGroupingRule`)?c.CSSGroupingRule=r.CSSGroupingRule:(Zt(`CSSMediaRule`)&&(c.CSSMediaRule=r.CSSMediaRule),Zt(`CSSConditionRule`)&&(c.CSSConditionRule=r.CSSConditionRule),Zt(`CSSSupportsRule`)&&(c.CSSSupportsRule=r.CSSSupportsRule));let l={};return Object.entries(c).forEach(([r,i])=>{l[r]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=new Proxy(l[r].insertRule,{apply:K((r,i,a)=>{let[o,s]=a,{id:c,styleId:l}=J(i.parentStyleSheet,t,n.styleMirror);return(c&&c!==-1||l&&l!==-1)&&e({id:c,styleId:l,adds:[{rule:o,index:[...Bt(i),s||0]}]}),r.apply(i,a)})}),i.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:K((r,i,a)=>{let[o]=a,{id:s,styleId:c}=J(i.parentStyleSheet,t,n.styleMirror);return(s&&s!==-1||c&&c!==-1)&&e({id:s,styleId:c,removes:[{index:[...Bt(i),o]}]}),r.apply(i,a)})})}),K(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=a,o&&(r.CSSStyleSheet.prototype.replace=o),s&&(r.CSSStyleSheet.prototype.replaceSync=s),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}function Ht({mirror:e,stylesheetManager:t},n){let r=null;r=n.nodeName===`#document`?e.getId(n):e.getId(M.host(n));let i=n.nodeName===`#document`?n.defaultView?.Document:n.ownerDocument?.defaultView?.ShadowRoot,a=i?.prototype?Object.getOwnPropertyDescriptor(i?.prototype,`adoptedStyleSheets`):void 0;return r===null||r===-1||!i||!a?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){return a.get?.call(this)},set(e){let n=a.set?.call(this,e);if(r!==null&&r!==-1)try{t.adoptStyleSheets(e,r)}catch{}return n}}),K(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function Ut({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){let a=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:K((i,o,s)=>{let[c,l,u]=s;if(n.has(c))return a.apply(o,[c,l,u]);let{id:d,styleId:f}=J(o.parentRule?.parentStyleSheet,t,r.styleMirror);return(d&&d!==-1||f&&f!==-1)&&e({id:d,styleId:f,set:{property:c,value:l,priority:u},index:Bt(o.parentRule)}),i.apply(o,s)})});let o=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:K((i,a,s)=>{let[c]=s;if(n.has(c))return o.apply(a,[c]);let{id:l,styleId:u}=J(a.parentRule?.parentStyleSheet,t,r.styleMirror);return(l&&l!==-1||u&&u!==-1)&&e({id:l,styleId:u,remove:{property:c},index:Bt(a.parentRule)}),i.apply(a,s)})}),K(()=>{i.CSSStyleDeclaration.prototype.setProperty=a,i.CSSStyleDeclaration.prototype.removeProperty=o})}function Wt({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:a}){let o=K(a=>$e(K(i=>{let o=jt(i);if(!o||G(o,t,n,!0))return;let{currentTime:s,volume:c,muted:l,playbackRate:u,loop:d}=o;e({type:a,id:r.getId(o),currentTime:s,volume:c,muted:l,playbackRate:u,loop:d})}),i.media||500)),s=[U(`play`,o(l.Play),a),U(`pause`,o(l.Pause),a),U(`seeked`,o(l.Seeked),a),U(`volumechange`,o(l.VolumeChange),a),U(`ratechange`,o(l.RateChange),a)];return K(()=>{s.forEach(e=>e())})}function Gt({fontCb:e,doc:t}){let n=t.defaultView;if(!n)return()=>{};let r=[],i=new WeakMap,a=n.FontFace;n.FontFace=function(e,t,n){let r=new a(e,t,n);return i.set(r,{family:e,buffer:typeof t!=`string`,descriptors:n,fontSource:typeof t==`string`?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};let o=j(t.fonts,`add`,function(t){return function(n){return setTimeout(K(()=>{let t=i.get(n);t&&(e(t),i.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=a}),r.push(o),K(()=>{r.forEach(e=>e())})}function Kt(e){let{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:a}=e,o=!0,s=K(()=>{let e=t.getSelection();if(!e||o&&e?.isCollapsed)return;o=e.isCollapsed||!1;let s=[],c=e.rangeCount||0;for(let t=0;t<c;t++){let{startContainer:a,startOffset:o,endContainer:c,endOffset:l}=e.getRangeAt(t);G(a,r,i,!0)||G(c,r,i,!0)||s.push({start:n.getId(a),startOffset:o,end:n.getId(c),endOffset:l})}a({ranges:s})});return s(),U(`selectionchange`,s)}function qt({doc:e,customElementCb:t}){let n=e.defaultView;return!n||!n.customElements?()=>{}:j(n.customElements,`define`,function(e){return function(n,r,i){try{t({define:{name:n}})}catch{console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,r,i])}})}function Jt(e,t){let{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:a,viewportResizeCb:o,inputCb:s,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:f,selectionCb:p,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),a(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),s(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),f(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}function Yt(e,t={}){let n=e.doc.defaultView;if(!n)return()=>{};Jt(e,t);let r,i=()=>{};e.recordDOM&&([r,i]=Mt(e,e.doc));let a=Nt(e),o=Pt(e),s=Ft(e),c=It(e,{win:n}),l=zt(e),u=Wt(e),d=()=>{},f=()=>{},p=()=>{},m=()=>{};e.recordDOM&&(d=Vt(e,{win:n}),f=Ht(e,e.doc),p=Ut(e,{win:n}),e.collectFonts&&(m=Gt(e)));let h=Kt(e),g=qt(e),_=[];for(let t of e.plugins)_.push(t.observer(t.callback,n,t.options));return K(()=>{q.forEach(e=>e.reset()),r?.disconnect(),i(),a(),o(),s(),c(),l(),u(),d(),f(),p(),m(),h(),g(),_.forEach(e=>e())})}function Xt(e){return window[e]!==void 0}function Zt(e){return!!(window[e]!==void 0&&window[e].prototype&&`insertRule`in window[e].prototype&&`deleteRule`in window[e].prototype)}for(var Qt=class{constructor(e){r(this,`iframeIdToRemoteIdMap`,new WeakMap),r(this,`iframeRemoteIdToIdMap`,new WeakMap),this.generateIdFn=e}getId(e,t,n,r){let i=n||this.getIdToRemoteIdMap(e),a=r||this.getRemoteIdToIdMap(e),o=i.get(t);return o||(o=this.generateIdFn(),i.set(t,o),a.set(o,t)),o}getIds(e,t){let n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){let r=n||this.getRemoteIdToIdMap(e);return typeof t==`number`?r.get(t)||-1:t}getRemoteIds(e,t){let n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},$t=class{constructor(e){r(this,`iframes`,new WeakMap),r(this,`crossOriginIframeMap`,new WeakMap),r(this,`crossOriginIframeMirror`,new Qt(Ee)),r(this,`crossOriginIframeStyleMirror`),r(this,`crossOriginIframeRootIdMap`,new WeakMap),r(this,`mirror`),r(this,`mutationCb`),r(this,`wrappedEmit`),r(this,`loadListener`),r(this,`stylesheetManager`),r(this,`recordCrossOriginIframes`),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Qt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener(`message`,this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((n=e.contentWindow)==null||n.addEventListener(`message`,this.handleMessage.bind(this))),(r=this.loadListener)==null||r.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 t=e;if(t.data.type!==`rrweb`||t.origin!==t.data.origin||!e.source)return;let n=this.crossOriginIframeMap.get(e.source);if(!n)return;let r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case i.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);let n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:i.IncrementalSnapshot,data:{source:a.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case i.Meta:case i.Load:case i.DomContentLoaded:return!1;case i.Plugin:return t;case i.Custom:return this.replaceIds(t.data.payload,e,[`id`,`parentId`,`previousId`,`nextId`]),t;case i.IncrementalSnapshot:switch(t.data.source){case a.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,[`parentId`,`nextId`,`previousId`]),this.replaceIdOnNode(t.node,e);let n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,[`parentId`,`id`])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,[`id`])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,[`id`])}),t;case a.Drag:case a.TouchMove:case a.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,[`id`])}),t;case a.ViewportResize:return!1;case a.MediaInteraction:case a.MouseInteraction:case a.Scroll:case a.CanvasMutation:case a.Input:return this.replaceIds(t.data,e,[`id`]),t;case a.StyleSheetRule:case a.StyleDeclaration:return this.replaceIds(t.data,e,[`id`]),this.replaceStyleIds(t.data,e,[`styleId`]),t;case a.Font:return t;case a.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,[`start`,`end`])}),t;case a.AdoptedStyleSheet:return this.replaceIds(t.data,e,[`id`]),this.replaceStyleIds(t.data,e,[`styleIds`]),(n=t.data.styles)==null||n.forEach(t=>{this.replaceStyleIds(t,e,[`styleId`])}),t}}return!1}replace(e,t,n,r){for(let i of r)!Array.isArray(t[i])&&typeof t[i]!=`number`||(Array.isArray(t[i])?t[i]=e.getIds(n,t[i]):t[i]=e.getId(n,t[i]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,[`id`,`rootId`]),`childNodes`in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type!==u.Document&&!e.rootId&&(e.rootId=t),`childNodes`in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},en=class{constructor(e){r(this,`shadowDoms`,new WeakSet),r(this,`mutationCb`),r(this,`scrollCb`),r(this,`bypassOptions`),r(this,`mirror`),r(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,t){if(!F(e)||this.shadowDoms.has(e))return;this.shadowDoms.add(e);let[n]=Mt({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Ft({...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(M.host(e))),this.restoreHandlers.push(Ht({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){!e.contentWindow||!e.contentDocument||this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){let n=this;this.restoreHandlers.push(j(e.prototype,`attachShadow`,function(e){return function(r){let i=e.call(this,r),a=M.shadowRoot(this);return a&&_t(this)&&n.addShadowRoot(a,t),i}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}},Y=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,tn=typeof Uint8Array>`u`?[]:new Uint8Array(256),nn=0;nn<Y.length;nn++)tn[Y.charCodeAt(nn)]=nn;var rn=function(e){var t=new Uint8Array(e),n,r=t.length,i=``;for(n=0;n<r;n+=3)i+=Y[t[n]>>2],i+=Y[(t[n]&3)<<4|t[n+1]>>4],i+=Y[(t[n+1]&15)<<2|t[n+2]>>6],i+=Y[t[n+2]&63];return r%3==2?i=i.substring(0,i.length-1)+`=`:r%3==1&&(i=i.substring(0,i.length-2)+`==`),i},an=new Map;function on(e,t){let n=an.get(e);return n||(n=new Map,an.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}var sn=(e,t,n)=>{if(!e||!(un(e,t)||typeof e==`object`))return;let r=e.constructor.name,i=on(n,r),a=i.indexOf(e);return a===-1&&(a=i.length,i.push(e)),a};function cn(e,t,n){if(e instanceof Array)return e.map(e=>cn(e,t,n));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:rn(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[cn(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}else if(e instanceof HTMLCanvasElement)return{rr_type:`HTMLImageElement`,src:e.toDataURL()};else if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[cn(e.data,t,n),e.width,e.height]};else if(un(e,t)||typeof e==`object`)return{rr_type:e.constructor.name,index:sn(e,t,n)};return e}var ln=(e,t,n)=>e.map(e=>cn(e,t,n)),un=(e,t)=>!![`WebGLActiveInfo`,`WebGLBuffer`,`WebGLFramebuffer`,`WebGLProgram`,`WebGLRenderbuffer`,`WebGLShader`,`WebGLShaderPrecisionFormat`,`WebGLTexture`,`WebGLUniformLocation`,`WebGLVertexArrayObject`,`WebGLVertexArrayObjectOES`].filter(e=>typeof t[e]==`function`).find(n=>e instanceof t[n]);function dn(e,t,n,r){let i=[],a=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let o of a)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!=`function`)continue;let a=j(t.CanvasRenderingContext2D.prototype,o,function(i){return function(...a){return G(this.canvas,n,r,!0)||setTimeout(()=>{let n=ln(a,t,this);e(this.canvas,{type:c[`2D`],property:o,args:n})},0),i.apply(this,a)}});i.push(a)}catch{let n=et(t.CanvasRenderingContext2D.prototype,o,{set(t){e(this.canvas,{type:c[`2D`],property:o,args:[t],setter:!0})}});i.push(n)}return()=>{i.forEach(e=>e())}}function fn(e){return e===`experimental-webgl`?`webgl`:e}function pn(e,t,n,r){let i=[];try{let a=j(e.HTMLCanvasElement.prototype,`getContext`,function(e){return function(i,...a){if(!G(this,t,n,!0)){let e=fn(i);if(`__context`in this||(this.__context=e),r&&[`webgl`,`webgl2`].includes(e))if(a[0]&&typeof a[0]==`object`){let e=a[0];e.preserveDrawingBuffer||=!0}else a.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[i,...a])}});i.push(a)}catch{console.error(`failed to patch HTMLCanvasElement.prototype.getContext`)}return()=>{i.forEach(e=>e())}}function mn(e,t,n,r,i,a){let o=[],s=Object.getOwnPropertyNames(e);for(let c of s)if(![`isContextLost`,`canvas`,`drawingBufferWidth`,`drawingBufferHeight`].includes(c))try{if(typeof e[c]!=`function`)continue;let s=j(e,c,function(e){return function(...o){let s=e.apply(this,o);if(sn(s,a,this),`tagName`in this.canvas&&!G(this.canvas,r,i,!0)){let e=ln(o,a,this),r={type:t,property:c,args:e};n(this.canvas,r)}return s}});o.push(s)}catch{let r=et(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});o.push(r)}return o}function hn(e,t,n,r){let i=[];return t.WebGLRenderingContext!==void 0&&i.push(...mn(t.WebGLRenderingContext.prototype,c.WebGL,e,n,r,t)),t.WebGL2RenderingContext!==void 0&&i.push(...mn(t.WebGL2RenderingContext.prototype,c.WebGL2,e,n,r,t)),()=>{i.forEach(e=>e())}}var gn=`(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
+ `,_n=typeof self<`u`&&self.Blob&&new Blob([gn],{type:`text/javascript;charset=utf-8`});function vn(e){let t;try{if(t=_n&&(self.URL||self.webkitURL).createObjectURL(_n),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(gn),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var yn=class{constructor(e){r(this,`pendingCanvasMutations`,new Map),r(this,`rafStamps`,{latestId:0,invokeId:null}),r(this,`mirror`),r(this,`mutationCb`),r(this,`resetObservers`),r(this,`frozen`,!1),r(this,`locked`,!1),r(this,`processMutation`,(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});let{sampling:t=`all`,win:n,blockClass:i,blockSelector:a,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&t===`all`&&this.initCanvasMutationObserver(n,i,a),o&&typeof t==`number`&&this.initCanvasFPSObserver(t,n,i,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=pn(t,n,r,!0),o=new Map,s=new vn;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:c[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let l=1e3/e,u=0,d,f=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{G(t,n,r,!0)||e.push(t)}),e},p=e=>{if(u&&e-u<l){d=requestAnimationFrame(p);return}u=e,f().forEach(async e=>{let t=this.mirror.getId(e);if(o.get(t)||e.width===0||e.height===0)return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}let n=await createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])}),d=requestAnimationFrame(p)};d=requestAnimationFrame(p),this.resetObservers=()=>{a(),cancelAnimationFrame(d)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=pn(e,t,n,!1),i=dn(this.processMutation.bind(this),e,t,n),a=hn(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},bn=class{constructor(e){r(this,`trackedLinkElements`,new WeakSet),r(this,`mutationCb`),r(this,`adoptedStyleSheetCb`),r(this,`styleMirror`,new pt),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:I(e,t.href),index:n}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},xn=class{constructor(){r(this,`nodeMap`,new WeakMap),r(this,`active`,!1)}inOtherBuffer(e,t){let n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},X,Sn,Cn,wn=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}var Z=le();function Tn(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o=`rr-block`,blockSelector:s=null,ignoreClass:c=`rr-ignore`,ignoreSelector:l=null,maskTextClass:u=`rr-mask`,maskTextSelector:d=null,inlineStylesheet:f=!0,maskAllInputs:p,maskInputOptions:m,slimDOMOptions:h,maskInputFn:g,maskTextFn:_,hooks:v,packFn:y,sampling:b={},dataURLOptions:x={},mousemoveWait:S,recordDOM:C=!0,recordCanvas:w=!1,recordCrossOriginIframes:ee=!1,recordAfter:T=e.recordAfter===`DOMContentLoaded`?e.recordAfter:`load`,userTriggeredOnInput:E=!1,collectFonts:D=!1,inlineImages:O=!1,plugins:k,keepIframeSrcFn:A=()=>!1,ignoreCSSAttributes:te=new Set([]),errorHandler:ne}=e;kt(ne);let j=!ee||window.parent===window,N=!1;if(!j)try{window.parent.document&&(N=!1)}catch{N=!0}if(j&&!t)throw Error(`emit function is required`);if(!j&&!N)return()=>{};S!==void 0&&b.mousemove===void 0&&(b.mousemove=S),Z.reset();let P=p===!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}:m===void 0?{password:!0}:m,F=qe(h);lt();let ie,ae=0,oe=e=>{for(let t of k||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!N&&(e=y(e)),e};X=(e,o)=>{let s=e;if(s.timestamp=re(),q[0]?.isFrozen()&&s.type!==i.FullSnapshot&&(s.type!==i.IncrementalSnapshot||s.data.source!==a.Mutation)&&q.forEach(e=>e.unfreeze()),j)t?.(oe(s),o);else if(N){let e={type:`rrweb`,event:oe(s),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,`*`)}if(s.type===i.FullSnapshot)ie=s,ae=0;else if(s.type===i.IncrementalSnapshot){if(s.data.source===a.Mutation&&s.data.isAttachIframe)return;ae++;let e=r&&ae>=r,t=n&&s.timestamp-ie.timestamp>n;(e||t)&&Sn(!0)}};let I=e=>{X({type:i.IncrementalSnapshot,data:{source:a.Mutation,...e}})},se=e=>X({type:i.IncrementalSnapshot,data:{source:a.Scroll,...e}}),ce=e=>X({type:i.IncrementalSnapshot,data:{source:a.CanvasMutation,...e}}),L=new bn({mutationCb:I,adoptedStyleSheetCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.AdoptedStyleSheet,...e}})}),R=new $t({mirror:Z,mutationCb:I,stylesheetManager:L,recordCrossOriginIframes:ee,wrappedEmit:X});for(let e of k||[])e.getMirror&&e.getMirror({nodeMirror:Z,crossOriginIframeMirror:R.crossOriginIframeMirror,crossOriginIframeStyleMirror:R.crossOriginIframeStyleMirror});let le=new xn;Cn=new yn({recordCanvas:w,mutationCb:ce,win:window,blockClass:o,blockSelector:s,mirror:Z,sampling:b.canvas,dataURLOptions:x});let z=new en({mutationCb:I,scrollCb:se,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:u,maskTextSelector:d,inlineStylesheet:f,maskInputOptions:P,dataURLOptions:x,maskTextFn:_,maskInputFn:g,recordCanvas:w,inlineImages:O,sampling:b,slimDOMOptions:F,iframeManager:R,stylesheetManager:L,canvasManager:Cn,keepIframeSrcFn:A,processedNodeManager:le},mirror:Z});Sn=(e=!1)=>{if(!C)return;X({type:i.Meta,data:{href:window.location.href,width:rt(),height:nt()}},e),L.reset(),z.init(),q.forEach(e=>e.lock());let t=Xe(document,{mirror:Z,blockClass:o,blockSelector:s,maskTextClass:u,maskTextSelector:d,inlineStylesheet:f,maskAllInputs:P,maskTextFn:_,maskInputFn:g,slimDOM:F,dataURLOptions:x,recordCanvas:w,inlineImages:O,onSerialize:e=>{ut(e,Z)&&R.addIframe(e),dt(e,Z)&&L.trackLinkElement(e),ft(e)&&z.addShadowRoot(M.shadowRoot(e),document)},onIframeLoad:(e,t)=>{R.attachIframe(e,t),z.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{L.attachLinkElement(e,t)},keepIframeSrcFn:A});if(!t)return console.warn(`Failed to snapshot the document`);X({type:i.FullSnapshot,data:{node:t,initialOffset:tt(window)}},e),q.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&L.adoptStyleSheets(document.adoptedStyleSheets,Z.getId(document))};try{let e=[],t=e=>K(Yt)({mutationCb:I,mousemoveCb:(e,t)=>X({type:i.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.MouseInteraction,...e}}),scrollCb:se,viewportResizeCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.ViewportResize,...e}}),inputCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.Input,...e}}),mediaInteractionCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.MediaInteraction,...e}}),styleSheetRuleCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.StyleSheetRule,...e}}),styleDeclarationCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.StyleDeclaration,...e}}),canvasMutationCb:ce,fontCb:e=>X({type:i.IncrementalSnapshot,data:{source:a.Font,...e}}),selectionCb:e=>{X({type:i.IncrementalSnapshot,data:{source:a.Selection,...e}})},customElementCb:e=>{X({type:i.IncrementalSnapshot,data:{source:a.CustomElement,...e}})},blockClass:o,ignoreClass:c,ignoreSelector:l,maskTextClass:u,maskTextSelector:d,maskInputOptions:P,inlineStylesheet:f,sampling:b,recordDOM:C,recordCanvas:w,inlineImages:O,userTriggeredOnInput:E,collectFonts:D,doc:e,maskInputFn:g,maskTextFn:_,keepIframeSrcFn:A,blockSelector:s,slimDOMOptions:F,dataURLOptions:x,mirror:Z,iframeManager:R,stylesheetManager:L,shadowDomManager:z,processedNodeManager:le,canvasManager:Cn,ignoreCSSAttributes:te,plugins:(k?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>X({type:i.Plugin,data:{plugin:e.name,payload:t}})}))||[]},v);R.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});let n=()=>{Sn(),e.push(t(document)),wn=!0};return[`interactive`,`complete`].includes(document.readyState)?n():(e.push(U(`DOMContentLoaded`,()=>{X({type:i.DomContentLoaded,data:{}}),T===`DOMContentLoaded`&&n()})),e.push(U(`load`,()=>{X({type:i.Load,data:{}}),T===`load`&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(`cross-origin`)||console.warn(e)}}),le.destroy(),wn=!1,At()}}catch(e){console.warn(e)}}Tn.addCustomEvent=(e,t)=>{if(!wn)throw Error(`please add custom event after start recording`);X({type:i.Custom,data:{tag:e,payload:t}})},Tn.freezePage=()=>{q.forEach(e=>e.freeze())},Tn.takeFullSnapshot=e=>{if(!wn)throw Error(`please take full snapshot after start recording`);Sn(e)},Tn.mirror=Z;var En=2;function Dn(e,t=e=>e){let n=[],r=0,i=1/0,a=-1/0,o=!1,s=new Set,c=null;function l(){n=[],r=0,i=1/0,a=-1/0,o=!1,s=new Set,c=null}return{push(l){let u=JSON.stringify(l);e.events.push(l),n.push(u),r+=u.length,i=Math.min(i,l.timestamp),a=Math.max(a,l.timestamp),l.type===En&&(o=!0);let d=location.href;d!==c&&(s.add(t(d)),c=d)},bytes:()=>r,take(){if(e.events.length===0)return null;let t={events:e.events,json:`{"events":[${n.join(`,`)}]}`,parts:n,bytes:r,start:i,end:a,hasFullSnapshot:o,urls:[...s]};return e.events=[],l(),t},restore(t){e.events=[...t.events,...e.events],n=[...t.parts,...n],r+=t.bytes,i=Math.min(i,t.start),a=Math.max(a,t.end),o||=t.hasFullSnapshot,s=new Set([...t.urls,...s])}}}var Q={collectorUrl:`https://api.mime8.com`,recorderVersion:`0.1.1`,ignoreUrls:[],maxBodySize:1024*1024,redact:[{header:/authorization|cookie|token|secret|api-?key|forwarded/i},{queryParam:/token|secret|password|api_?key|signature|credential/i},{bodyField:/password|passwd|secret|token|api_?key/i}],earlyUploadBytes:256*1024,uploadInterval:1e4,streamingTypes:[`text/event-stream`,`application/x-ndjson`,`application/jsonl`,`multipart/mixed`,`text/x-component`,`application/grpc-web`,`application/grpc-web+proto`,`application/grpc-web-text`,`application/grpc-web-text+proto`,`application/connect+proto`,`application/connect+json`],mediaTypes:[`image/`,`audio/`,`video/`,`font/`,`application/wasm`]};function On(e){let t=e.network??{},n=t.redact??{};return{...Q,projectKey:e.projectKey,collectorUrl:e.collectorUrl??Q.collectorUrl,ignoreUrls:[...Q.ignoreUrls,...t.ignoreUrls??[]],maxBodySize:t.maxBodySize??Q.maxBodySize,redact:[...Q.redact,...(n.headers??[]).map(e=>({header:e})),...(n.queryParams??[]).map(e=>({queryParam:e})),...(n.bodyFields??[]).map(e=>({bodyField:e}))],beforeRecord:t.beforeRecord,streamingTypes:[...Q.streamingTypes],mediaTypes:[...Q.mediaTypes]}}var kn=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});function An(e){if(typeof e.toBase64==`function`)return e.toBase64();let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function jn(e){try{return{text:kn.decode(e)}}catch{return{base64:An(e)}}}function Mn(e){for(let t=e.length-1;t>=Math.max(0,e.length-3);t--){let n=e[t];if((n&192)==128)continue;let r=n>=240?4:n>=224?3:n>=192?2:1;return e.length-t<r?t:e.length}return e.length}function Nn(e,t){if(e.length===0)return t;let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Pn(){let e=new Uint8Array;return{push(t){let n=Nn(e,t),r=Mn(n);try{let t=kn.decode(n.subarray(0,r));return e=n.slice(r),t?{text:t}:null}catch{return e=new Uint8Array,{base64:An(n)}}},end(){if(e.length===0)return null;let t=jn(e);return e=new Uint8Array,t}}}function Fn(e,t){return e>t.maxBodySize?{omitted:`too-large`,size:e}:null}function In(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<=56319&&n+1<e.length?(t+=4,n++):t+=3}return t}function Ln(e,t){return e.length*3<=t.maxBodySize?null:Fn(In(e),t)}async function Rn(e,t,n=!1){let r=Fn(e.size,t);if(r)return r;let i=new Uint8Array(await e.arrayBuffer());return n?{base64:An(i)}:jn(i)}function zn(e){let t=[];return e.forEach((e,n)=>{t.push(typeof e==`string`?{name:n,value:e}:{name:n,file:{name:e.name,type:e.type,size:e.size}})}),t}function Bn(e,t){if(e!=null){if(typeof e==`string`||e instanceof URLSearchParams){let n=e.toString();return Ln(n,t)??{text:n}}if(e instanceof FormData)return{form:zn(e)};if(e instanceof Blob)return Rn(e,t);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return Fn(n.byteLength,t)??jn(n)}return e instanceof ReadableStream?{omitted:`stream`}:{omitted:`unreadable`}}}function Vn(e){return typeof e==`string`?`text/plain;charset=UTF-8`:e instanceof URLSearchParams?`application/x-www-form-urlencoded;charset=UTF-8`:e instanceof FormData?`multipart/form-data`:e instanceof Blob&&e.type||null}async function Hn(e,t){let n=e.getReader(),r=[],i=0;for(let e=await n.read();!e.done;e=await n.read()){if(i+=e.value.byteLength,i>t)return n.cancel().catch(()=>{}),null;r.push(e.value)}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}function $(e){try{e()}catch{}}function Un(e){return e instanceof Error||e instanceof DOMException?e.message:String(e)}function Wn(e,t,n){let r=e.navigator;if(typeof r.sendBeacon!=`function`)return;let i=r.sendBeacon.bind(r),a=e=>$(()=>t.emit(e));r.sendBeacon=function(e,r){let o=i(e,r);return $(()=>{let i=new URL(String(e),document.baseURI).href;if(t.ignores(i))return;let s=t.nextId(),c=Date.now(),l=Vn(r),u=e=>({type:`http-request`,api:`beacon`,method:`POST`,url:i,headers:l?[[`content-type`,l]]:[],...e?{body:e}:{},queued:o,t:c,id:s}),d=Bn(r,n);if(d instanceof Promise){let e=t.place();d.catch(()=>({omitted:`unreadable`})).then(t=>a({...u(t),n:e}))}else a(u(d))}),o}}function Gn(e,t,n){return n.find(n=>e.matchMedia(`(${t}: ${n})`).matches)??`unknown`}function Kn(e=window){let{navigator:t,screen:n}=e;return{timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,languages:t.languages?[...t.languages]:[t.language],devicePixelRatio:e.devicePixelRatio,userAgent:t.userAgent,colorScheme:e.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,reducedMotion:e.matchMedia(`(prefers-reduced-motion: reduce)`).matches,hover:Gn(e,`hover`,[`hover`,`none`]),anyHover:Gn(e,`any-hover`,[`hover`,`none`]),pointer:Gn(e,`pointer`,[`fine`,`coarse`,`none`]),anyPointer:Gn(e,`any-pointer`,[`fine`,`coarse`,`none`]),maxTouchPoints:t.maxTouchPoints,screen:{width:n.width,height:n.height}}}var qn=`mime8/environment@1`;function Jn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}var Yn=`mime8/keys@1`,Xn=`mime8/network@1`,Zn=`mime8/storage@1`,Qn=`mime8/storage-change@1`;function $n(e,t,n){let r=e=>{try{e()}catch{}},i=e,a=e=>{let t=null;return r(()=>{e===i.localStorage?t=`local`:e===i.sessionStorage&&(t=`session`)}),t},o=i.Storage.prototype,{setItem:s,removeItem:c,clear:l}=o;return o.setItem=function(e,i){let o=Reflect.apply(s,this,arguments);return r(()=>{let r=a(this);if(r){let a=String(i);t({by:`app`,area:r,op:`set`,key:String(e),size:a.length,hash:n(a)})}}),o},o.removeItem=function(e){let n=!1;r(()=>{n=this.getItem(e)!==null});let i=Reflect.apply(c,this,arguments);return r(()=>{let r=a(this);r&&n&&t({by:`app`,area:r,op:`remove`,key:String(e)})}),i},o.clear=function(){let e=!0;r(()=>{e=this.length===0});let n=Reflect.apply(l,this,arguments);return r(()=>{let n=a(this);n&&!e&&t({by:`app`,area:n,op:`clear`})}),n},{setItem:s,removeItem:c,clear:l}}var er=new Set([`Enter`,`Escape`,`Tab`,`Backspace`,`Delete`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),tr=new Set([`button`,`submit`,`reset`,`checkbox`,`radio`]),nr=new Set([`button`,`checkbox`,`switch`,`menuitem`]);function rr(e){return e instanceof Element?e instanceof HTMLButtonElement?!0:e instanceof HTMLInputElement?tr.has(e.type):nr.has(e.getAttribute(`role`)??``):!1}function ir(e,t){if(e.isComposing||e.key===`Process`||e.keyCode===229)return!1;if(er.has(e.key))return!0;let{ctrlKey:n,metaKey:r,altKey:i}=e;if(/^.$/u.test(e.key)){if(e.key===` `&&!n&&!r&&!i)return rr(t);let a=e.getModifierState(`AltGraph`)||n&&i||i&&!r;return(n||r)&&!a}return n||r||i}function ar(e,t,n){let r=e=>$(()=>{let r=e.composedPath()[0];ir(e,r)&&t({type:6,timestamp:Date.now(),data:{plugin:Yn,payload:{key:e.key,code:e.code,alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,repeat:e.repeat,id:r instanceof Node?n(r):null}}})}),i={capture:!0,passive:!0};return e.addEventListener(`keydown`,r,i),()=>e.removeEventListener(`keydown`,r,i)}var or=EventTarget.prototype.addEventListener;function sr(e,t){let n=e.EventSource;if(typeof n!=`function`)return;let r=new WeakMap,i=e=>$(()=>t.emit(e));function a(e,t,n){n===`open`||n===`error`||t.subscribed.has(n)||(t.subscribed.add(n),or.call(e,n,e=>{let r=e;i({type:`sse-message`,event:n,data:String(r.data),lastEventId:r.lastEventId,t:Date.now(),id:t.id})}))}class o extends n{constructor(e,n){super(e,n),$(()=>{if(t.ignores(this.url))return;let e={id:t.nextId(),subscribed:new Set};r.set(this,e);let{id:n}=e;i({type:`sse-connect`,url:this.url,withCredentials:this.withCredentials,t:Date.now(),id:n}),or.call(this,`open`,()=>i({type:`sse-open`,t:Date.now(),id:n})),or.call(this,`error`,()=>i({type:`sse-error`,readyState:this.readyState,t:Date.now(),id:n})),a(this,e,`message`)})}close(){$(()=>{let e=r.get(this);e&&this.readyState!==n.CLOSED&&i({type:`sse-close`,t:Date.now(),id:e.id})}),super.close()}}Object.defineProperty(o.prototype,"addEventListener",{configurable:!0,writable:!0,value:function(e,t,n){$(()=>{let t=r.get(this);t&&a(this,t,e)}),or.call(this,e,t,n)}}),Object.defineProperty(o,"name",{value:`EventSource`}),e.EventSource=o}function cr(e,t){if(!e)return!1;let n=e.split(`;`)[0].trim().toLowerCase();return t.some(e=>e.endsWith(`/`)?n.startsWith(e):e.startsWith(`+`)?n.endsWith(e):n===e)}var lr=new Set([`DELETE`,`GET`,`HEAD`,`OPTIONS`,`POST`,`PUT`]);function ur(e){let t=e.toUpperCase();return lr.has(t)?t:e}function dr(e){return[...e]}function fr(e){return e instanceof DOMException||e instanceof Error?e.name:void 0}function pr(e,t){return fr(e)===`TimeoutError`||fr(t?.reason)===`TimeoutError`?`timeout`:fr(e)===`AbortError`||t?.aborted===!0?`abort`:`network`}async function mr(e,t){if(!e.body)return;let n=await Hn(e.body,t.maxBodySize);if(!n)return{omitted:`too-large`};let r=e.headers.get(`content-type`);if(r?.toLowerCase().startsWith(`multipart/form-data`))try{return{form:zn(await new Response(n,{headers:{"content-type":r}}).formData())}}catch{}return jn(n)}function hr(e){return e!==void 0&&!(e instanceof Headers)&&!Array.isArray(e)&&typeof e[Symbol.iterator]==`function`?new Headers:new Headers(e)}function gr(e,t,n){let r=t?.headers?hr(t.headers):new Headers(e.headers);if(n&&!r.has(`content-type`)){let e=Vn(t?.body);e&&r.set(`content-type`,e)}return r}function _r(e,t,n){if(e instanceof Request){let r=t?.body!==void 0&&t.body!==null,i=r?null:e.clone();return{method:ur(t?.method??e.method),headers:dr(gr(e,t,r)),body:i?mr(i,n):Bn(t?.body,n),signal:t?.signal??e.signal}}let r=hr(t?.headers),i=r.has(`content-type`)?null:Vn(t?.body);return i&&r.set(`content-type`,i),{method:ur(t?.method??`GET`),headers:dr(r),body:Bn(t?.body,n),signal:t?.signal}}function vr(e){return e instanceof Request?e.url:new URL(e instanceof URL?e.href:String(e),document.baseURI).href}function yr(e,t,n){let r=e.fetch;function i(e,r){let i=vr(e);if(t.ignores(i))return null;let a=t.nextId(),o=Date.now(),{method:s,headers:c,body:l,signal:u}=_r(e,r,n),d=e=>$(()=>t.emit(e)),f=e=>({type:`http-request`,api:`fetch`,method:s,url:i,headers:c,...e?{body:e}:{},t:o,id:a});if(l instanceof Promise){let e=t.place();l.catch(()=>void 0).then(t=>d({...f(t),n:e}))}else d(f(l));let p=e=>d({type:`http-error`,reason:pr(e,u),message:Un(e),t:Date.now(),id:a});async function m(e){let t=e.clone();if(!t.body){d({type:`http-end`,t:Date.now(),id:a});return}try{let r=await Hn(t.body,n.maxBodySize);if(r){d({type:`http-end`,body:jn(r),t:Date.now(),id:a});return}let i=Number(e.headers.get(`content-length`));d({type:`http-end`,body:Number.isFinite(i)&&i>0?{omitted:`too-large`,size:i}:{omitted:`too-large`},t:Date.now(),id:a})}catch(e){p(e)}}function h(e,t){let r=Pn(),i=null,o=0,s=!1,c=e=>$(()=>{if(s)return;if(o+=e.byteLength,o>n.maxBodySize){s=!0;return}let t=r.push(e);t&&d({type:`http-chunk`,data:t,t:Date.now(),id:a})}),l=new ReadableStream({type:`bytes`,async pull(e){for(i??=t.getReader();;){let t;try{t=await i.read()}catch(t){p(t),e.error(t);return}if(t.done){$(()=>{let e=s?null:r.end();e&&d({type:`http-chunk`,data:e,t:Date.now(),id:a}),d({type:`http-end`,...s?{truncated:!0}:{},t:Date.now(),id:a})}),e.close();return}if(t.value.byteLength!==0){c(t.value),e.enqueue(new Uint8Array(t.value));return}}},cancel(e){return p(new DOMException(String(e??`cancelled`),`AbortError`)),(i??t).cancel(e)}}),u=new Response(l,{status:e.status,statusText:e.statusText,headers:e.headers});for(let t of[`url`,`redirected`,`type`])Object.defineProperty(u,t,{value:e[t]});return u}return{failed:p,responded(e){if(d({type:`http-response`,status:e.status,statusText:e.statusText,url:e.url||i,redirected:e.redirected,fetchType:e.type,headers:dr(e.headers),t:Date.now(),id:a}),e.type===`opaque`||e.type===`opaqueredirect`){d({type:`http-end`,t:Date.now(),id:a});return}let t=e.headers.get(`content-type`);if(cr(t,n.mediaTypes)){d({type:`http-end`,body:{omitted:`media`},t:Date.now(),id:a});return}if(cr(t,n.streamingTypes)&&e.body)return h(e,e.body);m(e)}}}async function a(t,n){let a=null;$(()=>{a=i(t,n)});let o;try{o=await r.call(e,t,n)}catch(e){let t=a;throw $(()=>t?.failed(e)),e}let s=a,c=o;return $(()=>{c=s?.responded(o)??o}),c}e.fetch=a}var br=[`RTCPeerConnection`,`Worker`,`SharedWorker`,`WebTransport`,`WebSocketStream`];function xr(e,t){for(let n of br){let r=e[n];if(typeof r!=`function`)continue;let i=class extends r{constructor(...e){super(...e),$(()=>{let[r]=e,i=typeof r==`string`||r instanceof URL?new URL(String(r),document.baseURI).href:void 0;t.emit({type:`marker`,api:n,...i?{url:i}:{},t:Date.now()})})}};Object.defineProperty(i,"name",{value:n}),e[n]=i}}function Sr(e,t){return e.lastIndex=0,e.test(t)}function Cr(e,t){return typeof e==`string`?e.toLowerCase()===t.toLowerCase():e instanceof RegExp?Sr(e,t):e(t)}function wr(e,t){return typeof e==`string`?t.startsWith(e):e instanceof RegExp?Sr(e,t):e(t)}var Tr=`[redacted]`;function Er(e){return Tr}function Dr(e){try{return decodeURIComponent(e.replaceAll(`+`,` `))}catch{return e}}function Or(e,t){let n=!1,r=e.split(`&`).map(e=>{let r=e.indexOf(`=`);if(r===-1)return e;let i=e.slice(0,r);return Cr(t,Dr(i))?(n=!0,`${i}=${Er(e.slice(r+1))}`):e});return n?r.join(`&`):e}function kr(e,t,n,r){let i=t=>{for(;/\s/.test(e[t]??``);)t++;return t},a=t=>{for(t++;e[t]!==`"`;t++)e[t]===`\\`&&t++;return t+1},o=e[t];if(o===`"`)return a(t);if(o!==`{`&&o!==`[`){let n=t;for(;n<e.length&&!/[\s,\]}]/.test(e[n]);)n++;return n}let s=o===`{`?`}`:`]`,c=i(t+1);for(;e[c]!==s;){if(o===`{`){let t=a(c),o=JSON.parse(e.slice(c,t));c=i(i(t)+1);let s=kr(e,c,n,r);Cr(r,o)&&n.push([c,s]),c=s}else c=kr(e,c,n,r);c=i(c),e[c]===`,`&&(c=i(c+1))}return c+1}function Ar(e,t){try{JSON.parse(e)}catch{return e}let n=[];if(kr(e,e.search(/\S/),n,t),n.length===0)return e;n.sort((e,t)=>e[0]-t[0]);let r=``,i=0;for(let[t,a]of n)t<i||(r+=`${e.slice(i,t)}"${Tr}"`,i=a);return r+e.slice(i)}var jr=/^[^\s=&]+=[^\s&]*(?:&[^\s=&]+=[^\s&]*)*$/;function Mr(e){return(e.find(([e])=>e===`content-type`)?.[1]??``).split(`;`)[0].trim().toLowerCase()===`application/x-www-form-urlencoded`}function Nr(e,t,n=!1){if(`text`in e){let r=n?Or(e.text,t):Ar(e.text,t);return r===e.text?e:{text:r}}return`form`in e&&e.form.some(e=>Cr(t,e.name))?{form:e.form.map(e=>Cr(t,e.name)?{name:e.name,value:Tr}:e)}:e}var Pr={is:e=>`bodyField`in e,apply(e,t){let n=t.bodyField;switch(e.type){case`http-request`:{if(!e.body)return e;let t=Nr(e.body,n,Mr(e.headers));return t===e.body?e:{...e,body:t}}case`http-end`:{if(!e.body)return e;let t=`text`in e.body&&jr.test(e.body.text),r=Nr(e.body,n,t);return r===e.body?e:{...e,body:r}}case`ws-send`:case`ws-message`:{let t=Nr(e.data,n);return t===e.data?e:{...e,data:t}}case`sse-message`:{let t=Ar(e.data,n);return t===e.data?e:{...e,data:t}}default:return e}}};function Fr(e,t){return e.some(([e])=>Cr(t,e))?e.map(([e,n])=>Cr(t,e)?[e,Er(n)]:[e,n]):e}var Ir={is:e=>`header`in e,apply(e,t){if(e.type!==`http-request`&&e.type!==`http-response`)return e;let n=Fr(e.headers,t.header);return n===e.headers?e:{...e,headers:n}}};function Lr(e,t){let n=e.indexOf(`#`),r=n===-1?e:e.slice(0,n),i=n===-1?null:e.slice(n+1),a=r,o=r.indexOf(`?`);if(o!==-1&&(a=r.slice(0,o+1)+Or(r.slice(o+1),t)),i===null)return a;let s=i.indexOf(`?`),c=i;return s===-1?i.includes(`=`)&&(c=Or(i,t)):c=i.slice(0,s+1)+Or(i.slice(s+1),t),`${a}#${c}`}var Rr={is:e=>`queryParam`in e,apply(e,t){switch(e.type){case`http-request`:case`http-response`:case`sse-connect`:case`ws-connect`:case`marker`:{if(e.url===void 0)return e;let n=Lr(e.url,t.queryParam);return n===e.url?e:{...e,url:n}}default:return e}}},zr=[Ir,Rr,Pr],Br=/^([a-z][a-z\d+.-]*:\/\/[^/?#@:]*:)[^/?#@]*@/i;function Vr(e){return e.replace(Br,`$1${Tr}@`)}function Hr(e,t){let n=e;if(`url`in n&&n.url!==void 0){let e=Vr(n.url);e!==n.url&&(n={...n,url:e})}for(let e of t){let t=zr.find(t=>t.is(e));t&&(n=t.apply(n,e))}return n}function Ur(e,t){let n=Vr(e);for(let e of t)Rr.is(e)&&(n=Lr(n,e.queryParam));return n}function Wr(e,t){let n=0,r=0;return{ignores:t=>e.ignoreUrls.some(e=>wr(e,t)),nextId:()=>r++,place:()=>n++,emit(r){try{let i=Hr(r,e.redact);if(e.beforeRecord&&(i=e.beforeRecord(i)),!i)return;t({...i,n:i.n??n++})}catch{}}}}var Gr=EventTarget.prototype.addEventListener;function Kr(e,t,n){let r=e.WebSocket;if(typeof r!=`function`)return;let i=new WeakMap,a=e=>$(()=>t.emit(e));function o(e){return e>n.maxBodySize?{omitted:`too-large`,size:e}:null}function s(e,r,i){let s=Date.now();if(r instanceof Blob){let o=t.place();Rn(r,n,!0).catch(()=>({omitted:`unreadable`})).then(t=>a({type:e,data:t,t:s,id:i,n:o}));return}let c;if(typeof r==`string`)c=Ln(r,n)??{text:r};else if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)){let e=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength);c=o(e.byteLength)??{base64:An(e)}}else c={omitted:`unreadable`};a({type:e,data:c,t:s,id:i})}class c extends r{constructor(e,n){super(e,n),$(()=>{if(t.ignores(this.url))return;let e={id:t.nextId(),byApp:!1};i.set(this,e);let{id:r}=e;a({type:`ws-connect`,url:this.url,protocols:n===void 0?[]:[n].flat(),t:Date.now(),id:r}),Gr.call(this,`open`,()=>a({type:`ws-open`,protocol:this.protocol,extensions:this.extensions,t:Date.now(),id:r})),Gr.call(this,`message`,e=>$(()=>s(`ws-message`,e.data,r))),Gr.call(this,`close`,t=>{let n=t;a({type:`ws-close`,code:n.code,reason:n.reason,wasClean:n.wasClean,byApp:e.byApp,t:Date.now(),id:r})}),Gr.call(this,`error`,()=>a({type:`ws-error`,t:Date.now(),id:r}))})}send(e){$(()=>{let t=i.get(this);t&&this.readyState===r.OPEN&&s(`ws-send`,e,t.id)}),super.send(e)}close(e,t){$(()=>{let e=i.get(this);e&&(e.byApp=!0)}),super.close(e,t)}}Object.defineProperty(c,"name",{value:`WebSocket`}),e.WebSocket=c}function qr(e,t,n){let r=e=>$(()=>t({type:6,timestamp:Date.now(),data:{plugin:Qn,payload:e}}));$n(e,r,Jn),e.addEventListener(`storage`,t=>$(()=>{if(t.storageArea===e.localStorage)if(t.key===null)r({by:`other-tab`,area:`local`,op:`clear`});else if(t.newValue===null)r({by:`other-tab`,area:`local`,op:`remove`,key:t.key});else{let e=t.newValue.length,i=e>n.maxBodySize?null:t.newValue;r({by:`other-tab`,area:`local`,op:`set`,key:t.key,value:i,size:e})}})),e.cookieStore?.addEventListener(`change`,e=>$(()=>{let{changed:t,deleted:n}=e;for(let e of t)r({by:`cookie`,op:`set`,cookie:Jr(e)});for(let e of n)r({by:`cookie`,op:`remove`,name:e.name??``,domain:e.domain??null,path:e.path??`/`})}))}function Jr(e){let t=e.sameSite===`strict`||e.sameSite===`none`?e.sameSite:`lax`;return{name:e.name??``,value:e.value??``,domain:e.domain??null,path:e.path??`/`,expires:e.expires??null,secure:e.secure??!1,sameSite:t}}function Yr(e){let t=new Headers;for(let[n,r]of e)t.append(n,r);return[...t]}function Xr(e){return e.trim().split(/[\r\n]+/).filter(Boolean).map(e=>{let t=e.indexOf(`:`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]})}function Zr(e){let t=e.indexOf(`#`);return t===-1?e:e.slice(0,t)}function Qr(e,t,n){let r=e.XMLHttpRequest.prototype,{open:i,setRequestHeader:a,send:o}=r,s=new WeakMap,c=new WeakSet,l=e=>$(()=>t.emit(e));function u(e){return e>n.maxBodySize?{omitted:`too-large`,size:e}:null}function d(e,t){t.responded||(t.responded=!0,l({type:`http-response`,status:e.status,statusText:e.statusText,url:e.responseURL||t.url,redirected:!!e.responseURL&&e.responseURL!==Zr(t.url),headers:Yr(Xr(e.getAllResponseHeaders())),t:Date.now(),id:t.id}))}function f(e,t){e.ended||(e.ended=!0,l({type:`http-error`,reason:t,message:``,t:Date.now(),id:e.id}))}function p(e,r){if(r.ended)return;r.ended=!0,d(e,r);let{id:i}=r,a=e=>l({type:`http-end`,body:e,t:Date.now(),id:i});if(cr(e.getResponseHeader(`content-type`),n.mediaTypes)){a({omitted:`media`});return}switch(e.responseType){case``:case`text`:{let t=e.responseText;a(Ln(t,n)??{text:t});return}case`json`:{let r=e.response,a=Date.now(),o=t.place();setTimeout(()=>$(()=>{let e=JSON.stringify(r);l({type:`http-end`,body:Ln(e,n)??{text:e},t:a,id:i,n:o})}));return}case`arraybuffer`:{let t=new Uint8Array(e.response);a(u(t.byteLength)??jn(t));return}case`blob`:{let r=Date.now(),a=t.place();Rn(e.response,n).catch(()=>({omitted:`unreadable`})).then(e=>l({type:`http-end`,body:e,t:r,id:i,n:a}));return}default:a({omitted:`unreadable`})}}function m(e){if(!c.has(e)){c.add(e),e.addEventListener(`readystatechange`,()=>$(()=>{let t=s.get(e);t?.sent&&e.readyState===XMLHttpRequest.HEADERS_RECEIVED&&d(e,t)})),e.addEventListener(`load`,()=>$(()=>{let t=s.get(e);t?.sent&&e.readyState===XMLHttpRequest.DONE&&p(e,t)}));for(let[t,n]of Object.entries({error:`network`,abort:`abort`,timeout:`timeout`}))e.addEventListener(t,()=>$(()=>{let t=s.get(e);t?.sent&&f(t,n)}))}}r.open=function(...e){return $(()=>{let n=s.get(this);n?.sent&&!n.ended&&(this.readyState===XMLHttpRequest.DONE?p(this,n):f(n,`abort`));let[r,i]=e,a=new URL(String(i),document.baseURI).href;s.set(this,t.ignores(a)?null:{id:t.nextId(),method:ur(r),url:a,headers:[],sent:!1,responded:!1,ended:!1})}),Reflect.apply(i,this,e)},r.setRequestHeader=function(e,t){a.call(this,e,t),$(()=>s.get(this)?.headers.push([e.toLowerCase(),t]))},r.send=function(e){return $(()=>{let r=s.get(this);if(!r||r.sent||this.readyState!==XMLHttpRequest.OPENED)return;r.sent=!0;let i=Date.now(),{id:a,method:o,url:c}=r,u=[...r.headers],d=u.some(([e])=>e===`content-type`)?null:Vn(e);d&&u.push([`content-type`,d]);let f=Yr(u);m(this);let p=e=>({type:`http-request`,api:`xhr`,method:o,url:c,headers:f,...e?{body:e}:{},t:i,id:a}),h=Bn(e,n);if(h instanceof Promise){let e=t.place();h.catch(()=>({omitted:`unreadable`})).then(t=>l({...p(t),n:e}))}else l(p(h))}),o.call(this,e)}}function $r(e){return{type:6,timestamp:e.t,data:{plugin:Xn,payload:e}}}function ei(e,t){return{type:6,timestamp:t,data:{plugin:Zn,payload:e}}}function ti(e,t){return{type:6,timestamp:t,data:{plugin:qn,payload:e}}}async function ni(e){let t=new TextEncoder().encode(e),n=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new CompressionStream(`gzip`)).getReader(),r=[],i=0;for(let e=await n.read();!e.done;e=await n.read())r.push(e.value),i+=e.value.byteLength;let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}var ri=64*1024,ii=1024;function ai(e){return e>=400&&e<500&&e!==408&&e!==429}function oi(e,t,n,r){let i=`${e.collectorUrl}/api/projects/${e.projectKey}/sessions/${t}/chunks`,a=0,o=null;async function s(t,o){let s=n.take();if(s)try{let{json:n}=s,c=await ni(n),l={version:1,sequenceNumber:a,sentAt:Date.now(),start:s.start,end:s.end,eventCount:s.events.length,hasFullSnapshot:s.hasFullSnapshot,reason:t,urls:s.urls,recorderVersion:e.recorderVersion,rawBytes:n.length},u=JSON.stringify(l),d=()=>{let e=new FormData;return e.append(`metadata`,new Blob([u],{type:`application/json`})),e.append(`events`,new Blob([c],{type:`application/gzip`})),e},f=o&&c.byteLength+u.length+ii<=ri,p=e=>r(i,{method:`POST`,body:d(),keepalive:e}),m=await p(f).catch(e=>{if(f&&e instanceof TypeError)return p(!1);throw e});if(!m.ok&&!ai(m.status))throw Error(`Collector responded ${m.status}`);a++}catch{n.restore(s)}}async function c(t,r){for(;o;){if(!r)return;await o}o=s(t,r);try{await o}finally{o=null}n.bytes()>=e.earlyUploadBytes&&c(`size`,!1)}return setInterval(()=>{c(`interval`,!1)},e.uploadInterval),{flush:({final:e=!1}={})=>c(e?`hidden`:`interval`,e),notify(){!o&&n.bytes()>=e.earlyUploadBytes&&c(`size`,!1)}}}function si(){let e=crypto.getRandomValues(new Uint8Array(16)),t=Date.now();for(let n=0;n<6;n++)e[n]=Math.floor(t/2**(8*(5-n)))%256;e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var ci=4;function li(){let e=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);if(r!==null){let n=e.getItem(r);n!==null&&t.push({key:r,value:n})}}return t};return{localStorage:window.localStorage?e(localStorage):[],sessionStorage:window.sessionStorage?e(sessionStorage):[],cookies:document.cookie??``}}function ui(e){if(!e?.projectKey)throw Error(`mime8.init: projectKey is required`);if(window.mime8Replay===!0||window.__mime8)return;let t=On(e),n=window.fetch.bind(window);window.__mime8={sessionId:si(),events:[]};let r=e=>Ur(e,t.redact),i=Dn(window.__mime8,r),a=Date.now();i.push(ei(li(),a)),$(()=>i.push(ti(Kn(),a)));let o=oi(t,window.__mime8.sessionId,i,n),s=Wr(t,e=>{i.push($r(e)),o.notify()});yr(window,s,t),Qr(window,s,t),Wn(window,s,t),sr(window,s),Kr(window,s,t),xr(window,s),ar(document,e=>{i.push(e),o.notify()},e=>{let t=Tn.mirror.getId(e);return t>0?t:null}),qr(window,e=>{i.push(e),o.notify()},t),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&o.flush({final:!0})});let c=()=>{Tn({emit(e){e.type===ci&&(e={...e,data:{...e.data,href:r(e.data.href)}}),i.push(e),o.notify()}})};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,c):c()}return e.init=ui,e})({});