@dev-2-dev/websdk-plugin-session-tracker 0.9.3 → 0.9.4

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/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- var e;function t(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function n(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function r(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(o).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function o(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=r(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={}));var s=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function i(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(i=s?s(i):"*".repeat(i.length)),i}var a="__rrweb_original__";var c,l,d=1,h=new RegExp("[^a-z0-9-_:]");function u(){return d++}var g=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,p=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,m=/^(data:)([^,]*),(.*)/i;function f(e,t){return(e||"").replace(g,function(e,n,r,o,s,i){var a,c=r||s||i,l=n||o||"";if(!c)return e;if(!p.test(c))return"url(".concat(l).concat(c).concat(l,")");if(m.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),h=c.split("/");d.pop();for(var u=0,g=h;u<g.length;u++){var f=g[u];"."!==f&&(".."===f?d.pop():d.push(f))}return"url(".concat(l).concat(d.join("/")).concat(l,")")})}var I=/^[^ \t\n\r\u000c]+/,C=/^[, \t\n\r\u000c]+/;function y(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function v(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function S(){var e=document.createElement("a");return e.href="",e.href}function b(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?y(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(C),!(n>=t.length);){var s=r(I);if(","===s.slice(-1))s=y(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=y(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?f(r,S()):"object"===t&&"data"===n&&r?y(e,r):r:y(e,r)}function A(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&A(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&A(e.parentNode,t,n)}function k(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(A(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function w(t,n){var o=n.doc,s=n.mirror,d=n.blockClass,u=n.blockSelector,g=n.maskTextClass,p=n.maskTextSelector,m=n.inlineStylesheet,I=n.maskInputOptions,C=void 0===I?{}:I,y=n.maskTextFn,A=n.maskInputFn,w=n.dataURLOptions,M=void 0===w?{}:w,T=n.inlineImages,R=n.recordCanvas,E=n.keepIframeSrcFn,N=n.newlyAddedElement,x=void 0!==N&&N,F=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(o,s);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.Document,childNodes:[],compatMode:t.compatMode}:{type:e.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:e.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:F};case t.ELEMENT_NODE:return function(t,n){for(var o=n.doc,s=n.blockClass,d=n.blockSelector,u=n.inlineStylesheet,g=n.maskInputOptions,p=void 0===g?{}:g,m=n.maskInputFn,I=n.dataURLOptions,C=void 0===I?{}:I,y=n.inlineImages,A=n.recordCanvas,k=n.keepIframeSrcFn,w=n.newlyAddedElement,M=void 0!==w&&w,T=n.rootId,R=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&e.matches(n)}(t,s,d),E=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return h.test(t)?"div":t}(t),N={},x=t.attributes.length,F=0;F<x;F++){var O=t.attributes[F];N[O.name]=b(o,E,O.name,O.value)}if("link"===E&&u){var D=Array.from(o.styleSheets).find(function(e){return e.href===t.href}),B=null;D&&(B=r(D)),B&&(delete N.rel,delete N.href,N._cssText=f(B,D.href))}if("style"===E&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){(B=r(t.sheet))&&(N._cssText=f(B,S()))}if("input"===E||"textarea"===E||"select"===E){var L=t.value,U=t.checked;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&L?N.value=i({type:N.type,tagName:E,value:L,maskInputOptions:p,maskInputFn:m}):U&&(N.checked=U)}"option"===E&&(t.selected&&!p.select?N.selected=!0:delete N.selected);if("canvas"===E&&A)if("2d"===t.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,s=a in o?o[a]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(t)||(N.rr_dataURL=t.toDataURL(C.type,C.quality));else if(!("__context"in t)){var W=t.toDataURL(C.type,C.quality),Z=document.createElement("canvas");Z.width=t.width,Z.height=t.height,W!==Z.toDataURL(C.type,C.quality)&&(N.rr_dataURL=W)}if("img"===E&&y){c||(c=o.createElement("canvas"),l=c.getContext("2d"));var G=t,V=G.crossOrigin;G.crossOrigin="anonymous";var K=function(){try{c.width=G.naturalWidth,c.height=G.naturalHeight,l.drawImage(G,0,0),N.rr_dataURL=c.toDataURL(C.type,C.quality)}catch(e){}V?N.crossOrigin=V:G.removeAttribute("crossorigin")};G.complete&&0!==G.naturalWidth?K():G.onload=K}"audio"!==E&&"video"!==E||(N.rr_mediaState=t.paused?"paused":"played",N.rr_mediaCurrentTime=t.currentTime);M||(t.scrollLeft&&(N.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(N.rr_scrollTop=t.scrollTop));if(R){var _=t.getBoundingClientRect(),z=_.width,Y=_.height;N={class:N.class,rr_width:"".concat(z,"px"),rr_height:"".concat(Y,"px")}}"iframe"!==E||k(N.src)||(t.contentDocument||(N.rr_src=N.src),delete N.src);return{type:e.Element,tagName:E,attributes:N,childNodes:[],isSVG:v(t)||void 0,needBlock:R,rootId:T}}(t,{doc:o,blockClass:d,blockSelector:u,inlineStylesheet:m,maskInputOptions:C,maskInputFn:A,dataURLOptions:M,inlineImages:T,recordCanvas:R,keepIframeSrcFn:E,newlyAddedElement:x,rootId:F});case t.TEXT_NODE:return function(t,n){var r,o=n.maskTextClass,s=n.maskTextSelector,i=n.maskTextFn,a=n.rootId,c=t.parentNode&&t.parentNode.tagName,l=t.textContent,d="STYLE"===c||void 0,h="SCRIPT"===c||void 0;if(d&&l){try{t.nextSibling||t.previousSibling||(null===(r=t.parentNode.sheet)||void 0===r?void 0:r.cssRules)&&(l=(u=t.parentNode.sheet).cssRules?Array.from(u.cssRules).map(function(e){return e.cssText||""}).join(""):"")}catch(e){}l=f(l,S())}var u;h&&(l="SCRIPT_PLACEHOLDER");!d&&!h&&l&&k(t,o,s)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:e.Text,textContent:l||"",isStyle:d,rootId:a}}(t,{maskTextClass:g,maskTextSelector:p,maskTextFn:y,rootId:F});case t.CDATA_SECTION_NODE:return{type:e.CDATA,textContent:"",rootId:F};case t.COMMENT_NODE:return{type:e.Comment,textContent:t.textContent||"",rootId:F};default:return!1}}function M(e){return void 0===e?"":e.toLowerCase()}function T(r,o){var s,i=o.doc,a=o.mirror,c=o.blockClass,l=o.blockSelector,d=o.maskTextClass,h=o.maskTextSelector,g=o.skipChild,p=void 0!==g&&g,m=o.inlineStylesheet,f=void 0===m||m,I=o.maskInputOptions,C=void 0===I?{}:I,y=o.maskTextFn,v=o.maskInputFn,S=o.slimDOMOptions,b=o.dataURLOptions,A=void 0===b?{}:b,k=o.inlineImages,R=void 0!==k&&k,E=o.recordCanvas,N=void 0!==E&&E,x=o.onSerialize,F=o.onIframeLoad,O=o.iframeLoadTimeout,D=void 0===O?5e3:O,B=o.onStylesheetLoad,L=o.stylesheetLoadTimeout,U=void 0===L?5e3:L,W=o.keepIframeSrcFn,Z=void 0===W?function(){return!1}:W,G=o.newlyAddedElement,V=void 0!==G&&G,K=o.preserveWhiteSpace,_=void 0===K||K,z=w(r,{doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,dataURLOptions:A,inlineImages:R,recordCanvas:N,keepIframeSrcFn:Z,newlyAddedElement:V});if(!z)return null;s=a.hasNode(r)?a.getId(r):!function(t,n){if(n.comment&&t.type===e.Comment)return!0;if(t.type===e.Element){if(n.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(n.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(M(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===M(t.attributes.name)||"icon"===M(t.attributes.rel)||"apple-touch-icon"===M(t.attributes.rel)||"shortcut icon"===M(t.attributes.rel))))return!0;if("meta"===t.tagName){if(n.headMetaDescKeywords&&M(t.attributes.name).match(/^description|keywords$/))return!0;if(n.headMetaSocial&&(M(t.attributes.property).match(/^(og|twitter|fb):/)||M(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===M(t.attributes.name)))return!0;if(n.headMetaRobots&&("robots"===M(t.attributes.name)||"googlebot"===M(t.attributes.name)||"bingbot"===M(t.attributes.name)))return!0;if(n.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(n.headMetaAuthorship&&("author"===M(t.attributes.name)||"generator"===M(t.attributes.name)||"framework"===M(t.attributes.name)||"publisher"===M(t.attributes.name)||"progid"===M(t.attributes.name)||M(t.attributes.property).match(/^article:/)||M(t.attributes.property).match(/^product:/)))return!0;if(n.headMetaVerification&&("google-site-verification"===M(t.attributes.name)||"yandex-verification"===M(t.attributes.name)||"csrf-token"===M(t.attributes.name)||"p:domain_verify"===M(t.attributes.name)||"verify-v1"===M(t.attributes.name)||"verification"===M(t.attributes.name)||"shopify-checkout-api-token"===M(t.attributes.name)))return!0}}return!1}(z,S)&&(_||z.type!==e.Text||z.isStyle||z.textContent.replace(/^\s+|\s+$/gm,"").length)?u():-2;var Y=Object.assign(z,{id:s});if(a.add(r,Y),-2===s)return null;x&&x(r);var J=!p;if(Y.type===e.Element){J=J&&!Y.needBlock,delete Y.needBlock;var Q=r.shadowRoot;Q&&n(Q)&&(Y.isShadowHost=!0)}if((Y.type===e.Document||Y.type===e.Element)&&J){S.headWhitespace&&Y.type===e.Element&&"head"===Y.tagName&&(_=!1);for(var P={doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:p,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:B,stylesheetLoadTimeout:U,keepIframeSrcFn:Z},H=0,X=Array.from(r.childNodes);H<X.length;H++){($=T(X[H],P))&&Y.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(r)&&r.shadowRoot)for(var j=0,q=Array.from(r.shadowRoot.childNodes);j<q.length;j++){var $;($=T(q[j],P))&&(n(r.shadowRoot)&&($.isShadow=!0),Y.childNodes.push($))}}return r.parentNode&&t(r.parentNode)&&n(r.parentNode)&&(Y.isShadow=!0),Y.type===e.Element&&"iframe"===Y.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){s||(t(),s=!0)},n);e.addEventListener("load",function(){clearTimeout(a),s=!0,t()})}}}(r,function(){var e=r.contentDocument;if(e&&F){var t=T(e,{doc:e,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:B,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});t&&F(r,t)}},D),Y.type===e.Element&&"link"===Y.tagName&&"stylesheet"===Y.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout(function(){o||(t(),o=!0)},n);e.addEventListener("load",function(){clearTimeout(s),o=!0,t()})}}(r,function(){if(B){var e=T(r,{doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:B,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});e&&B(r,e)}},U),Y}function R(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}let E={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function N(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)},a))}}function x(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),s&&s.set&&s.set.call(this,e)}}),()=>x(e,t,s||{},!0)}function F(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function O(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function D(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function B(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(A(o,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function L(e,t){return-2===t.getId(e)}function U(e,n){if(t(e))return!1;const r=n.getId(e);return!n.has(r)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||U(e.parentNode,n))}function W(e){return Boolean(e.changedTouches)}function Z(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function G(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function V(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(E=new Proxy(E,{get:(e,t,n)=>Reflect.get(e,t,n)}));class K{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var _=(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))(_||{}),z=(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))(z||{}),Y=(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))(Y||{}),J=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(J||{});function Q(e){return"__ln"in e}class P{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Q(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Q(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const H=(e,t)=>`${e}@${t}`;class X{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],n=new P,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var s,i,a,c;let l=null;(null===(i=null===(s=o.getRootNode)||void 0===s?void 0:s.call(o))||void 0===i?void 0:i.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(l=o.getRootNode().host);let d=l;for(;(null===(c=null===(a=null==d?void 0:d.getRootNode)||void 0===a?void 0:a.call(d))||void 0===c?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&d.getRootNode().host;)d=d.getRootNode().host;const h=!(this.doc.contains(o)||d&&this.doc.contains(d));if(!o.parentNode||h)return;const u=t(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),g=r(o);if(-1===u||-1===g)return n.addNode(o);const p=T(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Z(e,this.mirror)&&this.iframeManager.addIframe(e),G(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),V(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});p&&e.push({parentId:u,nextId:g,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))q(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ee(this.droppedSet,e)||q(this.removes,e,this.mirror)?ee(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=r(s.value);-1!==t&&-1!==n&&(e=s)}if(!e)for(let t=n.length-1;t>=0;t--){const o=n.get(t);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===r(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=o;break}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}s=e.previous,n.removeNode(e.value),o(e.value)}const i={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!L(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;B(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:k(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=i({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),B(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find(t=>t.node===e.target);if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const o=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(o[e]=""===s?r:[r,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o[e]=!1)}else r.attributes[e.attributeName]=b(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(B(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(r=>{const o=this.mirror.getId(r),s=t(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);B(e.target,this.blockClass,this.blockSelector,!1)||L(r,this.mirror)||!function(e,t){return-1!==t.getId(e)}(r,this.mirror)||(this.addedSet.has(r)?(j(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(e.target)&&-1===o||U(e.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[H(o,s)]?j(this.movedSet,r):this.removes.push({parentId:s,id:o,isShadow:!(!t(e.target)||!n(e.target))||void 0})),this.mapRemoves.push(r))})}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(L(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[H(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);B(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(e=>this.genAdds(e))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function j(e,t){e.delete(t),t.childNodes.forEach(t=>j(e,t))}function q(e,t,n){return 0!==e.length&&$(e,t,n)}function $(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some(e=>e.id===o)||$(e,r,n)}function ee(e,t){return 0!==e.size&&te(e,t)}function te(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||te(e,n))}const ne=[],re="undefined"!=typeof CSSGroupingRule,oe="undefined"!=typeof CSSMediaRule,se="undefined"!=typeof CSSSupportsRule,ie="undefined"!=typeof CSSConditionRule;function ae(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ce(e,t){var n,r;const o=new X;ne.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function le({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(Y).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]).forEach(s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=ae(s);if(B(i,r,o,!0))return;const a=W(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:Y[t],id:c,x:l,y:d})})(s);a.push(R(i,c,t))}),()=>{a.forEach(e=>e())}}function de({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return R("scroll",N(s=>{const i=ae(s);if(!i||B(i,r,o,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})},s.scroll||100),t)}function he(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ue=["INPUT","TEXTAREA","SELECT"],ge=new WeakMap;function pe(e){return function(e,t){if(re&&e.parentRule instanceof CSSGroupingRule||oe&&e.parentRule instanceof CSSMediaRule||se&&e.parentRule instanceof CSSSupportsRule||ie&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function me(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function fe({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ie(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:g}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),h(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),u(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),g(...e)}}(e,t);const r=ce(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=N(t=>{const n=Date.now()-i;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],i=null},s),l=N(e=>{const t=ae(e),{clientX:n,clientY:o}=W(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?z.Drag:e instanceof MouseEvent?z.MouseMove:z.TouchMove)},o,{trailing:!1}),d=[R("mousemove",l,n),R("touchmove",l,n),R("drag",l,n)];return()=>{d.forEach(e=>e())}}(e),s=le(e),a=de(e),c=function({viewportResizeCb:e}){let t=-1,n=-1;return R("resize",N(()=>{const r=O(),o=D();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)},200),window)}(e),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function h(e){let n=ae(e);const l=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ue.indexOf(n.tagName)<0||B(n,r,o,!0))return;const h=n.type;if(n.classList.contains(s))return;let g=n.value,p=!1;"radio"===h||"checkbox"===h?p=n.checked:(a[n.tagName.toLowerCase()]||a[h])&&(g=i({maskInputOptions:a,tagName:n.tagName,type:h,value:g,maskInputFn:c})),u(n,he({text:g,isChecked:p,userTriggered:l},d));const m=n.name;"radio"===h&&m&&p&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach(e=>{e!==n&&u(e,he({text:e.value,isChecked:!p,userTriggered:!1},d))})}function u(t,r){const o=ge.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){ge.set(t,r);const o=n.getId(t);e(Object.assign(Object.assign({},r),{id:o}))}}const g=("last"===l.input?["change"]:["input","change"]).map(e=>R(e,h,t)),p=t.defaultView;if(!p)return()=>{g.forEach(e=>e())};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),f=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&g.push(...f.map(e=>x(e[0],e[1],{set(){h({target:this})}},!1,p))),()=>{g.forEach(e=>e())}}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=s=>N(o=>{const i=ae(o);if(!i||B(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})},o.media||500),i=[R("play",s(0)),R("pause",s(1)),R("seeked",s(2)),R("volumechange",s(3)),R("ratechange",s(4))];return()=>{i.forEach(e=>e())}}(e),h=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,s){const{id:i,styleId:a}=me(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:s}]}),o.apply(this,[r,s])};const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:o,styleId:i}=me(this,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:r}]}),s.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:o,styleId:s}=me(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:o,styleId:s}=me(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replaceSync:r}),a.apply(this,[r])});const c={};re?c.CSSGroupingRule=r.CSSGroupingRule:(oe&&(c.CSSMediaRule=r.CSSMediaRule),ie&&(c.CSSConditionRule=r.CSSConditionRule),se&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=function(o,s){const{id:i,styleId:a}=me(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:[...pe(this),s||0]}]}),l[r].insertRule.apply(this,[o,s])},o.prototype.deleteRule=function(o){const{id:s,styleId:i}=me(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...pe(this),o]}]}),l[r].deleteRule.apply(this,[o])}}),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}}(e,{win:n}),u=fe(e,e.doc),g=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(o,i,a){var c;if(n.has(o))return s.apply(this,[o,i,a]);const{id:l,styleId:d}=me(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:o,value:i,priority:a},index:pe(this.parentRule)}),s.apply(this,[o,i,a])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(o){var s;if(n.has(o))return i.apply(this,[o]);const{id:a,styleId:c}=me(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:o},index:pe(this.parentRule)}),i.apply(this,[o])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=F(t.fonts,"add",function(t){return function(n){return setTimeout(()=>{const t=o.get(n);t&&(e(t),o.delete(n))},0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=s}),r.push(i),()=>{r.forEach(e=>e())}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=s;B(i,r,o,!0)||B(l,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),R("selectionchange",a)}(e),f=[];for(const t of e.plugins)f.push(t.observer(t.callback,n,t.options));return()=>{ne.forEach(e=>e.reset()),r.disconnect(),o(),s(),a(),c(),l(),d(),h(),u(),g(),p(),m(),f.forEach(e=>e())}}class Ce{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class ye{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Ce(u),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ce(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case _.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:_.IncrementalSnapshot,data:{source:z.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case _.Meta:case _.Load:case _.DomContentLoaded:return!1;case _.Plugin:return t;case _.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case _.IncrementalSnapshot:switch(t.data.source){case z.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case z.Drag:case z.TouchMove:case z.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case z.ViewportResize:return!1;case z.MediaInteraction:case z.MouseInteraction:case z.Scroll:case z.CanvasMutation:case z.Input:return this.replaceIds(t.data,e,["id"]),t;case z.StyleSheetRule:case z.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case z.Font:return t;case z.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case z.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}}class ve{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(F(Element.prototype,"attachShadow",function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}}))}addShadowRoot(e,t){n(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ce(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),de(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),fe({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)},0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(F(e.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(r){const o=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),o}}))}}reset(){this.restorePatches.forEach(e=>e()),this.shadowDoms=new WeakSet}}
1
+ var e;function t(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function n(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function r(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(s).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function s(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=r(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={}));var o=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function i(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,s=e.value,o=e.maskInputFn,i=s||"";return(t[n.toLowerCase()]||t[r])&&(i=o?o(i):"*".repeat(i.length)),i}var a="__rrweb_original__";var c,l,d=1,h=new RegExp("[^a-z0-9-_:]");function u(){return d++}var g=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,p=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,m=/^(data:)([^,]*),(.*)/i;function f(e,t){return(e||"").replace(g,function(e,n,r,s,o,i){var a,c=r||o||i,l=n||s||"";if(!c)return e;if(!p.test(c))return"url(".concat(l).concat(c).concat(l,")");if(m.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),h=c.split("/");d.pop();for(var u=0,g=h;u<g.length;u++){var f=g[u];"."!==f&&(".."===f?d.pop():d.push(f))}return"url(".concat(l).concat(d.join("/")).concat(l,")")})}var I=/^[^ \t\n\r\u000c]+/,C=/^[, \t\n\r\u000c]+/;function y(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function v(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function S(){var e=document.createElement("a");return e.href="",e.href}function b(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?y(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,s=e.exec(t.substring(n));return s?(r=s[0],n+=r.length,r):""}for(var s=[];r(C),!(n>=t.length);){var o=r(I);if(","===o.slice(-1))o=y(e,o.substring(0,o.length-1)),s.push(o);else{var i="";o=y(e,o);for(var a=!1;;){var c=t.charAt(n);if(""===c){s.push((o+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,s.push((o+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return s.join(", ")}(e,r):"style"===n&&r?f(r,S()):"object"===t&&"data"===n&&r?y(e,r):r:y(e,r)}function A(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&A(e.parentNode,t,n);for(var r=e.classList.length;r--;){var s=e.classList[r];if(t.test(s))return!0}return!!n&&A(e.parentNode,t,n)}function k(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(A(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function w(t,n){var s=n.doc,o=n.mirror,d=n.blockClass,u=n.blockSelector,g=n.maskTextClass,p=n.maskTextSelector,m=n.inlineStylesheet,I=n.maskInputOptions,C=void 0===I?{}:I,y=n.maskTextFn,A=n.maskInputFn,w=n.dataURLOptions,M=void 0===w?{}:w,T=n.inlineImages,R=n.recordCanvas,E=n.keepIframeSrcFn,N=n.newlyAddedElement,x=void 0!==N&&N,F=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(s,o);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.Document,childNodes:[],compatMode:t.compatMode}:{type:e.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:e.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:F};case t.ELEMENT_NODE:return function(t,n){for(var s=n.doc,o=n.blockClass,d=n.blockSelector,u=n.inlineStylesheet,g=n.maskInputOptions,p=void 0===g?{}:g,m=n.maskInputFn,I=n.dataURLOptions,C=void 0===I?{}:I,y=n.inlineImages,A=n.recordCanvas,k=n.keepIframeSrcFn,w=n.newlyAddedElement,M=void 0!==w&&w,T=n.rootId,R=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var s=e.classList[r];if(t.test(s))return!0}return!!n&&e.matches(n)}(t,o,d),E=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return h.test(t)?"div":t}(t),N={},x=t.attributes.length,F=0;F<x;F++){var O=t.attributes[F];N[O.name]=b(s,E,O.name,O.value)}if("link"===E&&u){var D=Array.from(s.styleSheets).find(function(e){return e.href===t.href}),L=null;D&&(L=r(D)),L&&(delete N.rel,delete N.href,N._cssText=f(L,D.href))}if("style"===E&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){(L=r(t.sheet))&&(N._cssText=f(L,S()))}if("input"===E||"textarea"===E||"select"===E){var B=t.value,U=t.checked;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&B?N.value=i({type:N.type,tagName:E,value:B,maskInputOptions:p,maskInputFn:m}):U&&(N.checked=U)}"option"===E&&(t.selected&&!p.select?N.selected=!0:delete N.selected);if("canvas"===E&&A)if("2d"===t.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var s=t.getImageData,o=a in s?s[a]:s;if(new Uint32Array(o.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(t)||(N.rr_dataURL=t.toDataURL(C.type,C.quality));else if(!("__context"in t)){var W=t.toDataURL(C.type,C.quality),Z=document.createElement("canvas");Z.width=t.width,Z.height=t.height,W!==Z.toDataURL(C.type,C.quality)&&(N.rr_dataURL=W)}if("img"===E&&y){c||(c=s.createElement("canvas"),l=c.getContext("2d"));var G=t,V=G.crossOrigin;G.crossOrigin="anonymous";var K=function(){try{c.width=G.naturalWidth,c.height=G.naturalHeight,l.drawImage(G,0,0),N.rr_dataURL=c.toDataURL(C.type,C.quality)}catch(e){}V?N.crossOrigin=V:G.removeAttribute("crossorigin")};G.complete&&0!==G.naturalWidth?K():G.onload=K}"audio"!==E&&"video"!==E||(N.rr_mediaState=t.paused?"paused":"played",N.rr_mediaCurrentTime=t.currentTime);M||(t.scrollLeft&&(N.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(N.rr_scrollTop=t.scrollTop));if(R){var _=t.getBoundingClientRect(),z=_.width,Y=_.height;N={class:N.class,rr_width:"".concat(z,"px"),rr_height:"".concat(Y,"px")}}"iframe"!==E||k(N.src)||(t.contentDocument||(N.rr_src=N.src),delete N.src);return{type:e.Element,tagName:E,attributes:N,childNodes:[],isSVG:v(t)||void 0,needBlock:R,rootId:T}}(t,{doc:s,blockClass:d,blockSelector:u,inlineStylesheet:m,maskInputOptions:C,maskInputFn:A,dataURLOptions:M,inlineImages:T,recordCanvas:R,keepIframeSrcFn:E,newlyAddedElement:x,rootId:F});case t.TEXT_NODE:return function(t,n){var r,s=n.maskTextClass,o=n.maskTextSelector,i=n.maskTextFn,a=n.rootId,c=t.parentNode&&t.parentNode.tagName,l=t.textContent,d="STYLE"===c||void 0,h="SCRIPT"===c||void 0;if(d&&l){try{t.nextSibling||t.previousSibling||(null===(r=t.parentNode.sheet)||void 0===r?void 0:r.cssRules)&&(l=(u=t.parentNode.sheet).cssRules?Array.from(u.cssRules).map(function(e){return e.cssText||""}).join(""):"")}catch(e){}l=f(l,S())}var u;h&&(l="SCRIPT_PLACEHOLDER");!d&&!h&&l&&k(t,s,o)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:e.Text,textContent:l||"",isStyle:d,rootId:a}}(t,{maskTextClass:g,maskTextSelector:p,maskTextFn:y,rootId:F});case t.CDATA_SECTION_NODE:return{type:e.CDATA,textContent:"",rootId:F};case t.COMMENT_NODE:return{type:e.Comment,textContent:t.textContent||"",rootId:F};default:return!1}}function M(e){return void 0===e?"":e.toLowerCase()}function T(r,s){var o,i=s.doc,a=s.mirror,c=s.blockClass,l=s.blockSelector,d=s.maskTextClass,h=s.maskTextSelector,g=s.skipChild,p=void 0!==g&&g,m=s.inlineStylesheet,f=void 0===m||m,I=s.maskInputOptions,C=void 0===I?{}:I,y=s.maskTextFn,v=s.maskInputFn,S=s.slimDOMOptions,b=s.dataURLOptions,A=void 0===b?{}:b,k=s.inlineImages,R=void 0!==k&&k,E=s.recordCanvas,N=void 0!==E&&E,x=s.onSerialize,F=s.onIframeLoad,O=s.iframeLoadTimeout,D=void 0===O?5e3:O,L=s.onStylesheetLoad,B=s.stylesheetLoadTimeout,U=void 0===B?5e3:B,W=s.keepIframeSrcFn,Z=void 0===W?function(){return!1}:W,G=s.newlyAddedElement,V=void 0!==G&&G,K=s.preserveWhiteSpace,_=void 0===K||K,z=w(r,{doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,dataURLOptions:A,inlineImages:R,recordCanvas:N,keepIframeSrcFn:Z,newlyAddedElement:V});if(!z)return null;o=a.hasNode(r)?a.getId(r):!function(t,n){if(n.comment&&t.type===e.Comment)return!0;if(t.type===e.Element){if(n.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(n.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(M(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===M(t.attributes.name)||"icon"===M(t.attributes.rel)||"apple-touch-icon"===M(t.attributes.rel)||"shortcut icon"===M(t.attributes.rel))))return!0;if("meta"===t.tagName){if(n.headMetaDescKeywords&&M(t.attributes.name).match(/^description|keywords$/))return!0;if(n.headMetaSocial&&(M(t.attributes.property).match(/^(og|twitter|fb):/)||M(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===M(t.attributes.name)))return!0;if(n.headMetaRobots&&("robots"===M(t.attributes.name)||"googlebot"===M(t.attributes.name)||"bingbot"===M(t.attributes.name)))return!0;if(n.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(n.headMetaAuthorship&&("author"===M(t.attributes.name)||"generator"===M(t.attributes.name)||"framework"===M(t.attributes.name)||"publisher"===M(t.attributes.name)||"progid"===M(t.attributes.name)||M(t.attributes.property).match(/^article:/)||M(t.attributes.property).match(/^product:/)))return!0;if(n.headMetaVerification&&("google-site-verification"===M(t.attributes.name)||"yandex-verification"===M(t.attributes.name)||"csrf-token"===M(t.attributes.name)||"p:domain_verify"===M(t.attributes.name)||"verify-v1"===M(t.attributes.name)||"verification"===M(t.attributes.name)||"shopify-checkout-api-token"===M(t.attributes.name)))return!0}}return!1}(z,S)&&(_||z.type!==e.Text||z.isStyle||z.textContent.replace(/^\s+|\s+$/gm,"").length)?u():-2;var Y=Object.assign(z,{id:o});if(a.add(r,Y),-2===o)return null;x&&x(r);var J=!p;if(Y.type===e.Element){J=J&&!Y.needBlock,delete Y.needBlock;var Q=r.shadowRoot;Q&&n(Q)&&(Y.isShadowHost=!0)}if((Y.type===e.Document||Y.type===e.Element)&&J){S.headWhitespace&&Y.type===e.Element&&"head"===Y.tagName&&(_=!1);for(var P={doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:p,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:L,stylesheetLoadTimeout:U,keepIframeSrcFn:Z},H=0,X=Array.from(r.childNodes);H<X.length;H++){($=T(X[H],P))&&Y.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(r)&&r.shadowRoot)for(var j=0,q=Array.from(r.shadowRoot.childNodes);j<q.length;j++){var $;($=T(q[j],P))&&(n(r.shadowRoot)&&($.isShadow=!0),Y.childNodes.push($))}}return r.parentNode&&t(r.parentNode)&&n(r.parentNode)&&(Y.isShadow=!0),Y.type===e.Element&&"iframe"===Y.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var s,o=!1;try{s=r.document.readyState}catch(e){return}if("complete"===s){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){o||(t(),o=!0)},n);e.addEventListener("load",function(){clearTimeout(a),o=!0,t()})}}}(r,function(){var e=r.contentDocument;if(e&&F){var t=T(e,{doc:e,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:L,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});t&&F(r,t)}},D),Y.type===e.Element&&"link"===Y.tagName&&"stylesheet"===Y.attributes.rel&&function(e,t,n){var r,s=!1;try{r=e.sheet}catch(e){return}if(!r){var o=setTimeout(function(){s||(t(),s=!0)},n);e.addEventListener("load",function(){clearTimeout(o),s=!0,t()})}}(r,function(){if(L){var e=T(r,{doc:i,mirror:a,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:R,recordCanvas:N,preserveWhiteSpace:_,onSerialize:x,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:L,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});e&&L(r,e)}},U),Y}function R(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}let E={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function N(e,t,n={}){let r=null,s=0;return function(...o){const i=Date.now();s||!1!==n.leading||(s=i);const a=t-(i-s),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),s=i,e.apply(c,o)):r||!1===n.trailing||(r=setTimeout(()=>{s=!1===n.leading?0:Date.now(),r=null,e.apply(c,o)},a))}}function x(e,t,n,r,s=window){const o=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),o&&o.set&&o.set.call(this,e)}}),()=>x(e,t,o||{},!0)}function F(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],s=n(r);return"function"==typeof s&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}function O(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function D(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function L(e,t,n,r){if(!e)return!1;const s=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!s)return!1;if("string"==typeof t){if(s.classList.contains(t))return!0;if(r&&null!==s.closest("."+t))return!0}else if(A(s,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==s.closest(n))return!0}return!1}function B(e,t){return-2===t.getId(e)}function U(e,n){if(t(e))return!1;const r=n.getId(e);return!n.has(r)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||U(e.parentNode,n))}function W(e){return Boolean(e.changedTouches)}function Z(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function G(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function V(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(E=new Proxy(E,{get:(e,t,n)=>Reflect.get(e,t,n)}));class K{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var _=(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))(_||{}),z=(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))(z||{}),Y=(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))(Y||{}),J=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(J||{});function Q(e){return"__ln"in e}class P{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Q(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Q(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const H=(e,t)=>`${e}@${t}`;class X{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],n=new P,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},s=s=>{var o,i,a,c;let l=null;(null===(i=null===(o=s.getRootNode)||void 0===o?void 0:o.call(s))||void 0===i?void 0:i.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&s.getRootNode().host&&(l=s.getRootNode().host);let d=l;for(;(null===(c=null===(a=null==d?void 0:d.getRootNode)||void 0===a?void 0:a.call(d))||void 0===c?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&d.getRootNode().host;)d=d.getRootNode().host;const h=!(this.doc.contains(s)||d&&this.doc.contains(d));if(!s.parentNode||h)return;const u=t(s.parentNode)?this.mirror.getId(l):this.mirror.getId(s.parentNode),g=r(s);if(-1===u||-1===g)return n.addNode(s);const p=T(s,{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=>{Z(e,this.mirror)&&this.iframeManager.addIframe(e),G(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),V(s)&&this.shadowDomManager.addShadowRoot(s.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});p&&e.push({parentId:u,nextId:g,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))q(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||s(e);for(const e of Array.from(this.addedSet.values()))ee(this.droppedSet,e)||q(this.removes,e,this.mirror)?ee(this.movedSet,e)?s(e):this.droppedSet.add(e):s(e);let o=null;for(;n.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),n=r(o.value);-1!==t&&-1!==n&&(e=o)}if(!e)for(let t=n.length-1;t>=0;t--){const s=n.get(t);if(s){const t=this.mirror.getId(s.value.parentNode);if(-1===r(s.value))continue;if(-1!==t){e=s;break}{const t=s.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=s;break}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}o=e.previous,n.removeNode(e.value),s(e.value)}const i={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!B(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;L(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:k(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=i({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),L(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find(t=>t.node===e.target);if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const s=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),o=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&o===n.style.getPropertyPriority(e)||(s[e]=""===o?r:[r,o])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(s[e]=!1)}else r.attributes[e.attributeName]=b(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(L(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(r=>{const s=this.mirror.getId(r),o=t(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);L(e.target,this.blockClass,this.blockSelector,!1)||B(r,this.mirror)||!function(e,t){return-1!==t.getId(e)}(r,this.mirror)||(this.addedSet.has(r)?(j(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(e.target)&&-1===s||U(e.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[H(s,o)]?j(this.movedSet,r):this.removes.push({parentId:o,id:s,isShadow:!(!t(e.target)||!n(e.target))||void 0})),this.mapRemoves.push(r))})}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(B(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[H(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);L(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(e=>this.genAdds(e))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function j(e,t){e.delete(t),t.childNodes.forEach(t=>j(e,t))}function q(e,t,n){return 0!==e.length&&$(e,t,n)}function $(e,t,n){const{parentNode:r}=t;if(!r)return!1;const s=n.getId(r);return!!e.some(e=>e.id===s)||$(e,r,n)}function ee(e,t){return 0!==e.size&&te(e,t)}function te(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||te(e,n))}const ne=[],re="undefined"!=typeof CSSGroupingRule,se="undefined"!=typeof CSSMediaRule,oe="undefined"!=typeof CSSSupportsRule,ie="undefined"!=typeof CSSConditionRule;function ae(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ce(e,t){var n,r;const s=new X;ne.push(s),s.init(e);let o=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(o=window[i]);const a=new o(s.processMutations.bind(s));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function le({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:s,sampling:o}){if(!1===o.mouseInteraction)return()=>{};const i=!0===o.mouseInteraction||void 0===o.mouseInteraction?{}:o.mouseInteraction,a=[];return Object.keys(Y).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]).forEach(o=>{const i=o.toLowerCase(),c=(t=>o=>{const i=ae(o);if(L(i,r,s,!0))return;const a=W(o)?o.changedTouches[0]:o;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:Y[t],id:c,x:l,y:d})})(o);a.push(R(i,c,t))}),()=>{a.forEach(e=>e())}}function de({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:s,sampling:o}){return R("scroll",N(o=>{const i=ae(o);if(!i||L(i,r,s,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})},o.scroll||100),t)}function he(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ue=["INPUT","TEXTAREA","SELECT"],ge=new WeakMap;function pe(e){return function(e,t){if(re&&e.parentRule instanceof CSSGroupingRule||se&&e.parentRule instanceof CSSMediaRule||oe&&e.parentRule instanceof CSSSupportsRule||ie&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function me(e,t,n){let r,s;return e?(e.ownerNode?r=t.getId(e.ownerNode):s=n.getId(e),{styleId:s,id:r}):{}}function fe({mirror:e,stylesheetManager:t},n){var r,s,o;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(o=null===(s=n.ownerDocument)||void 0===s?void 0:s.defaultView)||void 0===o?void 0:o.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ie(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:s,scrollCb:o,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:g}=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),s(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),o(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),h(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),u(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),g(...e)}}(e,t);const r=ce(e,e.doc),s=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const s="number"==typeof t.mousemove?t.mousemove:50,o="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=N(t=>{const n=Date.now()-i;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],i=null},o),l=N(e=>{const t=ae(e),{clientX:n,clientY:s}=W(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:s,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?z.Drag:e instanceof MouseEvent?z.MouseMove:z.TouchMove)},s,{trailing:!1}),d=[R("mousemove",l,n),R("touchmove",l,n),R("drag",l,n)];return()=>{d.forEach(e=>e())}}(e),o=le(e),a=de(e),c=function({viewportResizeCb:e}){let t=-1,n=-1;return R("resize",N(()=>{const r=O(),s=D();t===r&&n===s||(e({width:Number(s),height:Number(r)}),t=r,n=s)},200),window)}(e),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:s,ignoreClass:o,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function h(e){let n=ae(e);const l=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ue.indexOf(n.tagName)<0||L(n,r,s,!0))return;const h=n.type;if(n.classList.contains(o))return;let g=n.value,p=!1;"radio"===h||"checkbox"===h?p=n.checked:(a[n.tagName.toLowerCase()]||a[h])&&(g=i({maskInputOptions:a,tagName:n.tagName,type:h,value:g,maskInputFn:c})),u(n,he({text:g,isChecked:p,userTriggered:l},d));const m=n.name;"radio"===h&&m&&p&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach(e=>{e!==n&&u(e,he({text:e.value,isChecked:!p,userTriggered:!1},d))})}function u(t,r){const s=ge.get(t);if(!s||s.text!==r.text||s.isChecked!==r.isChecked){ge.set(t,r);const s=n.getId(t);e(Object.assign(Object.assign({},r),{id:s}))}}const g=("last"===l.input?["change"]:["input","change"]).map(e=>R(e,h,t)),p=t.defaultView;if(!p)return()=>{g.forEach(e=>e())};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),f=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&g.push(...f.map(e=>x(e[0],e[1],{set(){h({target:this})}},!1,p))),()=>{g.forEach(e=>e())}}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:s}){const o=o=>N(s=>{const i=ae(s);if(!i||L(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:o,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})},s.media||500),i=[R("play",o(0)),R("pause",o(1)),R("seeked",o(2)),R("volumechange",o(3)),R("ratechange",o(4))];return()=>{i.forEach(e=>e())}}(e),h=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const s=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,o){const{id:i,styleId:a}=me(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:o}]}),s.apply(this,[r,o])};const o=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:s,styleId:i}=me(this,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:r}]}),o.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:s,styleId:o}=me(this,t,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&e({id:s,styleId:o,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:s,styleId:o}=me(this,t,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&e({id:s,styleId:o,replaceSync:r}),a.apply(this,[r])});const c={};re?c.CSSGroupingRule=r.CSSGroupingRule:(se&&(c.CSSMediaRule=r.CSSMediaRule),ie&&(c.CSSConditionRule=r.CSSConditionRule),oe&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,s])=>{l[r]={insertRule:s.prototype.insertRule,deleteRule:s.prototype.deleteRule},s.prototype.insertRule=function(s,o){const{id:i,styleId:a}=me(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:s,index:[...pe(this),o||0]}]}),l[r].insertRule.apply(this,[s,o])},s.prototype.deleteRule=function(s){const{id:o,styleId:i}=me(this.parentStyleSheet,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:[...pe(this),s]}]}),l[r].deleteRule.apply(this,[s])}}),()=>{r.CSSStyleSheet.prototype.insertRule=s,r.CSSStyleSheet.prototype.deleteRule=o,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}}(e,{win:n}),u=fe(e,e.doc),g=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:s}){const o=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=function(s,i,a){var c;if(n.has(s))return o.apply(this,[s,i,a]);const{id:l,styleId:d}=me(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:s,value:i,priority:a},index:pe(this.parentRule)}),o.apply(this,[s,i,a])};const i=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=function(s){var o;if(n.has(s))return i.apply(this,[s]);const{id:a,styleId:c}=me(null===(o=this.parentRule)||void 0===o?void 0:o.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:s},index:pe(this.parentRule)}),i.apply(this,[s])},()=>{s.CSSStyleDeclaration.prototype.setProperty=o,s.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],s=new WeakMap,o=n.FontFace;n.FontFace=function(e,t,n){const r=new o(e,t,n);return s.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=F(t.fonts,"add",function(t){return function(n){return setTimeout(()=>{const t=s.get(n);t&&(e(t),s.delete(n))},0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=o}),r.push(i),()=>{r.forEach(e=>e())}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:s,selectionCb:o}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const o=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=o;L(i,r,s,!0)||L(l,r,s,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}o({ranges:a})};return a(),R("selectionchange",a)}(e),f=[];for(const t of e.plugins)f.push(t.observer(t.callback,n,t.options));return()=>{ne.forEach(e=>e.reset()),r.disconnect(),s(),o(),a(),c(),l(),d(),h(),u(),g(),p(),m(),f.forEach(e=>e())}}class Ce{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const s=n||this.getIdToRemoteIdMap(e),o=r||this.getRemoteIdToIdMap(e);let i=s.get(t);return i||(i=this.generateIdFn(),s.set(t,i),o.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const s=r.get(t);return s||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class ye{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Ce(u),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ce(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case _.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:_.IncrementalSnapshot,data:{source:z.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case _.Meta:case _.Load:case _.DomContentLoaded:return!1;case _.Plugin:return t;case _.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case _.IncrementalSnapshot:switch(t.data.source){case z.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case z.Drag:case z.TouchMove:case z.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case z.ViewportResize:return!1;case z.MediaInteraction:case z.MouseInteraction:case z.Scroll:case z.CanvasMutation:case z.Input:return this.replaceIds(t.data,e,["id"]),t;case z.StyleSheetRule:case z.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case z.Font:return t;case z.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case z.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}}replace(e,t,n,r){for(const s of r)(Array.isArray(t[s])||"number"==typeof t[s])&&(Array.isArray(t[s])?t[s]=e.getIds(n,t[s]):t[s]=e.getId(n,t[s]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}}class ve{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(F(Element.prototype,"attachShadow",function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}}))}addShadowRoot(e,t){n(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ce(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),de(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),fe({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)},0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(F(e.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(r){const s=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),s}}))}}reset(){this.restorePatches.forEach(e=>e()),this.shadowDoms=new WeakSet}}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function i(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(s,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=be[n[t]>>2],o+=be[(3&n[t])<<4|n[t+1]>>4],o+=be[(15&n[t+1])<<2|n[t+2]>>6],o+=be[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const o=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...o){return B(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}});r.push(o)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=F(e,s,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!B(this.canvas,r,o,!0)){const e=Re([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const o=x(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),o=r.indexOf("\n",10)+1,s=r.substring(o)+"";return function(e){return new Fe(s,Object.assign({},e,{eval:!0}))}}function Be(e,t,n){var r=function(e){return atob(e)}(e),o=r.indexOf("\n",10)+1,s=r.substring(o)+"",i=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(i)}var Le="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Le?De(Ue):function(e){var t;return function(n){return t=t||Be(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const s=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const h=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{B(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))),l=requestAnimationFrame(h)};l=requestAnimationFrame(h),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=F(t.CanvasRenderingContext2D.prototype,i,function(o){return function(...s){return B(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...s],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),o.apply(this,s)}});o.push(s)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r){const o=[];return o.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&o.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t}),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:o(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new s;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:u,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const B=!0===h?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},L=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,o)=>{var s;if(!(null===(s=ne[0])||void 0===s?void 0:s.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),o);else if(F){const t={type:"rrweb",event:K(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,o=n&&e.timestamp-U.timestamp>n;(t||o)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:o,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:B,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:L,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,h,u;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new s:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,h=void 0===d?"rr-mask":d,u=n.maskTextSelector,g=void 0===u?null:u,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:o,blockClass:a,blockSelector:l,maskTextClass:h,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:B,maskTextFn:m,slimDOM:L,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(h=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===h?void 0:h.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:o,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:B,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:L,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Xe(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var ot=et(qe,0)[1],st=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,st[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,o=0,s=new He(t);o<r;++o)++s[e[o]-1];var i,a=new He(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],h=a[e[o]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)i[st[h]>>>c]=l}else for(i=new He(r),o=0;o<r;++o)i[o]=st[a[e[o]-1]++]>>>15-e[o];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ht=ct(lt,9,0),ut=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new Pe(0),0];if(1==o){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,h=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=d&&n[l].f<n[h].f?l++:h++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var u=s[0].s;for(r=1;r<o;++r)s[r].s>u&&(u=s[r].s);var g=new He(u+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(s.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<o;++r){var C=s[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=s[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=s[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,o=gt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},bt=function(e,t,n,r,o,s,i,a,c,l,d){mt(t,d++,n),++o[256];for(var h=It(o,15),u=h[0],g=h[1],p=It(s,15),m=p[0],f=p[1],I=yt(u),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(o,lt)+vt(s,dt)+i,B=vt(o,u)+vt(s,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=B)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(B<D)),d+=2,B<D){E=ct(u,g,0),N=u,x=ct(m,f,0),F=m;var L=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,L[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ht,N=lt,x=ut,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var h=d+65535;h<i?l=St(c,l,e.subarray(d,h)):(c[d]=s,l=St(c,l,e.subarray(d,i)))}else{for(var u=At[t-1],g=u>>>13,p=8191&u,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,B=0,L=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--L&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,B=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(B){S[M++]=268435456|rt[D]<<18|ot[B];var J=31&rt[D],Q=31&ot[B];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,s,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,o,s,i=kt(e,t,2,4);return r=i,o=t.level,s=0==o?0:o<6?1:9==o?3:2,r[0]=120,r[1]=s<<6|(s?32-2*s:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new Pe(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return pt(r,0,o)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.3"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:50,batchInterval:3e4,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,2!==e.type?this.checkBatchLimits():this.isSendingBatch||this.sendBatchToBackend()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,o=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||o)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),o=await this.sendRequest(r,null,"GET",{},!0);if(204===o.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const s=o.data,i="string"==typeof s?s:s?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),o=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:o,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},o=!1){return new Promise((s,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?s({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:o})})}}export{Tt as default};
15
+ ***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function i(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(o,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,o,i){const a=[],c=Object.getOwnPropertyNames(e);for(const o of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if("function"!=typeof e[o])continue;const c=F(e,o,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!L(this.canvas,r,s,!0)){const e=Re([...a],i,this),r={type:t,property:o,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"";return function(e){return new Fe(o,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"",i=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(i)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:o,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,s),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const o=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:o}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const h=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(h)};l=requestAnimationFrame(h),this.resetObservers=()=>{o(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const o=F(t.CanvasRenderingContext2D.prototype,i,function(s){return function(...o){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...o],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),s.apply(this,o)}});s.push(o)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new o;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:u,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===h?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var o;if(!(null===(o=ne[0])||void 0===o?void 0:o.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,h,u;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new o:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,h=void 0===d?"rr-mask":d,u=n.maskTextSelector,g=void 0===u?null:u,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:h,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(h=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===h?void 0:h.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new Xe(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return[n,s]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],ot=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,ot[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,o=new He(t);s<r;++s)++o[e[s]-1];var i,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],h=a[e[s]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)i[ot[h]>>>c]=l}else for(i=new He(r),s=0;s<r;++s)i[s]=ot[a[e[s]-1]++]>>>15-e[s];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ht=ct(lt,9,0),ut=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,o=n.slice();if(!s)return[new Pe(0),0];if(1==s){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,h=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=d&&n[l].f<n[h].f?l++:h++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var u=o[0].s;for(r=1;r<s;++r)o[r].s>u&&(u=o[r].s);var g=new He(u+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(o.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=o[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=o[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=o[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],o=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var o=0;o<r;++o)e[s+o+4]=n[o];return 8*(s+4+r)},bt=function(e,t,n,r,s,o,i,a,c,l,d){mt(t,d++,n),++s[256];for(var h=It(s,15),u=h[0],g=h[1],p=It(o,15),m=p[0],f=p[1],I=yt(u),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(o,dt)+i,L=vt(s,u)+vt(o,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(u,g,0),N=u,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ht,N=lt,x=ut,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,o){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var h=d+65535;h<i?l=St(c,l,e.subarray(d,h)):(c[d]=o,l=St(c,l,e.subarray(d,i)))}else{for(var u=At[t-1],g=u>>>13,p=8191&u,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,o,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,o=n.length,i=0;i!=o;){for(var a=Math.min(i+5552,o);i<a;++i)s+=r+=n[i];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,o,i=kt(e,t,2,4);return r=i,s=t.level,o=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,o=function(e){r[s++]=e},i=0;i<n;++i){if(s+5>r.length){var a=new Pe(s+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.4"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const o=s.data,i="string"==typeof o?o:o?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((o,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?o({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}}export{Tt as default};