humanbehavior-js 0.1.1 → 0.1.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/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/simple-demo.html +26 -0
- package/src/tracker.ts +1 -0
package/dist/index.min.js
CHANGED
|
@@ -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 Ae(e,t,n,o){return new(n||(n=Promise))(function(t,i){function r(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(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(r,s)}a((o=o.apply(e,[])).next())})}for(var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ee="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Te=0;Te<64;Te++)Ee[ke.charCodeAt(Te)]=Te;const Re=new Map;const Me=(e,t,n)=>{if(!e||!Fe(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Re.get(e);return n||(n=new Map,Re.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let i=o.indexOf(e);return-1===i&&(i=o.length,o.push(e)),i};function Ne(e,t,n){if(e instanceof Array)return e.map(e=>Ne(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,i="";for(t=0;t<o;t+=3)i+=ke[n[t]>>2],i+=ke[(3&n[t])<<4|n[t+1]>>4],i+=ke[(15&n[t+1])<<2|n[t+2]>>6],i+=ke[63&n[t+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ne(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:[Ne(e.data,t,n),e.width,e.height]}}if(Fe(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Oe=(e,t,n)=>[...e].map(e=>Ne(e,t,n)),Fe=(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 xe(e,t,n){const o=[];try{const i=D(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){return W(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...i])}});o.push(i)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function Le(e,t,n,o,i,r,s){const a=[],c=Object.getOwnPropertyNames(e);for(const r of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(r))try{if("function"!=typeof e[r])continue;const c=D(e,r,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,s,this),!W(this.canvas,o,i,!0)){const e=Oe([...a],s,this),o={type:t,property:r,args:e};n(this.canvas,o)}return c}});a.push(c)}catch(o){const i=L(e,r,{set(e){n(this.canvas,{type:t,property:r,args:[e],setter:!0})}});a.push(i)}return a}var De=null;try{var Ue="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");De=Ue.Worker}catch(e){}function Be(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),i=o.indexOf("\n",10)+1,r=o.substring(i)+"";return function(e){return new De(r,Object.assign({},e,{eval:!0}))}}function We(e,t,n){var o=function(e){return atob(e)}(e),i=o.indexOf("\n",10)+1,r=o.substring(i)+"",s=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(s)}var _e="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ge,Ze=(Ge="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUV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1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNC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FyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",_e?Be(Ge):function(e){var t;return function(n){return t=t||We(e),new Worker(t,n)}}(Ge));class Ve{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:i,recordCanvas:r,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(n,o,i),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,i,{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,o,i){const r=xe(t,n,o),s=new Map,a=new Ze;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:i,height:r}=e.data;this.mutationCb({id:t,type:H["2D"],commands:[{property:"clearRect",args:[0,0,i,r]},{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=>{W(t,n,o,!0)||e.push(t)}),e})().forEach(e=>Ae(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 o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[o])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{r(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=xe(e,t,n),i=function(e,t,n,o){const i=[],r=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of r)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const r=D(t.CanvasRenderingContext2D.prototype,s,function(i){return function(...r){return W(this.canvas,n,o,!0)||setTimeout(()=>{const n=Oe([...r],t,this);e(this.canvas,{type:H["2D"],property:s,args:n})},0),i.apply(this,r)}});i.push(r)}catch(n){const o=L(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:H["2D"],property:s,args:[t],setter:!0})}});i.push(o)}return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),r=function(e,t,n,o){const i=[];return i.push(...Le(t.WebGLRenderingContext.prototype,H.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&i.push(...Le(t.WebGL2RenderingContext.prototype,H.WebGL2,e,n,o,0,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),i(),r()}}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 i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}(e,["type"]);return t}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:o}),this.pendingCanvasMutations.delete(e)}}class Ke{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new P,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:s(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 ze(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Pe,je,Je,Ye=!1;const He=new a;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:i="rr-block",blockSelector:r=null,ignoreClass:s="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:y={},dataURLOptions:C={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:w=!1,collectFonts:A=!1,inlineImages:k=!1,plugins:E,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:R=new Set([])}=e,O=!b||window.parent===window;let F=!1;if(!O)try{window.parent.document,F=!1}catch(e){F=!0}if(O&&!t)throw new Error("emit function is required");void 0!==v&&void 0===y.mousemove&&(y.mousemove=v),He.reset();const x=!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===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 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 W=0;const _=e=>{for(const t of E||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Pe=(e,i)=>{var r;if(!(null===(r=re[0])||void 0===r?void 0:r.isFrozen())||e.type===j.FullSnapshot||e.type===j.IncrementalSnapshot&&e.data.source===J.Mutation||re.forEach(e=>e.unfreeze()),O)null==t||t(_(e),i);else if(F){const t={type:"rrweb",event:_(e),isCheckout:i};window.parent.postMessage(t,"*")}if(e.type===j.FullSnapshot)D=e,W=0;else if(e.type===j.IncrementalSnapshot){if(e.data.source===J.Mutation&&e.data.isAttachIframe)return;W++;const t=o&&W>=o,i=n&&e.timestamp-D.timestamp>n;(t||i)&&je(!0)}};const G=e=>{Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Mutation},e)}))},Z=e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Scroll},e)})),P=e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.CanvasMutation},e)})),Y=new Ke({mutationCb:G,adoptedStyleSheetCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.AdoptedStyleSheet},e)}))}),H=new be({mirror:He,mutationCb:G,stylesheetManager:Y,recordCrossOriginIframes:b,wrappedEmit:Pe});for(const e of E||[])e.getMirror&&e.getMirror({nodeMirror:He,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});Je=new Ve({recordCanvas:S,mutationCb:P,win:window,blockClass:i,blockSelector:r,mirror:He,sampling:y.canvas,dataURLOptions:C});const Q=new we({mutationCb:G,scrollCb:Z,bypassOptions:{blockClass:i,blockSelector:r,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:x,dataURLOptions:C,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:y,slimDOMOptions:L,iframeManager:H,stylesheetManager:Y,canvasManager:Je,keepIframeSrcFn:T},mirror:He});je=(e=!1)=>{var t,n,o,s,u,h;Pe(ze({type:j.Meta,data:{href:window.location.href,width:B(),height:U()}}),e),Y.reset(),re.forEach(e=>e.lock());const g=function(e,t){var n=t||{},o=n.mirror,i=void 0===o?new a:o,r=n.blockClass,s=void 0===r?"rr-block":r,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,y=n.recordCanvas,C=void 0!==y&&y,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,w=n.maskInputFn,A=n.slimDOM,k=void 0!==A&&A,E=n.dataURLOptions,T=n.preserveWhiteSpace,R=n.onSerialize,N=n.onIframeLoad,O=n.iframeLoadTimeout,F=n.onStylesheetLoad,x=n.stylesheetLoadTimeout,L=n.keepIframeSrcFn;return M(e,{doc:e,mirror:i,blockClass:s,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:w,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:E,inlineImages:I,recordCanvas:C,preserveWhiteSpace:T,onSerialize:R,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:F,stylesheetLoadTimeout:x,keepIframeSrcFn:void 0===L?function(){return!1}:L,newlyAddedElement:!1})}(document,{mirror:He,blockClass:i,blockSelector:r,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:x,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:S,inlineImages:k,onSerialize:e=>{V(e,He)&&H.addIframe(e),K(e,He)&&Y.trackLinkElement(e),z(e)&&Q.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),Q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Y.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!g)return console.warn("Failed to snapshot the document");Pe(ze({type:j.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===(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===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.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}}})),re.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Y.adoptStyleSheets(document.adoptedStyleSheets,He.getId(document))};try{const e=[];e.push(N("DOMContentLoaded",()=>{Pe(ze({type:j.DomContentLoaded,data:{}}))}));const t=e=>{var t;return ve({mutationCb:G,mousemoveCb:(e,t)=>Pe(ze({type:j.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.MouseInteraction},e)})),scrollCb:Z,viewportResizeCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.ViewportResize},e)})),inputCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Input},e)})),mediaInteractionCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.MediaInteraction},e)})),styleSheetRuleCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.StyleSheetRule},e)})),styleDeclarationCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.StyleDeclaration},e)})),canvasMutationCb:P,fontCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Font},e)})),selectionCb:e=>{Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Selection},e)}))},blockClass:i,ignoreClass:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:x,inlineStylesheet:d,sampling:y,recordCanvas:S,inlineImages:k,userTriggeredOnInput:w,collectFonts:A,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:T,blockSelector:r,slimDOMOptions:L,dataURLOptions:C,mirror:He,iframeManager:H,stylesheetManager:Y,shadowDomManager:Q,canvasManager:Je,ignoreCSSAttributes:R,plugins:(null===(t=null==E?void 0:E.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Pe(ze({type:j.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{je(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(N("load",()=>{Pe(ze({type:j.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){console.warn(e)}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Pe(ze({type:j.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{re.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");je(e)},Qe.mirror=He;const qe=[];for(let e=0;e<256;++e)qe.push((e+256).toString(16).slice(1));let Xe;const $e=new Uint8Array(16);const et={};function tt(e,t,n){let o;{const e=Date.now(),i=function(){if(!Xe){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Xe=crypto.getRandomValues.bind(crypto)}return Xe($e)}();!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}(et,e,i),o=function(e,t,n,o,i,r,s=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(r){if(s<0||s+16>r.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`)}else r=new Uint8Array(16),s=0;t??=Date.now(),n??=0,o??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+n)%4294967296;r[s++]=a>>>24&255,r[s++]=a>>>16&255,r[s++]=a>>>8&255,r[s++]=255&a;const c=t/4294967296*1e4&268435455;r[s++]=c>>>8&255,r[s++]=255&c,r[s++]=c>>>24&15|16,r[s++]=c>>>16&255,r[s++]=o>>>8|128,r[s++]=255&o;for(let e=0;e<6;++e)r[s++]=i[e];return r}(i,et.msecs,et.nsecs,et.clockseq,et.node,t,n)}return t??function(e,t=0){return(qe[e[t+0]]+qe[e[t+1]]+qe[e[t+2]]+qe[e[t+3]]+"-"+qe[e[t+4]]+qe[e[t+5]]+"-"+qe[e[t+6]]+qe[e[t+7]]+"-"+qe[e[t+8]]+qe[e[t+9]]+"-"+qe[e[t+10]]+qe[e[t+11]]+qe[e[t+12]]+qe[e[t+13]]+qe[e[t+14]]+qe[e[t+15]]).toLowerCase()}(o)}var nt;e.LogLevel=void 0,(nt=e.LogLevel||(e.LogLevel={}))[nt.NONE=0]="NONE",nt[nt.ERROR=1]="ERROR",nt[nt.WARN=2]="WARN",nt[nt.INFO=3]="INFO",nt[nt.DEBUG=4]="DEBUG";const ot=new class{constructor(t){this.config={level:e.LogLevel.ERROR,enableConsole:!0,enableStorage:!1},this.isBrowser="undefined"!=typeof window,t&&(this.config=Object.assign(Object.assign({},this.config),t))}setConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}shouldLog(e){return e<=this.config.level}formatMessage(e,t,...n){return`[HumanBehavior ${e}] ${(new Date).toISOString()}: ${t}`}error(t,...n){if(!this.shouldLog(e.LogLevel.ERROR))return;const o=this.formatMessage("ERROR",t);this.config.enableConsole&&console.error(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}warn(t,...n){if(!this.shouldLog(e.LogLevel.WARN))return;const o=this.formatMessage("WARN",t);this.config.enableConsole&&console.warn(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}info(t,...n){if(!this.shouldLog(e.LogLevel.INFO))return;const o=this.formatMessage("INFO",t);this.config.enableConsole&&console.log(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}debug(t,...n){if(!this.shouldLog(e.LogLevel.DEBUG))return;const o=this.formatMessage("DEBUG",t);this.config.enableConsole&&console.log(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}logToStorage(e,t){try{const n=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]"),o={message:e,args:t.length>0?t:void 0,timestamp:Date.now()};n.push(o),n.length>1e3&&n.splice(0,n.length-1e3),localStorage.setItem("human_behavior_logs",JSON.stringify(n))}catch(e){}}getLogs(){if(!this.isBrowser)return[];try{return JSON.parse(localStorage.getItem("human_behavior_logs")||"[]")}catch(e){return[]}}clearLogs(){this.isBrowser&&localStorage.removeItem("human_behavior_logs")}},it=(e,...t)=>ot.error(e,...t),rt=(e,...t)=>ot.warn(e,...t),st=(e,...t)=>ot.info(e,...t),at=(e,...t)=>ot.debug(e,...t),ct=10485760;function lt(e,t,n){return(new TextEncoder).encode(JSON.stringify({sessionId:n,events:[...e,t]})).length>ct}function dt(e,t){const n=(new TextEncoder).encode(JSON.stringify({sessionId:t,events:[e]})).length;if(n>ct)throw new Error(`Single event size (${n} bytes) exceeds maximum chunk size (10485760 bytes)`)}class ut{constructor({apiKey:e,ingestionUrl:t}){this.apiKey=e,this.baseUrl=t}init(e,n){return t(this,void 0,void 0,function*(){let t=null,o=null;"undefined"!=typeof window&&(t=window.location.href,o=document.referrer);const i=yield fetch(`${this.baseUrl}/api/ingestion/init`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,Referer:o||""},body:JSON.stringify({sessionId:e,endUserId:n,entryURL:t,referrer:o})});if(!i.ok)throw new Error(`Failed to initialize ingestion: ${i.statusText}`);const r=yield i.json();return{sessionId:r.sessionId,endUserId:r.endUserId}})}sendEvents(e,n,o){return t(this,void 0,void 0,function*(){const t=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:e,endUserId:o})});if(!t.ok)throw new Error(`Failed to send events: ${t.statusText}`)})}sendEventsChunked(e,n){return t(this,void 0,void 0,function*(){try{const t=[];let o=[];for(const i of e)if(lt(o,i,n)){if(o.length>0){const e=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:o})});if(!e.ok)throw new Error(`Failed to send events: ${e.statusText}`);t.push(yield e.json()),o=[]}dt(i,n),o=[i]}else o.push(i);if(o.length>0){const e=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:o})});if(!e.ok)throw new Error(`Failed to send events: ${e.statusText}`);t.push(yield e.json())}return t.flat()}catch(e){throw it("Error sending events:",e),e}})}sendUserData(e,n,o){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`${this.baseUrl}/api/ingestion/user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({userId:e,userAttributes:n,sessionId:o})});if(!t.ok)throw new Error(`Failed to send user data: ${t.statusText} with API key: ${this.apiKey}`);return yield t.json()}catch(e){throw it("Error sending user data:",e),e}})}sendUserAuth(e,n,o,i){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`${this.baseUrl}/api/ingestion/user/auth`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({userId:e,userAttributes:n,sessionId:o,authFields:i})});if(!t.ok)throw new Error(`Failed to authenticate user: ${t.statusText} with API key: ${this.apiKey}`);return yield t.json()}catch(e){throw it("Error authenticating user:",e),e}})}sendBeaconEvents(e,t){const n=new URLSearchParams;n.append("events",encodeURIComponent(JSON.stringify(e))),n.append("sessionId",encodeURIComponent(t)),n.append("timestamp",encodeURIComponent(Date.now().toString())),n.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon(`${this.baseUrl}/api/ingestion/events`,n)}}const ht="undefined"!=typeof window;class gt{constructor(e){this.redactedText="[REDACTED]",this.userSelectedFields=new Set,this.excludeSelectors=['[data-no-redact="true"]',".human-behavior-no-redact"],(null==e?void 0:e.redactedText)&&(this.redactedText=e.redactedText),(null==e?void 0:e.excludeSelectors)&&(this.excludeSelectors=[...this.excludeSelectors,...e.excludeSelectors]),(null==e?void 0:e.userFields)&&this.setFieldsToRedact(e.userFields)}setFieldsToRedact(e){this.userSelectedFields.clear(),e.forEach(e=>this.userSelectedFields.add(e)),e.length>0?(at(`Redaction: Active for ${e.length} field(s):`,e),e.forEach(e=>{const t=document.querySelectorAll(e);at(`Redaction: Found ${t.length} element(s) for selector '${e}'`),t.forEach((t,n)=>{at(`Redaction: Element ${n} for '${e}':`,t)})})):at("Redaction: Disabled - no fields selected")}isActive(){return this.userSelectedFields.size>0}getSelectedFields(){return Array.from(this.userSelectedFields)}processEvent(e){if(0===this.userSelectedFields.size)return e;const t=JSON.parse(JSON.stringify(e));if(3===t.type)if(5===t.data.source){this.isFieldSelected(t.data)&&(at("Redaction: Processing input event for redaction"),this.redactInputEvent(t.data))}else 0===t.data.source?this.redactDOMEvent(t.data):2===t.data.source&&this.redactMouseEvent(t.data);else 2===t.type&&this.redactFullSnapshot(t.data);return t}redactInputEvent(e){if(!this.isFieldSelected(e))return;at("Redaction: Redacting input event with text:",e.text);["text","value","content","data","input","textContent"].forEach(t=>{void 0!==e[t]&&"string"==typeof e[t]&&(e[t]=this.redactedText,at(`Redaction: Redacted property '${t}'`))}),Object.keys(e).forEach(t=>{"string"==typeof e[t]&&e[t].length>0&&(e[t]=this.redactedText,at(`Redaction: Redacted additional property '${t}'`))}),e.attributes&&"object"==typeof e.attributes&&e.attributes.value&&"string"==typeof e.attributes.value&&(e.attributes.value=this.redactedText,at("Redaction: Redacted nested value attribute")),at("Redaction: Input event redaction complete")}redactDOMEvent(e){e.texts&&Array.isArray(e.texts)&&e.texts.forEach(e=>{e.text&&"string"==typeof e.text&&this.shouldRedactDOMChange(e)&&(e.text=this.redactedText)}),e.attributes&&Array.isArray(e.attributes)&&e.attributes.forEach(e=>{e.attributes&&e.attributes.value&&"string"==typeof e.attributes.value&&this.shouldRedactDOMChange(e)&&(e.attributes.value=this.redactedText)}),e.adds&&Array.isArray(e.adds)&&e.adds.forEach(e=>{e.node&&e.node.textContent&&"string"==typeof e.node.textContent&&this.shouldRedactDOMChange(e)&&(e.node.textContent=this.redactedText)})}shouldRedactDOMChange(e){if(!ht)return!1;try{const t=e.id;if(void 0!==t){let e=document.querySelector(`[data-rrweb-id="${t}"]`);if(e)return this.shouldRedactElement(e)}const n=e.nodeId;if(void 0!==n){const e=document.querySelector(`[data-rrweb-id="${n}"]`);if(e)return this.shouldRedactElement(e)}return!1}catch(e){return rt("Error checking if DOM change should be redacted:",e),!1}}redactMouseEvent(e){e.text&&"string"==typeof e.text&&this.isFieldSelected(e)&&(e.text=this.redactedText)}redactFullSnapshot(e){e.node&&2===e.node.type&&this.redactNode(e.node)}redactNode(e){e&&(2!==e.type||!e.tagName||"input"!==e.tagName.toLowerCase()&&"textarea"!==e.tagName.toLowerCase()||this.shouldRedactNode(e)&&(e.attributes&&e.attributes.value&&(e.attributes.value=this.redactedText),e.textContent&&(e.textContent=this.redactedText)),e.childNodes&&Array.isArray(e.childNodes)&&e.childNodes.forEach(e=>{this.redactNode(e)}))}shouldRedactNode(e){if(!e.attributes)return!1;for(const t of this.userSelectedFields)if(this.selectorMatchesNode(t,e))return!0;return!1}selectorMatchesNode(e,t){if(!t.attributes)return!1;try{const n=document.createElement(t.tagName||"div");return t.attributes&&Object.keys(t.attributes).forEach(e=>{n.setAttribute(e,t.attributes[e])}),n.matches(e)}catch(n){return this.basicSelectorMatch(e,t)}}basicSelectorMatch(e,t){if(!t.attributes)return!1;if(e.includes("input[type=")){const n=e.match(/input\[type="([^"]+)"\]/);if(n&&"input"===t.tagName&&t.attributes.type===n[1])return!0}if(e.startsWith("#")){const n=e.substring(1);return t.attributes.id===n}if(e.startsWith(".")){const n=e.substring(1);return t.attributes.class&&t.attributes.class.includes(n)}return!e.includes("[")&&!e.includes(".")&&(t.tagName&&t.tagName.toLowerCase()===e.toLowerCase())}isFieldSelected(e){if(!ht)return!1;try{if(5===e.source){const t=e.id;if(void 0!==t){let n=document.querySelector(`[data-rrweb-id="${t}"]`);if(n)return this.shouldRedactElement(n);if(void 0!==e.nodeId&&(n=document.querySelector(`[data-rrweb-id="${e.nodeId}"]`),n))return this.shouldRedactElement(n);for(const e of this.userSelectedFields){const t=document.querySelectorAll(e);if(t.length>0)for(const n of t)if(n===document.activeElement)return at("Redaction: Found focused element matching selector:",e),!0}const o=document.activeElement;return!(!o||!this.shouldRedactElement(o))&&(at("Redaction: Active element should be redacted"),!0)}}const t=e.id;if(void 0!==t){let e=document.querySelector(`[data-rrweb-id="${t}"]`);if(e)return this.shouldRedactElement(e)}const n=e.nodeId;if(void 0!==n){const e=document.querySelector(`[data-rrweb-id="${n}"]`);if(e)return this.shouldRedactElement(e)}if(e.target&&e.target.id){const t=document.querySelector(`[data-rrweb-id="${e.target.id}"]`);if(t)return this.shouldRedactElement(t)}return!1}catch(e){return rt("Error checking if field should be redacted:",e),!1}}shouldRedactElement(e){for(const t of this.excludeSelectors)if(e.matches(t)||e.closest(t))return!1;for(const t of this.userSelectedFields)if(e.matches(t))return!0;return!1}getOriginalValue(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.value}isElementRedacted(e){return this.shouldRedactElement(e)}}const pt=new gt,mt="undefined"!=typeof window;class ft{static init(e,t){if(mt&&window.__humanBehaviorGlobalTracker)return at("Tracker already initialized, returning existing instance"),window.__humanBehaviorGlobalTracker;(null==t?void 0:t.logLevel)&&this.configureLogging({level:t.logLevel});const n=new ft(e,null==t?void 0:t.ingestionUrl);if((null==t?void 0:t.redactFields)&&n.setRedactedFields(t.redactFields),mt){const e=n.api.baseUrl+"/api/health";fetch(e,{method:"HEAD"}).then(()=>at("Connection test successful")).catch(e=>{rt("Connection test failed - ad blocker may be active:",e.message),n._connectionBlocked=!0})}return n.start(),n}constructor(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,this.originalConsole=null,this.consoleTrackingEnabled=!1,this.navigationTrackingEnabled=!1,this.currentUrl="",this.previousUrl="",this.originalPushState=null,this.originalReplaceState=null,this.navigationListeners=[],this._connectionBlocked=!1,!e)throw new Error("Human Behavior API Key is required");if(this.api=new ut({apiKey:e,ingestionUrl:t||"http://3.137.217.33:3000"}),this.apiKey=e,this.redactionManager=new gt,mt){const e=localStorage.getItem("human_behavior_session_id"),t=localStorage.getItem("human_behavior_last_activity"),n=Date.now()-18e5;e&&t&&parseInt(t)>n?(this.sessionId=e,at(`Reusing existing session: ${this.sessionId}`),localStorage.setItem("human_behavior_last_activity",Date.now().toString())):(e&&(at(`Session expired, clearing old session: ${e}`),localStorage.removeItem("human_behavior_session_id"),localStorage.removeItem("human_behavior_last_activity")),this.sessionId=tt(),at(`Creating new session: ${this.sessionId}`),localStorage.setItem("human_behavior_session_id",this.sessionId),localStorage.setItem("human_behavior_last_activity",Date.now().toString())),this.currentUrl=window.location.href,window.__humanBehaviorGlobalTracker=this}else this.sessionId=tt();this.initializationPromise=this.init()}init(){return t(this,void 0,void 0,function*(){try{const e=this.getCookie(`human_behavior_end_user_id_${this.apiKey}`);at(`Initializing with sessionId: ${this.sessionId}, userId: ${e}`);const{sessionId:t,endUserId:n}=yield this.api.init(this.sessionId,e);t!==this.sessionId&&(at(`Server returned different sessionId: ${t} (client had: ${this.sessionId})`),this.sessionId=t,mt&&localStorage.setItem("human_behavior_session_id",this.sessionId)),this.endUserId=n,this.setCookie(`human_behavior_end_user_id_${this.apiKey}`,n,365),mt?(this.setupPageUnloadHandler(),this.setupNavigationTracking(),this.processRejectedEvents()):rt("HumanBehaviorTracker initialized in a non-browser environment. Session tracking is disabled."),this.initialized=!0,st(`HumanBehaviorTracker initialized with sessionId: ${this.sessionId}, endUserId: ${n}`)}catch(e){throw it("Failed to initialize HumanBehaviorTracker:",e),e}})}ensureInitialized(){return t(this,void 0,void 0,function*(){if(!this.initializationPromise)throw new Error("HumanBehaviorTracker initialization failed");yield this.initializationPromise})}setupNavigationTracking(){if(!mt||this.navigationTrackingEnabled)return;this.navigationTrackingEnabled=!0,at("Setting up navigation tracking"),this.originalPushState=history.pushState,this.originalReplaceState=history.replaceState,history.pushState=(...e)=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.originalPushState.apply(history,e),this.trackNavigationEvent("pushState",this.previousUrl,this.currentUrl)},history.replaceState=(...e)=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.originalReplaceState.apply(history,e),this.trackNavigationEvent("replaceState",this.previousUrl,this.currentUrl)};const e=()=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.trackNavigationEvent("popstate",this.previousUrl,this.currentUrl)};window.addEventListener("popstate",e),this.navigationListeners.push(()=>{window.removeEventListener("popstate",e)});const t=()=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.trackNavigationEvent("hashchange",this.previousUrl,this.currentUrl)};window.addEventListener("hashchange",t),this.navigationListeners.push(()=>{window.removeEventListener("hashchange",t)}),this.trackNavigationEvent("pageLoad","",this.currentUrl)}trackNavigationEvent(e,n,o){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={type:e,from:n,to:o,timestamp:(new Date).toISOString(),pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"navigation"},t)},timestamp:Date.now()}),at(`Navigation tracked: ${e} from ${n} to ${o}`)}catch(e){it("Failed to track navigation event:",e)}})}trackPageView(e){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={url:e||window.location.href,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer,timestamp:(new Date).toISOString()};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"pageview"},t)},timestamp:Date.now()}),at(`Pageview tracked: ${t.url}`)}catch(e){it("Failed to track pageview event:",e)}})}customEvent(e,n){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={eventName:e,properties:n||{},timestamp:(new Date).toISOString(),url:window.location.href,pathname:window.location.pathname};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"custom"},t)},timestamp:Date.now()}),at(`Custom event tracked: ${e}`,n)}catch(e){it("Failed to track custom event:",e)}})}cleanupNavigationTracking(){this.navigationTrackingEnabled&&(this.originalPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&(history.replaceState=this.originalReplaceState),this.navigationListeners.forEach(e=>e()),this.navigationListeners=[],this.navigationTrackingEnabled=!1,at("Navigation tracking cleaned up"))}static logToStorage(e){st(e)}static configureLogging(e){ot.setConfig({level:{none:0,error:1,warn:2,info:3,debug:4}[e.level||"error"],enableConsole:!1!==e.enableConsole,enableStorage:e.enableStorage||!1})}enableConsoleTracking(){mt&&!this.consoleTrackingEnabled&&(this.originalConsole={log:console.log,warn:console.warn,error:console.error},console.log=(...e)=>{this.trackConsoleEvent("log",e),this.originalConsole.log(...e)},console.warn=(...e)=>{this.trackConsoleEvent("warn",e),this.originalConsole.warn(...e)},console.error=(...e)=>{this.trackConsoleEvent("error",e),this.originalConsole.error(...e)},this.consoleTrackingEnabled=!0,at("Console tracking enabled"))}disableConsoleTracking(){mt&&this.consoleTrackingEnabled&&(this.originalConsole&&(console.log=this.originalConsole.log,console.warn=this.originalConsole.warn,console.error=this.originalConsole.error),this.consoleTrackingEnabled=!1,at("Console tracking disabled"))}trackConsoleEvent(e,t){if(this.initialized)try{const n={level:e,message:t.map(e=>"object"==typeof e?JSON.stringify(e):String(e)).join(" "),timestamp:(new Date).toISOString(),url:window.location.href};this.addEvent({type:5,data:{payload:Object.assign({eventType:"console"},n)},timestamp:Date.now()}).catch(e=>{it("Failed to track console event:",e)})}catch(e){it("Error in trackConsoleEvent:",e)}}setupPageUnloadHandler(){if(!mt)return;at("Setting up page unload handler"),window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&(at("Page hidden - sending pending events"),this.api.sendBeaconEvents(this.eventIngestionQueue,this.sessionId))}),window.addEventListener("beforeunload",()=>{this.api.sendBeaconEvents(this.eventIngestionQueue,this.sessionId)});const e=()=>{localStorage.setItem("human_behavior_last_activity",Date.now().toString())};window.addEventListener("click",e),window.addEventListener("keydown",e),window.addEventListener("scroll",e),window.addEventListener("mousemove",e)}viewLogs(){try{const e=ot.getLogs();console.log("HumanBehavior Logs:",e),ot.clearLogs()}catch(e){it("Failed to read logs:",e)}}addUserInfo(e){return t(this,void 0,void 0,function*(){if(yield this.ensureInitialized(),!this.endUserId)throw new Error("Cannot add user info before tracker initialization");this.userProperties=e,yield this.api.sendUserData(this.endUserId,e,this.sessionId)})}auth(e){return t(this,void 0,void 0,function*(){if(yield this.ensureInitialized(),!this.endUserId)throw new Error("Cannot authenticate before tracker initialization");if(!this.userProperties||0===Object.keys(this.userProperties).length)throw new Error("No user info available. Call addUserInfo() first.");const t=yield this.api.sendUserAuth(this.endUserId,this.userProperties,this.sessionId,e);t&&t.userId&&t.userId!==this.endUserId&&(this.endUserId=t.userId,this.setCookie(`human_behavior_end_user_id_${this.apiKey}`,t.userId,365))})}start(){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt&&(this.flushInterval=window.setInterval(()=>{this.flush()},this.FLUSH_INTERVAL_MS),this.enableConsoleTracking(),Qe({emit:e=>{this.addEvent(e)},inlineStylesheet:!0,recordCanvas:!0,collectFonts:!0,blockClass:"rr-block",ignoreClass:"rr-ignore",maskTextClass:"rr-ignore"}))})}stop(){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt&&(this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.disableConsoleTracking(),this.cleanupNavigationTracking())})}addEvent(e){return t(this,void 0,void 0,function*(){yield this.ensureInitialized();const t=this.redactionManager.processEvent(e),n=(new TextEncoder).encode(JSON.stringify(t)).length;this.eventIngestionQueue.push(t),this.queueSizeBytes+=n})}processRejectedEvents(){return t(this,void 0,void 0,function*(){if(!this.isProcessingRejectedEvents&&0!==this.rejectedEvents.length){this.isProcessingRejectedEvents=!0;try{const e=tt();mt&&localStorage.setItem("human_behavior_session_id",e),this.api.sendBeaconEvents(this.rejectedEvents,e),this.rejectedEvents=[],this.sessionId=e}catch(e){it("Failed to process rejected events:",e)}finally{this.isProcessingRejectedEvents=!1}}})}flush(){return t(this,void 0,void 0,function*(){var e,t,n,o;if(!this.isProcessing&&this.initialized){this.isProcessing=!0;try{const i=this.eventIngestionQueue;if(this.eventIngestionQueue=[],this.queueSizeBytes=0,i.length>0){at("Flushing events:",i);try{yield this.api.sendEvents(i,this.sessionId,this.endUserId)}catch(r){if(null===(e=r.message)||void 0===e?void 0:e.includes("ERROR: Session already completed"))st("Session expired, storing events for retry"),this.rejectedEvents.push(...i),this.processRejectedEvents();else{if(!((null===(t=r.message)||void 0===t?void 0:t.includes("ERR_BLOCKED_BY_CLIENT"))||(null===(n=r.message)||void 0===n?void 0:n.includes("Failed to fetch"))||(null===(o=r.message)||void 0===o?void 0:o.includes("NetworkError"))))throw r;rt("Request blocked by ad blocker or network issue, storing events for retry"),this.rejectedEvents.push(...i)}}}}finally{this.isProcessing=!1}}})}setCookie(e,t,n){if(mt)try{const o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);const i=`expires=${o.toUTCString()}`;document.cookie=`${e}=${t};${i};path=/;SameSite=Lax`,localStorage.setItem(e,t),at(`Set cookie and localStorage: ${e}`)}catch(n){try{localStorage.setItem(e,t),at(`Cookie blocked, using localStorage: ${e}`)}catch(e){it("Failed to store user ID in both cookie and localStorage:",e)}}}getCookie(e){if(!mt)return null;try{const t=e+"=",n=document.cookie.split(";");for(let o=0;o<n.length;o++){let i=n[o];for(;" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t)){const n=i.substring(t.length,i.length);return at(`Found cookie: ${e}`),n}}const o=localStorage.getItem(e);return o?(at(`Cookie not found, using localStorage: ${e}`),o):null}catch(t){try{const t=localStorage.getItem(e);if(t)return at(`Cookie access failed, using localStorage: ${e}`),t}catch(e){it("Failed to access both cookie and localStorage:",e)}return null}}redact(e){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt?this.redactionManager=new gt(e):rt("Redaction is only available in browser environments")})}setRedactedFields(e){mt?this.redactionManager.setFieldsToRedact(e):rt("Redaction is only available in browser environments")}isRedactionActive(){return this.redactionManager.isActive()}getRedactedFields(){return this.redactionManager.getSelectedFields()}getSessionId(){return this.sessionId}getCurrentUrl(){return this.currentUrl}testConnection(){return t(this,void 0,void 0,function*(){try{return yield this.api.init(this.sessionId,this.endUserId),{success:!0}}catch(e){return{success:!1,error:e.message||"Unknown error"}}})}getConnectionStatus(){const e=[];let t=!1;return this.rejectedEvents.length>0&&(t=!0,e.push("Some requests may be blocked by ad blockers")),this._connectionBlocked&&(t=!0,e.push("Initial connection test failed - ad blocker may be active")),"undefined"==typeof window&&e.push("Not running in browser environment"),void 0===navigator.sendBeacon&&e.push("sendBeacon not available, using fetch fallback"),{blocked:t,recommendations:e}}isPreexistingUser(){if(!mt)return!1;const e=this.getCookie(`human_behavior_end_user_id_${this.apiKey}`);return null!==e&&e!==this.endUserId}getUserInfo(){return{endUserId:this.endUserId,sessionId:this.sessionId,isPreexistingUser:this.isPreexistingUser(),initialized:this.initialized}}}mt&&(window.HumanBehaviorTracker=ft),"undefined"!=typeof window&&(window.HumanBehaviorTracker=ft),e.HumanBehaviorAPI=ut,e.HumanBehaviorTracker=ft,e.MAX_CHUNK_SIZE_BYTES=ct,e.RedactionManager=gt,e.default=ft,e.isChunkSizeExceeded=lt,e.logDebug=at,e.logError=it,e.logInfo=st,e.logWarn=rt,e.logger=ot,e.redactionManager=pt,e.validateSingleEventSize=dt,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
15
|
+
***************************************************************************** */function Ae(e,t,n,o){return new(n||(n=Promise))(function(t,i){function r(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(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(r,s)}a((o=o.apply(e,[])).next())})}for(var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ee="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Te=0;Te<64;Te++)Ee[ke.charCodeAt(Te)]=Te;const Re=new Map;const Me=(e,t,n)=>{if(!e||!Fe(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Re.get(e);return n||(n=new Map,Re.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let i=o.indexOf(e);return-1===i&&(i=o.length,o.push(e)),i};function Ne(e,t,n){if(e instanceof Array)return e.map(e=>Ne(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,i="";for(t=0;t<o;t+=3)i+=ke[n[t]>>2],i+=ke[(3&n[t])<<4|n[t+1]>>4],i+=ke[(15&n[t+1])<<2|n[t+2]>>6],i+=ke[63&n[t+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ne(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:[Ne(e.data,t,n),e.width,e.height]}}if(Fe(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Oe=(e,t,n)=>[...e].map(e=>Ne(e,t,n)),Fe=(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 xe(e,t,n){const o=[];try{const i=D(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){return W(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...i])}});o.push(i)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function Le(e,t,n,o,i,r,s){const a=[],c=Object.getOwnPropertyNames(e);for(const r of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(r))try{if("function"!=typeof e[r])continue;const c=D(e,r,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,s,this),!W(this.canvas,o,i,!0)){const e=Oe([...a],s,this),o={type:t,property:r,args:e};n(this.canvas,o)}return c}});a.push(c)}catch(o){const i=L(e,r,{set(e){n(this.canvas,{type:t,property:r,args:[e],setter:!0})}});a.push(i)}return a}var De=null;try{var Ue="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");De=Ue.Worker}catch(e){}function Be(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),i=o.indexOf("\n",10)+1,r=o.substring(i)+"";return function(e){return new De(r,Object.assign({},e,{eval:!0}))}}function We(e,t,n){var o=function(e){return atob(e)}(e),i=o.indexOf("\n",10)+1,r=o.substring(i)+"",s=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(s)}var _e="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ge,Ze=(Ge="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3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AgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",_e?Be(Ge):function(e){var t;return function(n){return t=t||We(e),new Worker(t,n)}}(Ge));class Ve{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:i,recordCanvas:r,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(n,o,i),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,i,{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,o,i){const r=xe(t,n,o),s=new Map,a=new Ze;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:i,height:r}=e.data;this.mutationCb({id:t,type:H["2D"],commands:[{property:"clearRect",args:[0,0,i,r]},{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=>{W(t,n,o,!0)||e.push(t)}),e})().forEach(e=>Ae(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 o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[o])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{r(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=xe(e,t,n),i=function(e,t,n,o){const i=[],r=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of r)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const r=D(t.CanvasRenderingContext2D.prototype,s,function(i){return function(...r){return W(this.canvas,n,o,!0)||setTimeout(()=>{const n=Oe([...r],t,this);e(this.canvas,{type:H["2D"],property:s,args:n})},0),i.apply(this,r)}});i.push(r)}catch(n){const o=L(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:H["2D"],property:s,args:[t],setter:!0})}});i.push(o)}return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),r=function(e,t,n,o){const i=[];return i.push(...Le(t.WebGLRenderingContext.prototype,H.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&i.push(...Le(t.WebGL2RenderingContext.prototype,H.WebGL2,e,n,o,0,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),i(),r()}}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 i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}(e,["type"]);return t}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:o}),this.pendingCanvasMutations.delete(e)}}class Ke{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new P,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:s(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 ze(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Pe,je,Je,Ye=!1;const He=new a;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:i="rr-block",blockSelector:r=null,ignoreClass:s="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:y={},dataURLOptions:C={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:w=!1,collectFonts:A=!1,inlineImages:k=!1,plugins:E,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:R=new Set([])}=e,O=!b||window.parent===window;let F=!1;if(!O)try{window.parent.document,F=!1}catch(e){F=!0}if(O&&!t)throw new Error("emit function is required");void 0!==v&&void 0===y.mousemove&&(y.mousemove=v),He.reset();const x=!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===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 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 W=0;const _=e=>{for(const t of E||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Pe=(e,i)=>{var r;if(!(null===(r=re[0])||void 0===r?void 0:r.isFrozen())||e.type===j.FullSnapshot||e.type===j.IncrementalSnapshot&&e.data.source===J.Mutation||re.forEach(e=>e.unfreeze()),O)null==t||t(_(e),i);else if(F){const t={type:"rrweb",event:_(e),isCheckout:i};window.parent.postMessage(t,"*")}if(e.type===j.FullSnapshot)D=e,W=0;else if(e.type===j.IncrementalSnapshot){if(e.data.source===J.Mutation&&e.data.isAttachIframe)return;W++;const t=o&&W>=o,i=n&&e.timestamp-D.timestamp>n;(t||i)&&je(!0)}};const G=e=>{Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Mutation},e)}))},Z=e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Scroll},e)})),P=e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.CanvasMutation},e)})),Y=new Ke({mutationCb:G,adoptedStyleSheetCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.AdoptedStyleSheet},e)}))}),H=new be({mirror:He,mutationCb:G,stylesheetManager:Y,recordCrossOriginIframes:b,wrappedEmit:Pe});for(const e of E||[])e.getMirror&&e.getMirror({nodeMirror:He,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});Je=new Ve({recordCanvas:S,mutationCb:P,win:window,blockClass:i,blockSelector:r,mirror:He,sampling:y.canvas,dataURLOptions:C});const Q=new we({mutationCb:G,scrollCb:Z,bypassOptions:{blockClass:i,blockSelector:r,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:x,dataURLOptions:C,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:y,slimDOMOptions:L,iframeManager:H,stylesheetManager:Y,canvasManager:Je,keepIframeSrcFn:T},mirror:He});je=(e=!1)=>{var t,n,o,s,u,h;Pe(ze({type:j.Meta,data:{href:window.location.href,width:B(),height:U()}}),e),Y.reset(),re.forEach(e=>e.lock());const g=function(e,t){var n=t||{},o=n.mirror,i=void 0===o?new a:o,r=n.blockClass,s=void 0===r?"rr-block":r,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,y=n.recordCanvas,C=void 0!==y&&y,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,w=n.maskInputFn,A=n.slimDOM,k=void 0!==A&&A,E=n.dataURLOptions,T=n.preserveWhiteSpace,R=n.onSerialize,N=n.onIframeLoad,O=n.iframeLoadTimeout,F=n.onStylesheetLoad,x=n.stylesheetLoadTimeout,L=n.keepIframeSrcFn;return M(e,{doc:e,mirror:i,blockClass:s,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:w,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:E,inlineImages:I,recordCanvas:C,preserveWhiteSpace:T,onSerialize:R,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:F,stylesheetLoadTimeout:x,keepIframeSrcFn:void 0===L?function(){return!1}:L,newlyAddedElement:!1})}(document,{mirror:He,blockClass:i,blockSelector:r,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:x,maskTextFn:m,slimDOM:L,dataURLOptions:C,recordCanvas:S,inlineImages:k,onSerialize:e=>{V(e,He)&&H.addIframe(e),K(e,He)&&Y.trackLinkElement(e),z(e)&&Q.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),Q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Y.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!g)return console.warn("Failed to snapshot the document");Pe(ze({type:j.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===(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===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.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}}})),re.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Y.adoptStyleSheets(document.adoptedStyleSheets,He.getId(document))};try{const e=[];e.push(N("DOMContentLoaded",()=>{Pe(ze({type:j.DomContentLoaded,data:{}}))}));const t=e=>{var t;return ve({mutationCb:G,mousemoveCb:(e,t)=>Pe(ze({type:j.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.MouseInteraction},e)})),scrollCb:Z,viewportResizeCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.ViewportResize},e)})),inputCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Input},e)})),mediaInteractionCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.MediaInteraction},e)})),styleSheetRuleCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.StyleSheetRule},e)})),styleDeclarationCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.StyleDeclaration},e)})),canvasMutationCb:P,fontCb:e=>Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Font},e)})),selectionCb:e=>{Pe(ze({type:j.IncrementalSnapshot,data:Object.assign({source:J.Selection},e)}))},blockClass:i,ignoreClass:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:x,inlineStylesheet:d,sampling:y,recordCanvas:S,inlineImages:k,userTriggeredOnInput:w,collectFonts:A,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:T,blockSelector:r,slimDOMOptions:L,dataURLOptions:C,mirror:He,iframeManager:H,stylesheetManager:Y,shadowDomManager:Q,canvasManager:Je,ignoreCSSAttributes:R,plugins:(null===(t=null==E?void 0:E.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Pe(ze({type:j.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{je(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(N("load",()=>{Pe(ze({type:j.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){console.warn(e)}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Pe(ze({type:j.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{re.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");je(e)},Qe.mirror=He;const qe=[];for(let e=0;e<256;++e)qe.push((e+256).toString(16).slice(1));let Xe;const $e=new Uint8Array(16);const et={};function tt(e,t,n){let o;{const e=Date.now(),i=function(){if(!Xe){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Xe=crypto.getRandomValues.bind(crypto)}return Xe($e)}();!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}(et,e,i),o=function(e,t,n,o,i,r,s=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(r){if(s<0||s+16>r.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`)}else r=new Uint8Array(16),s=0;t??=Date.now(),n??=0,o??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+n)%4294967296;r[s++]=a>>>24&255,r[s++]=a>>>16&255,r[s++]=a>>>8&255,r[s++]=255&a;const c=t/4294967296*1e4&268435455;r[s++]=c>>>8&255,r[s++]=255&c,r[s++]=c>>>24&15|16,r[s++]=c>>>16&255,r[s++]=o>>>8|128,r[s++]=255&o;for(let e=0;e<6;++e)r[s++]=i[e];return r}(i,et.msecs,et.nsecs,et.clockseq,et.node,t,n)}return t??function(e,t=0){return(qe[e[t+0]]+qe[e[t+1]]+qe[e[t+2]]+qe[e[t+3]]+"-"+qe[e[t+4]]+qe[e[t+5]]+"-"+qe[e[t+6]]+qe[e[t+7]]+"-"+qe[e[t+8]]+qe[e[t+9]]+"-"+qe[e[t+10]]+qe[e[t+11]]+qe[e[t+12]]+qe[e[t+13]]+qe[e[t+14]]+qe[e[t+15]]).toLowerCase()}(o)}var nt;e.LogLevel=void 0,(nt=e.LogLevel||(e.LogLevel={}))[nt.NONE=0]="NONE",nt[nt.ERROR=1]="ERROR",nt[nt.WARN=2]="WARN",nt[nt.INFO=3]="INFO",nt[nt.DEBUG=4]="DEBUG";const ot=new class{constructor(t){this.config={level:e.LogLevel.ERROR,enableConsole:!0,enableStorage:!1},this.isBrowser="undefined"!=typeof window,t&&(this.config=Object.assign(Object.assign({},this.config),t))}setConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}shouldLog(e){return e<=this.config.level}formatMessage(e,t,...n){return`[HumanBehavior ${e}] ${(new Date).toISOString()}: ${t}`}error(t,...n){if(!this.shouldLog(e.LogLevel.ERROR))return;const o=this.formatMessage("ERROR",t);this.config.enableConsole&&console.error(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}warn(t,...n){if(!this.shouldLog(e.LogLevel.WARN))return;const o=this.formatMessage("WARN",t);this.config.enableConsole&&console.warn(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}info(t,...n){if(!this.shouldLog(e.LogLevel.INFO))return;const o=this.formatMessage("INFO",t);this.config.enableConsole&&console.log(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}debug(t,...n){if(!this.shouldLog(e.LogLevel.DEBUG))return;const o=this.formatMessage("DEBUG",t);this.config.enableConsole&&console.log(o,...n),this.config.enableStorage&&this.isBrowser&&this.logToStorage(o,n)}logToStorage(e,t){try{const n=JSON.parse(localStorage.getItem("human_behavior_logs")||"[]"),o={message:e,args:t.length>0?t:void 0,timestamp:Date.now()};n.push(o),n.length>1e3&&n.splice(0,n.length-1e3),localStorage.setItem("human_behavior_logs",JSON.stringify(n))}catch(e){}}getLogs(){if(!this.isBrowser)return[];try{return JSON.parse(localStorage.getItem("human_behavior_logs")||"[]")}catch(e){return[]}}clearLogs(){this.isBrowser&&localStorage.removeItem("human_behavior_logs")}},it=(e,...t)=>ot.error(e,...t),rt=(e,...t)=>ot.warn(e,...t),st=(e,...t)=>ot.info(e,...t),at=(e,...t)=>ot.debug(e,...t),ct=10485760;function lt(e,t,n){return(new TextEncoder).encode(JSON.stringify({sessionId:n,events:[...e,t]})).length>ct}function dt(e,t){const n=(new TextEncoder).encode(JSON.stringify({sessionId:t,events:[e]})).length;if(n>ct)throw new Error(`Single event size (${n} bytes) exceeds maximum chunk size (10485760 bytes)`)}class ut{constructor({apiKey:e,ingestionUrl:t}){this.apiKey=e,this.baseUrl=t}init(e,n){return t(this,void 0,void 0,function*(){let t=null,o=null;"undefined"!=typeof window&&(t=window.location.href,o=document.referrer);const i=yield fetch(`${this.baseUrl}/api/ingestion/init`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,Referer:o||""},body:JSON.stringify({sessionId:e,endUserId:n,entryURL:t,referrer:o})});if(!i.ok)throw new Error(`Failed to initialize ingestion: ${i.statusText}`);const r=yield i.json();return{sessionId:r.sessionId,endUserId:r.endUserId}})}sendEvents(e,n,o){return t(this,void 0,void 0,function*(){const t=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:e,endUserId:o})});if(!t.ok)throw new Error(`Failed to send events: ${t.statusText}`)})}sendEventsChunked(e,n){return t(this,void 0,void 0,function*(){try{const t=[];let o=[];for(const i of e)if(lt(o,i,n)){if(o.length>0){const e=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:o})});if(!e.ok)throw new Error(`Failed to send events: ${e.statusText}`);t.push(yield e.json()),o=[]}dt(i,n),o=[i]}else o.push(i);if(o.length>0){const e=yield fetch(`${this.baseUrl}/api/ingestion/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({sessionId:n,events:o})});if(!e.ok)throw new Error(`Failed to send events: ${e.statusText}`);t.push(yield e.json())}return t.flat()}catch(e){throw it("Error sending events:",e),e}})}sendUserData(e,n,o){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`${this.baseUrl}/api/ingestion/user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({userId:e,userAttributes:n,sessionId:o})});if(!t.ok)throw new Error(`Failed to send user data: ${t.statusText} with API key: ${this.apiKey}`);return yield t.json()}catch(e){throw it("Error sending user data:",e),e}})}sendUserAuth(e,n,o,i){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`${this.baseUrl}/api/ingestion/user/auth`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({userId:e,userAttributes:n,sessionId:o,authFields:i})});if(!t.ok)throw new Error(`Failed to authenticate user: ${t.statusText} with API key: ${this.apiKey}`);return yield t.json()}catch(e){throw it("Error authenticating user:",e),e}})}sendBeaconEvents(e,t){const n=new URLSearchParams;n.append("events",encodeURIComponent(JSON.stringify(e))),n.append("sessionId",encodeURIComponent(t)),n.append("timestamp",encodeURIComponent(Date.now().toString())),n.append("apiKey",encodeURIComponent(this.apiKey)),navigator.sendBeacon(`${this.baseUrl}/api/ingestion/events`,n)}}const ht="undefined"!=typeof window;class gt{constructor(e){this.redactedText="[REDACTED]",this.userSelectedFields=new Set,this.excludeSelectors=['[data-no-redact="true"]',".human-behavior-no-redact"],(null==e?void 0:e.redactedText)&&(this.redactedText=e.redactedText),(null==e?void 0:e.excludeSelectors)&&(this.excludeSelectors=[...this.excludeSelectors,...e.excludeSelectors]),(null==e?void 0:e.userFields)&&this.setFieldsToRedact(e.userFields)}setFieldsToRedact(e){this.userSelectedFields.clear(),e.forEach(e=>this.userSelectedFields.add(e)),e.length>0?(at(`Redaction: Active for ${e.length} field(s):`,e),e.forEach(e=>{const t=document.querySelectorAll(e);at(`Redaction: Found ${t.length} element(s) for selector '${e}'`),t.forEach((t,n)=>{at(`Redaction: Element ${n} for '${e}':`,t)})})):at("Redaction: Disabled - no fields selected")}isActive(){return this.userSelectedFields.size>0}getSelectedFields(){return Array.from(this.userSelectedFields)}processEvent(e){if(0===this.userSelectedFields.size)return e;const t=JSON.parse(JSON.stringify(e));if(3===t.type)if(5===t.data.source){this.isFieldSelected(t.data)&&(at("Redaction: Processing input event for redaction"),this.redactInputEvent(t.data))}else 0===t.data.source?this.redactDOMEvent(t.data):2===t.data.source&&this.redactMouseEvent(t.data);else 2===t.type&&this.redactFullSnapshot(t.data);return t}redactInputEvent(e){if(!this.isFieldSelected(e))return;at("Redaction: Redacting input event with text:",e.text);["text","value","content","data","input","textContent"].forEach(t=>{void 0!==e[t]&&"string"==typeof e[t]&&(e[t]=this.redactedText,at(`Redaction: Redacted property '${t}'`))}),Object.keys(e).forEach(t=>{"string"==typeof e[t]&&e[t].length>0&&(e[t]=this.redactedText,at(`Redaction: Redacted additional property '${t}'`))}),e.attributes&&"object"==typeof e.attributes&&e.attributes.value&&"string"==typeof e.attributes.value&&(e.attributes.value=this.redactedText,at("Redaction: Redacted nested value attribute")),at("Redaction: Input event redaction complete")}redactDOMEvent(e){e.texts&&Array.isArray(e.texts)&&e.texts.forEach(e=>{e.text&&"string"==typeof e.text&&this.shouldRedactDOMChange(e)&&(e.text=this.redactedText)}),e.attributes&&Array.isArray(e.attributes)&&e.attributes.forEach(e=>{e.attributes&&e.attributes.value&&"string"==typeof e.attributes.value&&this.shouldRedactDOMChange(e)&&(e.attributes.value=this.redactedText)}),e.adds&&Array.isArray(e.adds)&&e.adds.forEach(e=>{e.node&&e.node.textContent&&"string"==typeof e.node.textContent&&this.shouldRedactDOMChange(e)&&(e.node.textContent=this.redactedText)})}shouldRedactDOMChange(e){if(!ht)return!1;try{const t=e.id;if(void 0!==t){let e=document.querySelector(`[data-rrweb-id="${t}"]`);if(e)return this.shouldRedactElement(e)}const n=e.nodeId;if(void 0!==n){const e=document.querySelector(`[data-rrweb-id="${n}"]`);if(e)return this.shouldRedactElement(e)}return!1}catch(e){return rt("Error checking if DOM change should be redacted:",e),!1}}redactMouseEvent(e){e.text&&"string"==typeof e.text&&this.isFieldSelected(e)&&(e.text=this.redactedText)}redactFullSnapshot(e){e.node&&2===e.node.type&&this.redactNode(e.node)}redactNode(e){e&&(2!==e.type||!e.tagName||"input"!==e.tagName.toLowerCase()&&"textarea"!==e.tagName.toLowerCase()||this.shouldRedactNode(e)&&(e.attributes&&e.attributes.value&&(e.attributes.value=this.redactedText),e.textContent&&(e.textContent=this.redactedText)),e.childNodes&&Array.isArray(e.childNodes)&&e.childNodes.forEach(e=>{this.redactNode(e)}))}shouldRedactNode(e){if(!e.attributes)return!1;for(const t of this.userSelectedFields)if(this.selectorMatchesNode(t,e))return!0;return!1}selectorMatchesNode(e,t){if(!t.attributes)return!1;try{const n=document.createElement(t.tagName||"div");return t.attributes&&Object.keys(t.attributes).forEach(e=>{n.setAttribute(e,t.attributes[e])}),n.matches(e)}catch(n){return this.basicSelectorMatch(e,t)}}basicSelectorMatch(e,t){if(!t.attributes)return!1;if(e.includes("input[type=")){const n=e.match(/input\[type="([^"]+)"\]/);if(n&&"input"===t.tagName&&t.attributes.type===n[1])return!0}if(e.startsWith("#")){const n=e.substring(1);return t.attributes.id===n}if(e.startsWith(".")){const n=e.substring(1);return t.attributes.class&&t.attributes.class.includes(n)}return!e.includes("[")&&!e.includes(".")&&(t.tagName&&t.tagName.toLowerCase()===e.toLowerCase())}isFieldSelected(e){if(!ht)return!1;try{if(5===e.source){const t=e.id;if(void 0!==t){let n=document.querySelector(`[data-rrweb-id="${t}"]`);if(n)return this.shouldRedactElement(n);if(void 0!==e.nodeId&&(n=document.querySelector(`[data-rrweb-id="${e.nodeId}"]`),n))return this.shouldRedactElement(n);for(const e of this.userSelectedFields){const t=document.querySelectorAll(e);if(t.length>0)for(const n of t)if(n===document.activeElement)return at("Redaction: Found focused element matching selector:",e),!0}const o=document.activeElement;return!(!o||!this.shouldRedactElement(o))&&(at("Redaction: Active element should be redacted"),!0)}}const t=e.id;if(void 0!==t){let e=document.querySelector(`[data-rrweb-id="${t}"]`);if(e)return this.shouldRedactElement(e)}const n=e.nodeId;if(void 0!==n){const e=document.querySelector(`[data-rrweb-id="${n}"]`);if(e)return this.shouldRedactElement(e)}if(e.target&&e.target.id){const t=document.querySelector(`[data-rrweb-id="${e.target.id}"]`);if(t)return this.shouldRedactElement(t)}return!1}catch(e){return rt("Error checking if field should be redacted:",e),!1}}shouldRedactElement(e){for(const t of this.excludeSelectors)if(e.matches(t)||e.closest(t))return!1;for(const t of this.userSelectedFields)if(e.matches(t))return!0;return!1}getOriginalValue(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.value}isElementRedacted(e){return this.shouldRedactElement(e)}}const pt=new gt,mt="undefined"!=typeof window;class ft{static init(e,t){if(mt&&window.__humanBehaviorGlobalTracker)return at("Tracker already initialized, returning existing instance"),window.__humanBehaviorGlobalTracker;(null==t?void 0:t.logLevel)&&this.configureLogging({level:t.logLevel});const n=new ft(e,null==t?void 0:t.ingestionUrl);if((null==t?void 0:t.redactFields)&&n.setRedactedFields(t.redactFields),mt){const e=n.api.baseUrl+"/api/health";fetch(e,{method:"HEAD"}).then(()=>at("Connection test successful")).catch(e=>{rt("Connection test failed - ad blocker may be active:",e.message),n._connectionBlocked=!0})}return n.start(),n}constructor(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,this.originalConsole=null,this.consoleTrackingEnabled=!1,this.navigationTrackingEnabled=!1,this.currentUrl="",this.previousUrl="",this.originalPushState=null,this.originalReplaceState=null,this.navigationListeners=[],this._connectionBlocked=!1,!e)throw new Error("Human Behavior API Key is required");if(this.api=new ut({apiKey:e,ingestionUrl:t||"http://3.137.217.33:3000"}),this.apiKey=e,this.redactionManager=new gt,mt){const e=localStorage.getItem("human_behavior_session_id"),t=localStorage.getItem("human_behavior_last_activity"),n=Date.now()-18e5;e&&t&&parseInt(t)>n?(this.sessionId=e,at(`Reusing existing session: ${this.sessionId}`),localStorage.setItem("human_behavior_last_activity",Date.now().toString())):(e&&(at(`Session expired, clearing old session: ${e}`),localStorage.removeItem("human_behavior_session_id"),localStorage.removeItem("human_behavior_last_activity")),this.sessionId=tt(),at(`Creating new session: ${this.sessionId}`),localStorage.setItem("human_behavior_session_id",this.sessionId),localStorage.setItem("human_behavior_last_activity",Date.now().toString())),this.currentUrl=window.location.href,window.__humanBehaviorGlobalTracker=this}else this.sessionId=tt();this.initializationPromise=this.init()}init(){return t(this,void 0,void 0,function*(){try{const e=this.getCookie(`human_behavior_end_user_id_${this.apiKey}`);at(`Initializing with sessionId: ${this.sessionId}, userId: ${e}`);const{sessionId:t,endUserId:n}=yield this.api.init(this.sessionId,e);t!==this.sessionId&&(at(`Server returned different sessionId: ${t} (client had: ${this.sessionId})`),this.sessionId=t,mt&&localStorage.setItem("human_behavior_session_id",this.sessionId)),this.endUserId=n,this.setCookie(`human_behavior_end_user_id_${this.apiKey}`,n,365),mt?(this.setupPageUnloadHandler(),this.setupNavigationTracking(),this.processRejectedEvents()):rt("HumanBehaviorTracker initialized in a non-browser environment. Session tracking is disabled."),this.initialized=!0,st(`HumanBehaviorTracker initialized with sessionId: ${this.sessionId}, endUserId: ${n}`)}catch(e){throw it("Failed to initialize HumanBehaviorTracker:",e),e}})}ensureInitialized(){return t(this,void 0,void 0,function*(){if(!this.initializationPromise)throw new Error("HumanBehaviorTracker initialization failed");yield this.initializationPromise})}setupNavigationTracking(){if(!mt||this.navigationTrackingEnabled)return;this.navigationTrackingEnabled=!0,at("Setting up navigation tracking"),this.originalPushState=history.pushState,this.originalReplaceState=history.replaceState,history.pushState=(...e)=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.originalPushState.apply(history,e),this.trackNavigationEvent("pushState",this.previousUrl,this.currentUrl)},history.replaceState=(...e)=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.originalReplaceState.apply(history,e),this.trackNavigationEvent("replaceState",this.previousUrl,this.currentUrl)};const e=()=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.trackNavigationEvent("popstate",this.previousUrl,this.currentUrl)};window.addEventListener("popstate",e),this.navigationListeners.push(()=>{window.removeEventListener("popstate",e)});const t=()=>{this.previousUrl=this.currentUrl,this.currentUrl=window.location.href,this.trackNavigationEvent("hashchange",this.previousUrl,this.currentUrl)};window.addEventListener("hashchange",t),this.navigationListeners.push(()=>{window.removeEventListener("hashchange",t)}),this.trackNavigationEvent("pageLoad","",this.currentUrl)}trackNavigationEvent(e,n,o){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={type:e,from:n,to:o,timestamp:(new Date).toISOString(),pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"navigation"},t)},timestamp:Date.now()}),at(`Navigation tracked: ${e} from ${n} to ${o}`)}catch(e){it("Failed to track navigation event:",e)}})}trackPageView(e){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={url:e||window.location.href,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer,timestamp:(new Date).toISOString()};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"pageview"},t)},timestamp:Date.now()}),at(`Pageview tracked: ${t.url}`)}catch(e){it("Failed to track pageview event:",e)}})}customEvent(e,n){return t(this,void 0,void 0,function*(){if(this.initialized)try{const t={eventName:e,properties:n||{},timestamp:(new Date).toISOString(),url:window.location.href,pathname:window.location.pathname};yield this.addEvent({type:5,data:{payload:Object.assign({eventType:"custom"},t)},timestamp:Date.now()}),at(`Custom event tracked: ${e}`,n)}catch(e){it("Failed to track custom event:",e)}})}cleanupNavigationTracking(){this.navigationTrackingEnabled&&(this.originalPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&(history.replaceState=this.originalReplaceState),this.navigationListeners.forEach(e=>e()),this.navigationListeners=[],this.navigationTrackingEnabled=!1,at("Navigation tracking cleaned up"))}static logToStorage(e){st(e)}static configureLogging(e){ot.setConfig({level:{none:0,error:1,warn:2,info:3,debug:4}[e.level||"error"],enableConsole:!1!==e.enableConsole,enableStorage:e.enableStorage||!1})}enableConsoleTracking(){mt&&!this.consoleTrackingEnabled&&(this.originalConsole={log:console.log,warn:console.warn,error:console.error},console.log=(...e)=>{this.trackConsoleEvent("log",e),this.originalConsole.log(...e)},console.warn=(...e)=>{this.trackConsoleEvent("warn",e),this.originalConsole.warn(...e)},console.error=(...e)=>{this.trackConsoleEvent("error",e),this.originalConsole.error(...e)},this.consoleTrackingEnabled=!0,at("Console tracking enabled"))}disableConsoleTracking(){mt&&this.consoleTrackingEnabled&&(this.originalConsole&&(console.log=this.originalConsole.log,console.warn=this.originalConsole.warn,console.error=this.originalConsole.error),this.consoleTrackingEnabled=!1,at("Console tracking disabled"))}trackConsoleEvent(e,t){if(this.initialized)try{const n={level:e,message:t.map(e=>"object"==typeof e?JSON.stringify(e):String(e)).join(" "),timestamp:(new Date).toISOString(),url:window.location.href};this.addEvent({type:5,data:{payload:Object.assign({eventType:"console"},n)},timestamp:Date.now()}).catch(e=>{it("Failed to track console event:",e)})}catch(e){it("Error in trackConsoleEvent:",e)}}setupPageUnloadHandler(){if(!mt)return;at("Setting up page unload handler"),window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&(at("Page hidden - sending pending events"),this.api.sendBeaconEvents(this.eventIngestionQueue,this.sessionId))}),window.addEventListener("beforeunload",()=>{this.api.sendBeaconEvents(this.eventIngestionQueue,this.sessionId)});const e=()=>{localStorage.setItem("human_behavior_last_activity",Date.now().toString())};window.addEventListener("click",e),window.addEventListener("keydown",e),window.addEventListener("scroll",e),window.addEventListener("mousemove",e)}viewLogs(){try{const e=ot.getLogs();console.log("HumanBehavior Logs:",e),ot.clearLogs()}catch(e){it("Failed to read logs:",e)}}addUserInfo(e){return t(this,void 0,void 0,function*(){if(yield this.ensureInitialized(),!this.endUserId)throw new Error("Cannot add user info before tracker initialization");this.userProperties=e,yield this.api.sendUserData(this.endUserId,e,this.sessionId)})}auth(e){return t(this,void 0,void 0,function*(){if(yield this.ensureInitialized(),!this.endUserId)throw new Error("Cannot authenticate before tracker initialization");if(!this.userProperties||0===Object.keys(this.userProperties).length)throw new Error("No user info available. Call addUserInfo() first.");const t=yield this.api.sendUserAuth(this.endUserId,this.userProperties,this.sessionId,e);t&&t.userId&&t.userId!==this.endUserId&&(this.endUserId=t.userId,this.setCookie(`human_behavior_end_user_id_${this.apiKey}`,t.userId,365))})}start(){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt&&(this.flushInterval=window.setInterval(()=>{this.flush()},this.FLUSH_INTERVAL_MS),this.enableConsoleTracking(),Qe({emit:e=>{this.addEvent(e)},inlineStylesheet:!0,recordCanvas:!0,collectFonts:!0,inlineImages:!0,blockClass:"rr-block",ignoreClass:"rr-ignore",maskTextClass:"rr-ignore"}))})}stop(){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt&&(this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.disableConsoleTracking(),this.cleanupNavigationTracking())})}addEvent(e){return t(this,void 0,void 0,function*(){yield this.ensureInitialized();const t=this.redactionManager.processEvent(e),n=(new TextEncoder).encode(JSON.stringify(t)).length;this.eventIngestionQueue.push(t),this.queueSizeBytes+=n})}processRejectedEvents(){return t(this,void 0,void 0,function*(){if(!this.isProcessingRejectedEvents&&0!==this.rejectedEvents.length){this.isProcessingRejectedEvents=!0;try{const e=tt();mt&&localStorage.setItem("human_behavior_session_id",e),this.api.sendBeaconEvents(this.rejectedEvents,e),this.rejectedEvents=[],this.sessionId=e}catch(e){it("Failed to process rejected events:",e)}finally{this.isProcessingRejectedEvents=!1}}})}flush(){return t(this,void 0,void 0,function*(){var e,t,n,o;if(!this.isProcessing&&this.initialized){this.isProcessing=!0;try{const i=this.eventIngestionQueue;if(this.eventIngestionQueue=[],this.queueSizeBytes=0,i.length>0){at("Flushing events:",i);try{yield this.api.sendEvents(i,this.sessionId,this.endUserId)}catch(r){if(null===(e=r.message)||void 0===e?void 0:e.includes("ERROR: Session already completed"))st("Session expired, storing events for retry"),this.rejectedEvents.push(...i),this.processRejectedEvents();else{if(!((null===(t=r.message)||void 0===t?void 0:t.includes("ERR_BLOCKED_BY_CLIENT"))||(null===(n=r.message)||void 0===n?void 0:n.includes("Failed to fetch"))||(null===(o=r.message)||void 0===o?void 0:o.includes("NetworkError"))))throw r;rt("Request blocked by ad blocker or network issue, storing events for retry"),this.rejectedEvents.push(...i)}}}}finally{this.isProcessing=!1}}})}setCookie(e,t,n){if(mt)try{const o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);const i=`expires=${o.toUTCString()}`;document.cookie=`${e}=${t};${i};path=/;SameSite=Lax`,localStorage.setItem(e,t),at(`Set cookie and localStorage: ${e}`)}catch(n){try{localStorage.setItem(e,t),at(`Cookie blocked, using localStorage: ${e}`)}catch(e){it("Failed to store user ID in both cookie and localStorage:",e)}}}getCookie(e){if(!mt)return null;try{const t=e+"=",n=document.cookie.split(";");for(let o=0;o<n.length;o++){let i=n[o];for(;" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t)){const n=i.substring(t.length,i.length);return at(`Found cookie: ${e}`),n}}const o=localStorage.getItem(e);return o?(at(`Cookie not found, using localStorage: ${e}`),o):null}catch(t){try{const t=localStorage.getItem(e);if(t)return at(`Cookie access failed, using localStorage: ${e}`),t}catch(e){it("Failed to access both cookie and localStorage:",e)}return null}}redact(e){return t(this,void 0,void 0,function*(){yield this.ensureInitialized(),mt?this.redactionManager=new gt(e):rt("Redaction is only available in browser environments")})}setRedactedFields(e){mt?this.redactionManager.setFieldsToRedact(e):rt("Redaction is only available in browser environments")}isRedactionActive(){return this.redactionManager.isActive()}getRedactedFields(){return this.redactionManager.getSelectedFields()}getSessionId(){return this.sessionId}getCurrentUrl(){return this.currentUrl}testConnection(){return t(this,void 0,void 0,function*(){try{return yield this.api.init(this.sessionId,this.endUserId),{success:!0}}catch(e){return{success:!1,error:e.message||"Unknown error"}}})}getConnectionStatus(){const e=[];let t=!1;return this.rejectedEvents.length>0&&(t=!0,e.push("Some requests may be blocked by ad blockers")),this._connectionBlocked&&(t=!0,e.push("Initial connection test failed - ad blocker may be active")),"undefined"==typeof window&&e.push("Not running in browser environment"),void 0===navigator.sendBeacon&&e.push("sendBeacon not available, using fetch fallback"),{blocked:t,recommendations:e}}isPreexistingUser(){if(!mt)return!1;const e=this.getCookie(`human_behavior_end_user_id_${this.apiKey}`);return null!==e&&e!==this.endUserId}getUserInfo(){return{endUserId:this.endUserId,sessionId:this.sessionId,isPreexistingUser:this.isPreexistingUser(),initialized:this.initialized}}}mt&&(window.HumanBehaviorTracker=ft),"undefined"!=typeof window&&(window.HumanBehaviorTracker=ft),e.HumanBehaviorAPI=ut,e.HumanBehaviorTracker=ft,e.MAX_CHUNK_SIZE_BYTES=ct,e.RedactionManager=gt,e.default=ft,e.isChunkSizeExceeded=lt,e.logDebug=at,e.logError=it,e.logInfo=st,e.logWarn=rt,e.logger=ot,e.redactionManager=pt,e.validateSingleEventSize=dt,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
16
16
|
//# sourceMappingURL=index.min.js.map
|