(() => { let tracker_url_base = "https://publisher.skippership.com"; let tracker_key = "jenbMCNROn7jcZyD"; let tracker_exposed_identifier = 'skippership'; let tracker_heatmaps = [{"id":7,"name":"Homepage heatmap","path":"/","is_enabled":true,"snapshots":[{"id":5,"type":"desktop"},{"id":6,"type":"mobile"}]}]; let tracker_goals = []; let tracker_included_path = []; let tracker_excluded_path = []; let isReplayEnable = true; let isInitVisitorEnable = true; let isPageviewEnable = true; let isEventChildrenEnable = true; let isHeatmapEnable = true; let isGoalEnable = true; let isCustomGoalEnable = true; let socket = null; let socketUrl = "https://publisher.skippership.com"; let errorMessage = null; let serverTime = "2025-08-19T18:02:48.542Z"; let pageLoadTime = performance.now(); let is_mouse_movement_enabled = true; /* Helper messages */ let tracker_key_verify_message = 'The Tracker Code has been installed properly.'; let tracker_key_dnt_message = 'Do Not Track is enabled, we are respecting your privacy and we do not track you.'; let tracker_key_optout_message = 'You opted out of tracking, we are respecting your privacy and your decision and we do not track you.'; // Display error message if exists if (errorMessage) { console.log('%c' + errorMessage, 'color: #ff0000; font-weight: bold;'); } /*! * Socket.IO v4.4.1 * (c) 2014-2022 Guillermo Rauch * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}var d=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,y=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],v=function(t){var e=t,n=t.indexOf("["),r=t.indexOf("]");-1!=n&&-1!=r&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));for(var o,i,s=d.exec(t||""),a={},c=14;c--;)a[y[c]]=s[c]||"";return-1!=n&&-1!=r&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(t,e){var n=/\/{2,9}/g,r=e.replace(n,"/").split("/");"/"!=e.substr(0,1)&&0!==e.length||r.splice(0,1);"/"==e.substr(e.length-1,1)&&r.splice(r.length-1,1);return r}(0,a.path),a.queryKey=(o=a.query,i={},o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(i[e]=n)})),i),a};var m={exports:{}};try{m.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){m.exports=!1}var g=m.exports,k="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function b(t){var e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||g))return new XMLHttpRequest}catch(t){}if(!e)try{return new(k[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function w(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1?{type:O[n],data:t.substring(1)}:{type:O[n]}:S},M=function(t,e){if(I){var n=function(t){var e,n,r,o,i,s=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var u=new ArrayBuffer(s),h=new Uint8Array(u);for(e=0;e>4,h[c++]=(15&r)<<4|o>>2,h[c++]=(3&o)<<6|63&i;return u}(t);return U(n,e)}return{base64:!0,data:t}},U=function(t,e){return"blob"===e&&t instanceof ArrayBuffer?new Blob([t]):t},V=String.fromCharCode(30),H=function(t){i(o,t);var n=h(o);function o(t){var r;return e(this,o),(r=n.call(this)).writable=!1,A(c(r),t),r.opts=t,r.query=t.query,r.readyState="",r.socket=t.socket,r}return r(o,[{key:"onError",value:function(t,e){var n=new Error(t);return n.type="TransportError",n.description=e,f(s(o.prototype),"emit",this).call(this,"error",n),this}},{key:"open",value:function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(t){"open"===this.readyState&&this.write(t)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,f(s(o.prototype),"emit",this).call(this,"open")}},{key:"onData",value:function(t){var e=F(t,this.socket.binaryType);this.onPacket(e)}},{key:"onPacket",value:function(t){f(s(o.prototype),"emit",this).call(this,"packet",t)}},{key:"onClose",value:function(){this.readyState="closed",f(s(o.prototype),"emit",this).call(this,"close")}}]),o}(R),K="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Y={},z=0,$=0;function W(t){var e="";do{e=K[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function J(){var t=W(+new Date);return t!==D?(z=0,D=t):t+"."+W(z++)}for(;$<64;$++)Y[K[$]]=$;J.encode=W,J.decode=function(t){var e=0;for($=0;$0&&void 0!==arguments[0]?arguments[0]:{};return o(t,{xd:this.xd,xs:this.xs},this.opts),new nt(this.uri(),t)}},{key:"doWrite",value:function(t,e){var n=this,r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(function(t){n.onError("xhr post error",t)}))}},{key:"doPoll",value:function(){var t=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e}}]),s}(Q),nt=function(t){i(o,t);var n=h(o);function o(t,r){var i;return e(this,o),A(c(i=n.call(this)),r),i.opts=r,i.method=r.method||"GET",i.uri=t,i.async=!1!==r.async,i.data=void 0!==r.data?r.data:null,i.create(),i}return r(o,[{key:"create",value:function(){var t=this,e=w(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;var n=this.xhr=new b(e);try{n.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(var r in n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}catch(t){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{n.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||1223===n.status?t.onLoad():t.setTimeoutFn((function(){t.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((function(){t.onError(e)}),0)}"undefined"!=typeof document&&(this.index=o.requestsCount++,o.requests[this.index]=this)}},{key:"onSuccess",value:function(){this.emit("success"),this.cleanup()}},{key:"onData",value:function(t){this.emit("data",t),this.onSuccess()}},{key:"onError",value:function(t){this.emit("error",t),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Z,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete o.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var t=this.xhr.responseText;null!==t&&this.onData(t)}},{key:"abort",value:function(){this.cleanup()}}]),o}(R);if(nt.requestsCount=0,nt.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",rt);else if("function"==typeof addEventListener){addEventListener("onpagehide"in k?"pagehide":"unload",rt,!1)}function rt(){for(var t in nt.requests)nt.requests.hasOwnProperty(t)&&nt.requests[t].abort()}var ot="function"==typeof Promise&&"function"==typeof Promise.resolve?function(t){return Promise.resolve().then(t)}:function(t,e){return e(t,0)},it=k.WebSocket||k.MozWebSocket,st="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),at=function(t){i(o,t);var n=h(o);function o(t){var r;return e(this,o),(r=n.call(this,t)).supportsBinary=!t.forceBase64,r}return r(o,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var t=this.uri(),e=this.opts.protocols,n=st?{}:w(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=st?new it(t,e,n):e?new it(t,e):new it(t)}catch(t){return this.emit("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=function(e){return t.onData(e.data)},this.ws.onerror=function(e){return t.onError("websocket error",e)}}},{key:"write",value:function(t){var e=this;this.writable=!1;for(var n=function(n){var r=t[n],o=n===t.length-1;x(r,e.supportsBinary,(function(t){try{e.ws.send(t)}catch(t){}o&&ot((function(){e.writable=!0,e.emit("drain")}),e.setTimeoutFn)}))},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return e(this,a),r=s.call(this),n&&"object"===t(n)&&(i=n,n=null),n?(n=v(n),i.hostname=n.host,i.secure="https"===n.protocol||"wss"===n.protocol,i.port=n.port,n.query&&(i.query=n.query)):i.host&&(i.hostname=v(i.host).host),A(c(r),i),r.secure=null!=i.secure?i.secure:"undefined"!=typeof location&&"https:"===location.protocol,i.hostname&&!i.port&&(i.port=r.secure?"443":"80"),r.hostname=i.hostname||("undefined"!=typeof location?location.hostname:"localhost"),r.port=i.port||("undefined"!=typeof location&&location.port?location.port:r.secure?"443":"80"),r.transports=i.transports||["polling","websocket"],r.readyState="",r.writeBuffer=[],r.prevBufferLen=0,r.opts=o({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},i),r.opts.path=r.opts.path.replace(/\/$/,"")+"/","string"==typeof r.opts.query&&(r.opts.query=G.decode(r.opts.query)),r.id=null,r.upgrades=null,r.pingInterval=null,r.pingTimeout=null,r.pingTimeoutTimer=null,"function"==typeof addEventListener&&(r.opts.closeOnBeforeunload&&addEventListener("beforeunload",(function(){r.transport&&(r.transport.removeAllListeners(),r.transport.close())}),!1),"localhost"!==r.hostname&&(r.offlineEventListener=function(){r.onClose("transport close")},addEventListener("offline",r.offlineEventListener,!1))),r.open(),r}return r(a,[{key:"createTransport",value:function(t){var e=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}(this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);var n=o({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new ct[t](n)}},{key:"open",value:function(){var t,e=this;if(this.opts.rememberUpgrade&&a.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){e.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(){e.onClose("transport close")}))}},{key:"probe",value:function(t){var e=this,n=this.createTransport(t),r=!1;a.priorWebsocketSuccess=!1;var o=function(){r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(function(t){if(!r)if("pong"===t.type&&"probe"===t.data){if(e.upgrading=!0,e.emitReserved("upgrading",n),!n)return;a.priorWebsocketSuccess="websocket"===n.name,e.transport.pause((function(){r||"closed"!==e.readyState&&(f(),e.setTransport(n),n.send([{type:"upgrade"}]),e.emitReserved("upgrade",n),n=null,e.upgrading=!1,e.flush())}))}else{var o=new Error("probe error");o.transport=n.name,e.emitReserved("upgradeError",o)}})))};function i(){r||(r=!0,f(),n.close(),n=null)}var s=function(t){var r=new Error("probe error: "+t);r.transport=n.name,i(),e.emitReserved("upgradeError",r)};function c(){s("transport closed")}function u(){s("socket closed")}function h(t){n&&t.name!==n.name&&i()}var f=function(){n.removeListener("open",o),n.removeListener("error",s),n.removeListener("close",c),e.off("close",u),e.off("upgrading",h)};n.once("open",o),n.once("error",s),n.once("close",c),this.once("close",u),this.once("upgrading",h),n.open()}},{key:"onOpen",value:function(){if(this.readyState="open",a.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t0;case bt.ACK:case bt.BINARY_ACK:return Array.isArray(n)}}}]),a}(R);var Et=function(){function t(n){e(this,t),this.packet=n,this.buffers=[],this.reconPack=n}return r(t,[{key:"takeBinaryData",value:function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=gt(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}(),At=Object.freeze({__proto__:null,protocol:5,get PacketType(){return bt},Encoder:wt,Decoder:_t});function Rt(t,e,n){return t.on(e,n),function(){t.off(e,n)}}var Tt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Ct=function(t){i(o,t);var n=h(o);function o(t,r,i){var s;return e(this,o),(s=n.call(this)).connected=!1,s.disconnected=!0,s.receiveBuffer=[],s.sendBuffer=[],s.ids=0,s.acks={},s.flags={},s.io=t,s.nsp=r,i&&i.auth&&(s.auth=i.auth),s.io._autoConnect&&s.open(),s}return r(o,[{key:"subEvents",value:function(){if(!this.subs){var t=this.io;this.subs=[Rt(t,"open",this.onopen.bind(this)),Rt(t,"packet",this.onpacket.bind(this)),Rt(t,"error",this.onerror.bind(this)),Rt(t,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n1?e-1:0),r=1;r0&&t.jitter<=1?t.jitter:0,this.attempts=0}St.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},St.prototype.reset=function(){this.attempts=0},St.prototype.setMin=function(t){this.ms=t},St.prototype.setMax=function(t){this.max=t},St.prototype.setJitter=function(t){this.jitter=t};var Bt=function(n){i(s,n);var o=h(s);function s(n,r){var i,a;e(this,s),(i=o.call(this)).nsps={},i.subs=[],n&&"object"===t(n)&&(r=n,n=void 0),(r=r||{}).path=r.path||"/socket.io",i.opts=r,A(c(i),r),i.reconnection(!1!==r.reconnection),i.reconnectionAttempts(r.reconnectionAttempts||1/0),i.reconnectionDelay(r.reconnectionDelay||1e3),i.reconnectionDelayMax(r.reconnectionDelayMax||5e3),i.randomizationFactor(null!==(a=r.randomizationFactor)&&void 0!==a?a:.5),i.backoff=new Ot({min:i.reconnectionDelay(),max:i.reconnectionDelayMax(),jitter:i.randomizationFactor()}),i.timeout(null==r.timeout?2e4:r.timeout),i._readyState="closed",i.uri=n;var u=r.parser||At;return i.encoder=new u.Encoder,i.decoder=new u.Decoder,i._autoConnect=!1!==r.autoConnect,i._autoConnect&&i.open(),i}return r(s,[{key:"reconnection",value:function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}},{key:"reconnectionAttempts",value:function(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}},{key:"reconnectionDelay",value:function(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}},{key:"randomizationFactor",value:function(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}},{key:"reconnectionDelayMax",value:function(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}},{key:"timeout",value:function(t){return arguments.length?(this._timeout=t,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){var e=this;if(~this._readyState.indexOf("open"))return this;this.engine=new ut(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var o=Rt(n,"open",(function(){r.onopen(),t&&t()})),i=Rt(n,"error",(function(n){r.cleanup(),r._readyState="closed",e.emitReserved("error",n),t?t(n):r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;0===s&&o();var a=this.setTimeoutFn((function(){o(),n.close(),n.emit("error",new Error("timeout"))}),s);this.opts.autoUnref&&a.unref(),this.subs.push((function(){clearTimeout(a)}))}return this.subs.push(o),this.subs.push(i),this}},{key:"connect",value:function(t){return this.open(t)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var t=this.engine;this.subs.push(Rt(t,"ping",this.onping.bind(this)),Rt(t,"data",this.ondata.bind(this)),Rt(t,"error",this.onerror.bind(this)),Rt(t,"close",this.onclose.bind(this)),Rt(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(t){this.decoder.add(t)}},{key:"ondecoded",value:function(t){this.emitReserved("packet",t)}},{key:"onerror",value:function(t){this.emitReserved("error",t)}},{key:"socket",value:function(t,e){var n=this.nsps[t];return n||(n=new Ct(this,t,e),this.nsps[t]=n),n}},{key:"_destroy",value:function(t){for(var e=0,n=Object.keys(this.nsps);e=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){e.skipReconnect||(t.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),t.emitReserved("reconnect_error",n)):e.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}},{key:"onreconnect",value:function(){var t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}]),s}(R),Nt={};function xt(e,n){"object"===t(e)&&(n=e,e=void 0);var r,o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=t;n=n||"undefined"!=typeof location&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==n?n.protocol+"//"+t:"https://"+t),r=v(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+e,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(n=n||{}).path||"/socket.io"),i=o.source,s=o.id,a=o.path,c=Nt[s]&&a in Nt[s].nsps;return n.forceNew||n["force new connection"]||!1===n.multiplex||c?r=new Bt(i,n):(Nt[s]||(Nt[s]=new Bt(i,n)),r=Nt[s]),o.query&&!n.query&&(n.query=o.queryKey),r.socket(o.path,n)}return o(xt,{Manager:Bt,Socket:Ct,io:xt,connect:xt}),xt})); //# sourceMappingURL=socket.io.min.js.map var rrwebConsoleRecord=function(e){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function r(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function t(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),a=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function n(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var r=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),t=r.match(/ (\((.+):(\d+):(\d+)\)$)/),n=(r=t?r.replace(t[0],""):r).split(/\s+/).slice(1),o=this.extractLocation(t?t[1]:n.pop()),i=n.join(" ")||void 0,a=["eval",""].indexOf(o[0])>-1?void 0:o[0];return new h({functionName:i,fileName:a,lineNumber:o[1],columnNumber:o[2]})}),this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter((function(e){return!e.match(v)}),this).map((function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new h({functionName:e});var r=/((.*".+"[^@]*)?[^@]*)(?:@)/,t=e.match(r),n=t&&t[1]?t[1]:void 0,o=this.extractLocation(e.replace(r,""));return new h({functionName:n,fileName:o[0],lineNumber:o[1],columnNumber:o[2]})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var r=/Line (\d+).*script (?:in )?(\S+)/i,t=e.message.split("\n"),n=[],o=2,i=t.length;o/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new h({functionName:n,fileName:t[0],lineNumber:t[1],columnNumber:t[2]})}),this)}};function y(e){if(!e||!e.outerHTML)return"";for(var r="";e.parentElement;){var t=e.localName;if(!t)break;t=t.toLowerCase();var n=e.parentElement,o=[];if(n.children&&n.children.length>0)for(var i=0;i1&&(t+=":eq("+o.indexOf(e)+")"),r=t+(r?">"+r:""),e=n}return r}function b(e){return"[object Object]"===Object.prototype.toString.call(e)}function w(e,t){var n,o;if(0===t)return!0;var i=Object.keys(e);try{for(var a=r(i),c=a.next();!c.done;c=a.next()){var u=c.value;if(b(e[u])&&w(e[u],t-1))return!0}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return!1}function N(e,r){var t={numOfKeysLimit:50,depthOfLimit:4};Object.assign(t,r);var n=[],o=[];return JSON.stringify(e,(function(e,r){if(n.length>0){var i=n.indexOf(this);~i?n.splice(i+1):n.push(this),~i?o.splice(i,1/0,e):o.push(e),~n.indexOf(r)&&(r=n[0]===r?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(r)).join(".")+"]")}else n.push(r);if(null==r)return r;if(function(e){if(b(e)&&Object.keys(e).length>t.numOfKeysLimit)return!0;if("function"==typeof e)return!0;if(b(e)&&w(e,t.depthOfLimit))return!0;return!1}(r))return function(e){var r=e.toString();t.stringLengthLimit&&r.length>t.stringLengthLimit&&(r="".concat(r.slice(0,t.stringLengthLimit),"..."));return r}(r);if(r instanceof Event){var a={};for(var c in r){var u=r[c];Array.isArray(u)?a[c]=y(u.length?u[0]:null):a[c]=u}return a}return r instanceof Node?r instanceof HTMLElement?r?r.outerHTML:"":r.nodeName:r instanceof Error?r.stack?r.stack+"\nEnd of stack for Error object":r.name+": "+r.message:r}))}var S={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function O(e,o,i){var a,c,u,l=i.logger;if(!l)return function(){};u="string"==typeof l?o[l]:l;var s=0,f=[];if(i.level.includes("error")&&window){var p=function(r){var t=r.message,n=r.error,o=g.parse(n).map((function(e){return e.toString()})),a=[N(t,i.stringifyOptions)];e({level:"error",trace:o,payload:a})};window.addEventListener("error",p),f.push((function(){window&&window.removeEventListener("error",p)}))}try{for(var h=r(i.level),d=h.next();!d.done;d=h.next()){var m=d.value;f.push(v(u,m))}}catch(e){a={error:e}}finally{try{d&&!d.done&&(c=h.return)&&c.call(h)}finally{if(a)throw a.error}}return function(){f.forEach((function(e){return e()}))};function v(r,o){var a=this;return r[o]?function(e,r,t){try{if(!(r in e))return function(){};var n=e[r],o=t(n);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[r]=o,function(){e[r]=n}}catch(e){return function(){}}}(r,o,(function(r){return function(){for(var c=[],u=0;u-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var ie,je,Zt=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,jt=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,Ut=/^(data:)([^,]*),(.*)/i;function Ce(e,t){return(e||"").replace(Zt,function(r,n,o,s,l,a){var i=o||l||a,c=n||s||"";if(!i)return r;if(!jt.test(i)||Ut.test(i))return"url(".concat(c).concat(i).concat(c,")");if(i[0]==="/")return"url(".concat(c).concat(Vt(t)+i).concat(c,")");var d=t.split("/"),u=i.split("/");d.pop();for(var h=0,m=u;h=t.length);){var s=n(Ht);if(s.slice(-1)===",")s=ke(e,s.substring(0,s.length-1)),o.push(s);else{var l="";s=ke(e,s);for(var a=!1;;){var i=t.charAt(r);if(i===""){o.push((s+l).trim());break}else if(a)i===")"&&(a=!1);else if(i===","){r+=1,o.push((s+l).trim());break}else i==="("&&(a=!0);l+=i,r+=1}}}return o.join(", ")}function ke(e,t){if(!t||t.trim()==="")return t;var r=e.createElement("a");return r.href=t,r.href}function Yt(e){return Boolean(e.tagName==="svg"||e.ownerSVGElement)}function De(){var e=document.createElement("a");return e.href="",e.href}function Ue(e,t,r,n){return r==="src"||r==="href"&&n&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n&&n[0]!=="#"||r==="background"&&n&&(t==="table"||t==="td"||t==="th")?ke(e,n):r==="srcset"&&n?Bt(e,n):r==="style"&&n?Ce(n,De()):t==="object"&&r==="data"&&n?ke(e,n):n}function $t(e,t,r){if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var o=e.classList[n];if(t.test(o))return!0}return r?e.matches(r):!1}function Me(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Me(e.parentNode,t,r):!1;for(var n=e.classList.length;n--;){var o=e.classList[n];if(t.test(o))return!0}return r?Me(e.parentNode,t,r):!1}function He(e,t,r){var n=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(n===null)return!1;if(typeof t=="string"){if(n.classList.contains(t)||n.closest(".".concat(t)))return!0}else if(Me(n,t,!0))return!0;return!!(r&&(n.matches(r)||n.closest(r)))}function Kt(e,t,r){var n=e.contentWindow;if(n){var o=!1,s;try{s=n.document.readyState}catch{return}if(s!=="complete"){var l=setTimeout(function(){o||(t(),o=!0)},r);e.addEventListener("load",function(){clearTimeout(l),o=!0,t()});return}var a="about:blank";if(n.location.href!==a||e.src===a||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Jt(e,t,r){var n=!1,o;try{o=e.sheet}catch{return}if(!o){var s=setTimeout(function(){n||(t(),n=!0)},r);e.addEventListener("load",function(){clearTimeout(s),n=!0,t()})}}function Qt(e,t){var r=t.doc,n=t.mirror,o=t.blockClass,s=t.blockSelector,l=t.maskTextClass,a=t.maskTextSelector,i=t.inlineStylesheet,c=t.maskInputOptions,d=c===void 0?{}:c,u=t.maskTextFn,h=t.maskInputFn,m=t.dataURLOptions,p=m===void 0?{}:m,v=t.inlineImages,g=t.recordCanvas,S=t.keepIframeSrcFn,y=t.newlyAddedElement,f=y===void 0?!1:y,w=qt(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:x.Document,childNodes:[],compatMode:e.compatMode}:{type:x.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:x.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:w};case e.ELEMENT_NODE:return tr(e,{doc:r,blockClass:o,blockSelector:s,inlineStylesheet:i,maskInputOptions:d,maskInputFn:h,dataURLOptions:p,inlineImages:v,recordCanvas:g,keepIframeSrcFn:S,newlyAddedElement:f,rootId:w});case e.TEXT_NODE:return er(e,{maskTextClass:l,maskTextSelector:a,maskTextFn:u,rootId:w});case e.CDATA_SECTION_NODE:return{type:x.CDATA,textContent:"",rootId:w};case e.COMMENT_NODE:return{type:x.Comment,textContent:e.textContent||"",rootId:w};default:return!1}}function qt(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function er(e,t){var r,n=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,l=t.rootId,a=e.parentNode&&e.parentNode.tagName,i=e.textContent,c=a==="STYLE"?!0:void 0,d=a==="SCRIPT"?!0:void 0;if(c&&i){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(i=Gt(e.parentNode.sheet))}catch(u){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u),e)}i=Ce(i,De())}return d&&(i="SCRIPT_PLACEHOLDER"),!c&&!d&&i&&He(e,n,o)&&(i=s?s(i):i.replace(/[\S]/g,"*")),{type:x.Text,textContent:i||"",isStyle:c,rootId:l}}function tr(e,t){for(var r=t.doc,n=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,l=t.maskInputOptions,a=l===void 0?{}:l,i=t.maskInputFn,c=t.dataURLOptions,d=c===void 0?{}:c,u=t.inlineImages,h=t.recordCanvas,m=t.keepIframeSrcFn,p=t.newlyAddedElement,v=p===void 0?!1:p,g=t.rootId,S=$t(e,n,o),y=zt(e),f={},w=e.attributes.length,F=0;Fr.removeEventListener(e,t,n)}const ce=`Please stop import mirror directly. Instead of that,\r now you can use replayer.getMirror() to access the mirror instance of a replayer,\r or you can use record.mirror to access the mirror instance during recording.`;let Xe={map:{},getId(){return console.error(ce),-1},getNode(){return console.error(ce),null},removeNodeFromMap(){console.error(ce)},has(){return console.error(ce),!1},reset(){console.error(ce)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Xe=new Proxy(Xe,{get(e,t,r){return t==="map"&&console.error(ce),Reflect.get(e,t,r)}}));function Se(e,t,r={}){let n=null,o=0;return function(...s){const l=Date.now();!o&&r.leading===!1&&(o=l);const a=t-(l-o),i=this;a<=0||a>t?(n&&(clearTimeout(n),n=null),o=l,e.apply(i,s)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{o=r.leading===!1?0:Date.now(),n=null,e.apply(i,s)},a))}}function we(e,t,r,n,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set(l){setTimeout(()=>{r.set.call(this,l)},0),s&&s.set&&s.set.call(this,l)}}),()=>we(e,t,s||{},!0)}function de(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,()=>{e[t]=n}}catch{return()=>{}}}function Be(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ye(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function _(e,t,r,n){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if(typeof t=="string"){if(o.classList.contains(t)||n&&o.closest("."+t)!==null)return!0}else if(Me(o,t,n))return!0;return!!(r&&(e.matches(r)||n&&o.closest(r)!==null))}function or(e,t){return t.getId(e)!==-1}function Fe(e,t){return t.getId(e)===ge}function $e(e,t){if(fe(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?$e(e.parentNode,t):!0:!0}function Ke(e){return Boolean(e.changedTouches)}function ar(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=(...t)=>{let r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function Je(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function Qe(e,t){return Boolean(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function qe(e){return Boolean(e?.shadowRoot)}class sr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!=null?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var C=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(C||{}),I=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(I||{}),Ae=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(Ae||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{}),pe=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(pe||{}),ir=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(ir||{});function et(e){return"__ln"in e}class lr{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n`${e}@${t}`;class cr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],r=new lr,n=a=>{let i=a,c=ge;for(;c===ge;)i=i&&i.nextSibling,c=i&&this.mirror.getId(i);return c},o=a=>{var i,c,d,u;let h=null;((c=(i=a.getRootNode)==null?void 0:i.call(a))==null?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&a.getRootNode().host&&(h=a.getRootNode().host);let m=h;for(;((u=(d=m?.getRootNode)==null?void 0:d.call(m))==null?void 0:u.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&m.getRootNode().host;)m=m.getRootNode().host;const p=!this.doc.contains(a)&&(!m||!this.doc.contains(m));if(!a.parentNode||p)return;const v=fe(a.parentNode)?this.mirror.getId(h):this.mirror.getId(a.parentNode),g=n(a);if(v===-1||g===-1)return r.addNode(a);const S=le(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:y=>{Je(y,this.mirror)&&this.iframeManager.addIframe(y),Qe(y,this.mirror)&&this.stylesheetManager.trackLinkElement(y),qe(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(y,f)=>{this.iframeManager.attachIframe(y,f),this.shadowDomManager.observeAttachShadow(y)},onStylesheetLoad:(y,f)=>{this.stylesheetManager.attachLinkElement(y,f)}});S&&t.push({parentId:v,nextId:g,node:S})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of Array.from(this.movedSet.values()))rt(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||o(a);for(const a of Array.from(this.addedSet.values()))!ot(this.droppedSet,a)&&!rt(this.removes,a,this.mirror)||ot(this.movedSet,a)?o(a):this.droppedSet.add(a);let s=null;for(;r.length;){let a=null;if(s){const i=this.mirror.getId(s.value.parentNode),c=n(s.value);i!==-1&&c!==-1&&(a=s)}if(!a)for(let i=r.length-1;i>=0;i--){const c=r.get(i);if(c){const d=this.mirror.getId(c.value.parentNode);if(n(c.value)===-1)continue;if(d!==-1){a=c;break}else{const u=c.value;if(u.parentNode&&u.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const h=u.parentNode.host;if(this.mirror.getId(h)!==-1){a=c;break}}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}s=a.previous,r.removeNode(a.value),o(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>({id:this.mirror.getId(a.node),attributes:a.attributes})).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:t};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=t=>{if(!Fe(t.target,this.mirror))switch(t.type){case"characterData":{const r=t.target.textContent;!_(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:He(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.target.getAttribute(t.attributeName);if(t.attributeName==="value"&&(n=xe({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),_(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let o=this.attributes.find(s=>s.node===t.target);if(r.tagName==="IFRAME"&&t.attributeName==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)t.attributeName="rr_src";else return;if(o||(o={node:t.target,attributes:{}},this.attributes.push(o)),t.attributeName==="style"){const s=this.doc.createElement("span");t.oldValue&&s.setAttribute("style",t.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const l=o.attributes.style;for(const a of Array.from(r.style)){const i=r.style.getPropertyValue(a),c=r.style.getPropertyPriority(a);(i!==s.style.getPropertyValue(a)||c!==s.style.getPropertyPriority(a))&&(c===""?l[a]=i:l[a]=[i,c])}for(const a of Array.from(s.style))r.style.getPropertyValue(a)===""&&(l[a]=!1)}else o.attributes[t.attributeName]=Ue(this.doc,r.tagName,t.attributeName,n);break}case"childList":{if(_(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),o=fe(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);_(t.target,this.blockClass,this.blockSelector,!1)||Fe(r,this.mirror)||!or(r,this.mirror)||(this.addedSet.has(r)?(_e(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||$e(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[tt(n,o)]?_e(this.movedSet,r):this.removes.push({parentId:o,id:n,isShadow:fe(t.target)&&ye(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,r)=>{if(this.mirror.hasNode(t)){if(Fe(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[tt(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);_(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(n=>this.genAdds(n))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function _e(e,t){e.delete(t),t.childNodes.forEach(r=>_e(e,r))}function rt(e,t,r){return e.length===0?!1:nt(e,t,r)}function nt(e,t,r){const{parentNode:n}=t;if(!n)return!1;const o=r.getId(n);return e.some(s=>s.id===o)?!0:nt(e,n,r)}function ot(e,t){return e.size===0?!1:at(e,t)}function at(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:at(e,r):!1}var dr=Object.defineProperty,ur=Object.defineProperties,pr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,it=(e,t,r)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lt=(e,t)=>{for(var r in t||(t={}))hr.call(t,r)&&it(e,r,t[r]);if(st)for(var r of st(t))mr.call(t,r)&&it(e,r,t[r]);return e},fr=(e,t)=>ur(e,pr(t));const se=[],ct=typeof CSSGroupingRule<"u",dt=typeof CSSMediaRule<"u",ut=typeof CSSSupportsRule<"u",pt=typeof CSSConditionRule<"u";function ve(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function ht(e,t){var r,n;const o=new cr;se.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const l=(n=(r=window?.Zone)==null?void 0:r.__symbol__)==null?void 0:n.call(r,"MutationObserver");l&&window[l]&&(s=window[l]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function yr({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const o=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let l=[],a;const i=Se(u=>{const h=Date.now()-a;e(l.map(m=>(m.timeOffset-=h,m)),u),l=[],a=null},s),c=Se(u=>{const h=ve(u),{clientX:m,clientY:p}=Ke(u)?u.changedTouches[0]:u;a||(a=Date.now()),l.push({x:m,y:p,id:n.getId(h),timeOffset:Date.now()-a}),i(typeof DragEvent<"u"&&u instanceof DragEvent?I.Drag:u instanceof MouseEvent?I.MouseMove:I.TouchMove)},o,{trailing:!1}),d=[A("mousemove",c,r),A("touchmove",c,r),A("drag",c,r)];return()=>{d.forEach(u=>u())}}function gr({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const l=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,a=[],i=c=>d=>{const u=ve(d);if(_(u,n,o,!0))return;const h=Ke(d)?d.changedTouches[0]:d;if(!h)return;const m=r.getId(u),{clientX:p,clientY:v}=h;e({type:Ae[c],id:m,x:p,y:v})};return Object.keys(Ae).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&l[c]!==!1).forEach(c=>{const d=c.toLowerCase(),u=i(c);a.push(A(d,u,t))}),()=>{a.forEach(c=>c())}}function mt({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:s}){const l=Se(a=>{const i=ve(a);if(!i||_(i,n,o,!0))return;const c=r.getId(i);if(i===t){const d=t.scrollingElement||t.documentElement;e({id:c,x:d.scrollLeft,y:d.scrollTop})}else e({id:c,x:i.scrollLeft,y:i.scrollTop})},s.scroll||100);return A("scroll",l,t)}function Sr({viewportResizeCb:e}){let t=-1,r=-1;const n=Se(()=>{const o=Be(),s=Ye();(t!==o||r!==s)&&(e({width:Number(s),height:Number(o)}),t=o,r=s)},200);return A("resize",n,window)}function ft(e,t){const r=lt({},e);return t||delete r.userTriggered,r}const vr=["INPUT","TEXTAREA","SELECT"],yt=new WeakMap;function br({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,ignoreClass:s,maskInputOptions:l,maskInputFn:a,sampling:i,userTriggeredOnInput:c}){function d(g){let S=ve(g);const y=g.isTrusted;if(S&&S.tagName==="OPTION"&&(S=S.parentElement),!S||!S.tagName||vr.indexOf(S.tagName)<0||_(S,n,o,!0))return;const f=S.type;if(S.classList.contains(s))return;let w=S.value,F=!1;f==="radio"||f==="checkbox"?F=S.checked:(l[S.tagName.toLowerCase()]||l[f])&&(w=xe({maskInputOptions:l,tagName:S.tagName,type:f,value:w,maskInputFn:a})),u(S,ft({text:w,isChecked:F,userTriggered:y},c));const P=S.name;f==="radio"&&P&&F&&t.querySelectorAll(`input[type="radio"][name="${P}"]`).forEach(D=>{D!==S&&u(D,ft({text:D.value,isChecked:!F,userTriggered:!1},c))})}function u(g,S){const y=yt.get(g);if(!y||y.text!==S.text||y.isChecked!==S.isChecked){yt.set(g,S);const f=r.getId(g);e(fr(lt({},S),{id:f}))}}const h=(i.input==="last"?["change"]:["input","change"]).map(g=>A(g,d,t)),m=t.defaultView;if(!m)return()=>{h.forEach(g=>g())};const p=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),v=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&h.push(...v.map(g=>we(g[0],g[1],{set(){d({target:this})}},!1,m))),()=>{h.forEach(g=>g())}}function Oe(e){const t=[];function r(n,o){if(ct&&n.parentRule instanceof CSSGroupingRule||dt&&n.parentRule instanceof CSSMediaRule||ut&&n.parentRule instanceof CSSSupportsRule||pt&&n.parentRule instanceof CSSConditionRule){const s=Array.from(n.parentRule.cssRules).indexOf(n);o.unshift(s)}else if(n.parentStyleSheet){const s=Array.from(n.parentStyleSheet.cssRules).indexOf(n);o.unshift(s)}return o}return r(e,t)}function oe(e,t,r){let n,o;return e?(e.ownerNode?n=t.getId(e.ownerNode):o=r.getId(e),{styleId:o,id:n}):{}}function Ir({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){const o=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(d,u){const{id:h,styleId:m}=oe(this,t,r.styleMirror);return(h&&h!==-1||m&&m!==-1)&&e({id:h,styleId:m,adds:[{rule:d,index:u}]}),o.apply(this,[d,u])};const s=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,removes:[{index:d}]}),s.apply(this,[d])};let l;n.CSSStyleSheet.prototype.replace&&(l=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replace:d}),l.apply(this,[d])});let a;n.CSSStyleSheet.prototype.replaceSync&&(a=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replaceSync:d}),a.apply(this,[d])});const i={};ct?i.CSSGroupingRule=n.CSSGroupingRule:(dt&&(i.CSSMediaRule=n.CSSMediaRule),pt&&(i.CSSConditionRule=n.CSSConditionRule),ut&&(i.CSSSupportsRule=n.CSSSupportsRule));const c={};return Object.entries(i).forEach(([d,u])=>{c[d]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=function(h,m){const{id:p,styleId:v}=oe(this.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||v&&v!==-1)&&e({id:p,styleId:v,adds:[{rule:h,index:[...Oe(this),m||0]}]}),c[d].insertRule.apply(this,[h,m])},u.prototype.deleteRule=function(h){const{id:m,styleId:p}=oe(this.parentStyleSheet,t,r.styleMirror);return(m&&m!==-1||p&&p!==-1)&&e({id:m,styleId:p,removes:[{index:[...Oe(this),h]}]}),c[d].deleteRule.apply(this,[h])}}),()=>{n.CSSStyleSheet.prototype.insertRule=o,n.CSSStyleSheet.prototype.deleteRule=s,l&&(n.CSSStyleSheet.prototype.replace=l),a&&(n.CSSStyleSheet.prototype.replaceSync=a),Object.entries(i).forEach(([d,u])=>{u.prototype.insertRule=c[d].insertRule,u.prototype.deleteRule=c[d].deleteRule})}}function gt({mirror:e,stylesheetManager:t},r){var n,o,s;let l=null;r.nodeName==="#document"?l=e.getId(r):l=e.getId(r.host);const a=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(s=(o=r.ownerDocument)==null?void 0:o.defaultView)==null?void 0:s.ShadowRoot,i=Object.getOwnPropertyDescriptor(a?.prototype,"adoptedStyleSheets");return l===null||l===-1||!a||!i?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get(){var c;return(c=i.get)==null?void 0:c.call(this)},set(c){var d;const u=(d=i.set)==null?void 0:d.call(this,c);if(l!==null&&l!==-1)try{t.adoptStyleSheets(c,l)}catch{}return u}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get:i.get,set:i.set})})}function Cr({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(a,i,c){var d;if(r.has(a))return s.apply(this,[a,i,c]);const{id:u,styleId:h}=oe((d=this.parentRule)==null?void 0:d.parentStyleSheet,t,n.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,set:{property:a,value:i,priority:c},index:Oe(this.parentRule)}),s.apply(this,[a,i,c])};const l=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(a){var i;if(r.has(a))return l.apply(this,[a]);const{id:c,styleId:d}=oe((i=this.parentRule)==null?void 0:i.parentStyleSheet,t,n.styleMirror);return(c&&c!==-1||d&&d!==-1)&&e({id:c,styleId:d,remove:{property:a},index:Oe(this.parentRule)}),l.apply(this,[a])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=l}}function kr({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:o}){const s=a=>Se(i=>{const c=ve(i);if(!c||_(c,t,r,!0))return;const{currentTime:d,volume:u,muted:h,playbackRate:m}=c;e({type:a,id:n.getId(c),currentTime:d,volume:u,muted:h,playbackRate:m})},o.media||500),l=[A("play",s(pe.Play)),A("pause",s(pe.Pause)),A("seeked",s(pe.Seeked)),A("volumechange",s(pe.VolumeChange)),A("ratechange",s(pe.RateChange))];return()=>{l.forEach(a=>a())}}function Mr({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],o=new WeakMap,s=r.FontFace;r.FontFace=function(a,i,c){const d=new s(a,i,c);return o.set(d,{family:a,buffer:typeof i!="string",descriptors:c,fontSource:typeof i=="string"?i:JSON.stringify(Array.from(new Uint8Array(i)))}),d};const l=de(t.fonts,"add",function(a){return function(i){return setTimeout(()=>{const c=o.get(i);c&&(e(c),o.delete(i))},0),a.apply(this,[i])}});return n.push(()=>{r.FontFace=s}),n.push(l),()=>{n.forEach(a=>a())}}function wr(e){const{doc:t,mirror:r,blockClass:n,blockSelector:o,selectionCb:s}=e;let l=!0;const a=()=>{const i=t.getSelection();if(!i||l&&i?.isCollapsed)return;l=i.isCollapsed||!1;const c=[],d=i.rangeCount||0;for(let u=0;u{t.mutation&&t.mutation(...p),r(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),n(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),o(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),s(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),l(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),a(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),i(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),c(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),d(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),u(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),h(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),m(...p)}}function Tr(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};Or(e,t);const n=ht(e,e.doc),o=yr(e),s=gr(e),l=mt(e),a=Sr(e),i=br(e),c=kr(e),d=Ir(e,{win:r}),u=gt(e,e.doc),h=Cr(e,{win:r}),m=e.collectFonts?Mr(e):()=>{},p=wr(e),v=[];for(const g of e.plugins)v.push(g.observer(g.callback,r,g.options));return()=>{se.forEach(g=>g.reset()),n.disconnect(),o(),s(),l(),a(),i(),c(),d(),u(),h(),m(),p(),v.forEach(g=>g())}}class St{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,o){const s=n||this.getIdToRemoteIdMap(t),l=o||this.getRemoteIdToIdMap(t);let a=s.get(r);return a||(a=this.generateIdFn(),s.set(r,a),l.set(a,r)),a}getIds(t,r){const n=this.getIdToRemoteIdMap(t),o=this.getRemoteIdToIdMap(t);return r.map(s=>this.getId(t,s,n,o))}getRemoteId(t,r,n){const o=n||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:o.get(r)||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(o=>this.getRemoteId(t,o,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Rr{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new St(Ze),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new St(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)==null||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if(t.data.type==="rrweb"){if(!t.source)return;const r=this.crossOriginIframeMap.get(t.source);if(!r)return;const n=this.transformCrossOriginEvent(r,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,r){var n;switch(r.type){case C.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t),{timestamp:r.timestamp,type:C.IncrementalSnapshot,data:{source:I.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case C.Meta:case C.Load:case C.DomContentLoaded:return!1;case C.Plugin:return r;case C.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case C.IncrementalSnapshot:switch(r.data.source){case I.Mutation:return r.data.adds.forEach(o=>{this.replaceIds(o,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(o.node,t)}),r.data.removes.forEach(o=>{this.replaceIds(o,t,["parentId","id"])}),r.data.attributes.forEach(o=>{this.replaceIds(o,t,["id"])}),r.data.texts.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case I.Drag:case I.TouchMove:case I.MouseMove:return r.data.positions.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case I.ViewportResize:return!1;case I.MediaInteraction:case I.MouseInteraction:case I.Scroll:case I.CanvasMutation:case I.Input:return this.replaceIds(r.data,t,["id"]),r;case I.StyleSheetRule:case I.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case I.Font:return r;case I.Selection:return r.data.ranges.forEach(o=>{this.replaceIds(o,t,["start","end"])}),r;case I.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(o=>{this.replaceStyleIds(o,t,["styleId"])}),r}}}replace(t,r,n,o){for(const s of o)!Array.isArray(r[s])&&typeof r[s]!="number"||(Array.isArray(r[s])?r[s]=t.getIds(n,r[s]):r[s]=t.getId(n,r[s]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}}var Er=Object.defineProperty,Lr=Object.defineProperties,Nr=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,bt=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,It=(e,t)=>{for(var r in t||(t={}))xr.call(t,r)&&bt(e,r,t[r]);if(vt)for(var r of vt(t))Dr.call(t,r)&&bt(e,r,t[r]);return e},Ct=(e,t)=>Lr(e,Nr(t));class Fr{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const r=this;this.restorePatches.push(de(Element.prototype,"attachShadow",function(n){return function(o){const s=n.call(this,o);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,this.ownerDocument),s}}))}addShadowRoot(t,r){!ye(t)||this.shadowDoms.has(t)||(this.shadowDoms.add(t),ht(Ct(It({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),mt(Ct(It({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),gt({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0))}observeAttachShadow(t){if(t.contentWindow){const r=this;this.restorePatches.push(de(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(o){const s=n.call(this,o);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,t.contentDocument),s}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ar=typeof Uint8Array>"u"?[]:new Uint8Array(256),Te=0;Te>2],o+=he[(t[r]&3)<<4|t[r+1]>>4],o+=he[(t[r+1]&15)<<2|t[r+2]>>6],o+=he[t[r+2]&63];return n%3===2?o=o.substring(0,o.length-1)+"=":n%3===1&&(o=o.substring(0,o.length-2)+"=="),o};const kt=new Map;function Pr(e,t){let r=kt.get(e);return r||(r=new Map,kt.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const Mt=(e,t,r)=>{if(!e||!(Ot(e,t)||typeof e=="object"))return;const n=e.constructor.name,o=Pr(r,n);let s=o.indexOf(e);return s===-1&&(s=o.length,o.push(e)),s};function Re(e,t,r){if(e instanceof Array)return e.map(n=>Re(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,o=_r(e);return{rr_type:n,base64:o}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Re(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:o}=e;return{rr_type:n,src:o}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",o=e.toDataURL();return{rr_type:n,src:o}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Re(e.data,t,r),e.width,e.height]};if(Ot(e,t)||typeof e=="object"){const n=e.constructor.name,o=Mt(e,t,r);return{rr_type:n,index:o}}}}return e}const wt=(e,t,r)=>[...e].map(n=>Re(n,t,r)),Ot=(e,t)=>{const r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function");return Boolean(r.find(n=>e instanceof t[n]))};function Wr(e,t,r,n){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const l of s)try{if(typeof t.CanvasRenderingContext2D.prototype[l]!="function")continue;const a=de(t.CanvasRenderingContext2D.prototype,l,function(i){return function(...c){return _(this.canvas,r,n,!0)||setTimeout(()=>{const d=wt([...c],t,this);e(this.canvas,{type:ue["2D"],property:l,args:d})},0),i.apply(this,c)}});o.push(a)}catch{const i=we(t.CanvasRenderingContext2D.prototype,l,{set(c){e(this.canvas,{type:ue["2D"],property:l,args:[c],setter:!0})}});o.push(i)}return()=>{o.forEach(l=>l())}}function Tt(e,t,r){const n=[];try{const o=de(e.HTMLCanvasElement.prototype,"getContext",function(s){return function(l,...a){return _(this,t,r,!0)||"__context"in this||(this.__context=l),s.apply(this,[l,...a])}});n.push(o)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(o=>o())}}function Rt(e,t,r,n,o,s,l){const a=[],i=Object.getOwnPropertyNames(e);for(const c of i)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if(typeof e[c]!="function")continue;const d=de(e,c,function(u){return function(...h){const m=u.apply(this,h);if(Mt(m,l,this),!_(this.canvas,n,o,!0)){const p=wt([...h],l,this),v={type:t,property:c,args:p};r(this.canvas,v)}return m}});a.push(d)}catch{const u=we(e,c,{set(h){r(this.canvas,{type:t,property:c,args:[h],setter:!0})}});a.push(u)}return a}function zr(e,t,r,n,o){const s=[];return s.push(...Rt(t.WebGLRenderingContext.prototype,ue.WebGL,e,r,n,o,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...Rt(t.WebGL2RenderingContext.prototype,ue.WebGL2,e,r,n,o,t)),()=>{s.forEach(l=>l())}}function Gr(e,t){var r=atob(e);if(t){for(var n=new Uint8Array(r.length),o=0,s=r.length;o{var r={};for(var n in e)Ur.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Et)for(var n of Et(e))t.indexOf(n)<0&&Hr.call(e,n)&&(r[n]=e[n]);return r},Br=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{a(r.next(i))}catch(c){o(c)}},l=i=>{try{a(r.throw(i))}catch(c){o(c)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,l);a((r=r.apply(e,t)).next())});class Yr{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(i,c)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(i)||this.pendingCanvasMutations.set(i,[]),this.pendingCanvasMutations.get(i).push(c)};const{sampling:r="all",win:n,blockClass:o,blockSelector:s,recordCanvas:l,dataURLOptions:a}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,l&&r==="all"&&this.initCanvasMutationObserver(n,o,s),l&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,o,s,{dataURLOptions:a})}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(t,r,n,o,s){const l=Tt(r,n,o),a=new Map,i=new jr;i.onmessage=p=>{const{id:v}=p.data;if(a.set(v,!1),!("base64"in p.data))return;const{base64:g,type:S,width:y,height:f}=p.data;this.mutationCb({id:v,type:ue["2D"],commands:[{property:"clearRect",args:[0,0,y,f]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:g}],type:S}]},0,0]}]})};const c=1e3/t;let d=0,u;const h=()=>{const p=[];return r.document.querySelectorAll("canvas").forEach(v=>{_(v,n,o,!0)||p.push(v)}),p},m=p=>{if(d&&p-dBr(this,null,function*(){var g;const S=this.mirror.getId(v);if(a.get(S))return;if(a.set(S,!0),["webgl","webgl2"].includes(v.__context)){const f=v.getContext(v.__context);((g=f?.getContextAttributes())==null?void 0:g.preserveDrawingBuffer)===!1&&f?.clear(f.COLOR_BUFFER_BIT)}const y=yield createImageBitmap(v);i.postMessage({id:S,bitmap:y,width:v.width,height:v.height,dataURLOptions:s.dataURLOptions},[y])})),u=requestAnimationFrame(m)};u=requestAnimationFrame(m),this.resetObservers=()=>{l(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Tt(t,r,n),s=Wr(this.processMutation.bind(this),t,r,n),l=zr(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{o(),s(),l()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const o=n.map(l=>Xr(l,["type"])),{type:s}=n[0];this.mutationCb({id:r,type:s,commands:o}),this.pendingCanvasMutations.delete(t)}}class $r{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new sr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},o=[];for(const s of t){let l;if(this.styleMirror.has(s))l=this.styleMirror.getId(s);else{l=this.styleMirror.add(s);const a=Array.from(s.rules||CSSRule);o.push({styleId:l,rules:a.map((i,c)=>({rule:ze(i),index:c}))})}n.styleIds.push(l)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}var Kr=Object.defineProperty,Jr=Object.defineProperties,Qr=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,Nt=(e,t,r)=>t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,V=(e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Nt(e,r,t[r]);if(Lt)for(var r of Lt(t))en.call(t,r)&&Nt(e,r,t[r]);return e},tn=(e,t)=>Jr(e,Qr(t));function L(e){return tn(V({},e),{timestamp:Date.now()})}let T,Ee,Pe,Le=!1;const J=At();function be(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:l="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:i=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:m,maskTextFn:p,hooks:v,packFn:g,sampling:S={},dataURLOptions:y={},mousemoveWait:f,recordCanvas:w=!1,recordCrossOriginIframes:F=!1,userTriggeredOnInput:P=!1,collectFonts:D=!1,inlineImages:O=!1,plugins:X,keepIframeSrcFn:Z=()=>!1,ignoreCSSAttributes:B=new Set([])}=e,Y=F?window.parent===window:!0;let $=!1;if(!Y)try{window.parent.document,$=!1}catch{$=!0}if(Y&&!t)throw new Error("emit function is required");f!==void 0&&S.mousemove===void 0&&(S.mousemove=f),J.reset();const N=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u!==void 0?u:{password:!0},j=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};ar();let Q,te=0;const ne=b=>{for(const G of X||[])G.eventProcessor&&(b=G.eventProcessor(b));return g&&(b=g(b)),b};T=(b,G)=>{var K;if(((K=se[0])==null?void 0:K.isFrozen())&&b.type!==C.FullSnapshot&&!(b.type===C.IncrementalSnapshot&&b.data.source===I.Mutation)&&se.forEach(R=>R.unfreeze()),Y)t?.(ne(b),G);else if($){const R={type:"rrweb",event:ne(b),isCheckout:G};window.parent.postMessage(R,"*")}if(b.type===C.FullSnapshot)Q=b,te=0;else if(b.type===C.IncrementalSnapshot){if(b.data.source===I.Mutation&&b.data.isAttachIframe)return;te++;const R=n&&te>=n,ee=r&&b.timestamp-Q.timestamp>r;(R||ee)&&Ee(!0)}};const z=b=>{T(L({type:C.IncrementalSnapshot,data:V({source:I.Mutation},b)}))},U=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Scroll},b)})),ae=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.CanvasMutation},b)})),E=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.AdoptedStyleSheet},b)})),q=new $r({mutationCb:z,adoptedStyleSheetCb:E}),re=new Rr({mirror:J,mutationCb:z,stylesheetManager:q,recordCrossOriginIframes:F,wrappedEmit:T});for(const b of X||[])b.getMirror&&b.getMirror({nodeMirror:J,crossOriginIframeMirror:re.crossOriginIframeMirror,crossOriginIframeStyleMirror:re.crossOriginIframeStyleMirror});Pe=new Yr({recordCanvas:w,mutationCb:ae,win:window,blockClass:o,blockSelector:s,mirror:J,sampling:S.canvas,dataURLOptions:y});const me=new Fr({mutationCb:z,scrollCb:U,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskInputOptions:N,dataURLOptions:y,maskTextFn:p,maskInputFn:m,recordCanvas:w,inlineImages:O,sampling:S,slimDOMOptions:j,iframeManager:re,stylesheetManager:q,canvasManager:Pe,keepIframeSrcFn:Z},mirror:J});Ee=(b=!1)=>{var G,K,R,ee,k,H;T(L({type:C.Meta,data:{href:window.location.href,width:Ye(),height:Be()}}),b),q.reset(),se.forEach(W=>W.lock());const Ie=nr(document,{mirror:J,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskAllInputs:N,maskTextFn:p,slimDOM:j,dataURLOptions:y,recordCanvas:w,inlineImages:O,onSerialize:W=>{Je(W,J)&&re.addIframe(W),Qe(W,J)&&q.trackLinkElement(W),qe(W)&&me.addShadowRoot(W.shadowRoot,document)},onIframeLoad:(W,We)=>{re.attachIframe(W,We),me.observeAttachShadow(W)},onStylesheetLoad:(W,We)=>{q.attachLinkElement(W,We)},keepIframeSrcFn:Z});if(!Ie)return console.warn("Failed to snapshot the document");T(L({type:C.FullSnapshot,data:{node:Ie,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:document?.documentElement.scrollLeft||((K=(G=document?.body)==null?void 0:G.parentElement)==null?void 0:K.scrollLeft)||((R=document?.body)==null?void 0:R.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:document?.documentElement.scrollTop||((k=(ee=document?.body)==null?void 0:ee.parentElement)==null?void 0:k.scrollTop)||((H=document?.body)==null?void 0:H.scrollTop)||0}}})),se.forEach(W=>W.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&q.adoptStyleSheets(document.adoptedStyleSheets,J.getId(document))};try{const b=[];b.push(A("DOMContentLoaded",()=>{T(L({type:C.DomContentLoaded,data:{}}))}));const G=R=>{var ee;return Tr({mutationCb:z,mousemoveCb:(k,H)=>T(L({type:C.IncrementalSnapshot,data:{source:H,positions:k}})),mouseInteractionCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.MouseInteraction},k)})),scrollCb:U,viewportResizeCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.ViewportResize},k)})),inputCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Input},k)})),mediaInteractionCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.MediaInteraction},k)})),styleSheetRuleCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.StyleSheetRule},k)})),styleDeclarationCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.StyleDeclaration},k)})),canvasMutationCb:ae,fontCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Font},k)})),selectionCb:k=>{T(L({type:C.IncrementalSnapshot,data:V({source:I.Selection},k)}))},blockClass:o,ignoreClass:l,maskTextClass:a,maskTextSelector:i,maskInputOptions:N,inlineStylesheet:c,sampling:S,recordCanvas:w,inlineImages:O,userTriggeredOnInput:P,collectFonts:D,doc:R,maskInputFn:m,maskTextFn:p,keepIframeSrcFn:Z,blockSelector:s,slimDOMOptions:j,dataURLOptions:y,mirror:J,iframeManager:re,stylesheetManager:q,shadowDomManager:me,canvasManager:Pe,ignoreCSSAttributes:B,plugins:((ee=X?.filter(k=>k.observer))==null?void 0:ee.map(k=>({observer:k.observer,options:k.options,callback:H=>T(L({type:C.Plugin,data:{plugin:k.name,payload:H}}))})))||[]},v)};re.addLoadListener(R=>{b.push(G(R.contentDocument))});const K=()=>{Ee(),b.push(G(document)),Le=!0};return document.readyState==="interactive"||document.readyState==="complete"?K():b.push(A("load",()=>{T(L({type:C.Load,data:{}})),K()},window)),()=>{b.forEach(R=>R()),Le=!1}}catch(b){console.warn(b)}}return be.addCustomEvent=(e,t)=>{if(!Le)throw new Error("please add custom event after start recording");T(L({type:C.Custom,data:{tag:e,payload:t}}))},be.freezePage=()=>{se.forEach(e=>e.freeze())},be.takeFullSnapshot=e=>{if(!Le)throw new Error("please take full snapshot after start recording");Ee(e)},be.mirror=J,be}(); //# sourceMappingURL=rrweb-record.min.js.map /* Helpers */ let get_random_string = (length, chars) => { let result = ""; for (let i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; return result; }; let get_dynamic_var = (string) => { return `__${tracker_key}_${string}`; }; let get_random_id = () => { let result = get_random_string( 16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ); let date_time = new Date(); result += date_time.getFullYear(); result += date_time.getMonth(); result += date_time.getDate(); result += date_time.getHours(); result += date_time.getMinutes(); result += date_time.getSeconds(); /* Base64 return */ return btoa(result); }; let is_do_not_track = () => { if (window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack) { return ( window.doNotTrack == "1" || navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1" ); } else { return false; } }; let is_optout = () => { let params = new URL(document.location).searchParams; /* Disable tracking and set a cookie for the future */ let tracker_optout = params.get("tracker_optout"); if (tracker_optout !== null) { tracker_optout = tracker_optout == "true"; if (tracker_optout) { localStorage.setItem(get_dynamic_var("tracker_optout"), "true"); return true; } else { localStorage.setItem(get_dynamic_var("tracker_optout"), "false"); return false; } } return localStorage.getItem(get_dynamic_var("tracker_optout")) == "true"; }; let tracker_verify = () => { let params = new URL(document.location).searchParams; /* Disable tracking and set a cookie for the future */ let tracker_verify_query = params.get("tracker_verify"); if (tracker_verify_query !== null) { /* Check against the tracker key if needed */ if (tracker_verify_query != "") { if (tracker_key == tracker_verify_query) { alert(tracker_key_verify_message); } } else { /* If its a simpler check, just echo that it has been installed */ alert(tracker_key_verify_message); } } }; let get_device_type = () => { let android = /(?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera mini|avantgo|mobilesafari|docomo)/gi; let tablet = /(?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))/gi; return android.test(navigator.userAgent) ? "mobile" : tablet.test(navigator.userAgent) ? "tablet" : "desktop"; }; let get_current_url_domain_no_www = () => { let url = window.location.href.replace(window.location.protocol + "//", ""); /* Remove www. from the host */ if (url.startsWith("www.")) { url = url.replace("www.", ""); } url = sanitizeUrl(url); return url; }; const sanitizeUrl = (url) => { //remove trailing slashes url = url.replace(/\/+$/, ""); return url; }; const checkIncludeExcludePath = (pathes) => { pathes.forEach((element) => { if (get_current_url_domain_no_www().includes(element)) { return true; } }); return false; }; /** check if input contine credit card Number musk it */ const isCreditCardNumber = (number) => { let amex = new RegExp("^3[47][0-9]{13}$"); let visa = new RegExp("^4[0-9]{12}(?:[0-9]{3})?$"); let cup1 = new RegExp("^62[0-9]{14}[0-9]*$"); let cup2 = new RegExp("^81[0-9]{14}[0-9]*$"); let mastercard = new RegExp("^5[1-5][0-9]{14}$"); let mastercard2 = new RegExp("^2[2-7][0-9]{14}$"); let disco1 = new RegExp("^6011[0-9]{12}[0-9]*$"); let disco2 = new RegExp("^62[24568][0-9]{13}[0-9]*$"); let disco3 = new RegExp("^6[45][0-9]{14}[0-9]*$"); let diners = new RegExp("^3[0689][0-9]{12}[0-9]*$"); let jcb = new RegExp("^35[0-9]{14}[0-9]*$"); //check visa if (visa.test(number)) { return true; } //check american express if (amex.test(number)) { return true; } //check master if (mastercard.test(number) || mastercard2.test(number)) { return true; } //check discover if (disco1.test(number) || disco2.test(number) || disco3.test(number)) { return true; } //check diners club if (diners.test(number)) { return true; } //check jcb if (jcb.test(number)) { return true; } //check cup if (cup1.test(number) || cup2.test(number)) { return true; } return false; }; /* Events array to be used by heatmaps and session recordings */ let events = []; let eventChildrenEvents = []; let device_type = "desktop"; let heatmap_id = null; /** * Get accurate timestamp based on server time and elapsed time since page load */ const getAccurateTimestamp = () => { const timeSincePageLoad = performance.now() - pageLoadTime; const serverDate = new Date(serverTime); const accurateDate = new Date(serverDate.getTime() + timeSincePageLoad); return accurateDate.toISOString(); }; /** * length of replay in seconds */ let replay_time_length = 0; /** * max lenght time for session */ const max_session_time = 10 * 60 * 1000; // send replay event every secend const REPLAY_EVENTS_DELAY = 1000; const minimum_time_visitor_activity = 10 * 60 * 1000; /* Sending data via ES6 Fetch */ let send_events = (data) => { if (!('url' in data)) { data["url"] = window.location.href.replace(/\/$/g, ""); } socket.emit(data.type, data, () => { }); }; /** * get current page heatmap id */ const get_heatmap_id = () => { /* Initiate heatmaps tracking if needed */ if (tracker_heatmaps.length) { const current_domain = get_current_url_domain_no_www(); /* Iterate on all heatmaps and initiate them if needed */ for (let heatmap of tracker_heatmaps) { let heatmap_url = document.location.host + heatmap.path.replace(/\/$/g, ""); /* Check if heatmap url matches the current url */ if ( heatmap_url == current_domain || heatmap_url == "www." + current_domain ) { /* If needed, snapshot the page and send the data */ return heatmap["id"] || null; } } } return null; }; /** * get current page heatmap id */ const haveSnapshot = () => { /* Initiate heatmaps tracking if needed */ if (tracker_heatmaps.length) { const current_domain = get_current_url_domain_no_www(); const device_type = get_device_type(); /* Iterate on all heatmaps and initiate them if needed */ for (let heatmap of tracker_heatmaps) { let heatmap_url = document.location.host + heatmap.path.replace(/\/$/g, ""); /* Check if heatmap url matches the current url */ if ( heatmap_url == current_domain || heatmap_url == "www." + current_domain ) { /* Check if snapshot exists for current device type */ if (heatmap.snapshots.length > 0) { for (let snapshot of heatmap.snapshots) { if (snapshot.type === device_type) { return true; } } } /* If no snapshot exists for current device type, allow creating one */ return true; } } } return false; }; /** * Get CSS selector for an element */ const getElementSelector = (element) => { if (!element || !element.tagName) return ''; let path = []; while (element && element.nodeType === Node.ELEMENT_NODE) { let selector = element.nodeName.toLowerCase(); if (element.id) { selector += '#' + element.id; path.unshift(selector); break; } else { let sibling = element; let nth = 1; while (sibling = sibling.previousElementSibling) { if (sibling.nodeName.toLowerCase() === selector) nth++; } if (nth !== 1) selector += ":nth-of-type("+nth+")"; } path.unshift(selector); element = element.parentNode; } return path.join('>'); }; /* Visitor class */ class TrackerCodeVisitor { /* Create and initiate the class with the proper parameters */ async initiate() { /* Check if we already have the visitor id */ if ( localStorage.getItem(get_dynamic_var("visitor_uuid")) && localStorage.getItem(get_dynamic_var("visitor_uuid")).trim() != "" ) { this.visitor_uuid = localStorage .getItem(get_dynamic_var("visitor_uuid")) .trim(); let custom_parameters = this.get_custom_parameters(); if (this.get_ignore_dnt()) { isInitVisitorEnable = false; isReplayEnable = false; isPageviewEnable = false; isEventChildrenEnable = false; isHeatmapEnable = false; isGoalEnable = false; isCustomGoalEnable = false; } /* If custom parameters are set after the initiation of the visitor, update the visitor with the new parameters */ if ( custom_parameters && (!localStorage.getItem(get_dynamic_var("visitor_custom_parameters")) || (localStorage.getItem(get_dynamic_var("visitor_custom_parameters")) && localStorage.getItem( get_dynamic_var("visitor_custom_parameters") ) != btoa(JSON.stringify(custom_parameters)))) ) { /* Generate the details for the visitor */ let details = this.get_extra_details(); if (isInitVisitorEnable) { /* Send the details */ send_events({ visitor_uuid: this.visitor_uuid, type: "initiate_visitor", data: details, }); } } } else { /* Generate it randomly */ let visitor_uuid = get_random_id(); this.visitor_uuid = visitor_uuid; /* Save it to localstorage */ localStorage.setItem(get_dynamic_var("visitor_uuid"), this.visitor_uuid); /* Generate the details for the visitor */ let details = this.get_extra_details(); if (isInitVisitorEnable) { /* Send the details */ send_events({ visitor_uuid, type: "initiate_visitor", data: details, }); } } } get_extra_details() { let data = { resolution: { width: window.screen.width, height: window.screen.height, }, /* Extra detection based on the browser is made directly on the server side */ }; let custom_parameters = this.get_custom_parameters(); if (custom_parameters) { data.custom_parameters = custom_parameters; /* Save it to localstorage */ localStorage.setItem( get_dynamic_var("visitor_custom_parameters"), btoa(JSON.stringify(custom_parameters)) ); } return data; } get_custom_parameters() { /* Check for extra parameters */ let this_script = document.querySelector( `script[src$="tracker/${tracker_key}"]` ); if (this_script.dataset.customParameters) { try { let custom_parameters = JSON.parse( this_script.dataset.customParameters ); return custom_parameters; } catch (error) { return false; } } else { return false; } } get_ignore_dnt() { /* Check for extra parameters */ let this_script = document.querySelector( `script[src$="tracker/${tracker_key}"]` ); if (this_script.dataset.ignoreDnt) { if (navigator.doNotTrack) { return true; } return false; } return false; } } /* Session class */ class TrackerCodeEvents { /* Create and initiate the class with the proper parameters */ async initiate() { this.visitor_uuid = localStorage.getItem(get_dynamic_var("visitor_uuid")); this.visitor_session_uuid = localStorage.getItem( get_dynamic_var("visitor_session_uuid") ); // Make instance globally accessible for React Router integration window.trackerCodeEvent = this; // detect user device type device_type = get_device_type(); /* Store UUID of the last event for page loads */ localStorage.setItem( get_dynamic_var("visitor_session_event_uuid"), get_random_id() ); this.visitor_session_event_uuid = localStorage.getItem( get_dynamic_var("visitor_session_event_uuid") ); /* Get the session date if existing to detect the current session */ let visitor_session_date = localStorage.getItem( get_dynamic_var("visitor_session_date") ); let date = new Date(); /* Check if the current page is the first for this session */ if ( !visitor_session_date || (visitor_session_date && date - new Date(visitor_session_date) > max_session_time) ) { /* Generate the session uuid */ this.visitor_session_uuid = get_random_id(); localStorage.setItem( get_dynamic_var("visitor_session_uuid"), this.visitor_session_uuid ); /* Emit the landing page event */ await this.event_landing_page(); } else { /* Emit the pageview event */ await this.event_pageview(); } /* Set the new session date */ localStorage.setItem( get_dynamic_var("visitor_session_date"), date.toJSON() ); /* Expose function to window */ window[tracker_exposed_identifier] = { goal: async (key) => { await this.event_goal_conversion(key); }, identify: async (object) => { let this_script = document.querySelector( `script[src$="tracker/${tracker_key}"]` ); if (this_script != null) { this_script.setAttribute( "data-custom-parameters", JSON.stringify(object) ); await this.event_identify_update(object); } }, }; /* Initiate event handlers */ if (isEventChildrenEnable) { this.initiate_event_handlers(); } onRouteChange(() => { checkAndTrackGoals(); }); //send online event send_events({ type: "online", visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, visited_at: getAccurateTimestamp() }); await checkAndTrackGoals(); // send session replay events const send_sessions_replays = async () => { replay_time_length++; if (events.length > 50) { send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: "replays", data: events, replay_time_length, visited_at: getAccurateTimestamp() }); if (eventChildrenEvents.length > 0) { eventChildrenEvents.forEach(ev => { send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: ev.type, data: ev.data, count: ev.count, device_type: ev.device_type, heatmap_id: ev.heatmap_id, visited_at: ev.visited_at, url: ev.url }); }); eventChildrenEvents = []; } replay_time_length = 0; events = []; } }; // send snapshot const send_snapshot = async (snapshot) => { // if heatmap and replay is disabled if (!isReplayEnable && !isHeatmapEnable) return; if (haveSnapshot()) { heatmap_id = get_heatmap_id(); } send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: "snapshot", data: snapshot, heatmap_id, device_type, visited_at: getAccurateTimestamp() }); }; /** * start replay recording */ const startReplayRecording = () => { const mousemove = is_mouse_movement_enabled ? true : false; rrwebRecord({ /* Convert all text inputs to *** for privacy reasons */ maskAllInputs: true, /* Try to preserve external CSS links, fallback to inline if needed */ inlineStylesheet: false, stylesheetLoadTimeout: 5000, // 5 second timeout for CSS loading onStylesheetLoad: (linkElement, stylesheet) => { if (!stylesheet) { console.warn('CSS file could not be loaded, will be inlined:', linkElement.href); // If CSS fails to load, we'll let rrweb inline it as fallback return false; // This will trigger inline fallback } return true; // Keep external link }, /* Remove unnecessary parts of the page */ slimDOMOptions: { comment: true, headFavicon: true, headWhitespace: true, headMetaDescKeywords: true, headMetaSocial: true, headMetaRobots: true, headMetaHttpEquiv: true, headMetaAuthorship: true, headMetaVerification: true, }, plugins: [ rrwebConsoleRecord.getRecordConsolePlugin({ level: ["warn", "error"], lengthThreshold: 10000, stringifyOptions: { stringLengthLimit: 1000, numOfKeysLimit: 100, depthOfLimit: 1, }, logger: window.console, }), ], emit: (event, isCheckout) => { if (isCheckout) { events = []; // check session let visitor_session_date = localStorage.getItem( get_dynamic_var("visitor_session_date") ); let date = new Date(); if ( !visitor_session_date || (visitor_session_date && date - new Date(visitor_session_date) > max_session_time) ) { this.visitor_session_uuid = get_random_id(); localStorage.setItem( get_dynamic_var("visitor_session_uuid"), this.visitor_session_uuid ); /* Set the new session date */ localStorage.setItem( get_dynamic_var("visitor_session_date"), date.toJSON() ); } } events.push(event); /* Send the snapshot data */ if ( events.length == 2 && events[0].type == 4 && events[1].type == 2 ) { /* Send the caught snapshot */ send_snapshot(events); events = []; } /* if user not need to track session replay */ if (!isReplayEnable) return; //Mask credit card number if ("source" in event.data && event.data.source === 5) { if (isCreditCardNumber(event.data.text)) { event.data.text = "*".repeat(event.data.text.length); } } if (event.type == 6) { //tag console errors on replay if (event.data.payload.level == "error") { rrwebRecord.addCustomEvent("console-error"); } } }, sampling: { scroll: 150, media: 800, input: "last", maskAllInputs: false, maskInputOptions: { password: true }, mousemove, }, checkoutEveryNms: 5 * 60 * 1000, }); }; /** check if user is not active every 10 minits*/ const visitor_activity_interval = setInterval(() => { const last_time = localStorage.getItem( get_dynamic_var("last_visitor_active_time") ); const current_time = new Date(); if (!last_time) { this.update_last_visitor_activity(); return; } const last_activity = new Date(last_time); const diff = current_time.getTime() - last_activity.getTime(); if (diff > minimum_time_visitor_activity) { clearInterval(visitor_activity_interval); console.log('Socket disconnected due to user inactivity at:', new Date().toLocaleString()); socket.disconnect(); } }, 60 * 1000); /* Session replay tracking */ if (isReplayEnable || haveSnapshot()) { /* Make sure the page is fully loaded before initiating */ const checkInterval = setInterval(() => { if (document.readyState === "complete") { startReplayRecording(); if (isReplayEnable) { const replayInterval = setInterval(send_sessions_replays, 1000); // Add socket disconnect handler socket.on('disconnect', () => { console.log('Socket disconnected, resetting connection'); replay_time_length = 0; clearInterval(replayInterval); }); } clearInterval(checkInterval); } }, 1000); } } initiate_event_handlers() { this.initiate_event_handler_click(); this.initiate_event_handler_scroll(); this.initiate_event_handler_forms(); this.initiate_event_handler_resize(); this.initiate_event_handler_input_focus(); } /* Mouse click event handler */ initiate_event_handler_click() { /* Last click data for comparison */ let last_click_time = 0; let last_click_position = { x: 0, y: 0 }; let rage_click_threshold = 3; let rage_click_time_window = 1000; let rage_click_distance = 50; let clicks_count = 1; let click_positions = []; let timer = false; document.addEventListener("click", (event) => { this.update_last_visitor_activity(); if (!event.isTrusted) { return false; } const current_time = Date.now(); const current_position = { x: event.pageX, y: event.pageY }; const distance = Math.sqrt( Math.pow(current_position.x - last_click_position.x, 2) + Math.pow(current_position.y - last_click_position.y, 2) ); const time_since_last_click = current_time - last_click_time; click_positions.push({ position: current_position, timestamp: current_time }); click_positions = click_positions.filter(click => current_time - click.timestamp < rage_click_time_window ); const nearby_clicks = click_positions.filter(click => { const posDistance = Math.sqrt( Math.pow(click.position.x - current_position.x, 2) + Math.pow(click.position.y - current_position.y, 2) ); return posDistance < rage_click_distance; }); clicks_count = nearby_clicks.length; const is_rage_click = time_since_last_click < rage_click_time_window && distance < rage_click_distance && clicks_count >= rage_click_threshold; let timeout = event.target.tagName == "A" && !event.target.getAttribute("href")?.startsWith("#") ? 0 : 500; let text = event?.target?.innerText?.length > 61 ? `${event.target.innerText?.substr(0, 61)}...` : event.target.innerText; const viewport = this.get_viewport(); let data = { mouse: { x: event.pageX, y: event.pageY, }, text: text, element: event?.target?.tagName?.toLowerCase(), html_element: getElementSelector(event.target), viewport, time_since_last_click, distance_from_last_click: distance }; last_click_time = current_time; last_click_position = current_position; timer = setTimeout(() => { if (is_rage_click) { this.event_child("rage_click", { ...data, clicks_count, rage_click_duration: time_since_last_click, rage_click_area: { center: current_position, radius: rage_click_distance } }, 1); click_positions = []; } else { this.event_child("click", data, clicks_count); } }, timeout); }); } /* Scroll event handler */ initiate_event_handler_scroll() { let timer = false; document.addEventListener("scroll", (event) => { this.update_last_visitor_activity(); if (!event.isTrusted) { return false; } let data = { scroll: { percentage: parseInt( ((document.documentElement["scrollTop"] || document.body["scrollTop"]) / ((document.documentElement["scrollHeight"] || document.body["scrollHeight"]) - document.documentElement.clientHeight)) * 100 ), }, html_element: getElementSelector(document.documentElement) }; clearInterval(timer); timer = setTimeout(() => { this.event_child("scroll", data, 1); }, 500); }); } /* Inputs event handler */ initiate_event_handler_forms() { let event_handler_form = (event) => { let data = { form: {}, html_element: getElementSelector(event.target) }; let form_element = event.target; form_element.querySelectorAll('input').forEach(input_element => { if(input_element.type == 'password' || input_element.type == 'hidden') { return; } if(input_element.name.indexOf('captcha') !== -1) { return; } data.form[input_element.name] = input_element.value; }); this.update_last_visitor_activity(); this.event_child("form", data); }; document.querySelectorAll("form").forEach((form_element) => { form_element.addEventListener("submit", event_handler_form); }); } /* Window resize event handler */ initiate_event_handler_resize() { let timer = false; window.addEventListener("resize", (event) => { this.update_last_visitor_activity(); if (!event.isTrusted) { return false; } let data = { viewport: this.get_viewport(), html_element: getElementSelector(document.documentElement) }; clearInterval(timer); timer = setTimeout(() => { this.event_child("resize", data); }, 500); }); } /* Input focus event handler */ initiate_event_handler_input_focus() { document.addEventListener("focus", (event) => { this.update_last_visitor_activity(); if (!event.isTrusted) { return false; } // Only track focus events on input elements if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') { return false; } let data = { form: { [event.target.name]: { type: event.target.type, placeholder: event.target.placeholder, required: event.target.required, disabled: event.target.disabled, readonly: event.target.readOnly, value: event.target.value } }, html_element: getElementSelector(event.target) }; this.event_child("input_focus", data); }, true); } async event_landing_page() { if (!isPageviewEnable) return; let data = { path: window.location.pathname, title: document.title, referrer: document.referrer.includes( `${location.protocol}//${location.host}${location.pathname}` ) ? null : document.referrer, utm: this.get_utm_params(), viewport: this.get_viewport(), }; send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: "landing_page", data, visited_at: getAccurateTimestamp() }); } async event_pageview() { if (!isPageviewEnable) return; let data = { path: window.location.pathname, title: document.title, referrer: document.referrer.includes( `${location.protocol}//${location.host}${location.pathname}` ) ? null : document.referrer, viewport: this.get_viewport(), }; send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: "pageview", data, visited_at: getAccurateTimestamp() }); } /** * update user last activity */ update_last_visitor_activity() { localStorage.setItem( get_dynamic_var("last_visitor_active_time"), new Date() ); } event_child(type, data = {}, count = 1) { if (!isEventChildrenEnable) return; const heatmap_id = get_heatmap_id(); const timestamp = getAccurateTimestamp(); const url = window.location.href.replace(/\/$/g, ""); // Add timestamp to the event data const eventData = { ...data, timestamp }; if (Array.isArray(eventChildrenEvents)) { eventChildrenEvents.push({ type, data: eventData, count, device_type, heatmap_id, visited_at: timestamp, url }); } } // update visitor custom parameters async event_identify_update(custom_parameters) { if (!isInitVisitorEnable) return; /* Save it to localstorage */ localStorage.setItem( get_dynamic_var("visitor_custom_parameters"), btoa(JSON.stringify(custom_parameters)) ); send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, type: "identify", custom_parameters, visited_at: getAccurateTimestamp() }); } async event_goal_conversion(key) { if (!isGoalEnable) return; /* Iterate on all goals and initiate them if needed */ for (let goal of tracker_goals) { /* Check if goal url matches the current url */ if ( goal.key == key && !localStorage.getItem(get_dynamic_var(`visitor_goal_${goal.key}`)) ) { /* Send the goal completion */ send_events({ visitor_uuid: this.visitor_uuid, visitor_session_uuid: this.visitor_session_uuid, visitor_session_event_uuid: this.visitor_session_event_uuid, goal_id: goal.id, type: "goal_conversion", goal_key: goal.key, goal_name: goal.name, goal_type: goal.type, visited_at: getAccurateTimestamp() }); /* Set it in the local storage to make sure to not send it again */ localStorage.setItem(get_dynamic_var(`visitor_goal_${goal.key}`), true); break; } } } get_viewport() { return { width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight, }; } get_utm_params() { let url_params = new URLSearchParams(window.location.search); return { source: url_params.get("utm_source"), medium: url_params.get("utm_medium"), campaign: url_params.get("utm_campaign"), term: url_params.get("utm_term"), content: url_params.get("utm_content"), }; } } async function checkAndTrackGoals() { if (tracker_goals.length) { let current_domain = get_current_url_domain_no_www(); for (let goal of tracker_goals) { if (goal.type !== "page_view") continue; const goal_url = document.location.host + goal.path.replace(/\/$/g, ""); if ( (goal_url == current_domain || goal_url == "www." + current_domain) && !localStorage.getItem(get_dynamic_var(`visitor_goal_${goal.key}`)) ) { await window.trackerCodeEvent.event_goal_conversion(goal.key); } } } } function onRouteChange(callback) { let lastUrl = location.href; const wrapHistoryMethod = (type) => { const orig = history[type]; return function() { const rv = orig.apply(this, arguments); const newUrl = location.href; if (newUrl !== lastUrl) { lastUrl = newUrl; callback(); } return rv; }; }; history.pushState = wrapHistoryMethod('pushState'); history.replaceState = wrapHistoryMethod('replaceState'); window.addEventListener('popstate', () => { const newUrl = location.href; if (newUrl !== lastUrl) { lastUrl = newUrl; callback(); } }); const observer = new MutationObserver(() => { const newUrl = location.href; if (newUrl !== lastUrl) { lastUrl = newUrl; callback(); } }); observer.observe(document, { subtree: true, childList: true }); callback(); } /* Start function */ let aitrackercodestart = async () => { tracker_verify(); let this_script = document.querySelector(`script[src$="tracker/${tracker_key}"]`); /* Check for DNT */ let is_dnt = is_do_not_track(); /* Check for manual opt out */ let optout = is_optout(); /* Check if we should supress the DNT or not */ let should_track = !optout && (!is_dnt || (is_dnt && this_script.dataset.ignoreDnt)); if (should_track) { /* Initiate the Visitor */ let trackerCodeVisitor = new TrackerCodeVisitor(); await trackerCodeVisitor.initiate(); /* Initiate the Events */ let trackerCodeEvent = new TrackerCodeEvents(); await trackerCodeEvent.initiate(); } else { if (is_dnt) { console.log(`${tracker_url_base}: ${tracker_key_dnt_message}`); } if (optout) { console.log(`${tracker_url_base}: ${tracker_key_optout_message}`); } } }; let aitrackercodeprestart = () => { let history = window.history; let pushState = history.pushState; let replaceState = history.replaceState; if(history.pushState) { // Override pushState history.pushState = function() { pushState.apply(this, arguments); // Send pageview event when route changes if (window.trackerCodeEvent) { window.trackerCodeEvent.event_pageview(); } }; // Override replaceState history.replaceState = function() { replaceState.apply(this, arguments); // Send pageview event when route changes if (window.trackerCodeEvent) { window.trackerCodeEvent.event_pageview(); } }; // Handle browser back/forward window.addEventListener('popstate', () => { if (window.trackerCodeEvent) { window.trackerCodeEvent.event_pageview(); } }); } socket = io(socketUrl, { query: `tracker_key=${tracker_key}` /*remove end backslash*/, timeout: 5000, connect_timeout: 5000, }); socket.on("connect", () => { aitrackercodestart(); }); socket.on("refresh_visitor", async () => { localStorage.removeItem(get_dynamic_var("visitor_uuid")); /* reInitiate the Visitor */ let trackerCodeVisitor = new TrackerCodeVisitor(); await trackerCodeVisitor.initiate(); }); socket.on("refresh_session", async () => { localStorage.removeItem(get_dynamic_var("visitor_session_uuid")); localStorage.removeItem(get_dynamic_var("visitor_session_date")); /* reInitiate the Events */ let trackerCodeEvent = new TrackerCodeEvents(); await trackerCodeEvent.initiate(); }); }; if (tracker_included_path.length) { if (checkIncludeExcludePath(tracker_included_path)) { aitrackercodeprestart(); } } else if (tracker_excluded_path.length) { if (!checkIncludeExcludePath(tracker_excluded_path)) { aitrackercodeprestart(); } } else { aitrackercodeprestart(); } })();