@bugjar/reporter 0.1.2 → 0.1.4

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.
@@ -11628,4 +11628,3 @@ export {
11628
11628
  Yp as takeFullSnapshot,
11629
11629
  Gp as utils
11630
11630
  };
11631
- //# sourceMappingURL=rrweb-4OY2p61s.js.map
@@ -71,4 +71,3 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71
71
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72
72
  PERFORMANCE OF THIS SOFTWARE.
73
73
  ***************************************************************************** */function _n(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r,i,n=t.call(s),o=[];try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(a){i={error:a}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o}var Ge;(function(s){s[s.NotStarted=0]="NotStarted",s[s.Running=1]="Running",s[s.Stopped=2]="Stopped"})(Ge||(Ge={}));var Wa={type:"xstate.init"};function qr(s){return s===void 0?[]:[].concat(s)}function Be(s){return{type:"xstate.assign",assignment:s}}function kn(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 Er(s){return function(e){return s===e}}function za(s){return typeof s=="string"?{type:s}:s}function $n(s,e){return{value:s,context:e,actions:[],changed:!1,matches:Er(s)}}function Pn(s,e,t){var r=e,i=!1;return[s.filter(function(n){if(n.type==="xstate.assign"){i=!0;var o=Object.assign({},r);return typeof n.assignment=="function"?o=n.assignment(r,t):Object.keys(n.assignment).forEach(function(a){o[a]=typeof n.assignment[a]=="function"?n.assignment[a](r,t):n.assignment[a]}),r=o,!1}return!0}),r,i]}function Va(s,e){e===void 0&&(e={});var t=_n(Pn(qr(s.states[s.initial].entry).map(function(o){return kn(o,e.actions)}),s.context,Wa),2),r=t[0],i=t[1],n={config:s,_options:e,initialState:{value:s.initial,actions:r,context:i,matches:Er(s.initial)},transition:function(o,a){var l,u,c=typeof o=="string"?{value:o,context:s.context}:o,h=c.value,f=c.context,g=za(a),p=s.states[h];if(p.on){var m=qr(p.on[g.type]);try{for(var d=function($){var oe=typeof Symbol=="function"&&Symbol.iterator,se=oe&&$[oe],et=0;if(se)return se.call($);if($&&typeof $.length=="number")return{next:function(){return $&&et>=$.length&&($=void 0),{value:$&&$[et++],done:!$}}};throw new TypeError(oe?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),y=d.next();!y.done;y=d.next()){var S=y.value;if(S===void 0)return $n(h,f);var w=typeof S=="string"?{target:S}:S,v=w.target,x=w.actions,R=x===void 0?[]:x,U=w.cond,F=U===void 0?function(){return!0}:U,Y=v===void 0,K=v??h,te=s.states[K];if(F(f,g)){var re=_n(Pn((Y?qr(R):[].concat(p.exit,R,te.entry).filter(function($){return $})).map(function($){return kn($,n._options.actions)}),f,g),3),A=re[0],Ne=re[1],Ae=re[2],H=v??h;return{value:H,context:Ne,actions:A,changed:v!==h||A.length>0||Ae,matches:Er(H)}}}}catch($){l={error:$}}finally{try{y&&!y.done&&(u=d.return)&&u.call(d)}finally{if(l)throw l.error}}}return $n(h,f)}};return n}var Ln=function(s,e){return s.actions.forEach(function(t){var r=t.exec;return r&&r(s.context,e)})};function Ga(s){var e=s.initialState,t=Ge.NotStarted,r=new Set,i={_machine:s,send:function(n){t===Ge.Running&&(e=s.transition(e,n),Ln(e,za(n)),r.forEach(function(o){return o(e)}))},subscribe:function(n){return r.add(n),n(e),{unsubscribe:function(){return r.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:Er(o.value)}}return t=Ge.Running,Ln(e,Wa),i},stop:function(){return t=Ge.Stopped,r.clear(),i},get state(){return e},get status(){return t}};return i}function np(s,e){for(let t=s.length-1;t>=0;t--){const r=s[t];if(r.type===I.Meta&&r.timestamp<=e)return s.slice(t)}return s}function op(s,{getCastFn:e,applyEventsSynchronously:t,emitter:r}){const i=Va({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:Be({lastPlayedEvent:(n,o)=>o.type==="CAST_EVENT"?o.payload.event:n.lastPlayedEvent}),recordTimeOffset:Be((n,o)=>{let a=n.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(a=o.payload.timeOffset),{...n,timeOffset:a,baselineTime:n.events[0].timestamp+a}}),play(n){var o;const{timer:a,events:l,baselineTime:u,lastPlayedEvent:c}=n;a.clear();for(const p of l)Tn(p,u);const h=np(l,u);let f=c?.timestamp;c?.type===I.IncrementalSnapshot&&c.data.source===E.MouseMove&&(f=c.timestamp+((o=c.data.positions[0])==null?void 0:o.timeOffset)),u<(f||0)&&r.emit(T.PlayBack);const g=new Array;for(const p of h)if(!(f&&f<u&&(p.timestamp<=f||p===c)))if(p.timestamp<u)g.push(p);else{const m=e(p,!1);a.addAction({doAction:()=>{m()},delay:p.delay})}t(g),r.emit(T.Flush),a.start()},pause(n){n.timer.clear()},resetLastPlayedEvent:Be(n=>({...n,lastPlayedEvent:null})),startLive:Be({baselineTime:(n,o)=>(n.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:Be((n,o)=>{const{baselineTime:a,timer:l,events:u}=n;if(o.type==="ADD_EVENT"){const{event:c}=o.payload;Tn(c,a);let h=u.length-1;if(!u[h]||u[h].timestamp<=c.timestamp)u.push(c);else{let p=-1,m=0;for(;m<=h;){const d=Math.floor((m+h)/2);u[d].timestamp<=c.timestamp?m=d+1:h=d-1}p===-1&&(p=m),u.splice(p,0,c)}const f=c.timestamp<a,g=e(c,f);f?g():l.isActive()&&l.addAction({doAction:()=>{g()},delay:c.delay})}return{...n,events:u}})}});return Ga(i)}function ap(s){const e=Va({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,r)=>{"payload"in r&&t.timer.setSpeed(r.payload.speed)},recordSpeed:Be({normalSpeed:t=>t.timer.speed}),restoreSpeed:t=>{t.timer.setSpeed(t.normalSpeed)}}});return Ga(e)}const lp=s=>[`.${s} { background: currentColor }`,"noscript { display: none !important; }"],Fn=new Map;function ja(s,e){let t=Fn.get(s);return t||(t=new Map,Fn.set(s,t)),t.has(e)||t.set(e,[]),t.get(e)}function xe(s,e,t){return async r=>{if(r&&typeof r=="object"&&"rr_type"in r)if(t&&(t.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=await xe(s,e,t)(r.args);return await createImageBitmap.apply(null,i)}else if("index"in r){if(t||e===null)return r;const{rr_type:i,index:n}=r;return ja(e,i)[n]}else if("args"in r){const{rr_type:i,args:n}=r,o=window[i];return new o(...await Promise.all(n.map(xe(s,e,t))))}else{if("base64"in r)return Yd(r.base64);if("src"in r){const i=s.get(r.src);if(i)return i;{const n=new Image;return n.src=r.src,s.set(r.src,n),n}}else if("data"in r&&r.rr_type==="Blob"){const i=await Promise.all(r.data.map(xe(s,e,t)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return await Promise.all(r.map(xe(s,e,t)));return r}}function up(s,e){try{return e===be.WebGL?s.getContext("webgl")||s.getContext("experimental-webgl"):s.getContext("webgl2")}catch{return null}}const cp=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function hp(s,e){if(!e?.constructor)return;const{name:t}=e.constructor;if(!cp.includes(t))return;const r=ja(s,t);r.includes(e)||r.push(e)}async function fp({mutation:s,target:e,type:t,imageMap:r,errorHandler:i}){try{const n=up(e,t);if(!n)return;if(s.setter){n[s.property]=s.args[0];return}const o=n[s.property],a=await Promise.all(s.args.map(xe(r,n))),l=o.apply(n,a);hp(n,l);const u=!1}catch(n){i(s,n)}}async function dp({event:s,mutations:e,target:t,imageMap:r,errorHandler:i}){const n=t.getContext("2d");if(!n){i(e[0],new Error("Canvas context is null"));return}const o=e.map(async l=>Promise.all(l.args.map(xe(r,n))));(await Promise.all(o)).forEach((l,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"?(r.get(s),h.apply(n,c.args)):h.apply(n,l)}catch(h){i(c,h)}})}async function Ps({event:s,mutation:e,target:t,imageMap:r,canvasEventMap:i,errorHandler:n}){try{const o=i.get(s)||e,a="commands"in o?o.commands:[o];if([be.WebGL,be.WebGL2].includes(e.type)){for(let l=0;l<a.length;l++){const u=a[l];await fp({mutation:u,type:e.type,target:t,imageMap:r,errorHandler:n})}return}await dp({event:s,mutations:a,target:t,imageMap:r,errorHandler:n})}catch(o){n(e,o)}}class pp{constructor(e){b(this,"mediaMap",new Map),b(this,"warn"),b(this,"service"),b(this,"speedService"),b(this,"emitter"),b(this,"getCurrentTime"),b(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(T.Start,this.start.bind(this)),this.emitter.on(T.SkipStart,this.start.bind(this)),this.emitter.on(T.Pause,this.pause.bind(this)),this.emitter.on(T.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(e={pause:!1}){this.mediaMap.forEach((t,r)=>{this.syncTargetWithState(r),e.pause&&r.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:e,target:t,mediaState:r}){if(r.isPlaying){const n=(e-r.lastInteractionTimeOffset)/1e3*r.playbackRate,o="duration"in t&&t.duration;if(Number.isNaN(o)){this.waitForMetadata(t);return}let a=r.currentTimeAtLastInteraction+n;t.loop&&o!==!1&&(a=a%o),t.currentTime=a}else t.pause(),t.currentTime=r.currentTimeAtLastInteraction}waitForMetadata(e){if(this.metadataCallbackMap.has(e)||!("addEventListener"in e))return;const t=()=>{this.metadataCallbackMap.delete(e);const r=this.mediaMap.get(e);r&&this.seekTo({time:this.getCurrentTime(),target:e,mediaState:r})};this.metadataCallbackMap.set(e,t),e.addEventListener("loadedmetadata",t,{once:!0})}getMediaStateFromMutation({target:e,timeOffset:t,mutation:r}){const i=this.mediaMap.get(e),{type:n,playbackRate:o,currentTime:a,muted:l,volume:u,loop:c}=r;return{isPlaying:n===Ee.Play||n!==Ee.Pause&&(i?.isPlaying||e.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:a??i?.currentTimeAtLastInteraction??0,lastInteractionTimeOffset:t,playbackRate:o??i?.playbackRate??1,volume:u??i?.volume??1,muted:l??i?.muted??e.getAttribute("muted")===null,loop:c??i?.loop??e.getAttribute("loop")===null}}syncTargetWithState(e){const t=this.mediaMap.get(e);if(!t)return;const{muted:r,loop:i,volume:n,isPlaying:o}=t,a=this.service.state.matches("paused"),l=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=r,e.loop=i,e.playbackRate!==l&&(e.playbackRate=l),o&&!a?e.play():e.pause()}catch(u){this.warn(`Failed to replay media interactions: ${u.message||u}`)}}addMediaElements(e,t,r){if(!["AUDIO","VIDEO"].includes(e.nodeName))return;const i=e,n=r.getMeta(i);if(!n||!("attributes"in n))return;const o=this.service.state.matches("paused"),a=n.attributes;let l=!1;a.rr_mediaState?l=a.rr_mediaState==="played":l=i.getAttribute("autoplay")!==null,l&&o&&i.pause();let u=1;typeof a.rr_mediaPlaybackRate=="number"&&(u=a.rr_mediaPlaybackRate);let c=!1;typeof a.rr_mediaMuted=="boolean"?c=a.rr_mediaMuted:c=i.getAttribute("muted")!==null;let h=!1;typeof a.rr_mediaLoop=="boolean"?h=a.rr_mediaLoop:h=i.getAttribute("loop")!==null;let f=1;typeof a.rr_mediaVolume=="number"&&(f=a.rr_mediaVolume);let g=0;typeof a.rr_mediaCurrentTime=="number"&&(g=a.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:l,currentTimeAtLastInteraction:g,lastInteractionTimeOffset:t,playbackRate:u,volume:f,muted:c,loop:h}),this.syncTargetWithState(i)}mediaMutation({target:e,timeOffset:t,mutation:r}){this.mediaMap.set(e,this.getMediaStateFromMutation({target:e,timeOffset:t,mutation:r})),this.syncTargetWithState(e)}isSupportedMediaElement(e){return["AUDIO","VIDEO"].includes(e.nodeName)}reset(){this.mediaMap.clear()}}function Qt(s,e){if(s.nodeName!=="DIALOG"||s instanceof he)return;const t=s,r=t.open,i=r&&t.matches("dialog:modal"),n=t.getAttribute("rr_open_mode"),o=typeof e?.attributes.open=="string"||typeof t.getAttribute("open")=="string",a=n==="modal";if(!(r&&!(i&&n==="non-modal"||!i&&a))){if(!t.isConnected){console.warn("dialog is not attached to the dom",t);return}r&&t.close(),o&&(a?t.showModal():t.show())}}function mp(s,e){if(s.nodeName!=="DIALOG"||s instanceof he)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 gp=5*1e3,yp=Ua||rp,Bn="[replayer]",es={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Un(s){return s.type==I.IncrementalSnapshot&&(s.data.source==E.TouchMove||s.data.source==E.MouseInteraction&&s.data.type==_.TouchStart)}class wp{constructor(e,t){if(b(this,"wrapper"),b(this,"iframe"),b(this,"service"),b(this,"speedService"),b(this,"config"),b(this,"usingVirtualDom",!1),b(this,"virtualDom",new qe),b(this,"mouse"),b(this,"mouseTail",null),b(this,"tailPositions",[]),b(this,"emitter",yp()),b(this,"nextUserInteractionEvent"),b(this,"legacy_missingNodeRetryMap",{}),b(this,"cache",qi()),b(this,"imageMap",new Map),b(this,"canvasEventMap",new Map),b(this,"mirror",Vn()),b(this,"styleMirror",new vi),b(this,"mediaManager"),b(this,"firstFullSnapshot",null),b(this,"newDocumentQueue",[]),b(this,"mousePos",null),b(this,"touchActive",null),b(this,"lastMouseDownEvent",null),b(this,"lastHoveredRootNode"),b(this,"lastSelectionData",null),b(this,"constructedStyleMutations",[]),b(this,"adoptedStyleSheets",[]),b(this,"handleResize",a=>{this.iframe.style.display="inherit";for(const l of[this.mouseTail,this.iframe])l&&(l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)))}),b(this,"applyEventsSynchronously",a=>{for(const l of a){switch(l.type){case I.DomContentLoaded:case I.Load:case I.Custom:continue;case I.FullSnapshot:case I.Meta:case I.Plugin:case I.IncrementalSnapshot:break}this.getCastFn(l,!0)()}}),b(this,"getCastFn",(a,l=!1)=>{let u;switch(a.type){case I.DomContentLoaded:case I.Load:break;case I.Custom:u=()=>{this.emitter.emit(T.CustomEvent,a)};break;case I.Meta:u=()=>this.emitter.emit(T.Resize,{width:a.data.width,height:a.data.height});break;case I.FullSnapshot:u=()=>{var h;if(this.firstFullSnapshot){if(this.firstFullSnapshot===a){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(a,l),(h=this.iframe.contentWindow)==null||h.scrollTo(a.data.initialOffset)};break;case I.IncrementalSnapshot:u=()=>{if(this.applyIncremental(a,l),!l&&(a===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const h of this.service.state.context.events)if(!(h.timestamp<=a.timestamp)&&this.isUserInteraction(h)){h.delay-a.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=h);break}if(this.nextUserInteractionEvent){const h=this.nextUserInteractionEvent.delay-a.delay,f={speed:Math.min(Math.round(h/gp),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:f}),this.emitter.emit(T.SkipStart,f)}}};break}return()=>{u&&u();for(const f of this.config.plugins||[])f.handler&&f.handler(a,l,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:a}});const h=this.service.state.context.events.length-1;if(!this.config.liveMode&&a===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(T.Finish))};let g=50;a.type===I.IncrementalSnapshot&&a.data.source===E.MouseMove&&a.data.positions.length&&(g+=Math.max(0,-a.data.positions[0].timeOffset)),setTimeout(f,g)}this.emitter.emit(T.EventCast,a)}}),!t?.liveMode&&e.length<2)throw new Error("Replayer need at least 2 events.");const r={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:es,useVirtualDom:!0,logger:console};this.config=Object.assign({},r,t),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(T.Resize,this.handleResize),this.setupDom();for(const a of this.config.plugins||[])a.getMirror&&a.getMirror({nodeMirror:this.mirror});this.emitter.on(T.Flush,()=>{if(this.usingVirtualDom){const a={mirror:this.mirror,applyCanvas:(l,u,c)=>{Ps({event:l,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:(l,u)=>{l.source===E.StyleSheetRule?this.applyStyleSheetRule(l,u):l.source===E.StyleDeclaration&&this.applyStyleDeclaration(l,u)},afterAppend:(l,u)=>{for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(l,{id:u,replayer:this})}};if(this.iframe.contentDocument)try{wr(this.iframe.contentDocument,this.virtualDom,a,this.virtualDom.mirror)}catch(l){console.warn(l)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const l in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[l],c=br(u.node,this.mirror,this.virtualDom.mirror);wr(c,u.node,a,this.virtualDom.mirror),u.node=c}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(l=>{this.applyStyleSheetMutation(l)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(l=>{this.applyAdoptedStyleSheet(l)}),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[a,l]=this.lastMouseDownEvent;a.dispatchEvent(l)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(T.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const i=new ip([],{speed:this.config.speed});this.service=op({events:e.map(a=>t&&t.unpackFn?t.unpackFn(a):a).sort((a,l)=>a.timestamp-l.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(a=>{this.emitter.emit(T.StateChange,{player:a})}),this.speedService=ap({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(a=>{this.emitter.emit(T.StateChange,{speed:a})}),this.mediaManager=new pp({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(a=>a.type===I.Meta),o=this.service.state.context.events.find(a=>a.type===I.FullSnapshot);if(n){const{width:a,height:l}=n.data;setTimeout(()=>{this.emitter.emit(T.Resize,{width:a,height:l})},0)}o&&setTimeout(()=>{var a;this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),(a=this.iframe.contentWindow)==null||a.scrollTo(o.data.initialOffset))},1),this.service.state.context.events.find(Un)&&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<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),typeof e.mouseTail<"u"&&(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,r;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}})),(r=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(T.Start)}pause(e){var t,r;e===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof e=="number"&&(this.play(e),this.service.send({type:"PAUSE"})),(r=(t=this.iframe.contentDocument)==null?void 0:t.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(T.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(T.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(T.Destroy)}startLive(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})}addEvent(e){const t=this.config.unpackFn?this.config.unpackFn(e):e;Un(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=qi()}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&&(sp(this.iframe.contentWindow,this.iframe.contentDocument),yi(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 r=[],i=new Set,n=(l,u)=>{if(l.nodeName==="DIALOG"&&i.add(l),this.collectIframeAndAttachDocument(r,l),this.mediaManager.isSupportedMediaElement(l)){const{events:c}=this.service.state.context;this.mediaManager.addMediaElements(l,e.timestamp-c[0].timestamp,this.mirror)}for(const c of this.config.plugins||[])c.onBuild&&c.onBuild(l,{id:u,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),Wc(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:l,builtNode:u}of r)this.attachDocumentToIframe(l,u),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==l);const{documentElement:o,head:a}=this.iframe.contentDocument;this.insertStyleRules(o,a),i.forEach(l=>Qt(l)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(T.FullsnapshotRebuilded,e),t||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(e,t){var r;const i=lp(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&i.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),!!i.length)if(this.usingVirtualDom){const n=this.virtualDom.createElement("style");this.virtualDom.mirror.add(n,Ia(n,this.virtualDom.unserializedId)),e.insertBefore(n,t),n.rules.push({source:E.StyleSheetRule,adds:i.map((o,a)=>({rule:o,index:a}))})}else{const n=document.createElement("style");e.insertBefore(n,t);for(let o=0;o<i.length;o++)(r=n.sheet)==null||r.insertRule(i[o],o)}}attachDocumentToIframe(e,t){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],n=new Set,o=(a,l)=>{a.nodeName==="DIALOG"&&n.add(a),this.collectIframeAndAttachDocument(i,a);const u=r.getMeta(a);if(u?.type===ge.Element&&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(a,{id:l,replayer:this})};lt(e.node,{doc:t.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(t.contentDocument,e.node.id);for(const{mutationInQueue:a,builtNode:l}of i)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==a);n.forEach(a=>Qt(a))}collectIframeAndAttachDocument(e,t){if(je(t,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(t));r&&e.push({mutationInQueue:r,builtNode:t})}}waitForStylesheetLoad(){var e;const t=(e=this.iframe.contentDocument)==null?void 0:e.head;if(t){const r=new Set;let i,n=this.service.state;const o=()=>{n=this.service.state};this.emitter.on(T.Start,o),this.emitter.on(T.Pause,o);const a=()=>{this.emitter.off(T.Start,o),this.emitter.off(T.Pause,o)};t.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{l.sheet||(r.add(l),l.addEventListener("load",()=>{r.delete(l),r.size===0&&i!==-1&&(n.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(T.LoadStylesheetEnd),i&&clearTimeout(i),a())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(T.LoadStylesheetStart),i=setTimeout(()=>{n.matches("playing")&&this.play(this.getCurrentTime()),i=-1,a()},this.config.loadTimeout))}}async preloadAllImages(){const e=[];for(const t of this.service.state.context.events)t.type===I.IncrementalSnapshot&&t.data.source===E.CanvasMutation&&(e.push(this.deserializeAndPreloadCanvasEvents(t.data,t)),("commands"in t.data?t.data.commands:[t.data]).forEach(i=>{this.preloadImages(i,t)}));return Promise.all(e)}preloadImages(e,t){if(e.property==="drawImage"&&typeof e.args[0]=="string"&&!this.imageMap.has(t)){const r=document.createElement("canvas"),i=r.getContext("2d"),n=i?.createImageData(r.width,r.height);i?.putImageData(n,0,0)}}async deserializeAndPreloadCanvasEvents(e,t){if(!this.canvasEventMap.has(t)){const r={isUnchanged:!0};if("commands"in e){const i=await Promise.all(e.commands.map(async n=>{const o=await Promise.all(n.args.map(xe(this.imageMap,null,r)));return{...n,args:o}}));r.isUnchanged===!1&&this.canvasEventMap.set(t,{...e,commands:i})}else{const i=await Promise.all(e.args.map(xe(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(t,{...e,args:i})}}}applyIncremental(e,t){var r,i,n;const{data:o}=e;switch(o.source){case E.Mutation:{try{this.applyMutation(o,t)}catch(a){this.warn(`Exception in mutation ${a.message||a}`,o)}break}case E.Drag:case E.TouchMove:case E.MouseMove:if(t){const a=o.positions[o.positions.length-1];this.mousePos={x:a.x,y:a.y,id:a.id,debugData:o}}else o.positions.forEach(a=>{const l={doAction:()=>{this.moveAndHover(a.x,a.y,a.id,t,o)},delay:a.timeOffset+e.timestamp-this.service.state.context.baselineTime};this.timer.addAction(l)}),this.timer.addAction({doAction(){},delay:e.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case E.MouseInteraction:{if(o.id===-1)break;const a=new Event(Me(_[o.type])),l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);this.emitter.emit(T.MouseInteraction,{type:o.type,target:l});const{triggerFocus:u}=this.config;switch(o.type){case _.Blur:"blur"in l&&l.blur();break;case _.Focus:u&&l.focus&&l.focus({preventScroll:!0});break;case _.Click:case _.TouchStart:case _.TouchEnd:case _.MouseDown:case _.MouseUp:t?(o.type===_.TouchStart?this.touchActive=!0:o.type===_.TouchEnd&&(this.touchActive=!1),o.type===_.MouseDown?this.lastMouseDownEvent=[l,a]:o.type===_.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:o.x||0,y:o.y||0,id:o.id,debugData:o}):(o.type===_.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x||0,o.y||0,o.id,t,o),o.type===_.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===_.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===_.TouchEnd?this.mouse.classList.remove("touch-active"):l.dispatchEvent(a));break;case _.TouchCancel:t?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:l.dispatchEvent(a)}break}case E.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const a=this.virtualDom.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);a.scrollData=o;break}this.applyScroll(o,t);break}case E.ViewportResize:this.emitter.emit(T.Resize,{width:o.width,height:o.height});break;case E.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const a=this.virtualDom.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);a.inputData=o;break}this.applyInput(o);break}case E.MediaInteraction:{const a=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);const l=a,{events:u}=this.service.state.context;this.mediaManager.mediaMutation({target:l,timeOffset:e.timestamp-u[0].timestamp,mutation:o});break}case E.StyleSheetRule:case E.StyleDeclaration:{this.usingVirtualDom?o.styleId?this.constructedStyleMutations.push(o):o.id&&((i=this.virtualDom.mirror.getNode(o.id))==null||i.rules.push(o)):this.applyStyleSheetMutation(o);break}case E.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const a=this.virtualDom.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);a.canvasMutations.push({event:e,mutation:o})}else{const a=this.mirror.getNode(o.id);if(!a)return this.debugNodeNotFound(o,o.id);Ps({event:e,mutation:o,target:a,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case E.Font:{try{const a=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(n=this.iframe.contentDocument)==null||n.fonts.add(a)}catch(a){this.warn(a)}break}case E.Selection:{if(t){this.lastSelectionData=o;break}this.applySelection(o);break}case E.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(o):this.applyAdoptedStyleSheet(o);break}}}applyMutation(e,t){if(this.config.useVirtualDom&&!this.usingVirtualDom&&t&&(this.usingVirtualDom=!0,ad(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=Ea(c.node,this.virtualDom,this.mirror);h&&(c.node=h)}catch(c){this.warn(c)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;e.removes=e.removes.filter(u=>r.getNode(u.id)?!0:(this.warnNodeNotFound(e,u.id),!1)),e.removes.forEach(u=>{var c;const h=r.getNode(u.id);if(!h)return;let f=r.getNode(u.parentId);if(!f)return this.warnNodeNotFound(e,u.parentId);if(u.isShadow&&Ie(f)&&(f=f.shadowRoot),r.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(g){if(g instanceof DOMException)this.warn("parent could not remove child in mutation",f,h,e);else throw g}});const i={...this.legacy_missingNodeRetryMap},n=[],o=u=>{let c=null;return u.nextId&&(c=r.getNode(u.nextId)),u.nextId!==null&&u.nextId!==void 0&&u.nextId!==-1&&!c},a=u=>{var c,h;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let f=r.getNode(u.parentId);if(!f)return u.node.type===ge.Document?this.newDocumentQueue.push(u):n.push(u);u.node.isShadow&&(Ie(f)||f.attachShadow({mode:"open"}),f=f.shadowRoot);let g=null,p=null;if(u.previousId&&(g=r.getNode(u.previousId)),u.nextId&&(p=r.getNode(u.nextId)),o(u))return n.push(u);if(u.node.rootId&&!r.getNode(u.node.rootId))return;const m=u.node.rootId?r.getNode(u.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(je(f,r)){this.attachDocumentToIframe(u,f);return}const d=(w,v)=>{if(!this.usingVirtualDom){Qt(w);for(const x of this.config.plugins||[])x.onBuild&&x.onBuild(w,{id:v,replayer:this})}},y=lt(u.node,{doc:m,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:d});if(u.previousId===-1||u.nextId===-1){i[u.node.id]={node:y,mutation:u};return}const S=r.getMeta(f);if(S&&S.type===ge.Element&&u.node.type===ge.Text){const w=Array.isArray(f.childNodes)?f.childNodes:Array.from(f.childNodes);if(S.tagName==="textarea")for(const v of w)v.nodeType===f.TEXT_NODE&&f.removeChild(v);else if(S.tagName==="style"&&w.length===1)for(const v of w)v.nodeType===f.TEXT_NODE&&!r.hasNode(v)&&(y.textContent=v.textContent,f.removeChild(v))}else if(S?.type===ge.Document){const w=f;u.node.type===ge.DocumentType&&((c=w.childNodes[0])==null?void 0:c.nodeType)===Node.DOCUMENT_TYPE_NODE&&w.removeChild(w.childNodes[0]),y.nodeName==="HTML"&&w.documentElement&&w.removeChild(w.documentElement)}if(g&&g.nextSibling&&g.nextSibling.parentNode?f.insertBefore(y,g.nextSibling):p&&p.parentNode?f.contains(p)?f.insertBefore(y,p):f.insertBefore(y,null):f.appendChild(y),d(y,u.node.id),this.usingVirtualDom&&y.nodeName==="#text"&&f.nodeName==="STYLE"&&((h=f.rules)==null?void 0:h.length)>0&&(f.rules=[]),je(y,this.mirror)){const w=this.mirror.getId(y),v=this.newDocumentQueue.find(x=>x.parentId===w);v&&(this.attachDocumentToIframe(v,y),this.newDocumentQueue=this.newDocumentQueue.filter(x=>x!==v))}(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(i,f,y,u)};e.adds.forEach(u=>{a(u)});const l=Date.now();for(;n.length;){const u=Na(n);if(n.length=0,Date.now()-l>500){this.warn("Timeout in the loop, please check the resolve tree data:",u);break}for(const c of u)r.getNode(c.value.parentId)?wi(c,f=>{a(f)}):this.debug("Drop resolve tree since there is no parent for the root node.",c)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),Aa(e.texts).forEach(u=>{var c;const h=r.getNode(u.id);if(!h)return e.removes.find(g=>g.id===u.id)?void 0:this.warnNodeNotFound(e,u.id);const f=h.parentElement;if(u.value&&f&&f.tagName==="STYLE"?h.textContent=Ar(u.value,this.cache):h.textContent=u.value,this.usingVirtualDom){const g=h.parentNode;((c=g?.rules)==null?void 0:c.length)>0&&(g.rules=[])}}),e.attributes.forEach(u=>{var c;const h=r.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 g=u.attributes[f];if(g===null)h.removeAttribute(f),f==="open"&&mp(h,u);else if(typeof g=="string")try{if(f==="_cssText"&&(h.nodeName==="LINK"||h.nodeName==="STYLE"))try{const p=r.getMeta(h),m=lt({...p,attributes:{...p.attributes,...u.attributes}},{doc:h.ownerDocument,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});Object.assign(p.attributes,u.attributes);const d=h.nextSibling,y=h.parentNode;if(m&&y){y.removeChild(h),y.insertBefore(m,d),r.replace(u.id,m);break}}catch{}if(f==="value"&&h.nodeName==="TEXTAREA"){const p=h;p.childNodes.forEach(d=>p.removeChild(d));const m=(c=h.ownerDocument)==null?void 0:c.createTextNode(g);m&&p.appendChild(m)}else h.setAttribute(f,g);f==="rr_open_mode"&&h.nodeName==="DIALOG"&&Qt(h,u)}catch(p){this.warn("An error occurred may due to the checkout feature.",p)}else if(f==="style"){const p=g,m=h;for(const d in p)if(p[d]===!1)m.style.removeProperty(d);else if(p[d]instanceof Array){const y=p[d];m.style.setProperty(d,y[0],y[1])}else{const y=p[d];m.style.setProperty(d,y)}}}})}applyScroll(e,t){var r,i;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)(r=this.iframe.contentWindow)==null||r.scrollTo({top:e.y,left:e.x,behavior:t?"auto":"smooth"});else if(o?.type===ge.Document)(i=n.defaultView)==null||i.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{}}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{}}applySelection(e){try{const t=new Set,r=e.ranges.map(({start:i,startOffset:n,end:o,endOffset:a})=>{const l=this.mirror.getNode(i),u=this.mirror.getNode(o);if(!l||!u)return;const c=new Range;c.setStart(l,n),c.setEnd(u,a);const h=l.ownerDocument,f=h?.getSelection();return f&&t.add(f),{range:c,selection:f}});t.forEach(i=>i.removeAllRanges()),r.forEach(i=>{var n;return i&&((n=i.selection)==null?void 0:n.addRange(i.range))})}catch{}}applyStyleSheetMutation(e){var t;let r=null;e.styleId?r=this.styleMirror.getStyle(e.styleId):e.id&&(r=((t=this.mirror.getNode(e.id))==null?void 0:t.sheet)||null),r&&(e.source===E.StyleSheetRule?this.applyStyleSheetRule(e,r):e.source===E.StyleDeclaration&&this.applyStyleDeclaration(e,r))}applyStyleSheetRule(e,t){var r,i,n,o;if((r=e.adds)==null||r.forEach(({rule:a,index:l})=>{try{if(Array.isArray(l)){const{positions:u,index:c}=ks(l);ze(t.cssRules,u).insertRule(a,c)}else{const u=l===void 0?void 0:Math.min(l,t.cssRules.length);t?.insertRule(a,u)}}catch{}}),(i=e.removes)==null||i.forEach(({index:a})=>{try{if(Array.isArray(a)){const{positions:l,index:u}=ks(a);ze(t.cssRules,l).deleteRule(u||0)}else t?.deleteRule(a)}catch{}}),e.replace)try{(n=t.replace)==null||n.call(t,e.replace)}catch{}if(e.replaceSync)try{(o=t.replaceSync)==null||o.call(t,e.replaceSync)}catch{}}applyStyleDeclaration(e,t){e.set&&ze(t.rules,e.index).style.setProperty(e.set.property,e.set.value,e.set.priority),e.remove&&ze(t.rules,e.index).style.removeProperty(e.remove.property)}applyAdoptedStyleSheet(e){var t;const r=this.mirror.getNode(e.id);if(!r)return;(t=e.styles)==null||t.forEach(a=>{var l;let u=null,c=null;if(Ie(r)?c=((l=r.ownerDocument)==null?void 0:l.defaultView)||null:r.nodeName==="#document"&&(c=r.defaultView),!!c)try{u=new c.CSSStyleSheet,this.styleMirror.add(u,a.styleId),this.applyStyleSheetRule({source:E.StyleSheetRule,adds:a.rules},u)}catch{}});const i=10;let n=0;const o=(a,l)=>{const u=l.map(c=>this.styleMirror.getStyle(c)).filter(c=>c!==null);Ie(a)?a.shadowRoot.adoptedStyleSheets=u:a.nodeName==="#document"&&(a.adoptedStyleSheets=u),u.length!==l.length&&n<i&&(setTimeout(()=>o(a,l),0+100*n),n++)};o(r,e.styleIds)}legacy_resolveMissingNode(e,t,r,i){const{previousId:n,nextId:o}=i,a=n&&e[n],l=o&&e[o];if(a){const{node:u,mutation:c}=a;t.insertBefore(u,r),delete e[c.node.id],delete this.legacy_missingNodeRetryMap[c.node.id],(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(e,t,u,c)}if(l){const{node:u,mutation:c}=l;t.insertBefore(u,r.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,r,i,n){const o=this.mirror.getNode(r);if(!o)return this.debugNodeNotFound(n,r);const a=Si(o,this.iframe),l=e*a.absoluteScale+a.x,u=t*a.absoluteScale+a.y;this.mouse.style.left=`${l}px`,this.mouse.style.top=`${u}px`,i||this.drawMouseTail({x:l,y:u}),this.hoverElements(o)}drawMouseTail(e){if(!this.mouseTail)return;const{lineCap:t,lineWidth:r,strokeStyle:i,duration:n}=this.config.mouseTail===!0?es:Object.assign({},es,this.config.mouseTail),o=()=>{if(!this.mouseTail)return;const a=this.mouseTail.getContext("2d");!a||!this.tailPositions.length||(a.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),a.beginPath(),a.lineWidth=r,a.lineCap=t,a.strokeStyle=i,a.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(l=>a.lineTo(l.x,l.y)),a.stroke())};this.tailPositions.push(e),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(a=>a!==e),o()},n/this.speedService.state.context.timer.speed)}hoverElements(e){var t;(t=this.lastHoveredRootNode||this.iframe.contentDocument)==null||t.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")}),this.lastHoveredRootNode=e.getRootNode();let r=e;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(e){return e.type!==I.IncrementalSnapshot?!1:e.data.source>E.Mutation&&e.data.source<=E.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(T.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(Bn,...e)}debug(...e){this.config.showDebug&&this.config.logger.log(Bn,...e)}}const{addCustomEvent:bp}=Re,{freezePage:Sp}=Re,{takeFullSnapshot:vp}=Re;exports.EventType=I;exports.IncrementalSource=E;exports.MouseInteractions=_;exports.Replayer=wp;exports.ReplayerEvents=T;exports.addCustomEvent=bp;exports.canvasMutation=Ps;exports.freezePage=Sp;exports.record=Re;exports.takeFullSnapshot=vp;exports.utils=Ed;
74
- //# sourceMappingURL=rrweb-BXdUj-Sd.cjs.map
@@ -11676,4 +11676,3 @@ export {
11676
11676
  tm as takeFullSnapshot,
11677
11677
  Kp as utils
11678
11678
  };
11679
- //# sourceMappingURL=rrweb-DOpLs0kK.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugjar/reporter",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Privacy-first bug reporting SDK. DOM replay + redaction + markup, runs only on user consent.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -36,7 +36,8 @@
36
36
  "lint": "biome check src",
37
37
  "typecheck": "tsc --noEmit",
38
38
  "bundle-size": "size-limit",
39
- "prepublishOnly": "npm run build:production && npm run test && npm run bundle-size"
39
+ "prepublishOnly": "npm run build:production && npm run test && npm run bundle-size",
40
+ "release": "node ./scripts/publish.mjs"
40
41
  },
41
42
  "size-limit": [
42
43
  {