humanbehavior-js 0.0.4 → 0.0.5

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.min.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KoalawareTracker={})}(this,(function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)};function o(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function r(e,t){var n,o,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function s(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function i(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function a(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function c(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(l).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 l(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=c(e.styleSheet)||t}catch(e){}return t}"function"==typeof SuppressedError&&SuppressedError,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"}(t||(t={}));var d=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 o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function u(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,s=e.maskInputFn,i=r||"";return(t[n.toLowerCase()]||t[o])&&(i=s?s(i):"*".repeat(i.length)),i}var h="__rrweb_original__";var p,g,m=1,I=new RegExp("[^a-z0-9-_:]");function f(){return m++}var y=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,C=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,v=/^(data:)([^,]*),(.*)/i;function S(e,t){return(e||"").replace(y,(function(e,n,o,r,s,i){var a,c=o||s||i,l=n||r||"";if(!c)return e;if(!C.test(c))return"url(".concat(l).concat(c).concat(l,")");if(v.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("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var b=/^[^ \t\n\r\u000c]+/,A=/^[, \t\n\r\u000c]+/;function w(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function k(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function M(){var e=document.createElement("a");return e.href="",e.href}function T(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?w(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(A),!(n>=t.length);){var s=o(b);if(","===s.slice(-1))s=w(e,s.substring(0,s.length-1)),r.push(s);else{var i="";s=w(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){r.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,r.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?S(o,M()):"object"===t&&"data"===n&&o?w(e,o):o:w(e,o)}function E(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&E(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&E(e.parentNode,t,n)}function R(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(E(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function N(e,n){var o=n.doc,r=n.mirror,s=n.blockClass,i=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,d=n.inlineStylesheet,m=n.maskInputOptions,f=void 0===m?{}:m,y=n.maskTextFn,C=n.maskInputFn,v=n.dataURLOptions,b=void 0===v?{}:v,A=n.inlineImages,w=n.recordCanvas,E=n.keepIframeSrcFn,N=n.newlyAddedElement,O=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,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:t.Document,childNodes:[],compatMode:e.compatMode}:{type:t.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:t.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:F};case e.ELEMENT_NODE:return function(e,n){for(var o=n.doc,r=n.blockClass,s=n.blockSelector,i=n.inlineStylesheet,a=n.maskInputOptions,l=void 0===a?{}:a,d=n.maskInputFn,m=n.dataURLOptions,f=void 0===m?{}:m,y=n.inlineImages,C=n.recordCanvas,v=n.keepIframeSrcFn,b=n.newlyAddedElement,A=void 0!==b&&b,w=n.rootId,E=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,r,s),R=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return I.test(t)?"div":t}(e),N={},O=e.attributes.length,F=0;F<O;F++){var x=e.attributes[F];N[x.name]=T(o,R,x.name,x.value)}if("link"===R&&i){var L=Array.from(o.styleSheets).find((function(t){return t.href===e.href})),D=null;L&&(D=c(L)),D&&(delete N.rel,delete N.href,N._cssText=S(D,L.href))}if("style"===R&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(D=c(e.sheet))&&(N._cssText=S(D,M()))}if("input"===R||"textarea"===R||"select"===R){var B=e.value,U=e.checked;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&B?N.value=u({type:N.type,tagName:R,value:B,maskInputOptions:l,maskInputFn:d}):U&&(N.checked=U)}"option"===R&&(e.selected&&!l.select?N.selected=!0:delete N.selected);if("canvas"===R&&C)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,s=h in r?r[h]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(N.rr_dataURL=e.toDataURL(f.type,f.quality));else if(!("__context"in e)){var W=e.toDataURL(f.type,f.quality),Z=document.createElement("canvas");Z.width=e.width,Z.height=e.height,W!==Z.toDataURL(f.type,f.quality)&&(N.rr_dataURL=W)}if("img"===R&&y){p||(p=o.createElement("canvas"),g=p.getContext("2d"));var V=e,G=V.crossOrigin;V.crossOrigin="anonymous";var K=function(){try{p.width=V.naturalWidth,p.height=V.naturalHeight,g.drawImage(V,0,0),N.rr_dataURL=p.toDataURL(f.type,f.quality)}catch(e){console.warn("Cannot inline img src=".concat(V.currentSrc,"! Error: ").concat(e))}G?N.crossOrigin=G:V.removeAttribute("crossorigin")};V.complete&&0!==V.naturalWidth?K():V.onload=K}"audio"!==R&&"video"!==R||(N.rr_mediaState=e.paused?"paused":"played",N.rr_mediaCurrentTime=e.currentTime);A||(e.scrollLeft&&(N.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(N.rr_scrollTop=e.scrollTop));if(E){var _=e.getBoundingClientRect(),z=_.width,J=_.height;N={class:N.class,rr_width:"".concat(z,"px"),rr_height:"".concat(J,"px")}}"iframe"!==R||v(N.src)||(e.contentDocument||(N.rr_src=N.src),delete N.src);return{type:t.Element,tagName:R,attributes:N,childNodes:[],isSVG:k(e)||void 0,needBlock:E,rootId:w}}(e,{doc:o,blockClass:s,blockSelector:i,inlineStylesheet:d,maskInputOptions:f,maskInputFn:C,dataURLOptions:b,inlineImages:A,recordCanvas:w,keepIframeSrcFn:E,newlyAddedElement:O,rootId:F});case e.TEXT_NODE:return function(e,n){var o,r=n.maskTextClass,s=n.maskTextSelector,i=n.maskTextFn,a=n.rootId,c=e.parentNode&&e.parentNode.tagName,l=e.textContent,d="STYLE"===c||void 0,u="SCRIPT"===c||void 0;if(d&&l){try{e.nextSibling||e.previousSibling||(null===(o=e.parentNode.sheet)||void 0===o?void 0:o.cssRules)&&(l=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}l=S(l,M())}var h;u&&(l="SCRIPT_PLACEHOLDER");!d&&!u&&l&&R(e,r,s)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:t.Text,textContent:l||"",isStyle:d,rootId:a}}(e,{maskTextClass:a,maskTextSelector:l,maskTextFn:y,rootId:F});case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:"",rootId:F};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||"",rootId:F};default:return!1}}function O(e){return void 0===e?"":e.toLowerCase()}function F(e,n){var o,r=n.doc,s=n.mirror,c=n.blockClass,l=n.blockSelector,d=n.maskTextClass,u=n.maskTextSelector,h=n.skipChild,p=void 0!==h&&h,g=n.inlineStylesheet,m=void 0===g||g,I=n.maskInputOptions,y=void 0===I?{}:I,C=n.maskTextFn,v=n.maskInputFn,S=n.slimDOMOptions,b=n.dataURLOptions,A=void 0===b?{}:b,w=n.inlineImages,k=void 0!==w&&w,M=n.recordCanvas,T=void 0!==M&&M,E=n.onSerialize,R=n.onIframeLoad,x=n.iframeLoadTimeout,L=void 0===x?5e3:x,D=n.onStylesheetLoad,B=n.stylesheetLoadTimeout,U=void 0===B?5e3:B,W=n.keepIframeSrcFn,Z=void 0===W?function(){return!1}:W,V=n.newlyAddedElement,G=void 0!==V&&V,K=n.preserveWhiteSpace,_=void 0===K||K,z=N(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,dataURLOptions:A,inlineImages:k,recordCanvas:T,keepIframeSrcFn:Z,newlyAddedElement:G});if(!z)return console.warn(e,"not serialized"),null;o=s.hasNode(e)?s.getId(e):!function(e,n){if(n.comment&&e.type===t.Comment)return!0;if(e.type===t.Element){if(n.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(n.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(O(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===O(e.attributes.name)||"icon"===O(e.attributes.rel)||"apple-touch-icon"===O(e.attributes.rel)||"shortcut icon"===O(e.attributes.rel))))return!0;if("meta"===e.tagName){if(n.headMetaDescKeywords&&O(e.attributes.name).match(/^description|keywords$/))return!0;if(n.headMetaSocial&&(O(e.attributes.property).match(/^(og|twitter|fb):/)||O(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===O(e.attributes.name)))return!0;if(n.headMetaRobots&&("robots"===O(e.attributes.name)||"googlebot"===O(e.attributes.name)||"bingbot"===O(e.attributes.name)))return!0;if(n.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(n.headMetaAuthorship&&("author"===O(e.attributes.name)||"generator"===O(e.attributes.name)||"framework"===O(e.attributes.name)||"publisher"===O(e.attributes.name)||"progid"===O(e.attributes.name)||O(e.attributes.property).match(/^article:/)||O(e.attributes.property).match(/^product:/)))return!0;if(n.headMetaVerification&&("google-site-verification"===O(e.attributes.name)||"yandex-verification"===O(e.attributes.name)||"csrf-token"===O(e.attributes.name)||"p:domain_verify"===O(e.attributes.name)||"verify-v1"===O(e.attributes.name)||"verification"===O(e.attributes.name)||"shopify-checkout-api-token"===O(e.attributes.name)))return!0}}return!1}(z,S)&&(_||z.type!==t.Text||z.isStyle||z.textContent.replace(/^\s+|\s+$/gm,"").length)?f():-2;var J=Object.assign(z,{id:o});if(s.add(e,J),-2===o)return null;E&&E(e);var P=!p;if(J.type===t.Element){P=P&&!J.needBlock,delete J.needBlock;var Y=e.shadowRoot;Y&&a(Y)&&(J.isShadowHost=!0)}if((J.type===t.Document||J.type===t.Element)&&P){S.headWhitespace&&J.type===t.Element&&"head"===J.tagName&&(_=!1);for(var j={doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:p,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z},H=0,Q=Array.from(e.childNodes);H<Q.length;H++){($=F(Q[H],j))&&J.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var X=0,q=Array.from(e.shadowRoot.childNodes);X<q.length;X++){var $;($=F(q[X],j))&&(a(e.shadowRoot)&&($.isShadow=!0),J.childNodes.push($))}}return e.parentNode&&i(e.parentNode)&&a(e.parentNode)&&(J.isShadow=!0),J.type===t.Element&&"iframe"===J.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var i="about:blank";if(o.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()}))}}}(e,(function(){var t=e.contentDocument;if(t&&R){var n=F(t,{doc:t,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});n&&R(e,n)}}),L),J.type===t.Element&&"link"===J.tagName&&"stylesheet"===J.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var s=setTimeout((function(){r||(t(),r=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),r=!0,t()}))}}(e,(function(){if(D){var t=F(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});t&&D(e,t)}}),U),J}function x(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const L="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let D={map:{},getId:()=>(console.error(L),-1),getNode:()=>(console.error(L),null),removeNodeFromMap(){console.error(L)},has:()=>(console.error(L),!1),reset(){console.error(L)}};function B(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),c=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(c,s)):o||!1===n.trailing||(o=setTimeout((()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(c,s)}),a))}}function U(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>U(e,t,s||{},!0)}function W(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function V(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function G(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(E(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function K(e,t){return-2===t.getId(e)}function _(e,t){if(i(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||_(e.parentNode,t))}function z(e){return Boolean(e.changedTouches)}function J(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function P(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Y(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(D=new Proxy(D,{get:(e,t,n)=>("map"===t&&console.error(L),Reflect.get(e,t,n))}));class j{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 H=(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))(H||{}),Q=(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))(Q||{}),X=(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))(X||{}),q=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(q||{});function $(e){return"__ln"in e}class ee{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&&$(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&&$(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 te=(e,t)=>`${e}@${t}`;class ne{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=[],t=new ee,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,s,a,c;let l=null;(null===(s=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===s?void 0:s.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 u=!(this.doc.contains(o)||d&&this.doc.contains(d));if(!o.parentNode||u)return;const h=i(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),p=n(o);if(-1===h||-1===p)return t.addNode(o);const g=F(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=>{J(e,this.mirror)&&this.iframeManager.addIframe(e),P(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Y(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)}});g&&e.push({parentId:h,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))re(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ie(this.droppedSet,e)||re(this.removes,e,this.mirror)?ie(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const s={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};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!K(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;G(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:R(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=u({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),G(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=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(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(r[e]=""===s?o:[o,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=T(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(G(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),o=i(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);G(e.target,this.blockClass,this.blockSelector,!1)||K(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(oe(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||_(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[te(n,o)]?oe(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!i(e.target)||!a(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(K(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[te(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);G(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 oe(e,t){e.delete(t),t.childNodes.forEach((t=>oe(e,t)))}function re(e,t,n){return 0!==e.length&&se(e,t,n)}function se(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some((e=>e.id===r))||se(e,o,n)}function ie(e,t){return 0!==e.size&&ae(e,t)}function ae(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ae(e,n))}const ce=[],le="undefined"!=typeof CSSGroupingRule,de="undefined"!=typeof CSSMediaRule,ue="undefined"!=typeof CSSSupportsRule,he="undefined"!=typeof CSSConditionRule;function pe(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 ge(e,t){var n,o;const r=new ne;ce.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function me({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(X).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=pe(s);if(G(i,o,r,!0))return;const a=z(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:X[t],id:c,x:l,y:d})})(s);a.push(x(i,c,t))})),()=>{a.forEach((e=>e()))}}function Ie({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return x("scroll",B((s=>{const i=pe(s);if(!i||G(i,o,r,!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 fe(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ye=["INPUT","TEXTAREA","SELECT"],Ce=new WeakMap;function ve(e){return function(e,t){if(le&&e.parentRule instanceof CSSGroupingRule||de&&e.parentRule instanceof CSSMediaRule||ue&&e.parentRule instanceof CSSSupportsRule||he&&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 Se(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function be({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.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 o=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 o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ae(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...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),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const o=ge(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=B((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=B((e=>{const t=pe(e),{clientX:n,clientY:r}=z(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Q.Drag:e instanceof MouseEvent?Q.MouseMove:Q.TouchMove)}),r,{trailing:!1}),d=[x("mousemove",l,n),x("touchmove",l,n),x("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=me(e),i=Ie(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return x("resize",B((()=>{const o=Z(),r=V();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=pe(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ye.indexOf(n.tagName)<0||G(n,o,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let p=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(p=u({maskInputOptions:i,tagName:n.tagName,type:d,value:p,maskInputFn:a})),h(n,fe({text:p,isChecked:g,userTriggered:c},l));const m=n.name;"radio"===d&&m&&g&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,fe({text:e.value,isChecked:!g,userTriggered:!1},l))}))}function h(t,o){const r=Ce.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){Ce.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const p=("last"===c.input?["change"]:["input","change"]).map((e=>x(e,d,t))),g=t.defaultView;if(!g)return()=>{p.forEach((e=>e()))};const m=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),I=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&p.push(...I.map((e=>U(e[0],e[1],{set(){d({target:this})}},!1,g)))),()=>{p.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const s=s=>B((r=>{const i=pe(r);if(!i||G(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:o.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),r.media||500),i=[x("play",s(0)),x("pause",s(1)),x("seeked",s(2)),x("volumechange",s(3)),x("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Se(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:s}]}),r.apply(this,[o,s])};const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:i}=Se(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,removes:[{index:o}]}),s.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:s}=Se(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replace:o}),i.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:s}=Se(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replaceSync:o}),a.apply(this,[o])});const c={};le?c.CSSGroupingRule=o.CSSGroupingRule:(de&&(c.CSSMediaRule=o.CSSMediaRule),he&&(c.CSSConditionRule=o.CSSConditionRule),ue&&(c.CSSSupportsRule=o.CSSSupportsRule));const l={};return Object.entries(c).forEach((([o,r])=>{l[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Se(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:[...ve(this),s||0]}]}),l[o].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:i}=Se(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...ve(this),r]}]}),l[o].deleteRule.apply(this,[r])}})),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.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}),h=be(e,e.doc),p=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,i,a){var c;if(n.has(r))return s.apply(this,[r,i,a]);const{id:l,styleId:d}=Se(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,o.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:r,value:i,priority:a},index:ve(this.parentRule)}),s.apply(this,[r,i,a])};const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return i.apply(this,[r]);const{id:a,styleId:c}=Se(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:r},index:ve(this.parentRule)}),i.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),g=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=W(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}}));return o.push((()=>{n.FontFace=s})),o.push(i),()=>{o.forEach((e=>e()))}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,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;G(i,o,r,!0)||G(l,o,r,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),x("selectionchange",a)}(e),I=[];for(const t of e.plugins)I.push(t.observer(t.callback,n,t.options));return()=>{ce.forEach((e=>e.reset())),o.disconnect(),r(),s(),i(),a(),c(),l(),d(),h(),p(),g(),m(),I.forEach((e=>e()))}}class we{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,o)))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const r=o.get(t);return r||-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 ke{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new we(f),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new we(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 H.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:H.IncrementalSnapshot,data:{source:Q.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case H.Meta:case H.Load:case H.DomContentLoaded:return!1;case H.Plugin:return t;case H.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case H.IncrementalSnapshot:switch(t.data.source){case Q.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 Q.Drag:case Q.TouchMove:case Q.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Q.ViewportResize:return!1;case Q.MediaInteraction:case Q.MouseInteraction:case Q.Scroll:case Q.CanvasMutation:case Q.Input:return this.replaceIds(t.data,e,["id"]),t;case Q.StyleSheetRule:case Q.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Q.Font:return t;case Q.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Q.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,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));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 Me{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(W(Element.prototype,"attachShadow",(function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}})))}addShadowRoot(e,t){a(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ge(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Ie(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)),be({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(W(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KoalawareTracker={})}(this,(function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)};function o(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function r(e,t){var n,o,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function s(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function i(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function a(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function c(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(l).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 l(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=c(e.styleSheet)||t}catch(e){}return t}"function"==typeof SuppressedError&&SuppressedError,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"}(t||(t={}));var d=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 o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function u(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,s=e.maskInputFn,i=r||"";return(t[n.toLowerCase()]||t[o])&&(i=s?s(i):"*".repeat(i.length)),i}var h="__rrweb_original__";var p,g,m=1,I=new RegExp("[^a-z0-9-_:]");function f(){return m++}var y=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,C=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,v=/^(data:)([^,]*),(.*)/i;function b(e,t){return(e||"").replace(y,(function(e,n,o,r,s,i){var a,c=o||s||i,l=n||r||"";if(!c)return e;if(!C.test(c))return"url(".concat(l).concat(c).concat(l,")");if(v.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("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var S=/^[^ \t\n\r\u000c]+/,A=/^[, \t\n\r\u000c]+/;function w(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function k(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function M(){var e=document.createElement("a");return e.href="",e.href}function T(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?w(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(A),!(n>=t.length);){var s=o(S);if(","===s.slice(-1))s=w(e,s.substring(0,s.length-1)),r.push(s);else{var i="";s=w(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){r.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,r.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?b(o,M()):"object"===t&&"data"===n&&o?w(e,o):o:w(e,o)}function E(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&E(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&E(e.parentNode,t,n)}function R(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(E(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function N(e,n){var o=n.doc,r=n.mirror,s=n.blockClass,i=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,d=n.inlineStylesheet,m=n.maskInputOptions,f=void 0===m?{}:m,y=n.maskTextFn,C=n.maskInputFn,v=n.dataURLOptions,S=void 0===v?{}:v,A=n.inlineImages,w=n.recordCanvas,E=n.keepIframeSrcFn,N=n.newlyAddedElement,O=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,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:t.Document,childNodes:[],compatMode:e.compatMode}:{type:t.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:t.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:F};case e.ELEMENT_NODE:return function(e,n){for(var o=n.doc,r=n.blockClass,s=n.blockSelector,i=n.inlineStylesheet,a=n.maskInputOptions,l=void 0===a?{}:a,d=n.maskInputFn,m=n.dataURLOptions,f=void 0===m?{}:m,y=n.inlineImages,C=n.recordCanvas,v=n.keepIframeSrcFn,S=n.newlyAddedElement,A=void 0!==S&&S,w=n.rootId,E=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,r,s),R=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return I.test(t)?"div":t}(e),N={},O=e.attributes.length,F=0;F<O;F++){var x=e.attributes[F];N[x.name]=T(o,R,x.name,x.value)}if("link"===R&&i){var L=Array.from(o.styleSheets).find((function(t){return t.href===e.href})),D=null;L&&(D=c(L)),D&&(delete N.rel,delete N.href,N._cssText=b(D,L.href))}if("style"===R&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(D=c(e.sheet))&&(N._cssText=b(D,M()))}if("input"===R||"textarea"===R||"select"===R){var B=e.value,U=e.checked;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&B?N.value=u({type:N.type,tagName:R,value:B,maskInputOptions:l,maskInputFn:d}):U&&(N.checked=U)}"option"===R&&(e.selected&&!l.select?N.selected=!0:delete N.selected);if("canvas"===R&&C)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,s=h in r?r[h]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(N.rr_dataURL=e.toDataURL(f.type,f.quality));else if(!("__context"in e)){var W=e.toDataURL(f.type,f.quality),Z=document.createElement("canvas");Z.width=e.width,Z.height=e.height,W!==Z.toDataURL(f.type,f.quality)&&(N.rr_dataURL=W)}if("img"===R&&y){p||(p=o.createElement("canvas"),g=p.getContext("2d"));var V=e,G=V.crossOrigin;V.crossOrigin="anonymous";var K=function(){try{p.width=V.naturalWidth,p.height=V.naturalHeight,g.drawImage(V,0,0),N.rr_dataURL=p.toDataURL(f.type,f.quality)}catch(e){console.warn("Cannot inline img src=".concat(V.currentSrc,"! Error: ").concat(e))}G?N.crossOrigin=G:V.removeAttribute("crossorigin")};V.complete&&0!==V.naturalWidth?K():V.onload=K}"audio"!==R&&"video"!==R||(N.rr_mediaState=e.paused?"paused":"played",N.rr_mediaCurrentTime=e.currentTime);A||(e.scrollLeft&&(N.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(N.rr_scrollTop=e.scrollTop));if(E){var _=e.getBoundingClientRect(),z=_.width,J=_.height;N={class:N.class,rr_width:"".concat(z,"px"),rr_height:"".concat(J,"px")}}"iframe"!==R||v(N.src)||(e.contentDocument||(N.rr_src=N.src),delete N.src);return{type:t.Element,tagName:R,attributes:N,childNodes:[],isSVG:k(e)||void 0,needBlock:E,rootId:w}}(e,{doc:o,blockClass:s,blockSelector:i,inlineStylesheet:d,maskInputOptions:f,maskInputFn:C,dataURLOptions:S,inlineImages:A,recordCanvas:w,keepIframeSrcFn:E,newlyAddedElement:O,rootId:F});case e.TEXT_NODE:return function(e,n){var o,r=n.maskTextClass,s=n.maskTextSelector,i=n.maskTextFn,a=n.rootId,c=e.parentNode&&e.parentNode.tagName,l=e.textContent,d="STYLE"===c||void 0,u="SCRIPT"===c||void 0;if(d&&l){try{e.nextSibling||e.previousSibling||(null===(o=e.parentNode.sheet)||void 0===o?void 0:o.cssRules)&&(l=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}l=b(l,M())}var h;u&&(l="SCRIPT_PLACEHOLDER");!d&&!u&&l&&R(e,r,s)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:t.Text,textContent:l||"",isStyle:d,rootId:a}}(e,{maskTextClass:a,maskTextSelector:l,maskTextFn:y,rootId:F});case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:"",rootId:F};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||"",rootId:F};default:return!1}}function O(e){return void 0===e?"":e.toLowerCase()}function F(e,n){var o,r=n.doc,s=n.mirror,c=n.blockClass,l=n.blockSelector,d=n.maskTextClass,u=n.maskTextSelector,h=n.skipChild,p=void 0!==h&&h,g=n.inlineStylesheet,m=void 0===g||g,I=n.maskInputOptions,y=void 0===I?{}:I,C=n.maskTextFn,v=n.maskInputFn,b=n.slimDOMOptions,S=n.dataURLOptions,A=void 0===S?{}:S,w=n.inlineImages,k=void 0!==w&&w,M=n.recordCanvas,T=void 0!==M&&M,E=n.onSerialize,R=n.onIframeLoad,x=n.iframeLoadTimeout,L=void 0===x?5e3:x,D=n.onStylesheetLoad,B=n.stylesheetLoadTimeout,U=void 0===B?5e3:B,W=n.keepIframeSrcFn,Z=void 0===W?function(){return!1}:W,V=n.newlyAddedElement,G=void 0!==V&&V,K=n.preserveWhiteSpace,_=void 0===K||K,z=N(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,dataURLOptions:A,inlineImages:k,recordCanvas:T,keepIframeSrcFn:Z,newlyAddedElement:G});if(!z)return console.warn(e,"not serialized"),null;o=s.hasNode(e)?s.getId(e):!function(e,n){if(n.comment&&e.type===t.Comment)return!0;if(e.type===t.Element){if(n.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(n.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(O(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===O(e.attributes.name)||"icon"===O(e.attributes.rel)||"apple-touch-icon"===O(e.attributes.rel)||"shortcut icon"===O(e.attributes.rel))))return!0;if("meta"===e.tagName){if(n.headMetaDescKeywords&&O(e.attributes.name).match(/^description|keywords$/))return!0;if(n.headMetaSocial&&(O(e.attributes.property).match(/^(og|twitter|fb):/)||O(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===O(e.attributes.name)))return!0;if(n.headMetaRobots&&("robots"===O(e.attributes.name)||"googlebot"===O(e.attributes.name)||"bingbot"===O(e.attributes.name)))return!0;if(n.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(n.headMetaAuthorship&&("author"===O(e.attributes.name)||"generator"===O(e.attributes.name)||"framework"===O(e.attributes.name)||"publisher"===O(e.attributes.name)||"progid"===O(e.attributes.name)||O(e.attributes.property).match(/^article:/)||O(e.attributes.property).match(/^product:/)))return!0;if(n.headMetaVerification&&("google-site-verification"===O(e.attributes.name)||"yandex-verification"===O(e.attributes.name)||"csrf-token"===O(e.attributes.name)||"p:domain_verify"===O(e.attributes.name)||"verify-v1"===O(e.attributes.name)||"verification"===O(e.attributes.name)||"shopify-checkout-api-token"===O(e.attributes.name)))return!0}}return!1}(z,b)&&(_||z.type!==t.Text||z.isStyle||z.textContent.replace(/^\s+|\s+$/gm,"").length)?f():-2;var J=Object.assign(z,{id:o});if(s.add(e,J),-2===o)return null;E&&E(e);var P=!p;if(J.type===t.Element){P=P&&!J.needBlock,delete J.needBlock;var Y=e.shadowRoot;Y&&a(Y)&&(J.isShadowHost=!0)}if((J.type===t.Document||J.type===t.Element)&&P){b.headWhitespace&&J.type===t.Element&&"head"===J.tagName&&(_=!1);for(var j={doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:p,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:b,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z},Q=0,H=Array.from(e.childNodes);Q<H.length;Q++){($=F(H[Q],j))&&J.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var X=0,q=Array.from(e.shadowRoot.childNodes);X<q.length;X++){var $;($=F(q[X],j))&&(a(e.shadowRoot)&&($.isShadow=!0),J.childNodes.push($))}}return e.parentNode&&i(e.parentNode)&&a(e.parentNode)&&(J.isShadow=!0),J.type===t.Element&&"iframe"===J.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var i="about:blank";if(o.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()}))}}}(e,(function(){var t=e.contentDocument;if(t&&R){var n=F(t,{doc:t,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:b,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});n&&R(e,n)}}),L),J.type===t.Element&&"link"===J.tagName&&"stylesheet"===J.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var s=setTimeout((function(){r||(t(),r=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),r=!0,t()}))}}(e,(function(){if(D){var t=F(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:y,maskTextFn:C,maskInputFn:v,slimDOMOptions:b,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});t&&D(e,t)}}),U),J}function x(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const L="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let D={map:{},getId:()=>(console.error(L),-1),getNode:()=>(console.error(L),null),removeNodeFromMap(){console.error(L)},has:()=>(console.error(L),!1),reset(){console.error(L)}};function B(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),c=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(c,s)):o||!1===n.trailing||(o=setTimeout((()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(c,s)}),a))}}function U(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>U(e,t,s||{},!0)}function W(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function V(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function G(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(E(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function K(e,t){return-2===t.getId(e)}function _(e,t){if(i(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||_(e.parentNode,t))}function z(e){return Boolean(e.changedTouches)}function J(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function P(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Y(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(D=new Proxy(D,{get:(e,t,n)=>("map"===t&&console.error(L),Reflect.get(e,t,n))}));class j{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 Q=(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))(Q||{}),H=(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))(H||{}),X=(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))(X||{}),q=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(q||{});function $(e){return"__ln"in e}class ee{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&&$(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&&$(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 te=(e,t)=>`${e}@${t}`;class ne{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=[],t=new ee,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,s,a,c;let l=null;(null===(s=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===s?void 0:s.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 u=!(this.doc.contains(o)||d&&this.doc.contains(d));if(!o.parentNode||u)return;const h=i(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),p=n(o);if(-1===h||-1===p)return t.addNode(o);const g=F(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=>{J(e,this.mirror)&&this.iframeManager.addIframe(e),P(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Y(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)}});g&&e.push({parentId:h,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))re(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ie(this.droppedSet,e)||re(this.removes,e,this.mirror)?ie(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const s={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};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!K(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;G(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:R(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=u({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),G(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=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(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(r[e]=""===s?o:[o,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=T(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(G(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),o=i(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);G(e.target,this.blockClass,this.blockSelector,!1)||K(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(oe(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||_(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[te(n,o)]?oe(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!i(e.target)||!a(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(K(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[te(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);G(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 oe(e,t){e.delete(t),t.childNodes.forEach((t=>oe(e,t)))}function re(e,t,n){return 0!==e.length&&se(e,t,n)}function se(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some((e=>e.id===r))||se(e,o,n)}function ie(e,t){return 0!==e.size&&ae(e,t)}function ae(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ae(e,n))}const ce=[],le="undefined"!=typeof CSSGroupingRule,de="undefined"!=typeof CSSMediaRule,ue="undefined"!=typeof CSSSupportsRule,he="undefined"!=typeof CSSConditionRule;function pe(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 ge(e,t){var n,o;const r=new ne;ce.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function me({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(X).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=pe(s);if(G(i,o,r,!0))return;const a=z(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:X[t],id:c,x:l,y:d})})(s);a.push(x(i,c,t))})),()=>{a.forEach((e=>e()))}}function Ie({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return x("scroll",B((s=>{const i=pe(s);if(!i||G(i,o,r,!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 fe(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ye=["INPUT","TEXTAREA","SELECT"],Ce=new WeakMap;function ve(e){return function(e,t){if(le&&e.parentRule instanceof CSSGroupingRule||de&&e.parentRule instanceof CSSMediaRule||ue&&e.parentRule instanceof CSSSupportsRule||he&&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 be(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function Se({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.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 o=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 o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ae(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...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),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const o=ge(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=B((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=B((e=>{const t=pe(e),{clientX:n,clientY:r}=z(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?H.Drag:e instanceof MouseEvent?H.MouseMove:H.TouchMove)}),r,{trailing:!1}),d=[x("mousemove",l,n),x("touchmove",l,n),x("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=me(e),i=Ie(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return x("resize",B((()=>{const o=Z(),r=V();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=pe(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ye.indexOf(n.tagName)<0||G(n,o,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let p=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(p=u({maskInputOptions:i,tagName:n.tagName,type:d,value:p,maskInputFn:a})),h(n,fe({text:p,isChecked:g,userTriggered:c},l));const m=n.name;"radio"===d&&m&&g&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,fe({text:e.value,isChecked:!g,userTriggered:!1},l))}))}function h(t,o){const r=Ce.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){Ce.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const p=("last"===c.input?["change"]:["input","change"]).map((e=>x(e,d,t))),g=t.defaultView;if(!g)return()=>{p.forEach((e=>e()))};const m=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),I=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&p.push(...I.map((e=>U(e[0],e[1],{set(){d({target:this})}},!1,g)))),()=>{p.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const s=s=>B((r=>{const i=pe(r);if(!i||G(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:o.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),r.media||500),i=[x("play",s(0)),x("pause",s(1)),x("seeked",s(2)),x("volumechange",s(3)),x("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,s){const{id:i,styleId:a}=be(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:s}]}),r.apply(this,[o,s])};const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:i}=be(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,removes:[{index:o}]}),s.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:s}=be(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replace:o}),i.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:s}=be(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replaceSync:o}),a.apply(this,[o])});const c={};le?c.CSSGroupingRule=o.CSSGroupingRule:(de&&(c.CSSMediaRule=o.CSSMediaRule),he&&(c.CSSConditionRule=o.CSSConditionRule),ue&&(c.CSSSupportsRule=o.CSSSupportsRule));const l={};return Object.entries(c).forEach((([o,r])=>{l[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:i,styleId:a}=be(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:[...ve(this),s||0]}]}),l[o].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:i}=be(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...ve(this),r]}]}),l[o].deleteRule.apply(this,[r])}})),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.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}),h=Se(e,e.doc),p=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,i,a){var c;if(n.has(r))return s.apply(this,[r,i,a]);const{id:l,styleId:d}=be(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,o.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:r,value:i,priority:a},index:ve(this.parentRule)}),s.apply(this,[r,i,a])};const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return i.apply(this,[r]);const{id:a,styleId:c}=be(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:r},index:ve(this.parentRule)}),i.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),g=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=W(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}}));return o.push((()=>{n.FontFace=s})),o.push(i),()=>{o.forEach((e=>e()))}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,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;G(i,o,r,!0)||G(l,o,r,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),x("selectionchange",a)}(e),I=[];for(const t of e.plugins)I.push(t.observer(t.callback,n,t.options));return()=>{ce.forEach((e=>e.reset())),o.disconnect(),r(),s(),i(),a(),c(),l(),d(),h(),p(),g(),m(),I.forEach((e=>e()))}}class we{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,o)))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const r=o.get(t);return r||-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 ke{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new we(f),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new we(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 Q.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:Q.IncrementalSnapshot,data:{source:H.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Q.Meta:case Q.Load:case Q.DomContentLoaded:return!1;case Q.Plugin:return t;case Q.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Q.IncrementalSnapshot:switch(t.data.source){case H.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 H.Drag:case H.TouchMove:case H.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case H.ViewportResize:return!1;case H.MediaInteraction:case H.MouseInteraction:case H.Scroll:case H.CanvasMutation:case H.Input:return this.replaceIds(t.data,e,["id"]),t;case H.StyleSheetRule:case H.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case H.Font:return t;case H.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case H.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,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));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 Me{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(W(Element.prototype,"attachShadow",(function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}})))}addShadowRoot(e,t){a(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ge(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Ie(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)),Se({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(W(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -12,5 +12,5 @@
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 Te(e,t,n,o){return new(n||(n=Promise))((function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(s,i)}a((o=o.apply(e,[])).next())}))}for(var Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Re="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ne=0;Ne<64;Ne++)Re[Ee.charCodeAt(Ne)]=Ne;const Oe=new Map;const Fe=(e,t,n)=>{if(!e||!De(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Oe.get(e);return n||(n=new Map,Oe.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function xe(e,t,n){if(e instanceof Array)return e.map((e=>xe(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),o=n.length,r="";for(t=0;t<o;t+=3)r+=Ee[n[t]>>2],r+=Ee[(3&n[t])<<4|n[t+1]>>4],r+=Ee[(15&n[t+1])<<2|n[t+2]>>6],r+=Ee[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[xe(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:[xe(e.data,t,n),e.width,e.height]}}if(De(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Fe(e,t,n)}}return e}const Le=(e,t,n)=>[...e].map((e=>xe(e,t,n))),De=(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 Be(e,t,n){const o=[];try{const r=W(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...r){return G(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}}));o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function Ue(e,t,n,o,r,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=W(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Fe(c,i,this),!G(this.canvas,o,r,!0)){const e=Le([...a],i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return c}}));a.push(c)}catch(o){const r=U(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var We=null;try{var Ze="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");We=Ze.Worker}catch(e){}function Ve(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),r=o.indexOf("\n",10)+1,s=o.substring(r)+"";return function(e){return new We(s,Object.assign({},e,{eval:!0}))}}function Ge(e,t,n){var o=function(e){return atob(e)}(e),r=o.indexOf("\n",10)+1,s=o.substring(r)+"",i=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(i)}var Ke="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var _e,ze=(_e="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Ke?Ve(_e):function(e){var t;return function(n){return t=t||Ge(e),new Worker(t,n)}}(_e));class Je{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:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{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,o,r){const s=Be(t,n,o),i=new Map,a=new ze;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:q["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{G(t,n,o,!0)||e.push(t)})),e})().forEach((e=>Te(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 o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Be(e,t,n),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=W(t.CanvasRenderingContext2D.prototype,i,(function(r){return function(...s){return G(this.canvas,n,o,!0)||setTimeout((()=>{const n=Le([...s],t,this);e(this.canvas,{type:q["2D"],property:i,args:n})}),0),r.apply(this,s)}}));r.push(s)}catch(n){const o=U(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:q["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...Ue(t.WebGLRenderingContext.prototype,q.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...Ue(t.WebGL2RenderingContext.prototype,q.WebGL2,e,n,o,0,t)),()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),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 o=n.map((e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t})),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class Pe{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new j,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:[]},o=[];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);o.push({styleId:e,rules:n.map(((e,t)=>({rule:l(e),index:t})))})}n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ye(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let je,He,Qe,Xe=!1;const qe=new d;function $e(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:p,maskInputFn:g,maskTextFn:m,hooks:I,packFn:f,sampling:y={},dataURLOptions:C={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:E=new Set([])}=e,R=!b||window.parent===window;let N=!1;if(!R)try{window.parent.document,N=!1}catch(e){N=!0}if(R&&!t)throw new Error("emit function is required");void 0!==v&&void 0===y.mousemove&&(y.mousemove=v),qe.reset();const O=!0===u?{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!==h?h:{password:!0},L=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let D;!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 B=0;const U=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};je=(e,r)=>{var s;if(!(null===(s=ce[0])||void 0===s?void 0:s.isFrozen())||e.type===H.FullSnapshot||e.type===H.IncrementalSnapshot&&e.data.source===Q.Mutation||ce.forEach((e=>e.unfreeze())),R)null==t||t(U(e),r);else if(N){const t={type:"rrweb",event:U(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===H.FullSnapshot)D=e,B=0;else if(e.type===H.IncrementalSnapshot){if(e.data.source===Q.Mutation&&e.data.isAttachIframe)return;B++;const t=o&&B>=o,r=n&&e.timestamp-D.timestamp>n;(t||r)&&He(!0)}};const W=e=>{je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.Mutation},e)}))},G=e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.Scroll},e)})),K=e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.CanvasMutation},e)})),_=new Pe({mutationCb:W,adoptedStyleSheetCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.AdoptedStyleSheet},e)}))}),z=new ke({mirror:qe,mutationCb:W,stylesheetManager:_,recordCrossOriginIframes:b,wrappedEmit:je});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:qe,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});Qe=new Je({recordCanvas:S,mutationCb:K,win:window,blockClass:r,blockSelector:s,mirror:qe,sampling:y.canvas,dataURLOptions:C});const j=new Me({mutationCb:W,scrollCb:G,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:C,maskTextFn:m,maskInputFn:g,recordCanvas:S,inlineImages:k,sampling:y,slimDOMOptions:L,iframeManager:z,stylesheetManager:_,canvasManager:Qe,keepIframeSrcFn:T},mirror:qe});He=(e=!1)=>{var t,n,o,i,u,h;je(Ye({type:H.Meta,data:{href:window.location.href,width:V(),height:Z()}}),e),_.reset(),ce.forEach((e=>e.lock()));const p=function(e,t){var n=t||{},o=n.mirror,r=void 0===o?new d:o,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,u=void 0===l?"rr-mask":l,h=n.maskTextSelector,p=void 0===h?null:h,g=n.inlineStylesheet,m=void 0===g||g,I=n.inlineImages,f=void 0!==I&&I,y=n.recordCanvas,C=void 0!==y&&y,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,R=n.onIframeLoad,N=n.iframeLoadTimeout,O=n.onStylesheetLoad,x=n.stylesheetLoadTimeout,L=n.keepIframeSrcFn;return F(e,{doc:e,mirror:r,blockClass:i,blockSelector:c,maskTextClass:u,maskTextSelector:p,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===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:f,recordCanvas:C,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:N,onStylesheetLoad:O,stylesheetLoadTimeout:x,keepIframeSrcFn:void 0===L?function(){return!1}:L,newlyAddedElement:!1})}(document,{mirror:qe,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:S,inlineImages:k,onSerialize:e=>{J(e,qe)&&z.addIframe(e),P(e,qe)&&_.trackLinkElement(e),Y(e)&&j.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),j.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{_.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!p)return console.warn("Failed to snapshot the document");je(Ye({type:H.FullSnapshot,data:{node:p,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===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ce.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&_.adoptStyleSheets(document.adoptedStyleSheets,qe.getId(document))};try{const e=[];e.push(x("DOMContentLoaded",(()=>{je(Ye({type:H.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ae({mutationCb:W,mousemoveCb:(e,t)=>je(Ye({type:H.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.MouseInteraction},e)})),scrollCb:G,viewportResizeCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.ViewportResize},e)})),inputCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.Input},e)})),mediaInteractionCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.MediaInteraction},e)})),styleSheetRuleCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.StyleSheetRule},e)})),styleDeclarationCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.StyleDeclaration},e)})),canvasMutationCb:K,fontCb:e=>je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.Font},e)})),selectionCb:e=>{je(Ye({type:H.IncrementalSnapshot,data:Object.assign({source:Q.Selection},e)}))},blockClass:r,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:y,recordCanvas:S,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:g,maskTextFn:m,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:L,dataURLOptions:C,mirror:qe,iframeManager:z,stylesheetManager:_,shadowDomManager:j,canvasManager:Qe,ignoreCSSAttributes:E,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=>je(Ye({type:H.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},I)};z.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{He(),e.push(t(document)),Xe=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(x("load",(()=>{je(Ye({type:H.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),Xe=!1}}catch(e){console.warn(e)}}$e.addCustomEvent=(e,t)=>{if(!Xe)throw new Error("please add custom event after start recording");je(Ye({type:H.Custom,data:{tag:e,payload:t}}))},$e.freezePage=()=>{ce.forEach((e=>e.freeze()))},$e.takeFullSnapshot=e=>{if(!Xe)throw new Error("please take full snapshot after start recording");He(e)},$e.mirror=qe;const et=[];for(let e=0;e<256;++e)et.push((e+256).toString(16).slice(1));let tt;const nt=new Uint8Array(16);const ot={};function rt(e,t,n){let o;{const e=Date.now(),r=function(){if(!tt){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tt=crypto.getRandomValues.bind(crypto)}return tt(nt)}();!function(e,t,n){e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0);e.node||(e.node=n.slice(10,16),e.node[0]|=1,e.clockseq=16383&(n[8]<<8|n[9]));e.msecs=t}(ot,e,r),o=function(e,t,n,o,r,s,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(i<0||i+16>s.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else s=new Uint8Array(16),i=0;t??=Date.now(),n??=0,o??=16383&(e[8]<<8|e[9]),r??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+n)%4294967296;s[i++]=a>>>24&255,s[i++]=a>>>16&255,s[i++]=a>>>8&255,s[i++]=255&a;const c=t/4294967296*1e4&268435455;s[i++]=c>>>8&255,s[i++]=255&c,s[i++]=c>>>24&15|16,s[i++]=c>>>16&255,s[i++]=o>>>8|128,s[i++]=255&o;for(let e=0;e<6;++e)s[i++]=r[e];return s}(r,ot.msecs,ot.nsecs,ot.clockseq,ot.node,t,n)}return t??function(e,t=0){return(et[e[t+0]]+et[e[t+1]]+et[e[t+2]]+et[e[t+3]]+"-"+et[e[t+4]]+et[e[t+5]]+"-"+et[e[t+6]]+et[e[t+7]]+"-"+et[e[t+8]]+et[e[t+9]]+"-"+et[e[t+10]]+et[e[t+11]]+et[e[t+12]]+et[e[t+13]]+et[e[t+14]]+et[e[t+15]]).toLowerCase()}(o)}var st=process.env.HUMAN_BEHAVIOR_INGESTION_URL,it=10485760;function at(e,t,n){return(new TextEncoder).encode(JSON.stringify({sessionId:n,events:s(s([],e,!0),[t],!1)})).length>it}function ct(e,t){var n=(new TextEncoder).encode(JSON.stringify({sessionId:t,events:[e]})).length;if(n>it)throw new Error("Single event size (".concat(n," bytes) exceeds maximum chunk size (").concat(it," bytes)"))}var lt=function(){function e(e){var t=e.apiKey;if(this.apiKey=t,!st)throw new Error("HUMAN_BEHAVIOR_INGESTION_URL is not set");this.baseUrl=st}return e.prototype.init=function(e,t){return o(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/init"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:e,endUserId:t})})];case 1:if(!(n=r.sent()).ok)throw new Error("Failed to initialize ingestion: ".concat(n.statusText));return[4,n.json()];case 2:return[2,{sessionId:(o=r.sent()).sessionId,endUserId:o.endUserId}]}}))}))},e.prototype.sendEvents=function(e,t,n){return o(this,void 0,void 0,(function(){var o;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:e,endUserId:n})})];case 1:if(!(o=r.sent()).ok)throw new Error("Failed to send events: ".concat(o.statusText));return[2]}}))}))},e.prototype.sendEventsChunked=function(e,t){return o(this,void 0,void 0,(function(){var n,o,s,i,a,c,l,d,u,h,p;return r(this,(function(r){switch(r.label){case 0:r.trys.push([0,11,,12]),n=[],o=[],s=0,i=e,r.label=1;case 1:return s<i.length?(a=i[s],at(o,a,t)?o.length>0?[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:o})})]:[3,4]:[3,5]):[3,7];case 2:if(!(d=r.sent()).ok)throw new Error("Failed to send events: ".concat(d.statusText));return l=(c=n).push,[4,d.json()];case 3:l.apply(c,[r.sent()]),o=[],r.label=4;case 4:return ct(a,t),o=[a],[3,6];case 5:o.push(a),r.label=6;case 6:return s++,[3,1];case 7:return o.length>0?[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:o})})]:[3,10];case 8:if(!(d=r.sent()).ok)throw new Error("Failed to send events: ".concat(d.statusText));return h=(u=n).push,[4,d.json()];case 9:h.apply(u,[r.sent()]),r.label=10;case 10:return[2,n.flat()];case 11:throw p=r.sent(),console.error("Error sending events:",p),p;case 12:return[2]}}))}))},e.prototype.sendUserData=function(e,t,n){return o(this,void 0,void 0,(function(){var o,s;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/user"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({userId:e,userAttributes:t,sessionId:n})})];case 1:if(!(o=r.sent()).ok)throw new Error("Failed to send user data: ".concat(o.statusText," with API key: ").concat(this.apiKey));return[4,o.json()];case 2:return[2,r.sent()];case 3:throw s=r.sent(),console.error("Error sending user data:",s),s;case 4:return[2]}}))}))},e.prototype.sendSessionComplete=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/sessionComplete"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:e})})];case 1:if(!(t=n.sent()).ok)throw new Error("Failed to send session complete: ".concat(t.statusText));return[2]}}))}))},e.prototype.sendCustomEvent=function(e,t,n){return o(this,void 0,void 0,(function(){var o,s,i,a;return r(this,(function(r){switch(r.label){case 0:o=3,s=0,r.label=1;case 1:if(!(s<o))return[3,8];r.label=2;case 2:return r.trys.push([2,5,,7]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/customEvent"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({name:e,properties:t,sessionId:n,timestamp:(new Date).toISOString()})})];case 3:if(!(i=r.sent()).ok)throw new Error("Failed to send custom event: ".concat(i.statusText));return[4,i.json()];case 4:return[2,r.sent()];case 5:if(a=r.sent(),++s===o)throw console.error("Error sending custom event after max retries:",a),a;return[4,new Promise((function(e){return setTimeout(e,1e3*Math.pow(2,s))}))];case 6:return r.sent(),[3,7];case 7:return[3,1];case 8:return[2]}}))}))},e.prototype.sendCustomEvents=function(e,t){return o(this,void 0,void 0,(function(){var o,s,i,a;return r(this,(function(r){switch(r.label){case 0:o=3,s=0,r.label=1;case 1:if(!(s<o))return[3,8];r.label=2;case 2:return r.trys.push([2,5,,7]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/customEvent/batch"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({events:e.map((function(e){return n(n({},e),{sessionId:t})}))})})];case 3:if(!(i=r.sent()).ok)throw new Error("Failed to send custom events: ".concat(i.statusText));return[4,i.json()];case 4:return[2,r.sent()];case 5:if(a=r.sent(),++s===o)throw console.error("Error sending custom events after max retries:",a),a;return[4,new Promise((function(e){return setTimeout(e,1e3*Math.pow(2,s))}))];case 6:return r.sent(),[3,7];case 7:return[3,1];case 8:return[2]}}))}))},e.prototype.sendBeaconEvents=function(e,t,n){void 0===n&&(n=!1);var o=new URLSearchParams;o.append("events",encodeURIComponent(JSON.stringify(e))),o.append("sessionId",encodeURIComponent(t)),o.append("timestamp",encodeURIComponent(Date.now().toString())),o.append("apiKey",encodeURIComponent(this.apiKey)),n&&(console.log("Session complete beacon sending"),localStorage.setItem("koalaware_session_complete",Date.now().toString()),o.append("sessionComplete",encodeURIComponent("true"))),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/events"),o)},e.prototype.sendBeaconSessionComplete=function(e){var t=new URLSearchParams;t.append("sessionId",e),t.append("apiKey",this.apiKey),t.append("sessionComplete","true"),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/sessionComplete"),t)},e.prototype.sendBeaconCustomEvent=function(e,t,n){var o=new URLSearchParams;return o.append("name",encodeURIComponent(e)),o.append("properties",encodeURIComponent(JSON.stringify(t))),o.append("sessionId",encodeURIComponent(n)),o.append("timestamp",encodeURIComponent((new Date).toISOString())),o.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/customEvent"),o)},e.prototype.sendBeaconCustomEvents=function(e,t){var o=new URLSearchParams;return o.append("events",encodeURIComponent(JSON.stringify(e.map((function(e){return n(n({},e),{sessionId:t})}))))),o.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/customEvent/batch"),o)},e}(),dt="undefined"!=typeof window,ut=function(){function e(e){if(this.eventIngestionQueue=[],this.queueSizeBytes=0,this.rejectedEvents=[],this.isProcessingRejectedEvents=!1,this.userProperties={},this.isProcessing=!1,this.flushInterval=null,this.FLUSH_INTERVAL_MS=5e3,this.endUserId=null,this.initialized=!1,this.initializationPromise=null,!e)throw new Error("Human Behavior apiKey is required");this.api=new lt({apiKey:e}),this.apiKey=e;var t=dt?localStorage.getItem("human_behavior_session_id"):null,n=dt?localStorage.getItem("human_behavior_last_activity"):null,o=Date.now()-18e5,r=n&&parseInt(n)>o;this.sessionId=t&&r?t:rt(),t&&r||!dt||localStorage.setItem("human_behavior_session_id",this.sessionId),this.initializationPromise=this.init()}return e.prototype.init=function(){return o(this,void 0,void 0,(function(){var e,t,n,o,s;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.getCookie("human_behavior_end_user_id_".concat(this.apiKey)),[4,this.api.init(this.sessionId,e)];case 1:return t=r.sent(),n=t.sessionId,o=t.endUserId,this.sessionId=n,this.endUserId=o,this.setCookie("human_behavior_end_user_id_".concat(this.apiKey),o,365),dt?(this.setupPageUnloadHandler(),this.start(),this.processRejectedEvents()):console.warn("HumanBehaviorTracker initialized in a non-browser environment. Session tracking is disabled."),this.initialized=!0,console.log("HumanBehaviorTracker initialized"),[3,3];case 2:throw s=r.sent(),console.error("Failed to initialize HumanBehaviorTracker:",s),s;case 3:return[2]}}))}))},e.prototype.ensureInitialized=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(!this.initializationPromise)throw new Error("HumanBehaviorTracker initialization failed");return[4,this.initializationPromise];case 1:return e.sent(),[2]}}))}))},e.logToStorage=function(e){try{var t=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]");t.push("".concat((new Date).toISOString(),": ").concat(e)),localStorage.setItem("human_behavior_logs",JSON.stringify(t))}catch(e){console.error("Failed to log to storage:",e)}},e.prototype.setupPageUnloadHandler=function(){var e=this;dt&&(console.log("Setting up page unload handler"),window.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&(console.log("Page hidden - sending pending events"),e.api.sendBeaconEvents(e.eventIngestionQueue,e.sessionId))})),window.addEventListener("beforeunload",(function(){localStorage.setItem("human_behavior_last_activity",Date.now().toString()),e.api.sendBeaconEvents(e.eventIngestionQueue,e.sessionId)})),setInterval((function(){localStorage.setItem("human_behavior_last_activity",Date.now().toString())}),6e4))},e.prototype.viewLogs=function(){try{var e=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]");console.log("HumanBehavior Logs:",e),localStorage.removeItem("human_behavior_logs")}catch(e){console.error("Failed to read logs:",e)}},e.prototype.identifyUser=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,this.ensureInitialized()];case 1:return t.sent(),this.userProperties=e,[4,this.api.sendUserData(this.endUserId,e,this.sessionId)];case 2:return t.sent(),[2]}}))}))},e.prototype.customEvent=function(e){return o(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r(this,(function(n){switch(n.label){case 0:return[4,this.ensureInitialized()];case 1:return n.sent(),this.api.sendBeaconCustomEvent(e,t,this.sessionId),[2]}}))}))},e.prototype.start=function(){return o(this,void 0,void 0,(function(){var e=this;return r(this,(function(t){switch(t.label){case 0:return[4,this.ensureInitialized()];case 1:return t.sent(),dt?(this.flushInterval=window.setInterval((function(){e.flush()}),this.FLUSH_INTERVAL_MS),$e({emit:function(t){e.addEvent(t)}}),[2]):[2]}}))}))},e.prototype.stop=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),dt?(this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),[2]):[2]}}))}))},e.prototype.addEvent=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return[4,this.ensureInitialized()];case 1:return n.sent(),t=(new TextEncoder).encode(JSON.stringify(e)).length,this.eventIngestionQueue.push(e),this.queueSizeBytes+=t,[2]}}))}))},e.prototype.processRejectedEvents=function(){return o(this,void 0,void 0,(function(){var e;return r(this,(function(t){if(this.isProcessingRejectedEvents||0===this.rejectedEvents.length)return[2];this.isProcessingRejectedEvents=!0;try{e=rt(),dt&&localStorage.setItem("human_behavior_session_id",e),this.api.sendBeaconEvents(this.rejectedEvents,e),this.rejectedEvents=[],this.sessionId=e}catch(e){console.error("Failed to process rejected events:",e)}finally{this.isProcessingRejectedEvents=!1}return[2]}))}))},e.prototype.flush=function(){return o(this,void 0,void 0,(function(){var e,t,n,o;return r(this,(function(r){switch(r.label){case 0:if(this.isProcessing||!this.initialized)return[2];this.isProcessing=!0,r.label=1;case 1:if(r.trys.push([1,,6,7]),e=this.eventIngestionQueue,this.eventIngestionQueue=[],this.queueSizeBytes=0,!(e.length>0))return[3,5];console.log("Flushing events:",e),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.api.sendEvents(e,this.sessionId,this.endUserId)];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!(null===(o=t.message)||void 0===o?void 0:o.includes("ERROR: Session already completed")))throw t;return console.log("Session expired, storing events for retry"),(n=this.rejectedEvents).push.apply(n,e),this.processRejectedEvents(),[3,5];case 5:return[3,7];case 6:return this.isProcessing=!1,[7];case 7:return[2]}}))}))},e.prototype.setCookie=function(e,t,n){if(dt){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);var r="expires=".concat(o.toUTCString());document.cookie="".concat(e,"=").concat(t,";").concat(r,";path=/;SameSite=Lax")}},e.prototype.getCookie=function(e){if(!dt)return null;for(var t=e+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){for(var r=n[o];" "===r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return r.substring(t.length,r.length)}return null},e}();dt&&(window.HumanBehaviorTracker=ut),e.HumanBehaviorAPI=lt,e.HumanBehaviorTracker=ut,e.MAX_CHUNK_SIZE_BYTES=it,e.default=ut,e.isChunkSizeExceeded=at,e.validateSingleEventSize=ct,Object.defineProperty(e,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */function Te(e,t,n,o){return new(n||(n=Promise))((function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(s,i)}a((o=o.apply(e,[])).next())}))}for(var Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Re="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ne=0;Ne<64;Ne++)Re[Ee.charCodeAt(Ne)]=Ne;const Oe=new Map;const Fe=(e,t,n)=>{if(!e||!De(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Oe.get(e);return n||(n=new Map,Oe.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function xe(e,t,n){if(e instanceof Array)return e.map((e=>xe(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),o=n.length,r="";for(t=0;t<o;t+=3)r+=Ee[n[t]>>2],r+=Ee[(3&n[t])<<4|n[t+1]>>4],r+=Ee[(15&n[t+1])<<2|n[t+2]>>6],r+=Ee[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[xe(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:[xe(e.data,t,n),e.width,e.height]}}if(De(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Fe(e,t,n)}}return e}const Le=(e,t,n)=>[...e].map((e=>xe(e,t,n))),De=(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 Be(e,t,n){const o=[];try{const r=W(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...r){return G(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}}));o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function Ue(e,t,n,o,r,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=W(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Fe(c,i,this),!G(this.canvas,o,r,!0)){const e=Le([...a],i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return c}}));a.push(c)}catch(o){const r=U(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var We=null;try{var Ze="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");We=Ze.Worker}catch(e){}function Ve(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),r=o.indexOf("\n",10)+1,s=o.substring(r)+"";return function(e){return new We(s,Object.assign({},e,{eval:!0}))}}function Ge(e,t,n){var o=function(e){return atob(e)}(e),r=o.indexOf("\n",10)+1,s=o.substring(r)+"",i=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(i)}var Ke="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var _e,ze=(_e="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Ke?Ve(_e):function(e){var t;return function(n){return t=t||Ge(e),new Worker(t,n)}}(_e));class Je{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:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{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,o,r){const s=Be(t,n,o),i=new Map,a=new ze;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:q["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{G(t,n,o,!0)||e.push(t)})),e})().forEach((e=>Te(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 o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Be(e,t,n),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=W(t.CanvasRenderingContext2D.prototype,i,(function(r){return function(...s){return G(this.canvas,n,o,!0)||setTimeout((()=>{const n=Le([...s],t,this);e(this.canvas,{type:q["2D"],property:i,args:n})}),0),r.apply(this,s)}}));r.push(s)}catch(n){const o=U(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:q["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...Ue(t.WebGLRenderingContext.prototype,q.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...Ue(t.WebGL2RenderingContext.prototype,q.WebGL2,e,n,o,0,t)),()=>{r.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),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 o=n.map((e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t})),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class Pe{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new j,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:[]},o=[];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);o.push({styleId:e,rules:n.map(((e,t)=>({rule:l(e),index:t})))})}n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ye(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let je,Qe,He,Xe=!1;const qe=new d;function $e(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:p,maskInputFn:g,maskTextFn:m,hooks:I,packFn:f,sampling:y={},dataURLOptions:C={},mousemoveWait:v,recordCanvas:b=!1,recordCrossOriginIframes:S=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:E=new Set([])}=e,R=!S||window.parent===window;let N=!1;if(!R)try{window.parent.document,N=!1}catch(e){N=!0}if(R&&!t)throw new Error("emit function is required");void 0!==v&&void 0===y.mousemove&&(y.mousemove=v),qe.reset();const O=!0===u?{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!==h?h:{password:!0},L=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let D;!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 B=0;const U=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};je=(e,r)=>{var s;if(!(null===(s=ce[0])||void 0===s?void 0:s.isFrozen())||e.type===Q.FullSnapshot||e.type===Q.IncrementalSnapshot&&e.data.source===H.Mutation||ce.forEach((e=>e.unfreeze())),R)null==t||t(U(e),r);else if(N){const t={type:"rrweb",event:U(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===Q.FullSnapshot)D=e,B=0;else if(e.type===Q.IncrementalSnapshot){if(e.data.source===H.Mutation&&e.data.isAttachIframe)return;B++;const t=o&&B>=o,r=n&&e.timestamp-D.timestamp>n;(t||r)&&Qe(!0)}};const W=e=>{je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.Mutation},e)}))},G=e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.Scroll},e)})),K=e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.CanvasMutation},e)})),_=new Pe({mutationCb:W,adoptedStyleSheetCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.AdoptedStyleSheet},e)}))}),z=new ke({mirror:qe,mutationCb:W,stylesheetManager:_,recordCrossOriginIframes:S,wrappedEmit:je});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:qe,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});He=new Je({recordCanvas:b,mutationCb:K,win:window,blockClass:r,blockSelector:s,mirror:qe,sampling:y.canvas,dataURLOptions:C});const j=new Me({mutationCb:W,scrollCb:G,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:C,maskTextFn:m,maskInputFn:g,recordCanvas:b,inlineImages:k,sampling:y,slimDOMOptions:L,iframeManager:z,stylesheetManager:_,canvasManager:He,keepIframeSrcFn:T},mirror:qe});Qe=(e=!1)=>{var t,n,o,i,u,h;je(Ye({type:Q.Meta,data:{href:window.location.href,width:V(),height:Z()}}),e),_.reset(),ce.forEach((e=>e.lock()));const p=function(e,t){var n=t||{},o=n.mirror,r=void 0===o?new d:o,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,u=void 0===l?"rr-mask":l,h=n.maskTextSelector,p=void 0===h?null:h,g=n.inlineStylesheet,m=void 0===g||g,I=n.inlineImages,f=void 0!==I&&I,y=n.recordCanvas,C=void 0!==y&&y,v=n.maskAllInputs,b=void 0!==v&&v,S=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,R=n.onIframeLoad,N=n.iframeLoadTimeout,O=n.onStylesheetLoad,x=n.stylesheetLoadTimeout,L=n.keepIframeSrcFn;return F(e,{doc:e,mirror:r,blockClass:i,blockSelector:c,maskTextClass:u,maskTextSelector:p,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===b?{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===b?{password:!0}:b,maskTextFn:S,maskInputFn:A,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:f,recordCanvas:C,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:N,onStylesheetLoad:O,stylesheetLoadTimeout:x,keepIframeSrcFn:void 0===L?function(){return!1}:L,newlyAddedElement:!1})}(document,{mirror:qe,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:b,inlineImages:k,onSerialize:e=>{J(e,qe)&&z.addIframe(e),P(e,qe)&&_.trackLinkElement(e),Y(e)&&j.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),j.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{_.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!p)return console.warn("Failed to snapshot the document");je(Ye({type:Q.FullSnapshot,data:{node:p,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===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ce.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&_.adoptStyleSheets(document.adoptedStyleSheets,qe.getId(document))};try{const e=[];e.push(x("DOMContentLoaded",(()=>{je(Ye({type:Q.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ae({mutationCb:W,mousemoveCb:(e,t)=>je(Ye({type:Q.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.MouseInteraction},e)})),scrollCb:G,viewportResizeCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.ViewportResize},e)})),inputCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.Input},e)})),mediaInteractionCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.MediaInteraction},e)})),styleSheetRuleCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.StyleSheetRule},e)})),styleDeclarationCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.StyleDeclaration},e)})),canvasMutationCb:K,fontCb:e=>je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.Font},e)})),selectionCb:e=>{je(Ye({type:Q.IncrementalSnapshot,data:Object.assign({source:H.Selection},e)}))},blockClass:r,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:y,recordCanvas:b,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:g,maskTextFn:m,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:L,dataURLOptions:C,mirror:qe,iframeManager:z,stylesheetManager:_,shadowDomManager:j,canvasManager:He,ignoreCSSAttributes:E,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=>je(Ye({type:Q.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},I)};z.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{Qe(),e.push(t(document)),Xe=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(x("load",(()=>{je(Ye({type:Q.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),Xe=!1}}catch(e){console.warn(e)}}$e.addCustomEvent=(e,t)=>{if(!Xe)throw new Error("please add custom event after start recording");je(Ye({type:Q.Custom,data:{tag:e,payload:t}}))},$e.freezePage=()=>{ce.forEach((e=>e.freeze()))},$e.takeFullSnapshot=e=>{if(!Xe)throw new Error("please take full snapshot after start recording");Qe(e)},$e.mirror=qe;const et=[];for(let e=0;e<256;++e)et.push((e+256).toString(16).slice(1));let tt;const nt=new Uint8Array(16);const ot={};function rt(e,t,n){let o;{const e=Date.now(),r=function(){if(!tt){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tt=crypto.getRandomValues.bind(crypto)}return tt(nt)}();!function(e,t,n){e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0);e.node||(e.node=n.slice(10,16),e.node[0]|=1,e.clockseq=16383&(n[8]<<8|n[9]));e.msecs=t}(ot,e,r),o=function(e,t,n,o,r,s,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(i<0||i+16>s.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else s=new Uint8Array(16),i=0;t??=Date.now(),n??=0,o??=16383&(e[8]<<8|e[9]),r??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+n)%4294967296;s[i++]=a>>>24&255,s[i++]=a>>>16&255,s[i++]=a>>>8&255,s[i++]=255&a;const c=t/4294967296*1e4&268435455;s[i++]=c>>>8&255,s[i++]=255&c,s[i++]=c>>>24&15|16,s[i++]=c>>>16&255,s[i++]=o>>>8|128,s[i++]=255&o;for(let e=0;e<6;++e)s[i++]=r[e];return s}(r,ot.msecs,ot.nsecs,ot.clockseq,ot.node,t,n)}return t??function(e,t=0){return(et[e[t+0]]+et[e[t+1]]+et[e[t+2]]+et[e[t+3]]+"-"+et[e[t+4]]+et[e[t+5]]+"-"+et[e[t+6]]+et[e[t+7]]+"-"+et[e[t+8]]+et[e[t+9]]+"-"+et[e[t+10]]+et[e[t+11]]+et[e[t+12]]+et[e[t+13]]+et[e[t+14]]+et[e[t+15]]).toLowerCase()}(o)}var st=10485760;function it(e,t,n){return(new TextEncoder).encode(JSON.stringify({sessionId:n,events:s(s([],e,!0),[t],!1)})).length>st}function at(e,t){var n=(new TextEncoder).encode(JSON.stringify({sessionId:t,events:[e]})).length;if(n>st)throw new Error("Single event size (".concat(n," bytes) exceeds maximum chunk size (").concat(st," bytes)"))}var ct=function(){function e(e){var t=e.apiKey,n=e.ingestionUrl;this.apiKey=t,this.baseUrl=n}return e.prototype.init=function(e,t){return o(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/init"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:e,endUserId:t})})];case 1:if(!(n=r.sent()).ok)throw new Error("Failed to initialize ingestion: ".concat(n.statusText));return[4,n.json()];case 2:return[2,{sessionId:(o=r.sent()).sessionId,endUserId:o.endUserId}]}}))}))},e.prototype.sendEvents=function(e,t,n){return o(this,void 0,void 0,(function(){var o;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:e,endUserId:n})})];case 1:if(!(o=r.sent()).ok)throw new Error("Failed to send events: ".concat(o.statusText));return[2]}}))}))},e.prototype.sendEventsChunked=function(e,t){return o(this,void 0,void 0,(function(){var n,o,s,i,a,c,l,d,u,h,p;return r(this,(function(r){switch(r.label){case 0:r.trys.push([0,11,,12]),n=[],o=[],s=0,i=e,r.label=1;case 1:return s<i.length?(a=i[s],it(o,a,t)?o.length>0?[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:o})})]:[3,4]:[3,5]):[3,7];case 2:if(!(d=r.sent()).ok)throw new Error("Failed to send events: ".concat(d.statusText));return l=(c=n).push,[4,d.json()];case 3:l.apply(c,[r.sent()]),o=[],r.label=4;case 4:return at(a,t),o=[a],[3,6];case 5:o.push(a),r.label=6;case 6:return s++,[3,1];case 7:return o.length>0?[4,fetch("".concat(this.baseUrl,"/api/ingestion/events"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:t,events:o})})]:[3,10];case 8:if(!(d=r.sent()).ok)throw new Error("Failed to send events: ".concat(d.statusText));return h=(u=n).push,[4,d.json()];case 9:h.apply(u,[r.sent()]),r.label=10;case 10:return[2,n.flat()];case 11:throw p=r.sent(),console.error("Error sending events:",p),p;case 12:return[2]}}))}))},e.prototype.sendUserData=function(e,t,n){return o(this,void 0,void 0,(function(){var o,s;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/user"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({userId:e,userAttributes:t,sessionId:n})})];case 1:if(!(o=r.sent()).ok)throw new Error("Failed to send user data: ".concat(o.statusText," with API key: ").concat(this.apiKey));return[4,o.json()];case 2:return[2,r.sent()];case 3:throw s=r.sent(),console.error("Error sending user data:",s),s;case 4:return[2]}}))}))},e.prototype.sendSessionComplete=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(this.baseUrl,"/api/ingestion/sessionComplete"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({sessionId:e})})];case 1:if(!(t=n.sent()).ok)throw new Error("Failed to send session complete: ".concat(t.statusText));return[2]}}))}))},e.prototype.sendCustomEvent=function(e,t,n){return o(this,void 0,void 0,(function(){var o,s,i,a;return r(this,(function(r){switch(r.label){case 0:o=3,s=0,r.label=1;case 1:if(!(s<o))return[3,8];r.label=2;case 2:return r.trys.push([2,5,,7]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/customEvent"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({name:e,properties:t,sessionId:n,timestamp:(new Date).toISOString()})})];case 3:if(!(i=r.sent()).ok)throw new Error("Failed to send custom event: ".concat(i.statusText));return[4,i.json()];case 4:return[2,r.sent()];case 5:if(a=r.sent(),++s===o)throw console.error("Error sending custom event after max retries:",a),a;return[4,new Promise((function(e){return setTimeout(e,1e3*Math.pow(2,s))}))];case 6:return r.sent(),[3,7];case 7:return[3,1];case 8:return[2]}}))}))},e.prototype.sendCustomEvents=function(e,t){return o(this,void 0,void 0,(function(){var o,s,i,a;return r(this,(function(r){switch(r.label){case 0:o=3,s=0,r.label=1;case 1:if(!(s<o))return[3,8];r.label=2;case 2:return r.trys.push([2,5,,7]),[4,fetch("".concat(this.baseUrl,"/api/ingestion/customEvent/batch"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.apiKey)},body:JSON.stringify({events:e.map((function(e){return n(n({},e),{sessionId:t})}))})})];case 3:if(!(i=r.sent()).ok)throw new Error("Failed to send custom events: ".concat(i.statusText));return[4,i.json()];case 4:return[2,r.sent()];case 5:if(a=r.sent(),++s===o)throw console.error("Error sending custom events after max retries:",a),a;return[4,new Promise((function(e){return setTimeout(e,1e3*Math.pow(2,s))}))];case 6:return r.sent(),[3,7];case 7:return[3,1];case 8:return[2]}}))}))},e.prototype.sendBeaconEvents=function(e,t,n){void 0===n&&(n=!1);var o=new URLSearchParams;o.append("events",encodeURIComponent(JSON.stringify(e))),o.append("sessionId",encodeURIComponent(t)),o.append("timestamp",encodeURIComponent(Date.now().toString())),o.append("apiKey",encodeURIComponent(this.apiKey)),n&&(console.log("Session complete beacon sending"),localStorage.setItem("koalaware_session_complete",Date.now().toString()),o.append("sessionComplete",encodeURIComponent("true"))),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/events"),o)},e.prototype.sendBeaconSessionComplete=function(e){var t=new URLSearchParams;t.append("sessionId",e),t.append("apiKey",this.apiKey),t.append("sessionComplete","true"),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/sessionComplete"),t)},e.prototype.sendBeaconCustomEvent=function(e,t,n){var o=new URLSearchParams;return o.append("name",encodeURIComponent(e)),o.append("properties",encodeURIComponent(JSON.stringify(t))),o.append("sessionId",encodeURIComponent(n)),o.append("timestamp",encodeURIComponent((new Date).toISOString())),o.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/customEvent"),o)},e.prototype.sendBeaconCustomEvents=function(e,t){var o=new URLSearchParams;return o.append("events",encodeURIComponent(JSON.stringify(e.map((function(e){return n(n({},e),{sessionId:t})}))))),o.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon("".concat(this.baseUrl,"/api/ingestion/customEvent/batch"),o)},e}(),lt="undefined"!=typeof window,dt=function(){function e(e,t){if(this.eventIngestionQueue=[],this.queueSizeBytes=0,this.rejectedEvents=[],this.isProcessingRejectedEvents=!1,this.userProperties={},this.isProcessing=!1,this.flushInterval=null,this.FLUSH_INTERVAL_MS=5e3,this.endUserId=null,this.initialized=!1,this.initializationPromise=null,!e)throw new Error("Human Behavior API Key is required");if(!t)throw new Error("Human Behavior Ingestion URL is required");this.api=new ct({apiKey:e,ingestionUrl:t}),this.apiKey=e;var n=lt?localStorage.getItem("human_behavior_session_id"):null,o=lt?localStorage.getItem("human_behavior_last_activity"):null,r=Date.now()-18e5,s=o&&parseInt(o)>r;this.sessionId=n&&s?n:rt(),n&&s||!lt||localStorage.setItem("human_behavior_session_id",this.sessionId),this.initializationPromise=this.init()}return e.prototype.init=function(){return o(this,void 0,void 0,(function(){var e,t,n,o,s;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.getCookie("human_behavior_end_user_id_".concat(this.apiKey)),[4,this.api.init(this.sessionId,e)];case 1:return t=r.sent(),n=t.sessionId,o=t.endUserId,this.sessionId=n,this.endUserId=o,this.setCookie("human_behavior_end_user_id_".concat(this.apiKey),o,365),lt?(this.setupPageUnloadHandler(),this.start(),this.processRejectedEvents()):console.warn("HumanBehaviorTracker initialized in a non-browser environment. Session tracking is disabled."),this.initialized=!0,console.log("HumanBehaviorTracker initialized"),[3,3];case 2:throw s=r.sent(),console.error("Failed to initialize HumanBehaviorTracker:",s),s;case 3:return[2]}}))}))},e.prototype.ensureInitialized=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(!this.initializationPromise)throw new Error("HumanBehaviorTracker initialization failed");return[4,this.initializationPromise];case 1:return e.sent(),[2]}}))}))},e.logToStorage=function(e){try{var t=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]");t.push("".concat((new Date).toISOString(),": ").concat(e)),localStorage.setItem("human_behavior_logs",JSON.stringify(t))}catch(e){console.error("Failed to log to storage:",e)}},e.prototype.setupPageUnloadHandler=function(){var e=this;lt&&(console.log("Setting up page unload handler"),window.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&(console.log("Page hidden - sending pending events"),e.api.sendBeaconEvents(e.eventIngestionQueue,e.sessionId))})),window.addEventListener("beforeunload",(function(){localStorage.setItem("human_behavior_last_activity",Date.now().toString()),e.api.sendBeaconEvents(e.eventIngestionQueue,e.sessionId)})),setInterval((function(){localStorage.setItem("human_behavior_last_activity",Date.now().toString())}),6e4))},e.prototype.viewLogs=function(){try{var e=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]");console.log("HumanBehavior Logs:",e),localStorage.removeItem("human_behavior_logs")}catch(e){console.error("Failed to read logs:",e)}},e.prototype.identifyUser=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,this.ensureInitialized()];case 1:return t.sent(),this.userProperties=e,[4,this.api.sendUserData(this.endUserId,e,this.sessionId)];case 2:return t.sent(),[2]}}))}))},e.prototype.customEvent=function(e){return o(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r(this,(function(n){switch(n.label){case 0:return[4,this.ensureInitialized()];case 1:return n.sent(),this.api.sendBeaconCustomEvent(e,t,this.sessionId),[2]}}))}))},e.prototype.start=function(){return o(this,void 0,void 0,(function(){var e=this;return r(this,(function(t){switch(t.label){case 0:return[4,this.ensureInitialized()];case 1:return t.sent(),lt?(this.flushInterval=window.setInterval((function(){e.flush()}),this.FLUSH_INTERVAL_MS),$e({emit:function(t){e.addEvent(t)}}),[2]):[2]}}))}))},e.prototype.stop=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),lt?(this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),[2]):[2]}}))}))},e.prototype.addEvent=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return[4,this.ensureInitialized()];case 1:return n.sent(),t=(new TextEncoder).encode(JSON.stringify(e)).length,this.eventIngestionQueue.push(e),this.queueSizeBytes+=t,[2]}}))}))},e.prototype.processRejectedEvents=function(){return o(this,void 0,void 0,(function(){var e;return r(this,(function(t){if(this.isProcessingRejectedEvents||0===this.rejectedEvents.length)return[2];this.isProcessingRejectedEvents=!0;try{e=rt(),lt&&localStorage.setItem("human_behavior_session_id",e),this.api.sendBeaconEvents(this.rejectedEvents,e),this.rejectedEvents=[],this.sessionId=e}catch(e){console.error("Failed to process rejected events:",e)}finally{this.isProcessingRejectedEvents=!1}return[2]}))}))},e.prototype.flush=function(){return o(this,void 0,void 0,(function(){var e,t,n,o;return r(this,(function(r){switch(r.label){case 0:if(this.isProcessing||!this.initialized)return[2];this.isProcessing=!0,r.label=1;case 1:if(r.trys.push([1,,6,7]),e=this.eventIngestionQueue,this.eventIngestionQueue=[],this.queueSizeBytes=0,!(e.length>0))return[3,5];console.log("Flushing events:",e),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.api.sendEvents(e,this.sessionId,this.endUserId)];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!(null===(o=t.message)||void 0===o?void 0:o.includes("ERROR: Session already completed")))throw t;return console.log("Session expired, storing events for retry"),(n=this.rejectedEvents).push.apply(n,e),this.processRejectedEvents(),[3,5];case 5:return[3,7];case 6:return this.isProcessing=!1,[7];case 7:return[2]}}))}))},e.prototype.setCookie=function(e,t,n){if(lt){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);var r="expires=".concat(o.toUTCString());document.cookie="".concat(e,"=").concat(t,";").concat(r,";path=/;SameSite=Lax")}},e.prototype.getCookie=function(e){if(!lt)return null;for(var t=e+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){for(var r=n[o];" "===r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return r.substring(t.length,r.length)}return null},e}();lt&&(window.HumanBehaviorTracker=dt),e.HumanBehaviorAPI=ct,e.HumanBehaviorTracker=dt,e.MAX_CHUNK_SIZE_BYTES=st,e.default=dt,e.isChunkSizeExceeded=it,e.validateSingleEventSize=at,Object.defineProperty(e,"__esModule",{value:!0})}));
16
16
  //# sourceMappingURL=index.min.js.map