@dev-2-dev/websdk-plugin-session-tracker 0.9.1 → 0.9.2

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/browser.js CHANGED
@@ -12,4 +12,4 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,o){function i(e){try{a(r.next(e))}catch(e){o(e)}}function s(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,s)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ne(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=be[n[t]>>2],o+=be[(3&n[t])<<4|n[t+1]>>4],o+=be[(15&n[t+1])<<2|n[t+2]>>6],o+=be[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ne(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ne=(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 Ee(e,t,n){const r=[];try{const o=O(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...o){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}});r.push(o)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,o,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=O(e,i,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,s,this),!L(this.canvas,r,o,!0)){const e=Re([...a],s,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const o=x(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(o)}return a}var Oe=null;try{var Fe="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");Oe=Fe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),o=r.indexOf("\n",10)+1,i=r.substring(o)+"";return function(e){return new Oe(i,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),o=r.indexOf("\n",10)+1,i=r.substring(o)+"",s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESV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sNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29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JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const i=Ee(t,n,r),s=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ee(e,t,n),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=O(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...i],t,this);e(this.canvas,{type:J["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:J["2D"],property:s,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return o.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&o.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t}),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:o(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,Ye,ze=!1;const Je=new i;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:E=new Set([])}=e,x=!b||window.parent===window;let O=!1;if(!x)try{window.parent.document,O=!1}catch(e){O=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===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},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,o)=>{var i;if(!(null===(i=ne[0])||void 0===i?void 0:i.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===Y.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),o);else if(O){const t={type:"rrweb",event:K(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===Y.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,o=n&&e.timestamp-U.timestamp>n;(t||o)&&_e(!0)}};const z=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.CanvasMutation},e)})),P=new Ge({mutationCb:z,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:z,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});Ye=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:o,blockSelector:s,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:z,scrollCb:J,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:Ye,keepIframeSrcFn:N},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:F()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new i:r,s=n.blockClass,a=void 0===s?"rr-block":s,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,N=n.onSerialize,E=n.onIframeLoad,x=n.iframeLoadTimeout,O=n.onStylesheetLoad,F=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:o,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:N,onIframeLoad:E,iframeLoadTimeout:x,onStylesheetLoad:O,stylesheetLoadTimeout:F,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:N});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.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}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:z,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Selection},e)}))},blockClass:o,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:N,blockSelector:s,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:Ye,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=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),ze=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),ze=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!ze)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!ze)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Xe(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var ot=et(qe,0)[1],it=new He(32768),st=0;st<32768;++st){var at=(43690&st)>>>1|(21845&st)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,it[st]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,o=0,i=new He(t);o<r;++o)++i[e[o]-1];var s,a=new He(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new He(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)s[it[u]>>>c]=l}else for(s=new He(r),o=0;o<r;++o)s[o]=it[a[e[o]-1]++]>>>15-e[o];return s},lt=new Pe(288);for(st=0;st<144;++st)lt[st]=8;for(st=144;st<256;++st)lt[st]=9;for(st=256;st<280;++st)lt[st]=7;for(st=280;st<288;++st)lt[st]=8;var dt=new Pe(32);for(st=0;st<32;++st)dt[st]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new Pe(0),0];if(1==o){var s=new Pe(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<o;++r)i[r].s>h&&(h=i[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(i.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<o;++r){var C=i[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=i[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=i[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,o=gt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},bt=function(e,t,n,r,o,i,s,a,c,l,d){mt(t,d++,n),++o[256];for(var u=It(o,15),h=u[0],g=u[1],p=It(i,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var N,E,x,O,F=l+5<<3,D=vt(o,lt)+vt(i,dt)+s,L=vt(o,h)+vt(i,m)+s+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(F<=D&&F<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){N=ct(h,g,0),E=h,x=ct(m,f,0),O=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else N=ut,E=lt,x=ht,O=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,N[G+257]),d+=E[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=O[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,N[r[k]]),d+=E[r[k]];return ft(t,d,N[256]),d+E[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new Pe(r+s+5*(1+Math.floor(s/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||s<8)for(var d=0;d<=s;d+=65535){var u=d+65535;u<s?l=St(c,l,e.subarray(d,u)):(c[d]=i,l=St(c,l,e.subarray(d,s)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<s;++d){var N=v(d),E=32767&d,x=I[N];if(f[E]=x,I[N]=E,T<=d){var O=s-d;if((k>7e3||M>24576)&&O>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var F=0;F<286;++F)b[F]=0;for(F=0;F<30;++F)A[F]=0}var D=2,L=0,B=p,U=E-x&32767;if(O>2&&N==v(d-U))for(var W=Math.min(g,O)-1,Z=Math.min(32767,d),G=Math.min(258,O);U<=Z&&--B&&E!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(F=0;F<K;++F){var Y=d-U+F+32768&32767,z=Y-f[Y]+32768&32767;z>_&&(_=z,x=Y)}}}U+=(E=x)-(x=f[E])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|ot[L];var J=31&rt[D],Q=31&ot[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,i,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,o,i,s=kt(e,t,2,4);return r=s,o=t.level,i=0==o?0:o<6?1:9==o?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(s,s.length-4,n.d()),s}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new Pe(o+8+(n-s<<1));a.set(r),r=a}var c=e.charCodeAt(s);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++s))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return pt(r,0,o)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.1"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecording=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.pendingEvents=[],this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlTtl=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!0===t?.webSessions||n?.enabled||!0,maxBatchSize:1048576,maxSessionDuration:null,batchSize:50,batchInterval:3e4,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){this.context&&!this.isActive?(this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.sessionStartTime=Date.now(),this.sessionId=String(this.context.userManager.getSessionId()),this.sessionEvents=[],this.pendingEvents=[],this.currentSessionSize=0,this.lastBatchTime=Date.now(),this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlTtl=0,this.config.enableSessionRecording&&this.handleRecordingStart()):this.context?.logger.error("Session tracker is not initialized or already active")}async handleRecordingStart(){if(!this.context)return;const e=this.context.getPluginField("isRecordingActive"),t=this.context.isNewSession;if(t||!e){if(t||!e)try{const e=this.context.appManager.getAppId(),t=this.context.api.buildUrl(["sessions","configurations","get"],{appId:e}),n=await this.sendRequest(t,null,"GET");if(n&&n.data){const e=n.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),this.context.setPluginField("isRecordingActive",!1),void(this.isActive=!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1),this.isActive=!1}}else this.startSessionRecording()}stop(){this.isActive&&(this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.config.enableSessionRecording&&this.stopRecording&&(this.stopRecording(),this.stopRecording=null))}destroy(){this.stop(),this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}onUserChange(e){this.isActive&&(this.sessionStartTime=Date.now())}onFocus(){if(!this.context)return;const e=this.context.getPluginField("isRecordingActive");if(!this.isActive)return this.isActive=!0,void(this.config.enableSessionRecording&&e&&!this.stopRecording&&this.startSessionRecording());this.config.enableSessionRecording&&e&&!this.stopRecording&&this.startSessionRecording()}onBlur(){this.isActive&&(this.config.enableSessionRecording&&this.stopRecording&&(this.stopRecording(),this.stopRecording=null),this.isActive=!1,this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}))}onBeforeUnload(){this.isActive&&(this.stop(),this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}))}onTrackingChange(e){this.isActive&&(e?this.start():this.destroy())}onSessionStart(){this.isActive&&this.start()}onSessionEnd(){this.isActive&&this.stop()}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.fetchDelayedUrl();const e={emit:e=>{this.sessionEvents.push(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecording=t||null}checkBatchLimits(){const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=(this.config.batchSize||50),n=this.currentSessionSize>=(this.config.maxBatchSize||1048576),r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,o=Date.now()-this.lastBatchTime>=(this.config.batchInterval||3e4);(t||n||r||o)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context)return;const e=[...this.pendingEvents];this.pendingEvents=[];const t=e.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=t,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const t=e[0]?.timestamp||Date.now(),n=e[e.length-1]?.timestamp||Date.now(),r={appId:this.context.appManager.getAppId(),session_id:this.sessionId,user_id:this.context.userManager.getUserId(),start_time:t,end_time:n},o=this.context.api.buildUrl(["sessions","add"],r),i=await this.sendRequest(o,null,"GET",{},!0);if(204===i.status)return this.context.logger.warning("Session storage exceeded"),this.isActive=!1,void this.context?.setPluginField("isRecordingActive",!1);const s=i.data,a="string"==typeof s?s:s?.url;if(!a)throw new Error("No S3 URL returned");await this.uploadToS3(a,e),this.sentEventCount+=e.length,this.lastBatchTime=Date.now()}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:e.length}),t}finally{this.activeBatchCount--,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.appManager.getAppId(),t=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:e,user_id:this.context.userManager.getUserId()}),n=await this.sendRequest(t,null,"GET");if(n&&n.data){const e=n.data;this.delayedS3Url=e.url,this.delayedUrlTtl=e.ttl,this.scheduleDelayedUrlRefresh()}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const e=Math.max(0,this.delayedUrlTtl-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},e)}async sendFinalBatch(){if(!this.pendingEvents.length||!this.context)return;if(!this.delayedS3Url&&(this.context.logger.warning("No delayed URL available, attempting to fetch..."),await this.fetchDelayedUrl(),!this.delayedS3Url))return void this.context.logger.error("Failed to get delayed URL for final batch");const e=[...this.pendingEvents];this.pendingEvents=[],this.currentSessionSize=0;const t=JSON.stringify(e),n=new Blob([t],{type:"application/json"});fetch(this.delayedS3Url,{method:"PUT",body:n,keepalive:!0,credentials:"omit"}).then(e=>{if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}).catch(e=>{"TypeError"===e.name&&e.message.includes("Failed to fetch")||this.context?.logger.error(`Failed to send final batch: ${e}`)})}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},o=!1){return new Promise((i,s)=>{if(!this.context)return s(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?i({status:e,data:t}):s({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:o})})}}"undefined"!=typeof window&&(window.D2DWebSessionTracker=Tt)}();
15
+ ***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,o){function i(e){try{a(r.next(e))}catch(e){o(e)}}function s(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,s)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ne(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=be[n[t]>>2],o+=be[(3&n[t])<<4|n[t+1]>>4],o+=be[(15&n[t+1])<<2|n[t+2]>>6],o+=be[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ne(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ne=(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 Ee(e,t,n){const r=[];try{const o=O(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...o){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}});r.push(o)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,o,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=O(e,i,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,s,this),!L(this.canvas,r,o,!0)){const e=Re([...a],s,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const o=x(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(o)}return a}var Oe=null;try{var Fe="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");Oe=Fe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),o=r.indexOf("\n",10)+1,i=r.substring(o)+"";return function(e){return new Oe(i,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),o=r.indexOf("\n",10)+1,i=r.substring(o)+"",s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQ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Wxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const i=Ee(t,n,r),s=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ee(e,t,n),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=O(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...i],t,this);e(this.canvas,{type:J["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:J["2D"],property:s,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return o.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&o.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t}),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:o(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,Ye,ze=!1;const Je=new i;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:E=new Set([])}=e,x=!b||window.parent===window;let O=!1;if(!x)try{window.parent.document,O=!1}catch(e){O=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===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},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,o)=>{var i;if(!(null===(i=ne[0])||void 0===i?void 0:i.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===Y.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),o);else if(O){const t={type:"rrweb",event:K(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===Y.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,o=n&&e.timestamp-U.timestamp>n;(t||o)&&_e(!0)}};const z=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.CanvasMutation},e)})),P=new Ge({mutationCb:z,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:z,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});Ye=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:o,blockSelector:s,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:z,scrollCb:J,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:Ye,keepIframeSrcFn:N},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:F()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new i:r,s=n.blockClass,a=void 0===s?"rr-block":s,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,N=n.onSerialize,E=n.onIframeLoad,x=n.iframeLoadTimeout,O=n.onStylesheetLoad,F=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:o,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:N,onIframeLoad:E,iframeLoadTimeout:x,onStylesheetLoad:O,stylesheetLoadTimeout:F,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:N});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.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}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:z,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:Y.Selection},e)}))},blockClass:o,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:N,blockSelector:s,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:Ye,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=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),ze=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),ze=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!ze)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!ze)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Xe(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var ot=et(qe,0)[1],it=new He(32768),st=0;st<32768;++st){var at=(43690&st)>>>1|(21845&st)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,it[st]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,o=0,i=new He(t);o<r;++o)++i[e[o]-1];var s,a=new He(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new He(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)s[it[u]>>>c]=l}else for(s=new He(r),o=0;o<r;++o)s[o]=it[a[e[o]-1]++]>>>15-e[o];return s},lt=new Pe(288);for(st=0;st<144;++st)lt[st]=8;for(st=144;st<256;++st)lt[st]=9;for(st=256;st<280;++st)lt[st]=7;for(st=280;st<288;++st)lt[st]=8;var dt=new Pe(32);for(st=0;st<32;++st)dt[st]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new Pe(0),0];if(1==o){var s=new Pe(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<o;++r)i[r].s>h&&(h=i[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(i.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<o;++r){var C=i[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=i[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=i[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,o=gt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},bt=function(e,t,n,r,o,i,s,a,c,l,d){mt(t,d++,n),++o[256];for(var u=It(o,15),h=u[0],g=u[1],p=It(i,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var N,E,x,O,F=l+5<<3,D=vt(o,lt)+vt(i,dt)+s,L=vt(o,h)+vt(i,m)+s+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(F<=D&&F<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){N=ct(h,g,0),E=h,x=ct(m,f,0),O=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else N=ut,E=lt,x=ht,O=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,N[G+257]),d+=E[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=O[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,N[r[k]]),d+=E[r[k]];return ft(t,d,N[256]),d+E[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new Pe(r+s+5*(1+Math.floor(s/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||s<8)for(var d=0;d<=s;d+=65535){var u=d+65535;u<s?l=St(c,l,e.subarray(d,u)):(c[d]=i,l=St(c,l,e.subarray(d,s)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<s;++d){var N=v(d),E=32767&d,x=I[N];if(f[E]=x,I[N]=E,T<=d){var O=s-d;if((k>7e3||M>24576)&&O>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var F=0;F<286;++F)b[F]=0;for(F=0;F<30;++F)A[F]=0}var D=2,L=0,B=p,U=E-x&32767;if(O>2&&N==v(d-U))for(var W=Math.min(g,O)-1,Z=Math.min(32767,d),G=Math.min(258,O);U<=Z&&--B&&E!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(F=0;F<K;++F){var Y=d-U+F+32768&32767,z=Y-f[Y]+32768&32767;z>_&&(_=z,x=Y)}}}U+=(E=x)-(x=f[E])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|ot[L];var J=31&rt[D],Q=31&ot[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,i,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,o,i,s=kt(e,t,2,4);return r=s,o=t.level,i=0==o?0:o<6?1:9==o?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(s,s.length-4,n.d()),s}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new Pe(o+8+(n-s<<1));a.set(r),r=a}var c=e.charCodeAt(s);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++s))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return pt(r,0,o)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.2"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecording=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.pendingEvents=[],this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlTtl=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!0===t?.webSessions||n?.enabled||!0,maxBatchSize:1048576,maxSessionDuration:null,batchSize:50,batchInterval:3e4,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){this.context&&!this.isActive?(this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.sessionStartTime=Date.now(),this.sessionId=String(this.context.userManager.getSessionId()),this.sessionEvents=[],this.pendingEvents=[],this.currentSessionSize=0,this.lastBatchTime=Date.now(),this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlTtl=0,this.config.enableSessionRecording&&this.handleRecordingStart()):this.context?.logger.error("Session tracker is not initialized or already active")}async handleRecordingStart(){if(!this.context)return;const e=this.context.getPluginField("isRecordingActive"),t=this.context.isNewSession;if(t||!e){if(t||!e)try{const e=this.context.appManager.getAppId(),t=this.context.api.buildUrl(["sessions","configurations","get"],{appId:e}),n=await this.sendRequest(t,null,"GET");if(n&&n.data){const e=n.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),this.context.setPluginField("isRecordingActive",!1),void(this.isActive=!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1),this.isActive=!1}}else this.startSessionRecording()}stop(){this.isActive&&(this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.config.enableSessionRecording&&this.stopRecording&&(this.stopRecording(),this.stopRecording=null))}destroy(){this.stop(),this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}onUserChange(e){this.isActive&&(this.sessionStartTime=Date.now())}onFocus(){if(!this.context)return;const e=this.context.getPluginField("isRecordingActive");if(!this.isActive)return this.isActive=!0,void(this.config.enableSessionRecording&&e&&!this.stopRecording&&this.startSessionRecording());this.config.enableSessionRecording&&e&&!this.stopRecording&&this.startSessionRecording()}onBlur(){this.isActive&&(this.config.enableSessionRecording&&this.stopRecording&&(this.stopRecording(),this.stopRecording=null),this.isActive=!1,this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}))}onBeforeUnload(){this.isActive&&(this.stop(),this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}))}onTrackingChange(e){this.isActive&&(e?this.start():this.destroy())}onSessionStart(){this.isActive&&this.start()}onSessionEnd(){this.isActive&&this.stop()}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.lastBatchTime=Date.now(),Promise.race([this.fetchDelayedUrl(),new Promise((e,t)=>setTimeout(()=>t(new Error("fetchDelayedUrl timeout during recording start")),1e4))]).catch(e=>{this.context?.logger.error("Failed to fetch delayed URL when starting recording",{error:e})});const e={emit:e=>{this.sessionEvents.push(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,2!==e.type?this.checkBatchLimits():this.sendBatchToBackend()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecording=t||null}checkBatchLimits(){const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,o=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||o)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context)return;const e=[...this.pendingEvents];this.pendingEvents=[];const t=e.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=t,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const t=e[0]?.timestamp||Date.now(),n=e[e.length-1]?.timestamp||Date.now(),r={appId:this.context.appManager.getAppId(),session_id:this.sessionId,user_id:this.context.userManager.getUserId(),start_time:t,end_time:n},o=this.context.api.buildUrl(["sessions","add"],r),i=await this.sendRequest(o,null,"GET",{},!0);if(204===i.status)return this.context.logger.warning("Session storage exceeded"),this.isActive=!1,void this.context?.setPluginField("isRecordingActive",!1);const s=i.data,a="string"==typeof s?s:s?.url;if(!a)throw new Error("No S3 URL returned");await this.uploadToS3(a,e),this.sentEventCount+=e.length,this.lastBatchTime=Date.now()}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:e.length}),t}finally{this.activeBatchCount--,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.appManager.getAppId(),t=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:e,user_id:this.context.userManager.getUserId()}),n=await this.sendRequest(t,null,"GET");if(n&&n.data){const e=n.data;this.delayedS3Url=e.url,this.delayedUrlTtl=e.ttl,this.scheduleDelayedUrlRefresh()}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const e=Math.max(0,this.delayedUrlTtl-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},e)}async sendFinalBatch(){if(!this.pendingEvents.length||!this.context)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const e=[...this.pendingEvents];this.pendingEvents=[],this.currentSessionSize=0;const t=JSON.stringify(e),n=new Blob([t],{type:"application/json"});fetch(this.delayedS3Url,{method:"PUT",body:n,keepalive:!0,credentials:"omit"}).then(e=>{if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}).catch(e=>{"TypeError"===e.name&&e.message.includes("Failed to fetch")||this.context?.logger.error(`Failed to send final batch: ${e}`)})}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},o=!1){return new Promise((i,s)=>{if(!this.context)return s(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?i({status:e,data:t}):s({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:o})})}}"undefined"!=typeof window&&(window.D2DWebSessionTracker=Tt)}();