@highlight-run/rrweb 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rrweb.min.js CHANGED
@@ -26,5 +26,5 @@ var rrweb=function(e){"use strict";
26
26
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
27
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
28
  PERFORMANCE OF THIS SOFTWARE.
29
- ***************************************************************************** */function nt(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(et||(et={}));var ot={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function at(e){return{type:"xstate.assign",assignment:e}}function st(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function lt(e){return function(t){return e===t}}function ct(e){return"string"==typeof e?{type:e}:e}function ut(e,t){return{value:e,context:t,actions:[],changed:!1,matches:lt(e)}}function dt(e,t,r){var n=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},n);return"function"==typeof e.assignment?t=e.assignment(n,r):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](n,r):e.assignment[o]})),n=t,!1}return!0})),n,o]}function pt(e,t){void 0===t&&(t={});var r=nt(dt(it(e.states[e.initial].entry).map((function(e){return st(e,t.actions)})),e.context,ot),2),n=r[0],o=r[1],i={config:e,_options:t,initialState:{value:e.initial,actions:n,context:o,matches:lt(e.initial)},transition:function(t,r){var n,o,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=ct(r),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.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(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),f=p.next();!f.done;f=p.next()){var h=f.value;if(void 0===h)return ut(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,b=m.cond,S=void 0===v;if((void 0===b?function(){return!0}:b)(l,c)){var T=e.states[null!=v?v:s],x=nt(dt((S?it(g):[].concat(u.exit,g,T.entry).filter((function(e){return e}))).map((function(e){return st(e,i._options.actions)})),l,c),3),w=x[0],E=x[1],I=x[2],C=null!=v?v:s;return{value:C,context:E,actions:w,changed:v!==s||w.length>0||I,matches:lt(C)}}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(n)throw n.error}}}return ut(s,l)}};return i}var ft=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function ht(e){var t=e.initialState,r=et.NotStarted,n=new Set,o={_machine:e,send:function(o){r===et.Running&&(t=e.transition(t,o),ft(t,ct(o)),n.forEach((function(e){return e(t)})))},subscribe:function(e){return n.add(e),e(t),{unsubscribe:function(){return n.delete(e)}}},start:function(n){if(n){var i="object"==typeof n?n:{context:e.config.context,value:n};t={value:i.value,actions:[],context:i.context,matches:lt(i.value)}}return r=et.Running,ft(t,ot),o},stop:function(){return r=et.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}function mt(t,r){var n=r.getCastFn,o=r.applyEventsSynchronously,i=r.emitter;return ht(pt({id:"player",context:t,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:at({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:at((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),s(s({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(t){var r,a,s,c,u,d=t.timer,p=t.events,f=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=l(p),v=m.next();!v.done;v=m.next()){rt(v.value,f)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(a=m.return)&&a.call(m)}finally{if(r)throw r.error}}var y=function(t,r){for(var n=t.length-1;n>=0;n--){var o=t[n];if(o.type===e.EventType.Meta&&o.timestamp<=r)return t.slice(n)}return t}(p,f),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),f<(g||0)&&i.emit(e.ReplayerEvents.PlayBack);var b=new Array,S=new Array,T=function(e){if(g&&g<f&&(e.timestamp<=g||e===h))return"continue";if(e.timestamp<f)b.push(e);else{var t=n(e,!1);S.push({doAction:function(){t()},delay:e.delay})}};try{for(var x=l(y),w=x.next();!w.done;w=x.next()){T(w.value)}}catch(e){s={error:e}}finally{try{w&&!w.done&&(c=x.return)&&c.call(x)}finally{if(s)throw s.error}}o(b),i.emit(e.ReplayerEvents.Flush),d.addActions(S),d.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:at((function(e){return s(s({},e),{lastPlayedEvent:null})})),startLive:at({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),replaceEvents:at((function(e,t){var r,o,i=e.events,a=e.timer,c=e.baselineTime;if("REPLACE_EVENTS"===t.type){var u=t.payload.events;i.length=0;var d=[],p=function(e){if(rt(e,c),i.push(e),e.timestamp>=a.timeOffset+c){var t=n(e,!1);d.push({doAction:function(){t()},delay:e.delay})}};try{for(var f=l(u),h=f.next();!h.done;h=f.next()){p(h.value)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}a.isActive()&&a.replaceActions(d)}return s(s({},e),{events:i})})),addEvent:at((function(e,t){var r=e.baselineTime,o=e.timer,i=e.events;if("ADD_EVENT"===t.type){var a=t.payload.event;rt(a,r);var l=i.length-1;if(!i[l]||i[l].timestamp<=a.timestamp)i.push(a);else{for(var c=-1,u=0;u<=l;){var d=Math.floor((u+l)/2);i[d].timestamp<=a.timestamp?u=d+1:l=d-1}-1===c&&(c=u),i.splice(c,0,a)}var p=a.timestamp<r,f=n(a,p);p?f():o.isActive()&&o.addAction({doAction:function(){f()},delay:a.delay})}return s(s({},e),{events:i})}))}}))}var vt;function yt(e,t){var r=e[t[0]];return 1===t.length?r:yt(r.cssRules[t[1]].cssRules,t.slice(2))}function gt(e){var t=u(e),r=t.pop();return{positions:t,index:r}}function bt(e,t){var r=t.sheet;r&&e.forEach((function(e){if(e.type===vt.Insert)try{if(Array.isArray(e.index)){var n=gt(e.index),o=n.positions,i=n.index;yt(r.cssRules,o).insertRule(e.cssText,i)}else r.insertRule(e.cssText,e.index)}catch(e){}else if(e.type===vt.Remove)try{if(Array.isArray(e.index)){var a=gt(e.index);o=a.positions,i=a.index;yt(r.cssRules,o).deleteRule(i||0)}else r.deleteRule(e.index)}catch(e){}else if(e.type===vt.Snapshot)!function(e,t){var r;try{var n=Array.from((null===(r=t.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText})),o=Object.entries(n).reverse(),i=n.length;o.forEach((function(r){var n,o=c(r,2),a=o[0],s=o[1],l=e.indexOf(s);if(-1===l||l>i)try{null===(n=t.sheet)||void 0===n||n.deleteRule(Number(a))}catch(e){}i=l})),e.forEach((function(e,r){var n,o,i;try{(null===(o=null===(n=t.sheet)||void 0===n?void 0:n.cssRules[r])||void 0===o?void 0:o.cssText)!==e&&(null===(i=t.sheet)||void 0===i||i.insertRule(e,r))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===vt.SetProperty){yt(r.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===vt.RemoveProperty){yt(r.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(vt||(vt={}));var St=new Map;function Tt(e,t){var r=St.get(e);return r||(r=new Map,St.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var xt=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function wt(e,t){return function(r){if(r&&"object"==typeof r&&"rr_type"in r){if("index"in r){var n=r.rr_type,o=r.index;return Tt(t,n)[o]}if("args"in r){var i=r.rr_type,a=r.args,s=window[i];return new(s.bind.apply(s,u([void 0],a.map(wt(e,t)))))}if("base64"in r)return function(e){var t,r,n,o,i,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)r=Pe[e.charCodeAt(t)],n=Pe[e.charCodeAt(t+1)],o=Pe[e.charCodeAt(t+2)],i=Pe[e.charCodeAt(t+3)],u[l++]=r<<2|n>>4,u[l++]=(15&n)<<4|o>>2,u[l++]=(3&o)<<6|63&i;return c}(r.base64);if("src"in r){var l=e.get(r.src);if(l)return l;var c=new Image;return c.src=r.src,e.set(r.src,c),c}}else if(Array.isArray(r))return r.map(wt(e,t));return r}}function Et(e){var t=e.mutation,r=e.target,n=e.type,i=e.imageMap,a=e.errorHandler;try{var s=function(e,t){try{return t===o.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(r,n);if(!s)return;if(t.setter)return void(s[t.property]=t.args[0]);var l=s[t.property],c=t.args.map(wt(i,s));!function(e,t){if(null==t?void 0:t.constructor){var r=t.constructor.name;if(xt.includes(r)){var n=Tt(e,r);n.includes(t)||n.push(t)}}}(s,l.apply(s,c))}catch(e){a(t,e)}}var It=Ke||Je,Ct={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function kt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Mt=function(){function t(t,r){var n=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=It(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=le(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,r=e.__sn&&e.__sn.id;delete this.map[r],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==r?void 0:r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var o={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:Ct,inactiveThreshold:.02,inactiveSkipTime:2e3};this.config=Object.assign({},o,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new I,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,r,o,i,a,s=n.treeIndex.flush(),c=s.scrollMap,u=s.inputMap;n.fragmentParentMap.forEach((function(e,t){return n.restoreRealParent(t,e)}));try{for(var d=l(n.virtualStyleRulesMap.keys()),p=d.next();!p.done;p=d.next()){var f=p.value;n.restoreNodeSheet(f)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}n.fragmentParentMap.clear(),n.elementStateMap.clear(),n.virtualStyleRulesMap.clear();try{for(var h=l(c.values()),m=h.next();!m.done;m=h.next()){var v=m.value;n.applyScroll(v,!0)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var y=l(u.values()),g=y.next();!g.done;g=y.next()){v=g.value;n.applyInput(v)}}catch(e){i={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(i)throw i.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){n.firstFullSnapshot=null,n.mirror.reset()}));var i=new tt([],(null==r?void 0:r.speed)||o.speed);this.service=mt({events:t.map((function(e){return r&&r.unpackFn?r.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){n.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=ht(pt({id:"speed",context:{normalSpeed:-1,timer:i},initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:at({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){n.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var a=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),s=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(a){var c=a.data,u=c.width,d=c.height;setTimeout((function(){n.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}s&&setTimeout((function(){n.firstFullSnapshot||(n.firstFullSnapshot=s,n.rebuildFullSnapshot(s),n.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1),this.service.state.context.events.find(kt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(t.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),t.prototype.on=function(e,t){return this.emitter.on(e,t),this},t.prototype.off=function(e,t){return this.emitter.off(e,t),this},t.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(r){t.config[r]=e[r]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))},t.prototype.getActivityIntervals=function(){var e=this;if(0==this.activityIntervals.length){for(var t=[],r=this.getMetaData(),n=u([{timestamp:r.startTime}],this.service.state.context.events.filter((function(t){return e.isUserInteraction(t)})),[{timestamp:r.endTime}]),o=1;o<n.length;o++){var i=n[o-1],a=n[o];a.timestamp-i.timestamp>1e4?t.push({startTime:i.timestamp,endTime:a.timestamp,duration:a.timestamp-i.timestamp,active:!1}):t.push({startTime:i.timestamp,endTime:a.timestamp,duration:a.timestamp-i.timestamp,active:!0})}var s=[],l=t[0];for(o=1;o<t.length;o++)t[o].active!=t[o-1].active&&(s.push({startTime:l.startTime,endTime:t[o-1].endTime,duration:t[o-1].endTime-l.startTime,active:t[o-1].active}),l=t[o]);l&&t.length>0&&s.push({startTime:l.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-l.startTime,active:t[t.length-1].active}),l=s[0];for(o=1;o<s.length;o++)(!s[o].active&&s[o].duration>this.config.inactiveThreshold*r.totalTime||!s[o-1].active&&s[o-1].duration>this.config.inactiveThreshold*r.totalTime)&&(this.activityIntervals.push({startTime:l.startTime,endTime:s[o-1].endTime,duration:s[o-1].endTime-l.startTime,active:s[o-1].active}),l=s[o]);l&&s.length>0&&this.activityIntervals.push({startTime:l.startTime,endTime:s[s.length-1].endTime,duration:s[s.length-1].endTime-l.startTime,active:s[s.length-1].active})}return this.activityIntervals},t.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},t.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},t.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},t.prototype.getMirror=function(){return this.mirror},t.prototype.play=function(t){var r;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)},t.prototype.pause=function(t){var r;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},t.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},t.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},t.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;kt(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},t.prototype.replaceEvents=function(e){var t,r;try{for(var n=l(e),o=n.next();!o.done;o=n.next()){if(kt(o.value)){this.mouse.classList.add("touch-device");break}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.service.send({type:"REPLACE_EVENTS",payload:{events:e}})},t.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},t.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},t.prototype.resetCache=function(){this.cache=le()},t.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),!1!==this.config.mouseTail&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Ze(this.iframe.contentWindow,this.iframe.contentDocument),E(this.iframe.contentWindow))},t.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var n=l([this.mouseTail,this.iframe]),o=n.next();!o.done;o=n.next()){var i=o.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},t.prototype.applyEventsSynchronously=function(t){var r,n;try{for(var o=l(t),i=o.next();!i.done;i=o.next()){var a=i.value;switch(a.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(a.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(a,!0)()}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},t.prototype.getCastFn=function(t,r){var n,o=this;switch(void 0===r&&(r=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:n=function(){o.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:n=function(){return o.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:n=function(){if(o.firstFullSnapshot){if(o.firstFullSnapshot===t)return void(o.firstFullSnapshot=!0)}else o.firstFullSnapshot=!0;o.rebuildFullSnapshot(t,r),o.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:n=function(){var n,i;if(o.applyIncremental(t,r),!r&&(o.handleInactivity(t.timestamp),t===o.nextUserInteractionEvent&&(o.nextUserInteractionEvent=null,o.backToNormal()),o.config.skipInactive&&!o.nextUserInteractionEvent)){try{for(var a=l(o.service.state.context.events),s=a.next();!s.done;s=a.next()){var c=s.value;if(!(c.timestamp<=t.timestamp)&&o.isUserInteraction(c)){c.delay-t.delay>1e4*o.speedService.state.context.timer.speed&&(o.nextUserInteractionEvent=c);break}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}if(o.nextUserInteractionEvent){var u=o.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/2e3),o.config.maxSpeed)};o.speedService.send({type:"FAST_FORWARD",payload:d}),o.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,a;n&&n();try{for(var s=l(o.config.plugins||[]),c=s.next();!c.done;c=s.next()){c.value.handler(t,r,{replayer:o})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}o.service.send({type:"CAST_EVENT",payload:{event:t}});var u=o.service.state.context.events.length-1;if(t===o.service.state.context.events[u]){var d=function(){u<o.service.state.context.events.length-1||(o.backToNormal(),o.service.send("END"),o.emitter.emit(e.ReplayerEvents.Finish))};t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove&&t.data.positions.length?setTimeout((function(){d()}),Math.max(0,50-t.data.positions[0].timeOffset)):d()}o.emitter.emit(e.ReplayerEvents.EventCast,t)}},t.prototype.handleInactivity=function(t,r){var n,o;if((t===this.inactiveEndTimestamp||r)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){try{for(var i=l(this.getActivityIntervals()),a=i.next();!a.done;a=i.next()){var s=a.value;if(t>=s.startTime&&t<s.endTime&&!s.active){this.inactiveEndTimestamp=s.endTime;break}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}if(this.inactiveEndTimestamp){var c=this.inactiveEndTimestamp-t,u={speed:c/36e5*this.config.inactiveSkipTime<1e3?c/1e3:Math.round(Math.max(c,36e5)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:u}),this.emitter.emit(e.ReplayerEvents.SkipStart,u)}}},t.prototype.rebuildFullSnapshot=function(t,r){var n,o,i=this;if(void 0===r&&(r=!1),!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};var a=[];this.mirror.map=de(t.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)},cache:this.cache})[1];var s=function(e,t){c.attachDocumentToIframe(e,t),c.newDocumentQueue=c.newDocumentQueue.filter((function(t){return t!==e}))},c=this;try{for(var u=l(a),d=u.next();!d.done;d=u.next()){var p=d.value;s(p.mutationInQueue,p.builtNode)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}var f=this.iframe.contentDocument,h=f.documentElement,m=f.head;this.insertStyleRules(h,m),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},t.prototype.insertStyleRules=function(e,t){var r=document.createElement("style");e.insertBefore(r,t);var n,o=(n=this.config.blockClass,["noscript { display: none !important; }","."+n+" { background: currentColor; border-radius: 5px; }","."+n+":hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)r.sheet.insertRule(o[i],i)},t.prototype.attachDocumentToIframe=function(e,t){var r,n,o=this,i=[];if(!t.contentDocument)for(var a=t.parentNode;a;){if(this.fragmentParentMap.has(a)){var s=a,c=this.fragmentParentMap.get(s);this.restoreRealParent(s,c);break}a=a.parentNode}ue(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){if(o.collectIframeAndAttachDocument(i,e),e.__sn.type===O.Element&&"HTML"===e.__sn.tagName.toUpperCase()){var r=t.contentDocument,n=r.documentElement,a=r.head;o.insertStyleRules(n,a)}},cache:this.cache});var u=function(e,t){d.attachDocumentToIframe(e,t),d.newDocumentQueue=d.newDocumentQueue.filter((function(t){return t!==e}))},d=this;try{for(var p=l(i),f=p.next();!f.done;f=p.next()){var h=f.value;u(h.mutationInQueue,h.builtNode)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}},t.prototype.collectIframeAndAttachDocument=function(e,t){if(M(t)){var r=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));r&&e.push({mutationInQueue:r,builtNode:t})}},t.prototype.waitForStylesheetLoad=function(){var t,r=this,n=null===(t=this.iframe.contentDocument)||void 0===t?void 0:t.head;if(n){var o,i=new Set,a=this.service.state,s=function(){a=r.service.state};this.emitter.on(e.ReplayerEvents.Start,s),this.emitter.on(e.ReplayerEvents.Pause,s);var l=function(){r.emitter.off(e.ReplayerEvents.Start,s),r.emitter.off(e.ReplayerEvents.Pause,s)};n.querySelectorAll('link[rel="stylesheet"]').forEach((function(t){t.sheet||(i.add(t),t.addEventListener("load",(function(){i.delete(t),0===i.size&&-1!==o&&(a.matches("playing")&&r.play(r.getCurrentTime()),r.emitter.emit(e.ReplayerEvents.LoadStylesheetEnd),o&&clearTimeout(o),l())})))})),i.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){a.matches("playing")&&r.play(r.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},t.prototype.hasImageArg=function(e){var t,r;try{for(var n=l(e),o=n.next();!o.done;o=n.next()){var i=o.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!1},t.prototype.getImageArgs=function(e){var t,r,n=[];try{for(var o=l(e),i=o.next();!i.done;i=o.next()){var a=i.value;a&&"object"==typeof a&&("rr_type"in a&&"args"in a?n.push.apply(n,u(this.getImageArgs(a.args))):"rr_type"in a&&"HTMLImageElement"===a.rr_type?n.push(a.src):a instanceof Array&&n.push.apply(n,u(this.getImageArgs(a))))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n},t.prototype.preloadAllImages=function(){var t,r,n=this;this.service.state;var o=function(){n.service.state};this.emitter.on(e.ReplayerEvents.Start,o),this.emitter.on(e.ReplayerEvents.Pause,o);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return n.preloadImages(e,t)})):a.preloadImages(t.data,t))},a=this;try{for(var s=l(this.service.state.context.events),c=s.next();!c.done;c=s.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}},t.prototype.preloadImages=function(e,t){var r=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,r.imageMap.set(e,t)}));else{var n=document.createElement("canvas"),o=n.getContext("2d"),i=null==o?void 0:o.createImageData(n.width,n.height);null==i||i.data,JSON.parse(e.args[0]),null==o||o.putImageData(i,0,0)}},t.prototype.applyIncremental=function(t,r){var n,i,a=this,l=t.data;switch(l.source){case e.IncrementalSource.Mutation:r&&(l.adds.forEach((function(e){return a.treeIndex.add(e)})),l.texts.forEach((function(e){return a.treeIndex.text(e)})),l.attributes.forEach((function(e){return a.treeIndex.attribute(e)})),l.removes.forEach((function(e){return a.treeIndex.remove(e,a.mirror)})));try{this.applyMutation(l,r)}catch(e){this.warn("Exception in mutation "+(e.message||e),l)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(r){var c=l.positions[l.positions.length-1];this.mousePos={x:c.x,y:c.y,id:c.id,debugData:l}}else l.positions.forEach((function(e){var n={doAction:function(){a.moveAndHover(e.x,e.y,e.id,r,l)},delay:e.timeOffset+t.timestamp-a.service.state.context.baselineTime};a.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(n=l.positions[0])||void 0===n?void 0:n.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===l.id)break;var u=new Event(e.MouseInteractions[l.type].toLowerCase());if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:l.type,target:T});var d=this.config.triggerFocus;switch(l.type){case e.MouseInteractions.Blur:"blur"in T&&T.blur();break;case e.MouseInteractions.Focus:d&&T.focus&&T.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:r?(l.type===e.MouseInteractions.TouchStart?this.touchActive=!0:l.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:l.x,y:l.y,id:l.id,debugData:l}):(l.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(l.x,l.y,l.id,r,l),l.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):l.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):l.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:T.dispatchEvent(u)}break;case e.IncrementalSource.Scroll:if(-1===l.id)break;if(r){this.treeIndex.scroll(l);break}this.applyScroll(l,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:l.width,height:l.height});break;case e.IncrementalSource.Input:if(-1===l.id)break;if(r){this.treeIndex.input(l);break}this.applyInput(l);break;case e.IncrementalSource.MediaInteraction:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);var p=T;try{l.currentTime&&(p.currentTime=l.currentTime),l.volume&&(p.volume=l.volume),l.muted&&(p.muted=l.muted),1===l.type&&p.pause(),0===l.type&&p.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);var f,h=T,m=T.parentNode,v=this.fragmentParentMap.has(m),y=v?null:h.sheet;y||(this.virtualStyleRulesMap.has(T)?f=this.virtualStyleRulesMap.get(T):(f=[],this.virtualStyleRulesMap.set(T,f))),l.adds&&l.adds.forEach((function(e){var t=e.rule,r=e.index;if(y)try{if(Array.isArray(r)){var n=gt(r),o=n.positions,i=n.index;yt(y.cssRules,o).insertRule(t,i)}else{i=void 0===r?void 0:Math.min(r,y.cssRules.length);y.insertRule(t,i)}}catch(e){}else null==f||f.push({cssText:t,index:r,type:vt.Insert})})),l.removes&&l.removes.forEach((function(e){var t=e.index;if(v)null==f||f.push({index:t,type:vt.Remove});else try{if(Array.isArray(t)){var r=gt(t),n=r.positions,o=r.index;yt(y.cssRules,n).deleteRule(o||0)}else null==y||y.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);h=T;var g=T.parentNode,b=this.fragmentParentMap.has(g)?null:h.sheet,S=[];if(b||(this.virtualStyleRulesMap.has(T)?S=this.virtualStyleRulesMap.get(T):(S=[],this.virtualStyleRulesMap.set(T,S))),l.set)if(b)yt(b.rules,l.index).style.setProperty(l.set.property,l.set.value,l.set.priority);else S.push(s({type:vt.SetProperty,index:l.index},l.set));if(l.remove)if(b)yt(b.rules,l.index).style.removeProperty(l.remove.property);else S.push(s({type:vt.RemoveProperty,index:l.index},l.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var T;if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);!function(e){var t=e.event,r=e.mutation,n=e.target,i=e.imageMap,a=e.errorHandler;try{var s="commands"in r?r.commands:[r];[o.WebGL,o.WebGL2].includes(r.type)?s.forEach((function(e){Et({mutation:e,type:r.type,target:n,imageMap:i,errorHandler:a})})):s.forEach((function(e){!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,i=e.errorHandler;try{var a=n.getContext("2d");if(r.setter)return void(a[r.property]=r.args[0]);var s=a[r.property];if("drawImage"===r.property&&"string"==typeof r.args[0]){var l=o.get(t);r.args[0]=l,s.apply(a,r.args)}else s.apply(a,r.args)}catch(e){i(r,e)}}({event:t,mutation:e,target:n,imageMap:i,errorHandler:a})}))}catch(e){a(r,e)}}({event:t,mutation:l,target:T,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var x=new FontFace(l.family,l.buffer?new Uint8Array(JSON.parse(l.fontSource)):l.fontSource,l.descriptors);null===(i=this.iframe.contentDocument)||void 0===i||i.fonts.add(x)}catch(e){this.config.showWarning&&console.warn(e)}}},t.prototype.applyMutation=function(e,t){var r,n,o=this;e.removes.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.parentId})))return;return o.warnNodeNotFound(e,t.id)}o.virtualStyleRulesMap.has(r)&&o.virtualStyleRulesMap.delete(r);var n=o.mirror.getNode(t.parentId);if(!n)return o.warnNodeNotFound(e,t.parentId);if(t.isShadow&&R(n)&&(n=n.shadowRoot),o.mirror.removeNodeFromMap(r),n){var i=null,a="__sn"in n?o.fragmentParentMap.get(n):void 0;a&&a.contains(r)?n=a:o.fragmentParentMap.has(r)&&(i=o.fragmentParentMap.get(r),o.fragmentParentMap.delete(r),r=i);try{n.removeChild(r)}catch(t){if(!(t instanceof DOMException))throw t;o.warn("parent could not remove child in mutation",n,a,r,i,e)}}}));var i=s({},this.legacy_missingNodeRetryMap),a=[],c=function(e){var r,n,s,c;if(!o.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var u=o.mirror.getNode(e.parentId);if(!u)return e.node.type===O.Document?o.newDocumentQueue.push(e):a.push(e);var d=null;o.iframe.contentDocument.contains?d=o.iframe.contentDocument.contains(u):o.iframe.contentDocument.body.contains&&(d=o.iframe.contentDocument.body.contains(u));var p=(null===(c=(s=u).getElementsByTagName)||void 0===c?void 0:c.call(s,"iframe").length)>0;if(t&&d&&!M(u)&&!p){var f=document.createDocumentFragment();for(o.mirror.map[e.parentId]=f,o.fragmentParentMap.set(f,u),o.storeState(u);u.firstChild;)f.appendChild(u.firstChild);u=f}e.node.isShadow&&R(u)&&(u=u.shadowRoot);var h=null,m=null;if(e.previousId&&(h=o.mirror.getNode(e.previousId)),e.nextId&&(m=o.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=o.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return a.push(e);if(!e.node.rootId||o.mirror.getNode(e.node.rootId)){var v=e.node.rootId?o.mirror.getNode(e.node.rootId):o.iframe.contentDocument;if(M(u))o.attachDocumentToIframe(e,u);else{var y=ue(e.node,{doc:v,map:o.mirror.map,skipChild:!0,hackCss:!0,cache:o.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in u&&u.__sn.type===O.Element&&"textarea"===u.__sn.tagName&&e.node.type===O.Text)try{for(var g=l(Array.from(u.childNodes)),b=g.next();!b.done;b=g.next()){var S=b.value;S.nodeType===u.TEXT_NODE&&u.removeChild(S)}}catch(e){r={error:e}}finally{try{b&&!b.done&&(n=g.return)&&n.call(g)}finally{if(r)throw r.error}}if(h&&h.nextSibling&&h.nextSibling.parentNode)u.insertBefore(y,h.nextSibling);else if(m&&m.parentNode)u.contains(m)?u.insertBefore(y,m):u.insertBefore(y,null);else{if(u===v)for(;v.firstChild;)v.removeChild(v.firstChild);u.appendChild(y)}if(M(y)){var T=o.newDocumentQueue.find((function(e){return e.parentId===y.__sn.id}));T&&(o.attachDocumentToIframe(T,y),o.newDocumentQueue=o.newDocumentQueue.filter((function(e){return e!==T})))}(e.previousId||e.nextId)&&o.legacy_resolveMissingNode(i,u,y,e)}else i[e.node.id]={node:y,mutation:e}}}};e.adds.forEach((function(e){c(e)}));for(var u=Date.now();a.length;){var d=C(a);if(a.length=0,Date.now()-u>500){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}try{for(var p=(r=void 0,l(d)),f=p.next();!f.done;f=p.next()){var h=f.value;this.mirror.getNode(h.value.parentId)?k(h,(function(e){c(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",h)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),e.texts.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return o.warnNodeNotFound(e,t.id)}o.fragmentParentMap.has(r)&&(r=o.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return o.warnNodeNotFound(e,t.id)}for(var n in o.fragmentParentMap.has(r)&&(r=o.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var i=t.attributes[n];if(null===i)r.removeAttribute(n);else if("string"==typeof i)try{r.setAttribute(n,i)}catch(e){o.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===n){var a=i,s=r;for(var l in a)if(!1===a[l])s.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];s.style.setProperty(l,c[0],c[1])}else{var u=a[l];s.style.setProperty(l,u)}}}}))},t.prototype.applyScroll=function(e,t){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(e,e.id);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else if(r.__sn.type===O.Document)r.defaultView.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else try{r.scrollTop=e.y,r.scrollLeft=e.x}catch(e){}},t.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},t.prototype.legacy_resolveMissingNode=function(e,t,r,n){var o=n.previousId,i=n.nextId,a=o&&e[o],s=i&&e[i];if(a){var l=a,c=l.node,u=l.mutation;t.insertBefore(c,r),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,r.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},t.prototype.moveAndHover=function(e,t,r,n,o){var i=this.mirror.getNode(r);if(!i)return this.debugNodeNotFound(o,r);var a=N(i,this.iframe),s=e*a.absoluteScale+a.x,l=t*a.absoluteScale+a.y;this.mouse.style.left=s+"px",this.mouse.style.top=l+"px",n||this.drawMouseTail({x:s,y:l}),this.hoverElements(i)},t.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?Ct:Object.assign({},Ct,this.config.mouseTail),n=r.lineCap,o=r.lineWidth,i=r.strokeStyle,a=r.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=n,e.strokeStyle=i,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),a/this.speedService.state.context.timer.speed)}},t.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var r=e;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement},t.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},t.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},t.prototype.restoreRealParent=function(e,t){this.mirror.map[t.__sn.id]=t,t.__sn.type===O.Element&&"textarea"===t.__sn.tagName&&e.textContent&&(t.value=e.textContent),t.appendChild(e),this.restoreState(t)},t.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var n=e;(n.scrollLeft||n.scrollTop)&&this.elementStateMap.set(e,{scroll:[n.scrollLeft,n.scrollTop]}),"STYLE"===n.tagName&&function(e,t){var r;try{var n=Array.from((null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:vt.Snapshot,cssTexts:n}])}catch(e){}}(n,this.virtualStyleRulesMap);var o=n.children;try{for(var i=l(Array.from(o)),a=i.next();!a.done;a=i.next()){var s=a.value;this.storeState(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}},t.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var n=e;if(this.elementStateMap.has(e)){var o=this.elementStateMap.get(e);o.scroll&&(n.scrollLeft=o.scroll[0],n.scrollTop=o.scroll[1]),this.elementStateMap.delete(e)}var i=n.children;try{for(var a=l(Array.from(i)),s=a.next();!s.done;s=a.next()){var c=s.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},t.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&bt(t,e))},t.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '"+t+"' was previously removed. ",e):this.warn("Node with id '"+t+"' not found. ",e)},t.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},t.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug("[replayer]","Node with id '"+t+"' was previously removed. ",e):this.debug("[replayer]","Node with id '"+t+"' not found. ",e)},t.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,u(["[replayer]"],e))},t.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,u(["[replayer]"],e))},t}(),Nt={key:"_sid"},Rt=$e.addCustomEvent,_t=$e.freezePage;return e.Replayer=Mt,e.addCustomEvent=Rt,e.freezePage=_t,e.getRecordSequentialIdPlugin=function(e){var t=e?Object.assign({},Nt,e):Nt,r=0;return{name:"rrweb/sequential-id@1",eventProcessor:function(e){var n;return Object.assign(e,((n={})[t.key]=++r,n)),e},options:t}},e.record=$e,e.utils=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
29
+ ***************************************************************************** */function nt(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(et||(et={}));var ot={type:"xstate.init"};function it(e){return void 0===e?[]:[].concat(e)}function at(e){return{type:"xstate.assign",assignment:e}}function st(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function lt(e){return function(t){return e===t}}function ct(e){return"string"==typeof e?{type:e}:e}function ut(e,t){return{value:e,context:t,actions:[],changed:!1,matches:lt(e)}}function dt(e,t,r){var n=t,o=!1;return[e.filter((function(e){if("xstate.assign"===e.type){o=!0;var t=Object.assign({},n);return"function"==typeof e.assignment?t=e.assignment(n,r):Object.keys(e.assignment).forEach((function(o){t[o]="function"==typeof e.assignment[o]?e.assignment[o](n,r):e.assignment[o]})),n=t,!1}return!0})),n,o]}function pt(e,t){void 0===t&&(t={});var r=nt(dt(it(e.states[e.initial].entry).map((function(e){return st(e,t.actions)})),e.context,ot),2),n=r[0],o=r[1],i={config:e,_options:t,initialState:{value:e.initial,actions:n,context:o,matches:lt(e.initial)},transition:function(t,r){var n,o,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=ct(r),u=e.states[s];if(u.on){var d=it(u.on[c.type]);try{for(var p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.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(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),f=p.next();!f.done;f=p.next()){var h=f.value;if(void 0===h)return ut(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,b=m.cond,S=void 0===v;if((void 0===b?function(){return!0}:b)(l,c)){var T=e.states[null!=v?v:s],x=nt(dt((S?it(g):[].concat(u.exit,g,T.entry).filter((function(e){return e}))).map((function(e){return st(e,i._options.actions)})),l,c),3),w=x[0],E=x[1],I=x[2],C=null!=v?v:s;return{value:C,context:E,actions:w,changed:v!==s||w.length>0||I,matches:lt(C)}}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(n)throw n.error}}}return ut(s,l)}};return i}var ft=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function ht(e){var t=e.initialState,r=et.NotStarted,n=new Set,o={_machine:e,send:function(o){r===et.Running&&(t=e.transition(t,o),ft(t,ct(o)),n.forEach((function(e){return e(t)})))},subscribe:function(e){return n.add(e),e(t),{unsubscribe:function(){return n.delete(e)}}},start:function(n){if(n){var i="object"==typeof n?n:{context:e.config.context,value:n};t={value:i.value,actions:[],context:i.context,matches:lt(i.value)}}return r=et.Running,ft(t,ot),o},stop:function(){return r=et.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}function mt(t,r){var n=r.getCastFn,o=r.applyEventsSynchronously,i=r.emitter;return ht(pt({id:"player",context:t,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:at({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:at((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),s(s({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(t){var r,a,s,c,u,d=t.timer,p=t.events,f=t.baselineTime,h=t.lastPlayedEvent;d.clear();try{for(var m=l(p),v=m.next();!v.done;v=m.next()){rt(v.value,f)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(a=m.return)&&a.call(m)}finally{if(r)throw r.error}}var y=function(t,r){for(var n=t.length-1;n>=0;n--){var o=t[n];if(o.type===e.EventType.Meta&&o.timestamp<=r)return t.slice(n)}return t}(p,f),g=null==h?void 0:h.timestamp;(null==h?void 0:h.type)===e.EventType.IncrementalSnapshot&&h.data.source===e.IncrementalSource.MouseMove&&(g=h.timestamp+(null===(u=h.data.positions[0])||void 0===u?void 0:u.timeOffset)),f<(g||0)&&i.emit(e.ReplayerEvents.PlayBack);var b=new Array,S=new Array,T=function(e){if(g&&g<f&&(e.timestamp<=g||e===h))return"continue";if(e.timestamp<f)b.push(e);else{var t=n(e,!1);S.push({doAction:function(){t()},delay:e.delay})}};try{for(var x=l(y),w=x.next();!w.done;w=x.next()){T(w.value)}}catch(e){s={error:e}}finally{try{w&&!w.done&&(c=x.return)&&c.call(x)}finally{if(s)throw s.error}}o(b),i.emit(e.ReplayerEvents.Flush),d.addActions(S),d.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:at((function(e){return s(s({},e),{lastPlayedEvent:null})})),startLive:at({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),replaceEvents:at((function(e,t){var r,o,i=e.events,a=e.timer,c=e.baselineTime;if("REPLACE_EVENTS"===t.type){var u=t.payload.events;i.length=0;var d=[],p=function(e){if(rt(e,c),i.push(e),e.timestamp>=a.timeOffset+c){var t=n(e,!1);d.push({doAction:function(){t()},delay:e.delay})}};try{for(var f=l(u),h=f.next();!h.done;h=f.next()){p(h.value)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}a.isActive()&&a.replaceActions(d)}return s(s({},e),{events:i})})),addEvent:at((function(e,t){var r=e.baselineTime,o=e.timer,i=e.events;if("ADD_EVENT"===t.type){var a=t.payload.event;rt(a,r);var l=i.length-1;if(!i[l]||i[l].timestamp<=a.timestamp)i.push(a);else{for(var c=-1,u=0;u<=l;){var d=Math.floor((u+l)/2);i[d].timestamp<=a.timestamp?u=d+1:l=d-1}-1===c&&(c=u),i.splice(c,0,a)}var p=a.timestamp<r,f=n(a,p);p?f():o.isActive()&&o.addAction({doAction:function(){f()},delay:a.delay})}return s(s({},e),{events:i})}))}}))}var vt;function yt(e,t){var r=e[t[0]];return 1===t.length?r:yt(r.cssRules[t[1]].cssRules,t.slice(2))}function gt(e){var t=u(e),r=t.pop();return{positions:t,index:r}}function bt(e,t){var r=t.sheet;r&&e.forEach((function(e){if(e.type===vt.Insert)try{if(Array.isArray(e.index)){var n=gt(e.index),o=n.positions,i=n.index;yt(r.cssRules,o).insertRule(e.cssText,i)}else r.insertRule(e.cssText,e.index)}catch(e){}else if(e.type===vt.Remove)try{if(Array.isArray(e.index)){var a=gt(e.index);o=a.positions,i=a.index;yt(r.cssRules,o).deleteRule(i||0)}else r.deleteRule(e.index)}catch(e){}else if(e.type===vt.Snapshot)!function(e,t){var r;try{var n=Array.from((null===(r=t.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText})),o=Object.entries(n).reverse(),i=n.length;o.forEach((function(r){var n,o=c(r,2),a=o[0],s=o[1],l=e.indexOf(s);if(-1===l||l>i)try{null===(n=t.sheet)||void 0===n||n.deleteRule(Number(a))}catch(e){}i=l})),e.forEach((function(e,r){var n,o,i;try{(null===(o=null===(n=t.sheet)||void 0===n?void 0:n.cssRules[r])||void 0===o?void 0:o.cssText)!==e&&(null===(i=t.sheet)||void 0===i||i.insertRule(e,r))}catch(e){}}))}catch(e){}}(e.cssTexts,t);else if(e.type===vt.SetProperty){yt(r.cssRules,e.index).style.setProperty(e.property,e.value,e.priority)}else if(e.type===vt.RemoveProperty){yt(r.cssRules,e.index).style.removeProperty(e.property)}}))}!function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"}(vt||(vt={}));var St=new Map;function Tt(e,t){var r=St.get(e);return r||(r=new Map,St.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var xt=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function wt(e,t){return function(r){if(r&&"object"==typeof r&&"rr_type"in r){if("index"in r){var n=r.rr_type,o=r.index;return Tt(t,n)[o]}if("args"in r){var i=r.rr_type,a=r.args,s=window[i];return new(s.bind.apply(s,u([void 0],a.map(wt(e,t)))))}if("base64"in r)return function(e){var t,r,n,o,i,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)r=Pe[e.charCodeAt(t)],n=Pe[e.charCodeAt(t+1)],o=Pe[e.charCodeAt(t+2)],i=Pe[e.charCodeAt(t+3)],u[l++]=r<<2|n>>4,u[l++]=(15&n)<<4|o>>2,u[l++]=(3&o)<<6|63&i;return c}(r.base64);if("src"in r){var l=e.get(r.src);if(l)return l;var c=new Image;return c.src=r.src,e.set(r.src,c),c}}else if(Array.isArray(r))return r.map(wt(e,t));return r}}function Et(e){var t=e.mutation,r=e.target,n=e.type,i=e.imageMap,a=e.errorHandler;try{var s=function(e,t){try{return t===o.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(r,n);if(!s)return;if(t.setter)return void(s[t.property]=t.args[0]);var l=s[t.property],c=t.args.map(wt(i,s));!function(e,t){if(null==t?void 0:t.constructor){var r=t.constructor.name;if(xt.includes(r)){var n=Tt(e,r);n.includes(t)||n.push(t)}}}(s,l.apply(s,c))}catch(e){a(t,e)}}var It=Ke||Je,Ct={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function kt(t){return t.type==e.EventType.IncrementalSnapshot&&(t.data.source==e.IncrementalSource.TouchMove||t.data.source==e.IncrementalSource.MouseInteraction&&t.data.type==e.MouseInteractions.TouchStart)}var Mt=function(){function t(t,r){var n=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=It(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=le(),this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,r=e.__sn&&e.__sn.id;delete this.map[r],e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},has:function(e){return this.map.hasOwnProperty(e)},reset:function(){this.map={}}},this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(null==r?void 0:r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");var o={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:Ct,inactiveThreshold:.02,inactiveSkipTime:2e3};this.config=Object.assign({},o,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),this.setupDom(),this.treeIndex=new I,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.virtualStyleRulesMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,t,r,o,i,a,s=n.treeIndex.flush(),c=s.scrollMap,u=s.inputMap;n.fragmentParentMap.forEach((function(e,t){return n.restoreRealParent(t,e)}));try{for(var d=l(n.virtualStyleRulesMap.keys()),p=d.next();!p.done;p=d.next()){var f=p.value;n.restoreNodeSheet(f)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}n.fragmentParentMap.clear(),n.elementStateMap.clear(),n.virtualStyleRulesMap.clear();try{for(var h=l(c.values()),m=h.next();!m.done;m=h.next()){var v=m.value;n.applyScroll(v,!0)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var y=l(u.values()),g=y.next();!g.done;g=y.next()){v=g.value;n.applyInput(v)}}catch(e){i={error:e}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(i)throw i.error}}})),this.emitter.on(e.ReplayerEvents.PlayBack,(function(){n.firstFullSnapshot=null,n.mirror.reset()}));var i=new tt([],(null==r?void 0:r.speed)||o.speed);this.service=mt({events:t.map((function(e){return r&&r.unpackFn?r.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){n.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=ht(pt({id:"speed",context:{normalSpeed:-1,timer:i},initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:at({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){n.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var a=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),s=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(a){var c=a.data,u=c.width,d=c.height;setTimeout((function(){n.emitter.emit(e.ReplayerEvents.Resize,{width:u,height:d})}),0)}s&&setTimeout((function(){n.firstFullSnapshot||(n.firstFullSnapshot=s,n.rebuildFullSnapshot(s),n.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1),this.service.state.context.events.find(kt)&&this.mouse.classList.add("touch-device")}return Object.defineProperty(t.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),t.prototype.on=function(e,t){return this.emitter.on(e,t),this},t.prototype.off=function(e,t){return this.emitter.off(e,t),this},t.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(r){t.config[r]=e[r]})),this.config.skipInactive||this.backToNormal(),void 0!==e.speed&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),void 0!==e.mouseTail&&(!1===e.mouseTail?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))},t.prototype.getActivityIntervals=function(){var e=this;if(0==this.activityIntervals.length){for(var t=[],r=this.getMetaData(),n=u([{timestamp:r.startTime}],this.service.state.context.events.filter((function(t){return e.isUserInteraction(t)})),[{timestamp:r.endTime}]),o=1;o<n.length;o++){var i=n[o-1],a=n[o];a.timestamp-i.timestamp>1e4?t.push({startTime:i.timestamp,endTime:a.timestamp,duration:a.timestamp-i.timestamp,active:!1}):t.push({startTime:i.timestamp,endTime:a.timestamp,duration:a.timestamp-i.timestamp,active:!0})}var s=[],l=t[0];for(o=1;o<t.length;o++)t[o].active!=t[o-1].active&&(s.push({startTime:l.startTime,endTime:t[o-1].endTime,duration:t[o-1].endTime-l.startTime,active:t[o-1].active}),l=t[o]);l&&t.length>0&&s.push({startTime:l.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-l.startTime,active:t[t.length-1].active}),l=s[0];for(o=1;o<s.length;o++)(!s[o].active&&s[o].duration>this.config.inactiveThreshold*r.totalTime||!s[o-1].active&&s[o-1].duration>this.config.inactiveThreshold*r.totalTime)&&(this.activityIntervals.push({startTime:l.startTime,endTime:s[o-1].endTime,duration:s[o-1].endTime-l.startTime,active:s[o-1].active}),l=s[o]);l&&s.length>0&&this.activityIntervals.push({startTime:l.startTime,endTime:s[s.length-1].endTime,duration:s[s.length-1].endTime-l.startTime,active:s[s.length-1].active})}return this.activityIntervals},t.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},t.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},t.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},t.prototype.getMirror=function(){return this.mirror},t.prototype.play=function(t){var r;void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)},t.prototype.pause=function(t){var r;void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),null===(r=this.iframe.contentDocument)||void 0===r||r.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.Pause)},t.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},t.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},t.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;kt(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},t.prototype.replaceEvents=function(e){var t,r;try{for(var n=l(e),o=n.next();!o.done;o=n.next()){if(kt(o.value)){this.mouse.classList.add("touch-device");break}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.service.send({type:"REPLACE_EVENTS",payload:{events:e}})},t.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},t.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},t.prototype.resetCache=function(){this.cache=le()},t.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),!1!==this.config.mouseTail&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");var e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Ze(this.iframe.contentWindow,this.iframe.contentDocument),E(this.iframe.contentWindow))},t.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var n=l([this.mouseTail,this.iframe]),o=n.next();!o.done;o=n.next()){var i=o.value;i&&(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},t.prototype.applyEventsSynchronously=function(t){var r,n;try{for(var o=l(t),i=o.next();!i.done;i=o.next()){var a=i.value;switch(a.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:continue;case e.EventType.FullSnapshot:case e.EventType.Meta:case e.EventType.Plugin:break;case e.EventType.IncrementalSnapshot:switch(a.data.source){case e.IncrementalSource.MediaInteraction:continue}}this.getCastFn(a,!0)()}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null,!0===this.touchActive?this.mouse.classList.add("touch-active"):!1===this.touchActive&&this.mouse.classList.remove("touch-active"),this.touchActive=null},t.prototype.getCastFn=function(t,r){var n,o=this;switch(void 0===r&&(r=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:n=function(){o.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:n=function(){return o.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:n=function(){if(o.firstFullSnapshot){if(o.firstFullSnapshot===t)return void(o.firstFullSnapshot=!0)}else o.firstFullSnapshot=!0;o.rebuildFullSnapshot(t,r),o.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:n=function(){var n,i;if(o.applyIncremental(t,r),!r&&(o.handleInactivity(t.timestamp),t===o.nextUserInteractionEvent&&(o.nextUserInteractionEvent=null,o.backToNormal()),o.config.skipInactive&&!o.nextUserInteractionEvent)){try{for(var a=l(o.service.state.context.events),s=a.next();!s.done;s=a.next()){var c=s.value;if(!(c.timestamp<=t.timestamp)&&o.isUserInteraction(c)){c.delay-t.delay>1e4*o.speedService.state.context.timer.speed&&(o.nextUserInteractionEvent=c);break}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}if(o.nextUserInteractionEvent){var u=o.nextUserInteractionEvent.delay-t.delay,d={speed:Math.min(Math.round(u/2e3),o.config.maxSpeed)};o.speedService.send({type:"FAST_FORWARD",payload:d}),o.emitter.emit(e.ReplayerEvents.SkipStart,d)}}}}return function(){var i,a;n&&n();try{for(var s=l(o.config.plugins||[]),c=s.next();!c.done;c=s.next()){c.value.handler(t,r,{replayer:o})}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}o.service.send({type:"CAST_EVENT",payload:{event:t}});var u=o.service.state.context.events.length-1;if(t===o.service.state.context.events[u]){var d=function(){u<o.service.state.context.events.length-1||(o.backToNormal(),o.service.send("END"),o.emitter.emit(e.ReplayerEvents.Finish))};t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove&&t.data.positions.length?setTimeout((function(){d()}),Math.max(0,50-t.data.positions[0].timeOffset)):d()}o.emitter.emit(e.ReplayerEvents.EventCast,t)}},t.prototype.handleInactivity=function(t,r){var n,o;if((t===this.inactiveEndTimestamp||r)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){try{for(var i=l(this.getActivityIntervals()),a=i.next();!a.done;a=i.next()){var s=a.value;if(t>=s.startTime&&t<s.endTime&&!s.active){this.inactiveEndTimestamp=s.endTime;break}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}if(this.inactiveEndTimestamp){var c=this.inactiveEndTimestamp-t,u={speed:c/36e5*this.config.inactiveSkipTime<1e3?c/1e3:Math.round(Math.max(c,36e5)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:u}),this.emitter.emit(e.ReplayerEvents.SkipStart,u)}}},t.prototype.rebuildFullSnapshot=function(t,r){var n,o,i=this;if(void 0===r&&(r=!1),!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};var a=[];this.mirror.map=de(t.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)},cache:this.cache})[1];var s=function(e,t){c.attachDocumentToIframe(e,t),c.newDocumentQueue=c.newDocumentQueue.filter((function(t){return t!==e}))},c=this;try{for(var u=l(a),d=u.next();!d.done;d=u.next()){var p=d.value;s(p.mutationInQueue,p.builtNode)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}var f=this.iframe.contentDocument,h=f.documentElement,m=f.head;this.insertStyleRules(h,m),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(e.ReplayerEvents.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},t.prototype.insertStyleRules=function(e,t){var r=document.createElement("style");e.insertBefore(r,t);var n,o=(n=this.config.blockClass,["noscript { display: none !important; }","."+n+" { background: currentColor; border-radius: 5px; }","."+n+":hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)r.sheet.insertRule(o[i],i)},t.prototype.attachDocumentToIframe=function(e,t){var r,n,o=this,i=[];if(!t.contentDocument)for(var a=t.parentNode;a;){if(this.fragmentParentMap.has(a)){var s=a,c=this.fragmentParentMap.get(s);this.restoreRealParent(s,c);break}a=a.parentNode}ue(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){if(o.collectIframeAndAttachDocument(i,e),e.__sn.type===O.Element&&"HTML"===e.__sn.tagName.toUpperCase()){var r=t.contentDocument,n=r.documentElement,a=r.head;o.insertStyleRules(n,a)}},cache:this.cache});var u=function(e,t){d.attachDocumentToIframe(e,t),d.newDocumentQueue=d.newDocumentQueue.filter((function(t){return t!==e}))},d=this;try{for(var p=l(i),f=p.next();!f.done;f=p.next()){var h=f.value;u(h.mutationInQueue,h.builtNode)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}},t.prototype.collectIframeAndAttachDocument=function(e,t){if(M(t)){var r=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));r&&e.push({mutationInQueue:r,builtNode:t})}},t.prototype.waitForStylesheetLoad=function(){var t,r=this,n=null===(t=this.iframe.contentDocument)||void 0===t?void 0:t.head;if(n){var o,i=new Set,a=this.service.state,s=function(){a=r.service.state};this.emitter.on(e.ReplayerEvents.Start,s),this.emitter.on(e.ReplayerEvents.Pause,s);var l=function(){r.emitter.off(e.ReplayerEvents.Start,s),r.emitter.off(e.ReplayerEvents.Pause,s)};n.querySelectorAll('link[rel="stylesheet"]').forEach((function(t){t.sheet||(i.add(t),t.addEventListener("load",(function(){i.delete(t),0===i.size&&-1!==o&&(a.matches("playing")&&r.play(r.getCurrentTime()),r.emitter.emit(e.ReplayerEvents.LoadStylesheetEnd),o&&clearTimeout(o),l())})))})),i.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(e.ReplayerEvents.LoadStylesheetStart),o=setTimeout((function(){a.matches("playing")&&r.play(r.getCurrentTime()),o=-1,l()}),this.config.loadTimeout))}},t.prototype.hasImageArg=function(e){var t,r;try{for(var n=l(e),o=n.next();!o.done;o=n.next()){var i=o.value;if(i&&"object"==typeof i)if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else{if("rr_type"in i&&"HTMLImageElement"===i.rr_type)return!0;if(i instanceof Array&&this.hasImageArg(i))return!0}else;}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!1},t.prototype.getImageArgs=function(e){var t,r,n=[];try{for(var o=l(e),i=o.next();!i.done;i=o.next()){var a=i.value;a&&"object"==typeof a&&("rr_type"in a&&"args"in a?n.push.apply(n,u(this.getImageArgs(a.args))):"rr_type"in a&&"HTMLImageElement"===a.rr_type?n.push(a.src):a instanceof Array&&n.push.apply(n,u(this.getImageArgs(a))))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n},t.prototype.preloadAllImages=function(){var t,r,n=this;this.service.state;var o=function(){n.service.state};this.emitter.on(e.ReplayerEvents.Start,o),this.emitter.on(e.ReplayerEvents.Pause,o);var i=function(t){t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.CanvasMutation&&("commands"in t.data?t.data.commands.forEach((function(e){return n.preloadImages(e,t)})):a.preloadImages(t.data,t))},a=this;try{for(var s=l(this.service.state.context.events),c=s.next();!c.done;c=s.next()){i(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}},t.prototype.preloadImages=function(e,t){var r=this;if("drawImage"!==e.property||"string"!=typeof e.args[0]||this.imageMap.has(t))this.hasImageArg(e.args)&&this.getImageArgs(e.args).forEach((function(e){var t=new Image;t.src=e,r.imageMap.set(e,t)}));else{var n=document.createElement("canvas"),o=n.getContext("2d"),i=null==o?void 0:o.createImageData(n.width,n.height);null==i||i.data,JSON.parse(e.args[0]),null==o||o.putImageData(i,0,0)}},t.prototype.applyIncremental=function(t,r){var n,i,a=this,l=t.data;switch(l.source){case e.IncrementalSource.Mutation:r&&(l.adds.forEach((function(e){return a.treeIndex.add(e)})),l.texts.forEach((function(e){return a.treeIndex.text(e)})),l.attributes.forEach((function(e){return a.treeIndex.attribute(e)})),l.removes.forEach((function(e){return a.treeIndex.remove(e,a.mirror)})));try{this.applyMutation(l,r)}catch(e){this.warn("Exception in mutation "+(e.message||e),l)}break;case e.IncrementalSource.Drag:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MouseMove:if(r){var c=l.positions[l.positions.length-1];this.mousePos={x:c.x,y:c.y,id:c.id,debugData:l}}else l.positions.forEach((function(e){var n={doAction:function(){a.moveAndHover(e.x,e.y,e.id,r,l)},delay:e.timeOffset+t.timestamp-a.service.state.context.baselineTime};a.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:t.delay-(null===(n=l.positions[0])||void 0===n?void 0:n.timeOffset)});break;case e.IncrementalSource.MouseInteraction:if(-1===l.id)break;var u=new Event(e.MouseInteractions[l.type].toLowerCase());if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);this.emitter.emit(e.ReplayerEvents.MouseInteraction,{type:l.type,target:T});var d=this.config.triggerFocus;switch(l.type){case e.MouseInteractions.Blur:"blur"in T&&T.blur();break;case e.MouseInteractions.Focus:d&&T.focus&&T.focus({preventScroll:!0});break;case e.MouseInteractions.Click:case e.MouseInteractions.TouchStart:case e.MouseInteractions.TouchEnd:r?(l.type===e.MouseInteractions.TouchStart?this.touchActive=!0:l.type===e.MouseInteractions.TouchEnd&&(this.touchActive=!1),this.mousePos={x:l.x,y:l.y,id:l.id,debugData:l}):(l.type===e.MouseInteractions.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(l.x,l.y,l.id,r,l),l.type===e.MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):l.type===e.MouseInteractions.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):l.type===e.MouseInteractions.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case e.MouseInteractions.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:T.dispatchEvent(u)}break;case e.IncrementalSource.Scroll:if(-1===l.id)break;if(r){this.treeIndex.scroll(l);break}this.applyScroll(l,!1);break;case e.IncrementalSource.ViewportResize:this.emitter.emit(e.ReplayerEvents.Resize,{width:l.width,height:l.height});break;case e.IncrementalSource.Input:if(-1===l.id)break;if(r){this.treeIndex.input(l);break}this.applyInput(l);break;case e.IncrementalSource.MediaInteraction:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);var p=T;try{l.currentTime&&(p.currentTime=l.currentTime),l.volume&&(p.volume=l.volume),l.muted&&(p.muted=l.muted),1===l.type&&p.pause(),0===l.type&&p.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case e.IncrementalSource.StyleSheetRule:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);var f,h=T,m=T.parentNode,v=this.fragmentParentMap.has(m),y=v?null:h.sheet;y||(this.virtualStyleRulesMap.has(T)?f=this.virtualStyleRulesMap.get(T):(f=[],this.virtualStyleRulesMap.set(T,f))),l.adds&&l.adds.forEach((function(e){var t=e.rule,r=e.index;if(y)try{if(Array.isArray(r)){var n=gt(r),o=n.positions,i=n.index;yt(y.cssRules,o).insertRule(t,i)}else{i=void 0===r?void 0:Math.min(r,y.cssRules.length);y.insertRule(t,i)}}catch(e){}else null==f||f.push({cssText:t,index:r,type:vt.Insert})})),l.removes&&l.removes.forEach((function(e){var t=e.index;if(v)null==f||f.push({index:t,type:vt.Remove});else try{if(Array.isArray(t)){var r=gt(t),n=r.positions,o=r.index;yt(y.cssRules,n).deleteRule(o||0)}else null==y||y.deleteRule(t)}catch(e){}}));break;case e.IncrementalSource.StyleDeclaration:if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);h=T;var g=T.parentNode,b=this.fragmentParentMap.has(g)?null:h.sheet,S=[];if(b||(this.virtualStyleRulesMap.has(T)?S=this.virtualStyleRulesMap.get(T):(S=[],this.virtualStyleRulesMap.set(T,S))),l.set)if(b)yt(b.rules,l.index).style.setProperty(l.set.property,l.set.value,l.set.priority);else S.push(s({type:vt.SetProperty,index:l.index},l.set));if(l.remove)if(b)yt(b.rules,l.index).style.removeProperty(l.remove.property);else S.push(s({type:vt.RemoveProperty,index:l.index},l.remove));break;case e.IncrementalSource.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var T;if(!(T=this.mirror.getNode(l.id)))return this.debugNodeNotFound(l,l.id);!function(e){var t=e.event,r=e.mutation,n=e.target,i=e.imageMap,a=e.errorHandler;try{var s="commands"in r?r.commands:[r];[o.WebGL,o.WebGL2].includes(r.type)?s.forEach((function(e){Et({mutation:e,type:r.type,target:n,imageMap:i,errorHandler:a})})):s.forEach((function(e){!function(e){var t=e.event,r=e.mutation,n=e.target,o=e.imageMap,i=e.errorHandler;try{var a=n.getContext("2d");if(r.setter)return void(a[r.property]=r.args[0]);var s=a[r.property];if("drawImage"===r.property&&"string"==typeof r.args[0]){var l=o.get(t);r.args[0]=l,s.apply(a,r.args)}else s.apply(a,r.args)}catch(e){i(r,e)}}({event:t,mutation:e,target:n,imageMap:i,errorHandler:a})}))}catch(e){a(r,e)}}({event:t,mutation:l,target:T,imageMap:this.imageMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case e.IncrementalSource.Font:try{var x=new FontFace(l.family,l.buffer?new Uint8Array(JSON.parse(l.fontSource)):l.fontSource,l.descriptors);null===(i=this.iframe.contentDocument)||void 0===i||i.fonts.add(x)}catch(e){this.config.showWarning&&console.warn(e)}}},t.prototype.applyMutation=function(e,t){var r,n,o=this;e.removes.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.parentId})))return;return o.warnNodeNotFound(e,t.id)}o.virtualStyleRulesMap.has(r)&&o.virtualStyleRulesMap.delete(r);var n=o.mirror.getNode(t.parentId);if(!n)return o.warnNodeNotFound(e,t.parentId);if(t.isShadow&&R(n)&&(n=n.shadowRoot),o.mirror.removeNodeFromMap(r),n){var i=null,a="__sn"in n?o.fragmentParentMap.get(n):void 0;a&&a.contains(r)?n=a:o.fragmentParentMap.has(r)&&(i=o.fragmentParentMap.get(r),o.fragmentParentMap.delete(r),r=i);try{n.removeChild(r)}catch(t){if(!(t instanceof DOMException))throw t;o.warn("parent could not remove child in mutation",n,a,r,i,e)}}}));var i=s({},this.legacy_missingNodeRetryMap),a=[],c=function(e){var r,n,s,c;if(!o.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var u=o.mirror.getNode(e.parentId);if(!u)return e.node.type===O.Document?o.newDocumentQueue.push(e):a.push(e);var d=null;o.iframe.contentDocument.contains?d=o.iframe.contentDocument.contains(u):o.iframe.contentDocument.body.contains&&(d=o.iframe.contentDocument.body.contains(u));var p=(null===(c=(s=u).getElementsByTagName)||void 0===c?void 0:c.call(s,"iframe").length)>0;if(t&&d&&!M(u)&&!p){var f=document.createDocumentFragment();for(o.mirror.map[e.parentId]=f,o.fragmentParentMap.set(f,u),o.storeState(u);u.firstChild;)f.appendChild(u.firstChild);u=f}e.node.isShadow&&R(u)&&(u=u.shadowRoot);var h=null,m=null;if(e.previousId&&(h=o.mirror.getNode(e.previousId)),e.nextId&&(m=o.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=o.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return a.push(e);if(!e.node.rootId||o.mirror.getNode(e.node.rootId)){var v=e.node.rootId?o.mirror.getNode(e.node.rootId):o.iframe.contentDocument;if(M(u))o.attachDocumentToIframe(e,u);else{var y=ue(e.node,{doc:v,map:o.mirror.map,skipChild:!0,hackCss:!0,cache:o.cache});if(-1!==e.previousId&&-1!==e.nextId){if("__sn"in u&&u.__sn.type===O.Element&&"textarea"===u.__sn.tagName&&e.node.type===O.Text)try{for(var g=l(Array.from(u.childNodes)),b=g.next();!b.done;b=g.next()){var S=b.value;S.nodeType===u.TEXT_NODE&&u.removeChild(S)}}catch(e){r={error:e}}finally{try{b&&!b.done&&(n=g.return)&&n.call(g)}finally{if(r)throw r.error}}if(h&&h.nextSibling&&h.nextSibling.parentNode)u.insertBefore(y,h.nextSibling);else if(m&&m.parentNode)u.contains(m)?u.insertBefore(y,m):u.insertBefore(y,null);else{if(u===v)for(;v.firstChild;)v.removeChild(v.firstChild);u.appendChild(y)}if(M(y)){var T=o.newDocumentQueue.find((function(e){return e.parentId===y.__sn.id}));T&&(o.attachDocumentToIframe(T,y),o.newDocumentQueue=o.newDocumentQueue.filter((function(e){return e!==T})))}(e.previousId||e.nextId)&&o.legacy_resolveMissingNode(i,u,y,e)}else i[e.node.id]={node:y,mutation:e}}}};e.adds.forEach((function(e){c(e)}));for(var u=Date.now();a.length;){var d=C(a);if(a.length=0,Date.now()-u>500){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}try{for(var p=(r=void 0,l(d)),f=p.next();!f.done;f=p.next()){var h=f.value;this.mirror.getNode(h.value.parentId)?k(h,(function(e){c(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",h)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),e.texts.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return o.warnNodeNotFound(e,t.id)}o.fragmentParentMap.has(r)&&(r=o.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=o.mirror.getNode(t.id);if(!r){if(e.removes.find((function(e){return e.id===t.id})))return;return o.warnNodeNotFound(e,t.id)}for(var n in o.fragmentParentMap.has(r)&&(r=o.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var i=t.attributes[n];if(null===i)r.removeAttribute(n);else if("string"==typeof i)try{r.setAttribute(n,i)}catch(e){o.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}else if("style"===n){var a=i,s=r;for(var l in a)if(!1===a[l])s.style.removeProperty(l);else if(a[l]instanceof Array){var c=a[l];s.style.setProperty(l,c[0],c[1])}else{var u=a[l];s.style.setProperty(l,u)}}}}))},t.prototype.applyScroll=function(e,t){var r=this.mirror.getNode(e.id);if(!r)return this.debugNodeNotFound(e,e.id);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else if(r.__sn.type===O.Document)r.defaultView.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else try{r.scrollTop=e.y,r.scrollLeft=e.x}catch(e){}},t.prototype.applyInput=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(e){}},t.prototype.legacy_resolveMissingNode=function(e,t,r,n){var o=n.previousId,i=n.nextId,a=o&&e[o],s=i&&e[i];if(a){var l=a,c=l.node,u=l.mutation;t.insertBefore(c,r),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}if(s){var d=s;c=d.node,u=d.mutation;t.insertBefore(c,r.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},t.prototype.moveAndHover=function(e,t,r,n,o){var i=this.mirror.getNode(r);if(!i)return this.debugNodeNotFound(o,r);var a=N(i,this.iframe),s=e*a.absoluteScale+a.x,l=t*a.absoluteScale+a.y;this.mouse.style.left=s+"px",this.mouse.style.top=l+"px",n||this.drawMouseTail({x:s,y:l}),this.hoverElements(i)},t.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?Ct:Object.assign({},Ct,this.config.mouseTail),n=r.lineCap,o=r.lineWidth,i=r.strokeStyle,a=r.duration,s=function(){if(t.mouseTail){var e=t.mouseTail.getContext("2d");e&&t.tailPositions.length&&(e.clearRect(0,0,t.mouseTail.width,t.mouseTail.height),e.beginPath(),e.lineWidth=o,e.lineCap=n,e.strokeStyle=i,e.moveTo(t.tailPositions[0].x,t.tailPositions[0].y),t.tailPositions.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}};this.tailPositions.push(e),s(),setTimeout((function(){t.tailPositions=t.tailPositions.filter((function(t){return t!==e})),s()}),a/this.speedService.state.context.timer.speed)}},t.prototype.hoverElements=function(e){var t;null===(t=this.iframe.contentDocument)||void 0===t||t.querySelectorAll(".\\:hover").forEach((function(e){e.classList.remove(":hover")}));for(var r=e;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement},t.prototype.isUserInteraction=function(t){return t.type===e.EventType.IncrementalSnapshot&&(t.data.source>e.IncrementalSource.Mutation&&t.data.source<=e.IncrementalSource.Input)},t.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(e.ReplayerEvents.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},t.prototype.restoreRealParent=function(e,t){this.mirror.map[t.__sn.id]=t,t.__sn.type===O.Element&&"textarea"===t.__sn.tagName&&e.textContent&&(t.value=e.textContent);try{t.appendChild(e),this.restoreState(t)}catch(e){console.warn(e)}},t.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var n=e;(n.scrollLeft||n.scrollTop)&&this.elementStateMap.set(e,{scroll:[n.scrollLeft,n.scrollTop]}),"STYLE"===n.tagName&&function(e,t){var r;try{var n=Array.from((null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||[]).map((function(e){return e.cssText}));t.set(e,[{type:vt.Snapshot,cssTexts:n}])}catch(e){}}(n,this.virtualStyleRulesMap);var o=n.children;try{for(var i=l(Array.from(o)),a=i.next();!a.done;a=i.next()){var s=a.value;this.storeState(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}},t.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var n=e;if(this.elementStateMap.has(e)){var o=this.elementStateMap.get(e);o.scroll&&(n.scrollLeft=o.scroll[0],n.scrollTop=o.scroll[1]),this.elementStateMap.delete(e)}var i=n.children;try{for(var a=l(Array.from(i)),s=a.next();!s.done;s=a.next()){var c=s.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},t.prototype.restoreNodeSheet=function(e){var t=this.virtualStyleRulesMap.get(e);"STYLE"===e.nodeName&&(t&&bt(t,e))},t.prototype.warnNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.warn("Node with id '"+t+"' was previously removed. ",e):this.warn("Node with id '"+t+"' not found. ",e)},t.prototype.warnCanvasMutationFailed=function(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)},t.prototype.debugNodeNotFound=function(e,t){this.treeIndex.idRemoved(t)?this.debug("[replayer]","Node with id '"+t+"' was previously removed. ",e):this.debug("[replayer]","Node with id '"+t+"' not found. ",e)},t.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,u(["[replayer]"],e))},t.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,u(["[replayer]"],e))},t}(),Nt={key:"_sid"},Rt=$e.addCustomEvent,_t=$e.freezePage;return e.Replayer=Mt,e.addCustomEvent=Rt,e.freezePage=_t,e.getRecordSequentialIdPlugin=function(e){var t=e?Object.assign({},Nt,e):Nt,r=0;return{name:"rrweb/sequential-id@1",eventProcessor:function(e){var n;return Object.assign(e,((n={})[t.key]=++r,n)),e},options:t}},e.record=$e,e.utils=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
30
30
  //# sourceMappingURL=rrweb.min.js.map