@bss-sbc/rrweb
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -29,3 +29,3 @@ var rrwebReplay=function(e){"use strict"; | ||
and limitations under the License. | ||
***************************************************************************** */!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(M||(M={}));var I={type:"xstate.init"};function D(e){return void 0===e?[]:[].concat(e)}function k(e){return{type:"xstate.assign",assignment:e}}function A(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 _(e){return function(t){return e===t}}function F(e){return"string"==typeof e?{type:e}:e}function O(e,t){return{value:e,context:t,actions:[],changed:!1,matches:_(e)}}function P(e,t){void 0===t&&(t={});var r={config:e,_options:t,initialState:{value:e.initial,actions:D(e.states[e.initial].entry).map((function(e){return A(e,t.actions)})),context:e.context,matches:_(e.initial)},transition:function(t,n){var o,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=F(n),u=e.states[s];if(u.on){var f=D(u.on[c.type]),d=function(t){if(void 0===t)return{value:O(s,l)};var n="string"==typeof t?{target:t}:t,o=n.target,i=void 0===o?s:o,a=n.actions,f=void 0===a?[]:a,d=n.cond,p=l;if((void 0===d?function(){return!0}:d)(l,c)){var h=e.states[i],m=!1,v=[].concat(u.exit,f,h.entry).filter((function(e){return e})).map((function(e){return A(e,r._options.actions)})).filter((function(e){if("xstate.assign"===e.type){m=!0;var t=Object.assign({},p);return"function"==typeof e.assignment?t=e.assignment(p,c):Object.keys(e.assignment).forEach((function(r){t[r]="function"==typeof e.assignment[r]?e.assignment[r](p,c):e.assignment[r]})),p=t,!1}return!0}));return{value:{value:i,context:p,actions:v,changed:i!==s||v.length>0||m,matches:_(i)}}}};try{for(var p=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}(f),h=p.next();!h.done;h=p.next()){var m=d(h.value);if("object"==typeof m)return m.value}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}}return O(s,l)}};return r}var R=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function L(e){var t=e.initialState,r=M.NotStarted,n=new Set,o={_machine:e,send:function(o){r===M.Running&&(t=e.transition(t,o),R(t,F(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:_(i.value)}}return r=M.Running,R(t,I),o},stop:function(){return r=M.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}var B="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",j={map:{},getId:function(){return console.error(B),-1},getNode:function(){return console.error(B),null},removeNodeFromMap:function(){console.error(B)},has:function(){return console.error(B),!1},reset:function(){console.error(B)}};"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:function(e,t,r){return"map"===t&&console.error(B),Reflect.get(e,t,r)}}));var U=function(){function e(){this.reset()}return e.prototype.add=function(e){var t=this.indexes.get(e.parentId),r={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(r.parent=t,t.children[r.id]=r):this.tree[r.id]=r,this.indexes.set(r.id,r)},e.prototype.remove=function(e,t){var r=this,n=this.indexes.get(e.parentId),o=this.indexes.get(e.id),i=function(e){r.removeIdSet.add(e);var n=t.getNode(e);null==n||n.childNodes.forEach((function(e){"__sn"in e&&i(e.__sn.id)}))},a=function(t){r.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return a(e)}));var n=r.indexes.get(t.id);if(n){var o=n.parent;o&&(delete n.parent,delete o.children[n.id],r.indexes.delete(e.id))}};o?n?(delete o.parent,delete n.children[o.id],this.indexes.delete(e.id),a(o)):(delete this.tree[o.id],this.indexes.delete(o.id),a(o)):(this.removeNodeMutations.push(e),i(e.id))},e.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},e.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},e.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},e.prototype.input=function(e){this.inputMap.set(e.id,e)},e.prototype.flush=function(){var e,t,r,o,i=this,a=this.tree,s=this.removeNodeMutations,l=this.textMutations,c=this.attributeMutations,u={source:w.Mutation,removes:s,texts:l,attributes:c,adds:[]},f=function(e,t){t&&i.removeIdSet.add(e.id),u.texts=u.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),u.attributes=u.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return f(e,!0)})):(u.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return f(e,!1)})))};Object.values(a).forEach((function(e){return f(e,!1)}));try{for(var d=n(this.scrollMap.keys()),p=d.next();!p.done;p=d.next()){var h=p.value;this.removeIdSet.has(h)&&this.scrollMap.delete(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var m=n(this.inputMap.keys()),v=m.next();!v.done;v=m.next()){h=v.value;this.removeIdSet.has(h)&&this.inputMap.delete(h)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}var y=new Map(this.scrollMap),g=new Map(this.inputMap);return this.reset(),{mutationData:u,scrollMap:y,inputMap:g}},e.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},e}();function V(e){var t,r,o={},i=function(e,t){var r={value:e,parent:t,children:[]};return o[e.node.id]=r,r},a=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,f=c.parentId;if(u&&u in o){var d=o[u];if(d.parent){var p=d.parent.children.indexOf(d);d.parent.children.splice(p,0,i(c,d.parent))}else{p=a.indexOf(d);a.splice(p,0,i(c,null))}}else if(f in o){var h=o[f];h.children.push(i(c,h))}else a.push(i(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return a}function z(e,t){t(e.value);for(var r=e.children.length-1;r>=0;r--)z(e.children[r],t)}function W(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function Y(e){var t;return Boolean(null===(t=e)||void 0===t?void 0:t.shadowRoot)}function X(e,t){var o=t.getCastFn,i=t.emitter;return L(P({id:"player",context:e,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"]}}},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"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:k({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:k((function(e,t){var n=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(n=t.payload.timeOffset),r(r({},e),{timeOffset:n,baselineTime:e.events[0].timestamp+n})})),play:function(e){var t,r,a,s,l,c=e.timer,u=e.events,f=e.baselineTime,d=e.lastPlayedEvent;c.clear();try{for(var p=n(u),h=p.next();!h.done;h=p.next()){C(h.value,f)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}var m=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r];if(n.type===g.Meta&&n.timestamp<=t)return e.slice(r)}return e}(u,f),v=null==d?void 0:d.timestamp;(null==d?void 0:d.type)===g.IncrementalSnapshot&&d.data.source===w.MouseMove&&(v=d.timestamp+(null===(l=d.data.positions[0])||void 0===l?void 0:l.timeOffset)),f<(v||0)&&i.emit(x.PlayBack);var y=new Array,b=function(e){if(v&&v<f&&(e.timestamp<=v||e===d))return"continue";var t=e.timestamp<f;if(t&&!function(e){switch(e.type){case g.DomContentLoaded:case g.Load:case g.Custom:return!1;case g.FullSnapshot:case g.Meta:case g.Plugin:return!0}switch(e.data.source){case w.MouseMove:case w.MouseInteraction:case w.TouchMove:case w.MediaInteraction:return!1;case w.ViewportResize:case w.StyleSheetRule:case w.Scroll:case w.Input:return!0}return!0}(e))return"continue";var r=o(e,t);t?r():y.push({doAction:function(){r(),i.emit(x.EventCast,e)},delay:e.delay})};try{for(var S=n(m),E=S.next();!E.done;E=S.next()){b(E.value)}}catch(e){a={error:e}}finally{try{E&&!E.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}i.emit(x.Flush),c.addActions(y),c.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:k((function(e){return r(r({},e),{lastPlayedEvent:null})})),startLive:k({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:k((function(e,t){var n=e.baselineTime,a=e.timer,s=e.events;if("ADD_EVENT"===t.type){var l=t.payload.event;C(l,n);var c=s.length-1;if(!s[c]||s[c].timestamp<=l.timestamp)s.push(l);else{for(var u=-1,f=0;f<=c;){var d=Math.floor((f+c)/2);s[d].timestamp<=l.timestamp?f=d+1:c=d-1}-1===u&&(u=f),s.splice(u,0,l)}var p=l.timestamp<n,h=o(l,p);p?h():a.isActive()&&a.addAction({doAction:function(){h(),i.emit(x.EventCast,l)},delay:l.delay})}return r(r({},e),{events:s})}))}}))}var Q=y||E,H={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"},G=function(){function e(e,t){var r=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Q(),this.legacy_missingNodeRetryMap={},this.imageMap=new Map,this.mirror={map:{},getId:function(e){return 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=[],!(null==t?void 0:t.liveMode)&&e.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:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:H};this.config=Object.assign({},o,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(x.Resize,this.handleResize),this.setupDom(),this.treeIndex=new U,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.emitter.on(x.Flush,(function(){var e,t,o,i,a=r.treeIndex.flush(),s=a.scrollMap,l=a.inputMap;r.fragmentParentMap.forEach((function(e,t){return r.restoreRealParent(t,e)})),r.fragmentParentMap.clear(),r.elementStateMap.clear();try{for(var c=n(s.values()),u=c.next();!u.done;u=c.next()){var f=u.value;r.applyScroll(f)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}try{for(var d=n(l.values()),p=d.next();!p.done;p=d.next()){f=p.value;r.applyInput(f)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}})),this.emitter.on(x.PlayBack,(function(){r.firstFullSnapshot=null,r.mirror.reset()}));var i=new N([],(null==t?void 0:t.speed)||o.speed);this.service=X({events:e.map((function(e){return t&&t.unpackFn?t.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(e){r.emitter.emit(x.StateChange,{player:e})})),this.speedService=L(P({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:k({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(e){r.emitter.emit(x.StateChange,{speed:e})}));var a=this.service.state.context.events.find((function(e){return e.type===g.Meta})),s=this.service.state.context.events.find((function(e){return e.type===g.FullSnapshot}));if(a){var l=a.data,c=l.width,u=l.height;setTimeout((function(){r.emitter.emit(x.Resize,{width:c,height:u})}),0)}s&&setTimeout((function(){r.firstFullSnapshot||(r.firstFullSnapshot=s,r.rebuildFullSnapshot(s),r.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1)}return Object.defineProperty(e.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.emitter.on(e,t),this},e.prototype.off=function(e,t){return this.emitter.off(e,t),this},e.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"))},e.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}},e.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},e.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},e.prototype.getMirror=function(){return this.mirror},e.prototype.play=function(e){var t;void 0===e&&(e=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}}),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(x.Start)},e.prototype.pause=function(e){var t;void 0===e&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof e&&(this.play(e),this.service.send({type:"PAUSE"})),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.Pause)},e.prototype.resume=function(e){void 0===e&&(e=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(x.Resume)},e.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},e.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},e.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},e.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},e.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,t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(T(this.iframe.contentWindow,this.iframe.contentDocument),void 0===(e=this.iframe.contentWindow)&&(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=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1}))},e.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var o=n([this.mouseTail,this.iframe]),i=o.next();!i.done;i=o.next()){var a=i.value;a&&(a.setAttribute("width",String(e.width)),a.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},e.prototype.getCastFn=function(e,t){var r,o=this;switch(void 0===t&&(t=!1),e.type){case g.DomContentLoaded:case g.Load:break;case g.Custom:r=function(){o.emitter.emit(x.CustomEvent,e)};break;case g.Meta:r=function(){return o.emitter.emit(x.Resize,{width:e.data.width,height:e.data.height})};break;case g.FullSnapshot:r=function(){if(o.firstFullSnapshot){if(o.firstFullSnapshot===e)return void(o.firstFullSnapshot=!0)}else o.firstFullSnapshot=!0;o.rebuildFullSnapshot(e,t),o.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case g.IncrementalSnapshot:r=function(){var r,i;if(o.applyIncremental(e,t),!t&&(e===o.nextUserInteractionEvent&&(o.nextUserInteractionEvent=null,o.backToNormal()),o.config.skipInactive&&!o.nextUserInteractionEvent)){try{for(var a=n(o.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(l.timestamp<=e.timestamp)&&o.isUserInteraction(l)){l.delay-e.delay>1e4*o.speedService.state.context.timer.speed&&(o.nextUserInteractionEvent=l);break}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}if(o.nextUserInteractionEvent){var c=o.nextUserInteractionEvent.delay-e.delay,u={speed:Math.min(Math.round(c/5e3),o.config.maxSpeed)};o.speedService.send({type:"FAST_FORWARD",payload:u}),o.emitter.emit(x.SkipStart,u)}}}}return function(){var i,a;r&&r();try{for(var s=n(o.config.plugins||[]),l=s.next();!l.done;l=s.next()){l.value.handler(e,t,{replayer:o})}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}o.service.send({type:"CAST_EVENT",payload:{event:e}});var c=o.service.state.context.events.length-1;if(e===o.service.state.context.events[c]){var u=function(){c<o.service.state.context.events.length-1||(o.backToNormal(),o.service.send("END"),o.emitter.emit(x.Finish))};e.type===g.IncrementalSnapshot&&e.data.source===w.MouseMove&&e.data.positions.length?setTimeout((function(){u()}),Math.max(0,50-e.data.positions[0].timeOffset)):u()}}},e.prototype.rebuildFullSnapshot=function(e,t){var r,o,i=this;if(void 0===t&&(t=!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=v(e.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}})[1];var s=function(e,t){if(l.attachDocumentToIframe(e,t),l.newDocumentQueue=l.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var r=t.contentDocument,n=r.documentElement,o=r.head;l.insertStyleRules(n,o)}},l=this;try{for(var c=n(a),u=c.next();!u.done;u=c.next()){var f=u.value;s(f.mutationInQueue,f.builtNode)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}var d=this.iframe.contentDocument,p=d.documentElement,h=d.head;this.insertStyleRules(p,h),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},e.prototype.insertStyleRules=function(e,t){var r=document.createElement("style");e.insertBefore(r,t);var n,o=(n=this.config.blockClass,["."+n+" { background: #ccc }","noscript { display: none !important; }"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused * { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)r.sheet.insertRule(o[i],i)},e.prototype.attachDocumentToIframe=function(e,t){var r,o,i=this,a=[];if(!t.contentDocument)for(var s=t.parentNode;s;){if(this.fragmentParentMap.has(s)){var l=s,c=this.fragmentParentMap.get(l);this.restoreRealParent(l,c);break}s=s.parentNode}m(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}});var u=function(e,t){if(f.attachDocumentToIframe(e,t),f.newDocumentQueue=f.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var r=t.contentDocument,n=r.documentElement,o=r.head;f.insertStyleRules(n,o)}},f=this;try{for(var d=n(a),p=d.next();!p.done;p=d.next()){var h=p.value;u(h.mutationInQueue,h.builtNode)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=d.return)&&o.call(d)}finally{if(r)throw r.error}}},e.prototype.collectIframeAndAttachDocument=function(e,t){if(W(t)){var r=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));r&&e.push({mutationInQueue:r,builtNode:t})}},e.prototype.waitForStylesheetLoad=function(){var e,t=this,r=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.head;if(r){var n,o=new Set,i=this.service.state,a=function(){i=t.service.state};this.emitter.on(x.Start,a),this.emitter.on(x.Pause,a);var s=function(){t.emitter.off(x.Start,a),t.emitter.off(x.Pause,a)};r.querySelectorAll('link[rel="stylesheet"]').forEach((function(e){e.sheet||(o.add(e),e.addEventListener("load",(function(){o.delete(e),0===o.size&&-1!==n&&(i.matches("playing")&&t.play(t.getCurrentTime()),t.emitter.emit(x.LoadStylesheetEnd),n&&window.clearTimeout(n),s())})))})),o.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(x.LoadStylesheetStart),n=window.setTimeout((function(){i.matches("playing")&&t.play(t.getCurrentTime()),n=-1,s()}),this.config.loadTimeout))}},e.prototype.preloadAllImages=function(){var e,t,r=this,o=(this.service.state,function(){r.service.state});this.emitter.on(x.Start,o),this.emitter.on(x.Pause,o);var i=0;try{for(var a=n(this.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(l.type===g.IncrementalSnapshot&&l.data.source===w.CanvasMutation&&"drawImage"===l.data.property&&"string"==typeof l.data.args[0]&&!this.imageMap.has(l)){i++;var c=document.createElement("canvas"),u=c.getContext("2d"),f=null==u?void 0:u.createImageData(c.width,c.height);null==f||f.data;JSON.parse(l.data.args[0]),null==u||u.putImageData(f,0,0)}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}0!==i&&this.service.send({type:"PAUSE"})},e.prototype.applyIncremental=function(e,t){var r,n,o=this,i=e.data;switch(i.source){case w.Mutation:t&&(i.adds.forEach((function(e){return o.treeIndex.add(e)})),i.texts.forEach((function(e){return o.treeIndex.text(e)})),i.attributes.forEach((function(e){return o.treeIndex.attribute(e)})),i.removes.forEach((function(e){return o.treeIndex.remove(e,o.mirror)}))),this.applyMutation(i,t);break;case w.Drag:case w.TouchMove:case w.MouseMove:if(t){var a=i.positions[i.positions.length-1];this.moveAndHover(i,a.x,a.y,a.id)}else i.positions.forEach((function(t){var r={doAction:function(){o.moveAndHover(i,t.x,t.y,t.id)},delay:t.timeOffset+e.timestamp-o.service.state.context.baselineTime};o.timer.addAction(r)})),this.timer.addAction({doAction:function(){},delay:e.delay-(null===(r=i.positions[0])||void 0===r?void 0:r.timeOffset)});break;case w.MouseInteraction:if(-1===i.id)break;var s=new Event(b[i.type].toLowerCase());if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);this.emitter.emit(x.MouseInteraction,{type:i.type,target:v});var l=this.config.triggerFocus;switch(i.type){case b.Blur:"blur"in v&&v.blur();break;case b.Focus:l&&v.focus;break;case b.Click:case b.TouchStart:case b.TouchEnd:t||(this.moveAndHover(i,i.x,i.y,i.id),this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active"));break;default:v.dispatchEvent(s)}break;case w.Scroll:if(-1===i.id)break;if(t){this.treeIndex.scroll(i);break}this.applyScroll(i);break;case w.ViewportResize:this.emitter.emit(x.Resize,{width:i.width,height:i.height});break;case w.Input:if(-1===i.id)break;if(t){this.treeIndex.input(i);break}this.applyInput(i);break;case w.MediaInteraction:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var c=v;try{i.currentTime&&(c.currentTime=i.currentTime),i.type===S.Pause&&c.pause(),i.type===S.Play&&c.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case w.StyleSheetRule:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var u=v,f=v.parentNode,d=this.fragmentParentMap.has(f),p=void 0;if(d){var h=this.fragmentParentMap.get(v.parentNode);p=document.createTextNode(""),f.replaceChild(p,v),h.appendChild(v)}var m=u.sheet;i.adds&&i.adds.forEach((function(e){var t=e.rule,r=e.index;try{var n=void 0===r?void 0:Math.min(r,m.rules.length);try{m.insertRule(t,n)}catch(e){}}catch(e){}})),i.removes&&i.removes.forEach((function(e){var t=e.index;try{m.deleteRule(t)}catch(e){}})),d&&p&&f.replaceChild(v,p);break;case w.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var v;if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);try{var y=v.getContext("2d");if(i.setter)return void(y[i.property]=i.args[0]);var g=y[i.property];if("drawImage"===i.property&&"string"==typeof i.args[0]){var E=this.imageMap.get(e);i.args[0]=E,g.apply(y,i.args)}else g.apply(y,i.args)}catch(e){this.warnCanvasMutationFailed(i,i.id,e)}break;case w.Font:try{var T=new FontFace(i.family,i.buffer?new Uint8Array(JSON.parse(i.fontSource)):i.fontSource,i.descriptors);null===(n=this.iframe.contentDocument)||void 0===n||n.fonts.add(T)}catch(e){this.config.showWarning&&console.warn(e)}}},e.prototype.applyMutation=function(e,o){var i,a,s=this;try{e.removes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);var n=s.mirror.getNode(t.parentId);if(!n)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&Y(n)&&(n=n.shadowRoot),s.mirror.removeNodeFromMap(r),n){var o="__sn"in n?s.fragmentParentMap.get(n):void 0;if(o&&o.contains(r))o.removeChild(r);else if(s.fragmentParentMap.has(r)){var i=s.fragmentParentMap.get(r);n.removeChild(i),s.fragmentParentMap.delete(r)}else n.removeChild(r)}}));var l=r({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var r,n;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var i=s.mirror.getNode(e.parentId);if(!i)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var a=null;s.iframe.contentDocument.contains?a=s.iframe.contentDocument.contains(i):s.iframe.contentDocument.body.contains&&(a=s.iframe.contentDocument.body.contains(i));var u=(null===(n=(r=i).getElementsByTagName)||void 0===n?void 0:n.call(r,"iframe").length)>0;if(o&&a&&!W(i)&&!u){var f=document.createDocumentFragment();for(s.mirror.map[e.parentId]=f,s.fragmentParentMap.set(f,i),s.storeState(i);i.firstChild;)f.appendChild(i.firstChild);i=f}e.node.isShadow&&Y(i)&&(i=i.shadowRoot);var d=null,p=null;if(e.previousId&&(d=s.mirror.getNode(e.previousId)),e.nextId&&(p=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var h=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(W(i))s.attachDocumentToIframe(e,i);else{var v=m(e.node,{doc:h,map:s.mirror.map,skipChild:!0,hackCss:!0});if(-1!==e.previousId&&-1!==e.nextId){if(d&&d.nextSibling&&d.nextSibling.parentNode)i.insertBefore(v,d.nextSibling);else if(p&&p.parentNode)i.contains(p)?i.insertBefore(v,p):i.insertBefore(v,null);else{if(i===h)for(;h.firstChild;)h.removeChild(h.firstChild);i.appendChild(v)}if(W(v)){var y=s.newDocumentQueue.find((function(e){return e.parentId===v.__sn.id}));if(y&&(s.attachDocumentToIframe(y,v),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==y}))),v.contentDocument){var g=v.contentDocument,w=g.documentElement,b=g.head;s.insertStyleRules(w,b)}}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,i,v,e)}else l[e.node.id]={node:v,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var f=Date.now();c.length;){var d=V(c);if(c.length=0,Date.now()-f>500){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}try{for(var p=(i=void 0,n(d)),h=p.next();!h.done;h=p.next()){var v=h.value;this.mirror.getNode(v.value.parentId)?z(v,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",v)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);for(var n in s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var o=t.attributes[n];try{null!==o?r.setAttribute(n,o):r.removeAttribute(n)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}}}))}catch(e){console.log("[ERROR applyMutation]: ",e)}},e.prototype.applyScroll=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);if(t===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:"smooth"});else try{t.scrollTop=e.y,t.scrollLeft=e.x}catch(e){}},e.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){}},e.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 f=s;c=f.node,u=f.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)}},e.prototype.moveAndHover=function(e,t,r,n){var o=this.mirror.getNode(n);if(!o)return this.debugNodeNotFound(e,n);var i=function e(t,r){var n,o,i=null===(o=null===(n=t.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===o?void 0:o.frameElement;if(!i||i===r)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=i.getBoundingClientRect(),s=e(i,r),l=a.height/i.clientHeight;return{x:a.x*s.relativeScale+s.x,y:a.y*s.relativeScale+s.y,relativeScale:l,absoluteScale:s.absoluteScale*l}}(o,this.iframe),a=t*i.absoluteScale+i.x,s=r*i.absoluteScale+i.y;this.mouse.style.left=a+"px",this.mouse.style.top=s+"px",this.drawMouseTail({x:a,y:s}),this.hoverElements(o)},e.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?H:Object.assign({},H,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)}},e.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},e.prototype.isUserInteraction=function(e){return e.type===g.IncrementalSnapshot&&(e.data.source>w.Mutation&&e.data.source<=w.Input)},e.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(x.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},e.prototype.restoreRealParent=function(e,r){this.mirror.map[r.__sn.id]=r,r.__sn.type===t.Element&&"textarea"===r.__sn.tagName&&e.textContent&&(r.value=e.textContent),r.appendChild(e),this.restoreState(r)},e.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]});var i=o.children;try{for(var a=n(Array.from(i)),s=a.next();!s.done;s=a.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},e.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var i=this.elementStateMap.get(e);i.scroll&&(o.scrollLeft=i.scroll[0],o.scrollTop=i.scroll[1]),this.elementStateMap.delete(e)}var a=o.children;try{for(var s=n(Array.from(a)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}},e.prototype.warnNodeNotFound=function(e,t){this.warn("Node with id '"+t+"' not found in",e)},e.prototype.warnCanvasMutationFailed=function(e,t,r){this.warn("Has error on update canvas '"+t+"'",e,r)},e.prototype.debugNodeNotFound=function(e,t){this.debug("[replayer]","Node with id '"+t+"' not found in",e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,i(["[replayer]"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,i(["[replayer]"],e))},e}(),q=Uint8Array,J=Uint16Array,$=Uint32Array,K=new q([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Z=new q([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ee=new q([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),te=function(e,t){for(var r=new J(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var o=new $(r[30]);for(n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)o[i]=i-r[n]<<5|n;return[r,o]},re=te(K,2),ne=re[0],oe=re[1];ne[28]=258,oe[258]=28;for(var ie=te(Z,0)[0],ae=new J(32768),se=0;se<32768;++se){var le=(43690&se)>>>1|(21845&se)<<1;le=(61680&(le=(52428&le)>>>2|(13107&le)<<2))>>>4|(3855&le)<<4,ae[se]=((65280&le)>>>8|(255&le)<<8)>>>1}var ce=function(e,t,r){for(var n=e.length,o=0,i=new J(t);o<n;++o)++i[e[o]-1];var a,s=new J(t);for(o=0;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;if(r){a=new J(1<<t);var l=15-t;for(o=0;o<n;++o)if(e[o])for(var c=o<<4|e[o],u=t-e[o],f=s[e[o]-1]++<<u,d=f|(1<<u)-1;f<=d;++f)a[ae[f]>>>l]=c}else for(a=new J(n),o=0;o<n;++o)a[o]=ae[s[e[o]-1]++]>>>15-e[o];return a},ue=new q(288);for(se=0;se<144;++se)ue[se]=8;for(se=144;se<256;++se)ue[se]=9;for(se=256;se<280;++se)ue[se]=7;for(se=280;se<288;++se)ue[se]=8;var fe=new q(32);for(se=0;se<32;++se)fe[se]=5;ce(ue,9,0);var de=ce(ue,9,1),pe=(ce(fe,5,0),ce(fe,5,1)),he=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},me=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(7&t)&r},ve=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(7&t)},ye=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof J?J:e instanceof $?$:q)(r-t);return n.set(e.subarray(t,r)),n},ge=new $(256);for(se=0;se<256;++se){for(var we=se,be=9;--be;)we=(1&we&&3988292384)^we>>>1;ge[se]=we}function Se(e,t){return function(e,t,r){var n=e.length,o=!t||r,i=!r||r.i;r||(r={}),t||(t=new q(3*n));var a=function(e){var r=t.length;if(e>r){var n=new q(Math.max(2*r,e));n.set(t),t=n}},s=r.f||0,l=r.p||0,c=r.b||0,u=r.l,f=r.d,d=r.m,p=r.n;if(s&&!u)return t;var h,m=8*n;do{if(!u){r.f=s=me(e,l,1);var v=me(e,l+1,3);if(l+=3,!v){var y=e[(I=((h=l)/8>>0)+(7&h&&1)+4)-4]|e[I-3]<<8,g=I+y;if(g>n){if(i)throw"unexpected EOF";break}o&&a(c+y),t.set(e.subarray(I,g),c),r.b=c+=y,r.p=l=8*g;continue}if(1==v)u=de,f=pe,d=9,p=5;else{if(2!=v)throw"invalid block type";var w=me(e,l,31)+257,b=me(e,l+10,15)+4,S=w+me(e,l+5,31)+1;l+=14;for(var x=new q(S),E=new q(19),T=0;T<b;++T)E[ee[T]]=me(e,l+3*T,7);l+=3*b;var M=he(E),N=(1<<M)-1;if(!i&&l+S*(M+7)>m)break;var C=ce(E,M,1);for(T=0;T<S;){var I,D=C[me(e,l,N)];if(l+=15&D,(I=D>>>4)<16)x[T++]=I;else{var k=0,A=0;for(16==I?(A=3+me(e,l,3),l+=2,k=x[T-1]):17==I?(A=3+me(e,l,7),l+=3):18==I&&(A=11+me(e,l,127),l+=7);A--;)x[T++]=k}}var _=x.subarray(0,w),F=x.subarray(w);d=he(_),p=he(F),u=ce(_,d,1),f=ce(F,p,1)}if(l>m)throw"unexpected EOF"}o&&a(c+131072);for(var O=(1<<d)-1,P=(1<<p)-1,R=d+p+18;i||l+R<m;){var L=(k=u[ve(e,l)&O])>>>4;if((l+=15&k)>m)throw"unexpected EOF";if(!k)throw"invalid length/literal";if(L<256)t[c++]=L;else{if(256==L){u=null;break}var B=L-254;if(L>264){var j=K[T=L-257];B=me(e,l,(1<<j)-1)+ne[T],l+=j}var U=f[ve(e,l)&P],V=U>>>4;if(!U)throw"invalid distance";l+=15&U;F=ie[V];if(V>3){j=Z[V];F+=ve(e,l)&(1<<j)-1,l+=j}if(l>m)throw"unexpected EOF";o&&a(c+131072);for(var z=c+B;c<z;c+=4)t[c]=t[c-F],t[c+1]=t[c+1-F],t[c+2]=t[c+2-F],t[c+3]=t[c+3-F];c=z}}r.l=u,r.p=l,r.b=c,u&&(s=1,r.m=d,r.d=f,r.n=p)}while(!s);return c==t.length?t:ye(t,0,c)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}return e.Replayer=G,e.unpack=function(e){if("string"!=typeof e)return e;try{if((t=JSON.parse(e)).timestamp)return t}catch(e){}try{var t;if("v1"===(t=JSON.parse(function(e,t){var r="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;n<e.length;){var o=e[n++];o<128||t?r+=String.fromCharCode(o):o<224?r+=String.fromCharCode((31&o)<<6|63&e[n++]):o<240?r+=String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}return r}(Se(function(e,t){var r=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new q(e.length+(e.length>>>1)),o=0,i=function(e){n[o++]=e},a=0;a<r;++a){if(o+5>n.length){var s=new q(o+8+(r-a<<1));s.set(n),n=s}var l=e.charCodeAt(a);l<128||t?i(l):l<2048?(i(192|l>>>6),i(128|63&l)):l>55295&&l<57344?(i(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),i(128|l>>>12&63),i(128|l>>>6&63),i(128|63&l)):(i(224|l>>>12),i(128|l>>>6&63),i(128|63&l))}return ye(n,0,o)}(e,!0))))).v)return t;throw new Error("These events were packed with packer "+t.v+" which is incompatible with current packer v1.")}catch(e){throw console.error(e),new Error("Unknown data format.")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
***************************************************************************** */!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(M||(M={}));var I={type:"xstate.init"};function D(e){return void 0===e?[]:[].concat(e)}function k(e){return{type:"xstate.assign",assignment:e}}function A(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 _(e){return function(t){return e===t}}function F(e){return"string"==typeof e?{type:e}:e}function O(e,t){return{value:e,context:t,actions:[],changed:!1,matches:_(e)}}function R(e,t){void 0===t&&(t={});var r={config:e,_options:t,initialState:{value:e.initial,actions:D(e.states[e.initial].entry).map((function(e){return A(e,t.actions)})),context:e.context,matches:_(e.initial)},transition:function(t,n){var o,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=F(n),u=e.states[s];if(u.on){var f=D(u.on[c.type]),d=function(t){if(void 0===t)return{value:O(s,l)};var n="string"==typeof t?{target:t}:t,o=n.target,i=void 0===o?s:o,a=n.actions,f=void 0===a?[]:a,d=n.cond,p=l;if((void 0===d?function(){return!0}:d)(l,c)){var h=e.states[i],m=!1,v=[].concat(u.exit,f,h.entry).filter((function(e){return e})).map((function(e){return A(e,r._options.actions)})).filter((function(e){if("xstate.assign"===e.type){m=!0;var t=Object.assign({},p);return"function"==typeof e.assignment?t=e.assignment(p,c):Object.keys(e.assignment).forEach((function(r){t[r]="function"==typeof e.assignment[r]?e.assignment[r](p,c):e.assignment[r]})),p=t,!1}return!0}));return{value:{value:i,context:p,actions:v,changed:i!==s||v.length>0||m,matches:_(i)}}}};try{for(var p=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}(f),h=p.next();!h.done;h=p.next()){var m=d(h.value);if("object"==typeof m)return m.value}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}}return O(s,l)}};return r}var P=function(e,t){return e.actions.forEach((function(r){var n=r.exec;return n&&n(e.context,t)}))};function L(e){var t=e.initialState,r=M.NotStarted,n=new Set,o={_machine:e,send:function(o){r===M.Running&&(t=e.transition(t,o),P(t,F(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:_(i.value)}}return r=M.Running,P(t,I),o},stop:function(){return r=M.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}var B="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",j={map:{},getId:function(){return console.error(B),-1},getNode:function(){return console.error(B),null},removeNodeFromMap:function(){console.error(B)},has:function(){return console.error(B),!1},reset:function(){console.error(B)}};"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:function(e,t,r){return"map"===t&&console.error(B),Reflect.get(e,t,r)}}));var U=function(){function e(){this.reset()}return e.prototype.add=function(e){var t=this.indexes.get(e.parentId),r={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(r.parent=t,t.children[r.id]=r):this.tree[r.id]=r,this.indexes.set(r.id,r)},e.prototype.remove=function(e,t){var r=this,n=this.indexes.get(e.parentId),o=this.indexes.get(e.id),i=function(e){r.removeIdSet.add(e);var n=t.getNode(e);null==n||n.childNodes.forEach((function(e){"__sn"in e&&i(e.__sn.id)}))},a=function(t){r.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return a(e)}));var n=r.indexes.get(t.id);if(n){var o=n.parent;o&&(delete n.parent,delete o.children[n.id],r.indexes.delete(e.id))}};o?n?(delete o.parent,delete n.children[o.id],this.indexes.delete(e.id),a(o)):(delete this.tree[o.id],this.indexes.delete(o.id),a(o)):(this.removeNodeMutations.push(e),i(e.id))},e.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},e.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},e.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},e.prototype.input=function(e){this.inputMap.set(e.id,e)},e.prototype.flush=function(){var e,t,r,o,i=this,a=this.tree,s=this.removeNodeMutations,l=this.textMutations,c=this.attributeMutations,u={source:w.Mutation,removes:s,texts:l,attributes:c,adds:[]},f=function(e,t){t&&i.removeIdSet.add(e.id),u.texts=u.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),u.attributes=u.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return f(e,!0)})):(u.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return f(e,!1)})))};Object.values(a).forEach((function(e){return f(e,!1)}));try{for(var d=n(this.scrollMap.keys()),p=d.next();!p.done;p=d.next()){var h=p.value;this.removeIdSet.has(h)&&this.scrollMap.delete(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var m=n(this.inputMap.keys()),v=m.next();!v.done;v=m.next()){h=v.value;this.removeIdSet.has(h)&&this.inputMap.delete(h)}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}var y=new Map(this.scrollMap),g=new Map(this.inputMap);return this.reset(),{mutationData:u,scrollMap:y,inputMap:g}},e.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},e}();function V(e){var t,r,o={},i=function(e,t){var r={value:e,parent:t,children:[]};return o[e.node.id]=r,r},a=[];try{for(var s=n(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,f=c.parentId;if(u&&u in o){var d=o[u];if(d.parent){var p=d.parent.children.indexOf(d);d.parent.children.splice(p,0,i(c,d.parent))}else{p=a.indexOf(d);a.splice(p,0,i(c,null))}}else if(f in o){var h=o[f];h.children.push(i(c,h))}else a.push(i(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return a}function z(e,t){t(e.value);for(var r=e.children.length-1;r>=0;r--)z(e.children[r],t)}function W(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function Y(e){var t;return Boolean(null===(t=e)||void 0===t?void 0:t.shadowRoot)}function X(e,t){var o=t.getCastFn,i=t.emitter;return L(R({id:"player",context:e,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"]}}},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"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:k({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:k((function(e,t){var n=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(n=t.payload.timeOffset),r(r({},e),{timeOffset:n,baselineTime:e.events[0].timestamp+n})})),play:function(e){var t,r,a,s,l,c=e.timer,u=e.events,f=e.baselineTime,d=e.lastPlayedEvent;c.clear();try{for(var p=n(u),h=p.next();!h.done;h=p.next()){C(h.value,f)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}var m=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r];if(n.type===g.Meta&&n.timestamp<=t)return e.slice(r)}return e}(u,f),v=null==d?void 0:d.timestamp;(null==d?void 0:d.type)===g.IncrementalSnapshot&&d.data.source===w.MouseMove&&(v=d.timestamp+(null===(l=d.data.positions[0])||void 0===l?void 0:l.timeOffset)),f<(v||0)&&i.emit(x.PlayBack);var y=new Array,b=function(e){if(v&&v<f&&(e.timestamp<=v||e===d))return"continue";var t=e.timestamp<f;if(t&&!function(e){switch(e.type){case g.DomContentLoaded:case g.Load:case g.Custom:return!1;case g.FullSnapshot:case g.Meta:case g.Plugin:return!0}switch(e.data.source){case w.MouseMove:case w.MouseInteraction:case w.TouchMove:case w.MediaInteraction:return!1;case w.ViewportResize:case w.StyleSheetRule:case w.Scroll:case w.Input:return!0}return!0}(e))return"continue";var r=o(e,t);t?r():y.push({doAction:function(){r(),i.emit(x.EventCast,e)},delay:e.delay})};try{for(var S=n(m),E=S.next();!E.done;E=S.next()){b(E.value)}}catch(e){a={error:e}}finally{try{E&&!E.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}i.emit(x.Flush),c.addActions(y),c.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:k((function(e){return r(r({},e),{lastPlayedEvent:null})})),startLive:k({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:k((function(e,t){var n=e.baselineTime,a=e.timer,s=e.events;if("ADD_EVENT"===t.type){var l=t.payload.event;C(l,n);var c=s.length-1;if(!s[c]||s[c].timestamp<=l.timestamp)s.push(l);else{for(var u=-1,f=0;f<=c;){var d=Math.floor((f+c)/2);s[d].timestamp<=l.timestamp?f=d+1:c=d-1}-1===u&&(u=f),s.splice(u,0,l)}var p=l.timestamp<n,h=o(l,p);p?h():a.isActive()&&a.addAction({doAction:function(){h(),i.emit(x.EventCast,l)},delay:l.delay})}return r(r({},e),{events:s})}))}}))}var Q=y||E,H={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"},G=function(){function e(e,t){var r=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Q(),this.legacy_missingNodeRetryMap={},this.imageMap=new Map,this.mirror={map:{},getId:function(e){return 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=[],!(null==t?void 0:t.liveMode)&&e.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:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:H};this.config=Object.assign({},o,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(x.Resize,this.handleResize),this.setupDom(),this.treeIndex=new U,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.emitter.on(x.Flush,(function(){var e,t,o,i,a=r.treeIndex.flush(),s=a.scrollMap,l=a.inputMap;r.fragmentParentMap.forEach((function(e,t){return r.restoreRealParent(t,e)})),r.fragmentParentMap.clear(),r.elementStateMap.clear();try{for(var c=n(s.values()),u=c.next();!u.done;u=c.next()){var f=u.value;r.applyScroll(f)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}try{for(var d=n(l.values()),p=d.next();!p.done;p=d.next()){f=p.value;r.applyInput(f)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}})),this.emitter.on(x.PlayBack,(function(){r.firstFullSnapshot=null,r.mirror.reset()}));var i=new N([],(null==t?void 0:t.speed)||o.speed);this.service=X({events:e.map((function(e){return t&&t.unpackFn?t.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(e){r.emitter.emit(x.StateChange,{player:e})})),this.speedService=L(R({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:k({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(e){r.emitter.emit(x.StateChange,{speed:e})}));var a=this.service.state.context.events.find((function(e){return e.type===g.Meta})),s=this.service.state.context.events.find((function(e){return e.type===g.FullSnapshot}));if(a){var l=a.data,c=l.width,u=l.height;setTimeout((function(){r.emitter.emit(x.Resize,{width:c,height:u})}),0)}s&&setTimeout((function(){r.firstFullSnapshot||(r.firstFullSnapshot=s,r.rebuildFullSnapshot(s),r.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1)}return Object.defineProperty(e.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.emitter.on(e,t),this},e.prototype.off=function(e,t){return this.emitter.off(e,t),this},e.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"))},e.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}},e.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},e.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},e.prototype.getMirror=function(){return this.mirror},e.prototype.play=function(e){var t;void 0===e&&(e=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}}),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(x.Start)},e.prototype.pause=function(e){var t;void 0===e&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof e&&(this.play(e),this.service.send({type:"PAUSE"})),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.Pause)},e.prototype.resume=function(e){void 0===e&&(e=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(x.Resume)},e.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},e.prototype.addEvent=function(e){var t=this,r=this.config.unpackFn?this.config.unpackFn(e):e;Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:r}})}))},e.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},e.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},e.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,t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(T(this.iframe.contentWindow,this.iframe.contentDocument),void 0===(e=this.iframe.contentWindow)&&(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=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1}))},e.prototype.handleResize=function(e){var t,r;this.iframe.style.display="inherit";try{for(var o=n([this.mouseTail,this.iframe]),i=o.next();!i.done;i=o.next()){var a=i.value;a&&(a.setAttribute("width",String(e.width)),a.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},e.prototype.getCastFn=function(e,t){var r=this;void 0===t&&(t=!1);try{var o;switch(e.type){case g.DomContentLoaded:case g.Load:break;case g.Custom:o=function(){r.emitter.emit(x.CustomEvent,e)};break;case g.Meta:o=function(){return r.emitter.emit(x.Resize,{width:e.data.width,height:e.data.height})};break;case g.FullSnapshot:o=function(){if(r.firstFullSnapshot){if(r.firstFullSnapshot===e)return void(r.firstFullSnapshot=!0)}else r.firstFullSnapshot=!0;r.rebuildFullSnapshot(e,t),r.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case g.IncrementalSnapshot:o=function(){var o,i;if(r.applyIncremental(e,t),!t&&(e===r.nextUserInteractionEvent&&(r.nextUserInteractionEvent=null,r.backToNormal()),r.config.skipInactive&&!r.nextUserInteractionEvent)){try{for(var a=n(r.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(l.timestamp<=e.timestamp)&&r.isUserInteraction(l)){l.delay-e.delay>1e4*r.speedService.state.context.timer.speed&&(r.nextUserInteractionEvent=l);break}}}catch(e){o={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}if(r.nextUserInteractionEvent){var c=r.nextUserInteractionEvent.delay-e.delay,u={speed:Math.min(Math.round(c/5e3),r.config.maxSpeed)};r.speedService.send({type:"FAST_FORWARD",payload:u}),r.emitter.emit(x.SkipStart,u)}}}}return function(){var i,a;o&&o();try{for(var s=n(r.config.plugins||[]),l=s.next();!l.done;l=s.next()){l.value.handler(e,t,{replayer:r})}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}r.service.send({type:"CAST_EVENT",payload:{event:e}});var c=r.service.state.context.events.length-1;if(e===r.service.state.context.events[c]){var u=function(){c<r.service.state.context.events.length-1||(r.backToNormal(),r.service.send("END"),r.emitter.emit(x.Finish))};e.type===g.IncrementalSnapshot&&e.data.source===w.MouseMove&&e.data.positions.length?setTimeout((function(){u()}),Math.max(0,50-e.data.positions[0].timeOffset)):u()}}}catch(e){console.log("[ERROR getCastFn]: ",e)}},e.prototype.rebuildFullSnapshot=function(e,t){var r,o,i=this;if(void 0===t&&(t=!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=v(e.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}})[1];var s=function(e,t){if(l.attachDocumentToIframe(e,t),l.newDocumentQueue=l.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var r=t.contentDocument,n=r.documentElement,o=r.head;l.insertStyleRules(n,o)}},l=this;try{for(var c=n(a),u=c.next();!u.done;u=c.next()){var f=u.value;s(f.mutationInQueue,f.builtNode)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}var d=this.iframe.contentDocument,p=d.documentElement,h=d.head;this.insertStyleRules(p,h),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},e.prototype.insertStyleRules=function(e,t){var r=document.createElement("style");e.insertBefore(r,t);var n,o=(n=this.config.blockClass,["."+n+" { background: #ccc }","noscript { display: none !important; }"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused * { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)r.sheet.insertRule(o[i],i)},e.prototype.attachDocumentToIframe=function(e,t){var r,o,i=this,a=[];if(!t.contentDocument)for(var s=t.parentNode;s;){if(this.fragmentParentMap.has(s)){var l=s,c=this.fragmentParentMap.get(l);this.restoreRealParent(l,c);break}s=s.parentNode}m(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}});var u=function(e,t){if(f.attachDocumentToIframe(e,t),f.newDocumentQueue=f.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var r=t.contentDocument,n=r.documentElement,o=r.head;f.insertStyleRules(n,o)}},f=this;try{for(var d=n(a),p=d.next();!p.done;p=d.next()){var h=p.value;u(h.mutationInQueue,h.builtNode)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=d.return)&&o.call(d)}finally{if(r)throw r.error}}},e.prototype.collectIframeAndAttachDocument=function(e,t){if(W(t)){var r=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));r&&e.push({mutationInQueue:r,builtNode:t})}},e.prototype.waitForStylesheetLoad=function(){var e,t=this,r=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.head;if(r){var n,o=new Set,i=this.service.state,a=function(){i=t.service.state};this.emitter.on(x.Start,a),this.emitter.on(x.Pause,a);var s=function(){t.emitter.off(x.Start,a),t.emitter.off(x.Pause,a)};r.querySelectorAll('link[rel="stylesheet"]').forEach((function(e){e.sheet||(o.add(e),e.addEventListener("load",(function(){o.delete(e),0===o.size&&-1!==n&&(i.matches("playing")&&t.play(t.getCurrentTime()),t.emitter.emit(x.LoadStylesheetEnd),n&&window.clearTimeout(n),s())})))})),o.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(x.LoadStylesheetStart),n=window.setTimeout((function(){i.matches("playing")&&t.play(t.getCurrentTime()),n=-1,s()}),this.config.loadTimeout))}},e.prototype.preloadAllImages=function(){var e,t,r=this,o=(this.service.state,function(){r.service.state});this.emitter.on(x.Start,o),this.emitter.on(x.Pause,o);var i=0;try{for(var a=n(this.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(l.type===g.IncrementalSnapshot&&l.data.source===w.CanvasMutation&&"drawImage"===l.data.property&&"string"==typeof l.data.args[0]&&!this.imageMap.has(l)){i++;var c=document.createElement("canvas"),u=c.getContext("2d"),f=null==u?void 0:u.createImageData(c.width,c.height);null==f||f.data;JSON.parse(l.data.args[0]),null==u||u.putImageData(f,0,0)}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}0!==i&&this.service.send({type:"PAUSE"})},e.prototype.applyIncremental=function(e,t){var r,n,o=this,i=e.data;switch(i.source){case w.Mutation:t&&(i.adds.forEach((function(e){return o.treeIndex.add(e)})),i.texts.forEach((function(e){return o.treeIndex.text(e)})),i.attributes.forEach((function(e){return o.treeIndex.attribute(e)})),i.removes.forEach((function(e){return o.treeIndex.remove(e,o.mirror)}))),this.applyMutation(i,t);break;case w.Drag:case w.TouchMove:case w.MouseMove:if(t){var a=i.positions[i.positions.length-1];this.moveAndHover(i,a.x,a.y,a.id)}else i.positions.forEach((function(t){var r={doAction:function(){o.moveAndHover(i,t.x,t.y,t.id)},delay:t.timeOffset+e.timestamp-o.service.state.context.baselineTime};o.timer.addAction(r)})),this.timer.addAction({doAction:function(){},delay:e.delay-(null===(r=i.positions[0])||void 0===r?void 0:r.timeOffset)});break;case w.MouseInteraction:if(-1===i.id)break;var s=new Event(b[i.type].toLowerCase());if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);this.emitter.emit(x.MouseInteraction,{type:i.type,target:v});var l=this.config.triggerFocus;switch(i.type){case b.Blur:"blur"in v&&v.blur();break;case b.Focus:l&&v.focus;break;case b.Click:case b.TouchStart:case b.TouchEnd:t||(this.moveAndHover(i,i.x,i.y,i.id),this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active"));break;default:v.dispatchEvent(s)}break;case w.Scroll:if(-1===i.id)break;if(t){this.treeIndex.scroll(i);break}this.applyScroll(i);break;case w.ViewportResize:this.emitter.emit(x.Resize,{width:i.width,height:i.height});break;case w.Input:if(-1===i.id)break;if(t){this.treeIndex.input(i);break}this.applyInput(i);break;case w.MediaInteraction:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var c=v;try{i.currentTime&&(c.currentTime=i.currentTime),i.type===S.Pause&&c.pause(),i.type===S.Play&&c.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case w.StyleSheetRule:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var u=v,f=v.parentNode,d=this.fragmentParentMap.has(f),p=void 0;if(d){var h=this.fragmentParentMap.get(v.parentNode);p=document.createTextNode(""),f.replaceChild(p,v),h.appendChild(v)}var m=u.sheet;i.adds&&i.adds.forEach((function(e){var t=e.rule,r=e.index;try{var n=void 0===r?void 0:Math.min(r,m.rules.length);try{m.insertRule(t,n)}catch(e){}}catch(e){}})),i.removes&&i.removes.forEach((function(e){var t=e.index;try{m.deleteRule(t)}catch(e){}})),d&&p&&f.replaceChild(v,p);break;case w.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var v;if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);try{var y=v.getContext("2d");if(i.setter)return void(y[i.property]=i.args[0]);var g=y[i.property];if("drawImage"===i.property&&"string"==typeof i.args[0]){var E=this.imageMap.get(e);i.args[0]=E,g.apply(y,i.args)}else g.apply(y,i.args)}catch(e){this.warnCanvasMutationFailed(i,i.id,e)}break;case w.Font:try{var T=new FontFace(i.family,i.buffer?new Uint8Array(JSON.parse(i.fontSource)):i.fontSource,i.descriptors);null===(n=this.iframe.contentDocument)||void 0===n||n.fonts.add(T)}catch(e){this.config.showWarning&&console.warn(e)}}},e.prototype.applyMutation=function(e,o){var i,a,s=this;try{e.removes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);var n=s.mirror.getNode(t.parentId);if(!n)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&Y(n)&&(n=n.shadowRoot),s.mirror.removeNodeFromMap(r),n){var o="__sn"in n?s.fragmentParentMap.get(n):void 0;if(o&&o.contains(r))o.removeChild(r);else if(s.fragmentParentMap.has(r)){var i=s.fragmentParentMap.get(r);n.removeChild(i),s.fragmentParentMap.delete(r)}else n.removeChild(r)}}));var l=r({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var r,n;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var i=s.mirror.getNode(e.parentId);if(!i)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var a=null;s.iframe.contentDocument.contains?a=s.iframe.contentDocument.contains(i):s.iframe.contentDocument.body.contains&&(a=s.iframe.contentDocument.body.contains(i));var u=(null===(n=(r=i).getElementsByTagName)||void 0===n?void 0:n.call(r,"iframe").length)>0;if(o&&a&&!W(i)&&!u){var f=document.createDocumentFragment();for(s.mirror.map[e.parentId]=f,s.fragmentParentMap.set(f,i),s.storeState(i);i.firstChild;)f.appendChild(i.firstChild);i=f}e.node.isShadow&&Y(i)&&(i=i.shadowRoot);var d=null,p=null;if(e.previousId&&(d=s.mirror.getNode(e.previousId)),e.nextId&&(p=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var h=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(W(i))s.attachDocumentToIframe(e,i);else{var v=m(e.node,{doc:h,map:s.mirror.map,skipChild:!0,hackCss:!0});if(-1!==e.previousId&&-1!==e.nextId){if(d&&d.nextSibling&&d.nextSibling.parentNode)i.insertBefore(v,d.nextSibling);else if(p&&p.parentNode)i.contains(p)?i.insertBefore(v,p):i.insertBefore(v,null);else{if(i===h)for(;h.firstChild;)h.removeChild(h.firstChild);i.appendChild(v)}if(W(v)){var y=s.newDocumentQueue.find((function(e){return e.parentId===v.__sn.id}));if(y&&(s.attachDocumentToIframe(y,v),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==y}))),v.contentDocument){var g=v.contentDocument,w=g.documentElement,b=g.head;s.insertStyleRules(w,b)}}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,i,v,e)}else l[e.node.id]={node:v,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var f=Date.now();c.length;){var d=V(c);if(c.length=0,Date.now()-f>500){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}try{for(var p=(i=void 0,n(d)),h=p.next();!h.done;h=p.next()){var v=h.value;this.mirror.getNode(v.value.parentId)?z(v,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",v)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),r.textContent=t.value})),e.attributes.forEach((function(t){var r=s.mirror.getNode(t.id);if(!r)return s.warnNodeNotFound(e,t.id);for(var n in s.fragmentParentMap.has(r)&&(r=s.fragmentParentMap.get(r)),t.attributes)if("string"==typeof n){var o=t.attributes[n];try{null!==o?r.setAttribute(n,o):r.removeAttribute(n)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}}}))}catch(e){console.log("[ERROR applyMutation]: ",e)}},e.prototype.applyScroll=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);if(t===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:"smooth"});else try{t.scrollTop=e.y,t.scrollLeft=e.x}catch(e){}},e.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){}},e.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 f=s;c=f.node,u=f.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)}},e.prototype.moveAndHover=function(e,t,r,n){var o=this.mirror.getNode(n);if(!o)return this.debugNodeNotFound(e,n);var i=function e(t,r){var n,o,i=null===(o=null===(n=t.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===o?void 0:o.frameElement;if(!i||i===r)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=i.getBoundingClientRect(),s=e(i,r),l=a.height/i.clientHeight;return{x:a.x*s.relativeScale+s.x,y:a.y*s.relativeScale+s.y,relativeScale:l,absoluteScale:s.absoluteScale*l}}(o,this.iframe),a=t*i.absoluteScale+i.x,s=r*i.absoluteScale+i.y;this.mouse.style.left=a+"px",this.mouse.style.top=s+"px",this.drawMouseTail({x:a,y:s}),this.hoverElements(o)},e.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var r=!0===this.config.mouseTail?H:Object.assign({},H,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)}},e.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},e.prototype.isUserInteraction=function(e){return e.type===g.IncrementalSnapshot&&(e.data.source>w.Mutation&&e.data.source<=w.Input)},e.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(x.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},e.prototype.restoreRealParent=function(e,r){this.mirror.map[r.__sn.id]=r,r.__sn.type===t.Element&&"textarea"===r.__sn.tagName&&e.textContent&&(r.value=e.textContent),r.appendChild(e),this.restoreState(r)},e.prototype.storeState=function(e){var t,r;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]});var i=o.children;try{for(var a=n(Array.from(i)),s=a.next();!s.done;s=a.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},e.prototype.restoreState=function(e){var t,r;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var i=this.elementStateMap.get(e);i.scroll&&(o.scrollLeft=i.scroll[0],o.scrollTop=i.scroll[1]),this.elementStateMap.delete(e)}var a=o.children;try{for(var s=n(Array.from(a)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}},e.prototype.warnNodeNotFound=function(e,t){this.warn("Node with id '"+t+"' not found in",e)},e.prototype.warnCanvasMutationFailed=function(e,t,r){this.warn("Has error on update canvas '"+t+"'",e,r)},e.prototype.debugNodeNotFound=function(e,t){this.debug("[replayer]","Node with id '"+t+"' not found in",e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,i(["[replayer]"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,i(["[replayer]"],e))},e}(),q=Uint8Array,J=Uint16Array,$=Uint32Array,K=new q([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Z=new q([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ee=new q([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),te=function(e,t){for(var r=new J(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var o=new $(r[30]);for(n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)o[i]=i-r[n]<<5|n;return[r,o]},re=te(K,2),ne=re[0],oe=re[1];ne[28]=258,oe[258]=28;for(var ie=te(Z,0)[0],ae=new J(32768),se=0;se<32768;++se){var le=(43690&se)>>>1|(21845&se)<<1;le=(61680&(le=(52428&le)>>>2|(13107&le)<<2))>>>4|(3855&le)<<4,ae[se]=((65280&le)>>>8|(255&le)<<8)>>>1}var ce=function(e,t,r){for(var n=e.length,o=0,i=new J(t);o<n;++o)++i[e[o]-1];var a,s=new J(t);for(o=0;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;if(r){a=new J(1<<t);var l=15-t;for(o=0;o<n;++o)if(e[o])for(var c=o<<4|e[o],u=t-e[o],f=s[e[o]-1]++<<u,d=f|(1<<u)-1;f<=d;++f)a[ae[f]>>>l]=c}else for(a=new J(n),o=0;o<n;++o)a[o]=ae[s[e[o]-1]++]>>>15-e[o];return a},ue=new q(288);for(se=0;se<144;++se)ue[se]=8;for(se=144;se<256;++se)ue[se]=9;for(se=256;se<280;++se)ue[se]=7;for(se=280;se<288;++se)ue[se]=8;var fe=new q(32);for(se=0;se<32;++se)fe[se]=5;ce(ue,9,0);var de=ce(ue,9,1),pe=(ce(fe,5,0),ce(fe,5,1)),he=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},me=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(7&t)&r},ve=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(7&t)},ye=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof J?J:e instanceof $?$:q)(r-t);return n.set(e.subarray(t,r)),n},ge=new $(256);for(se=0;se<256;++se){for(var we=se,be=9;--be;)we=(1&we&&3988292384)^we>>>1;ge[se]=we}function Se(e,t){return function(e,t,r){var n=e.length,o=!t||r,i=!r||r.i;r||(r={}),t||(t=new q(3*n));var a=function(e){var r=t.length;if(e>r){var n=new q(Math.max(2*r,e));n.set(t),t=n}},s=r.f||0,l=r.p||0,c=r.b||0,u=r.l,f=r.d,d=r.m,p=r.n;if(s&&!u)return t;var h,m=8*n;do{if(!u){r.f=s=me(e,l,1);var v=me(e,l+1,3);if(l+=3,!v){var y=e[(I=((h=l)/8>>0)+(7&h&&1)+4)-4]|e[I-3]<<8,g=I+y;if(g>n){if(i)throw"unexpected EOF";break}o&&a(c+y),t.set(e.subarray(I,g),c),r.b=c+=y,r.p=l=8*g;continue}if(1==v)u=de,f=pe,d=9,p=5;else{if(2!=v)throw"invalid block type";var w=me(e,l,31)+257,b=me(e,l+10,15)+4,S=w+me(e,l+5,31)+1;l+=14;for(var x=new q(S),E=new q(19),T=0;T<b;++T)E[ee[T]]=me(e,l+3*T,7);l+=3*b;var M=he(E),N=(1<<M)-1;if(!i&&l+S*(M+7)>m)break;var C=ce(E,M,1);for(T=0;T<S;){var I,D=C[me(e,l,N)];if(l+=15&D,(I=D>>>4)<16)x[T++]=I;else{var k=0,A=0;for(16==I?(A=3+me(e,l,3),l+=2,k=x[T-1]):17==I?(A=3+me(e,l,7),l+=3):18==I&&(A=11+me(e,l,127),l+=7);A--;)x[T++]=k}}var _=x.subarray(0,w),F=x.subarray(w);d=he(_),p=he(F),u=ce(_,d,1),f=ce(F,p,1)}if(l>m)throw"unexpected EOF"}o&&a(c+131072);for(var O=(1<<d)-1,R=(1<<p)-1,P=d+p+18;i||l+P<m;){var L=(k=u[ve(e,l)&O])>>>4;if((l+=15&k)>m)throw"unexpected EOF";if(!k)throw"invalid length/literal";if(L<256)t[c++]=L;else{if(256==L){u=null;break}var B=L-254;if(L>264){var j=K[T=L-257];B=me(e,l,(1<<j)-1)+ne[T],l+=j}var U=f[ve(e,l)&R],V=U>>>4;if(!U)throw"invalid distance";l+=15&U;F=ie[V];if(V>3){j=Z[V];F+=ve(e,l)&(1<<j)-1,l+=j}if(l>m)throw"unexpected EOF";o&&a(c+131072);for(var z=c+B;c<z;c+=4)t[c]=t[c-F],t[c+1]=t[c+1-F],t[c+2]=t[c+2-F],t[c+3]=t[c+3-F];c=z}}r.l=u,r.p=l,r.b=c,u&&(s=1,r.m=d,r.d=f,r.n=p)}while(!s);return c==t.length?t:ye(t,0,c)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}return e.Replayer=G,e.unpack=function(e){if("string"!=typeof e)return e;try{if((t=JSON.parse(e)).timestamp)return t}catch(e){}try{var t;if("v1"===(t=JSON.parse(function(e,t){var r="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;n<e.length;){var o=e[n++];o<128||t?r+=String.fromCharCode(o):o<224?r+=String.fromCharCode((31&o)<<6|63&e[n++]):o<240?r+=String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}return r}(Se(function(e,t){var r=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new q(e.length+(e.length>>>1)),o=0,i=function(e){n[o++]=e},a=0;a<r;++a){if(o+5>n.length){var s=new q(o+8+(r-a<<1));s.set(n),n=s}var l=e.charCodeAt(a);l<128||t?i(l):l<2048?(i(192|l>>>6),i(128|63&l)):l>55295&&l<57344?(i(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),i(128|l>>>12&63),i(128|l>>>6&63),i(128|63&l)):(i(224|l>>>12),i(128|l>>>6&63),i(128|63&l))}return ye(n,0,o)}(e,!0))))).v)return t;throw new Error("These events were packed with packer "+t.v+" which is incompatible with current packer v1.")}catch(e){throw console.error(e),new Error("Unknown data format.")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=rrweb-replay-unpack.min.js.map |
@@ -29,3 +29,3 @@ var rrwebReplay=function(e){"use strict"; | ||
and limitations under the License. | ||
***************************************************************************** */!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(M||(M={}));var C={type:"xstate.init"};function D(e){return void 0===e?[]:[].concat(e)}function A(e){return{type:"xstate.assign",assignment:e}}function k(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 _(e){return function(t){return e===t}}function F(e){return"string"==typeof e?{type:e}:e}function O(e,t){return{value:e,context:t,actions:[],changed:!1,matches:_(e)}}function P(e,t){void 0===t&&(t={});var n={config:e,_options:t,initialState:{value:e.initial,actions:D(e.states[e.initial].entry).map((function(e){return k(e,t.actions)})),context:e.context,matches:_(e.initial)},transition:function(t,r){var o,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=F(r),u=e.states[s];if(u.on){var d=D(u.on[c.type]),f=function(t){if(void 0===t)return{value:O(s,l)};var r="string"==typeof t?{target:t}:t,o=r.target,i=void 0===o?s:o,a=r.actions,d=void 0===a?[]:a,f=r.cond,p=l;if((void 0===f?function(){return!0}:f)(l,c)){var h=e.states[i],m=!1,v=[].concat(u.exit,d,h.entry).filter((function(e){return e})).map((function(e){return k(e,n._options.actions)})).filter((function(e){if("xstate.assign"===e.type){m=!0;var t=Object.assign({},p);return"function"==typeof e.assignment?t=e.assignment(p,c):Object.keys(e.assignment).forEach((function(n){t[n]="function"==typeof e.assignment[n]?e.assignment[n](p,c):e.assignment[n]})),p=t,!1}return!0}));return{value:{value:i,context:p,actions:v,changed:i!==s||v.length>0||m,matches:_(i)}}}};try{for(var p=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(d),h=p.next();!h.done;h=p.next()){var m=f(h.value);if("object"==typeof m)return m.value}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}}return O(s,l)}};return n}var R=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};function L(e){var t=e.initialState,n=M.NotStarted,r=new Set,o={_machine:e,send:function(o){n===M.Running&&(t=e.transition(t,o),R(t,F(o)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(r){if(r){var i="object"==typeof r?r:{context:e.config.context,value:r};t={value:i.value,actions:[],context:i.context,matches:_(i.value)}}return n=M.Running,R(t,C),o},stop:function(){return n=M.Stopped,r.clear(),o},get state(){return t},get status(){return n}};return o}var B="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",j={map:{},getId:function(){return console.error(B),-1},getNode:function(){return console.error(B),null},removeNodeFromMap:function(){console.error(B)},has:function(){return console.error(B),!1},reset:function(){console.error(B)}};"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:function(e,t,n){return"map"===t&&console.error(B),Reflect.get(e,t,n)}}));var V=function(){function e(){this.reset()}return e.prototype.add=function(e){var t=this.indexes.get(e.parentId),n={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(n.parent=t,t.children[n.id]=n):this.tree[n.id]=n,this.indexes.set(n.id,n)},e.prototype.remove=function(e,t){var n=this,r=this.indexes.get(e.parentId),o=this.indexes.get(e.id),i=function(e){n.removeIdSet.add(e);var r=t.getNode(e);null==r||r.childNodes.forEach((function(e){"__sn"in e&&i(e.__sn.id)}))},a=function(t){n.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return a(e)}));var r=n.indexes.get(t.id);if(r){var o=r.parent;o&&(delete r.parent,delete o.children[r.id],n.indexes.delete(e.id))}};o?r?(delete o.parent,delete r.children[o.id],this.indexes.delete(e.id),a(o)):(delete this.tree[o.id],this.indexes.delete(o.id),a(o)):(this.removeNodeMutations.push(e),i(e.id))},e.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},e.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},e.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},e.prototype.input=function(e){this.inputMap.set(e.id,e)},e.prototype.flush=function(){var e,t,n,o,i=this,a=this.tree,s=this.removeNodeMutations,l=this.textMutations,c=this.attributeMutations,u={source:b.Mutation,removes:s,texts:l,attributes:c,adds:[]},d=function(e,t){t&&i.removeIdSet.add(e.id),u.texts=u.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),u.attributes=u.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return d(e,!0)})):(u.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return d(e,!1)})))};Object.values(a).forEach((function(e){return d(e,!1)}));try{for(var f=r(this.scrollMap.keys()),p=f.next();!p.done;p=f.next()){var h=p.value;this.removeIdSet.has(h)&&this.scrollMap.delete(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var m=r(this.inputMap.keys()),v=m.next();!v.done;v=m.next()){h=v.value;this.removeIdSet.has(h)&&this.inputMap.delete(h)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}var y=new Map(this.scrollMap),g=new Map(this.inputMap);return this.reset(),{mutationData:u,scrollMap:y,inputMap:g}},e.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},e}();function U(e){var t,n,o={},i=function(e,t){var n={value:e,parent:t,children:[]};return o[e.node.id]=n,n},a=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var f=o[u];if(f.parent){var p=f.parent.children.indexOf(f);f.parent.children.splice(p,0,i(c,f.parent))}else{p=a.indexOf(f);a.splice(p,0,i(c,null))}}else if(d in o){var h=o[d];h.children.push(i(c,h))}else a.push(i(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return a}function W(e,t){t(e.value);for(var n=e.children.length-1;n>=0;n--)W(e.children[n],t)}function z(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function Y(e){var t;return Boolean(null===(t=e)||void 0===t?void 0:t.shadowRoot)}function X(e,t){var o=t.getCastFn,i=t.emitter;return L(P({id:"player",context:e,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"]}}},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"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:A({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:A((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),n(n({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(e){var t,n,a,s,l,c=e.timer,u=e.events,d=e.baselineTime,f=e.lastPlayedEvent;c.clear();try{for(var p=r(u),h=p.next();!h.done;h=p.next()){I(h.value,d)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}var m=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.type===g.Meta&&r.timestamp<=t)return e.slice(n)}return e}(u,d),v=null==f?void 0:f.timestamp;(null==f?void 0:f.type)===g.IncrementalSnapshot&&f.data.source===b.MouseMove&&(v=f.timestamp+(null===(l=f.data.positions[0])||void 0===l?void 0:l.timeOffset)),d<(v||0)&&i.emit(x.PlayBack);var y=new Array,w=function(e){if(v&&v<d&&(e.timestamp<=v||e===f))return"continue";var t=e.timestamp<d;if(t&&!function(e){switch(e.type){case g.DomContentLoaded:case g.Load:case g.Custom:return!1;case g.FullSnapshot:case g.Meta:case g.Plugin:return!0}switch(e.data.source){case b.MouseMove:case b.MouseInteraction:case b.TouchMove:case b.MediaInteraction:return!1;case b.ViewportResize:case b.StyleSheetRule:case b.Scroll:case b.Input:return!0}return!0}(e))return"continue";var n=o(e,t);t?n():y.push({doAction:function(){n(),i.emit(x.EventCast,e)},delay:e.delay})};try{for(var S=r(m),E=S.next();!E.done;E=S.next()){w(E.value)}}catch(e){a={error:e}}finally{try{E&&!E.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}i.emit(x.Flush),c.addActions(y),c.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:A((function(e){return n(n({},e),{lastPlayedEvent:null})})),startLive:A({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:A((function(e,t){var r=e.baselineTime,a=e.timer,s=e.events;if("ADD_EVENT"===t.type){var l=t.payload.event;I(l,r);var c=s.length-1;if(!s[c]||s[c].timestamp<=l.timestamp)s.push(l);else{for(var u=-1,d=0;d<=c;){var f=Math.floor((d+c)/2);s[f].timestamp<=l.timestamp?d=f+1:c=f-1}-1===u&&(u=d),s.splice(u,0,l)}var p=l.timestamp<r,h=o(l,p);p?h():a.isActive()&&a.addAction({doAction:function(){h(),i.emit(x.EventCast,l)},delay:l.delay})}return n(n({},e),{events:s})}))}}))}var Q=y||E,H={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"},G=function(){function e(e,t){var n=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Q(),this.legacy_missingNodeRetryMap={},this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,n=e.__sn&&e.__sn.id;delete this.map[n],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=[],!(null==t?void 0:t.liveMode)&&e.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:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:H};this.config=Object.assign({},o,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(x.Resize,this.handleResize),this.setupDom(),this.treeIndex=new V,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.emitter.on(x.Flush,(function(){var e,t,o,i,a=n.treeIndex.flush(),s=a.scrollMap,l=a.inputMap;n.fragmentParentMap.forEach((function(e,t){return n.restoreRealParent(t,e)})),n.fragmentParentMap.clear(),n.elementStateMap.clear();try{for(var c=r(s.values()),u=c.next();!u.done;u=c.next()){var d=u.value;n.applyScroll(d)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}try{for(var f=r(l.values()),p=f.next();!p.done;p=f.next()){d=p.value;n.applyInput(d)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}})),this.emitter.on(x.PlayBack,(function(){n.firstFullSnapshot=null,n.mirror.reset()}));var i=new N([],(null==t?void 0:t.speed)||o.speed);this.service=X({events:e.map((function(e){return t&&t.unpackFn?t.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(e){n.emitter.emit(x.StateChange,{player:e})})),this.speedService=L(P({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:A({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(e){n.emitter.emit(x.StateChange,{speed:e})}));var a=this.service.state.context.events.find((function(e){return e.type===g.Meta})),s=this.service.state.context.events.find((function(e){return e.type===g.FullSnapshot}));if(a){var l=a.data,c=l.width,u=l.height;setTimeout((function(){n.emitter.emit(x.Resize,{width:c,height:u})}),0)}s&&setTimeout((function(){n.firstFullSnapshot||(n.firstFullSnapshot=s,n.rebuildFullSnapshot(s),n.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1)}return Object.defineProperty(e.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.emitter.on(e,t),this},e.prototype.off=function(e,t){return this.emitter.off(e,t),this},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),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"))},e.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}},e.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},e.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},e.prototype.getMirror=function(){return this.mirror},e.prototype.play=function(e){var t;void 0===e&&(e=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}}),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(x.Start)},e.prototype.pause=function(e){var t;void 0===e&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof e&&(this.play(e),this.service.send({type:"PAUSE"})),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.Pause)},e.prototype.resume=function(e){void 0===e&&(e=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(x.Resume)},e.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},e.prototype.addEvent=function(e){var t=this,n=this.config.unpackFn?this.config.unpackFn(e):e;Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:n}})}))},e.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},e.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},e.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,t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(T(this.iframe.contentWindow,this.iframe.contentDocument),void 0===(e=this.iframe.contentWindow)&&(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=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1}))},e.prototype.handleResize=function(e){var t,n;this.iframe.style.display="inherit";try{for(var o=r([this.mouseTail,this.iframe]),i=o.next();!i.done;i=o.next()){var a=i.value;a&&(a.setAttribute("width",String(e.width)),a.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},e.prototype.getCastFn=function(e,t){var n,o=this;switch(void 0===t&&(t=!1),e.type){case g.DomContentLoaded:case g.Load:break;case g.Custom:n=function(){o.emitter.emit(x.CustomEvent,e)};break;case g.Meta:n=function(){return o.emitter.emit(x.Resize,{width:e.data.width,height:e.data.height})};break;case g.FullSnapshot:n=function(){if(o.firstFullSnapshot){if(o.firstFullSnapshot===e)return void(o.firstFullSnapshot=!0)}else o.firstFullSnapshot=!0;o.rebuildFullSnapshot(e,t),o.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case g.IncrementalSnapshot:n=function(){var n,i;if(o.applyIncremental(e,t),!t&&(e===o.nextUserInteractionEvent&&(o.nextUserInteractionEvent=null,o.backToNormal()),o.config.skipInactive&&!o.nextUserInteractionEvent)){try{for(var a=r(o.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(l.timestamp<=e.timestamp)&&o.isUserInteraction(l)){l.delay-e.delay>1e4*o.speedService.state.context.timer.speed&&(o.nextUserInteractionEvent=l);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 c=o.nextUserInteractionEvent.delay-e.delay,u={speed:Math.min(Math.round(c/5e3),o.config.maxSpeed)};o.speedService.send({type:"FAST_FORWARD",payload:u}),o.emitter.emit(x.SkipStart,u)}}}}return function(){var i,a;n&&n();try{for(var s=r(o.config.plugins||[]),l=s.next();!l.done;l=s.next()){l.value.handler(e,t,{replayer:o})}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}o.service.send({type:"CAST_EVENT",payload:{event:e}});var c=o.service.state.context.events.length-1;if(e===o.service.state.context.events[c]){var u=function(){c<o.service.state.context.events.length-1||(o.backToNormal(),o.service.send("END"),o.emitter.emit(x.Finish))};e.type===g.IncrementalSnapshot&&e.data.source===b.MouseMove&&e.data.positions.length?setTimeout((function(){u()}),Math.max(0,50-e.data.positions[0].timeOffset)):u()}}},e.prototype.rebuildFullSnapshot=function(e,t){var n,o,i=this;if(void 0===t&&(t=!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=v(e.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}})[1];var s=function(e,t){if(l.attachDocumentToIframe(e,t),l.newDocumentQueue=l.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var n=t.contentDocument,r=n.documentElement,o=n.head;l.insertStyleRules(r,o)}},l=this;try{for(var c=r(a),u=c.next();!u.done;u=c.next()){var d=u.value;s(d.mutationInQueue,d.builtNode)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}var f=this.iframe.contentDocument,p=f.documentElement,h=f.head;this.insertStyleRules(p,h),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},e.prototype.insertStyleRules=function(e,t){var n=document.createElement("style");e.insertBefore(n,t);var r,o=(r=this.config.blockClass,["."+r+" { background: #ccc }","noscript { display: none !important; }"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused * { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)n.sheet.insertRule(o[i],i)},e.prototype.attachDocumentToIframe=function(e,t){var n,o,i=this,a=[];if(!t.contentDocument)for(var s=t.parentNode;s;){if(this.fragmentParentMap.has(s)){var l=s,c=this.fragmentParentMap.get(l);this.restoreRealParent(l,c);break}s=s.parentNode}m(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}});var u=function(e,t){if(d.attachDocumentToIframe(e,t),d.newDocumentQueue=d.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var n=t.contentDocument,r=n.documentElement,o=n.head;d.insertStyleRules(r,o)}},d=this;try{for(var f=r(a),p=f.next();!p.done;p=f.next()){var h=p.value;u(h.mutationInQueue,h.builtNode)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}},e.prototype.collectIframeAndAttachDocument=function(e,t){if(z(t)){var n=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));n&&e.push({mutationInQueue:n,builtNode:t})}},e.prototype.waitForStylesheetLoad=function(){var e,t=this,n=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.head;if(n){var r,o=new Set,i=this.service.state,a=function(){i=t.service.state};this.emitter.on(x.Start,a),this.emitter.on(x.Pause,a);var s=function(){t.emitter.off(x.Start,a),t.emitter.off(x.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach((function(e){e.sheet||(o.add(e),e.addEventListener("load",(function(){o.delete(e),0===o.size&&-1!==r&&(i.matches("playing")&&t.play(t.getCurrentTime()),t.emitter.emit(x.LoadStylesheetEnd),r&&window.clearTimeout(r),s())})))})),o.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(x.LoadStylesheetStart),r=window.setTimeout((function(){i.matches("playing")&&t.play(t.getCurrentTime()),r=-1,s()}),this.config.loadTimeout))}},e.prototype.preloadAllImages=function(){var e,t,n=this,o=(this.service.state,function(){n.service.state});this.emitter.on(x.Start,o),this.emitter.on(x.Pause,o);var i=0;try{for(var a=r(this.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(l.type===g.IncrementalSnapshot&&l.data.source===b.CanvasMutation&&"drawImage"===l.data.property&&"string"==typeof l.data.args[0]&&!this.imageMap.has(l)){i++;var c=document.createElement("canvas"),u=c.getContext("2d"),d=null==u?void 0:u.createImageData(c.width,c.height);null==d||d.data;JSON.parse(l.data.args[0]),null==u||u.putImageData(d,0,0)}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}0!==i&&this.service.send({type:"PAUSE"})},e.prototype.applyIncremental=function(e,t){var n,r,o=this,i=e.data;switch(i.source){case b.Mutation:t&&(i.adds.forEach((function(e){return o.treeIndex.add(e)})),i.texts.forEach((function(e){return o.treeIndex.text(e)})),i.attributes.forEach((function(e){return o.treeIndex.attribute(e)})),i.removes.forEach((function(e){return o.treeIndex.remove(e,o.mirror)}))),this.applyMutation(i,t);break;case b.Drag:case b.TouchMove:case b.MouseMove:if(t){var a=i.positions[i.positions.length-1];this.moveAndHover(i,a.x,a.y,a.id)}else i.positions.forEach((function(t){var n={doAction:function(){o.moveAndHover(i,t.x,t.y,t.id)},delay:t.timeOffset+e.timestamp-o.service.state.context.baselineTime};o.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:e.delay-(null===(n=i.positions[0])||void 0===n?void 0:n.timeOffset)});break;case b.MouseInteraction:if(-1===i.id)break;var s=new Event(w[i.type].toLowerCase());if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);this.emitter.emit(x.MouseInteraction,{type:i.type,target:v});var l=this.config.triggerFocus;switch(i.type){case w.Blur:"blur"in v&&v.blur();break;case w.Focus:l&&v.focus;break;case w.Click:case w.TouchStart:case w.TouchEnd:t||(this.moveAndHover(i,i.x,i.y,i.id),this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active"));break;default:v.dispatchEvent(s)}break;case b.Scroll:if(-1===i.id)break;if(t){this.treeIndex.scroll(i);break}this.applyScroll(i);break;case b.ViewportResize:this.emitter.emit(x.Resize,{width:i.width,height:i.height});break;case b.Input:if(-1===i.id)break;if(t){this.treeIndex.input(i);break}this.applyInput(i);break;case b.MediaInteraction:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var c=v;try{i.currentTime&&(c.currentTime=i.currentTime),i.type===S.Pause&&c.pause(),i.type===S.Play&&c.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case b.StyleSheetRule:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var u=v,d=v.parentNode,f=this.fragmentParentMap.has(d),p=void 0;if(f){var h=this.fragmentParentMap.get(v.parentNode);p=document.createTextNode(""),d.replaceChild(p,v),h.appendChild(v)}var m=u.sheet;i.adds&&i.adds.forEach((function(e){var t=e.rule,n=e.index;try{var r=void 0===n?void 0:Math.min(n,m.rules.length);try{m.insertRule(t,r)}catch(e){}}catch(e){}})),i.removes&&i.removes.forEach((function(e){var t=e.index;try{m.deleteRule(t)}catch(e){}})),f&&p&&d.replaceChild(v,p);break;case b.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var v;if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);try{var y=v.getContext("2d");if(i.setter)return void(y[i.property]=i.args[0]);var g=y[i.property];if("drawImage"===i.property&&"string"==typeof i.args[0]){var E=this.imageMap.get(e);i.args[0]=E,g.apply(y,i.args)}else g.apply(y,i.args)}catch(e){this.warnCanvasMutationFailed(i,i.id,e)}break;case b.Font:try{var T=new FontFace(i.family,i.buffer?new Uint8Array(JSON.parse(i.fontSource)):i.fontSource,i.descriptors);null===(r=this.iframe.contentDocument)||void 0===r||r.fonts.add(T)}catch(e){this.config.showWarning&&console.warn(e)}}},e.prototype.applyMutation=function(e,o){var i,a,s=this;try{e.removes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);var r=s.mirror.getNode(t.parentId);if(!r)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&Y(r)&&(r=r.shadowRoot),s.mirror.removeNodeFromMap(n),r){var o="__sn"in r?s.fragmentParentMap.get(r):void 0;if(o&&o.contains(n))o.removeChild(n);else if(s.fragmentParentMap.has(n)){var i=s.fragmentParentMap.get(n);r.removeChild(i),s.fragmentParentMap.delete(n)}else r.removeChild(n)}}));var l=n({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var n,r;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var i=s.mirror.getNode(e.parentId);if(!i)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var a=null;s.iframe.contentDocument.contains?a=s.iframe.contentDocument.contains(i):s.iframe.contentDocument.body.contains&&(a=s.iframe.contentDocument.body.contains(i));var u=(null===(r=(n=i).getElementsByTagName)||void 0===r?void 0:r.call(n,"iframe").length)>0;if(o&&a&&!z(i)&&!u){var d=document.createDocumentFragment();for(s.mirror.map[e.parentId]=d,s.fragmentParentMap.set(d,i),s.storeState(i);i.firstChild;)d.appendChild(i.firstChild);i=d}e.node.isShadow&&Y(i)&&(i=i.shadowRoot);var f=null,p=null;if(e.previousId&&(f=s.mirror.getNode(e.previousId)),e.nextId&&(p=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var h=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(z(i))s.attachDocumentToIframe(e,i);else{var v=m(e.node,{doc:h,map:s.mirror.map,skipChild:!0,hackCss:!0});if(-1!==e.previousId&&-1!==e.nextId){if(f&&f.nextSibling&&f.nextSibling.parentNode)i.insertBefore(v,f.nextSibling);else if(p&&p.parentNode)i.contains(p)?i.insertBefore(v,p):i.insertBefore(v,null);else{if(i===h)for(;h.firstChild;)h.removeChild(h.firstChild);i.appendChild(v)}if(z(v)){var y=s.newDocumentQueue.find((function(e){return e.parentId===v.__sn.id}));if(y&&(s.attachDocumentToIframe(y,v),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==y}))),v.contentDocument){var g=v.contentDocument,b=g.documentElement,w=g.head;s.insertStyleRules(b,w)}}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,i,v,e)}else l[e.node.id]={node:v,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var f=U(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",f);break}try{for(var p=(i=void 0,r(f)),h=p.next();!h.done;h=p.next()){var v=h.value;this.mirror.getNode(v.value.parentId)?W(v,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",v)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),n.textContent=t.value})),e.attributes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);for(var r in s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),t.attributes)if("string"==typeof r){var o=t.attributes[r];try{null!==o?n.setAttribute(r,o):n.removeAttribute(r)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}}}))}catch(e){console.log("[ERROR applyMutation]: ",e)}},e.prototype.applyScroll=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);if(t===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:"smooth"});else try{t.scrollTop=e.y,t.scrollLeft=e.x}catch(e){}},e.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){}},e.prototype.legacy_resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a){var l=a,c=l.node,u=l.mutation;t.insertBefore(c,n),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,n.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},e.prototype.moveAndHover=function(e,t,n,r){var o=this.mirror.getNode(r);if(!o)return this.debugNodeNotFound(e,r);var i=function e(t,n){var r,o,i=null===(o=null===(r=t.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===o?void 0:o.frameElement;if(!i||i===n)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=i.getBoundingClientRect(),s=e(i,n),l=a.height/i.clientHeight;return{x:a.x*s.relativeScale+s.x,y:a.y*s.relativeScale+s.y,relativeScale:l,absoluteScale:s.absoluteScale*l}}(o,this.iframe),a=t*i.absoluteScale+i.x,s=n*i.absoluteScale+i.y;this.mouse.style.left=a+"px",this.mouse.style.top=s+"px",this.drawMouseTail({x:a,y:s}),this.hoverElements(o)},e.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var n=!0===this.config.mouseTail?H:Object.assign({},H,this.config.mouseTail),r=n.lineCap,o=n.lineWidth,i=n.strokeStyle,a=n.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=r,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)}},e.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 n=e;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement},e.prototype.isUserInteraction=function(e){return e.type===g.IncrementalSnapshot&&(e.data.source>b.Mutation&&e.data.source<=b.Input)},e.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(x.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},e.prototype.restoreRealParent=function(e,n){this.mirror.map[n.__sn.id]=n,n.__sn.type===t.Element&&"textarea"===n.__sn.tagName&&e.textContent&&(n.value=e.textContent),n.appendChild(e),this.restoreState(n)},e.prototype.storeState=function(e){var t,n;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]});var i=o.children;try{for(var a=r(Array.from(i)),s=a.next();!s.done;s=a.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}},e.prototype.restoreState=function(e){var t,n;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var i=this.elementStateMap.get(e);i.scroll&&(o.scrollLeft=i.scroll[0],o.scrollTop=i.scroll[1]),this.elementStateMap.delete(e)}var a=o.children;try{for(var s=r(Array.from(a)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}},e.prototype.warnNodeNotFound=function(e,t){this.warn("Node with id '"+t+"' not found in",e)},e.prototype.warnCanvasMutationFailed=function(e,t,n){this.warn("Has error on update canvas '"+t+"'",e,n)},e.prototype.debugNodeNotFound=function(e,t){this.debug("[replayer]","Node with id '"+t+"' not found in",e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,i(["[replayer]"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,i(["[replayer]"],e))},e}();return e.Replayer=G,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
***************************************************************************** */!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(M||(M={}));var C={type:"xstate.init"};function D(e){return void 0===e?[]:[].concat(e)}function A(e){return{type:"xstate.assign",assignment:e}}function k(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 _(e){return function(t){return e===t}}function F(e){return"string"==typeof e?{type:e}:e}function O(e,t){return{value:e,context:t,actions:[],changed:!1,matches:_(e)}}function R(e,t){void 0===t&&(t={});var n={config:e,_options:t,initialState:{value:e.initial,actions:D(e.states[e.initial].entry).map((function(e){return k(e,t.actions)})),context:e.context,matches:_(e.initial)},transition:function(t,r){var o,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=F(r),u=e.states[s];if(u.on){var d=D(u.on[c.type]),f=function(t){if(void 0===t)return{value:O(s,l)};var r="string"==typeof t?{target:t}:t,o=r.target,i=void 0===o?s:o,a=r.actions,d=void 0===a?[]:a,f=r.cond,p=l;if((void 0===f?function(){return!0}:f)(l,c)){var h=e.states[i],m=!1,v=[].concat(u.exit,d,h.entry).filter((function(e){return e})).map((function(e){return k(e,n._options.actions)})).filter((function(e){if("xstate.assign"===e.type){m=!0;var t=Object.assign({},p);return"function"==typeof e.assignment?t=e.assignment(p,c):Object.keys(e.assignment).forEach((function(n){t[n]="function"==typeof e.assignment[n]?e.assignment[n](p,c):e.assignment[n]})),p=t,!1}return!0}));return{value:{value:i,context:p,actions:v,changed:i!==s||v.length>0||m,matches:_(i)}}}};try{for(var p=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(d),h=p.next();!h.done;h=p.next()){var m=f(h.value);if("object"==typeof m)return m.value}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}}return O(s,l)}};return n}var P=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};function L(e){var t=e.initialState,n=M.NotStarted,r=new Set,o={_machine:e,send:function(o){n===M.Running&&(t=e.transition(t,o),P(t,F(o)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(r){if(r){var i="object"==typeof r?r:{context:e.config.context,value:r};t={value:i.value,actions:[],context:i.context,matches:_(i.value)}}return n=M.Running,P(t,C),o},stop:function(){return n=M.Stopped,r.clear(),o},get state(){return t},get status(){return n}};return o}var B="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",j={map:{},getId:function(){return console.error(B),-1},getNode:function(){return console.error(B),null},removeNodeFromMap:function(){console.error(B)},has:function(){return console.error(B),!1},reset:function(){console.error(B)}};"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(j=new Proxy(j,{get:function(e,t,n){return"map"===t&&console.error(B),Reflect.get(e,t,n)}}));var V=function(){function e(){this.reset()}return e.prototype.add=function(e){var t=this.indexes.get(e.parentId),n={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(n.parent=t,t.children[n.id]=n):this.tree[n.id]=n,this.indexes.set(n.id,n)},e.prototype.remove=function(e,t){var n=this,r=this.indexes.get(e.parentId),o=this.indexes.get(e.id),i=function(e){n.removeIdSet.add(e);var r=t.getNode(e);null==r||r.childNodes.forEach((function(e){"__sn"in e&&i(e.__sn.id)}))},a=function(t){n.removeIdSet.add(t.id),Object.values(t.children).forEach((function(e){return a(e)}));var r=n.indexes.get(t.id);if(r){var o=r.parent;o&&(delete r.parent,delete o.children[r.id],n.indexes.delete(e.id))}};o?r?(delete o.parent,delete r.children[o.id],this.indexes.delete(e.id),a(o)):(delete this.tree[o.id],this.indexes.delete(o.id),a(o)):(this.removeNodeMutations.push(e),i(e.id))},e.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},e.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},e.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},e.prototype.input=function(e){this.inputMap.set(e.id,e)},e.prototype.flush=function(){var e,t,n,o,i=this,a=this.tree,s=this.removeNodeMutations,l=this.textMutations,c=this.attributeMutations,u={source:b.Mutation,removes:s,texts:l,attributes:c,adds:[]},d=function(e,t){t&&i.removeIdSet.add(e.id),u.texts=u.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),u.attributes=u.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return d(e,!0)})):(u.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return d(e,!1)})))};Object.values(a).forEach((function(e){return d(e,!1)}));try{for(var f=r(this.scrollMap.keys()),p=f.next();!p.done;p=f.next()){var h=p.value;this.removeIdSet.has(h)&&this.scrollMap.delete(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var m=r(this.inputMap.keys()),v=m.next();!v.done;v=m.next()){h=v.value;this.removeIdSet.has(h)&&this.inputMap.delete(h)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}var y=new Map(this.scrollMap),g=new Map(this.inputMap);return this.reset(),{mutationData:u,scrollMap:y,inputMap:g}},e.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},e}();function U(e){var t,n,o={},i=function(e,t){var n={value:e,parent:t,children:[]};return o[e.node.id]=n,n},a=[];try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.nextId,d=c.parentId;if(u&&u in o){var f=o[u];if(f.parent){var p=f.parent.children.indexOf(f);f.parent.children.splice(p,0,i(c,f.parent))}else{p=a.indexOf(f);a.splice(p,0,i(c,null))}}else if(d in o){var h=o[d];h.children.push(i(c,h))}else a.push(i(c,null))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return a}function W(e,t){t(e.value);for(var n=e.children.length-1;n>=0;n--)W(e.children[n],t)}function z(e){return"__sn"in e&&(e.__sn.type===t.Element&&"iframe"===e.__sn.tagName)}function Y(e){var t;return Boolean(null===(t=e)||void 0===t?void 0:t.shadowRoot)}function X(e,t){var o=t.getCastFn,i=t.emitter;return L(R({id:"player",context:e,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"]}}},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"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:A({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:A((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),n(n({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(e){var t,n,a,s,l,c=e.timer,u=e.events,d=e.baselineTime,f=e.lastPlayedEvent;c.clear();try{for(var p=r(u),h=p.next();!h.done;h=p.next()){I(h.value,d)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}var m=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.type===g.Meta&&r.timestamp<=t)return e.slice(n)}return e}(u,d),v=null==f?void 0:f.timestamp;(null==f?void 0:f.type)===g.IncrementalSnapshot&&f.data.source===b.MouseMove&&(v=f.timestamp+(null===(l=f.data.positions[0])||void 0===l?void 0:l.timeOffset)),d<(v||0)&&i.emit(x.PlayBack);var y=new Array,w=function(e){if(v&&v<d&&(e.timestamp<=v||e===f))return"continue";var t=e.timestamp<d;if(t&&!function(e){switch(e.type){case g.DomContentLoaded:case g.Load:case g.Custom:return!1;case g.FullSnapshot:case g.Meta:case g.Plugin:return!0}switch(e.data.source){case b.MouseMove:case b.MouseInteraction:case b.TouchMove:case b.MediaInteraction:return!1;case b.ViewportResize:case b.StyleSheetRule:case b.Scroll:case b.Input:return!0}return!0}(e))return"continue";var n=o(e,t);t?n():y.push({doAction:function(){n(),i.emit(x.EventCast,e)},delay:e.delay})};try{for(var S=r(m),E=S.next();!E.done;E=S.next()){w(E.value)}}catch(e){a={error:e}}finally{try{E&&!E.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}i.emit(x.Flush),c.addActions(y),c.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:A((function(e){return n(n({},e),{lastPlayedEvent:null})})),startLive:A({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:A((function(e,t){var r=e.baselineTime,a=e.timer,s=e.events;if("ADD_EVENT"===t.type){var l=t.payload.event;I(l,r);var c=s.length-1;if(!s[c]||s[c].timestamp<=l.timestamp)s.push(l);else{for(var u=-1,d=0;d<=c;){var f=Math.floor((d+c)/2);s[f].timestamp<=l.timestamp?d=f+1:c=f-1}-1===u&&(u=d),s.splice(u,0,l)}var p=l.timestamp<r,h=o(l,p);p?h():a.isActive()&&a.addAction({doAction:function(){h(),i.emit(x.EventCast,l)},delay:l.delay})}return n(n({},e),{events:s})}))}}))}var Q=y||E,H={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"},G=function(){function e(e,t){var n=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=Q(),this.legacy_missingNodeRetryMap={},this.imageMap=new Map,this.mirror={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return this.map[e]||null},removeNodeFromMap:function(e){var t=this,n=e.__sn&&e.__sn.id;delete this.map[n],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=[],!(null==t?void 0:t.liveMode)&&e.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:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:H};this.config=Object.assign({},o,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(x.Resize,this.handleResize),this.setupDom(),this.treeIndex=new V,this.fragmentParentMap=new Map,this.elementStateMap=new Map,this.emitter.on(x.Flush,(function(){var e,t,o,i,a=n.treeIndex.flush(),s=a.scrollMap,l=a.inputMap;n.fragmentParentMap.forEach((function(e,t){return n.restoreRealParent(t,e)})),n.fragmentParentMap.clear(),n.elementStateMap.clear();try{for(var c=r(s.values()),u=c.next();!u.done;u=c.next()){var d=u.value;n.applyScroll(d)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}try{for(var f=r(l.values()),p=f.next();!p.done;p=f.next()){d=p.value;n.applyInput(d)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}})),this.emitter.on(x.PlayBack,(function(){n.firstFullSnapshot=null,n.mirror.reset()}));var i=new N([],(null==t?void 0:t.speed)||o.speed);this.service=X({events:e.map((function(e){return t&&t.unpackFn?t.unpackFn(e):e})).sort((function(e,t){return e.timestamp-t.timestamp})),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(e){n.emitter.emit(x.StateChange,{player:e})})),this.speedService=L(R({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:A({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(e){n.emitter.emit(x.StateChange,{speed:e})}));var a=this.service.state.context.events.find((function(e){return e.type===g.Meta})),s=this.service.state.context.events.find((function(e){return e.type===g.FullSnapshot}));if(a){var l=a.data,c=l.width,u=l.height;setTimeout((function(){n.emitter.emit(x.Resize,{width:c,height:u})}),0)}s&&setTimeout((function(){n.firstFullSnapshot||(n.firstFullSnapshot=s,n.rebuildFullSnapshot(s),n.iframe.contentWindow.scrollTo(s.data.initialOffset))}),1)}return Object.defineProperty(e.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.emitter.on(e,t),this},e.prototype.off=function(e,t){return this.emitter.off(e,t),this},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),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"))},e.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}},e.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},e.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},e.prototype.getMirror=function(){return this.mirror},e.prototype.play=function(e){var t;void 0===e&&(e=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}}),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.remove("rrweb-paused"),this.emitter.emit(x.Start)},e.prototype.pause=function(e){var t;void 0===e&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof e&&(this.play(e),this.service.send({type:"PAUSE"})),null===(t=this.iframe.contentDocument)||void 0===t||t.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.Pause)},e.prototype.resume=function(e){void 0===e&&(e=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(x.Resume)},e.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},e.prototype.addEvent=function(e){var t=this,n=this.config.unpackFn?this.config.unpackFn(e):e;Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:n}})}))},e.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},e.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},e.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,t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(T(this.iframe.contentWindow,this.iframe.contentDocument),void 0===(e=this.iframe.contentWindow)&&(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=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1}))},e.prototype.handleResize=function(e){var t,n;this.iframe.style.display="inherit";try{for(var o=r([this.mouseTail,this.iframe]),i=o.next();!i.done;i=o.next()){var a=i.value;a&&(a.setAttribute("width",String(e.width)),a.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},e.prototype.getCastFn=function(e,t){var n=this;void 0===t&&(t=!1);try{var o;switch(e.type){case g.DomContentLoaded:case g.Load:break;case g.Custom:o=function(){n.emitter.emit(x.CustomEvent,e)};break;case g.Meta:o=function(){return n.emitter.emit(x.Resize,{width:e.data.width,height:e.data.height})};break;case g.FullSnapshot:o=function(){if(n.firstFullSnapshot){if(n.firstFullSnapshot===e)return void(n.firstFullSnapshot=!0)}else n.firstFullSnapshot=!0;n.rebuildFullSnapshot(e,t),n.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case g.IncrementalSnapshot:o=function(){var o,i;if(n.applyIncremental(e,t),!t&&(e===n.nextUserInteractionEvent&&(n.nextUserInteractionEvent=null,n.backToNormal()),n.config.skipInactive&&!n.nextUserInteractionEvent)){try{for(var a=r(n.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(l.timestamp<=e.timestamp)&&n.isUserInteraction(l)){l.delay-e.delay>1e4*n.speedService.state.context.timer.speed&&(n.nextUserInteractionEvent=l);break}}}catch(e){o={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}if(n.nextUserInteractionEvent){var c=n.nextUserInteractionEvent.delay-e.delay,u={speed:Math.min(Math.round(c/5e3),n.config.maxSpeed)};n.speedService.send({type:"FAST_FORWARD",payload:u}),n.emitter.emit(x.SkipStart,u)}}}}return function(){var i,a;o&&o();try{for(var s=r(n.config.plugins||[]),l=s.next();!l.done;l=s.next()){l.value.handler(e,t,{replayer:n})}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}n.service.send({type:"CAST_EVENT",payload:{event:e}});var c=n.service.state.context.events.length-1;if(e===n.service.state.context.events[c]){var u=function(){c<n.service.state.context.events.length-1||(n.backToNormal(),n.service.send("END"),n.emitter.emit(x.Finish))};e.type===g.IncrementalSnapshot&&e.data.source===b.MouseMove&&e.data.positions.length?setTimeout((function(){u()}),Math.max(0,50-e.data.positions[0].timeOffset)):u()}}}catch(e){console.log("[ERROR getCastFn]: ",e)}},e.prototype.rebuildFullSnapshot=function(e,t){var n,o,i=this;if(void 0===t&&(t=!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=v(e.data.node,{doc:this.iframe.contentDocument,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}})[1];var s=function(e,t){if(l.attachDocumentToIframe(e,t),l.newDocumentQueue=l.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var n=t.contentDocument,r=n.documentElement,o=n.head;l.insertStyleRules(r,o)}},l=this;try{for(var c=r(a),u=c.next();!u.done;u=c.next()){var d=u.value;s(d.mutationInQueue,d.builtNode)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}var f=this.iframe.contentDocument,p=f.documentElement,h=f.head;this.insertStyleRules(p,h),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(x.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},e.prototype.insertStyleRules=function(e,t){var n=document.createElement("style");e.insertBefore(n,t);var r,o=(r=this.config.blockClass,["."+r+" { background: #ccc }","noscript { display: none !important; }"]).concat(this.config.insertStyleRules);this.config.pauseAnimation&&o.push("html.rrweb-paused * { animation-play-state: paused !important; }");for(var i=0;i<o.length;i++)n.sheet.insertRule(o[i],i)},e.prototype.attachDocumentToIframe=function(e,t){var n,o,i=this,a=[];if(!t.contentDocument)for(var s=t.parentNode;s;){if(this.fragmentParentMap.has(s)){var l=s,c=this.fragmentParentMap.get(l);this.restoreRealParent(l,c);break}s=s.parentNode}m(e.node,{doc:t.contentDocument,map:this.mirror.map,hackCss:!0,skipChild:!1,afterAppend:function(e){i.collectIframeAndAttachDocument(a,e)}});var u=function(e,t){if(d.attachDocumentToIframe(e,t),d.newDocumentQueue=d.newDocumentQueue.filter((function(t){return t!==e})),t.contentDocument){var n=t.contentDocument,r=n.documentElement,o=n.head;d.insertStyleRules(r,o)}},d=this;try{for(var f=r(a),p=f.next();!p.done;p=f.next()){var h=p.value;u(h.mutationInQueue,h.builtNode)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}},e.prototype.collectIframeAndAttachDocument=function(e,t){if(z(t)){var n=this.newDocumentQueue.find((function(e){return e.parentId===t.__sn.id}));n&&e.push({mutationInQueue:n,builtNode:t})}},e.prototype.waitForStylesheetLoad=function(){var e,t=this,n=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.head;if(n){var r,o=new Set,i=this.service.state,a=function(){i=t.service.state};this.emitter.on(x.Start,a),this.emitter.on(x.Pause,a);var s=function(){t.emitter.off(x.Start,a),t.emitter.off(x.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach((function(e){e.sheet||(o.add(e),e.addEventListener("load",(function(){o.delete(e),0===o.size&&-1!==r&&(i.matches("playing")&&t.play(t.getCurrentTime()),t.emitter.emit(x.LoadStylesheetEnd),r&&window.clearTimeout(r),s())})))})),o.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(x.LoadStylesheetStart),r=window.setTimeout((function(){i.matches("playing")&&t.play(t.getCurrentTime()),r=-1,s()}),this.config.loadTimeout))}},e.prototype.preloadAllImages=function(){var e,t,n=this,o=(this.service.state,function(){n.service.state});this.emitter.on(x.Start,o),this.emitter.on(x.Pause,o);var i=0;try{for(var a=r(this.service.state.context.events),s=a.next();!s.done;s=a.next()){var l=s.value;if(l.type===g.IncrementalSnapshot&&l.data.source===b.CanvasMutation&&"drawImage"===l.data.property&&"string"==typeof l.data.args[0]&&!this.imageMap.has(l)){i++;var c=document.createElement("canvas"),u=c.getContext("2d"),d=null==u?void 0:u.createImageData(c.width,c.height);null==d||d.data;JSON.parse(l.data.args[0]),null==u||u.putImageData(d,0,0)}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}0!==i&&this.service.send({type:"PAUSE"})},e.prototype.applyIncremental=function(e,t){var n,r,o=this,i=e.data;switch(i.source){case b.Mutation:t&&(i.adds.forEach((function(e){return o.treeIndex.add(e)})),i.texts.forEach((function(e){return o.treeIndex.text(e)})),i.attributes.forEach((function(e){return o.treeIndex.attribute(e)})),i.removes.forEach((function(e){return o.treeIndex.remove(e,o.mirror)}))),this.applyMutation(i,t);break;case b.Drag:case b.TouchMove:case b.MouseMove:if(t){var a=i.positions[i.positions.length-1];this.moveAndHover(i,a.x,a.y,a.id)}else i.positions.forEach((function(t){var n={doAction:function(){o.moveAndHover(i,t.x,t.y,t.id)},delay:t.timeOffset+e.timestamp-o.service.state.context.baselineTime};o.timer.addAction(n)})),this.timer.addAction({doAction:function(){},delay:e.delay-(null===(n=i.positions[0])||void 0===n?void 0:n.timeOffset)});break;case b.MouseInteraction:if(-1===i.id)break;var s=new Event(w[i.type].toLowerCase());if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);this.emitter.emit(x.MouseInteraction,{type:i.type,target:v});var l=this.config.triggerFocus;switch(i.type){case w.Blur:"blur"in v&&v.blur();break;case w.Focus:l&&v.focus;break;case w.Click:case w.TouchStart:case w.TouchEnd:t||(this.moveAndHover(i,i.x,i.y,i.id),this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active"));break;default:v.dispatchEvent(s)}break;case b.Scroll:if(-1===i.id)break;if(t){this.treeIndex.scroll(i);break}this.applyScroll(i);break;case b.ViewportResize:this.emitter.emit(x.Resize,{width:i.width,height:i.height});break;case b.Input:if(-1===i.id)break;if(t){this.treeIndex.input(i);break}this.applyInput(i);break;case b.MediaInteraction:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var c=v;try{i.currentTime&&(c.currentTime=i.currentTime),i.type===S.Pause&&c.pause(),i.type===S.Play&&c.play()}catch(e){this.config.showWarning&&console.warn("Failed to replay media interactions: "+(e.message||e))}break;case b.StyleSheetRule:if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);var u=v,d=v.parentNode,f=this.fragmentParentMap.has(d),p=void 0;if(f){var h=this.fragmentParentMap.get(v.parentNode);p=document.createTextNode(""),d.replaceChild(p,v),h.appendChild(v)}var m=u.sheet;i.adds&&i.adds.forEach((function(e){var t=e.rule,n=e.index;try{var r=void 0===n?void 0:Math.min(n,m.rules.length);try{m.insertRule(t,r)}catch(e){}}catch(e){}})),i.removes&&i.removes.forEach((function(e){var t=e.index;try{m.deleteRule(t)}catch(e){}})),f&&p&&d.replaceChild(v,p);break;case b.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var v;if(!(v=this.mirror.getNode(i.id)))return this.debugNodeNotFound(i,i.id);try{var y=v.getContext("2d");if(i.setter)return void(y[i.property]=i.args[0]);var g=y[i.property];if("drawImage"===i.property&&"string"==typeof i.args[0]){var E=this.imageMap.get(e);i.args[0]=E,g.apply(y,i.args)}else g.apply(y,i.args)}catch(e){this.warnCanvasMutationFailed(i,i.id,e)}break;case b.Font:try{var T=new FontFace(i.family,i.buffer?new Uint8Array(JSON.parse(i.fontSource)):i.fontSource,i.descriptors);null===(r=this.iframe.contentDocument)||void 0===r||r.fonts.add(T)}catch(e){this.config.showWarning&&console.warn(e)}}},e.prototype.applyMutation=function(e,o){var i,a,s=this;try{e.removes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);var r=s.mirror.getNode(t.parentId);if(!r)return s.warnNodeNotFound(e,t.parentId);if(t.isShadow&&Y(r)&&(r=r.shadowRoot),s.mirror.removeNodeFromMap(n),r){var o="__sn"in r?s.fragmentParentMap.get(r):void 0;if(o&&o.contains(n))o.removeChild(n);else if(s.fragmentParentMap.has(n)){var i=s.fragmentParentMap.get(n);r.removeChild(i),s.fragmentParentMap.delete(n)}else r.removeChild(n)}}));var l=n({},this.legacy_missingNodeRetryMap),c=[],u=function(e){var n,r;if(!s.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var i=s.mirror.getNode(e.parentId);if(!i)return e.node.type===t.Document?s.newDocumentQueue.push(e):c.push(e);var a=null;s.iframe.contentDocument.contains?a=s.iframe.contentDocument.contains(i):s.iframe.contentDocument.body.contains&&(a=s.iframe.contentDocument.body.contains(i));var u=(null===(r=(n=i).getElementsByTagName)||void 0===r?void 0:r.call(n,"iframe").length)>0;if(o&&a&&!z(i)&&!u){var d=document.createDocumentFragment();for(s.mirror.map[e.parentId]=d,s.fragmentParentMap.set(d,i),s.storeState(i);i.firstChild;)d.appendChild(i.firstChild);i=d}e.node.isShadow&&Y(i)&&(i=i.shadowRoot);var f=null,p=null;if(e.previousId&&(f=s.mirror.getNode(e.previousId)),e.nextId&&(p=s.mirror.getNode(e.nextId)),function(e){var t=null;return e.nextId&&(t=s.mirror.getNode(e.nextId)),null!==e.nextId&&void 0!==e.nextId&&-1!==e.nextId&&!t}(e))return c.push(e);if(!e.node.rootId||s.mirror.getNode(e.node.rootId)){var h=e.node.rootId?s.mirror.getNode(e.node.rootId):s.iframe.contentDocument;if(z(i))s.attachDocumentToIframe(e,i);else{var v=m(e.node,{doc:h,map:s.mirror.map,skipChild:!0,hackCss:!0});if(-1!==e.previousId&&-1!==e.nextId){if(f&&f.nextSibling&&f.nextSibling.parentNode)i.insertBefore(v,f.nextSibling);else if(p&&p.parentNode)i.contains(p)?i.insertBefore(v,p):i.insertBefore(v,null);else{if(i===h)for(;h.firstChild;)h.removeChild(h.firstChild);i.appendChild(v)}if(z(v)){var y=s.newDocumentQueue.find((function(e){return e.parentId===v.__sn.id}));if(y&&(s.attachDocumentToIframe(y,v),s.newDocumentQueue=s.newDocumentQueue.filter((function(e){return e!==y}))),v.contentDocument){var g=v.contentDocument,b=g.documentElement,w=g.head;s.insertStyleRules(b,w)}}(e.previousId||e.nextId)&&s.legacy_resolveMissingNode(l,i,v,e)}else l[e.node.id]={node:v,mutation:e}}}};e.adds.forEach((function(e){u(e)}));for(var d=Date.now();c.length;){var f=U(c);if(c.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",f);break}try{for(var p=(i=void 0,r(f)),h=p.next();!h.done;h=p.next()){var v=h.value;this.mirror.getNode(v.value.parentId)?W(v,(function(e){u(e)})):this.debug("Drop resolve tree since there is no parent for the root node.",v)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}Object.keys(l).length&&Object.assign(this.legacy_missingNodeRetryMap,l),e.texts.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),n.textContent=t.value})),e.attributes.forEach((function(t){var n=s.mirror.getNode(t.id);if(!n)return s.warnNodeNotFound(e,t.id);for(var r in s.fragmentParentMap.has(n)&&(n=s.fragmentParentMap.get(n)),t.attributes)if("string"==typeof r){var o=t.attributes[r];try{null!==o?n.setAttribute(r,o):n.removeAttribute(r)}catch(e){s.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",e)}}}))}catch(e){console.log("[ERROR applyMutation]: ",e)}},e.prototype.applyScroll=function(e){var t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);if(t===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:"smooth"});else try{t.scrollTop=e.y,t.scrollLeft=e.x}catch(e){}},e.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){}},e.prototype.legacy_resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a){var l=a,c=l.node,u=l.mutation;t.insertBefore(c,n),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,n.nextSibling),delete e[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(e,t,c,u)}},e.prototype.moveAndHover=function(e,t,n,r){var o=this.mirror.getNode(r);if(!o)return this.debugNodeNotFound(e,r);var i=function e(t,n){var r,o,i=null===(o=null===(r=t.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===o?void 0:o.frameElement;if(!i||i===n)return{x:0,y:0,relativeScale:1,absoluteScale:1};var a=i.getBoundingClientRect(),s=e(i,n),l=a.height/i.clientHeight;return{x:a.x*s.relativeScale+s.x,y:a.y*s.relativeScale+s.y,relativeScale:l,absoluteScale:s.absoluteScale*l}}(o,this.iframe),a=t*i.absoluteScale+i.x,s=n*i.absoluteScale+i.y;this.mouse.style.left=a+"px",this.mouse.style.top=s+"px",this.drawMouseTail({x:a,y:s}),this.hoverElements(o)},e.prototype.drawMouseTail=function(e){var t=this;if(this.mouseTail){var n=!0===this.config.mouseTail?H:Object.assign({},H,this.config.mouseTail),r=n.lineCap,o=n.lineWidth,i=n.strokeStyle,a=n.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=r,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)}},e.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 n=e;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement},e.prototype.isUserInteraction=function(e){return e.type===g.IncrementalSnapshot&&(e.data.source>b.Mutation&&e.data.source<=b.Input)},e.prototype.backToNormal=function(){this.nextUserInteractionEvent=null,this.speedService.state.matches("normal")||(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(x.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))},e.prototype.restoreRealParent=function(e,n){this.mirror.map[n.__sn.id]=n,n.__sn.type===t.Element&&"textarea"===n.__sn.tagName&&e.textContent&&(n.value=e.textContent),n.appendChild(e),this.restoreState(n)},e.prototype.storeState=function(e){var t,n;if(e&&e.nodeType===e.ELEMENT_NODE){var o=e;(o.scrollLeft||o.scrollTop)&&this.elementStateMap.set(e,{scroll:[o.scrollLeft,o.scrollTop]});var i=o.children;try{for(var a=r(Array.from(i)),s=a.next();!s.done;s=a.next()){var l=s.value;this.storeState(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}},e.prototype.restoreState=function(e){var t,n;if(e.nodeType===e.ELEMENT_NODE){var o=e;if(this.elementStateMap.has(e)){var i=this.elementStateMap.get(e);i.scroll&&(o.scrollLeft=i.scroll[0],o.scrollTop=i.scroll[1]),this.elementStateMap.delete(e)}var a=o.children;try{for(var s=r(Array.from(a)),l=s.next();!l.done;l=s.next()){var c=l.value;this.restoreState(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}},e.prototype.warnNodeNotFound=function(e,t){this.warn("Node with id '"+t+"' not found in",e)},e.prototype.warnCanvasMutationFailed=function(e,t,n){this.warn("Has error on update canvas '"+t+"'",e,n)},e.prototype.debugNodeNotFound=function(e,t){this.debug("[replayer]","Node with id '"+t+"' not found in",e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showWarning&&console.warn.apply(console,i(["[replayer]"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.config.showDebug&&console.log.apply(console,i(["[replayer]"],e))},e}();return e.Replayer=G,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=rrweb-replay.min.js.map |
@@ -325,124 +325,130 @@ import { __values, __assign, __spread } from '../../ext/tslib/tslib.es6.js'; | ||
if (isSync === void 0) { isSync = false; } | ||
var castFn; | ||
switch (event.type) { | ||
case EventType.DomContentLoaded: | ||
case EventType.Load: | ||
break; | ||
case EventType.Custom: | ||
castFn = function () { | ||
_this.emitter.emit(ReplayerEvents.CustomEvent, event); | ||
}; | ||
break; | ||
case EventType.Meta: | ||
castFn = function () { | ||
return _this.emitter.emit(ReplayerEvents.Resize, { | ||
width: event.data.width, | ||
height: event.data.height, | ||
}); | ||
}; | ||
break; | ||
case EventType.FullSnapshot: | ||
castFn = function () { | ||
if (_this.firstFullSnapshot) { | ||
if (_this.firstFullSnapshot === event) { | ||
try { | ||
var castFn_1; | ||
switch (event.type) { | ||
case EventType.DomContentLoaded: | ||
case EventType.Load: | ||
break; | ||
case EventType.Custom: | ||
castFn_1 = function () { | ||
_this.emitter.emit(ReplayerEvents.CustomEvent, event); | ||
}; | ||
break; | ||
case EventType.Meta: | ||
castFn_1 = function () { | ||
return _this.emitter.emit(ReplayerEvents.Resize, { | ||
width: event.data.width, | ||
height: event.data.height, | ||
}); | ||
}; | ||
break; | ||
case EventType.FullSnapshot: | ||
castFn_1 = function () { | ||
if (_this.firstFullSnapshot) { | ||
if (_this.firstFullSnapshot === event) { | ||
_this.firstFullSnapshot = true; | ||
return; | ||
} | ||
} | ||
else { | ||
_this.firstFullSnapshot = true; | ||
} | ||
_this.rebuildFullSnapshot(event, isSync); | ||
_this.iframe.contentWindow.scrollTo(event.data.initialOffset); | ||
}; | ||
break; | ||
case EventType.IncrementalSnapshot: | ||
castFn_1 = function () { | ||
var e_4, _a; | ||
_this.applyIncremental(event, isSync); | ||
if (isSync) { | ||
return; | ||
} | ||
} | ||
else { | ||
_this.firstFullSnapshot = true; | ||
} | ||
_this.rebuildFullSnapshot(event, isSync); | ||
_this.iframe.contentWindow.scrollTo(event.data.initialOffset); | ||
}; | ||
break; | ||
case EventType.IncrementalSnapshot: | ||
castFn = function () { | ||
var e_4, _a; | ||
_this.applyIncremental(event, isSync); | ||
if (isSync) { | ||
return; | ||
} | ||
if (event === _this.nextUserInteractionEvent) { | ||
_this.nextUserInteractionEvent = null; | ||
_this.backToNormal(); | ||
} | ||
if (_this.config.skipInactive && !_this.nextUserInteractionEvent) { | ||
try { | ||
for (var _b = __values(_this.service.state.context.events), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _event = _c.value; | ||
if (_event.timestamp <= event.timestamp) { | ||
continue; | ||
} | ||
if (_this.isUserInteraction(_event)) { | ||
if (_event.delay - event.delay > | ||
SKIP_TIME_THRESHOLD * | ||
_this.speedService.state.context.timer.speed) { | ||
_this.nextUserInteractionEvent = _event; | ||
if (event === _this.nextUserInteractionEvent) { | ||
_this.nextUserInteractionEvent = null; | ||
_this.backToNormal(); | ||
} | ||
if (_this.config.skipInactive && !_this.nextUserInteractionEvent) { | ||
try { | ||
for (var _b = __values(_this.service.state.context.events), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _event = _c.value; | ||
if (_event.timestamp <= event.timestamp) { | ||
continue; | ||
} | ||
break; | ||
if (_this.isUserInteraction(_event)) { | ||
if (_event.delay - event.delay > | ||
SKIP_TIME_THRESHOLD * | ||
_this.speedService.state.context.timer.speed) { | ||
_this.nextUserInteractionEvent = _event; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
if (_this.nextUserInteractionEvent) { | ||
var skipTime = _this.nextUserInteractionEvent.delay - event.delay; | ||
var payload = { | ||
speed: Math.min(Math.round(skipTime / SKIP_TIME_INTERVAL), _this.config.maxSpeed), | ||
}; | ||
_this.speedService.send({ type: 'FAST_FORWARD', payload: payload }); | ||
_this.emitter.emit(ReplayerEvents.SkipStart, payload); | ||
} | ||
} | ||
if (_this.nextUserInteractionEvent) { | ||
var skipTime = _this.nextUserInteractionEvent.delay - event.delay; | ||
var payload = { | ||
speed: Math.min(Math.round(skipTime / SKIP_TIME_INTERVAL), _this.config.maxSpeed), | ||
}; | ||
_this.speedService.send({ type: 'FAST_FORWARD', payload: payload }); | ||
_this.emitter.emit(ReplayerEvents.SkipStart, payload); | ||
} | ||
} | ||
}; | ||
break; | ||
} | ||
var wrappedCastFn = function () { | ||
var e_5, _a; | ||
if (castFn) { | ||
castFn(); | ||
}; | ||
break; | ||
default: | ||
} | ||
try { | ||
for (var _b = __values(_this.config.plugins || []), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var plugin = _c.value; | ||
plugin.handler(event, isSync, { replayer: _this }); | ||
var wrappedCastFn = function () { | ||
var e_5, _a; | ||
if (castFn_1) { | ||
castFn_1(); | ||
} | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
for (var _b = __values(_this.config.plugins || []), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var plugin = _c.value; | ||
plugin.handler(event, isSync, { replayer: _this }); | ||
} | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
_this.service.send({ type: 'CAST_EVENT', payload: { event: event } }); | ||
var last_index = _this.service.state.context.events.length - 1; | ||
if (event === _this.service.state.context.events[last_index]) { | ||
var finish_1 = function () { | ||
if (last_index < _this.service.state.context.events.length - 1) { | ||
return; | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
_this.backToNormal(); | ||
_this.service.send('END'); | ||
_this.emitter.emit(ReplayerEvents.Finish); | ||
}; | ||
if (event.type === EventType.IncrementalSnapshot && | ||
event.data.source === IncrementalSource.MouseMove && | ||
event.data.positions.length) { | ||
setTimeout(function () { | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
_this.service.send({ type: 'CAST_EVENT', payload: { event: event } }); | ||
var last_index = _this.service.state.context.events.length - 1; | ||
if (event === _this.service.state.context.events[last_index]) { | ||
var finish_1 = function () { | ||
if (last_index < _this.service.state.context.events.length - 1) { | ||
return; | ||
} | ||
_this.backToNormal(); | ||
_this.service.send('END'); | ||
_this.emitter.emit(ReplayerEvents.Finish); | ||
}; | ||
if (event.type === EventType.IncrementalSnapshot && | ||
event.data.source === IncrementalSource.MouseMove && | ||
event.data.positions.length) { | ||
setTimeout(function () { | ||
finish_1(); | ||
}, Math.max(0, -event.data.positions[0].timeOffset + 50)); | ||
} | ||
else { | ||
finish_1(); | ||
}, Math.max(0, -event.data.positions[0].timeOffset + 50)); | ||
} | ||
} | ||
else { | ||
finish_1(); | ||
} | ||
} | ||
}; | ||
return wrappedCastFn; | ||
}; | ||
return wrappedCastFn; | ||
} | ||
catch (e) { | ||
console.log("[ERROR getCastFn]: ", e); | ||
} | ||
}; | ||
@@ -449,0 +455,0 @@ Replayer.prototype.rebuildFullSnapshot = function (event, isSync) { |
{ | ||
"name": "@bss-sbc/rrweb", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "record and replay the web", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4550750
55653