@appsurify-testmap/rrweb-player 3.1.1-alpha.2 → 3.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,7 +71,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
71
71
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
72
72
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
73
73
  PERFORMANCE OF THIS SOFTWARE.
74
- ***************************************************************************** */function Sn(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i,r,n=t.call(s),o=[];try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){r={error:l}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}return o}var Qe;(function(s){s[s.NotStarted=0]="NotStarted",s[s.Running=1]="Running",s[s.Stopped=2]="Stopped"})(Qe||(Qe={}));var Fl={type:"xstate.init"};function ts(s){return s===void 0?[]:[].concat(s)}function Je(s){return{type:"xstate.assign",assignment:s}}function En(s,e){return typeof(s=typeof s=="string"&&e&&e[s]?e[s]:s)=="string"?{type:s}:typeof s=="function"?{type:s.name,exec:s}:s}function Ai(s){return function(e){return s===e}}function Bl(s){return typeof s=="string"?{type:s}:s}function xn(s,e){return{value:s,context:e,actions:[],changed:!1,matches:Ai(s)}}function An(s,e,t){var i=e,r=!1;return[s.filter(function(n){if(n.type==="xstate.assign"){r=!0;var o=Object.assign({},i);return typeof n.assignment=="function"?o=n.assignment(i,t):Object.keys(n.assignment).forEach(function(l){o[l]=typeof n.assignment[l]=="function"?n.assignment[l](i,t):n.assignment[l]}),i=o,!1}return!0}),i,r]}function Ul(s,e){e===void 0&&(e={});var t=Sn(An(ts(s.states[s.initial].entry).map(function(o){return En(o,e.actions)}),s.context,Fl),2),i=t[0],r=t[1],n={config:s,_options:e,initialState:{value:s.initial,actions:i,context:r,matches:Ai(s.initial)},transition:function(o,l){var a,u,c=typeof o=="string"?{value:o,context:s.context}:o,h=c.value,f=c.context,p=Bl(l),y=s.states[h];if(y.on){var b=ts(y.on[p.type]);try{for(var d=function(W){var he=typeof Symbol=="function"&&Symbol.iterator,le=he&&W[he],te=0;if(le)return le.call(W);if(W&&typeof W.length=="number")return{next:function(){return W&&te>=W.length&&(W=void 0),{value:W&&W[te++],done:!W}}};throw new TypeError(he?"Object is not iterable.":"Symbol.iterator is not defined.")}(b),m=d.next();!m.done;m=d.next()){var w=m.value;if(w===void 0)return xn(h,f);var v=typeof w=="string"?{target:w}:w,x=v.target,R=v.actions,_=R===void 0?[]:R,z=v.cond,A=z===void 0?function(){return!0}:z,G=x===void 0,Y=x!=null?x:h,ce=s.states[Y];if(A(f,p)){var ue=Sn(An((G?ts(_):[].concat(y.exit,_,ce.entry).filter(function(W){return W})).map(function(W){return En(W,n._options.actions)}),f,p),3),ee=ue[0],V=ue[1],ae=ue[2],k=x!=null?x:h;return{value:k,context:V,actions:ee,changed:x!==h||ee.length>0||ae,matches:Ai(k)}}}}catch(W){a={error:W}}finally{try{m&&!m.done&&(u=d.return)&&u.call(d)}finally{if(a)throw a.error}}}return xn(h,f)}};return n}var Nn=function(s,e){return s.actions.forEach(function(t){var i=t.exec;return i&&i(s.context,e)})};function zl(s){var e=s.initialState,t=Qe.NotStarted,i=new Set,r={_machine:s,send:function(n){t===Qe.Running&&(e=s.transition(e,n),Nn(e,Bl(n)),i.forEach(function(o){return o(e)}))},subscribe:function(n){return i.add(n),n(e),{unsubscribe:function(){return i.delete(n)}}},start:function(n){if(n){var o=typeof n=="object"?n:{context:s.config.context,value:n};e={value:o.value,actions:[],context:o.context,matches:Ai(o.value)}}return t=Qe.Running,Nn(e,Fl),r},stop:function(){return t=Qe.Stopped,i.clear(),r},get state(){return e},get status(){return t}};return r}function Od(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.type===K.Meta&&i.timestamp<=e)return s.slice(t)}return s}function Dd(s,{getCastFn:e,applyEventsSynchronously:t,emitter:i}){const r=Ul({id:"player",context:s,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:Je({lastPlayedEvent:(n,o)=>o.type==="CAST_EVENT"?o.payload.event:n.lastPlayedEvent}),recordTimeOffset:Je((n,o)=>{let l=n.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(l=o.payload.timeOffset),oe(P({},n),{timeOffset:l,baselineTime:n.events[0].timestamp+l})}),play(n){var o;const{timer:l,events:a,baselineTime:u,lastPlayedEvent:c}=n;l.clear();for(const y of a)Cn(y,u);const h=Od(a,u);let f=c==null?void 0:c.timestamp;(c==null?void 0:c.type)===K.IncrementalSnapshot&&c.data.source===F.MouseMove&&(f=c.timestamp+((o=c.data.positions[0])==null?void 0:o.timeOffset)),u<(f||0)&&i.emit(L.PlayBack);const p=new Array;for(const y of h)if(!(f&&f<u&&(y.timestamp<=f||y===c)))if(y.timestamp<=u)p.push(y);else{const b=e(y,!1);l.addAction({doAction:()=>{b()},delay:y.delay})}t(p),i.emit(L.Flush),l.start()},pause(n){n.timer.clear()},resetLastPlayedEvent:Je(n=>oe(P({},n),{lastPlayedEvent:null})),startLive:Je({baselineTime:(n,o)=>(n.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:Je((n,o)=>{const{baselineTime:l,timer:a,events:u}=n;if(o.type==="ADD_EVENT"){const{event:c}=o.payload;Cn(c,l);let h=u.length-1;if(!u[h]||u[h].timestamp<=c.timestamp)u.push(c);else{let y=-1,b=0;for(;b<=h;){const d=Math.floor((b+h)/2);u[d].timestamp<=c.timestamp?b=d+1:h=d-1}y===-1&&(y=b),u.splice(y,0,c)}const f=c.timestamp<l,p=e(c,f);f?p():a.isActive()&&a.addAction({doAction:()=>{p()},delay:c.delay})}return oe(P({},n),{events:u})})}});return zl(r)}function _d(s){const e=Ul({id:"speed",context:s,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:(t,i)=>{"payload"in i&&t.timer.setSpeed(i.payload.speed)},recordSpeed:Je({normalSpeed:t=>t.timer.speed}),restoreSpeed:t=>{t.timer.setSpeed(t.normalSpeed)}}});return zl(e)}const Td=s=>[`.${s} { background: currentColor }`,"noscript { display: none !important; }"],Mn=new Map;function Vl(s,e){let t=Mn.get(s);return t||(t=new Map,Mn.set(s,t)),t.has(e)||t.set(e,[]),t.get(e)}function Le(s,e,t){return async i=>{if(i&&typeof i=="object"&&"rr_type"in i)if(t&&(t.isUnchanged=!1),i.rr_type==="ImageBitmap"&&"args"in i){const r=await Le(s,e,t)(i.args);return await createImageBitmap.apply(null,r)}else if("index"in i){if(t||e===null)return i;const{rr_type:r,index:n}=i;return Vl(e,r)[n]}else if("args"in i){const{rr_type:r,args:n}=i,o=window[r];return new o(...await Promise.all(n.map(Le(s,e,t))))}else{if("base64"in i)return xd(i.base64);if("src"in i){const r=s.get(i.src);if(r)return r;{const n=new Image;return n.src=i.src,s.set(i.src,n),n}}else if("data"in i&&i.rr_type==="Blob"){const r=await Promise.all(i.data.map(Le(s,e,t)));return new Blob(r,{type:i.type})}}else if(Array.isArray(i))return await Promise.all(i.map(Le(s,e,t)));return i}}function kd(s,e){try{return e===xi.WebGL?s.getContext("webgl")||s.getContext("experimental-webgl"):s.getContext("webgl2")}catch(t){return null}}const Pd=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Ld(s,e){if(!(e!=null&&e.constructor))return;const{name:t}=e.constructor;if(!Pd.includes(t))return;const i=Vl(s,t);i.includes(e)||i.push(e)}async function $d({mutation:s,target:e,type:t,imageMap:i,errorHandler:r}){try{const n=kd(e,t);if(!n)return;if(s.setter){n[s.property]=s.args[0];return}const o=n[s.property],l=await Promise.all(s.args.map(Le(i,n))),a=o.apply(n,l);Ld(n,a);const u=!1}catch(n){r(s,n)}}async function Fd({event:s,mutations:e,target:t,imageMap:i,errorHandler:r}){const n=t.getContext("2d");if(!n){r(e[0],new Error("Canvas context is null"));return}const o=e.map(async a=>Promise.all(a.args.map(Le(i,n))));(await Promise.all(o)).forEach((a,u)=>{const c=e[u];try{if(c.setter){n[c.property]=c.args[0];return}const h=n[c.property];c.property==="drawImage"&&typeof c.args[0]=="string"?(i.get(s),h.apply(n,c.args)):h.apply(n,a)}catch(h){r(c,h)}})}async function Rn({event:s,mutation:e,target:t,imageMap:i,canvasEventMap:r,errorHandler:n}){try{const o=r.get(s)||e,l="commands"in o?o.commands:[o];if([xi.WebGL,xi.WebGL2].includes(e.type)){for(let a=0;a<l.length;a++){const u=l[a];await $d({mutation:u,type:e.type,target:t,imageMap:i,errorHandler:n})}return}await Fd({event:s,mutations:l,target:t,imageMap:i,errorHandler:n})}catch(o){n(e,o)}}class Bd{constructor(e){N(this,"mediaMap",new Map),N(this,"warn"),N(this,"service"),N(this,"speedService"),N(this,"emitter"),N(this,"getCurrentTime"),N(this,"metadataCallbackMap",new Map),this.warn=e.warn,this.service=e.service,this.speedService=e.speedService,this.emitter=e.emitter,this.getCurrentTime=e.getCurrentTime,this.emitter.on(L.Start,this.start.bind(this)),this.emitter.on(L.SkipStart,this.start.bind(this)),this.emitter.on(L.Pause,this.pause.bind(this)),this.emitter.on(L.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(e={pause:!1}){this.mediaMap.forEach((t,i)=>{this.syncTargetWithState(i),e.pause&&i.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:e,target:t,mediaState:i}){if(i.isPlaying){const n=(e-i.lastInteractionTimeOffset)/1e3*i.playbackRate,o="duration"in t&&t.duration;if(Number.isNaN(o)){this.waitForMetadata(t);return}let l=i.currentTimeAtLastInteraction+n;t.loop&&o!==!1&&(l=l%o),t.currentTime=l}else t.pause(),t.currentTime=i.currentTimeAtLastInteraction}waitForMetadata(e){if(this.metadataCallbackMap.has(e)||!("addEventListener"in e))return;const t=()=>{this.metadataCallbackMap.delete(e);const i=this.mediaMap.get(e);i&&this.seekTo({time:this.getCurrentTime(),target:e,mediaState:i})};this.metadataCallbackMap.set(e,t),e.addEventListener("loadedmetadata",t,{once:!0})}getMediaStateFromMutation({target:e,timeOffset:t,mutation:i}){var p,y,b,d,m;const r=this.mediaMap.get(e),{type:n,playbackRate:o,currentTime:l,muted:a,volume:u,loop:c}=i;return{isPlaying:n===Us.Play||n!==Us.Pause&&((r==null?void 0:r.isPlaying)||e.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(p=l!=null?l:r==null?void 0:r.currentTimeAtLastInteraction)!=null?p:0,lastInteractionTimeOffset:t,playbackRate:(y=o!=null?o:r==null?void 0:r.playbackRate)!=null?y:1,volume:(b=u!=null?u:r==null?void 0:r.volume)!=null?b:1,muted:(d=a!=null?a:r==null?void 0:r.muted)!=null?d:e.getAttribute("muted")===null,loop:(m=c!=null?c:r==null?void 0:r.loop)!=null?m:e.getAttribute("loop")===null}}syncTargetWithState(e){const t=this.mediaMap.get(e);if(!t)return;const{muted:i,loop:r,volume:n,isPlaying:o}=t,l=this.service.state.matches("paused"),a=t.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:e,mediaState:t}),e.volume!==n&&(e.volume=n),e.muted=i,e.loop=r,e.playbackRate!==a&&(e.playbackRate=a),o&&!l?e.play():e.pause()}catch(u){this.warn(`Failed to replay media interactions: ${u.message||u}`)}}addMediaElements(e,t,i){if(!["AUDIO","VIDEO"].includes(e.nodeName))return;const r=e,n=i.getMeta(r);if(!n||!("attributes"in n))return;const o=this.service.state.matches("paused"),l=n.attributes;let a=!1;l.rr_mediaState?a=l.rr_mediaState==="played":a=r.getAttribute("autoplay")!==null,a&&o&&r.pause();let u=1;typeof l.rr_mediaPlaybackRate=="number"&&(u=l.rr_mediaPlaybackRate);let c=!1;typeof l.rr_mediaMuted=="boolean"?c=l.rr_mediaMuted:c=r.getAttribute("muted")!==null;let h=!1;typeof l.rr_mediaLoop=="boolean"?h=l.rr_mediaLoop:h=r.getAttribute("loop")!==null;let f=1;typeof l.rr_mediaVolume=="number"&&(f=l.rr_mediaVolume);let p=0;typeof l.rr_mediaCurrentTime=="number"&&(p=l.rr_mediaCurrentTime),this.mediaMap.set(r,{isPlaying:a,currentTimeAtLastInteraction:p,lastInteractionTimeOffset:t,playbackRate:u,volume:f,muted:c,loop:h}),this.syncTargetWithState(r)}mediaMutation({target:e,timeOffset:t,mutation:i}){this.mediaMap.set(e,this.getMediaStateFromMutation({target:e,timeOffset:t,mutation:i})),this.syncTargetWithState(e)}isSupportedMediaElement(e){return["AUDIO","VIDEO"].includes(e.nodeName)}reset(){this.mediaMap.clear()}}function ni(s,e){if(s.nodeName!=="DIALOG"||s instanceof Se)return;const t=s,i=t.open,r=i&&t.matches("dialog:modal"),n=t.getAttribute("rr_open_mode"),o=typeof(e==null?void 0:e.attributes.open)=="string"||typeof t.getAttribute("open")=="string",l=n==="modal";if(!(i&&!(r&&n==="non-modal"||!r&&l))){if(!t.isConnected){console.warn("dialog is not attached to the dom",t);return}i&&t.close(),o&&(l?t.showModal():t.show())}}function Ud(s,e){if(s.nodeName!=="DIALOG"||s instanceof Se)return;const t=s;if(!t.isConnected){console.warn("dialog is not attached to the dom",t);return}e.attributes.open===null&&(t.removeAttribute("open"),t.removeAttribute("rr_open_mode"))}const zd=5*1e3,Vd=$l||Md,In="[replayer]",is={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function On(s){return s.type==K.IncrementalSnapshot&&(s.data.source==F.TouchMove||s.data.source==F.MouseInteraction&&s.data.type==re.TouchStart)}class Wd{constructor(e,t){if(N(this,"wrapper"),N(this,"iframe"),N(this,"service"),N(this,"speedService"),N(this,"config"),N(this,"usingVirtualDom",!1),N(this,"virtualDom",new ct),N(this,"mouse"),N(this,"mouseTail",null),N(this,"tailPositions",[]),N(this,"emitter",Vd()),N(this,"nextUserInteractionEvent"),N(this,"legacy_missingNodeRetryMap",{}),N(this,"cache",Xr()),N(this,"imageMap",new Map),N(this,"canvasEventMap",new Map),N(this,"mirror",so()),N(this,"styleMirror",new Ed),N(this,"mediaManager"),N(this,"firstFullSnapshot",null),N(this,"newDocumentQueue",[]),N(this,"mousePos",null),N(this,"touchActive",null),N(this,"lastMouseDownEvent",null),N(this,"lastHoveredRootNode"),N(this,"lastSelectionData",null),N(this,"constructedStyleMutations",[]),N(this,"adoptedStyleSheets",[]),N(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const a of[this.mouseTail,this.iframe])a&&(a.setAttribute("width",String(l.width)),a.setAttribute("height",String(l.height)))}),N(this,"applyEventsSynchronously",l=>{for(const a of l){switch(a.type){case K.DomContentLoaded:case K.Load:case K.Custom:continue;case K.FullSnapshot:case K.Meta:case K.Plugin:case K.IncrementalSnapshot:break}this.getCastFn(a,!0)()}}),N(this,"getCastFn",(l,a=!1)=>{let u;switch(l.type){case K.DomContentLoaded:case K.Load:break;case K.Custom:u=()=>{this.emitter.emit(L.CustomEvent,l)};break;case K.Meta:u=()=>this.emitter.emit(L.Resize,{width:l.data.width,height:l.data.height});break;case K.FullSnapshot:u=()=>{var h;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,a),(h=this.iframe.contentWindow)==null||h.scrollTo(l.data.initialOffset)};break;case K.IncrementalSnapshot:u=()=>{if(this.applyIncremental(l,a),!a&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const h of this.service.state.context.events)if(!(h.timestamp<=l.timestamp)&&this.isUserInteraction(h)){h.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=h);break}if(this.nextUserInteractionEvent){const h=this.nextUserInteractionEvent.delay-l.delay,f={speed:Math.min(Math.round(h/zd),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:f}),this.emitter.emit(L.SkipStart,f)}}};break}return()=>{u&&u();for(const f of this.config.plugins||[])f.handler&&f.handler(l,a,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const h=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[h]){const f=()=>{h<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(L.Finish))};let p=50;l.type===K.IncrementalSnapshot&&l.data.source===F.MouseMove&&l.data.positions.length&&(p+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(f,p)}this.emitter.emit(L.EventCast,l)}}),!(t!=null&&t.liveMode)&&e.length<2)throw new Error("Replayer need at least 2 events.");const i={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,inactivePeriodThreshold:10*1e3,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:is,useVirtualDom:!0,logger:console};this.config=Object.assign({},i,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(L.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});this.emitter.on(L.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(a,u,c)=>{Rn({event:a,mutation:u,target:c,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(a,u)=>{a.source===F.StyleSheetRule?this.applyStyleSheetRule(a,u):a.source===F.StyleDeclaration&&this.applyStyleDeclaration(a,u)},afterAppend:(a,u)=>{for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(a,{id:u,replayer:this})}};if(this.iframe.contentDocument)try{Si(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(a){console.warn(a)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const a in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[a],c=Ei(u.node,this.mirror,this.virtualDom.mirror);Si(c,u.node,l,this.virtualDom.mirror),u.node=c}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(a=>{this.applyStyleSheetMutation(a)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(a=>{this.applyAdoptedStyleSheet(a)}),this.adoptedStyleSheets=[]}if(this.mousePos&&(this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null),this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null,this.lastMouseDownEvent){const[l,a]=this.lastMouseDownEvent;l.dispatchEvent(a)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(L.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const r=new Id([],{speed:this.config.speed});this.service=Dd({events:e.map(l=>t&&t.unpackFn?t.unpackFn(l):l).sort((l,a)=>l.timestamp-a.timestamp),timer:r,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(L.StateChange,{player:l})}),this.speedService=_d({normalSpeed:-1,timer:r}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(L.StateChange,{speed:l})}),this.mediaManager=new Bd({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const n=this.service.state.context.events.find(l=>l.type===K.Meta),o=this.service.state.context.events.find(l=>l.type===K.FullSnapshot);if(n){const{width:l,height:a}=n.data;setTimeout(()=>{this.emitter.emit(L.Resize,{width:l,height:a})},0)}o&&setTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),(l=this.iframe.contentWindow)==null||l.scrollTo(o.data.initialOffset))},1),this.service.state.context.events.find(On)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(e,t){return this.emitter.on(e,t),this}off(e,t){return this.emitter.off(e,t),this}setConfig(e){Object.keys(e).forEach(t=>{e[t],this.config[t]=e[t]}),this.config.skipInactive||this.backToNormal(),typeof e.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),typeof e.mouseTail!="undefined"&&(e.mouseTail===!1?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"))}getMetaData(){const 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}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:e,events:t}=this.service.state.context;return e-t[0].timestamp}getMirror(){return this.mirror}play(e=0){var t,i;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:e}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}})),(i=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||i.classList.remove("rrweb-paused"),this.emitter.emit(L.Start)}pause(e){var t,i;e===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof e=="number"&&(this.play(e),this.service.send({type:"PAUSE"})),(i=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||i.classList.add("rrweb-paused"),this.emitter.emit(L.Pause)}resume(e=0){this.warn("The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(L.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(L.Destroy)}startLive(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})}addEvent(e){const t=this.config.unpackFn?this.config.unpackFn(e):e;On(t)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:t}}))}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=Xr()}setupDom(){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),this.config.mouseTail!==!1&&(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");const e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Rd(this.iframe.contentWindow,this.iframe.contentDocument),bd(this.iframe.contentWindow))}rebuildFullSnapshot(e,t=!1){if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&this.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const i=[],r=new Set,n=(a,u)=>{if(a.nodeName==="DIALOG"&&r.add(a),this.collectIframeAndAttachDocument(i,a),this.mediaManager.isSupportedMediaElement(a)){const{events:c}=this.service.state.context;this.mediaManager.addMediaElements(a,e.timestamp-c[0].timestamp,this.mirror)}for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(a,{id:u,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),_c(e.data.node,{doc:this.iframe.contentDocument,afterAppend:n,cache:this.cache,mirror:this.mirror}),n(this.iframe.contentDocument,e.data.node.id);for(const{mutationInQueue:a,builtNode:u}of i)this.attachDocumentToIframe(a,u),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:o,head:l}=this.iframe.contentDocument;this.insertStyleRules(o,l),r.forEach(a=>ni(a)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(L.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(e,t){var i;const r=Td(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),!!r.length)if(this.usingVirtualDom){const n=this.virtualDom.createElement("style");this.virtualDom.mirror.add(n,Tl(n,this.virtualDom.unserializedId)),e.insertBefore(n,t),n.rules.push({source:F.StyleSheetRule,adds:r.map((o,l)=>({rule:o,index:l}))})}else{const n=document.createElement("style");e.insertBefore(n,t);for(let o=0;o<r.length;o++)(i=n.sheet)==null||i.insertRule(r[o],o)}}attachDocumentToIframe(e,t){const i=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,r=[],n=new Set,o=(l,a)=>{l.nodeName==="DIALOG"&&n.add(l),this.collectIframeAndAttachDocument(r,l);const u=i.getMeta(l);if((u==null?void 0:u.type)===Pe.Element&&(u==null?void 0:u.tagName.toUpperCase())==="HTML"){const{documentElement:c,head:h}=t.contentDocument;this.insertStyleRules(c,h)}if(!this.usingVirtualDom)for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(l,{id:a,replayer:this})};St(e.node,{doc:t.contentDocument,mirror:i,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(t.contentDocument,e.node.id);for(const{mutationInQueue:l,builtNode:a}of r)this.attachDocumentToIframe(l,a),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);n.forEach(l=>ni(l))}collectIframeAndAttachDocument(e,t){if(es(t,this.mirror)){const i=this.newDocumentQueue.find(r=>r.parentId===this.mirror.getId(t));i&&e.push({mutationInQueue:i,builtNode:t})}}waitForStylesheetLoad(){var e;const t=(e=this.iframe.contentDocument)==null?void 0:e.head;if(t){const i=new Set;let r,n=this.service.state;const o=()=>{n=this.service.state};this.emitter.on(L.Start,o),this.emitter.on(L.Pause,o);const l=()=>{this.emitter.off(L.Start,o),this.emitter.off(L.Pause,o)};t.querySelectorAll('link[rel="stylesheet"]').forEach(a=>{a.sheet||(i.add(a),a.addEventListener("load",()=>{i.delete(a),i.size===0&&r!==-1&&(n.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(L.LoadStylesheetEnd),r&&clearTimeout(r),l())}))}),i.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(L.LoadStylesheetStart),r=setTimeout(()=>{n.matches("playing")&&this.play(this.getCurrentTime()),r=-1,l()},this.config.loadTimeout))}}async preloadAllImages(){const e=[];for(const t of this.service.state.context.events)t.type===K.IncrementalSnapshot&&t.data.source===F.CanvasMutation&&(e.push(this.deserializeAndPreloadCanvasEvents(t.data,t)),("commands"in t.data?t.data.commands:[t.data]).forEach(r=>{this.preloadImages(r,t)}));return Promise.all(e)}preloadImages(e,t){if(e.property==="drawImage"&&typeof e.args[0]=="string"&&!this.imageMap.has(t)){const i=document.createElement("canvas"),r=i.getContext("2d"),n=r==null?void 0:r.createImageData(i.width,i.height);r==null||r.putImageData(n,0,0)}}async deserializeAndPreloadCanvasEvents(e,t){if(!this.canvasEventMap.has(t)){const i={isUnchanged:!0};if("commands"in e){const r=await Promise.all(e.commands.map(async n=>{const o=await Promise.all(n.args.map(Le(this.imageMap,null,i)));return oe(P({},n),{args:o})}));i.isUnchanged===!1&&this.canvasEventMap.set(t,oe(P({},e),{commands:r}))}else{const r=await Promise.all(e.args.map(Le(this.imageMap,null,i)));i.isUnchanged===!1&&this.canvasEventMap.set(t,oe(P({},e),{args:r}))}}}applyIncremental(e,t){var i,r,n;const{data:o}=e;switch(o.source){case F.Mutation:{try{this.applyMutation(o,t)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,o)}break}case F.Drag:case F.TouchMove:case F.MouseMove:if(t){const l=o.positions[o.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:o}}else o.positions.forEach(l=>{const a={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,t,o)},delay:l.timeOffset+e.timestamp-this.service.state.context.baselineTime};this.timer.addAction(a)}),this.timer.addAction({doAction(){},delay:e.delay-((i=o.positions[0])==null?void 0:i.timeOffset)});break;case F.MouseInteraction:{if(o.id===-1)break;const l=new Event(Ma(re[o.type])),a=this.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);this.emitter.emit(L.MouseInteraction,{type:o.type,target:a});const{triggerFocus:u}=this.config;switch(o.type){case re.Blur:"blur"in a&&a.blur();break;case re.Focus:u&&a.focus&&a.focus({preventScroll:!0});break;case re.Click:case re.TouchStart:case re.TouchEnd:case re.MouseDown:case re.MouseUp:t?(o.type===re.TouchStart?this.touchActive=!0:o.type===re.TouchEnd&&(this.touchActive=!1),o.type===re.MouseDown?this.lastMouseDownEvent=[a,l]:o.type===re.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:o.x||0,y:o.y||0,id:o.id,debugData:o}):(o.type===re.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x||0,o.y||0,o.id,t,o),o.type===re.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===re.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===re.TouchEnd?this.mouse.classList.remove("touch-active"):a.dispatchEvent(l));break;case re.TouchCancel:t?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:a.dispatchEvent(l)}break}case F.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.scrollData=o;break}this.applyScroll(o,t);break}case F.ViewportResize:this.emitter.emit(L.Resize,{width:o.width,height:o.height});break;case F.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.inputData=o;break}this.applyInput(o);break}case F.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const a=l,{events:u}=this.service.state.context;this.mediaManager.mediaMutation({target:a,timeOffset:e.timestamp-u[0].timestamp,mutation:o});break}case F.StyleSheetRule:case F.StyleDeclaration:{this.usingVirtualDom?o.styleId?this.constructedStyleMutations.push(o):o.id&&((r=this.virtualDom.mirror.getNode(o.id))==null||r.rules.push(o)):this.applyStyleSheetMutation(o);break}case F.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.canvasMutations.push({event:e,mutation:o})}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);Rn({event:e,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case F.Font:{try{const l=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(n=this.iframe.contentDocument)==null||n.fonts.add(l)}catch(l){this.warn(l)}break}case F.Selection:{if(t){this.lastSelectionData=o;break}this.applySelection(o);break}case F.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(o):this.applyAdoptedStyleSheet(o);break}case F.Visibility:{const{mutations:l}=o;for(const a of l){const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(a.id):this.mirror.getNode(a.id);u&&u instanceof Element&&(u.style.visibility=a.isVisible?"visible":"hidden")}break}}}applyMutation(e,t){if(this.config.useVirtualDom&&!this.usingVirtualDom&&t&&(this.usingVirtualDom=!0,ed(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const u in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[u],h=_l(c.node,this.virtualDom,this.mirror);h&&(c.node=h)}catch(c){this.warn(c)}const i=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;e.removes=e.removes.filter(u=>i.getNode(u.id)?!0:(this.warnNodeNotFound(e,u.id),!1)),e.removes.forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return;let f=i.getNode(u.parentId);if(!f)return this.warnNodeNotFound(e,u.parentId);if(u.isShadow&&si(f)&&(f=f.shadowRoot),i.removeNodeFromMap(h),f)try{f.removeChild(h),this.usingVirtualDom&&h.nodeName==="#text"&&f.nodeName==="STYLE"&&((c=f.rules)==null?void 0:c.length)>0&&(f.rules=[])}catch(p){if(p instanceof DOMException)this.warn("parent could not remove child in mutation",f,h,e);else throw p}});const r=P({},this.legacy_missingNodeRetryMap),n=[],o=u=>{let c=null;return u.nextId&&(c=i.getNode(u.nextId)),u.nextId!==null&&u.nextId!==void 0&&u.nextId!==-1&&!c},l=u=>{var c,h;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let f=i.getNode(u.parentId);if(!f)return u.node.type===Pe.Document?this.newDocumentQueue.push(u):n.push(u);u.node.isShadow&&(si(f)||f.attachShadow({mode:"open"}),f=f.shadowRoot);let p=null,y=null;if(u.previousId&&(p=i.getNode(u.previousId)),u.nextId&&(y=i.getNode(u.nextId)),o(u))return n.push(u);if(u.node.rootId&&!i.getNode(u.node.rootId))return;const b=u.node.rootId?i.getNode(u.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(es(f,i)){this.attachDocumentToIframe(u,f);return}const d=(v,x)=>{if(!this.usingVirtualDom){ni(v);for(const R of this.config.plugins||[])R.onBuild&&R.onBuild(v,{id:x,replayer:this})}},m=St(u.node,{doc:b,mirror:i,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:d});if(u.previousId===-1||u.nextId===-1){r[u.node.id]={node:m,mutation:u};return}const w=i.getMeta(f);if(w&&w.type===Pe.Element&&u.node.type===Pe.Text){const v=Array.isArray(f.childNodes)?f.childNodes:Array.from(f.childNodes);if(w.tagName==="textarea")for(const x of v)x.nodeType===f.TEXT_NODE&&f.removeChild(x);else if(w.tagName==="style"&&v.length===1)for(const x of v)x.nodeType===f.TEXT_NODE&&!i.hasNode(x)&&(m.textContent=x.textContent,f.removeChild(x))}else if((w==null?void 0:w.type)===Pe.Document){const v=f;u.node.type===Pe.DocumentType&&((c=v.childNodes[0])==null?void 0:c.nodeType)===Node.DOCUMENT_TYPE_NODE&&v.removeChild(v.childNodes[0]),m.nodeName==="HTML"&&v.documentElement&&v.removeChild(v.documentElement)}if(p&&p.nextSibling&&p.nextSibling.parentNode?f.insertBefore(m,p.nextSibling):y&&y.parentNode?f.contains(y)?f.insertBefore(m,y):f.insertBefore(m,null):f.appendChild(m),d(m,u.node.id),this.usingVirtualDom&&m.nodeName==="#text"&&f.nodeName==="STYLE"&&((h=f.rules)==null?void 0:h.length)>0&&(f.rules=[]),es(m,this.mirror)){const v=this.mirror.getId(m),x=this.newDocumentQueue.find(R=>R.parentId===v);x&&(this.attachDocumentToIframe(x,m),this.newDocumentQueue=this.newDocumentQueue.filter(R=>R!==x))}(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(r,f,m,u)};e.adds.forEach(u=>{l(u)});const a=Date.now();for(;n.length;){const u=Cd(n);if(n.length=0,Date.now()-a>500){this.warn("Timeout in the loop, please check the resolve tree data:",u);break}for(const c of u)i.getNode(c.value.parentId)?Pl(c,f=>{l(f)}):this.debug("Drop resolve tree since there is no parent for the root node.",c)}Object.keys(r).length&&Object.assign(this.legacy_missingNodeRetryMap,r),Sd(e.texts).forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return e.removes.find(p=>p.id===u.id)?void 0:this.warnNodeNotFound(e,u.id);const f=h.parentElement;if(u.value&&f&&f.tagName==="STYLE"?h.textContent=_i(u.value,this.cache):h.textContent=u.value,this.usingVirtualDom){const p=h.parentNode;((c=p==null?void 0:p.rules)==null?void 0:c.length)>0&&(p.rules=[])}}),e.attributes.forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return e.removes.find(f=>f.id===u.id)?void 0:this.warnNodeNotFound(e,u.id);for(const f in u.attributes)if(typeof f=="string"){const p=u.attributes[f];if(p===null)h.removeAttribute(f),f==="open"&&Ud(h,u);else if(typeof p=="string")try{if(f==="_cssText"&&(h.nodeName==="LINK"||h.nodeName==="STYLE"))try{const y=i.getMeta(h),b=St(oe(P({},y),{attributes:P(P({},y.attributes),u.attributes)}),{doc:h.ownerDocument,mirror:i,skipChild:!0,hackCss:!0,cache:this.cache});Object.assign(y.attributes,u.attributes);const d=h.nextSibling,m=h.parentNode;if(b&&m){m.removeChild(h),m.insertBefore(b,d),i.replace(u.id,b);break}}catch(y){}if(f==="value"&&h.nodeName==="TEXTAREA"){const y=h;y.childNodes.forEach(d=>y.removeChild(d));const b=(c=h.ownerDocument)==null?void 0:c.createTextNode(p);b&&y.appendChild(b)}else h.setAttribute(f,p);f==="rr_open_mode"&&h.nodeName==="DIALOG"&&ni(h,u)}catch(y){this.warn("An error occurred may due to the checkout feature.",y)}else if(f==="style"){const y=p,b=h;for(const d in y)if(y[d]===!1)b.style.removeProperty(d);else if(y[d]instanceof Array){const m=y[d];b.style.setProperty(d,m[0],m[1])}else{const m=y[d];b.style.setProperty(d,m)}}}})}applyScroll(e,t){var i,r;const n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(e,e.id);const o=this.mirror.getMeta(n);if(n===this.iframe.contentDocument)(i=this.iframe.contentWindow)==null||i.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else if((o==null?void 0:o.type)===Pe.Document)(r=n.defaultView)==null||r.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else try{n.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"})}catch(l){}}applyInput(e){const t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(i){}}applySelection(e){try{const t=new Set,i=e.ranges.map(({start:r,startOffset:n,end:o,endOffset:l})=>{const a=this.mirror.getNode(r),u=this.mirror.getNode(o);if(!a||!u)return;const c=new Range;c.setStart(a,n),c.setEnd(u,l);const h=a.ownerDocument,f=h==null?void 0:h.getSelection();return f&&t.add(f),{range:c,selection:f}});t.forEach(r=>r.removeAllRanges()),i.forEach(r=>{var n;return r&&((n=r.selection)==null?void 0:n.addRange(r.range))})}catch(t){}}applyStyleSheetMutation(e){var t;let i=null;e.styleId?i=this.styleMirror.getStyle(e.styleId):e.id&&(i=((t=this.mirror.getNode(e.id))==null?void 0:t.sheet)||null),i&&(e.source===F.StyleSheetRule?this.applyStyleSheetRule(e,i):e.source===F.StyleDeclaration&&this.applyStyleDeclaration(e,i))}applyStyleSheetRule(e,t){var i,r,n,o;if((i=e.adds)==null||i.forEach(({rule:l,index:a})=>{try{if(Array.isArray(a)){const{positions:u,index:c}=vn(a);vt(t.cssRules,u).insertRule(l,c)}else{const u=a===void 0?void 0:Math.min(a,t.cssRules.length);t==null||t.insertRule(l,u)}}catch(u){}}),(r=e.removes)==null||r.forEach(({index:l})=>{try{if(Array.isArray(l)){const{positions:a,index:u}=vn(l);vt(t.cssRules,a).deleteRule(u||0)}else t==null||t.deleteRule(l)}catch(a){}}),e.replace)try{(n=t.replace)==null||n.call(t,e.replace)}catch(l){}if(e.replaceSync)try{(o=t.replaceSync)==null||o.call(t,e.replaceSync)}catch(l){}}applyStyleDeclaration(e,t){e.set&&vt(t.rules,e.index).style.setProperty(e.set.property,e.set.value,e.set.priority),e.remove&&vt(t.rules,e.index).style.removeProperty(e.remove.property)}applyAdoptedStyleSheet(e){var t;const i=this.mirror.getNode(e.id);if(!i)return;(t=e.styles)==null||t.forEach(l=>{var a;let u=null,c=null;if(si(i)?c=((a=i.ownerDocument)==null?void 0:a.defaultView)||null:i.nodeName==="#document"&&(c=i.defaultView),!!c)try{u=new c.CSSStyleSheet,this.styleMirror.add(u,l.styleId),this.applyStyleSheetRule({source:F.StyleSheetRule,adds:l.rules},u)}catch(h){}});const r=10;let n=0;const o=(l,a)=>{const u=a.map(c=>this.styleMirror.getStyle(c)).filter(c=>c!==null);si(l)?l.shadowRoot.adoptedStyleSheets=u:l.nodeName==="#document"&&(l.adoptedStyleSheets=u),u.length!==a.length&&n<r&&(setTimeout(()=>o(l,a),0+100*n),n++)};o(i,e.styleIds)}legacy_resolveMissingNode(e,t,i,r){const{previousId:n,nextId:o}=r,l=n&&e[n],a=o&&e[o];if(l){const{node:u,mutation:c}=l;t.insertBefore(u,i),delete e[c.node.id],delete this.legacy_missingNodeRetryMap[c.node.id],(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(e,t,u,c)}if(a){const{node:u,mutation:c}=a;t.insertBefore(u,i.nextSibling),delete e[c.node.id],delete this.legacy_missingNodeRetryMap[c.node.id],(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(e,t,u,c)}}moveAndHover(e,t,i,r,n){const o=this.mirror.getNode(i);if(!o)return this.debugNodeNotFound(n,i);const l=Ll(o,this.iframe),a=e*l.absoluteScale+l.x,u=t*l.absoluteScale+l.y;this.mouse.style.left=`${a}px`,this.mouse.style.top=`${u}px`,r||this.drawMouseTail({x:a,y:u}),this.hoverElements(o)}drawMouseTail(e){if(!this.mouseTail)return;const{lineCap:t,lineWidth:i,strokeStyle:r,duration:n}=this.config.mouseTail===!0?is:Object.assign({},is,this.config.mouseTail),o=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=i,l.lineCap=t,l.strokeStyle=r,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(a=>l.lineTo(a.x,a.y)),l.stroke())};this.tailPositions.push(e),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==e),o()},n/this.speedService.state.context.timer.speed)}hoverElements(e){var t;(t=this.lastHoveredRootNode||this.iframe.contentDocument)==null||t.querySelectorAll(".\\:hover").forEach(r=>{r.classList.remove(":hover")}),this.lastHoveredRootNode=e.getRootNode();let i=e;for(;i;)i.classList&&i.classList.add(":hover"),i=i.parentElement}isUserInteraction(e){return e.type!==K.IncrementalSnapshot?!1:e.data.source>F.Mutation&&e.data.source<=F.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(L.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(e,t){this.warn(`Node with id '${t}' not found. `,e)}warnCanvasMutationFailed(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)}debugNodeNotFound(e,t){this.debug(`Node with id '${t}' not found. `,e)}warn(...e){this.config.showWarning&&this.config.logger.warn(In,...e)}debug(...e){this.config.showDebug&&this.config.logger.log(In,...e)}}var ye=Uint8Array,$e=Uint16Array,zs=Uint32Array,Wl=new ye([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]),Gl=new ye([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]),Gd=new ye([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yl=function(s,e){for(var t=new $e(31),i=0;i<31;++i)t[i]=e+=1<<s[i-1];for(var r=new zs(t[30]),i=1;i<30;++i)for(var n=t[i];n<t[i+1];++n)r[n]=n-t[i]<<5|i;return[t,r]},jl=Yl(Wl,2),Zl=jl[0],Yd=jl[1];Zl[28]=258,Yd[258]=28;var jd=Yl(Gl,0),Zd=jd[0],Vs=new $e(32768);for(var Z=0;Z<32768;++Z){var ke=(Z&43690)>>>1|(Z&21845)<<1;ke=(ke&52428)>>>2|(ke&13107)<<2,ke=(ke&61680)>>>4|(ke&3855)<<4,Vs[Z]=((ke&65280)>>>8|(ke&255)<<8)>>>1}var Et=function(s,e,t){for(var i=s.length,r=0,n=new $e(e);r<i;++r)++n[s[r]-1];var o=new $e(e);for(r=0;r<e;++r)o[r]=o[r-1]+n[r-1]<<1;var l;if(t){l=new $e(1<<e);var a=15-e;for(r=0;r<i;++r)if(s[r])for(var u=r<<4|s[r],c=e-s[r],h=o[s[r]-1]++<<c,f=h|(1<<c)-1;h<=f;++h)l[Vs[h]>>>a]=u}else for(l=new $e(i),r=0;r<i;++r)l[r]=Vs[o[s[r]-1]++]>>>15-s[r];return l},Ft=new ye(288);for(var Z=0;Z<144;++Z)Ft[Z]=8;for(var Z=144;Z<256;++Z)Ft[Z]=9;for(var Z=256;Z<280;++Z)Ft[Z]=7;for(var Z=280;Z<288;++Z)Ft[Z]=8;var Hl=new ye(32);for(var Z=0;Z<32;++Z)Hl[Z]=5;var Hd=Et(Ft,9,1),Xd=Et(Hl,5,1),ss=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},ve=function(s,e,t){var i=e/8>>0;return(s[i]|s[i+1]<<8)>>>(e&7)&t},rs=function(s,e){var t=e/8>>0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>>(e&7)},Jd=function(s){return(s/8>>0)+(s&7&&1)},Xl=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof $e?$e:s instanceof zs?zs:ye)(t-e);return i.set(s.subarray(e,t)),i},Kd=function(s,e,t){var i=s.length,r=!e||t,n=!t||t.i;t||(t={}),e||(e=new ye(i*3));var o=function(j){var g=e.length;if(j>g){var D=new ye(Math.max(g*2,j));D.set(e),e=D}},l=t.f||0,a=t.p||0,u=t.b||0,c=t.l,h=t.d,f=t.m,p=t.n,y=i*8;do{if(!c){t.f=l=ve(s,a,1);var b=ve(s,a+1,3);if(a+=3,b)if(b==1)c=Hd,h=Xd,f=9,p=5;else if(b==2){var v=ve(s,a,31)+257,x=ve(s,a+10,15)+4,R=v+ve(s,a+5,31)+1;a+=14;for(var _=new ye(R),z=new ye(19),A=0;A<x;++A)z[Gd[A]]=ve(s,a+A*3,7);a+=x*3;var G=ss(z),Y=(1<<G)-1;if(!n&&a+R*(G+7)>y)break;for(var ce=Et(z,G,1),A=0;A<R;){var ue=ce[ve(s,a,Y)];a+=ue&15;var d=ue>>>4;if(d<16)_[A++]=d;else{var ee=0,V=0;for(d==16?(V=3+ve(s,a,3),a+=2,ee=_[A-1]):d==17?(V=3+ve(s,a,7),a+=3):d==18&&(V=11+ve(s,a,127),a+=7);V--;)_[A++]=ee}}var ae=_.subarray(0,v),k=_.subarray(v);f=ss(ae),p=ss(k),c=Et(ae,f,1),h=Et(k,p,1)}else throw"invalid block type";else{var d=Jd(a)+4,m=s[d-4]|s[d-3]<<8,w=d+m;if(w>i){if(n)throw"unexpected EOF";break}r&&o(u+m),e.set(s.subarray(d,w),u),t.b=u+=m,t.p=a=w*8;continue}if(a>y)throw"unexpected EOF"}r&&o(u+131072);for(var W=(1<<f)-1,he=(1<<p)-1,le=f+p+18;n||a+le<y;){var ee=c[rs(s,a)&W],te=ee>>>4;if(a+=ee&15,a>y)throw"unexpected EOF";if(!ee)throw"invalid length/literal";if(te<256)e[u++]=te;else if(te==256){c=null;break}else{var Q=te-254;if(te>264){var A=te-257,we=Wl[A];Q=ve(s,a,(1<<we)-1)+Zl[A],a+=we}var Ee=h[rs(s,a)&he],E=Ee>>>4;if(!Ee)throw"invalid distance";a+=Ee&15;var k=Zd[E];if(E>3){var we=Gl[E];k+=rs(s,a)&(1<<we)-1,a+=we}if(a>y)throw"unexpected EOF";r&&o(u+131072);for(var J=u+Q;u<J;u+=4)e[u]=e[u-k],e[u+1]=e[u+1-k],e[u+2]=e[u+2-k],e[u+3]=e[u+3-k];u=J}}t.l=c,t.p=a,t.b=u,c&&(l=1,t.m=f,t.d=h,t.n=p)}while(!l);return u==e.length?e:Xl(e,0,u)},Qd=function(s){if((s[0]&15)!=8||s[0]>>>4>7||(s[0]<<8|s[1])%31)throw"invalid zlib data";if(s[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function qd(s,e){return Kd((Qd(s),s.subarray(2,-4)),e)}function ep(s,e){for(var t=s.length,i=new ye(s.length+(s.length>>>1)),r=0,n=function(u){i[r++]=u},o=0;o<t;++o){if(r+5>i.length){var l=new ye(r+8+(t-o<<1));l.set(i),i=l}var a=s.charCodeAt(o);n(a)}return Xl(i,0,r)}function tp(s,e){var t="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(s);for(var i=0;i<s.length;){var r=s[i++];r<128||e?t+=String.fromCharCode(r):r<224?t+=String.fromCharCode((r&31)<<6|s[i++]&63):r<240?t+=String.fromCharCode((r&15)<<12|(s[i++]&63)<<6|s[i++]&63):(r=((r&15)<<18|(s[i++]&63)<<12|(s[i++]&63)<<6|s[i++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023))}return t}const Dn="v1",ip=s=>{if(typeof s!="string")return s;try{const e=JSON.parse(s);if(e.timestamp)return e}catch(e){}try{const e=JSON.parse(tp(qd(ep(s,!0))));if(e.v===Dn)return e;throw new Error(`These events were packed with packer ${e.v} which is incompatible with current packer ${Dn}.`)}catch(e){throw console.error(e),new Error("Unknown data format.")}};var at=(s=>(s[s.DomContentLoaded=0]="DomContentLoaded",s[s.Load=1]="Load",s[s.FullSnapshot=2]="FullSnapshot",s[s.IncrementalSnapshot=3]="IncrementalSnapshot",s[s.Meta=4]="Meta",s[s.Custom=5]="Custom",s[s.Plugin=6]="Plugin",s))(at||{}),Ws=(s=>(s[s.Mutation=0]="Mutation",s[s.MouseMove=1]="MouseMove",s[s.MouseInteraction=2]="MouseInteraction",s[s.Scroll=3]="Scroll",s[s.ViewportResize=4]="ViewportResize",s[s.Input=5]="Input",s[s.TouchMove=6]="TouchMove",s[s.MediaInteraction=7]="MediaInteraction",s[s.StyleSheetRule=8]="StyleSheetRule",s[s.CanvasMutation=9]="CanvasMutation",s[s.Font=10]="Font",s[s.Log=11]="Log",s[s.Drag=12]="Drag",s[s.StyleDeclaration=13]="StyleDeclaration",s[s.Selection=14]="Selection",s[s.AdoptedStyleSheet=15]="AdoptedStyleSheet",s[s.CustomElement=16]="CustomElement",s[s.Visibility=17]="Visibility",s))(Ws||{});function _n(s){let e="";return Object.keys(s).forEach(t=>{e+=`${t}: ${s[t]};`}),e}function wt(s,e=2){let t=String(s);const i=Math.pow(10,e-1);if(s<i)for(;String(i).length>t.length;)t=`0${s}`;return t}const Jl=1e3,Gs=60*Jl,Tn=60*Gs;function oi(s){if(s<=0)return"00:00";const e=Math.floor(s/Tn);s=s%Tn;const t=Math.floor(s/Gs);s=s%Gs;const i=Math.floor(s/Jl);return e?`${wt(e)}:${wt(t)}:${wt(i)}`:`${wt(t)}:${wt(i)}`}function sp(s){return s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.resolve()}function rp(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function kn(){let s=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(e=>{e in document&&(s=s||!!document[e])}),s}function np(s){return document.addEventListener("fullscreenchange",s),document.addEventListener("webkitfullscreenchange",s),document.addEventListener("mozfullscreenchange",s),document.addEventListener("MSFullscreenChange",s),()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("webkitfullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.removeEventListener("MSFullscreenChange",s)}}function Pn(s){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(s)]}function op(s){return s.type!==at.IncrementalSnapshot?!1:s.data.source>Ws.Mutation&&s.data.source<=Ws.Input}function lp(s,e){const t=[];let i=s[0].timestamp;for(const r of s)op(r)&&(r.timestamp-i>e&&t.push([i,r.timestamp]),i=r.timestamp);return t}const Ln=.001,ap=1;function br(){return{normalizationApplied:!1,toReplayerTime:s=>s,toPlayerTime:s=>s,toReplayerAbsolute:s=>s,toPlayerAbsolute:s=>s,normalizeEvent:s=>s}}function up(s,e=!0){if(!s.length){const l=br();return{events:s,mapper:l}}const t=e?cp(s):null,i=s.map(l=>Kl(l,t)),r=$n(s),n=$n(i),o=pp(t,r,n);return{events:i,mapper:o}}function $n(s){return s.reduce((e,t)=>Math.min(e,t.timestamp),1/0)}function cp(s){const e=s.find(l=>l.type===at.FullSnapshot);if(!e)return null;const t=s.filter(l=>l.type===at.IncrementalSnapshot&&l.timestamp<e.timestamp);if(!t.length)return null;const i=t.reduce((l,a)=>Math.min(l,a.timestamp),1/0),r=t.reduce((l,a)=>Math.max(l,a.timestamp),-1/0),n=Math.max(0,r-i),o=Math.max(n,ap);return{earliestProblem:i,span:n,blockSpan:o,blockStart:e.timestamp+Ln,tailShift:Ln+o,firstFullTimestamp:e.timestamp}}function Kl(s,e){if(!e)return s;const t=s.type===at.IncrementalSnapshot&&s.timestamp<e.firstFullTimestamp,i=hp(s.timestamp,t,e);return i===s.timestamp?s:oe(P({},s),{timestamp:i})}function hp(s,e,t){if(!t)return s;if(s>t.firstFullTimestamp)return s+t.tailShift;if(e&&s<t.firstFullTimestamp){if(t.span===0)return t.blockStart;const i=t.blockSpan/t.span;return t.blockStart+(s-t.earliestProblem)*i}return s}function fp(s,e){if(!e)return s;if(s>e.firstFullTimestamp)return s+e.tailShift;if(s>=e.earliestProblem&&s<e.firstFullTimestamp){if(e.span===0)return e.blockStart;const t=e.blockSpan/e.span;return e.blockStart+(s-e.earliestProblem)*t}return s}function dp(s,e){if(!e)return s;const t=e.blockStart+e.blockSpan,i=e.firstFullTimestamp+e.tailShift;if(s>=i)return s-e.tailShift;if(s>=e.blockStart&&s<=t){if(e.span===0)return e.earliestProblem;const r=e.blockSpan/e.span;return e.earliestProblem+(s-e.blockStart)/r}return s}function pp(s,e,t){const i=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0,n=l=>fp(l,s),o=l=>dp(l,s);return{normalizationApplied:!!s,normalizeEvent:l=>Kl(l,s),toReplayerAbsolute:n,toPlayerAbsolute:o,toReplayerTime:l=>{const a=i+l;return n(a)-r},toPlayerTime:l=>{const a=r+l;return o(a)-i}}}function mp(s){let e,t,i,r,n,o,l,a,u;return{c(){e=ne("div"),t=ne("input"),i=ge(),r=ne("label"),n=ge(),o=ne("span"),l=Ve(s[3]),M(t,"type","checkbox"),M(t,"id",s[2]),t.disabled=s[1],M(t,"class","svelte-a6h7w7"),M(r,"for",s[2]),M(r,"class","svelte-a6h7w7"),M(o,"class","label svelte-a6h7w7"),M(e,"class","switch svelte-a6h7w7"),et(e,"disabled",s[1])},m(c,h){Te(c,e,h),$(e,t),t.checked=s[0],$(e,i),$(e,r),$(e,n),$(e,o),$(o,l),a||(u=Ke(t,"change",s[4]),a=!0)},p(c,[h]){h&4&&M(t,"id",c[2]),h&2&&(t.disabled=c[1]),h&1&&(t.checked=c[0]),h&4&&M(r,"for",c[2]),h&8&&di(l,c[3]),h&2&&et(e,"disabled",c[1])},i:xt,o:xt,d(c){c&&Me(e),a=!1,u()}}}function gp(s,e,t){let{disabled:i}=e,{checked:r}=e,{id:n}=e,{label:o}=e;function l(){r=this.checked,t(0,r)}return s.$$set=a=>{"disabled"in a&&t(1,i=a.disabled),"checked"in a&&t(0,r=a.checked),"id"in a&&t(2,n=a.id),"label"in a&&t(3,o=a.label)},[r,i,n,o,l]}class yp extends Xs{constructor(e){super(),Hs(this,e,gp,mp,Ys,{disabled:1,checked:0,id:2,label:3})}}function Fn(s,e,t){const i=s.slice();return i[40]=e[t],i}function Bn(s,e,t){const i=s.slice();return i[43]=e[t],i}function Un(s,e,t){const i=s.slice();return i[46]=e[t],i}function zn(s){let e,t,i,r=oi(s[6])+"",n,o,l,a,u,c,h,f,p,y,b=oi(s[8].totalTime)+"",d,m,w,v,x,R,_,z,A,G,Y,ce,ue,ee=je(s[13]),V=[];for(let E=0;E<ee.length;E+=1)V[E]=Vn(Un(s,ee,E));let ae=je(s[9]),k=[];for(let E=0;E<ae.length;E+=1)k[E]=Wn(Bn(s,ae,E));function W(E,J){return E[7]==="playing"?vp:wp}let he=W(s),le=he(s),te=je(s[3]),Q=[];for(let E=0;E<te.length;E+=1)Q[E]=Gn(Fn(s,te,E));function we(E){s[30](E)}let Ee={id:"skip",disabled:s[10]==="skipping",label:"skip inactive"};return s[0]!==void 0&&(Ee.checked=s[0]),_=new yp({props:Ee}),ze.push(()=>va(_,"checked",we)),{c(){e=ne("div"),t=ne("div"),i=ne("span"),n=Ve(r),o=ge(),l=ne("div"),a=ne("div"),u=ge();for(let E=0;E<V.length;E+=1)V[E].c();c=ge();for(let E=0;E<k.length;E+=1)k[E].c();h=ge(),f=ne("div"),p=ge(),y=ne("span"),d=Ve(b),m=ge(),w=ne("div"),v=ne("button"),le.c(),x=ge();for(let E=0;E<Q.length;E+=1)Q[E].c();R=ge(),to(_.$$.fragment),A=ge(),G=ne("button"),G.innerHTML=`<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M916 380c-26.4 0-48-21.6-48-48L868 223.2 613.6 477.6c-18.4
74
+ ***************************************************************************** */function Sn(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i,r,n=t.call(s),o=[];try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){r={error:l}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}return o}var Qe;(function(s){s[s.NotStarted=0]="NotStarted",s[s.Running=1]="Running",s[s.Stopped=2]="Stopped"})(Qe||(Qe={}));var Fl={type:"xstate.init"};function ts(s){return s===void 0?[]:[].concat(s)}function Je(s){return{type:"xstate.assign",assignment:s}}function En(s,e){return typeof(s=typeof s=="string"&&e&&e[s]?e[s]:s)=="string"?{type:s}:typeof s=="function"?{type:s.name,exec:s}:s}function Ai(s){return function(e){return s===e}}function Bl(s){return typeof s=="string"?{type:s}:s}function xn(s,e){return{value:s,context:e,actions:[],changed:!1,matches:Ai(s)}}function An(s,e,t){var i=e,r=!1;return[s.filter(function(n){if(n.type==="xstate.assign"){r=!0;var o=Object.assign({},i);return typeof n.assignment=="function"?o=n.assignment(i,t):Object.keys(n.assignment).forEach(function(l){o[l]=typeof n.assignment[l]=="function"?n.assignment[l](i,t):n.assignment[l]}),i=o,!1}return!0}),i,r]}function Ul(s,e){e===void 0&&(e={});var t=Sn(An(ts(s.states[s.initial].entry).map(function(o){return En(o,e.actions)}),s.context,Fl),2),i=t[0],r=t[1],n={config:s,_options:e,initialState:{value:s.initial,actions:i,context:r,matches:Ai(s.initial)},transition:function(o,l){var a,u,c=typeof o=="string"?{value:o,context:s.context}:o,h=c.value,f=c.context,p=Bl(l),y=s.states[h];if(y.on){var b=ts(y.on[p.type]);try{for(var d=function(W){var he=typeof Symbol=="function"&&Symbol.iterator,le=he&&W[he],te=0;if(le)return le.call(W);if(W&&typeof W.length=="number")return{next:function(){return W&&te>=W.length&&(W=void 0),{value:W&&W[te++],done:!W}}};throw new TypeError(he?"Object is not iterable.":"Symbol.iterator is not defined.")}(b),m=d.next();!m.done;m=d.next()){var w=m.value;if(w===void 0)return xn(h,f);var v=typeof w=="string"?{target:w}:w,x=v.target,R=v.actions,_=R===void 0?[]:R,z=v.cond,A=z===void 0?function(){return!0}:z,G=x===void 0,Y=x!=null?x:h,ce=s.states[Y];if(A(f,p)){var ue=Sn(An((G?ts(_):[].concat(y.exit,_,ce.entry).filter(function(W){return W})).map(function(W){return En(W,n._options.actions)}),f,p),3),ee=ue[0],V=ue[1],ae=ue[2],k=x!=null?x:h;return{value:k,context:V,actions:ee,changed:x!==h||ee.length>0||ae,matches:Ai(k)}}}}catch(W){a={error:W}}finally{try{m&&!m.done&&(u=d.return)&&u.call(d)}finally{if(a)throw a.error}}}return xn(h,f)}};return n}var Nn=function(s,e){return s.actions.forEach(function(t){var i=t.exec;return i&&i(s.context,e)})};function zl(s){var e=s.initialState,t=Qe.NotStarted,i=new Set,r={_machine:s,send:function(n){t===Qe.Running&&(e=s.transition(e,n),Nn(e,Bl(n)),i.forEach(function(o){return o(e)}))},subscribe:function(n){return i.add(n),n(e),{unsubscribe:function(){return i.delete(n)}}},start:function(n){if(n){var o=typeof n=="object"?n:{context:s.config.context,value:n};e={value:o.value,actions:[],context:o.context,matches:Ai(o.value)}}return t=Qe.Running,Nn(e,Fl),r},stop:function(){return t=Qe.Stopped,i.clear(),r},get state(){return e},get status(){return t}};return r}function Od(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.type===K.Meta&&i.timestamp<=e)return s.slice(t)}return s}function Dd(s,{getCastFn:e,applyEventsSynchronously:t,emitter:i}){const r=Ul({id:"player",context:s,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:Je({lastPlayedEvent:(n,o)=>o.type==="CAST_EVENT"?o.payload.event:n.lastPlayedEvent}),recordTimeOffset:Je((n,o)=>{let l=n.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(l=o.payload.timeOffset),oe(P({},n),{timeOffset:l,baselineTime:n.events[0].timestamp+l})}),play(n){var o;const{timer:l,events:a,baselineTime:u,lastPlayedEvent:c}=n;l.clear();for(const y of a)Cn(y,u);const h=Od(a,u);let f=c==null?void 0:c.timestamp;(c==null?void 0:c.type)===K.IncrementalSnapshot&&c.data.source===F.MouseMove&&(f=c.timestamp+((o=c.data.positions[0])==null?void 0:o.timeOffset)),u<(f||0)&&i.emit(L.PlayBack);const p=new Array;for(const y of h)if(!(f&&f<u&&(y.timestamp<=f||y===c)))if(y.timestamp<=u)p.push(y);else{const b=e(y,!1);l.addAction({doAction:()=>{b()},delay:y.delay})}t(p),i.emit(L.Flush),l.start()},pause(n){n.timer.clear()},resetLastPlayedEvent:Je(n=>oe(P({},n),{lastPlayedEvent:null})),startLive:Je({baselineTime:(n,o)=>(n.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:Je((n,o)=>{const{baselineTime:l,timer:a,events:u}=n;if(o.type==="ADD_EVENT"){const{event:c}=o.payload;Cn(c,l);let h=u.length-1;if(!u[h]||u[h].timestamp<=c.timestamp)u.push(c);else{let y=-1,b=0;for(;b<=h;){const d=Math.floor((b+h)/2);u[d].timestamp<=c.timestamp?b=d+1:h=d-1}y===-1&&(y=b),u.splice(y,0,c)}const f=c.timestamp<l,p=e(c,f);f?p():a.isActive()&&a.addAction({doAction:()=>{p()},delay:c.delay})}return oe(P({},n),{events:u})})}});return zl(r)}function _d(s){const e=Ul({id:"speed",context:s,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:(t,i)=>{"payload"in i&&t.timer.setSpeed(i.payload.speed)},recordSpeed:Je({normalSpeed:t=>t.timer.speed}),restoreSpeed:t=>{t.timer.setSpeed(t.normalSpeed)}}});return zl(e)}const Td=s=>[`.${s} { background: currentColor }`,"noscript { display: none !important; }"],Mn=new Map;function Vl(s,e){let t=Mn.get(s);return t||(t=new Map,Mn.set(s,t)),t.has(e)||t.set(e,[]),t.get(e)}function Le(s,e,t){return async i=>{if(i&&typeof i=="object"&&"rr_type"in i)if(t&&(t.isUnchanged=!1),i.rr_type==="ImageBitmap"&&"args"in i){const r=await Le(s,e,t)(i.args);return await createImageBitmap.apply(null,r)}else if("index"in i){if(t||e===null)return i;const{rr_type:r,index:n}=i;return Vl(e,r)[n]}else if("args"in i){const{rr_type:r,args:n}=i,o=window[r];return new o(...await Promise.all(n.map(Le(s,e,t))))}else{if("base64"in i)return xd(i.base64);if("src"in i){const r=s.get(i.src);if(r)return r;{const n=new Image;return n.src=i.src,s.set(i.src,n),n}}else if("data"in i&&i.rr_type==="Blob"){const r=await Promise.all(i.data.map(Le(s,e,t)));return new Blob(r,{type:i.type})}}else if(Array.isArray(i))return await Promise.all(i.map(Le(s,e,t)));return i}}function kd(s,e){try{return e===xi.WebGL?s.getContext("webgl")||s.getContext("experimental-webgl"):s.getContext("webgl2")}catch(t){return null}}const Pd=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Ld(s,e){if(!(e!=null&&e.constructor))return;const{name:t}=e.constructor;if(!Pd.includes(t))return;const i=Vl(s,t);i.includes(e)||i.push(e)}async function $d({mutation:s,target:e,type:t,imageMap:i,errorHandler:r}){try{const n=kd(e,t);if(!n)return;if(s.setter){n[s.property]=s.args[0];return}const o=n[s.property],l=await Promise.all(s.args.map(Le(i,n))),a=o.apply(n,l);Ld(n,a);const u=!1}catch(n){r(s,n)}}async function Fd({event:s,mutations:e,target:t,imageMap:i,errorHandler:r}){const n=t.getContext("2d");if(!n){r(e[0],new Error("Canvas context is null"));return}const o=e.map(async a=>Promise.all(a.args.map(Le(i,n))));(await Promise.all(o)).forEach((a,u)=>{const c=e[u];try{if(c.setter){n[c.property]=c.args[0];return}const h=n[c.property];c.property==="drawImage"&&typeof c.args[0]=="string"?(i.get(s),h.apply(n,c.args)):h.apply(n,a)}catch(h){r(c,h)}})}async function Rn({event:s,mutation:e,target:t,imageMap:i,canvasEventMap:r,errorHandler:n}){try{const o=r.get(s)||e,l="commands"in o?o.commands:[o];if([xi.WebGL,xi.WebGL2].includes(e.type)){for(let a=0;a<l.length;a++){const u=l[a];await $d({mutation:u,type:e.type,target:t,imageMap:i,errorHandler:n})}return}await Fd({event:s,mutations:l,target:t,imageMap:i,errorHandler:n})}catch(o){n(e,o)}}class Bd{constructor(e){N(this,"mediaMap",new Map),N(this,"warn"),N(this,"service"),N(this,"speedService"),N(this,"emitter"),N(this,"getCurrentTime"),N(this,"metadataCallbackMap",new Map),this.warn=e.warn,this.service=e.service,this.speedService=e.speedService,this.emitter=e.emitter,this.getCurrentTime=e.getCurrentTime,this.emitter.on(L.Start,this.start.bind(this)),this.emitter.on(L.SkipStart,this.start.bind(this)),this.emitter.on(L.Pause,this.pause.bind(this)),this.emitter.on(L.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(e={pause:!1}){this.mediaMap.forEach((t,i)=>{this.syncTargetWithState(i),e.pause&&i.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:e,target:t,mediaState:i}){if(i.isPlaying){const n=(e-i.lastInteractionTimeOffset)/1e3*i.playbackRate,o="duration"in t&&t.duration;if(Number.isNaN(o)){this.waitForMetadata(t);return}let l=i.currentTimeAtLastInteraction+n;t.loop&&o!==!1&&(l=l%o),t.currentTime=l}else t.pause(),t.currentTime=i.currentTimeAtLastInteraction}waitForMetadata(e){if(this.metadataCallbackMap.has(e)||!("addEventListener"in e))return;const t=()=>{this.metadataCallbackMap.delete(e);const i=this.mediaMap.get(e);i&&this.seekTo({time:this.getCurrentTime(),target:e,mediaState:i})};this.metadataCallbackMap.set(e,t),e.addEventListener("loadedmetadata",t,{once:!0})}getMediaStateFromMutation({target:e,timeOffset:t,mutation:i}){var p,y,b,d,m;const r=this.mediaMap.get(e),{type:n,playbackRate:o,currentTime:l,muted:a,volume:u,loop:c}=i;return{isPlaying:n===Us.Play||n!==Us.Pause&&((r==null?void 0:r.isPlaying)||e.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(p=l!=null?l:r==null?void 0:r.currentTimeAtLastInteraction)!=null?p:0,lastInteractionTimeOffset:t,playbackRate:(y=o!=null?o:r==null?void 0:r.playbackRate)!=null?y:1,volume:(b=u!=null?u:r==null?void 0:r.volume)!=null?b:1,muted:(d=a!=null?a:r==null?void 0:r.muted)!=null?d:e.getAttribute("muted")===null,loop:(m=c!=null?c:r==null?void 0:r.loop)!=null?m:e.getAttribute("loop")===null}}syncTargetWithState(e){const t=this.mediaMap.get(e);if(!t)return;const{muted:i,loop:r,volume:n,isPlaying:o}=t,l=this.service.state.matches("paused"),a=t.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:e,mediaState:t}),e.volume!==n&&(e.volume=n),e.muted=i,e.loop=r,e.playbackRate!==a&&(e.playbackRate=a),o&&!l?e.play():e.pause()}catch(u){this.warn(`Failed to replay media interactions: ${u.message||u}`)}}addMediaElements(e,t,i){if(!["AUDIO","VIDEO"].includes(e.nodeName))return;const r=e,n=i.getMeta(r);if(!n||!("attributes"in n))return;const o=this.service.state.matches("paused"),l=n.attributes;let a=!1;l.rr_mediaState?a=l.rr_mediaState==="played":a=r.getAttribute("autoplay")!==null,a&&o&&r.pause();let u=1;typeof l.rr_mediaPlaybackRate=="number"&&(u=l.rr_mediaPlaybackRate);let c=!1;typeof l.rr_mediaMuted=="boolean"?c=l.rr_mediaMuted:c=r.getAttribute("muted")!==null;let h=!1;typeof l.rr_mediaLoop=="boolean"?h=l.rr_mediaLoop:h=r.getAttribute("loop")!==null;let f=1;typeof l.rr_mediaVolume=="number"&&(f=l.rr_mediaVolume);let p=0;typeof l.rr_mediaCurrentTime=="number"&&(p=l.rr_mediaCurrentTime),this.mediaMap.set(r,{isPlaying:a,currentTimeAtLastInteraction:p,lastInteractionTimeOffset:t,playbackRate:u,volume:f,muted:c,loop:h}),this.syncTargetWithState(r)}mediaMutation({target:e,timeOffset:t,mutation:i}){this.mediaMap.set(e,this.getMediaStateFromMutation({target:e,timeOffset:t,mutation:i})),this.syncTargetWithState(e)}isSupportedMediaElement(e){return["AUDIO","VIDEO"].includes(e.nodeName)}reset(){this.mediaMap.clear()}}function ni(s,e){if(s.nodeName!=="DIALOG"||s instanceof Se)return;const t=s,i=t.open,r=i&&t.matches("dialog:modal"),n=t.getAttribute("rr_open_mode"),o=typeof(e==null?void 0:e.attributes.open)=="string"||typeof t.getAttribute("open")=="string",l=n==="modal";if(!(i&&!(r&&n==="non-modal"||!r&&l))){if(!t.isConnected){console.warn("dialog is not attached to the dom",t);return}i&&t.close(),o&&(l?t.showModal():t.show())}}function Ud(s,e){if(s.nodeName!=="DIALOG"||s instanceof Se)return;const t=s;if(!t.isConnected){console.warn("dialog is not attached to the dom",t);return}e.attributes.open===null&&(t.removeAttribute("open"),t.removeAttribute("rr_open_mode"))}const zd=5*1e3,Vd=$l||Md,In="[replayer]",is={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function On(s){return s.type==K.IncrementalSnapshot&&(s.data.source==F.TouchMove||s.data.source==F.MouseInteraction&&s.data.type==re.TouchStart)}class Wd{constructor(e,t){if(N(this,"wrapper"),N(this,"iframe"),N(this,"service"),N(this,"speedService"),N(this,"config"),N(this,"usingVirtualDom",!1),N(this,"virtualDom",new ct),N(this,"mouse"),N(this,"mouseTail",null),N(this,"tailPositions",[]),N(this,"emitter",Vd()),N(this,"nextUserInteractionEvent"),N(this,"legacy_missingNodeRetryMap",{}),N(this,"cache",Xr()),N(this,"imageMap",new Map),N(this,"canvasEventMap",new Map),N(this,"mirror",so()),N(this,"styleMirror",new Ed),N(this,"mediaManager"),N(this,"firstFullSnapshot",null),N(this,"newDocumentQueue",[]),N(this,"mousePos",null),N(this,"touchActive",null),N(this,"lastMouseDownEvent",null),N(this,"lastHoveredRootNode"),N(this,"lastSelectionData",null),N(this,"constructedStyleMutations",[]),N(this,"adoptedStyleSheets",[]),N(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const a of[this.mouseTail,this.iframe])a&&(a.setAttribute("width",String(l.width)),a.setAttribute("height",String(l.height)))}),N(this,"applyEventsSynchronously",l=>{for(const a of l){switch(a.type){case K.DomContentLoaded:case K.Load:case K.Custom:continue;case K.FullSnapshot:case K.Meta:case K.Plugin:case K.IncrementalSnapshot:break}this.getCastFn(a,!0)()}}),N(this,"getCastFn",(l,a=!1)=>{let u;switch(l.type){case K.DomContentLoaded:case K.Load:break;case K.Custom:u=()=>{this.emitter.emit(L.CustomEvent,l)};break;case K.Meta:u=()=>this.emitter.emit(L.Resize,{width:l.data.width,height:l.data.height});break;case K.FullSnapshot:u=()=>{var h;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,a),(h=this.iframe.contentWindow)==null||h.scrollTo(l.data.initialOffset)};break;case K.IncrementalSnapshot:u=()=>{if(this.applyIncremental(l,a),!a&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const h of this.service.state.context.events)if(!(h.timestamp<=l.timestamp)&&this.isUserInteraction(h)){h.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=h);break}if(this.nextUserInteractionEvent){const h=this.nextUserInteractionEvent.delay-l.delay,f={speed:Math.min(Math.round(h/zd),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:f}),this.emitter.emit(L.SkipStart,f)}}};break}return()=>{u&&u();for(const f of this.config.plugins||[])f.handler&&f.handler(l,a,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const h=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[h]){const f=()=>{h<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(L.Finish))};let p=50;l.type===K.IncrementalSnapshot&&l.data.source===F.MouseMove&&l.data.positions.length&&(p+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(f,p)}this.emitter.emit(L.EventCast,l)}}),!(t!=null&&t.liveMode)&&e.length<2)throw new Error("Replayer need at least 2 events.");const i={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,inactivePeriodThreshold:10*1e3,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:is,useVirtualDom:!0,logger:console};this.config=Object.assign({},i,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(L.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});this.emitter.on(L.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(a,u,c)=>{Rn({event:a,mutation:u,target:c,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(a,u)=>{a.source===F.StyleSheetRule?this.applyStyleSheetRule(a,u):a.source===F.StyleDeclaration&&this.applyStyleDeclaration(a,u)},afterAppend:(a,u)=>{for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(a,{id:u,replayer:this})}};if(this.iframe.contentDocument)try{Si(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(a){console.warn(a)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const a in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[a],c=Ei(u.node,this.mirror,this.virtualDom.mirror);Si(c,u.node,l,this.virtualDom.mirror),u.node=c}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(a=>{this.applyStyleSheetMutation(a)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(a=>{this.applyAdoptedStyleSheet(a)}),this.adoptedStyleSheets=[]}if(this.mousePos&&(this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null),this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null,this.lastMouseDownEvent){const[l,a]=this.lastMouseDownEvent;l.dispatchEvent(a)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(L.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const r=new Id([],{speed:this.config.speed});this.service=Dd({events:e.map(l=>t&&t.unpackFn?t.unpackFn(l):l).sort((l,a)=>l.timestamp-a.timestamp),timer:r,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(L.StateChange,{player:l})}),this.speedService=_d({normalSpeed:-1,timer:r}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(L.StateChange,{speed:l})}),this.mediaManager=new Bd({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const n=this.service.state.context.events.find(l=>l.type===K.Meta),o=this.service.state.context.events.find(l=>l.type===K.FullSnapshot);if(n){const{width:l,height:a}=n.data;setTimeout(()=>{this.emitter.emit(L.Resize,{width:l,height:a})},0)}o&&setTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),(l=this.iframe.contentWindow)==null||l.scrollTo(o.data.initialOffset))},1),this.service.state.context.events.find(On)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(e,t){return this.emitter.on(e,t),this}off(e,t){return this.emitter.off(e,t),this}setConfig(e){Object.keys(e).forEach(t=>{e[t],this.config[t]=e[t]}),this.config.skipInactive||this.backToNormal(),typeof e.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),typeof e.mouseTail!="undefined"&&(e.mouseTail===!1?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"))}getMetaData(){const 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}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:e,events:t}=this.service.state.context;return e-t[0].timestamp}getMirror(){return this.mirror}play(e=0){var t,i;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:e}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}})),(i=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||i.classList.remove("rrweb-paused"),this.emitter.emit(L.Start)}pause(e){var t,i;e===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof e=="number"&&(this.play(e),this.service.send({type:"PAUSE"})),(i=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||i.classList.add("rrweb-paused"),this.emitter.emit(L.Pause)}resume(e=0){this.warn("The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(L.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(L.Destroy)}startLive(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})}addEvent(e){const t=this.config.unpackFn?this.config.unpackFn(e):e;On(t)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:t}}))}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=Xr()}setupDom(){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),this.config.mouseTail!==!1&&(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");const e=["allow-same-origin","allow-scripts"];this.config.UNSAFE_replayCanvas,this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Rd(this.iframe.contentWindow,this.iframe.contentDocument),bd(this.iframe.contentWindow))}rebuildFullSnapshot(e,t=!1){if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&this.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const i=[],r=new Set,n=(a,u)=>{if(a.nodeName==="DIALOG"&&r.add(a),this.collectIframeAndAttachDocument(i,a),this.mediaManager.isSupportedMediaElement(a)){const{events:c}=this.service.state.context;this.mediaManager.addMediaElements(a,e.timestamp-c[0].timestamp,this.mirror)}for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(a,{id:u,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),_c(e.data.node,{doc:this.iframe.contentDocument,afterAppend:n,cache:this.cache,mirror:this.mirror}),n(this.iframe.contentDocument,e.data.node.id);for(const{mutationInQueue:a,builtNode:u}of i)this.attachDocumentToIframe(a,u),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:o,head:l}=this.iframe.contentDocument;this.insertStyleRules(o,l),r.forEach(a=>ni(a)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(L.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(e,t){var i;const r=Td(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),!!r.length)if(this.usingVirtualDom){const n=this.virtualDom.createElement("style");this.virtualDom.mirror.add(n,Tl(n,this.virtualDom.unserializedId)),e.insertBefore(n,t),n.rules.push({source:F.StyleSheetRule,adds:r.map((o,l)=>({rule:o,index:l}))})}else{const n=document.createElement("style");e.insertBefore(n,t);for(let o=0;o<r.length;o++)(i=n.sheet)==null||i.insertRule(r[o],o)}}attachDocumentToIframe(e,t){const i=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,r=[],n=new Set,o=(l,a)=>{l.nodeName==="DIALOG"&&n.add(l),this.collectIframeAndAttachDocument(r,l);const u=i.getMeta(l);if((u==null?void 0:u.type)===Pe.Element&&(u==null?void 0:u.tagName.toUpperCase())==="HTML"){const{documentElement:c,head:h}=t.contentDocument;this.insertStyleRules(c,h)}if(!this.usingVirtualDom)for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(l,{id:a,replayer:this})};St(e.node,{doc:t.contentDocument,mirror:i,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(t.contentDocument,e.node.id);for(const{mutationInQueue:l,builtNode:a}of r)this.attachDocumentToIframe(l,a),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);n.forEach(l=>ni(l))}collectIframeAndAttachDocument(e,t){if(es(t,this.mirror)){const i=this.newDocumentQueue.find(r=>r.parentId===this.mirror.getId(t));i&&e.push({mutationInQueue:i,builtNode:t})}}waitForStylesheetLoad(){var e;const t=(e=this.iframe.contentDocument)==null?void 0:e.head;if(t){const i=new Set;let r,n=this.service.state;const o=()=>{n=this.service.state};this.emitter.on(L.Start,o),this.emitter.on(L.Pause,o);const l=()=>{this.emitter.off(L.Start,o),this.emitter.off(L.Pause,o)};t.querySelectorAll('link[rel="stylesheet"]').forEach(a=>{a.sheet||(i.add(a),a.addEventListener("load",()=>{i.delete(a),i.size===0&&r!==-1&&(n.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(L.LoadStylesheetEnd),r&&clearTimeout(r),l())}))}),i.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(L.LoadStylesheetStart),r=setTimeout(()=>{n.matches("playing")&&this.play(this.getCurrentTime()),r=-1,l()},this.config.loadTimeout))}}async preloadAllImages(){const e=[];for(const t of this.service.state.context.events)t.type===K.IncrementalSnapshot&&t.data.source===F.CanvasMutation&&(e.push(this.deserializeAndPreloadCanvasEvents(t.data,t)),("commands"in t.data?t.data.commands:[t.data]).forEach(r=>{this.preloadImages(r,t)}));return Promise.all(e)}preloadImages(e,t){if(e.property==="drawImage"&&typeof e.args[0]=="string"&&!this.imageMap.has(t)){const i=document.createElement("canvas"),r=i.getContext("2d"),n=r==null?void 0:r.createImageData(i.width,i.height);r==null||r.putImageData(n,0,0)}}async deserializeAndPreloadCanvasEvents(e,t){if(!this.canvasEventMap.has(t)){const i={isUnchanged:!0};if("commands"in e){const r=await Promise.all(e.commands.map(async n=>{const o=await Promise.all(n.args.map(Le(this.imageMap,null,i)));return oe(P({},n),{args:o})}));i.isUnchanged===!1&&this.canvasEventMap.set(t,oe(P({},e),{commands:r}))}else{const r=await Promise.all(e.args.map(Le(this.imageMap,null,i)));i.isUnchanged===!1&&this.canvasEventMap.set(t,oe(P({},e),{args:r}))}}}applyIncremental(e,t){var i,r,n;const{data:o}=e;switch(o.source){case F.Mutation:{try{this.applyMutation(o,t)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,o)}break}case F.Drag:case F.TouchMove:case F.MouseMove:if(t){const l=o.positions[o.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:o}}else o.positions.forEach(l=>{const a={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,t,o)},delay:l.timeOffset+e.timestamp-this.service.state.context.baselineTime};this.timer.addAction(a)}),this.timer.addAction({doAction(){},delay:e.delay-((i=o.positions[0])==null?void 0:i.timeOffset)});break;case F.MouseInteraction:{if(o.id===-1)break;const l=new Event(Ma(re[o.type])),a=this.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);this.emitter.emit(L.MouseInteraction,{type:o.type,target:a});const{triggerFocus:u}=this.config;switch(o.type){case re.Blur:"blur"in a&&a.blur();break;case re.Focus:u&&a.focus&&a.focus({preventScroll:!0});break;case re.Click:case re.TouchStart:case re.TouchEnd:case re.MouseDown:case re.MouseUp:t?(o.type===re.TouchStart?this.touchActive=!0:o.type===re.TouchEnd&&(this.touchActive=!1),o.type===re.MouseDown?this.lastMouseDownEvent=[a,l]:o.type===re.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:o.x||0,y:o.y||0,id:o.id,debugData:o}):(o.type===re.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x||0,o.y||0,o.id,t,o),o.type===re.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===re.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===re.TouchEnd?this.mouse.classList.remove("touch-active"):a.dispatchEvent(l));break;case re.TouchCancel:t?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:a.dispatchEvent(l)}break}case F.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.scrollData=o;break}this.applyScroll(o,t);break}case F.ViewportResize:this.emitter.emit(L.Resize,{width:o.width,height:o.height});break;case F.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.inputData=o;break}this.applyInput(o);break}case F.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const a=l,{events:u}=this.service.state.context;this.mediaManager.mediaMutation({target:a,timeOffset:e.timestamp-u[0].timestamp,mutation:o});break}case F.StyleSheetRule:case F.StyleDeclaration:{this.usingVirtualDom?o.styleId?this.constructedStyleMutations.push(o):o.id&&((r=this.virtualDom.mirror.getNode(o.id))==null||r.rules.push(o)):this.applyStyleSheetMutation(o);break}case F.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.canvasMutations.push({event:e,mutation:o})}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);Rn({event:e,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case F.Font:{try{const l=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(n=this.iframe.contentDocument)==null||n.fonts.add(l)}catch(l){this.warn(l)}break}case F.Selection:{if(t){this.lastSelectionData=o;break}this.applySelection(o);break}case F.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(o):this.applyAdoptedStyleSheet(o);break}case F.Visibility:{const{mutations:l}=o;for(const a of l){const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(a.id):this.mirror.getNode(a.id);u&&u instanceof Element&&(u.style.visibility=a.isVisible?"visible":"hidden")}break}}}applyMutation(e,t){if(this.config.useVirtualDom&&!this.usingVirtualDom&&t&&(this.usingVirtualDom=!0,ed(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const u in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[u],h=_l(c.node,this.virtualDom,this.mirror);h&&(c.node=h)}catch(c){this.warn(c)}const i=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;e.removes=e.removes.filter(u=>i.getNode(u.id)?!0:(this.warnNodeNotFound(e,u.id),!1)),e.removes.forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return;let f=i.getNode(u.parentId);if(!f)return this.warnNodeNotFound(e,u.parentId);if(u.isShadow&&si(f)&&(f=f.shadowRoot),i.removeNodeFromMap(h),f)try{f.removeChild(h),this.usingVirtualDom&&h.nodeName==="#text"&&f.nodeName==="STYLE"&&((c=f.rules)==null?void 0:c.length)>0&&(f.rules=[])}catch(p){if(p instanceof DOMException)this.warn("parent could not remove child in mutation",f,h,e);else throw p}});const r=P({},this.legacy_missingNodeRetryMap),n=[],o=u=>{let c=null;return u.nextId&&(c=i.getNode(u.nextId)),u.nextId!==null&&u.nextId!==void 0&&u.nextId!==-1&&!c},l=u=>{var c,h;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let f=i.getNode(u.parentId);if(!f)return u.node.type===Pe.Document?this.newDocumentQueue.push(u):n.push(u);u.node.isShadow&&(si(f)||f.attachShadow({mode:"open"}),f=f.shadowRoot);let p=null,y=null;if(u.previousId&&(p=i.getNode(u.previousId)),u.nextId&&(y=i.getNode(u.nextId)),o(u))return n.push(u);if(u.node.rootId&&!i.getNode(u.node.rootId))return;const b=u.node.rootId?i.getNode(u.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(es(f,i)){this.attachDocumentToIframe(u,f);return}const d=(v,x)=>{if(!this.usingVirtualDom){ni(v);for(const R of this.config.plugins||[])R.onBuild&&R.onBuild(v,{id:x,replayer:this})}},m=St(u.node,{doc:b,mirror:i,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:d});if(u.previousId===-1||u.nextId===-1){r[u.node.id]={node:m,mutation:u};return}const w=i.getMeta(f);if(w&&w.type===Pe.Element&&u.node.type===Pe.Text){const v=Array.isArray(f.childNodes)?f.childNodes:Array.from(f.childNodes);if(w.tagName==="textarea")for(const x of v)x.nodeType===f.TEXT_NODE&&f.removeChild(x);else if(w.tagName==="style"&&v.length===1)for(const x of v)x.nodeType===f.TEXT_NODE&&!i.hasNode(x)&&(m.textContent=x.textContent,f.removeChild(x))}else if((w==null?void 0:w.type)===Pe.Document){const v=f;u.node.type===Pe.DocumentType&&((c=v.childNodes[0])==null?void 0:c.nodeType)===Node.DOCUMENT_TYPE_NODE&&v.removeChild(v.childNodes[0]),m.nodeName==="HTML"&&v.documentElement&&v.removeChild(v.documentElement)}if(p&&p.nextSibling&&p.nextSibling.parentNode?f.insertBefore(m,p.nextSibling):y&&y.parentNode?f.contains(y)?f.insertBefore(m,y):f.insertBefore(m,null):f.appendChild(m),d(m,u.node.id),this.usingVirtualDom&&m.nodeName==="#text"&&f.nodeName==="STYLE"&&((h=f.rules)==null?void 0:h.length)>0&&(f.rules=[]),es(m,this.mirror)){const v=this.mirror.getId(m),x=this.newDocumentQueue.find(R=>R.parentId===v);x&&(this.attachDocumentToIframe(x,m),this.newDocumentQueue=this.newDocumentQueue.filter(R=>R!==x))}(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(r,f,m,u)};e.adds.forEach(u=>{l(u)});const a=Date.now();for(;n.length;){const u=Cd(n);if(n.length=0,Date.now()-a>500){this.warn("Timeout in the loop, please check the resolve tree data:",u);break}for(const c of u)i.getNode(c.value.parentId)?Pl(c,f=>{l(f)}):this.debug("Drop resolve tree since there is no parent for the root node.",c)}Object.keys(r).length&&Object.assign(this.legacy_missingNodeRetryMap,r),Sd(e.texts).forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return e.removes.find(p=>p.id===u.id)?void 0:this.warnNodeNotFound(e,u.id);const f=h.parentElement;if(u.value&&f&&f.tagName==="STYLE"?h.textContent=_i(u.value,this.cache):h.textContent=u.value,this.usingVirtualDom){const p=h.parentNode;((c=p==null?void 0:p.rules)==null?void 0:c.length)>0&&(p.rules=[])}}),e.attributes.forEach(u=>{var c;const h=i.getNode(u.id);if(!h)return e.removes.find(f=>f.id===u.id)?void 0:this.warnNodeNotFound(e,u.id);for(const f in u.attributes)if(typeof f=="string"){const p=u.attributes[f];if(p===null)h.removeAttribute(f),f==="open"&&Ud(h,u);else if(typeof p=="string")try{if(f==="_cssText"&&(h.nodeName==="LINK"||h.nodeName==="STYLE"))try{const y=i.getMeta(h),b=St(oe(P({},y),{attributes:P(P({},y.attributes),u.attributes)}),{doc:h.ownerDocument,mirror:i,skipChild:!0,hackCss:!0,cache:this.cache});Object.assign(y.attributes,u.attributes);const d=h.nextSibling,m=h.parentNode;if(b&&m){m.removeChild(h),m.insertBefore(b,d),i.replace(u.id,b);break}}catch(y){}if(f==="value"&&h.nodeName==="TEXTAREA"){const y=h;y.childNodes.forEach(d=>y.removeChild(d));const b=(c=h.ownerDocument)==null?void 0:c.createTextNode(p);b&&y.appendChild(b)}else h.setAttribute(f,p);f==="rr_open_mode"&&h.nodeName==="DIALOG"&&ni(h,u)}catch(y){this.warn("An error occurred may due to the checkout feature.",y)}else if(f==="style"){const y=p,b=h;for(const d in y)if(y[d]===!1)b.style.removeProperty(d);else if(y[d]instanceof Array){const m=y[d];b.style.setProperty(d,m[0],m[1])}else{const m=y[d];b.style.setProperty(d,m)}}}})}applyScroll(e,t){var i,r;const n=this.mirror.getNode(e.id);if(!n)return this.debugNodeNotFound(e,e.id);const o=this.mirror.getMeta(n);if(n===this.iframe.contentDocument)(i=this.iframe.contentWindow)==null||i.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else if((o==null?void 0:o.type)===Pe.Document)(r=n.defaultView)==null||r.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else try{n.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"})}catch(l){}}applyInput(e){const t=this.mirror.getNode(e.id);if(!t)return this.debugNodeNotFound(e,e.id);try{t.checked=e.isChecked,t.value=e.text}catch(i){}}applySelection(e){try{const t=new Set,i=e.ranges.map(({start:r,startOffset:n,end:o,endOffset:l})=>{const a=this.mirror.getNode(r),u=this.mirror.getNode(o);if(!a||!u)return;const c=new Range;c.setStart(a,n),c.setEnd(u,l);const h=a.ownerDocument,f=h==null?void 0:h.getSelection();return f&&t.add(f),{range:c,selection:f}});t.forEach(r=>r.removeAllRanges()),i.forEach(r=>{var n;return r&&((n=r.selection)==null?void 0:n.addRange(r.range))})}catch(t){}}applyStyleSheetMutation(e){var t;let i=null;e.styleId?i=this.styleMirror.getStyle(e.styleId):e.id&&(i=((t=this.mirror.getNode(e.id))==null?void 0:t.sheet)||null),i&&(e.source===F.StyleSheetRule?this.applyStyleSheetRule(e,i):e.source===F.StyleDeclaration&&this.applyStyleDeclaration(e,i))}applyStyleSheetRule(e,t){var i,r,n,o;if((i=e.adds)==null||i.forEach(({rule:l,index:a})=>{try{if(Array.isArray(a)){const{positions:u,index:c}=vn(a);vt(t.cssRules,u).insertRule(l,c)}else{const u=a===void 0?void 0:Math.min(a,t.cssRules.length);t==null||t.insertRule(l,u)}}catch(u){}}),(r=e.removes)==null||r.forEach(({index:l})=>{try{if(Array.isArray(l)){const{positions:a,index:u}=vn(l);vt(t.cssRules,a).deleteRule(u||0)}else t==null||t.deleteRule(l)}catch(a){}}),e.replace)try{(n=t.replace)==null||n.call(t,e.replace)}catch(l){}if(e.replaceSync)try{(o=t.replaceSync)==null||o.call(t,e.replaceSync)}catch(l){}}applyStyleDeclaration(e,t){e.set&&vt(t.rules,e.index).style.setProperty(e.set.property,e.set.value,e.set.priority),e.remove&&vt(t.rules,e.index).style.removeProperty(e.remove.property)}applyAdoptedStyleSheet(e){var t;const i=this.mirror.getNode(e.id);if(!i)return;(t=e.styles)==null||t.forEach(l=>{var a;let u=null,c=null;if(si(i)?c=((a=i.ownerDocument)==null?void 0:a.defaultView)||null:i.nodeName==="#document"&&(c=i.defaultView),!!c)try{u=new c.CSSStyleSheet,this.styleMirror.add(u,l.styleId),this.applyStyleSheetRule({source:F.StyleSheetRule,adds:l.rules},u)}catch(h){}});const r=10;let n=0;const o=(l,a)=>{const u=a.map(c=>this.styleMirror.getStyle(c)).filter(c=>c!==null);si(l)?l.shadowRoot.adoptedStyleSheets=u:l.nodeName==="#document"&&(l.adoptedStyleSheets=u),u.length!==a.length&&n<r&&(setTimeout(()=>o(l,a),0+100*n),n++)};o(i,e.styleIds)}legacy_resolveMissingNode(e,t,i,r){const{previousId:n,nextId:o}=r,l=n&&e[n],a=o&&e[o];if(l){const{node:u,mutation:c}=l;t.insertBefore(u,i),delete e[c.node.id],delete this.legacy_missingNodeRetryMap[c.node.id],(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(e,t,u,c)}if(a){const{node:u,mutation:c}=a;t.insertBefore(u,i.nextSibling),delete e[c.node.id],delete this.legacy_missingNodeRetryMap[c.node.id],(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(e,t,u,c)}}moveAndHover(e,t,i,r,n){const o=this.mirror.getNode(i);if(!o)return this.debugNodeNotFound(n,i);const l=Ll(o,this.iframe),a=e*l.absoluteScale+l.x,u=t*l.absoluteScale+l.y;this.mouse.style.left=`${a}px`,this.mouse.style.top=`${u}px`,r||this.drawMouseTail({x:a,y:u}),this.hoverElements(o)}drawMouseTail(e){if(!this.mouseTail)return;const{lineCap:t,lineWidth:i,strokeStyle:r,duration:n}=this.config.mouseTail===!0?is:Object.assign({},is,this.config.mouseTail),o=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=i,l.lineCap=t,l.strokeStyle=r,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(a=>l.lineTo(a.x,a.y)),l.stroke())};this.tailPositions.push(e),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==e),o()},n/this.speedService.state.context.timer.speed)}hoverElements(e){var t;(t=this.lastHoveredRootNode||this.iframe.contentDocument)==null||t.querySelectorAll(".\\:hover").forEach(r=>{r.classList.remove(":hover")}),this.lastHoveredRootNode=e.getRootNode();let i=e;for(;i;)i.classList&&i.classList.add(":hover"),i=i.parentElement}isUserInteraction(e){return e.type!==K.IncrementalSnapshot?!1:e.data.source>F.Mutation&&e.data.source<=F.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(L.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(e,t){this.warn(`Node with id '${t}' not found. `,e)}warnCanvasMutationFailed(e,t){this.warn("Has error on canvas update",t,"canvas mutation:",e)}debugNodeNotFound(e,t){this.debug(`Node with id '${t}' not found. `,e)}warn(...e){this.config.showWarning&&this.config.logger.warn(In,...e)}debug(...e){this.config.showDebug&&this.config.logger.log(In,...e)}}var ye=Uint8Array,$e=Uint16Array,zs=Uint32Array,Wl=new ye([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]),Gl=new ye([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]),Gd=new ye([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yl=function(s,e){for(var t=new $e(31),i=0;i<31;++i)t[i]=e+=1<<s[i-1];for(var r=new zs(t[30]),i=1;i<30;++i)for(var n=t[i];n<t[i+1];++n)r[n]=n-t[i]<<5|i;return[t,r]},jl=Yl(Wl,2),Zl=jl[0],Yd=jl[1];Zl[28]=258,Yd[258]=28;var jd=Yl(Gl,0),Zd=jd[0],Vs=new $e(32768);for(var Z=0;Z<32768;++Z){var ke=(Z&43690)>>>1|(Z&21845)<<1;ke=(ke&52428)>>>2|(ke&13107)<<2,ke=(ke&61680)>>>4|(ke&3855)<<4,Vs[Z]=((ke&65280)>>>8|(ke&255)<<8)>>>1}var Et=function(s,e,t){for(var i=s.length,r=0,n=new $e(e);r<i;++r)++n[s[r]-1];var o=new $e(e);for(r=0;r<e;++r)o[r]=o[r-1]+n[r-1]<<1;var l;if(t){l=new $e(1<<e);var a=15-e;for(r=0;r<i;++r)if(s[r])for(var u=r<<4|s[r],c=e-s[r],h=o[s[r]-1]++<<c,f=h|(1<<c)-1;h<=f;++h)l[Vs[h]>>>a]=u}else for(l=new $e(i),r=0;r<i;++r)l[r]=Vs[o[s[r]-1]++]>>>15-s[r];return l},Ft=new ye(288);for(var Z=0;Z<144;++Z)Ft[Z]=8;for(var Z=144;Z<256;++Z)Ft[Z]=9;for(var Z=256;Z<280;++Z)Ft[Z]=7;for(var Z=280;Z<288;++Z)Ft[Z]=8;var Hl=new ye(32);for(var Z=0;Z<32;++Z)Hl[Z]=5;var Hd=Et(Ft,9,1),Xd=Et(Hl,5,1),ss=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},ve=function(s,e,t){var i=e/8>>0;return(s[i]|s[i+1]<<8)>>>(e&7)&t},rs=function(s,e){var t=e/8>>0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>>(e&7)},Jd=function(s){return(s/8>>0)+(s&7&&1)},Xl=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof $e?$e:s instanceof zs?zs:ye)(t-e);return i.set(s.subarray(e,t)),i},Kd=function(s,e,t){var i=s.length,r=!e||t,n=!t||t.i;t||(t={}),e||(e=new ye(i*3));var o=function(j){var g=e.length;if(j>g){var D=new ye(Math.max(g*2,j));D.set(e),e=D}},l=t.f||0,a=t.p||0,u=t.b||0,c=t.l,h=t.d,f=t.m,p=t.n,y=i*8;do{if(!c){t.f=l=ve(s,a,1);var b=ve(s,a+1,3);if(a+=3,b)if(b==1)c=Hd,h=Xd,f=9,p=5;else if(b==2){var v=ve(s,a,31)+257,x=ve(s,a+10,15)+4,R=v+ve(s,a+5,31)+1;a+=14;for(var _=new ye(R),z=new ye(19),A=0;A<x;++A)z[Gd[A]]=ve(s,a+A*3,7);a+=x*3;var G=ss(z),Y=(1<<G)-1;if(!n&&a+R*(G+7)>y)break;for(var ce=Et(z,G,1),A=0;A<R;){var ue=ce[ve(s,a,Y)];a+=ue&15;var d=ue>>>4;if(d<16)_[A++]=d;else{var ee=0,V=0;for(d==16?(V=3+ve(s,a,3),a+=2,ee=_[A-1]):d==17?(V=3+ve(s,a,7),a+=3):d==18&&(V=11+ve(s,a,127),a+=7);V--;)_[A++]=ee}}var ae=_.subarray(0,v),k=_.subarray(v);f=ss(ae),p=ss(k),c=Et(ae,f,1),h=Et(k,p,1)}else throw"invalid block type";else{var d=Jd(a)+4,m=s[d-4]|s[d-3]<<8,w=d+m;if(w>i){if(n)throw"unexpected EOF";break}r&&o(u+m),e.set(s.subarray(d,w),u),t.b=u+=m,t.p=a=w*8;continue}if(a>y)throw"unexpected EOF"}r&&o(u+131072);for(var W=(1<<f)-1,he=(1<<p)-1,le=f+p+18;n||a+le<y;){var ee=c[rs(s,a)&W],te=ee>>>4;if(a+=ee&15,a>y)throw"unexpected EOF";if(!ee)throw"invalid length/literal";if(te<256)e[u++]=te;else if(te==256){c=null;break}else{var Q=te-254;if(te>264){var A=te-257,we=Wl[A];Q=ve(s,a,(1<<we)-1)+Zl[A],a+=we}var Ee=h[rs(s,a)&he],E=Ee>>>4;if(!Ee)throw"invalid distance";a+=Ee&15;var k=Zd[E];if(E>3){var we=Gl[E];k+=rs(s,a)&(1<<we)-1,a+=we}if(a>y)throw"unexpected EOF";r&&o(u+131072);for(var J=u+Q;u<J;u+=4)e[u]=e[u-k],e[u+1]=e[u+1-k],e[u+2]=e[u+2-k],e[u+3]=e[u+3-k];u=J}}t.l=c,t.p=a,t.b=u,c&&(l=1,t.m=f,t.d=h,t.n=p)}while(!l);return u==e.length?e:Xl(e,0,u)},Qd=function(s){if((s[0]&15)!=8||s[0]>>>4>7||(s[0]<<8|s[1])%31)throw"invalid zlib data";if(s[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function qd(s,e){return Kd((Qd(s),s.subarray(2,-4)),e)}function ep(s,e){for(var t=s.length,i=new ye(s.length+(s.length>>>1)),r=0,n=function(u){i[r++]=u},o=0;o<t;++o){if(r+5>i.length){var l=new ye(r+8+(t-o<<1));l.set(i),i=l}var a=s.charCodeAt(o);n(a)}return Xl(i,0,r)}function tp(s,e){var t="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(s);for(var i=0;i<s.length;){var r=s[i++];r<128||e?t+=String.fromCharCode(r):r<224?t+=String.fromCharCode((r&31)<<6|s[i++]&63):r<240?t+=String.fromCharCode((r&15)<<12|(s[i++]&63)<<6|s[i++]&63):(r=((r&15)<<18|(s[i++]&63)<<12|(s[i++]&63)<<6|s[i++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023))}return t}const Dn="v1",ip=s=>{if(typeof s!="string")return s;try{const e=JSON.parse(s);if(e.timestamp)return e}catch(e){}try{const e=JSON.parse(tp(qd(ep(s,!0))));if(e.v===Dn)return e;throw new Error(`These events were packed with packer ${e.v} which is incompatible with current packer ${Dn}.`)}catch(e){throw console.error(e),new Error("Unknown data format.")}};var at=(s=>(s[s.DomContentLoaded=0]="DomContentLoaded",s[s.Load=1]="Load",s[s.FullSnapshot=2]="FullSnapshot",s[s.IncrementalSnapshot=3]="IncrementalSnapshot",s[s.Meta=4]="Meta",s[s.Custom=5]="Custom",s[s.Plugin=6]="Plugin",s))(at||{}),Ws=(s=>(s[s.Mutation=0]="Mutation",s[s.MouseMove=1]="MouseMove",s[s.MouseInteraction=2]="MouseInteraction",s[s.Scroll=3]="Scroll",s[s.ViewportResize=4]="ViewportResize",s[s.Input=5]="Input",s[s.TouchMove=6]="TouchMove",s[s.MediaInteraction=7]="MediaInteraction",s[s.StyleSheetRule=8]="StyleSheetRule",s[s.CanvasMutation=9]="CanvasMutation",s[s.Font=10]="Font",s[s.Log=11]="Log",s[s.Drag=12]="Drag",s[s.StyleDeclaration=13]="StyleDeclaration",s[s.Selection=14]="Selection",s[s.AdoptedStyleSheet=15]="AdoptedStyleSheet",s[s.CustomElement=16]="CustomElement",s[s.Visibility=17]="Visibility",s))(Ws||{});function _n(s){let e="";return Object.keys(s).forEach(t=>{e+=`${t}: ${s[t]};`}),e}function wt(s,e=2){let t=String(s);const i=Math.pow(10,e-1);if(s<i)for(;String(i).length>t.length;)t=`0${s}`;return t}const Jl=1e3,Gs=60*Jl,Tn=60*Gs;function oi(s){if(s<=0)return"00:00";const e=Math.floor(s/Tn);s=s%Tn;const t=Math.floor(s/Gs);s=s%Gs;const i=Math.floor(s/Jl);return e?`${wt(e)}:${wt(t)}:${wt(i)}`:`${wt(t)}:${wt(i)}`}function sp(s){return s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.resolve()}function rp(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function kn(){let s=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(e=>{e in document&&(s=s||!!document[e])}),s}function np(s){return document.addEventListener("fullscreenchange",s),document.addEventListener("webkitfullscreenchange",s),document.addEventListener("mozfullscreenchange",s),document.addEventListener("MSFullscreenChange",s),()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("webkitfullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.removeEventListener("MSFullscreenChange",s)}}function Pn(s){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(s)]}function op(s){return s.type!==at.IncrementalSnapshot?!1:s.data.source>Ws.Mutation&&s.data.source<=Ws.Input}function lp(s,e){const t=[];let i=s[0].timestamp;for(const r of s)op(r)&&(r.timestamp-i>e&&t.push([i,r.timestamp]),i=r.timestamp);return t}const Ln=.001,ap=1;function br(){return{normalizationApplied:!1,toReplayerTime:s=>s,toPlayerTime:s=>s,toReplayerAbsolute:s=>s,toPlayerAbsolute:s=>s,normalizeEvent:s=>s}}function up(s,e=!0){if(!s.length){const l=br();return{events:s,mapper:l}}const t=e?cp(s):null,i=s.map(l=>Kl(l,t)),r=$n(s),n=$n(i),o=pp(t,r,n);return{events:i,mapper:o}}function $n(s){return s.reduce((e,t)=>Math.min(e,t.timestamp),1/0)}function cp(s){const e=s.find(l=>l.type===at.FullSnapshot);if(!e)return null;const t=s.filter(l=>l.type===at.IncrementalSnapshot&&l.timestamp<e.timestamp);if(!t.length)return null;const i=t.reduce((l,a)=>Math.min(l,a.timestamp),1/0),r=t.reduce((l,a)=>Math.max(l,a.timestamp),-1/0),n=Math.max(0,r-i),o=Math.max(n,ap);return{earliestProblem:i,span:n,blockSpan:o,blockStart:e.timestamp+Ln,tailShift:Ln+o,firstFullTimestamp:e.timestamp}}function Kl(s,e){if(!e)return s;const t=s.type===at.IncrementalSnapshot&&s.timestamp<e.firstFullTimestamp,i=hp(s.timestamp,t,e);return i===s.timestamp?s:oe(P({},s),{timestamp:i})}function hp(s,e,t){if(!t)return s;if(s>t.firstFullTimestamp)return s+t.tailShift;if(e&&s<t.firstFullTimestamp){if(t.span===0)return t.blockStart;const i=t.blockSpan/t.span;return t.blockStart+(s-t.earliestProblem)*i}return s}function fp(s,e){if(!e)return s;if(s>e.firstFullTimestamp)return s+e.tailShift;if(s>=e.earliestProblem&&s<e.firstFullTimestamp){if(e.span===0)return e.blockStart;const t=e.blockSpan/e.span;return e.blockStart+(s-e.earliestProblem)*t}return s}function dp(s,e){if(!e)return s;const t=e.blockStart+e.blockSpan,i=e.firstFullTimestamp+e.tailShift;if(s>=i)return s-e.tailShift;if(s>=e.blockStart&&s<=t){if(e.span===0)return e.earliestProblem;const r=e.blockSpan/e.span;return e.earliestProblem+(s-e.blockStart)/r}return s}function pp(s,e,t){const i=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0,n=l=>fp(l,s),o=l=>dp(l,s);return{normalizationApplied:!!s,normalizeEvent:l=>Kl(l,s),toReplayerAbsolute:n,toPlayerAbsolute:o,toReplayerTime:l=>{const a=i+l;return n(a)-r},toPlayerTime:l=>{const a=r+l;return o(a)-i}}}function mp(s){let e,t,i,r,n,o,l,a,u;return{c(){e=ne("div"),t=ne("input"),i=ge(),r=ne("label"),n=ge(),o=ne("span"),l=Ve(s[3]),M(t,"type","checkbox"),M(t,"id",s[2]),t.disabled=s[1],M(t,"class","svelte-a6h7w7"),M(r,"for",s[2]),M(r,"class","svelte-a6h7w7"),M(o,"class","label svelte-a6h7w7"),M(e,"class","switch svelte-a6h7w7"),et(e,"disabled",s[1])},m(c,h){Te(c,e,h),$(e,t),t.checked=s[0],$(e,i),$(e,r),$(e,n),$(e,o),$(o,l),a||(u=Ke(t,"change",s[4]),a=!0)},p(c,[h]){h&4&&M(t,"id",c[2]),h&2&&(t.disabled=c[1]),h&1&&(t.checked=c[0]),h&4&&M(r,"for",c[2]),h&8&&di(l,c[3]),h&2&&et(e,"disabled",c[1])},i:xt,o:xt,d(c){c&&Me(e),a=!1,u()}}}function gp(s,e,t){let{disabled:i}=e,{checked:r}=e,{id:n}=e,{label:o}=e;function l(){r=this.checked,t(0,r)}return s.$$set=a=>{"disabled"in a&&t(1,i=a.disabled),"checked"in a&&t(0,r=a.checked),"id"in a&&t(2,n=a.id),"label"in a&&t(3,o=a.label)},[r,i,n,o,l]}class yp extends Xs{constructor(e){super(),Hs(this,e,gp,mp,Ys,{disabled:1,checked:0,id:2,label:3})}}function Fn(s,e,t){const i=s.slice();return i[40]=e[t],i}function Bn(s,e,t){const i=s.slice();return i[43]=e[t],i}function Un(s,e,t){const i=s.slice();return i[46]=e[t],i}function zn(s){let e,t,i,r=oi(s[6])+"",n,o,l,a,u,c,h,f,p,y,b=oi(s[8].totalTime)+"",d,m,w,v,x,R,_,z,A,G,Y,ce,ue,ee=je(s[13]),V=[];for(let E=0;E<ee.length;E+=1)V[E]=Vn(Un(s,ee,E));let ae=je(s[9]),k=[];for(let E=0;E<ae.length;E+=1)k[E]=Wn(Bn(s,ae,E));function W(E,J){return E[7]==="playing"?vp:wp}let he=W(s),le=he(s),te=je(s[3]),Q=[];for(let E=0;E<te.length;E+=1)Q[E]=Gn(Fn(s,te,E));function we(E){s[30](E)}let Ee={id:"skip",disabled:s[10]==="skipping",label:"skip inactive"};return s[0]!==void 0&&(Ee.checked=s[0]),_=new yp({props:Ee}),ze.push(()=>va(_,"checked",we)),{c(){e=ne("div"),t=ne("div"),i=ne("span"),n=Ve(r),o=ge(),l=ne("div"),a=ne("div"),u=ge();for(let E=0;E<V.length;E+=1)V[E].c();c=ge();for(let E=0;E<k.length;E+=1)k[E].c();h=ge(),f=ne("div"),p=ge(),y=ne("span"),d=Ve(b),m=ge(),w=ne("div"),v=ne("button"),le.c(),x=ge();for(let E=0;E<Q.length;E+=1)Q[E].c();R=ge(),to(_.$$.fragment),A=ge(),G=ne("button"),G.innerHTML=`<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M916 380c-26.4 0-48-21.6-48-48L868 223.2 613.6 477.6c-18.4
75
75
  18.4-48.8 18.4-68 0-18.4-18.4-18.4-48.8 0-68L800 156 692 156c-26.4
76
76
  0-48-21.6-48-48 0-26.4 21.6-48 48-48l224 0c26.4 0 48 21.6 48 48l0
77
77
  224C964 358.4 942.4 380 916 380zM231.2 860l108.8 0c26.4 0 48 21.6 48