Socket
Socket
Sign inDemoInstall

rrweb

Package Overview
Dependencies
8
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.3 to 2.0.0-alpha.4

es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js

193

dist/plugins/canvas-webrtc-record.js

@@ -1181,3 +1181,10 @@ var rrwebCanvasWebRTCRecord = (function (exports) {

this.streamMap = /* @__PURE__ */ new Map();
this.incomingStreams = /* @__PURE__ */ new Set();
this.outgoingStreams = /* @__PURE__ */ new Set();
this.streamNodeMap = /* @__PURE__ */ new Map();
this.canvasWindowMap = /* @__PURE__ */ new Map();
this.windowPeerMap = /* @__PURE__ */ new WeakMap();
this.peerWindowMap = /* @__PURE__ */ new WeakMap();
this.signalSendCallback = signalSendCallback;
window.addEventListener("message", this.windowPostMessageHandler.bind(this));
if (peer)

@@ -1189,4 +1196,5 @@ this.peer = peer;

name: PLUGIN_NAME,
getMirror: (mirror) => {
this.mirror = mirror;
getMirror: ({ nodeMirror, crossOriginIframeMirror }) => {
this.mirror = nodeMirror;
this.crossOriginIframeMirror = crossOriginIframeMirror;
},

@@ -1202,6 +1210,10 @@ options: {}

}
signalReceiveFromCrossOriginIframe(signal, source) {
const peer = this.setupPeer(source);
peer.signal(signal);
}
startStream(id, stream) {
var _a, _b;
if (!this.peer)
return this.setupPeer();
this.setupPeer();
const data = {

@@ -1212,31 +1224,91 @@ nodeId: id,

(_a = this.peer) == null ? void 0 : _a.send(JSON.stringify(data));
(_b = this.peer) == null ? void 0 : _b.addStream(stream);
if (!this.outgoingStreams.has(stream))
(_b = this.peer) == null ? void 0 : _b.addStream(stream);
this.outgoingStreams.add(stream);
}
setupPeer() {
if (!this.peer) {
this.peer = new Peer({
setupPeer(source) {
let peer;
if (!source) {
if (this.peer)
return this.peer;
peer = this.peer = new Peer({
initiator: true
});
this.peer.on("error", (err) => {
this.peer = null;
console.log("error", err);
} else {
const peerFromMap = this.windowPeerMap.get(source);
if (peerFromMap)
return peerFromMap;
peer = new Peer({
initiator: false
});
this.peer.on("close", () => {
this.peer = null;
console.log("closing");
});
this.peer.on("signal", (data) => {
this.signalSendCallback(data);
});
this.peer.on("connect", () => {
for (const [id, stream] of this.streamMap) {
this.startStream(id, stream);
this.windowPeerMap.set(source, peer);
this.peerWindowMap.set(peer, source);
}
const resetPeer = (source2) => {
if (!source2)
return this.peer = null;
this.windowPeerMap.delete(source2);
this.peerWindowMap.delete(peer);
};
peer.on("error", (err) => {
resetPeer(source);
console.log("error", err);
});
peer.on("close", () => {
resetPeer(source);
console.log("closing");
});
peer.on("signal", (data) => {
var _a, _b;
if (this.inRootFrame()) {
if (peer === this.peer) {
this.signalSendCallback(data);
} else {
(_a = this.peerWindowMap.get(peer)) == null ? void 0 : _a.postMessage({
type: "rrweb-canvas-webrtc",
data: {
type: "signal",
signal: data
}
}, "*");
}
});
}
} else {
(_b = window.top) == null ? void 0 : _b.postMessage({
type: "rrweb-canvas-webrtc",
data: {
type: "signal",
signal: data
}
}, "*");
}
});
peer.on("connect", () => {
if (this.inRootFrame() && peer !== this.peer)
return;
for (const [id, stream] of this.streamMap) {
this.startStream(id, stream);
}
});
if (!this.inRootFrame())
return peer;
peer.on("data", (data) => {
try {
const json = JSON.parse(data);
this.streamNodeMap.set(json.streamId, json.nodeId);
} catch (error) {
console.error("Could not parse data", error);
}
this.flushStreams();
});
peer.on("stream", (stream) => {
this.incomingStreams.add(stream);
this.flushStreams();
});
return peer;
}
setupStream(id) {
setupStream(id, rootId) {
var _a;
if (id === -1)
return false;
let stream = this.streamMap.get(id);
let stream = this.streamMap.get(rootId || id);
if (stream)

@@ -1246,8 +1318,77 @@ return stream;

if (!el || !("captureStream" in el))
return false;
return this.setupStreamInCrossOriginIframe(id, rootId || id);
if (!this.inRootFrame()) {
(_a = window.top) == null ? void 0 : _a.postMessage({
type: "rrweb-canvas-webrtc",
data: {
type: "i-have-canvas",
rootId: rootId || id
}
}, "*");
}
stream = el.captureStream();
this.streamMap.set(id, stream);
this.streamMap.set(rootId || id, stream);
this.setupPeer();
return stream;
}
flushStreams() {
this.incomingStreams.forEach((stream) => {
const nodeId = this.streamNodeMap.get(stream.id);
if (!nodeId)
return;
this.startStream(nodeId, stream);
});
}
inRootFrame() {
return Boolean(window.top && window.top === window);
}
setupStreamInCrossOriginIframe(id, rootId) {
let found = false;
document.querySelectorAll("iframe").forEach((iframe) => {
var _a;
if (found)
return;
const remoteId = this.crossOriginIframeMirror.getRemoteId(iframe, id);
if (remoteId === -1)
return;
found = true;
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage({
type: "rrweb-canvas-webrtc",
data: {
type: "who-has-canvas",
id: remoteId,
rootId
}
}, "*");
});
return found;
}
isCrossOriginIframeMessageEventContent(event) {
return Boolean("type" in event.data && "data" in event.data && event.data.type === "rrweb-canvas-webrtc" && event.data.data);
}
windowPostMessageHandler(event) {
if (!this.isCrossOriginIframeMessageEventContent(event))
return;
const { type } = event.data.data;
if (type === "who-has-canvas") {
const { id, rootId } = event.data.data;
this.setupStream(id, rootId);
} else if (type === "signal") {
const { signal } = event.data.data;
const { source } = event;
if (!source || !("self" in source))
return;
if (this.inRootFrame()) {
this.signalReceiveFromCrossOriginIframe(signal, source);
} else {
this.signalReceive(signal);
}
} else if (type === "i-have-canvas") {
const { rootId } = event.data.data;
const { source } = event;
if (!source || !("self" in source))
return;
this.canvasWindowMap.set(rootId, source);
}
}
}

@@ -1254,0 +1395,0 @@

2

dist/plugins/canvas-webrtc-record.min.js

@@ -1,2 +0,2 @@

var rrwebCanvasWebRTCRecord=function(u){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function g(h){const e=new Uint8Array(h);for(let t=0;t<h;t++)e[t]=Math.random()*256|0;return e}function f(){if(typeof globalThis>"u")return null;const h={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return h.RTCPeerConnection?h:null}function n(h,e){return Object.defineProperty(h,"code",{value:e,enumerable:!0,configurable:!0}),h}function p(h){return h.replace(/a=ice-options:trickle\s\n/g,"")}function C(h){console.warn(h)}class l{constructor(e={}){if(this._map=new Map,this._id=g(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||g(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||l.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},l.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:f(),!this._wrtc)throw n(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(n(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(n(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(n(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(n(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(i=>{!t.address||t.address.endsWith(".local")?C("Ignoring unsupported ICE candidate."):this.destroy(n(i,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(i){this.destroy(n(i,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw n(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const i=this._senderMap.get(e)||new Map;let s=i.get(t);if(!s)s=this._pc.addTrack(e,t),i.set(t,s),this._senderMap.set(e,i),this._needsNegotiation();else throw s.removed?n(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):n(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,i){if(this.destroying)return;if(this.destroyed)throw n(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const s=this._senderMap.get(e),r=s?s.get(i):null;if(!r)throw n(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,s),r.replaceTrack!=null?r.replaceTrack(t):this.destroy(n(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw n(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const i=this._senderMap.get(e),s=i?i.get(t):null;if(!s)throw n(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{s.removed=!0,this._pc.removeTrack(s)}catch(r){r.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(s):this.destroy(n(r,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw n(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(n(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=i=>{this._onChannelMessage(i)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=i=>{this.destroy(n(i,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const r=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:r.type,sdp:r.sdp})},i=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=r=>{this.destroy(n(r,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(n(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const r=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:r.type,sdp:r.sdp}),this.initiator||this._requestMissingTransceivers()},i=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=r=>{this.destroy(n(r,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(n(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(n(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(n(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(n(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=i=>(Object.prototype.toString.call(i.values)==="[object Array]"&&i.values.forEach(s=>{Object.assign(i,s)}),i);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(i=>{const s=[];i.forEach(r=>{s.push(t(r))}),e(null,s)},i=>e(i)):this._pc.getStats.length>0?this._pc.getStats(i=>{if(this.destroyed)return;const s=[];i.result().forEach(r=>{const d={};r.names().forEach(_=>{d[_]=r.stat(_)}),d.id=r.id,d.type=r.type,d.timestamp=r.timestamp,s.push(t(d))}),e(null,s)},i=>e(i)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,i)=>{if(this.destroyed)return;t&&(i=[]);const s={},r={},d={};let _=!1;i.forEach(a=>{(a.type==="remotecandidate"||a.type==="remote-candidate")&&(s[a.id]=a),(a.type==="localcandidate"||a.type==="local-candidate")&&(r[a.id]=a),(a.type==="candidatepair"||a.type==="candidate-pair")&&(d[a.id]=a)});const R=a=>{_=!0;let o=r[a.localCandidateId];o&&(o.ip||o.address)?(this.localAddress=o.ip||o.address,this.localPort=Number(o.port)):o&&o.ipAddress?(this.localAddress=o.ipAddress,this.localPort=Number(o.portNumber)):typeof a.googLocalAddress=="string"&&(o=a.googLocalAddress.split(":"),this.localAddress=o[0],this.localPort=Number(o[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let c=s[a.remoteCandidateId];c&&(c.ip||c.address)?(this.remoteAddress=c.ip||c.address,this.remotePort=Number(c.port)):c&&c.ipAddress?(this.remoteAddress=c.ipAddress,this.remotePort=Number(c.portNumber)):typeof a.googRemoteAddress=="string"&&(c=a.googRemoteAddress.split(":"),this.remoteAddress=c[0],this.remotePort=Number(c[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(i.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&R(d[a.selectedCandidatePairId]),(a.type==="googCandidatePair"&&a.googActiveConnection==="true"||(a.type==="candidatepair"||a.type==="candidate-pair")&&a.selected)&&R(a)}),!_&&(!Object.keys(d).length||Object.keys(r).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(o){return this.destroy(n(o,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const a=this._cb;this._cb=null,a(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(i=>i.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const i=this._map;i.has(e)||i.set(e,new Set),i.get(e).add(t)}off(e,t){const i=this._map,s=i.get(e);!s||(s.delete(t),s.size===0&&i.delete(e))}once(e,t){const i=(...s)=>{this.off(e,i),t(...s)};this.on(e,i)}emit(e,...t){const i=this._map;if(!!i.has(e))for(const s of i.get(e))try{s(...t)}catch(r){console.error(r)}}}l.WEBRTC_SUPPORT=!!f(),l.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},l.channelConfig={};const m="rrweb/canvas-webrtc@1";class E{constructor({signalSendCallback:e,peer:t}){this.peer=null,this.streamMap=new Map,this.signalSendCallback=e,t&&(this.peer=t)}initPlugin(){return{name:m,getMirror:e=>{this.mirror=e},options:{}}}signalReceive(e){var t;this.peer||this.setupPeer(),(t=this.peer)==null||t.signal(e)}startStream(e,t){var i,s;if(!this.peer)return this.setupPeer();const r={nodeId:e,streamId:t.id};(i=this.peer)==null||i.send(JSON.stringify(r)),(s=this.peer)==null||s.addStream(t)}setupPeer(){this.peer||(this.peer=new l({initiator:!0}),this.peer.on("error",e=>{this.peer=null,console.log("error",e)}),this.peer.on("close",()=>{this.peer=null,console.log("closing")}),this.peer.on("signal",e=>{this.signalSendCallback(e)}),this.peer.on("connect",()=>{for(const[e,t]of this.streamMap)this.startStream(e,t)}))}setupStream(e){if(e===-1)return!1;let t=this.streamMap.get(e);if(t)return t;const i=this.mirror.getNode(e);return!i||!("captureStream"in i)?!1:(t=i.captureStream(),this.streamMap.set(e,t),this.setupPeer(),t)}}return u.PLUGIN_NAME=m,u.RRWebPluginCanvasWebRTCRecord=E,Object.defineProperty(u,"__esModule",{value:!0}),u}({});
var rrwebCanvasWebRTCRecord=function(_){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function g(d){const e=new Uint8Array(d);for(let t=0;t<d;t++)e[t]=Math.random()*256|0;return e}function f(){if(typeof globalThis>"u")return null;const d={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return d.RTCPeerConnection?d:null}function r(d,e){return Object.defineProperty(d,"code",{value:e,enumerable:!0,configurable:!0}),d}function p(d){return d.replace(/a=ice-options:trickle\s\n/g,"")}function y(d){console.warn(d)}class l{constructor(e={}){if(this._map=new Map,this._id=g(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||g(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||l.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},l.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:f(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(s=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(s,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(s){this.destroy(r(s,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const s=this._senderMap.get(e)||new Map;let i=s.get(t);if(!i)i=this._pc.addTrack(e,t),s.set(t,i),this._senderMap.set(e,s),this._needsNegotiation();else throw i.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,s){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),n=i?i.get(s):null;if(!n)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),n.replaceTrack!=null?n.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const s=this._senderMap.get(e),i=s?s.get(t):null;if(!i)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(n){n.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(i):this.destroy(r(n,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=s=>{this._onChannelMessage(s)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=s=>{this.destroy(r(s,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp})},s=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp}),this.initiator||this._requestMissingTransceivers()},s=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=s=>(Object.prototype.toString.call(s.values)==="[object Array]"&&s.values.forEach(i=>{Object.assign(s,i)}),s);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(s=>{const i=[];s.forEach(n=>{i.push(t(n))}),e(null,i)},s=>e(s)):this._pc.getStats.length>0?this._pc.getStats(s=>{if(this.destroyed)return;const i=[];s.result().forEach(n=>{const o={};n.names().forEach(u=>{o[u]=n.stat(u)}),o.id=n.id,o.type=n.type,o.timestamp=n.timestamp,i.push(t(o))}),e(null,i)},s=>e(s)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,s)=>{if(this.destroyed)return;t&&(s=[]);const i={},n={},o={};let u=!1;s.forEach(a=>{(a.type==="remotecandidate"||a.type==="remote-candidate")&&(i[a.id]=a),(a.type==="localcandidate"||a.type==="local-candidate")&&(n[a.id]=a),(a.type==="candidatepair"||a.type==="candidate-pair")&&(o[a.id]=a)});const R=a=>{u=!0;let h=n[a.localCandidateId];h&&(h.ip||h.address)?(this.localAddress=h.ip||h.address,this.localPort=Number(h.port)):h&&h.ipAddress?(this.localAddress=h.ipAddress,this.localPort=Number(h.portNumber)):typeof a.googLocalAddress=="string"&&(h=a.googLocalAddress.split(":"),this.localAddress=h[0],this.localPort=Number(h[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let c=i[a.remoteCandidateId];c&&(c.ip||c.address)?(this.remoteAddress=c.ip||c.address,this.remotePort=Number(c.port)):c&&c.ipAddress?(this.remoteAddress=c.ipAddress,this.remotePort=Number(c.portNumber)):typeof a.googRemoteAddress=="string"&&(c=a.googRemoteAddress.split(":"),this.remoteAddress=c[0],this.remotePort=Number(c[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(s.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&R(o[a.selectedCandidatePairId]),(a.type==="googCandidatePair"&&a.googActiveConnection==="true"||(a.type==="candidatepair"||a.type==="candidate-pair")&&a.selected)&&R(a)}),!u&&(!Object.keys(o).length||Object.keys(n).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(h){return this.destroy(r(h,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const a=this._cb;this._cb=null,a(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(s=>s.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const s=this._map;s.has(e)||s.set(e,new Set),s.get(e).add(t)}off(e,t){const s=this._map,i=s.get(e);!i||(i.delete(t),i.size===0&&s.delete(e))}once(e,t){const s=(...i)=>{this.off(e,s),t(...i)};this.on(e,s)}emit(e,...t){const s=this._map;if(!!s.has(e))for(const i of s.get(e))try{i(...t)}catch(n){console.error(n)}}}l.WEBRTC_SUPPORT=!!f(),l.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},l.channelConfig={};const m="rrweb/canvas-webrtc@1";class C{constructor({signalSendCallback:e,peer:t}){this.peer=null,this.streamMap=new Map,this.incomingStreams=new Set,this.outgoingStreams=new Set,this.streamNodeMap=new Map,this.canvasWindowMap=new Map,this.windowPeerMap=new WeakMap,this.peerWindowMap=new WeakMap,this.signalSendCallback=e,window.addEventListener("message",this.windowPostMessageHandler.bind(this)),t&&(this.peer=t)}initPlugin(){return{name:m,getMirror:({nodeMirror:e,crossOriginIframeMirror:t})=>{this.mirror=e,this.crossOriginIframeMirror=t},options:{}}}signalReceive(e){var t;this.peer||this.setupPeer(),(t=this.peer)==null||t.signal(e)}signalReceiveFromCrossOriginIframe(e,t){this.setupPeer(t).signal(e)}startStream(e,t){var s,i;this.peer||this.setupPeer();const n={nodeId:e,streamId:t.id};(s=this.peer)==null||s.send(JSON.stringify(n)),this.outgoingStreams.has(t)||(i=this.peer)==null||i.addStream(t),this.outgoingStreams.add(t)}setupPeer(e){let t;if(e){const i=this.windowPeerMap.get(e);if(i)return i;t=new l({initiator:!1}),this.windowPeerMap.set(e,t),this.peerWindowMap.set(t,e)}else{if(this.peer)return this.peer;t=this.peer=new l({initiator:!0})}const s=i=>{if(!i)return this.peer=null;this.windowPeerMap.delete(i),this.peerWindowMap.delete(t)};return t.on("error",i=>{s(e),console.log("error",i)}),t.on("close",()=>{s(e),console.log("closing")}),t.on("signal",i=>{var n,o;this.inRootFrame()?t===this.peer?this.signalSendCallback(i):(n=this.peerWindowMap.get(t))==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*"):(o=window.top)==null||o.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*")}),t.on("connect",()=>{if(!(this.inRootFrame()&&t!==this.peer))for(const[i,n]of this.streamMap)this.startStream(i,n)}),this.inRootFrame()&&(t.on("data",i=>{try{const n=JSON.parse(i);this.streamNodeMap.set(n.streamId,n.nodeId)}catch(n){console.error("Could not parse data",n)}this.flushStreams()}),t.on("stream",i=>{this.incomingStreams.add(i),this.flushStreams()})),t}setupStream(e,t){var s;if(e===-1)return!1;let i=this.streamMap.get(t||e);if(i)return i;const n=this.mirror.getNode(e);return!n||!("captureStream"in n)?this.setupStreamInCrossOriginIframe(e,t||e):(this.inRootFrame()||(s=window.top)==null||s.postMessage({type:"rrweb-canvas-webrtc",data:{type:"i-have-canvas",rootId:t||e}},"*"),i=n.captureStream(),this.streamMap.set(t||e,i),this.setupPeer(),i)}flushStreams(){this.incomingStreams.forEach(e=>{const t=this.streamNodeMap.get(e.id);!t||this.startStream(t,e)})}inRootFrame(){return Boolean(window.top&&window.top===window)}setupStreamInCrossOriginIframe(e,t){let s=!1;return document.querySelectorAll("iframe").forEach(i=>{var n;if(s)return;const o=this.crossOriginIframeMirror.getRemoteId(i,e);o!==-1&&(s=!0,(n=i.contentWindow)==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"who-has-canvas",id:o,rootId:t}},"*"))}),s}isCrossOriginIframeMessageEventContent(e){return Boolean("type"in e.data&&"data"in e.data&&e.data.type==="rrweb-canvas-webrtc"&&e.data.data)}windowPostMessageHandler(e){if(!this.isCrossOriginIframeMessageEventContent(e))return;const{type:t}=e.data.data;if(t==="who-has-canvas"){const{id:s,rootId:i}=e.data.data;this.setupStream(s,i)}else if(t==="signal"){const{signal:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.inRootFrame()?this.signalReceiveFromCrossOriginIframe(s,i):this.signalReceive(s)}else if(t==="i-have-canvas"){const{rootId:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.canvasWindowMap.set(s,i)}}}return _.PLUGIN_NAME=m,_.RRWebPluginCanvasWebRTCRecord=C,Object.defineProperty(_,"__esModule",{value:!0}),_}({});
//# sourceMappingURL=canvas-webrtc-record.min.js.map

@@ -1192,4 +1192,4 @@ var rrwebCanvasWebRTCReplay = (function (exports) {

},
getMirror: (mirror) => {
this.mirror = mirror;
getMirror: (options) => {
this.mirror = options.nodeMirror;
}

@@ -1196,0 +1196,0 @@ };

@@ -1,2 +0,2 @@

var rrwebCanvasWebRTCReplay=function(g){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function f(h){const e=new Uint8Array(h);for(let t=0;t<h;t++)e[t]=Math.random()*256|0;return e}function p(){if(typeof globalThis>"u")return null;const h={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return h.RTCPeerConnection?h:null}function r(h,e){return Object.defineProperty(h,"code",{value:e,enumerable:!0,configurable:!0}),h}function m(h){return h.replace(/a=ice-options:trickle\s\n/g,"")}function y(h){console.warn(h)}class _{constructor(e={}){if(this._map=new Map,this._id=f(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||f(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||_.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},_.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:p(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(i=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(i,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(i){this.destroy(r(i,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const i=this._senderMap.get(e)||new Map;let s=i.get(t);if(!s)s=this._pc.addTrack(e,t),i.set(t,s),this._senderMap.set(e,i),this._needsNegotiation();else throw s.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,i){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const s=this._senderMap.get(e),a=s?s.get(i):null;if(!a)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,s),a.replaceTrack!=null?a.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const i=this._senderMap.get(e),s=i?i.get(t):null;if(!s)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{s.removed=!0,this._pc.removeTrack(s)}catch(a){a.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(s):this.destroy(r(a,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=i=>{this._onChannelMessage(i)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=i=>{this.destroy(r(i,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp})},i=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp}),this.initiator||this._requestMissingTransceivers()},i=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=i=>(Object.prototype.toString.call(i.values)==="[object Array]"&&i.values.forEach(s=>{Object.assign(i,s)}),i);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(i=>{const s=[];i.forEach(a=>{s.push(t(a))}),e(null,s)},i=>e(i)):this._pc.getStats.length>0?this._pc.getStats(i=>{if(this.destroyed)return;const s=[];i.result().forEach(a=>{const c={};a.names().forEach(l=>{c[l]=a.stat(l)}),c.id=a.id,c.type=a.type,c.timestamp=a.timestamp,s.push(t(c))}),e(null,s)},i=>e(i)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,i)=>{if(this.destroyed)return;t&&(i=[]);const s={},a={},c={};let l=!1;i.forEach(n=>{(n.type==="remotecandidate"||n.type==="remote-candidate")&&(s[n.id]=n),(n.type==="localcandidate"||n.type==="local-candidate")&&(a[n.id]=n),(n.type==="candidatepair"||n.type==="candidate-pair")&&(c[n.id]=n)});const u=n=>{l=!0;let o=a[n.localCandidateId];o&&(o.ip||o.address)?(this.localAddress=o.ip||o.address,this.localPort=Number(o.port)):o&&o.ipAddress?(this.localAddress=o.ipAddress,this.localPort=Number(o.portNumber)):typeof n.googLocalAddress=="string"&&(o=n.googLocalAddress.split(":"),this.localAddress=o[0],this.localPort=Number(o[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let d=s[n.remoteCandidateId];d&&(d.ip||d.address)?(this.remoteAddress=d.ip||d.address,this.remotePort=Number(d.port)):d&&d.ipAddress?(this.remoteAddress=d.ipAddress,this.remotePort=Number(d.portNumber)):typeof n.googRemoteAddress=="string"&&(d=n.googRemoteAddress.split(":"),this.remoteAddress=d[0],this.remotePort=Number(d[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(i.forEach(n=>{n.type==="transport"&&n.selectedCandidatePairId&&u(c[n.selectedCandidatePairId]),(n.type==="googCandidatePair"&&n.googActiveConnection==="true"||(n.type==="candidatepair"||n.type==="candidate-pair")&&n.selected)&&u(n)}),!l&&(!Object.keys(c).length||Object.keys(a).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(o){return this.destroy(r(o,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const n=this._cb;this._cb=null,n(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(i=>i.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const i=this._map;i.has(e)||i.set(e,new Set),i.get(e).add(t)}off(e,t){const i=this._map,s=i.get(e);!s||(s.delete(t),s.size===0&&i.delete(e))}once(e,t){const i=(...s)=>{this.off(e,i),t(...s)};this.on(e,i)}emit(e,...t){const i=this._map;if(!!i.has(e))for(const s of i.get(e))try{s(...t)}catch(a){console.error(a)}}}_.WEBRTC_SUPPORT=!!p(),_.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},_.channelConfig={};class R{constructor({canvasFoundCallback:e,signalSendCallback:t}){this.peer=null,this.streamNodeMap=new Map,this.streams=new Set,this.runningStreams=new WeakSet,this.canvasFoundCallback=e,this.signalSendCallback=t}initPlugin(){return{onBuild:(e,t)=>{e.nodeName==="CANVAS"&&this.canvasFoundCallback(e,t)},getMirror:e=>{this.mirror=e}}}startStream(e,t){if(!this.runningStreams.has(t)){if(e.tagName==="VIDEO"){const i=e;i.srcObject=t,i.play(),this.runningStreams.add(t);return}if("MediaStreamTrackProcessor"in window){const i=e,s=i.getContext("2d");if(!s)throw new Error(`startStream: Could not get 2d canvas context for ${i.outerHTML}`);const a=t.getVideoTracks()[0],c=new MediaStreamTrackProcessor({track:a}).readable.getReader(),l=function(){c.read().then(({done:u,value:n})=>{!n||((i.width!==n.displayWidth||i.height!==n.displayHeight)&&(i.width=n.displayWidth,i.height=n.displayHeight),s.clearRect(0,0,i.width,i.height),s.drawImage(n,0,0),n.close(),u||l())})};l(),this.runningStreams.add(t)}else{const i=document.createElement("video");i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("width",e.width.toString()),i.setAttribute("height",e.height.toString()),e.replaceWith(i),this.startStream(i,t)}}}signalReceive(e){this.peer||(this.peer=new _({initiator:!1}),this.peer.on("error",t=>{this.peer=null,console.log("error",t)}),this.peer.on("close",()=>{this.peer=null,console.log("closing")}),this.peer.on("signal",t=>{this.signalSendCallback(t)}),this.peer.on("connect",()=>{}),this.peer.on("data",t=>{try{const i=JSON.parse(t);this.streamNodeMap.set(i.streamId,i.nodeId)}catch(i){console.error("Could not parse data",i)}this.flushStreams()}),this.peer.on("stream",t=>{this.streams.add(t),this.flushStreams()})),this.peer.signal(e)}flushStreams(){this.streams.forEach(e=>{const t=this.streamNodeMap.get(e.id);if(!t)return;const i=this.mirror.getNode(t);i&&this.startStream(i,e)})}}return g.RRWebPluginCanvasWebRTCReplay=R,Object.defineProperty(g,"__esModule",{value:!0}),g}({});
var rrwebCanvasWebRTCReplay=function(g){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function f(h){const e=new Uint8Array(h);for(let t=0;t<h;t++)e[t]=Math.random()*256|0;return e}function p(){if(typeof globalThis>"u")return null;const h={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return h.RTCPeerConnection?h:null}function r(h,e){return Object.defineProperty(h,"code",{value:e,enumerable:!0,configurable:!0}),h}function m(h){return h.replace(/a=ice-options:trickle\s\n/g,"")}function y(h){console.warn(h)}class _{constructor(e={}){if(this._map=new Map,this._id=f(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||f(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||_.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},_.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:p(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(i=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(i,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(i){this.destroy(r(i,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const i=this._senderMap.get(e)||new Map;let s=i.get(t);if(!s)s=this._pc.addTrack(e,t),i.set(t,s),this._senderMap.set(e,i),this._needsNegotiation();else throw s.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,i){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const s=this._senderMap.get(e),a=s?s.get(i):null;if(!a)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,s),a.replaceTrack!=null?a.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const i=this._senderMap.get(e),s=i?i.get(t):null;if(!s)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{s.removed=!0,this._pc.removeTrack(s)}catch(a){a.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(s):this.destroy(r(a,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=i=>{this._onChannelMessage(i)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=i=>{this.destroy(r(i,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp})},i=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=m(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const a=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:a.type,sdp:a.sdp}),this.initiator||this._requestMissingTransceivers()},i=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},s=a=>{this.destroy(r(a,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(i).catch(s)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=i=>(Object.prototype.toString.call(i.values)==="[object Array]"&&i.values.forEach(s=>{Object.assign(i,s)}),i);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(i=>{const s=[];i.forEach(a=>{s.push(t(a))}),e(null,s)},i=>e(i)):this._pc.getStats.length>0?this._pc.getStats(i=>{if(this.destroyed)return;const s=[];i.result().forEach(a=>{const c={};a.names().forEach(l=>{c[l]=a.stat(l)}),c.id=a.id,c.type=a.type,c.timestamp=a.timestamp,s.push(t(c))}),e(null,s)},i=>e(i)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,i)=>{if(this.destroyed)return;t&&(i=[]);const s={},a={},c={};let l=!1;i.forEach(n=>{(n.type==="remotecandidate"||n.type==="remote-candidate")&&(s[n.id]=n),(n.type==="localcandidate"||n.type==="local-candidate")&&(a[n.id]=n),(n.type==="candidatepair"||n.type==="candidate-pair")&&(c[n.id]=n)});const u=n=>{l=!0;let o=a[n.localCandidateId];o&&(o.ip||o.address)?(this.localAddress=o.ip||o.address,this.localPort=Number(o.port)):o&&o.ipAddress?(this.localAddress=o.ipAddress,this.localPort=Number(o.portNumber)):typeof n.googLocalAddress=="string"&&(o=n.googLocalAddress.split(":"),this.localAddress=o[0],this.localPort=Number(o[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let d=s[n.remoteCandidateId];d&&(d.ip||d.address)?(this.remoteAddress=d.ip||d.address,this.remotePort=Number(d.port)):d&&d.ipAddress?(this.remoteAddress=d.ipAddress,this.remotePort=Number(d.portNumber)):typeof n.googRemoteAddress=="string"&&(d=n.googRemoteAddress.split(":"),this.remoteAddress=d[0],this.remotePort=Number(d[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(i.forEach(n=>{n.type==="transport"&&n.selectedCandidatePairId&&u(c[n.selectedCandidatePairId]),(n.type==="googCandidatePair"&&n.googActiveConnection==="true"||(n.type==="candidatepair"||n.type==="candidate-pair")&&n.selected)&&u(n)}),!l&&(!Object.keys(c).length||Object.keys(a).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(o){return this.destroy(r(o,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const n=this._cb;this._cb=null,n(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(i=>i.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const i=this._map;i.has(e)||i.set(e,new Set),i.get(e).add(t)}off(e,t){const i=this._map,s=i.get(e);!s||(s.delete(t),s.size===0&&i.delete(e))}once(e,t){const i=(...s)=>{this.off(e,i),t(...s)};this.on(e,i)}emit(e,...t){const i=this._map;if(!!i.has(e))for(const s of i.get(e))try{s(...t)}catch(a){console.error(a)}}}_.WEBRTC_SUPPORT=!!p(),_.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},_.channelConfig={};class R{constructor({canvasFoundCallback:e,signalSendCallback:t}){this.peer=null,this.streamNodeMap=new Map,this.streams=new Set,this.runningStreams=new WeakSet,this.canvasFoundCallback=e,this.signalSendCallback=t}initPlugin(){return{onBuild:(e,t)=>{e.nodeName==="CANVAS"&&this.canvasFoundCallback(e,t)},getMirror:e=>{this.mirror=e.nodeMirror}}}startStream(e,t){if(!this.runningStreams.has(t)){if(e.tagName==="VIDEO"){const i=e;i.srcObject=t,i.play(),this.runningStreams.add(t);return}if("MediaStreamTrackProcessor"in window){const i=e,s=i.getContext("2d");if(!s)throw new Error(`startStream: Could not get 2d canvas context for ${i.outerHTML}`);const a=t.getVideoTracks()[0],c=new MediaStreamTrackProcessor({track:a}).readable.getReader(),l=function(){c.read().then(({done:u,value:n})=>{!n||((i.width!==n.displayWidth||i.height!==n.displayHeight)&&(i.width=n.displayWidth,i.height=n.displayHeight),s.clearRect(0,0,i.width,i.height),s.drawImage(n,0,0),n.close(),u||l())})};l(),this.runningStreams.add(t)}else{const i=document.createElement("video");i.setAttribute("autoplay","true"),i.setAttribute("playsinline","true"),i.setAttribute("width",e.width.toString()),i.setAttribute("height",e.height.toString()),e.replaceWith(i),this.startStream(i,t)}}}signalReceive(e){this.peer||(this.peer=new _({initiator:!1}),this.peer.on("error",t=>{this.peer=null,console.log("error",t)}),this.peer.on("close",()=>{this.peer=null,console.log("closing")}),this.peer.on("signal",t=>{this.signalSendCallback(t)}),this.peer.on("connect",()=>{}),this.peer.on("data",t=>{try{const i=JSON.parse(t);this.streamNodeMap.set(i.streamId,i.nodeId)}catch(i){console.error("Could not parse data",i)}this.flushStreams()}),this.peer.on("stream",t=>{this.streams.add(t),this.flushStreams()})),this.peer.signal(e)}flushStreams(){this.streams.forEach(e=>{const t=this.streamNodeMap.get(e.id);if(!t)return;const i=this.mirror.getNode(t);i&&this.startStream(i,e)})}}return g.RRWebPluginCanvasWebRTCReplay=R,Object.defineProperty(g,"__esModule",{value:!0}),g}({});
//# sourceMappingURL=canvas-webrtc-replay.min.js.map
var rrwebConsoleReplay=function(c){"use strict";var i;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(i||(i={}));const r=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let d={map:{},getId(){return console.error(r),-1},getNode(){return console.error(r),null},removeNodeFromMap(){console.error(r)},has(){return console.error(r),!1},reset(){console.error(r)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(d=new Proxy(d,{get(e,t,o){return t==="map"&&console.error(r),Reflect.get(e,t,o)}}));const g="rrweb/console@1";var u=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(u||{}),p=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(p||{}),h=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(h||{}),m=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(m||{}),y=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(y||{}),M=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(M||{});const s="__rrweb_original__",S={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],replayLogger:void 0};class C{constructor(t){this.config=Object.assign(S,t)}getConsoleLogger(){const t={};for(const o of this.config.level)o==="trace"?t[o]=n=>{(console.log[s]?console.log[s]:console.log)(...n.payload.map(l=>JSON.parse(l)),this.formatMessage(n))}:t[o]=n=>{(console[o][s]?console[o][s]:console[o])(...n.payload.map(l=>JSON.parse(l)),this.formatMessage(n))};return t}formatMessage(t){if(t.trace.length===0)return"";const o=`
at `;let n=o;return n+=t.trace.join(o),n}}const v=e=>{const t=e?.replayLogger||new C(e).getConsoleLogger();return{handler(o,n,l){let a=null;if(o.type===u.IncrementalSnapshot&&o.data.source===p.Log?a=o.data:o.type===u.Plugin&&o.data.plugin===g&&(a=o.data.payload),a)try{typeof t[a.level]=="function"&&t[a.level](a)}catch(f){l.replayer.config.showWarning&&console.warn(f)}}}};return c.getReplayConsolePlugin=v,Object.defineProperty(c,"__esModule",{value:!0}),c}({});
or you can use record.mirror to access the mirror instance during recording.`;let d={map:{},getId(){return console.error(r),-1},getNode(){return console.error(r),null},removeNodeFromMap(){console.error(r)},has(){return console.error(r),!1},reset(){console.error(r)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(d=new Proxy(d,{get(e,t,o){return t==="map"&&console.error(r),Reflect.get(e,t,o)}}));const p="rrweb/console@1";var u=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(u||{}),g=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(g||{}),m=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(m||{}),y=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(y||{}),S=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(S||{}),C=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(C||{});const s="__rrweb_original__",M={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],replayLogger:void 0};class f{constructor(t){this.config=Object.assign(M,t)}getConsoleLogger(){const t={};for(const o of this.config.level)o==="trace"?t[o]=n=>{(console.log[s]?console.log[s]:console.log)(...n.payload.map(l=>JSON.parse(l)),this.formatMessage(n))}:t[o]=n=>{(console[o][s]?console[o][s]:console[o])(...n.payload.map(l=>JSON.parse(l)),this.formatMessage(n))};return t}formatMessage(t){if(t.trace.length===0)return"";const o=`
at `;let n=o;return n+=t.trace.join(o),n}}const v=e=>{const t=e?.replayLogger||new f(e).getConsoleLogger();return{handler(o,n,l){let a=null;if(o.type===u.IncrementalSnapshot&&o.data.source===g.Log?a=o.data:o.type===u.Plugin&&o.data.plugin===p&&(a=o.data.payload),a)try{typeof t[a.level]=="function"&&t[a.level](a)}catch(D){l.replayer.config.showWarning&&console.warn(D)}}}};return c.getReplayConsolePlugin=v,Object.defineProperty(c,"__esModule",{value:!0}),c}({});
//# sourceMappingURL=console-replay.min.js.map

@@ -1,4 +0,4 @@

var rrwebRecord=function(er){"use strict";var sr;(function(r){r[r.Document=0]="Document",r[r.DocumentType=1]="DocumentType",r[r.Element=2]="Element",r[r.Text=3]="Text",r[r.CDATA=4]="CDATA",r[r.Comment=5]="Comment"})(sr||(sr={}));const B=`Please stop import mirror directly. Instead of that,\r
var rrwebRecord=function(er){"use strict";var sr;(function(r){r[r.Document=0]="Document",r[r.DocumentType=1]="DocumentType",r[r.Element=2]="Element",r[r.Text=3]="Text",r[r.CDATA=4]="CDATA",r[r.Comment=5]="Comment"})(sr||(sr={}));const N=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let cr={map:{},getId(){return console.error(B),-1},getNode(){return console.error(B),null},removeNodeFromMap(){console.error(B)},has(){return console.error(B),!1},reset(){console.error(B)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(cr=new Proxy(cr,{get(r,e,a){return e==="map"&&console.error(B),Reflect.get(r,e,a)}}));for(var Ir=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(Ir||{}),dr=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r))(dr||{}),Rr=(r=>(r[r.MouseUp=0]="MouseUp",r[r.MouseDown=1]="MouseDown",r[r.Click=2]="Click",r[r.ContextMenu=3]="ContextMenu",r[r.DblClick=4]="DblClick",r[r.Focus=5]="Focus",r[r.Blur=6]="Blur",r[r.TouchStart=7]="TouchStart",r[r.TouchMove_Departed=8]="TouchMove_Departed",r[r.TouchEnd=9]="TouchEnd",r[r.TouchCancel=10]="TouchCancel",r))(Rr||{}),xr=(r=>(r[r["2D"]=0]="2D",r[r.WebGL=1]="WebGL",r[r.WebGL2=2]="WebGL2",r))(xr||{}),Er=(r=>(r[r.Play=0]="Play",r[r.Pause=1]="Pause",r[r.Seeked=2]="Seeked",r[r.VolumeChange=3]="VolumeChange",r[r.RateChange=4]="RateChange",r))(Er||{}),Lr=(r=>(r.Start="start",r.Pause="pause",r.Resume="resume",r.Resize="resize",r.Finish="finish",r.FullsnapshotRebuilded="fullsnapshot-rebuilded",r.LoadStylesheetStart="load-stylesheet-start",r.LoadStylesheetEnd="load-stylesheet-end",r.SkipStart="skip-start",r.SkipEnd="skip-end",r.MouseInteraction="mouse-interaction",r.EventCast="event-cast",r.CustomEvent="custom-event",r.Flush="flush",r.StateChange="state-change",r.PlayBack="play-back",r.Destroy="destroy",r))(Lr||{}),hr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pr=typeof Uint8Array>"u"?[]:new Uint8Array(256),Y=0;Y<hr.length;Y++)pr[hr.charCodeAt(Y)]=Y;var S=Uint8Array,w=Uint16Array,J=Uint32Array,nr=new S([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]),ar=new S([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]),wr=new S([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gr=function(r,e){for(var a=new w(31),n=0;n<31;++n)a[n]=e+=1<<r[n-1];for(var o=new J(a[30]),n=1;n<30;++n)for(var t=a[n];t<a[n+1];++t)o[t]=t-a[n]<<5|n;return[a,o]},yr=gr(nr,2),Or=yr[0],or=yr[1];Or[28]=258,or[258]=28;for(var Ur=gr(ar,0),Mr=Ur[1],tr=new w(32768),s=0;s<32768;++s){var O=(s&43690)>>>1|(s&21845)<<1;O=(O&52428)>>>2|(O&13107)<<2,O=(O&61680)>>>4|(O&3855)<<4,tr[s]=((O&65280)>>>8|(O&255)<<8)>>>1}for(var K=function(r,e,a){for(var n=r.length,o=0,t=new w(e);o<n;++o)++t[r[o]-1];var f=new w(e);for(o=0;o<e;++o)f[o]=f[o-1]+t[o-1]<<1;var i;if(a){i=new w(1<<e);var l=15-e;for(o=0;o<n;++o)if(r[o])for(var c=o<<4|r[o],v=e-r[o],g=f[r[o]-1]++<<v,m=g|(1<<v)-1;g<=m;++g)i[tr[g]>>>l]=c}else for(i=new w(n),o=0;o<n;++o)i[o]=tr[f[r[o]-1]++]>>>15-r[o];return i},G=new S(288),s=0;s<144;++s)G[s]=8;for(var s=144;s<256;++s)G[s]=9;for(var s=256;s<280;++s)G[s]=7;for(var s=280;s<288;++s)G[s]=8;for(var Z=new S(32),s=0;s<32;++s)Z[s]=5;var zr=K(G,9,0),jr=K(Z,5,0),Cr=function(r){return(r/8>>0)+(r&7&&1)},Sr=function(r,e,a){(e==null||e<0)&&(e=0),(a==null||a>r.length)&&(a=r.length);var n=new(r instanceof w?w:r instanceof J?J:S)(a-e);return n.set(r.subarray(e,a)),n},p=function(r,e,a){a<<=e&7;var n=e/8>>0;r[n]|=a,r[n+1]|=a>>>8},H=function(r,e,a){a<<=e&7;var n=e/8>>0;r[n]|=a,r[n+1]|=a>>>8,r[n+2]|=a>>>16},vr=function(r,e){for(var a=[],n=0;n<r.length;++n)r[n]&&a.push({s:n,f:r[n]});var o=a.length,t=a.slice();if(!o)return[new S(0),0];if(o==1){var f=new S(a[0].s+1);return f[a[0].s]=1,[f,1]}a.sort(function(R,b){return R.f-b.f}),a.push({s:-1,f:25001});var i=a[0],l=a[1],c=0,v=1,g=2;for(a[0]={s:-1,f:i.f+l.f,l:i,r:l};v!=o-1;)i=a[a[c].f<a[g].f?c++:g++],l=a[c!=v&&a[c].f<a[g].f?c++:g++],a[v++]={s:-1,f:i.f+l.f,l:i,r:l};for(var m=t[0].s,n=1;n<o;++n)t[n].s>m&&(m=t[n].s);var y=new w(m+1),I=fr(a[v-1],y,0);if(I>e){var n=0,C=0,U=I-e,V=1<<U;for(t.sort(function(b,M){return y[M.s]-y[b.s]||b.f-M.f});n<o;++n){var d=t[n].s;if(y[d]>e)C+=V-(1<<I-y[d]),y[d]=e;else break}for(C>>>=U;C>0;){var N=t[n].s;y[N]<e?C-=1<<e-y[N]++-1:++n}for(;n>=0&&C;--n){var z=t[n].s;y[z]==e&&(--y[z],++C)}I=e}return[new S(y),I]},fr=function(r,e,a){return r.s==-1?Math.max(fr(r.l,e,a+1),fr(r.r,e,a+1)):e[r.s]=a},mr=function(r){for(var e=r.length;e&&!r[--e];);for(var a=new w(++e),n=0,o=r[0],t=1,f=function(l){a[n++]=l},i=1;i<=e;++i)if(r[i]==o&&i!=e)++t;else{if(!o&&t>2){for(;t>138;t-=138)f(32754);t>2&&(f(t>10?t-11<<5|28690:t-3<<5|12305),t=0)}else if(t>3){for(f(o),--t;t>6;t-=6)f(8304);t>2&&(f(t-3<<5|8208),t=0)}for(;t--;)f(o);t=1,o=r[i]}return[a.subarray(0,n),e]},Q=function(r,e){for(var a=0,n=0;n<e.length;++n)a+=r[n]*e[n];return a},$=function(r,e,a){var n=a.length,o=Cr(e+2);r[o]=n&255,r[o+1]=n>>>8,r[o+2]=r[o]^255,r[o+3]=r[o+1]^255;for(var t=0;t<n;++t)r[o+t+4]=a[t];return(o+4+n)*8},Dr=function(r,e,a,n,o,t,f,i,l,c,v){p(e,v++,a),++o[256];for(var g=vr(o,15),m=g[0],y=g[1],I=vr(t,15),C=I[0],U=I[1],V=mr(m),d=V[0],N=V[1],z=mr(C),R=z[0],b=z[1],M=new w(19),u=0;u<d.length;++u)M[d[u]&31]++;for(var u=0;u<R.length;++u)M[R[u]&31]++;for(var W=vr(M,7),k=W[0],rr=W[1],D=19;D>4&&!k[wr[D-1]];--D);var _=c+5<<3,A=Q(o,G)+Q(t,Z)+f,F=Q(o,m)+Q(t,C)+f+14+3*D+Q(M,k)+(2*M[16]+3*M[17]+7*M[18]);if(_<=A&&_<=F)return $(e,v,r.subarray(l,l+c));var x,h,P,j;if(p(e,v,1+(F<A)),v+=2,F<A){x=K(m,y,0),h=m,P=K(C,U,0),j=C;var lr=K(k,rr,0);p(e,v,N-257),p(e,v+5,b-1),p(e,v+10,D-4),v+=14;for(var u=0;u<D;++u)p(e,v+3*u,k[wr[u]]);v+=3*D;for(var E=[d,R],X=0;X<2;++X)for(var q=E[X],u=0;u<q.length;++u){var L=q[u]&31;p(e,v,lr[L]),v+=k[L],L>15&&(p(e,v,q[u]>>>5&127),v+=q[u]>>>12)}}else x=zr,h=G,P=jr,j=Z;for(var u=0;u<i;++u)if(n[u]>255){var L=n[u]>>>18&31;H(e,v,x[L+257]),v+=h[L+257],L>7&&(p(e,v,n[u]>>>23&31),v+=nr[L]);var T=n[u]&31;H(e,v,P[T]),v+=j[T],T>3&&(H(e,v,n[u]>>>5&8191),v+=ar[T])}else H(e,v,x[n[u]]),v+=h[n[u]];return H(e,v,x[256]),v+h[256]},Gr=new J([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vr=new S(0),Wr=function(r,e,a,n,o,t){var f=r.length,i=new S(n+f+5*(1+Math.floor(f/7e3))+o),l=i.subarray(n,i.length-o),c=0;if(!e||f<8)for(var v=0;v<=f;v+=65535){var g=v+65535;g<f?c=$(l,c,r.subarray(v,g)):(l[v]=t,c=$(l,c,r.subarray(v,f)))}else{for(var m=Gr[e-1],y=m>>>13,I=m&8191,C=(1<<a)-1,U=new w(32768),V=new w(C+1),d=Math.ceil(a/3),N=2*d,z=function(ir){return(r[ir]^r[ir+1]<<d^r[ir+2]<<N)&C},R=new J(25e3),b=new w(288),M=new w(32),u=0,W=0,v=0,k=0,rr=0,D=0;v<f;++v){var _=z(v),A=v&32767,F=V[_];if(U[A]=F,V[_]=A,rr<=v){var x=f-v;if((u>7e3||k>24576)&&x>423){c=Dr(r,l,0,R,b,M,W,k,D,v-D,c),k=u=W=0,D=v;for(var h=0;h<286;++h)b[h]=0;for(var h=0;h<30;++h)M[h]=0}var P=2,j=0,lr=I,E=A-F&32767;if(x>2&&_==z(v-E))for(var X=Math.min(y,x)-1,q=Math.min(32767,v),L=Math.min(258,x);E<=q&&--lr&&A!=F;){if(r[v+P]==r[v+P-E]){for(var T=0;T<L&&r[v+T]==r[v+T-E];++T);if(T>P){if(P=T,j=E,T>X)break;for(var oe=Math.min(E,T-2),kr=0,h=0;h<oe;++h){var ur=v-E+h+32768&32767,te=U[ur],Ar=ur-te+32768&32767;Ar>kr&&(kr=Ar,F=ur)}}}A=F,F=U[A],E+=A-F+32768&32767}if(j){R[k++]=268435456|or[P]<<18|Mr[j];var Fr=or[P]&31,Pr=Mr[j]&31;W+=nr[Fr]+ar[Pr],++b[257+Fr],++M[Pr],rr=v+P,++u}else R[k++]=r[v],++b[r[v]]}}c=Dr(r,l,t,R,b,M,W,k,D,v-D,c),t||(c=$(l,c,Vr))}return Sr(i,0,n+Cr(c)+o)},Br=function(){var r=1,e=0;return{p:function(a){for(var n=r,o=e,t=a.length,f=0;f!=t;){for(var i=Math.min(f+5552,t);f<i;++f)n+=a[f],o+=n;n%=65521,o%=65521}r=n,e=o},d:function(){return(r>>>8<<16|(e&255)<<8|e>>>8)+((r&255)<<23)*2}}},Nr=function(r,e,a,n,o){return Wr(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,a,n,!o)},_r=function(r,e,a){for(;a;++e)r[e]=a,a>>>=8},qr=function(r,e){var a=e.level,n=a==0?0:a<6?1:a==9?3:2;r[0]=120,r[1]=n<<6|(n?32-2*n:1)};function Jr(r,e){e===void 0&&(e={});var a=Br();a.p(r);var n=Nr(r,e,2,4);return qr(n,e),_r(n,n.length-4,a.d()),n}function Kr(r,e){var a=r.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var n=new S(r.length+(r.length>>>1)),o=0,t=function(c){n[o++]=c},f=0;f<a;++f){if(o+5>n.length){var i=new S(o+8+(a-f<<1));i.set(n),n=i}var l=r.charCodeAt(f);l<128||e?t(l):l<2048?(t(192|l>>>6),t(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++f)&1023,t(240|l>>>18),t(128|l>>>12&63),t(128|l>>>6&63),t(128|l&63)):(t(224|l>>>12),t(128|l>>>6&63),t(128|l&63))}return Sr(n,0,o)}function Hr(r,e){var a="";if(!e&&typeof TextDecoder<"u")return new TextDecoder().decode(r);for(var n=0;n<r.length;){var o=r[n++];o<128||e?a+=String.fromCharCode(o):o<224?a+=String.fromCharCode((o&31)<<6|r[n++]&63):o<240?a+=String.fromCharCode((o&15)<<12|(r[n++]&63)<<6|r[n++]&63):(o=((o&15)<<18|(r[n++]&63)<<12|(r[n++]&63)<<6|r[n++]&63)-65536,a+=String.fromCharCode(55296|o>>10,56320|o&1023))}return a}const Qr="v1";var Xr=Object.defineProperty,Yr=Object.defineProperties,Zr=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,$r=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,br=(r,e,a)=>e in r?Xr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[e]=a,ee=(r,e)=>{for(var a in e||(e={}))$r.call(e,a)&&br(r,a,e[a]);if(Tr)for(var a of Tr(e))re.call(e,a)&&br(r,a,e[a]);return r},ne=(r,e)=>Yr(r,Zr(e));const ae=r=>{const e=ne(ee({},r),{v:Qr});return Hr(Jr(Kr(JSON.stringify(e))),!0)};return er.pack=ae,Object.defineProperty(er,"__esModule",{value:!0}),er}({});
or you can use record.mirror to access the mirror instance during recording.`;let cr={map:{},getId(){return console.error(N),-1},getNode(){return console.error(N),null},removeNodeFromMap(){console.error(N)},has(){return console.error(N),!1},reset(){console.error(N)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(cr=new Proxy(cr,{get(r,e,n){return e==="map"&&console.error(N),Reflect.get(r,e,n)}}));for(var Lr=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(Lr||{}),Rr=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r))(Rr||{}),xr=(r=>(r[r.MouseUp=0]="MouseUp",r[r.MouseDown=1]="MouseDown",r[r.Click=2]="Click",r[r.ContextMenu=3]="ContextMenu",r[r.DblClick=4]="DblClick",r[r.Focus=5]="Focus",r[r.Blur=6]="Blur",r[r.TouchStart=7]="TouchStart",r[r.TouchMove_Departed=8]="TouchMove_Departed",r[r.TouchEnd=9]="TouchEnd",r[r.TouchCancel=10]="TouchCancel",r))(xr||{}),Ir=(r=>(r[r["2D"]=0]="2D",r[r.WebGL=1]="WebGL",r[r.WebGL2=2]="WebGL2",r))(Ir||{}),Er=(r=>(r[r.Play=0]="Play",r[r.Pause=1]="Pause",r[r.Seeked=2]="Seeked",r[r.VolumeChange=3]="VolumeChange",r[r.RateChange=4]="RateChange",r))(Er||{}),Or=(r=>(r.Start="start",r.Pause="pause",r.Resume="resume",r.Resize="resize",r.Finish="finish",r.FullsnapshotRebuilded="fullsnapshot-rebuilded",r.LoadStylesheetStart="load-stylesheet-start",r.LoadStylesheetEnd="load-stylesheet-end",r.SkipStart="skip-start",r.SkipEnd="skip-end",r.MouseInteraction="mouse-interaction",r.EventCast="event-cast",r.CustomEvent="custom-event",r.Flush="flush",r.StateChange="state-change",r.PlayBack="play-back",r.Destroy="destroy",r))(Or||{}),wr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pr=typeof Uint8Array>"u"?[]:new Uint8Array(256),Z=0;Z<wr.length;Z++)pr[wr.charCodeAt(Z)]=Z;var m=Uint8Array,g=Uint16Array,K=Uint32Array,ar=new m([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]),nr=new m([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]),gr=new m([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yr=function(r,e){for(var n=new g(31),a=0;a<31;++a)n[a]=e+=1<<r[a-1];for(var o=new K(n[30]),a=1;a<30;++a)for(var t=n[a];t<n[a+1];++t)o[t]=t-n[a]<<5|a;return[n,o]},Mr=yr(ar,2),Ur=Mr[0],or=Mr[1];Ur[28]=258,or[258]=28;for(var zr=yr(nr,0),Cr=zr[1],tr=new g(32768),s=0;s<32768;++s){var U=(s&43690)>>>1|(s&21845)<<1;U=(U&52428)>>>2|(U&13107)<<2,U=(U&61680)>>>4|(U&3855)<<4,tr[s]=((U&65280)>>>8|(U&255)<<8)>>>1}for(var H=function(r,e,n){for(var a=r.length,o=0,t=new g(e);o<a;++o)++t[r[o]-1];var f=new g(e);for(o=0;o<e;++o)f[o]=f[o-1]+t[o-1]<<1;var i;if(n){i=new g(1<<e);var l=15-e;for(o=0;o<a;++o)if(r[o])for(var c=o<<4|r[o],v=e-r[o],y=f[r[o]-1]++<<v,D=y|(1<<v)-1;y<=D;++y)i[tr[y]>>>l]=c}else for(i=new g(a),o=0;o<a;++o)i[o]=tr[f[r[o]-1]++]>>>15-r[o];return i},V=new m(288),s=0;s<144;++s)V[s]=8;for(var s=144;s<256;++s)V[s]=9;for(var s=256;s<280;++s)V[s]=7;for(var s=280;s<288;++s)V[s]=8;for(var $=new m(32),s=0;s<32;++s)$[s]=5;var jr=H(V,9,0),Gr=H($,5,0),Sr=function(r){return(r/8>>0)+(r&7&&1)},mr=function(r,e,n){(e==null||e<0)&&(e=0),(n==null||n>r.length)&&(n=r.length);var a=new(r instanceof g?g:r instanceof K?K:m)(n-e);return a.set(r.subarray(e,n)),a},p=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8},Q=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8,r[a+2]|=n>>>16},vr=function(r,e){for(var n=[],a=0;a<r.length;++a)r[a]&&n.push({s:a,f:r[a]});var o=n.length,t=n.slice();if(!o)return[new m(0),0];if(o==1){var f=new m(n[0].s+1);return f[n[0].s]=1,[f,1]}n.sort(function(x,k){return x.f-k.f}),n.push({s:-1,f:25001});var i=n[0],l=n[1],c=0,v=1,y=2;for(n[0]={s:-1,f:i.f+l.f,l:i,r:l};v!=o-1;)i=n[n[c].f<n[y].f?c++:y++],l=n[c!=v&&n[c].f<n[y].f?c++:y++],n[v++]={s:-1,f:i.f+l.f,l:i,r:l};for(var D=t[0].s,a=1;a<o;++a)t[a].s>D&&(D=t[a].s);var M=new g(D+1),L=fr(n[v-1],M,0);if(L>e){var a=0,S=0,z=L-e,W=1<<z;for(t.sort(function(k,C){return M[C.s]-M[k.s]||k.f-C.f});a<o;++a){var R=t[a].s;if(M[R]>e)S+=W-(1<<L-M[R]),M[R]=e;else break}for(S>>>=z;S>0;){var _=t[a].s;M[_]<e?S-=1<<e-M[_]++-1:++a}for(;a>=0&&S;--a){var j=t[a].s;M[j]==e&&(--M[j],++S)}L=e}return[new m(M),L]},fr=function(r,e,n){return r.s==-1?Math.max(fr(r.l,e,n+1),fr(r.r,e,n+1)):e[r.s]=n},Dr=function(r){for(var e=r.length;e&&!r[--e];);for(var n=new g(++e),a=0,o=r[0],t=1,f=function(l){n[a++]=l},i=1;i<=e;++i)if(r[i]==o&&i!=e)++t;else{if(!o&&t>2){for(;t>138;t-=138)f(32754);t>2&&(f(t>10?t-11<<5|28690:t-3<<5|12305),t=0)}else if(t>3){for(f(o),--t;t>6;t-=6)f(8304);t>2&&(f(t-3<<5|8208),t=0)}for(;t--;)f(o);t=1,o=r[i]}return[n.subarray(0,a),e]},X=function(r,e){for(var n=0,a=0;a<e.length;++a)n+=r[a]*e[a];return n},h=function(r,e,n){var a=n.length,o=Sr(e+2);r[o]=a&255,r[o+1]=a>>>8,r[o+2]=r[o]^255,r[o+3]=r[o+1]^255;for(var t=0;t<a;++t)r[o+t+4]=n[t];return(o+4+a)*8},br=function(r,e,n,a,o,t,f,i,l,c,v){p(e,v++,n),++o[256];for(var y=vr(o,15),D=y[0],M=y[1],L=vr(t,15),S=L[0],z=L[1],W=Dr(D),R=W[0],_=W[1],j=Dr(S),x=j[0],k=j[1],C=new g(19),u=0;u<R.length;++u)C[R[u]&31]++;for(var u=0;u<x.length;++u)C[x[u]&31]++;for(var B=vr(C,7),A=B[0],rr=B[1],b=19;b>4&&!A[gr[b-1]];--b);var q=c+5<<3,F=X(o,V)+X(t,$)+f,P=X(o,D)+X(t,S)+f+14+3*b+X(C,A)+(2*C[16]+3*C[17]+7*C[18]);if(q<=F&&q<=P)return h(e,v,r.subarray(l,l+c));var I,w,d,G;if(p(e,v,1+(P<F)),v+=2,P<F){I=H(D,M,0),w=D,d=H(S,z,0),G=S;var lr=H(A,rr,0);p(e,v,_-257),p(e,v+5,k-1),p(e,v+10,b-4),v+=14;for(var u=0;u<b;++u)p(e,v+3*u,A[gr[u]]);v+=3*b;for(var E=[R,x],Y=0;Y<2;++Y)for(var J=E[Y],u=0;u<J.length;++u){var O=J[u]&31;p(e,v,lr[O]),v+=A[O],O>15&&(p(e,v,J[u]>>>5&127),v+=J[u]>>>12)}}else I=jr,w=V,d=Gr,G=$;for(var u=0;u<i;++u)if(a[u]>255){var O=a[u]>>>18&31;Q(e,v,I[O+257]),v+=w[O+257],O>7&&(p(e,v,a[u]>>>23&31),v+=ar[O]);var T=a[u]&31;Q(e,v,d[T]),v+=G[T],T>3&&(Q(e,v,a[u]>>>5&8191),v+=nr[T])}else Q(e,v,I[a[u]]),v+=w[a[u]];return Q(e,v,I[256]),v+w[256]},Vr=new K([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wr=new m(0),Br=function(r,e,n,a,o,t){var f=r.length,i=new m(a+f+5*(1+Math.floor(f/7e3))+o),l=i.subarray(a,i.length-o),c=0;if(!e||f<8)for(var v=0;v<=f;v+=65535){var y=v+65535;y<f?c=h(l,c,r.subarray(v,y)):(l[v]=t,c=h(l,c,r.subarray(v,f)))}else{for(var D=Vr[e-1],M=D>>>13,L=D&8191,S=(1<<n)-1,z=new g(32768),W=new g(S+1),R=Math.ceil(n/3),_=2*R,j=function(ir){return(r[ir]^r[ir+1]<<R^r[ir+2]<<_)&S},x=new K(25e3),k=new g(288),C=new g(32),u=0,B=0,v=0,A=0,rr=0,b=0;v<f;++v){var q=j(v),F=v&32767,P=W[q];if(z[F]=P,W[q]=F,rr<=v){var I=f-v;if((u>7e3||A>24576)&&I>423){c=br(r,l,0,x,k,C,B,A,b,v-b,c),A=u=B=0,b=v;for(var w=0;w<286;++w)k[w]=0;for(var w=0;w<30;++w)C[w]=0}var d=2,G=0,lr=L,E=F-P&32767;if(I>2&&q==j(v-E))for(var Y=Math.min(M,I)-1,J=Math.min(32767,v),O=Math.min(258,I);E<=J&&--lr&&F!=P;){if(r[v+d]==r[v+d-E]){for(var T=0;T<O&&r[v+T]==r[v+T-E];++T);if(T>d){if(d=T,G=E,T>Y)break;for(var oe=Math.min(E,T-2),Ar=0,w=0;w<oe;++w){var ur=v-E+w+32768&32767,te=z[ur],Fr=ur-te+32768&32767;Fr>Ar&&(Ar=Fr,P=ur)}}}F=P,P=z[F],E+=F-P+32768&32767}if(G){x[A++]=268435456|or[d]<<18|Cr[G];var Pr=or[d]&31,dr=Cr[G]&31;B+=ar[Pr]+nr[dr],++k[257+Pr],++C[dr],rr=v+d,++u}else x[A++]=r[v],++k[r[v]]}}c=br(r,l,t,x,k,C,B,A,b,v-b,c),t||(c=h(l,c,Wr))}return mr(i,0,a+Sr(c)+o)},Nr=function(){var r=1,e=0;return{p:function(n){for(var a=r,o=e,t=n.length,f=0;f!=t;){for(var i=Math.min(f+5552,t);f<i;++f)a+=n[f],o+=a;a%=65521,o%=65521}r=a,e=o},d:function(){return(r>>>8<<16|(e&255)<<8|e>>>8)+((r&255)<<23)*2}}},_r=function(r,e,n,a,o){return Br(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,n,a,!o)},qr=function(r,e,n){for(;n;++e)r[e]=n,n>>>=8},Jr=function(r,e){var n=e.level,a=n==0?0:n<6?1:n==9?3:2;r[0]=120,r[1]=a<<6|(a?32-2*a:1)};function Kr(r,e){e===void 0&&(e={});var n=Nr();n.p(r);var a=_r(r,e,2,4);return Jr(a,e),qr(a,a.length-4,n.d()),a}function Hr(r,e){var n=r.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new m(r.length+(r.length>>>1)),o=0,t=function(c){a[o++]=c},f=0;f<n;++f){if(o+5>a.length){var i=new m(o+8+(n-f<<1));i.set(a),a=i}var l=r.charCodeAt(f);l<128||e?t(l):l<2048?(t(192|l>>>6),t(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++f)&1023,t(240|l>>>18),t(128|l>>>12&63),t(128|l>>>6&63),t(128|l&63)):(t(224|l>>>12),t(128|l>>>6&63),t(128|l&63))}return mr(a,0,o)}function Qr(r,e){var n="";if(!e&&typeof TextDecoder<"u")return new TextDecoder().decode(r);for(var a=0;a<r.length;){var o=r[a++];o<128||e?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((o&31)<<6|r[a++]&63):o<240?n+=String.fromCharCode((o&15)<<12|(r[a++]&63)<<6|r[a++]&63):(o=((o&15)<<18|(r[a++]&63)<<12|(r[a++]&63)<<6|r[a++]&63)-65536,n+=String.fromCharCode(55296|o>>10,56320|o&1023))}return n}const Xr="v1";var Yr=Object.defineProperty,Zr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,kr=(r,e,n)=>e in r?Yr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,ee=(r,e)=>{for(var n in e||(e={}))hr.call(e,n)&&kr(r,n,e[n]);if(Tr)for(var n of Tr(e))re.call(e,n)&&kr(r,n,e[n]);return r},ae=(r,e)=>Zr(r,$r(e));const ne=r=>{const e=ae(ee({},r),{v:Xr});return Qr(Kr(Hr(JSON.stringify(e))),!0)};return er.pack=ne,Object.defineProperty(er,"__esModule",{value:!0}),er}({});
//# sourceMappingURL=rrweb-record-pack.min.js.map

@@ -1,5 +0,5 @@

var rrwebRecord=function(){"use strict";var N;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(N||(N={}));function Lt(e){return e.nodeType===e.ELEMENT_NODE}function fe(e){var t=e?.host;return Boolean(t?.shadowRoot===e)}function ye(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function Te(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(Ae).join(""):null}catch{return null}}function Ae(e){var t=e.cssText;if(Tt(e))try{t=Te(e.styleSheet)||t}catch{}return t}function Tt(e){return"styleSheet"in e}var Pe=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var n;if(!t)return-1;var r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var n=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(o){return n.removeNodeFromMap(o)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,n){var r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)},e.prototype.replace=function(t,n){var r=this.getNode(t);if(r){var o=this.nodeMetaMap.get(r);o&&this.nodeMetaMap.set(n,o)}this.idNodeMap.set(t,n)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Et(){return new Pe}function Ee(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(s?i=s(i):i="*".repeat(i.length)),i}var _e="__rrweb_original__";function Rt(e){var t=e.getContext("2d");if(!t)return!0;for(var n=50,r=0;r<e.width;r+=n)for(var o=0;o<e.height;o+=n){var s=t.getImageData,i=_e in s?s[_e]:s,l=new Uint32Array(i.call(t,r,o,Math.min(n,e.width-r),Math.min(n,e.height-o)).data.buffer);if(l.some(function(a){return a!==0}))return!1}return!0}var xt=1,Nt=new RegExp("[^a-z0-9-_:]"),ve=-2;function Dt(){return xt++}function Ft(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return Nt.test(t)?"div":t}function At(e){return e.cssRules?Array.from(e.cssRules).map(function(t){return t.cssText||""}).join(""):""}function Pt(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var se,We,_t=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Wt=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,zt=/^(data:)([^,]*),(.*)/i;function Ce(e,t){return(e||"").replace(_t,function(n,r,o,s,i,l){var a=o||i||l,c=r||s||"";if(!a)return n;if(!Wt.test(a)||zt.test(a))return"url(".concat(c).concat(a).concat(c,")");if(a[0]==="/")return"url(".concat(c).concat(Pt(t)+a).concat(c,")");var u=t.split("/"),d=a.split("/");u.pop();for(var h=0,m=d;h<m.length;h++){var p=m[h];p!=="."&&(p===".."?u.pop():u.push(p))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var Gt=/^[^ \t\n\r\u000c]+/,Vt=/^[, \t\n\r\u000c]+/;function Zt(e,t){if(t.trim()==="")return t;var n=0;function r(c){var u,d=c.exec(t.substring(n));return d?(u=d[0],n+=u.length,u):""}for(var o=[];r(Vt),!(n>=t.length);){var s=r(Gt);if(s.slice(-1)===",")s=ke(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=ke(e,s);for(var l=!1;;){var a=t.charAt(n);if(a===""){o.push((s+i).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){n+=1,o.push((s+i).trim());break}else a==="("&&(l=!0);i+=a,n+=1}}}return o.join(", ")}function ke(e,t){if(!t||t.trim()==="")return t;var n=e.createElement("a");return n.href=t,n.href}function jt(e){return Boolean(e.tagName==="svg"||e.ownerSVGElement)}function Re(){var e=document.createElement("a");return e.href="",e.href}function ze(e,t,n,r){return n==="src"||n==="href"&&r&&!(t==="use"&&r[0]==="#")||n==="xlink:href"&&r&&r[0]!=="#"||n==="background"&&r&&(t==="table"||t==="td"||t==="th")?ke(e,r):n==="srcset"&&r?Zt(e,r):n==="style"&&r?Ce(r,Re()):t==="object"&&n==="data"&&r?ke(e,r):r}function Ut(e,t,n){if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return n?e.matches(n):!1}function Ie(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?Ie(e.parentNode,t,n):!1;for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return n?Ie(e.parentNode,t,n):!1}function Ge(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(r===null)return!1;if(typeof t=="string"){if(r.classList.contains(t)||r.closest(".".concat(t)))return!0}else if(Ie(r,t,!0))return!0;return!!(n&&(r.matches(n)||r.closest(n)))}function Xt(e,t,n){var r=e.contentWindow;if(r){var o=!1,s;try{s=r.document.readyState}catch{return}if(s!=="complete"){var i=setTimeout(function(){o||(t(),o=!0)},n);e.addEventListener("load",function(){clearTimeout(i),o=!0,t()});return}var l="about:blank";if(r.location.href!==l||e.src===l||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Ht(e,t,n){var r=!1,o;try{o=e.sheet}catch{return}if(!o){var s=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(s),r=!0,t()})}}function Bt(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,l=t.maskTextSelector,a=t.inlineStylesheet,c=t.maskInputOptions,u=c===void 0?{}:c,d=t.maskTextFn,h=t.maskInputFn,m=t.dataURLOptions,p=m===void 0?{}:m,y=t.inlineImages,S=t.recordCanvas,v=t.keepIframeSrcFn,g=t.newlyAddedElement,f=g===void 0?!1:g,C=Yt(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:N.Document,childNodes:[],compatMode:e.compatMode}:{type:N.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:N.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:C};case e.ELEMENT_NODE:return $t(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:a,maskInputOptions:u,maskInputFn:h,dataURLOptions:p,inlineImages:y,recordCanvas:S,keepIframeSrcFn:v,newlyAddedElement:f,rootId:C});case e.TEXT_NODE:return Kt(e,{maskTextClass:i,maskTextSelector:l,maskTextFn:d,rootId:C});case e.CDATA_SECTION_NODE:return{type:N.CDATA,textContent:"",rootId:C};case e.COMMENT_NODE:return{type:N.Comment,textContent:e.textContent||"",rootId:C};default:return!1}}function Yt(e,t){if(t.hasNode(e)){var n=t.getId(e);return n===1?void 0:n}}function Kt(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,i=t.rootId,l=e.parentNode&&e.parentNode.tagName,a=e.textContent,c=l==="STYLE"?!0:void 0,u=l==="SCRIPT"?!0:void 0;if(c&&a){try{e.nextSibling||e.previousSibling||!((n=e.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(a=At(e.parentNode.sheet))}catch(d){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(d),e)}a=Ce(a,Re())}return u&&(a="SCRIPT_PLACEHOLDER"),!c&&!u&&a&&Ge(e,r,o)&&(a=s?s(a):a.replace(/[\S]/g,"*")),{type:N.Text,textContent:a||"",isStyle:c,rootId:i}}function $t(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,i=t.maskInputOptions,l=i===void 0?{}:i,a=t.maskInputFn,c=t.dataURLOptions,u=c===void 0?{}:c,d=t.inlineImages,h=t.recordCanvas,m=t.keepIframeSrcFn,p=t.newlyAddedElement,y=p===void 0?!1:p,S=t.rootId,v=Ut(e,r,o),g=Ft(e),f={},C=e.attributes.length,R=0;R<C;R++){var z=e.attributes[R];f[z.name]=ze(n,g,z.name,z.value)}if(g==="link"&&s){var T=Array.from(n.styleSheets).find(function(F){return F.href===e.href}),w=null;T&&(w=Te(T)),w&&(delete f.rel,delete f.href,f._cssText=Ce(w,T.href))}if(g==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var w=Te(e.sheet);w&&(f._cssText=Ce(w,Re()))}if(g==="input"||g==="textarea"||g==="select"){var B=e.value,Y=e.checked;f.type!=="radio"&&f.type!=="checkbox"&&f.type!=="submit"&&f.type!=="button"&&B?f.value=Ee({type:f.type,tagName:g,value:B,maskInputOptions:l,maskInputFn:a}):Y&&(f.checked=Y)}if(g==="option"&&(e.selected&&!l.select?f.selected=!0:delete f.selected),g==="canvas"&&h){if(e.__context==="2d")Rt(e)||(f.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var G=e.toDataURL(u.type,u.quality),X=document.createElement("canvas");X.width=e.width,X.height=e.height;var K=X.toDataURL(u.type,u.quality);G!==K&&(f.rr_dataURL=G)}}if(g==="img"&&d){se||(se=n.createElement("canvas"),We=se.getContext("2d"));var x=e,$=x.crossOrigin;x.crossOrigin="anonymous";var Z=function(){try{se.width=x.naturalWidth,se.height=x.naturalHeight,We.drawImage(x,0,0),f.rr_dataURL=se.toDataURL(u.type,u.quality)}catch(F){console.warn("Cannot inline img src=".concat(x.currentSrc,"! Error: ").concat(F))}$?f.crossOrigin=$:x.removeAttribute("crossorigin")};x.complete&&x.naturalWidth!==0?Z():x.onload=Z}if((g==="audio"||g==="video")&&(f.rr_mediaState=e.paused?"paused":"played",f.rr_mediaCurrentTime=e.currentTime),y||(e.scrollLeft&&(f.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(f.rr_scrollTop=e.scrollTop)),v){var ne=e.getBoundingClientRect(),re=ne.width,J=ne.height;f={class:f.class,rr_width:"".concat(re,"px"),rr_height:"".concat(J,"px")}}return g==="iframe"&&!m(f.src)&&(e.contentDocument||(f.rr_src=f.src),delete f.src),{type:N.Element,tagName:g,attributes:f,childNodes:[],isSVG:jt(e)||void 0,needBlock:v,rootId:S}}function I(e){return e===void 0?"":e.toLowerCase()}function Jt(e,t){return!!(t.comment&&e.type===N.Comment||e.type===N.Element&&(t.script&&(e.tagName==="script"||e.tagName==="link"&&e.attributes.rel==="preload"&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js"))||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(I(e.attributes.name).match(/^msapplication-tile(image|color)$/)||I(e.attributes.name)==="application-name"||I(e.attributes.rel)==="icon"||I(e.attributes.rel)==="apple-touch-icon"||I(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&I(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(I(e.attributes.property).match(/^(og|twitter|fb):/)||I(e.attributes.name).match(/^(og|twitter):/)||I(e.attributes.name)==="pinterest")||t.headMetaRobots&&(I(e.attributes.name)==="robots"||I(e.attributes.name)==="googlebot"||I(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(I(e.attributes.name)==="author"||I(e.attributes.name)==="generator"||I(e.attributes.name)==="framework"||I(e.attributes.name)==="publisher"||I(e.attributes.name)==="progid"||I(e.attributes.property).match(/^article:/)||I(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(I(e.attributes.name)==="google-site-verification"||I(e.attributes.name)==="yandex-verification"||I(e.attributes.name)==="csrf-token"||I(e.attributes.name)==="p:domain_verify"||I(e.attributes.name)==="verify-v1"||I(e.attributes.name)==="verification"||I(e.attributes.name)==="shopify-checkout-api-token"))))}function ie(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,l=t.maskTextSelector,a=t.skipChild,c=a===void 0?!1:a,u=t.inlineStylesheet,d=u===void 0?!0:u,h=t.maskInputOptions,m=h===void 0?{}:h,p=t.maskTextFn,y=t.maskInputFn,S=t.slimDOMOptions,v=t.dataURLOptions,g=v===void 0?{}:v,f=t.inlineImages,C=f===void 0?!1:f,R=t.recordCanvas,z=R===void 0?!1:R,T=t.onSerialize,w=t.onIframeLoad,B=t.iframeLoadTimeout,Y=B===void 0?5e3:B,G=t.onStylesheetLoad,X=t.stylesheetLoadTimeout,K=X===void 0?5e3:X,x=t.keepIframeSrcFn,$=x===void 0?function(){return!1}:x,Z=t.newlyAddedElement,ne=Z===void 0?!1:Z,re=t.preserveWhiteSpace,J=re===void 0?!0:re,F=Bt(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:m,maskTextFn:p,maskInputFn:y,dataURLOptions:g,inlineImages:C,recordCanvas:z,keepIframeSrcFn:$,newlyAddedElement:ne});if(!F)return console.warn(e,"not serialized"),null;var Q;r.hasNode(e)?Q=r.getId(e):Jt(F,S)||!J&&F.type===N.Text&&!F.isStyle&&!F.textContent.replace(/^\s+|\s+$/gm,"").length?Q=ve:Q=Dt();var L=Object.assign(F,{id:Q});if(r.add(e,L),Q===ve)return null;T&&T(e);var b=!c;if(L.type===N.Element){b=b&&!L.needBlock,delete L.needBlock;var j=e.shadowRoot;j&&ye(j)&&(L.isShadowHost=!0)}if((L.type===N.Document||L.type===N.Element)&&b){S.headWhitespace&&L.type===N.Element&&L.tagName==="head"&&(J=!1);for(var q={doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:c,inlineStylesheet:d,maskInputOptions:m,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:g,inlineImages:C,recordCanvas:z,preserveWhiteSpace:J,onSerialize:T,onIframeLoad:w,iframeLoadTimeout:Y,onStylesheetLoad:G,stylesheetLoadTimeout:K,keepIframeSrcFn:$},P=0,ee=Array.from(e.childNodes);P<ee.length;P++){var k=ee[P],U=ie(k,q);U&&L.childNodes.push(U)}if(Lt(e)&&e.shadowRoot)for(var me=0,A=Array.from(e.shadowRoot.childNodes);me<A.length;me++){var k=A[me],U=ie(k,q);U&&(ye(e.shadowRoot)&&(U.isShadow=!0),L.childNodes.push(U))}}return e.parentNode&&fe(e.parentNode)&&ye(e.parentNode)&&(L.isShadow=!0),L.type===N.Element&&L.tagName==="iframe"&&Xt(e,function(){var te=e.contentDocument;if(te&&w){var Ot=ie(te,{doc:te,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:m,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:g,inlineImages:C,recordCanvas:z,preserveWhiteSpace:J,onSerialize:T,onIframeLoad:w,iframeLoadTimeout:Y,onStylesheetLoad:G,stylesheetLoadTimeout:K,keepIframeSrcFn:$});Ot&&w(e,Ot)}},Y),L.type===N.Element&&L.tagName==="link"&&L.attributes.rel==="stylesheet"&&Ht(e,function(){if(G){var te=ie(e,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:i,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:m,maskTextFn:p,maskInputFn:y,slimDOMOptions:S,dataURLOptions:g,inlineImages:C,recordCanvas:z,preserveWhiteSpace:J,onSerialize:T,onIframeLoad:w,iframeLoadTimeout:Y,onStylesheetLoad:G,stylesheetLoadTimeout:K,keepIframeSrcFn:$});te&&G(e,te)}},K),L}function Qt(e,t){var n=t||{},r=n.mirror,o=r===void 0?new Pe:r,s=n.blockClass,i=s===void 0?"rr-block":s,l=n.blockSelector,a=l===void 0?null:l,c=n.maskTextClass,u=c===void 0?"rr-mask":c,d=n.maskTextSelector,h=d===void 0?null:d,m=n.inlineStylesheet,p=m===void 0?!0:m,y=n.inlineImages,S=y===void 0?!1:y,v=n.recordCanvas,g=v===void 0?!1:v,f=n.maskAllInputs,C=f===void 0?!1:f,R=n.maskTextFn,z=n.maskInputFn,T=n.slimDOM,w=T===void 0?!1:T,B=n.dataURLOptions,Y=n.preserveWhiteSpace,G=n.onSerialize,X=n.onIframeLoad,K=n.iframeLoadTimeout,x=n.onStylesheetLoad,$=n.stylesheetLoadTimeout,Z=n.keepIframeSrcFn,ne=Z===void 0?function(){return!1}:Z,re=C===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:C===!1?{password:!0}:C,J=w===!0||w==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:w==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:w===!1?{}:w;return ie(e,{doc:e,mirror:o,blockClass:i,blockSelector:a,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:re,maskTextFn:R,maskInputFn:z,slimDOMOptions:J,dataURLOptions:B,inlineImages:S,recordCanvas:g,preserveWhiteSpace:Y,onSerialize:G,onIframeLoad:X,iframeLoadTimeout:K,onStylesheetLoad:x,stylesheetLoadTimeout:$,keepIframeSrcFn:ne,newlyAddedElement:!1})}function _(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const le=`Please stop import mirror directly. Instead of that,\r
var rrwebRecord=function(){"use strict";var x;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(x||(x={}));function xt(e){return e.nodeType===e.ELEMENT_NODE}function fe(e){var t=e?.host;return Boolean(t?.shadowRoot===e)}function ye(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function Dt(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function Ne(e){try{var t=e.rules||e.cssRules;return t?Dt(Array.from(t).map(ze).join("")):null}catch{return null}}function ze(e){var t=e.cssText;if(Ft(e))try{t=Ne(e.styleSheet)||t}catch{}return t}function Ft(e){return"styleSheet"in e}var Ge=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var r;if(!t)return-1;var n=(r=this.getMeta(t))===null||r===void 0?void 0:r.id;return n??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var r=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(o){return r.removeNodeFromMap(o)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,r){var n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)},e.prototype.replace=function(t,r){var n=this.getNode(t);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(r,o)}this.idNodeMap.set(t,r)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function At(){return new Ge}function xe(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,o=e.value,s=e.maskInputFn,l=o||"";return(t[r.toLowerCase()]||t[n])&&(s?l=s(l):l="*".repeat(l.length)),l}var Ve="__rrweb_original__";function _t(e){var t=e.getContext("2d");if(!t)return!0;for(var r=50,n=0;n<e.width;n+=r)for(var o=0;o<e.height;o+=r){var s=t.getImageData,l=Ve in s?s[Ve]:s,a=new Uint32Array(l.call(t,n,o,Math.min(r,e.width-n),Math.min(r,e.height-o)).data.buffer);if(a.some(function(i){return i!==0}))return!1}return!0}var Pt=1,Wt=new RegExp("[^a-z0-9-_:]"),ge=-2;function Ze(){return Pt++}function zt(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return Wt.test(t)?"div":t}function Gt(e){return e.cssRules?Array.from(e.cssRules).map(function(t){return t.cssText||""}).join(""):""}function Vt(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var ie,je,Zt=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,jt=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,Ut=/^(data:)([^,]*),(.*)/i;function Ce(e,t){return(e||"").replace(Zt,function(r,n,o,s,l,a){var i=o||l||a,c=n||s||"";if(!i)return r;if(!jt.test(i)||Ut.test(i))return"url(".concat(c).concat(i).concat(c,")");if(i[0]==="/")return"url(".concat(c).concat(Vt(t)+i).concat(c,")");var d=t.split("/"),u=i.split("/");d.pop();for(var h=0,m=u;h<m.length;h++){var p=m[h];p!=="."&&(p===".."?d.pop():d.push(p))}return"url(".concat(c).concat(d.join("/")).concat(c,")")})}var Ht=/^[^ \t\n\r\u000c]+/,Xt=/^[, \t\n\r\u000c]+/;function Bt(e,t){if(t.trim()==="")return t;var r=0;function n(c){var d,u=c.exec(t.substring(r));return u?(d=u[0],r+=d.length,d):""}for(var o=[];n(Xt),!(r>=t.length);){var s=n(Ht);if(s.slice(-1)===",")s=ke(e,s.substring(0,s.length-1)),o.push(s);else{var l="";s=ke(e,s);for(var a=!1;;){var i=t.charAt(r);if(i===""){o.push((s+l).trim());break}else if(a)i===")"&&(a=!1);else if(i===","){r+=1,o.push((s+l).trim());break}else i==="("&&(a=!0);l+=i,r+=1}}}return o.join(", ")}function ke(e,t){if(!t||t.trim()==="")return t;var r=e.createElement("a");return r.href=t,r.href}function Yt(e){return Boolean(e.tagName==="svg"||e.ownerSVGElement)}function De(){var e=document.createElement("a");return e.href="",e.href}function Ue(e,t,r,n){return r==="src"||r==="href"&&n&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n&&n[0]!=="#"||r==="background"&&n&&(t==="table"||t==="td"||t==="th")?ke(e,n):r==="srcset"&&n?Bt(e,n):r==="style"&&n?Ce(n,De()):t==="object"&&r==="data"&&n?ke(e,n):n}function $t(e,t,r){if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var o=e.classList[n];if(t.test(o))return!0}return r?e.matches(r):!1}function Me(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Me(e.parentNode,t,r):!1;for(var n=e.classList.length;n--;){var o=e.classList[n];if(t.test(o))return!0}return r?Me(e.parentNode,t,r):!1}function He(e,t,r){var n=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(n===null)return!1;if(typeof t=="string"){if(n.classList.contains(t)||n.closest(".".concat(t)))return!0}else if(Me(n,t,!0))return!0;return!!(r&&(n.matches(r)||n.closest(r)))}function Kt(e,t,r){var n=e.contentWindow;if(n){var o=!1,s;try{s=n.document.readyState}catch{return}if(s!=="complete"){var l=setTimeout(function(){o||(t(),o=!0)},r);e.addEventListener("load",function(){clearTimeout(l),o=!0,t()});return}var a="about:blank";if(n.location.href!==a||e.src===a||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Jt(e,t,r){var n=!1,o;try{o=e.sheet}catch{return}if(!o){var s=setTimeout(function(){n||(t(),n=!0)},r);e.addEventListener("load",function(){clearTimeout(s),n=!0,t()})}}function Qt(e,t){var r=t.doc,n=t.mirror,o=t.blockClass,s=t.blockSelector,l=t.maskTextClass,a=t.maskTextSelector,i=t.inlineStylesheet,c=t.maskInputOptions,d=c===void 0?{}:c,u=t.maskTextFn,h=t.maskInputFn,m=t.dataURLOptions,p=m===void 0?{}:m,v=t.inlineImages,g=t.recordCanvas,S=t.keepIframeSrcFn,y=t.newlyAddedElement,f=y===void 0?!1:y,w=qt(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:x.Document,childNodes:[],compatMode:e.compatMode}:{type:x.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:x.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:w};case e.ELEMENT_NODE:return tr(e,{doc:r,blockClass:o,blockSelector:s,inlineStylesheet:i,maskInputOptions:d,maskInputFn:h,dataURLOptions:p,inlineImages:v,recordCanvas:g,keepIframeSrcFn:S,newlyAddedElement:f,rootId:w});case e.TEXT_NODE:return er(e,{maskTextClass:l,maskTextSelector:a,maskTextFn:u,rootId:w});case e.CDATA_SECTION_NODE:return{type:x.CDATA,textContent:"",rootId:w};case e.COMMENT_NODE:return{type:x.Comment,textContent:e.textContent||"",rootId:w};default:return!1}}function qt(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function er(e,t){var r,n=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,l=t.rootId,a=e.parentNode&&e.parentNode.tagName,i=e.textContent,c=a==="STYLE"?!0:void 0,d=a==="SCRIPT"?!0:void 0;if(c&&i){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(i=Gt(e.parentNode.sheet))}catch(u){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u),e)}i=Ce(i,De())}return d&&(i="SCRIPT_PLACEHOLDER"),!c&&!d&&i&&He(e,n,o)&&(i=s?s(i):i.replace(/[\S]/g,"*")),{type:x.Text,textContent:i||"",isStyle:c,rootId:l}}function tr(e,t){for(var r=t.doc,n=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,l=t.maskInputOptions,a=l===void 0?{}:l,i=t.maskInputFn,c=t.dataURLOptions,d=c===void 0?{}:c,u=t.inlineImages,h=t.recordCanvas,m=t.keepIframeSrcFn,p=t.newlyAddedElement,v=p===void 0?!1:p,g=t.rootId,S=$t(e,n,o),y=zt(e),f={},w=e.attributes.length,F=0;F<w;F++){var P=e.attributes[F];f[P.name]=Ue(r,y,P.name,P.value)}if(y==="link"&&s){var D=Array.from(r.styleSheets).find(function(U){return U.href===e.href}),O=null;D&&(O=Ne(D)),O&&(delete f.rel,delete f.href,f._cssText=Ce(O,D.href))}if(y==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var O=Ne(e.sheet);O&&(f._cssText=Ce(O,De()))}if(y==="input"||y==="textarea"||y==="select"){var X=e.value,Z=e.checked;f.type!=="radio"&&f.type!=="checkbox"&&f.type!=="submit"&&f.type!=="button"&&X?f.value=xe({type:f.type,tagName:y,value:X,maskInputOptions:a,maskInputFn:i}):Z&&(f.checked=Z)}if(y==="option"&&(e.selected&&!a.select?f.selected=!0:delete f.selected),y==="canvas"&&h){if(e.__context==="2d")_t(e)||(f.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var B=e.toDataURL(d.type,d.quality),Y=document.createElement("canvas");Y.width=e.width,Y.height=e.height;var $=Y.toDataURL(d.type,d.quality);B!==$&&(f.rr_dataURL=B)}}if(y==="img"&&u){ie||(ie=r.createElement("canvas"),je=ie.getContext("2d"));var N=e,j=N.crossOrigin;N.crossOrigin="anonymous";var Q=function(){try{ie.width=N.naturalWidth,ie.height=N.naturalHeight,je.drawImage(N,0,0),f.rr_dataURL=ie.toDataURL(d.type,d.quality)}catch(U){console.warn("Cannot inline img src=".concat(N.currentSrc,"! Error: ").concat(U))}j?f.crossOrigin=j:N.removeAttribute("crossorigin")};N.complete&&N.naturalWidth!==0?Q():N.onload=Q}if((y==="audio"||y==="video")&&(f.rr_mediaState=e.paused?"paused":"played",f.rr_mediaCurrentTime=e.currentTime),v||(e.scrollLeft&&(f.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(f.rr_scrollTop=e.scrollTop)),S){var te=e.getBoundingClientRect(),ne=te.width,z=te.height;f={class:f.class,rr_width:"".concat(ne,"px"),rr_height:"".concat(z,"px")}}return y==="iframe"&&!m(f.src)&&(e.contentDocument||(f.rr_src=f.src),delete f.src),{type:x.Element,tagName:y,attributes:f,childNodes:[],isSVG:Yt(e)||void 0,needBlock:S,rootId:g}}function M(e){return e===void 0?"":e.toLowerCase()}function rr(e,t){return!!(t.comment&&e.type===x.Comment||e.type===x.Element&&(t.script&&(e.tagName==="script"||e.tagName==="link"&&e.attributes.rel==="preload"&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js"))||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(M(e.attributes.name).match(/^msapplication-tile(image|color)$/)||M(e.attributes.name)==="application-name"||M(e.attributes.rel)==="icon"||M(e.attributes.rel)==="apple-touch-icon"||M(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&M(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(M(e.attributes.property).match(/^(og|twitter|fb):/)||M(e.attributes.name).match(/^(og|twitter):/)||M(e.attributes.name)==="pinterest")||t.headMetaRobots&&(M(e.attributes.name)==="robots"||M(e.attributes.name)==="googlebot"||M(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(M(e.attributes.name)==="author"||M(e.attributes.name)==="generator"||M(e.attributes.name)==="framework"||M(e.attributes.name)==="publisher"||M(e.attributes.name)==="progid"||M(e.attributes.property).match(/^article:/)||M(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(M(e.attributes.name)==="google-site-verification"||M(e.attributes.name)==="yandex-verification"||M(e.attributes.name)==="csrf-token"||M(e.attributes.name)==="p:domain_verify"||M(e.attributes.name)==="verify-v1"||M(e.attributes.name)==="verification"||M(e.attributes.name)==="shopify-checkout-api-token"))))}function le(e,t){var r=t.doc,n=t.mirror,o=t.blockClass,s=t.blockSelector,l=t.maskTextClass,a=t.maskTextSelector,i=t.skipChild,c=i===void 0?!1:i,d=t.inlineStylesheet,u=d===void 0?!0:d,h=t.maskInputOptions,m=h===void 0?{}:h,p=t.maskTextFn,v=t.maskInputFn,g=t.slimDOMOptions,S=t.dataURLOptions,y=S===void 0?{}:S,f=t.inlineImages,w=f===void 0?!1:f,F=t.recordCanvas,P=F===void 0?!1:F,D=t.onSerialize,O=t.onIframeLoad,X=t.iframeLoadTimeout,Z=X===void 0?5e3:X,B=t.onStylesheetLoad,Y=t.stylesheetLoadTimeout,$=Y===void 0?5e3:Y,N=t.keepIframeSrcFn,j=N===void 0?function(){return!1}:N,Q=t.newlyAddedElement,te=Q===void 0?!1:Q,ne=t.preserveWhiteSpace,z=ne===void 0?!0:ne,U=Qt(e,{doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,inlineStylesheet:u,maskInputOptions:m,maskTextFn:p,maskInputFn:v,dataURLOptions:y,inlineImages:w,recordCanvas:P,keepIframeSrcFn:j,newlyAddedElement:te});if(!U)return console.warn(e,"not serialized"),null;var ae;n.hasNode(e)?ae=n.getId(e):rr(U,g)||!z&&U.type===x.Text&&!U.isStyle&&!U.textContent.replace(/^\s+|\s+$/gm,"").length?ae=ge:ae=Ze();var E=Object.assign(U,{id:ae});if(n.add(e,E),ae===ge)return null;D&&D(e);var q=!c;if(E.type===x.Element){q=q&&!E.needBlock,delete E.needBlock;var re=e.shadowRoot;re&&ye(re)&&(E.isShadowHost=!0)}if((E.type===x.Document||E.type===x.Element)&&q){g.headWhitespace&&E.type===x.Element&&E.tagName==="head"&&(z=!1);for(var me={doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:c,inlineStylesheet:u,maskInputOptions:m,maskTextFn:p,maskInputFn:v,slimDOMOptions:g,dataURLOptions:y,inlineImages:w,recordCanvas:P,preserveWhiteSpace:z,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:Z,onStylesheetLoad:B,stylesheetLoadTimeout:$,keepIframeSrcFn:j},b=0,G=Array.from(e.childNodes);b<G.length;b++){var K=G[b],R=le(K,me);R&&E.childNodes.push(R)}if(xt(e)&&e.shadowRoot)for(var ee=0,k=Array.from(e.shadowRoot.childNodes);ee<k.length;ee++){var K=k[ee],R=le(K,me);R&&(ye(e.shadowRoot)&&(R.isShadow=!0),E.childNodes.push(R))}}return e.parentNode&&fe(e.parentNode)&&ye(e.parentNode)&&(E.isShadow=!0),E.type===x.Element&&E.tagName==="iframe"&&Kt(e,function(){var H=e.contentDocument;if(H&&O){var Ie=le(H,{doc:H,mirror:n,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:m,maskTextFn:p,maskInputFn:v,slimDOMOptions:g,dataURLOptions:y,inlineImages:w,recordCanvas:P,preserveWhiteSpace:z,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:Z,onStylesheetLoad:B,stylesheetLoadTimeout:$,keepIframeSrcFn:j});Ie&&O(e,Ie)}},Z),E.type===x.Element&&E.tagName==="link"&&E.attributes.rel==="stylesheet"&&Jt(e,function(){if(B){var H=le(e,{doc:r,mirror:n,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:m,maskTextFn:p,maskInputFn:v,slimDOMOptions:g,dataURLOptions:y,inlineImages:w,recordCanvas:P,preserveWhiteSpace:z,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:Z,onStylesheetLoad:B,stylesheetLoadTimeout:$,keepIframeSrcFn:j});H&&B(e,H)}},$),E}function nr(e,t){var r=t||{},n=r.mirror,o=n===void 0?new Ge:n,s=r.blockClass,l=s===void 0?"rr-block":s,a=r.blockSelector,i=a===void 0?null:a,c=r.maskTextClass,d=c===void 0?"rr-mask":c,u=r.maskTextSelector,h=u===void 0?null:u,m=r.inlineStylesheet,p=m===void 0?!0:m,v=r.inlineImages,g=v===void 0?!1:v,S=r.recordCanvas,y=S===void 0?!1:S,f=r.maskAllInputs,w=f===void 0?!1:f,F=r.maskTextFn,P=r.maskInputFn,D=r.slimDOM,O=D===void 0?!1:D,X=r.dataURLOptions,Z=r.preserveWhiteSpace,B=r.onSerialize,Y=r.onIframeLoad,$=r.iframeLoadTimeout,N=r.onStylesheetLoad,j=r.stylesheetLoadTimeout,Q=r.keepIframeSrcFn,te=Q===void 0?function(){return!1}:Q,ne=w===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:w===!1?{password:!0}:w,z=O===!0||O==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:O==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:O===!1?{}:O;return le(e,{doc:e,mirror:o,blockClass:l,blockSelector:i,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:ne,maskTextFn:F,maskInputFn:P,slimDOMOptions:z,dataURLOptions:X,inlineImages:g,recordCanvas:y,preserveWhiteSpace:Z,onSerialize:B,onIframeLoad:Y,iframeLoadTimeout:$,onStylesheetLoad:N,stylesheetLoadTimeout:j,keepIframeSrcFn:te,newlyAddedElement:!1})}function A(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const ce=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let Ve={map:{},getId(){return console.error(le),-1},getNode(){return console.error(le),null},removeNodeFromMap(){console.error(le)},has(){return console.error(le),!1},reset(){console.error(le)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Ve=new Proxy(Ve,{get(e,t,n){return t==="map"&&console.error(le),Reflect.get(e,t,n)}}));function Se(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();!o&&n.leading===!1&&(o=i);const l=t-(i-o),a=this;l<=0||l>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(a,s)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{o=n.leading===!1?0:Date.now(),r=null,e.apply(a,s)},l))}}function Me(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(i){setTimeout(()=>{n.set.call(this,i)},0),s&&s.set&&s.set.call(this,i)}}),()=>Me(e,t,s||{},!0)}function ce(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}function Ze(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function je(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function W(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if(typeof t=="string"){if(o.classList.contains(t)||r&&o.closest("."+t)!==null)return!0}else if(Ie(o,t,r))return!0;return!!(n&&(e.matches(n)||r&&o.closest(n)!==null))}function qt(e,t){return t.getId(e)!==-1}function xe(e,t){return t.getId(e)===ve}function Ue(e,t){if(fe(e))return!1;const n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Ue(e.parentNode,t):!0:!0}function Xe(e){return Boolean(e.changedTouches)}function en(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let n=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function He(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function Be(e,t){return Boolean(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Ye(e){return Boolean(e?.shadowRoot)}class tn{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var n;return(n=this.styleIDMap.get(t))!=null?n:-1}has(t){return this.styleIDMap.has(t)}add(t,n){if(this.has(t))return this.getId(t);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(t,r),this.idStyleMap.set(r,t),r}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}}var M=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(M||{}),D=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(D||{}),Ne=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(Ne||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{}),de=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(de||{}),nn=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(nn||{});function Ke(e){return"__ln"in e}class rn{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<t;r++)n=n?.next||null;return n}addNode(t){const n={value:t,previous:null,next:null};if(t.__ln=n,t.previousSibling&&Ke(t.previousSibling)){const r=t.previousSibling.__ln.next;n.next=r,n.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(t.nextSibling&&Ke(t.nextSibling)&&t.nextSibling.__ln.previous){const r=t.nextSibling.__ln.previous;n.previous=r,n.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;this.length++}removeNode(t){const n=t.__ln;!this.head||(n.previous?(n.previous.next=n.next,n.next&&(n.next.previous=n.previous)):(this.head=n.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const $e=(e,t)=>`${e}@${t}`;class on{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{var t;if(this.frozen||this.locked)return;const n=[],r=new rn,o=a=>{let c=a,u=ve;for(;u===ve;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},s=a=>{var c,u,d,h,m;const p=a.getRootNode?(c=a.getRootNode())==null?void 0:c.host:null;let y=p;for(;(d=(u=y?.getRootNode)==null?void 0:u.call(y))!=null&&d.host;)y=((m=(h=y?.getRootNode)==null?void 0:h.call(y))==null?void 0:m.host)||null;const S=!this.doc.contains(a)&&(!y||!this.doc.contains(y));if(!a.parentNode||S)return;const v=fe(a.parentNode)?this.mirror.getId(p):this.mirror.getId(a.parentNode),g=o(a);if(v===-1||g===-1)return r.addNode(a);const f=ie(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:C=>{He(C,this.mirror)&&this.iframeManager.addIframe(C),Be(C,this.mirror)&&this.stylesheetManager.trackLinkElement(C),Ye(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,document)},onIframeLoad:(C,R)=>{this.iframeManager.attachIframe(C,R,this.mirror),this.shadowDomManager.observeAttachShadow(C)},onStylesheetLoad:(C,R)=>{this.stylesheetManager.attachLinkElement(C,R)}});f&&n.push({parentId:v,nextId:g,node:f})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of Array.from(this.movedSet.values()))Je(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||s(a);for(const a of Array.from(this.addedSet.values()))!qe(this.droppedSet,a)&&!Je(this.removes,a,this.mirror)||qe(this.movedSet,a)?s(a):this.droppedSet.add(a);let i=null;for(;r.length;){let a=null;if(i){const c=this.mirror.getId(i.value.parentNode),u=o(i.value);c!==-1&&u!==-1&&(a=i)}if(!a)for(let c=r.length-1;c>=0;c--){const u=r.get(c);if(u){const d=this.mirror.getId(u.value.parentNode);if(o(u.value)===-1)continue;if(d!==-1){a=u;break}else{const h=u.value,m=h.getRootNode?(t=h.getRootNode())==null?void 0:t.host:null;if(this.mirror.getId(m)!==-1){a=u;break}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}i=a.previous,r.removeNode(a.value),s(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>({id:this.mirror.getId(a.node),attributes:a.attributes})).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:n};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=t=>{if(!xe(t.target,this.mirror))switch(t.type){case"characterData":{const n=t.target.textContent;!W(t.target,this.blockClass,this.blockSelector,!1)&&n!==t.oldValue&&this.texts.push({value:Ge(t.target,this.maskTextClass,this.maskTextSelector)&&n?this.maskTextFn?this.maskTextFn(n):n.replace(/[\S]/g,"*"):n,node:t.target});break}case"attributes":{const n=t.target;let r=t.target.getAttribute(t.attributeName);if(t.attributeName==="value"&&(r=Ee({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:r,maskInputFn:this.maskInputFn})),W(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue)return;let o=this.attributes.find(s=>s.node===t.target);if(n.tagName==="IFRAME"&&t.attributeName==="src"&&!this.keepIframeSrcFn(r))if(!n.contentDocument)t.attributeName="rr_src";else return;if(o||(o={node:t.target,attributes:{}},this.attributes.push(o)),t.attributeName==="style"){const s=this.doc.createElement("span");t.oldValue&&s.setAttribute("style",t.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const i=o.attributes.style;for(const l of Array.from(n.style)){const a=n.style.getPropertyValue(l),c=n.style.getPropertyPriority(l);(a!==s.style.getPropertyValue(l)||c!==s.style.getPropertyPriority(l))&&(c===""?i[l]=a:i[l]=[a,c])}for(const l of Array.from(s.style))n.style.getPropertyValue(l)===""&&(i[l]=!1)}else o.attributes[t.attributeName]=ze(this.doc,n.tagName,t.attributeName,r);break}case"childList":{if(W(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(n=>this.genAdds(n,t.target)),t.removedNodes.forEach(n=>{const r=this.mirror.getId(n),o=fe(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);W(t.target,this.blockClass,this.blockSelector,!1)||xe(n,this.mirror)||!qt(n,this.mirror)||(this.addedSet.has(n)?(De(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(t.target)&&r===-1||Ue(t.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[$e(r,o)]?De(this.movedSet,n):this.removes.push({parentId:o,id:r,isShadow:fe(t.target)&&ye(t.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(t,n)=>{if(this.mirror.hasNode(t)){if(xe(t,this.mirror))return;this.movedSet.add(t);let r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[$e(this.mirror.getId(t),r)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);W(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(r=>this.genAdds(r))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(n=>{this[n]=t[n]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function De(e,t){e.delete(t),t.childNodes.forEach(n=>De(e,n))}function Je(e,t,n){return e.length===0?!1:Qe(e,t,n)}function Qe(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return e.some(s=>s.id===o)?!0:Qe(e,r,n)}function qe(e,t){return e.size===0?!1:et(e,t)}function et(e,t){const{parentNode:n}=t;return n?e.has(n)?!0:et(e,n):!1}var an=Object.defineProperty,sn=Object.defineProperties,ln=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,cn=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable,nt=(e,t,n)=>t in e?an(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rt=(e,t)=>{for(var n in t||(t={}))cn.call(t,n)&&nt(e,n,t[n]);if(tt)for(var n of tt(t))un.call(t,n)&&nt(e,n,t[n]);return e},dn=(e,t)=>sn(e,ln(t));const ae=[],ot=typeof CSSGroupingRule<"u",at=typeof CSSMediaRule<"u",st=typeof CSSSupportsRule<"u",it=typeof CSSConditionRule<"u";function ge(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function lt(e,t){var n,r;const o=new on;ae.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=(r=(n=window?.Zone)==null?void 0:n.__symbol__)==null?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const l=new s(o.processMutations.bind(o));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function pn({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};const o=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let i=[],l;const a=Se(d=>{const h=Date.now()-l;e(i.map(m=>(m.timeOffset-=h,m)),d),i=[],l=null},s),c=Se(d=>{const h=ge(d),{clientX:m,clientY:p}=Xe(d)?d.changedTouches[0]:d;l||(l=Date.now()),i.push({x:m,y:p,id:r.getId(h),timeOffset:Date.now()-l}),a(typeof DragEvent<"u"&&d instanceof DragEvent?D.Drag:d instanceof MouseEvent?D.MouseMove:D.TouchMove)},o,{trailing:!1}),u=[_("mousemove",c,n),_("touchmove",c,n),_("drag",c,n)];return()=>{u.forEach(d=>d())}}function hn({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const i=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,l=[],a=c=>u=>{const d=ge(u);if(W(d,r,o,!0))return;const h=Xe(u)?u.changedTouches[0]:u;if(!h)return;const m=n.getId(d),{clientX:p,clientY:y}=h;e({type:Ne[c],id:m,x:p,y})};return Object.keys(Ne).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&i[c]!==!1).forEach(c=>{const u=c.toLowerCase(),d=a(c);l.push(_(u,d,t))}),()=>{l.forEach(c=>c())}}function ct({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){const i=Se(l=>{const a=ge(l);if(!a||W(a,r,o,!0))return;const c=n.getId(a);if(a===t){const u=t.scrollingElement||t.documentElement;e({id:c,x:u.scrollLeft,y:u.scrollTop})}else e({id:c,x:a.scrollLeft,y:a.scrollTop})},s.scroll||100);return _("scroll",i,t)}function mn({viewportResizeCb:e}){let t=-1,n=-1;const r=Se(()=>{const o=Ze(),s=je();(t!==o||n!==s)&&(e({width:Number(s),height:Number(o)}),t=o,n=s)},200);return _("resize",r,window)}function ut(e,t){const n=rt({},e);return t||delete n.userTriggered,n}const fn=["INPUT","TEXTAREA","SELECT"],dt=new WeakMap;function yn({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:l,sampling:a,userTriggeredOnInput:c}){function u(S){let v=ge(S);const g=S.isTrusted;if(v&&v.tagName==="OPTION"&&(v=v.parentElement),!v||!v.tagName||fn.indexOf(v.tagName)<0||W(v,r,o,!0))return;const f=v.type;if(v.classList.contains(s))return;let C=v.value,R=!1;f==="radio"||f==="checkbox"?R=v.checked:(i[v.tagName.toLowerCase()]||i[f])&&(C=Ee({maskInputOptions:i,tagName:v.tagName,type:f,value:C,maskInputFn:l})),d(v,ut({text:C,isChecked:R,userTriggered:g},c));const z=v.name;f==="radio"&&z&&R&&t.querySelectorAll(`input[type="radio"][name="${z}"]`).forEach(T=>{T!==v&&d(T,ut({text:T.value,isChecked:!R,userTriggered:!1},c))})}function d(S,v){const g=dt.get(S);if(!g||g.text!==v.text||g.isChecked!==v.isChecked){dt.set(S,v);const f=n.getId(S);e(dn(rt({},v),{id:f}))}}const h=(a.input==="last"?["change"]:["input","change"]).map(S=>_(S,u,t)),m=t.defaultView;if(!m)return()=>{h.forEach(S=>S())};const p=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),y=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&h.push(...y.map(S=>Me(S[0],S[1],{set(){u({target:this})}},!1,m))),()=>{h.forEach(S=>S())}}function we(e){const t=[];function n(r,o){if(ot&&r.parentRule instanceof CSSGroupingRule||at&&r.parentRule instanceof CSSMediaRule||st&&r.parentRule instanceof CSSSupportsRule||it&&r.parentRule instanceof CSSConditionRule){const s=Array.from(r.parentRule.cssRules).indexOf(r);o.unshift(s)}else if(r.parentStyleSheet){const s=Array.from(r.parentStyleSheet.cssRules).indexOf(r);o.unshift(s)}return o}return n(e,t)}function oe(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function vn({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(u,d){const{id:h,styleId:m}=oe(this,t,n.styleMirror);return(h&&h!==-1||m&&m!==-1)&&e({id:h,styleId:m,adds:[{rule:u,index:d}]}),o.apply(this,[u,d])};const s=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=function(u){const{id:d,styleId:h}=oe(this,t,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&e({id:d,styleId:h,removes:[{index:u}]}),s.apply(this,[u])};let i;r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(u){const{id:d,styleId:h}=oe(this,t,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&e({id:d,styleId:h,replace:u}),i.apply(this,[u])});let l;r.CSSStyleSheet.prototype.replaceSync&&(l=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(u){const{id:d,styleId:h}=oe(this,t,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&e({id:d,styleId:h,replaceSync:u}),l.apply(this,[u])});const a={};ot?a.CSSGroupingRule=r.CSSGroupingRule:(at&&(a.CSSMediaRule=r.CSSMediaRule),it&&(a.CSSConditionRule=r.CSSConditionRule),st&&(a.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(a).forEach(([u,d])=>{c[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=function(h,m){const{id:p,styleId:y}=oe(this.parentStyleSheet,t,n.styleMirror);return(p&&p!==-1||y&&y!==-1)&&e({id:p,styleId:y,adds:[{rule:h,index:[...we(this),m||0]}]}),c[u].insertRule.apply(this,[h,m])},d.prototype.deleteRule=function(h){const{id:m,styleId:p}=oe(this.parentStyleSheet,t,n.styleMirror);return(m&&m!==-1||p&&p!==-1)&&e({id:m,styleId:p,removes:[{index:[...we(this),h]}]}),c[u].deleteRule.apply(this,[h])}}),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),l&&(r.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([u,d])=>{d.prototype.insertRule=c[u].insertRule,d.prototype.deleteRule=c[u].deleteRule})}}function pt({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;n.nodeName==="#document"?i=e.getId(n):i=e.getId(n.host);const l=n.nodeName==="#document"?(r=n.defaultView)==null?void 0:r.Document:(s=(o=n.ownerDocument)==null?void 0:o.defaultView)==null?void 0:s.ShadowRoot,a=Object.getOwnPropertyDescriptor(l?.prototype,"adoptedStyleSheets");return i===null||i===-1||!l||!a?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var c;return(c=a.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=a.set)==null?void 0:u.call(this,c);if(i!==null&&i!==-1)try{t.adoptStyleSheets(c,i)}catch{}return d}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})}function Sn({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(l,a,c){var u;if(n.has(l))return s.apply(this,[l,a,c]);const{id:d,styleId:h}=oe((u=this.parentRule)==null?void 0:u.parentStyleSheet,t,r.styleMirror);return(d&&d!==-1||h&&h!==-1)&&e({id:d,styleId:h,set:{property:l,value:a,priority:c},index:we(this.parentRule)}),s.apply(this,[l,a,c])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(l){var a;if(n.has(l))return i.apply(this,[l]);const{id:c,styleId:u}=oe((a=this.parentRule)==null?void 0:a.parentStyleSheet,t,r.styleMirror);return(c&&c!==-1||u&&u!==-1)&&e({id:c,styleId:u,remove:{property:l},index:we(this.parentRule)}),i.apply(this,[l])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}function gn({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=l=>Se(a=>{const c=ge(a);if(!c||W(c,t,n,!0))return;const{currentTime:u,volume:d,muted:h,playbackRate:m}=c;e({type:l,id:r.getId(c),currentTime:u,volume:d,muted:h,playbackRate:m})},o.media||500),i=[_("play",s(de.Play)),_("pause",s(de.Pause)),_("seeked",s(de.Seeked)),_("volumechange",s(de.VolumeChange)),_("ratechange",s(de.RateChange))];return()=>{i.forEach(l=>l())}}function bn({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(l,a,c){const u=new s(l,a,c);return o.set(u,{family:l,buffer:typeof a!="string",descriptors:c,fontSource:typeof a=="string"?a:JSON.stringify(Array.from(new Uint8Array(a)))}),u};const i=ce(t.fonts,"add",function(l){return function(a){return setTimeout(()=>{const c=o.get(a);c&&(e(c),o.delete(a))},0),l.apply(this,[a])}});return r.push(()=>{n.FontFace=s}),r.push(i),()=>{r.forEach(l=>l())}}function Cn(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const l=()=>{const a=t.getSelection();if(!a||i&&a?.isCollapsed)return;i=a.isCollapsed||!1;const c=[],u=a.rangeCount||0;for(let d=0;d<u;d++){const h=a.getRangeAt(d),{startContainer:m,startOffset:p,endContainer:y,endOffset:S}=h;W(m,r,o,!0)||W(y,r,o,!0)||c.push({start:n.getId(m),startOffset:p,end:n.getId(y),endOffset:S})}s({ranges:c})};return l(),_("selectionchange",l)}function kn(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:l,mediaInteractionCb:a,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:m}=e;e.mutationCb=(...p)=>{t.mutation&&t.mutation(...p),n(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),r(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),o(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),s(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),i(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),l(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),a(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),c(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),u(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),d(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),h(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),m(...p)}}function In(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};kn(e,t);const r=lt(e,e.doc),o=pn(e),s=hn(e),i=ct(e),l=mn(e),a=yn(e),c=gn(e),u=vn(e,{win:n}),d=pt(e,e.doc),h=Sn(e,{win:n}),m=e.collectFonts?bn(e):()=>{},p=Cn(e),y=[];for(const S of e.plugins)y.push(S.observer(S.callback,n,S.options));return()=>{ae.forEach(S=>S.reset()),r.disconnect(),o(),s(),i(),l(),a(),c(),u(),d(),h(),m(),p(),y.forEach(S=>S())}}class Mn{constructor(t){this.iframes=new WeakMap,this.mutationCb=t.mutationCb,this.stylesheetManager=t.stylesheetManager}addIframe(t){this.iframes.set(t,!0)}addLoadListener(t){this.loadListener=t}attachIframe(t,n,r){var o;this.mutationCb({adds:[{parentId:r.getId(t),nextId:null,node:n}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(o=this.loadListener)==null||o.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,r.getId(t.contentDocument))}}var wn=Object.defineProperty,On=Object.defineProperties,Ln=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,En=Object.prototype.propertyIsEnumerable,mt=(e,t,n)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ft=(e,t)=>{for(var n in t||(t={}))Tn.call(t,n)&&mt(e,n,t[n]);if(ht)for(var n of ht(t))En.call(t,n)&&mt(e,n,t[n]);return e},yt=(e,t)=>On(e,Ln(t));class Rn{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const n=this;this.restorePatches.push(ce(Element.prototype,"attachShadow",function(r){return function(o){const s=r.call(this,o);return this.shadowRoot&&n.addShadowRoot(this.shadowRoot,this.ownerDocument),s}}))}addShadowRoot(t,n){!ye(t)||this.shadowDoms.has(t)||(this.shadowDoms.add(t),lt(yt(ft({},this.bypassOptions),{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),ct(yt(ft({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),pt({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0))}observeAttachShadow(t){if(t.contentWindow){const n=this;this.restorePatches.push(ce(t.contentWindow.HTMLElement.prototype,"attachShadow",function(r){return function(o){const s=r.call(this,o);return this.shadowRoot&&n.addShadowRoot(this.shadowRoot,t.contentDocument),s}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xn=typeof Uint8Array>"u"?[]:new Uint8Array(256),Oe=0;Oe<pe.length;Oe++)xn[pe.charCodeAt(Oe)]=Oe;var Nn=function(e){var t=new Uint8Array(e),n,r=t.length,o="";for(n=0;n<r;n+=3)o+=pe[t[n]>>2],o+=pe[(t[n]&3)<<4|t[n+1]>>4],o+=pe[(t[n+1]&15)<<2|t[n+2]>>6],o+=pe[t[n+2]&63];return r%3===2?o=o.substring(0,o.length-1)+"=":r%3===1&&(o=o.substring(0,o.length-2)+"=="),o};const vt=new Map;function Dn(e,t){let n=vt.get(e);return n||(n=new Map,vt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}const St=(e,t,n)=>{if(!e||!(bt(e,t)||typeof e=="object"))return;const r=e.constructor.name,o=Dn(n,r);let s=o.indexOf(e);return s===-1&&(s=o.length,o.push(e)),s};function Le(e,t,n){if(e instanceof Array)return e.map(r=>Le(r,t,n));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const r=e.constructor.name,o=Nn(e);return{rr_type:r,base64:o}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Le(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const r=e.constructor.name,{src:o}=e;return{rr_type:r,src:o}}else if(e instanceof HTMLCanvasElement){const r="HTMLImageElement",o=e.toDataURL();return{rr_type:r,src:o}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Le(e.data,t,n),e.width,e.height]};if(bt(e,t)||typeof e=="object"){const r=e.constructor.name,o=St(e,t,n);return{rr_type:r,index:o}}}}return e}const gt=(e,t,n)=>[...e].map(r=>Le(r,t,n)),bt=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(r=>typeof t[r]=="function");return Boolean(n.find(r=>e instanceof t[r]))};function Fn(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if(typeof t.CanvasRenderingContext2D.prototype[i]!="function")continue;const l=ce(t.CanvasRenderingContext2D.prototype,i,function(a){return function(...c){return W(this.canvas,n,r,!0)||setTimeout(()=>{const u=gt([...c],t,this);e(this.canvas,{type:ue["2D"],property:i,args:u})},0),a.apply(this,c)}});o.push(l)}catch{const a=Me(t.CanvasRenderingContext2D.prototype,i,{set(c){e(this.canvas,{type:ue["2D"],property:i,args:[c],setter:!0})}});o.push(a)}return()=>{o.forEach(i=>i())}}function Ct(e,t,n){const r=[];try{const o=ce(e.HTMLCanvasElement.prototype,"getContext",function(s){return function(i,...l){return W(this,t,n,!0)||"__context"in this||(this.__context=i),s.apply(this,[i,...l])}});r.push(o)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach(o=>o())}}function kt(e,t,n,r,o,s,i){const l=[],a=Object.getOwnPropertyNames(e);for(const c of a)try{if(typeof e[c]!="function")continue;const u=ce(e,c,function(d){return function(...h){const m=d.apply(this,h);if(St(m,i,e),!W(this.canvas,r,o,!0)){const p=gt([...h],i,e),y={type:t,property:c,args:p};n(this.canvas,y)}return m}});l.push(u)}catch{const d=Me(e,c,{set(h){n(this.canvas,{type:t,property:c,args:[h],setter:!0})}});l.push(d)}return l}function An(e,t,n,r,o){const s=[];return s.push(...kt(t.WebGLRenderingContext.prototype,ue.WebGL,e,n,r,o,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...kt(t.WebGL2RenderingContext.prototype,ue.WebGL2,e,n,r,o,t)),()=>{s.forEach(i=>i())}}function Pn(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function _n(e,t,n){var r=t===void 0?null:t,o=n===void 0?!1:n,s=Pn(e,o),i=s.indexOf(`
`,10)+1,l=s.substring(i)+(r?"//# sourceMappingURL="+r:""),a=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(a)}function Wn(e,t,n){var r;return function(s){return r=r||_n(e,t,n),new Worker(r,s)}}var zn=Wn("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Zm9yKHZhciByPSJBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OSsvIixwPXR5cGVvZiBVaW50OEFycmF5PiJ1Ij9bXTpuZXcgVWludDhBcnJheSgyNTYpLGY9MDtmPHIubGVuZ3RoO2YrKylwW3IuY2hhckNvZGVBdChmKV09Zjt2YXIgdT1mdW5jdGlvbihzKXt2YXIgZT1uZXcgVWludDhBcnJheShzKSxuLGE9ZS5sZW5ndGgsdD0iIjtmb3Iobj0wO248YTtuKz0zKXQrPXJbZVtuXT4+Ml0sdCs9clsoZVtuXSYzKTw8NHxlW24rMV0+PjRdLHQrPXJbKGVbbisxXSYxNSk8PDJ8ZVtuKzJdPj42XSx0Kz1yW2VbbisyXSY2M107cmV0dXJuIGElMz09PTI/dD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTEpKyI9IjphJTM9PT0xJiYodD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTIpKyI9PSIpLHR9O2NvbnN0IGM9bmV3IE1hcCxsPW5ldyBNYXA7YXN5bmMgZnVuY3Rpb24gdihzLGUsbil7Y29uc3QgYT1gJHtzfS0ke2V9YDtpZigiT2Zmc2NyZWVuQ2FudmFzImluIGdsb2JhbFRoaXMpe2lmKGwuaGFzKGEpKXJldHVybiBsLmdldChhKTtjb25zdCB0PW5ldyBPZmZzY3JlZW5DYW52YXMocyxlKTt0LmdldENvbnRleHQoIjJkIik7Y29uc3QgZz1hd2FpdChhd2FpdCB0LmNvbnZlcnRUb0Jsb2IobikpLmFycmF5QnVmZmVyKCksZD11KGcpO3JldHVybiBsLnNldChhLGQpLGR9ZWxzZSByZXR1cm4iIn1jb25zdCBpPXNlbGY7aS5vbm1lc3NhZ2U9YXN5bmMgZnVuY3Rpb24ocyl7aWYoIk9mZnNjcmVlbkNhbnZhcyJpbiBnbG9iYWxUaGlzKXtjb25zdHtpZDplLGJpdG1hcDpuLHdpZHRoOmEsaGVpZ2h0OnQsZGF0YVVSTE9wdGlvbnM6Z309cy5kYXRhLGQ9dihhLHQsZyksaD1uZXcgT2Zmc2NyZWVuQ2FudmFzKGEsdCk7aC5nZXRDb250ZXh0KCIyZCIpLmRyYXdJbWFnZShuLDAsMCksbi5jbG9zZSgpO2NvbnN0IHc9YXdhaXQgaC5jb252ZXJ0VG9CbG9iKGcpLHk9dy50eXBlLGI9YXdhaXQgdy5hcnJheUJ1ZmZlcigpLG89dShiKTtpZighYy5oYXMoZSkmJmF3YWl0IGQ9PT1vKXJldHVybiBjLnNldChlLG8pLGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpZihjLmdldChlKT09PW8pcmV0dXJuIGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpLnBvc3RNZXNzYWdlKHtpZDplLHR5cGU6eSxiYXNlNjQ6byx3aWR0aDphLGhlaWdodDp0fSksYy5zZXQoZSxvKX1lbHNlIHJldHVybiBpLnBvc3RNZXNzYWdlKHtpZDpzLmRhdGEuaWR9KX19KSgpOwoK",null,!1),It=Object.getOwnPropertySymbols,Gn=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable,Zn=(e,t)=>{var n={};for(var r in e)Gn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&It)for(var r of It(e))t.indexOf(r)<0&&Vn.call(e,r)&&(n[r]=e[r]);return n},jn=(e,t,n)=>new Promise((r,o)=>{var s=a=>{try{l(n.next(a))}catch(c){o(c)}},i=a=>{try{l(n.throw(a))}catch(c){o(c)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(s,i);l((n=n.apply(e,t)).next())});class Un{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,c)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(c)};const{sampling:n="all",win:r,blockClass:o,blockSelector:s,recordCanvas:i,dataURLOptions:l}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,i&&n==="all"&&this.initCanvasMutationObserver(r,o,s),i&&typeof n=="number"&&this.initCanvasFPSObserver(n,r,o,s,{dataURLOptions:l})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,n,r,o,s){const i=Ct(n,r,o),l=new Map,a=new zn;a.onmessage=p=>{const{id:y}=p.data;if(l.set(y,!1),!("base64"in p.data))return;const{base64:S,type:v,width:g,height:f}=p.data;this.mutationCb({id:y,type:ue["2D"],commands:[{property:"clearRect",args:[0,0,g,f]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:S}],type:v}]},0,0]}]})};const c=1e3/t;let u=0,d;const h=()=>{const p=[];return n.document.querySelectorAll("canvas").forEach(y=>{W(y,r,o,!0)||p.push(y)}),p},m=p=>{if(u&&p-u<c){d=requestAnimationFrame(m);return}u=p,h().forEach(y=>jn(this,null,function*(){var S;const v=this.mirror.getId(y);if(l.get(v))return;if(l.set(v,!0),["webgl","webgl2"].includes(y.__context)){const f=y.getContext(y.__context);((S=f?.getContextAttributes())==null?void 0:S.preserveDrawingBuffer)===!1&&f?.clear(f.COLOR_BUFFER_BIT)}const g=yield createImageBitmap(y);a.postMessage({id:v,bitmap:g,width:y.width,height:y.height,dataURLOptions:s.dataURLOptions},[g])})),d=requestAnimationFrame(m)};d=requestAnimationFrame(m),this.resetObservers=()=>{i(),cancelAnimationFrame(d)}}initCanvasMutationObserver(t,n,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Ct(t,n,r),s=Fn(this.processMutation.bind(this),t,n,r),i=An(this.processMutation.bind(this),t,n,r,this.mirror);this.resetObservers=()=>{o(),s(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=n=>{this.rafStamps.latestId=n,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,n)=>{const r=this.mirror.getId(n);this.flushPendingCanvasMutationFor(n,r)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,n){if(this.frozen||this.locked)return;const r=this.pendingCanvasMutations.get(t);if(!r||n===-1)return;const o=r.map(i=>Zn(i,["type"])),{type:s}=r[0];this.mutationCb({id:n,type:s,commands:o}),this.pendingCanvasMutations.delete(t)}}class Xn{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new tn,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,n){"_cssText"in n.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:n.id,attributes:n.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,n){if(t.length===0)return;const r={id:n,styleIds:[]},o=[];for(const s of t){let i;if(this.styleMirror.has(s))i=this.styleMirror.getId(s);else{i=this.styleMirror.add(s);const l=Array.from(s.rules||CSSRule);o.push({styleId:i,rules:l.map((a,c)=>({rule:Ae(a),index:c}))})}r.styleIds.push(i)}o.length>0&&(r.styles=o),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}var Hn=Object.defineProperty,Bn=Object.defineProperties,Yn=Object.getOwnPropertyDescriptors,Mt=Object.getOwnPropertySymbols,Kn=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable,wt=(e,t,n)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))Kn.call(t,n)&&wt(e,n,t[n]);if(Mt)for(var n of Mt(t))$n.call(t,n)&&wt(e,n,t[n]);return e},Jn=(e,t)=>Bn(e,Yn(t));function E(e){return Jn(V({},e),{timestamp:Date.now()})}let O,he,Fe;const H=Et();function be(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:l="rr-mask",maskTextSelector:a=null,inlineStylesheet:c=!0,maskAllInputs:u,maskInputOptions:d,slimDOMOptions:h,maskInputFn:m,maskTextFn:p,hooks:y,packFn:S,sampling:v={},dataURLOptions:g={},mousemoveWait:f,recordCanvas:C=!1,userTriggeredOnInput:R=!1,collectFonts:z=!1,inlineImages:T=!1,plugins:w,keepIframeSrcFn:B=()=>!1,ignoreCSSAttributes:Y=new Set([])}=e;if(!t)throw new Error("emit function is required");f!==void 0&&v.mousemove===void 0&&(v.mousemove=f),H.reset();const G=u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:d!==void 0?d:{password:!0},X=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};en();let K,x=0;for(const b of w||[])b.getMirror&&b.getMirror(H);const $=b=>{for(const j of w||[])j.eventProcessor&&(b=j.eventProcessor(b));return S&&(b=S(b)),b};O=(b,j)=>{var q;if(((q=ae[0])==null?void 0:q.isFrozen())&&b.type!==M.FullSnapshot&&!(b.type===M.IncrementalSnapshot&&b.data.source===D.Mutation)&&ae.forEach(P=>P.unfreeze()),t($(b),j),b.type===M.FullSnapshot)K=b,x=0;else if(b.type===M.IncrementalSnapshot){if(b.data.source===D.Mutation&&b.data.isAttachIframe)return;x++;const P=r&&x>=r,ee=n&&b.timestamp-K.timestamp>n;(P||ee)&&he(!0)}};const Z=b=>{O(E({type:M.IncrementalSnapshot,data:V({source:D.Mutation},b)}))},ne=b=>O(E({type:M.IncrementalSnapshot,data:V({source:D.Scroll},b)})),re=b=>O(E({type:M.IncrementalSnapshot,data:V({source:D.CanvasMutation},b)})),J=b=>O(E({type:M.IncrementalSnapshot,data:V({source:D.AdoptedStyleSheet},b)})),F=new Xn({mutationCb:Z,adoptedStyleSheetCb:J}),Q=new Mn({mutationCb:Z,stylesheetManager:F});Fe=new Un({recordCanvas:C,mutationCb:re,win:window,blockClass:o,blockSelector:s,mirror:H,sampling:v.canvas,dataURLOptions:g});const L=new Rn({mutationCb:Z,scrollCb:ne,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,inlineStylesheet:c,maskInputOptions:G,dataURLOptions:g,maskTextFn:p,maskInputFn:m,recordCanvas:C,inlineImages:T,sampling:v,slimDOMOptions:X,iframeManager:Q,stylesheetManager:F,canvasManager:Fe,keepIframeSrcFn:B},mirror:H});he=(b=!1)=>{var j,q,P,ee,k,U;O(E({type:M.Meta,data:{href:window.location.href,width:je(),height:Ze()}}),b),F.reset(),ae.forEach(A=>A.lock());const me=Qt(document,{mirror:H,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,inlineStylesheet:c,maskAllInputs:G,maskTextFn:p,slimDOM:X,dataURLOptions:g,recordCanvas:C,inlineImages:T,onSerialize:A=>{He(A,H)&&Q.addIframe(A),Be(A,H)&&F.trackLinkElement(A),Ye(A)&&L.addShadowRoot(A.shadowRoot,document)},onIframeLoad:(A,te)=>{Q.attachIframe(A,te,H),L.observeAttachShadow(A)},onStylesheetLoad:(A,te)=>{F.attachLinkElement(A,te)},keepIframeSrcFn:B});if(!me)return console.warn("Failed to snapshot the document");O(E({type:M.FullSnapshot,data:{node:me,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:document?.documentElement.scrollLeft||((q=(j=document?.body)==null?void 0:j.parentElement)==null?void 0:q.scrollLeft)||((P=document?.body)==null?void 0:P.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:document?.documentElement.scrollTop||((k=(ee=document?.body)==null?void 0:ee.parentElement)==null?void 0:k.scrollTop)||((U=document?.body)==null?void 0:U.scrollTop)||0}}})),ae.forEach(A=>A.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&F.adoptStyleSheets(document.adoptedStyleSheets,H.getId(document))};try{const b=[];b.push(_("DOMContentLoaded",()=>{O(E({type:M.DomContentLoaded,data:{}}))}));const j=P=>{var ee;return In({mutationCb:Z,mousemoveCb:(k,U)=>O(E({type:M.IncrementalSnapshot,data:{source:U,positions:k}})),mouseInteractionCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.MouseInteraction},k)})),scrollCb:ne,viewportResizeCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.ViewportResize},k)})),inputCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.Input},k)})),mediaInteractionCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.MediaInteraction},k)})),styleSheetRuleCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.StyleSheetRule},k)})),styleDeclarationCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.StyleDeclaration},k)})),canvasMutationCb:re,fontCb:k=>O(E({type:M.IncrementalSnapshot,data:V({source:D.Font},k)})),selectionCb:k=>{O(E({type:M.IncrementalSnapshot,data:V({source:D.Selection},k)}))},blockClass:o,ignoreClass:i,maskTextClass:l,maskTextSelector:a,maskInputOptions:G,inlineStylesheet:c,sampling:v,recordCanvas:C,inlineImages:T,userTriggeredOnInput:R,collectFonts:z,doc:P,maskInputFn:m,maskTextFn:p,keepIframeSrcFn:B,blockSelector:s,slimDOMOptions:X,dataURLOptions:g,mirror:H,iframeManager:Q,stylesheetManager:F,shadowDomManager:L,canvasManager:Fe,ignoreCSSAttributes:Y,plugins:((ee=w?.filter(k=>k.observer))==null?void 0:ee.map(k=>({observer:k.observer,options:k.options,callback:U=>O(E({type:M.Plugin,data:{plugin:k.name,payload:U}}))})))||[]},y)};Q.addLoadListener(P=>{b.push(j(P.contentDocument))});const q=()=>{he(),b.push(j(document))};return document.readyState==="interactive"||document.readyState==="complete"?q():b.push(_("load",()=>{O(E({type:M.Load,data:{}})),q()},window)),()=>{b.forEach(P=>P()),O=void 0,he=void 0}}catch(b){console.warn(b)}}return be.addCustomEvent=(e,t)=>{if(!O)throw new Error("please add custom event after start recording");O(E({type:M.Custom,data:{tag:e,payload:t}}))},be.freezePage=()=>{ae.forEach(e=>e.freeze())},be.takeFullSnapshot=e=>{if(!he)throw new Error("please take full snapshot after start recording");he(e)},be.mirror=H,be}();
or you can use record.mirror to access the mirror instance during recording.`;let Xe={map:{},getId(){return console.error(ce),-1},getNode(){return console.error(ce),null},removeNodeFromMap(){console.error(ce)},has(){return console.error(ce),!1},reset(){console.error(ce)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Xe=new Proxy(Xe,{get(e,t,r){return t==="map"&&console.error(ce),Reflect.get(e,t,r)}}));function Se(e,t,r={}){let n=null,o=0;return function(...s){const l=Date.now();!o&&r.leading===!1&&(o=l);const a=t-(l-o),i=this;a<=0||a>t?(n&&(clearTimeout(n),n=null),o=l,e.apply(i,s)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{o=r.leading===!1?0:Date.now(),n=null,e.apply(i,s)},a))}}function we(e,t,r,n,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set(l){setTimeout(()=>{r.set.call(this,l)},0),s&&s.set&&s.set.call(this,l)}}),()=>we(e,t,s||{},!0)}function de(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,()=>{e[t]=n}}catch{return()=>{}}}function Be(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ye(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function _(e,t,r,n){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if(typeof t=="string"){if(o.classList.contains(t)||n&&o.closest("."+t)!==null)return!0}else if(Me(o,t,n))return!0;return!!(r&&(e.matches(r)||n&&o.closest(r)!==null))}function or(e,t){return t.getId(e)!==-1}function Fe(e,t){return t.getId(e)===ge}function $e(e,t){if(fe(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?$e(e.parentNode,t):!0:!0}function Ke(e){return Boolean(e.changedTouches)}function ar(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function Je(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function Qe(e,t){return Boolean(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function qe(e){return Boolean(e?.shadowRoot)}class sr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!=null?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var C=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(C||{}),I=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(I||{}),Ae=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(Ae||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{}),pe=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(pe||{}),ir=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(ir||{});function et(e){return"__ln"in e}class lr{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=r?.next||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&et(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&et(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;this.length++}removeNode(t){const r=t.__ln;!this.head||(r.previous?(r.previous.next=r.next,r.next&&(r.next.previous=r.previous)):(this.head=r.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const tt=(e,t)=>`${e}@${t}`;class cr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],r=new lr,n=a=>{let i=a,c=ge;for(;c===ge;)i=i&&i.nextSibling,c=i&&this.mirror.getId(i);return c},o=a=>{var i,c,d,u;let h=null;((c=(i=a.getRootNode)==null?void 0:i.call(a))==null?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&a.getRootNode().host&&(h=a.getRootNode().host);let m=h;for(;((u=(d=m?.getRootNode)==null?void 0:d.call(m))==null?void 0:u.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&m.getRootNode().host;)m=m.getRootNode().host;const p=!this.doc.contains(a)&&(!m||!this.doc.contains(m));if(!a.parentNode||p)return;const v=fe(a.parentNode)?this.mirror.getId(h):this.mirror.getId(a.parentNode),g=n(a);if(v===-1||g===-1)return r.addNode(a);const S=le(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:y=>{Je(y,this.mirror)&&this.iframeManager.addIframe(y),Qe(y,this.mirror)&&this.stylesheetManager.trackLinkElement(y),qe(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(y,f)=>{this.iframeManager.attachIframe(y,f),this.shadowDomManager.observeAttachShadow(y)},onStylesheetLoad:(y,f)=>{this.stylesheetManager.attachLinkElement(y,f)}});S&&t.push({parentId:v,nextId:g,node:S})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of Array.from(this.movedSet.values()))rt(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||o(a);for(const a of Array.from(this.addedSet.values()))!ot(this.droppedSet,a)&&!rt(this.removes,a,this.mirror)||ot(this.movedSet,a)?o(a):this.droppedSet.add(a);let s=null;for(;r.length;){let a=null;if(s){const i=this.mirror.getId(s.value.parentNode),c=n(s.value);i!==-1&&c!==-1&&(a=s)}if(!a)for(let i=r.length-1;i>=0;i--){const c=r.get(i);if(c){const d=this.mirror.getId(c.value.parentNode);if(n(c.value)===-1)continue;if(d!==-1){a=c;break}else{const u=c.value;if(u.parentNode&&u.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const h=u.parentNode.host;if(this.mirror.getId(h)!==-1){a=c;break}}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}s=a.previous,r.removeNode(a.value),o(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>({id:this.mirror.getId(a.node),attributes:a.attributes})).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:t};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=t=>{if(!Fe(t.target,this.mirror))switch(t.type){case"characterData":{const r=t.target.textContent;!_(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:He(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.target.getAttribute(t.attributeName);if(t.attributeName==="value"&&(n=xe({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),_(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let o=this.attributes.find(s=>s.node===t.target);if(r.tagName==="IFRAME"&&t.attributeName==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)t.attributeName="rr_src";else return;if(o||(o={node:t.target,attributes:{}},this.attributes.push(o)),t.attributeName==="style"){const s=this.doc.createElement("span");t.oldValue&&s.setAttribute("style",t.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const l=o.attributes.style;for(const a of Array.from(r.style)){const i=r.style.getPropertyValue(a),c=r.style.getPropertyPriority(a);(i!==s.style.getPropertyValue(a)||c!==s.style.getPropertyPriority(a))&&(c===""?l[a]=i:l[a]=[i,c])}for(const a of Array.from(s.style))r.style.getPropertyValue(a)===""&&(l[a]=!1)}else o.attributes[t.attributeName]=Ue(this.doc,r.tagName,t.attributeName,n);break}case"childList":{if(_(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),o=fe(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);_(t.target,this.blockClass,this.blockSelector,!1)||Fe(r,this.mirror)||!or(r,this.mirror)||(this.addedSet.has(r)?(_e(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||$e(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[tt(n,o)]?_e(this.movedSet,r):this.removes.push({parentId:o,id:n,isShadow:fe(t.target)&&ye(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,r)=>{if(this.mirror.hasNode(t)){if(Fe(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[tt(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);_(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(n=>this.genAdds(n))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function _e(e,t){e.delete(t),t.childNodes.forEach(r=>_e(e,r))}function rt(e,t,r){return e.length===0?!1:nt(e,t,r)}function nt(e,t,r){const{parentNode:n}=t;if(!n)return!1;const o=r.getId(n);return e.some(s=>s.id===o)?!0:nt(e,n,r)}function ot(e,t){return e.size===0?!1:at(e,t)}function at(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:at(e,r):!1}var dr=Object.defineProperty,ur=Object.defineProperties,pr=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,it=(e,t,r)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lt=(e,t)=>{for(var r in t||(t={}))hr.call(t,r)&&it(e,r,t[r]);if(st)for(var r of st(t))mr.call(t,r)&&it(e,r,t[r]);return e},fr=(e,t)=>ur(e,pr(t));const se=[],ct=typeof CSSGroupingRule<"u",dt=typeof CSSMediaRule<"u",ut=typeof CSSSupportsRule<"u",pt=typeof CSSConditionRule<"u";function ve(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function ht(e,t){var r,n;const o=new cr;se.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const l=(n=(r=window?.Zone)==null?void 0:r.__symbol__)==null?void 0:n.call(r,"MutationObserver");l&&window[l]&&(s=window[l]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function yr({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const o=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let l=[],a;const i=Se(u=>{const h=Date.now()-a;e(l.map(m=>(m.timeOffset-=h,m)),u),l=[],a=null},s),c=Se(u=>{const h=ve(u),{clientX:m,clientY:p}=Ke(u)?u.changedTouches[0]:u;a||(a=Date.now()),l.push({x:m,y:p,id:n.getId(h),timeOffset:Date.now()-a}),i(typeof DragEvent<"u"&&u instanceof DragEvent?I.Drag:u instanceof MouseEvent?I.MouseMove:I.TouchMove)},o,{trailing:!1}),d=[A("mousemove",c,r),A("touchmove",c,r),A("drag",c,r)];return()=>{d.forEach(u=>u())}}function gr({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const l=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,a=[],i=c=>d=>{const u=ve(d);if(_(u,n,o,!0))return;const h=Ke(d)?d.changedTouches[0]:d;if(!h)return;const m=r.getId(u),{clientX:p,clientY:v}=h;e({type:Ae[c],id:m,x:p,y:v})};return Object.keys(Ae).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&l[c]!==!1).forEach(c=>{const d=c.toLowerCase(),u=i(c);a.push(A(d,u,t))}),()=>{a.forEach(c=>c())}}function mt({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:s}){const l=Se(a=>{const i=ve(a);if(!i||_(i,n,o,!0))return;const c=r.getId(i);if(i===t){const d=t.scrollingElement||t.documentElement;e({id:c,x:d.scrollLeft,y:d.scrollTop})}else e({id:c,x:i.scrollLeft,y:i.scrollTop})},s.scroll||100);return A("scroll",l,t)}function Sr({viewportResizeCb:e}){let t=-1,r=-1;const n=Se(()=>{const o=Be(),s=Ye();(t!==o||r!==s)&&(e({width:Number(s),height:Number(o)}),t=o,r=s)},200);return A("resize",n,window)}function ft(e,t){const r=lt({},e);return t||delete r.userTriggered,r}const vr=["INPUT","TEXTAREA","SELECT"],yt=new WeakMap;function br({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,ignoreClass:s,maskInputOptions:l,maskInputFn:a,sampling:i,userTriggeredOnInput:c}){function d(g){let S=ve(g);const y=g.isTrusted;if(S&&S.tagName==="OPTION"&&(S=S.parentElement),!S||!S.tagName||vr.indexOf(S.tagName)<0||_(S,n,o,!0))return;const f=S.type;if(S.classList.contains(s))return;let w=S.value,F=!1;f==="radio"||f==="checkbox"?F=S.checked:(l[S.tagName.toLowerCase()]||l[f])&&(w=xe({maskInputOptions:l,tagName:S.tagName,type:f,value:w,maskInputFn:a})),u(S,ft({text:w,isChecked:F,userTriggered:y},c));const P=S.name;f==="radio"&&P&&F&&t.querySelectorAll(`input[type="radio"][name="${P}"]`).forEach(D=>{D!==S&&u(D,ft({text:D.value,isChecked:!F,userTriggered:!1},c))})}function u(g,S){const y=yt.get(g);if(!y||y.text!==S.text||y.isChecked!==S.isChecked){yt.set(g,S);const f=r.getId(g);e(fr(lt({},S),{id:f}))}}const h=(i.input==="last"?["change"]:["input","change"]).map(g=>A(g,d,t)),m=t.defaultView;if(!m)return()=>{h.forEach(g=>g())};const p=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),v=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&h.push(...v.map(g=>we(g[0],g[1],{set(){d({target:this})}},!1,m))),()=>{h.forEach(g=>g())}}function Oe(e){const t=[];function r(n,o){if(ct&&n.parentRule instanceof CSSGroupingRule||dt&&n.parentRule instanceof CSSMediaRule||ut&&n.parentRule instanceof CSSSupportsRule||pt&&n.parentRule instanceof CSSConditionRule){const s=Array.from(n.parentRule.cssRules).indexOf(n);o.unshift(s)}else if(n.parentStyleSheet){const s=Array.from(n.parentStyleSheet.cssRules).indexOf(n);o.unshift(s)}return o}return r(e,t)}function oe(e,t,r){let n,o;return e?(e.ownerNode?n=t.getId(e.ownerNode):o=r.getId(e),{styleId:o,id:n}):{}}function Ir({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){const o=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(d,u){const{id:h,styleId:m}=oe(this,t,r.styleMirror);return(h&&h!==-1||m&&m!==-1)&&e({id:h,styleId:m,adds:[{rule:d,index:u}]}),o.apply(this,[d,u])};const s=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,removes:[{index:d}]}),s.apply(this,[d])};let l;n.CSSStyleSheet.prototype.replace&&(l=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replace:d}),l.apply(this,[d])});let a;n.CSSStyleSheet.prototype.replaceSync&&(a=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=function(d){const{id:u,styleId:h}=oe(this,t,r.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,replaceSync:d}),a.apply(this,[d])});const i={};ct?i.CSSGroupingRule=n.CSSGroupingRule:(dt&&(i.CSSMediaRule=n.CSSMediaRule),pt&&(i.CSSConditionRule=n.CSSConditionRule),ut&&(i.CSSSupportsRule=n.CSSSupportsRule));const c={};return Object.entries(i).forEach(([d,u])=>{c[d]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=function(h,m){const{id:p,styleId:v}=oe(this.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||v&&v!==-1)&&e({id:p,styleId:v,adds:[{rule:h,index:[...Oe(this),m||0]}]}),c[d].insertRule.apply(this,[h,m])},u.prototype.deleteRule=function(h){const{id:m,styleId:p}=oe(this.parentStyleSheet,t,r.styleMirror);return(m&&m!==-1||p&&p!==-1)&&e({id:m,styleId:p,removes:[{index:[...Oe(this),h]}]}),c[d].deleteRule.apply(this,[h])}}),()=>{n.CSSStyleSheet.prototype.insertRule=o,n.CSSStyleSheet.prototype.deleteRule=s,l&&(n.CSSStyleSheet.prototype.replace=l),a&&(n.CSSStyleSheet.prototype.replaceSync=a),Object.entries(i).forEach(([d,u])=>{u.prototype.insertRule=c[d].insertRule,u.prototype.deleteRule=c[d].deleteRule})}}function gt({mirror:e,stylesheetManager:t},r){var n,o,s;let l=null;r.nodeName==="#document"?l=e.getId(r):l=e.getId(r.host);const a=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(s=(o=r.ownerDocument)==null?void 0:o.defaultView)==null?void 0:s.ShadowRoot,i=Object.getOwnPropertyDescriptor(a?.prototype,"adoptedStyleSheets");return l===null||l===-1||!a||!i?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get(){var c;return(c=i.get)==null?void 0:c.call(this)},set(c){var d;const u=(d=i.set)==null?void 0:d.call(this,c);if(l!==null&&l!==-1)try{t.adoptStyleSheets(c,l)}catch{}return u}}),()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get:i.get,set:i.set})})}function Cr({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(a,i,c){var d;if(r.has(a))return s.apply(this,[a,i,c]);const{id:u,styleId:h}=oe((d=this.parentRule)==null?void 0:d.parentStyleSheet,t,n.styleMirror);return(u&&u!==-1||h&&h!==-1)&&e({id:u,styleId:h,set:{property:a,value:i,priority:c},index:Oe(this.parentRule)}),s.apply(this,[a,i,c])};const l=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(a){var i;if(r.has(a))return l.apply(this,[a]);const{id:c,styleId:d}=oe((i=this.parentRule)==null?void 0:i.parentStyleSheet,t,n.styleMirror);return(c&&c!==-1||d&&d!==-1)&&e({id:c,styleId:d,remove:{property:a},index:Oe(this.parentRule)}),l.apply(this,[a])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=l}}function kr({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:o}){const s=a=>Se(i=>{const c=ve(i);if(!c||_(c,t,r,!0))return;const{currentTime:d,volume:u,muted:h,playbackRate:m}=c;e({type:a,id:n.getId(c),currentTime:d,volume:u,muted:h,playbackRate:m})},o.media||500),l=[A("play",s(pe.Play)),A("pause",s(pe.Pause)),A("seeked",s(pe.Seeked)),A("volumechange",s(pe.VolumeChange)),A("ratechange",s(pe.RateChange))];return()=>{l.forEach(a=>a())}}function Mr({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],o=new WeakMap,s=r.FontFace;r.FontFace=function(a,i,c){const d=new s(a,i,c);return o.set(d,{family:a,buffer:typeof i!="string",descriptors:c,fontSource:typeof i=="string"?i:JSON.stringify(Array.from(new Uint8Array(i)))}),d};const l=de(t.fonts,"add",function(a){return function(i){return setTimeout(()=>{const c=o.get(i);c&&(e(c),o.delete(i))},0),a.apply(this,[i])}});return n.push(()=>{r.FontFace=s}),n.push(l),()=>{n.forEach(a=>a())}}function wr(e){const{doc:t,mirror:r,blockClass:n,blockSelector:o,selectionCb:s}=e;let l=!0;const a=()=>{const i=t.getSelection();if(!i||l&&i?.isCollapsed)return;l=i.isCollapsed||!1;const c=[],d=i.rangeCount||0;for(let u=0;u<d;u++){const h=i.getRangeAt(u),{startContainer:m,startOffset:p,endContainer:v,endOffset:g}=h;_(m,n,o,!0)||_(v,n,o,!0)||c.push({start:r.getId(m),startOffset:p,end:r.getId(v),endOffset:g})}s({ranges:c})};return a(),A("selectionchange",a)}function Or(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:l,inputCb:a,mediaInteractionCb:i,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:m}=e;e.mutationCb=(...p)=>{t.mutation&&t.mutation(...p),r(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),n(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),o(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),s(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),l(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),a(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),i(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),c(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),d(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),u(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),h(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),m(...p)}}function Tr(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};Or(e,t);const n=ht(e,e.doc),o=yr(e),s=gr(e),l=mt(e),a=Sr(e),i=br(e),c=kr(e),d=Ir(e,{win:r}),u=gt(e,e.doc),h=Cr(e,{win:r}),m=e.collectFonts?Mr(e):()=>{},p=wr(e),v=[];for(const g of e.plugins)v.push(g.observer(g.callback,r,g.options));return()=>{se.forEach(g=>g.reset()),n.disconnect(),o(),s(),l(),a(),i(),c(),d(),u(),h(),m(),p(),v.forEach(g=>g())}}class St{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,o){const s=n||this.getIdToRemoteIdMap(t),l=o||this.getRemoteIdToIdMap(t);let a=s.get(r);return a||(a=this.generateIdFn(),s.set(r,a),l.set(a,r)),a}getIds(t,r){const n=this.getIdToRemoteIdMap(t),o=this.getRemoteIdToIdMap(t);return r.map(s=>this.getId(t,s,n,o))}getRemoteId(t,r,n){const o=n||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:o.get(r)||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(o=>this.getRemoteId(t,o,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Rr{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new St(Ze),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new St(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)==null||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if(t.data.type==="rrweb"){if(!t.source)return;const r=this.crossOriginIframeMap.get(t.source);if(!r)return;const n=this.transformCrossOriginEvent(r,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,r){var n;switch(r.type){case C.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t),{timestamp:r.timestamp,type:C.IncrementalSnapshot,data:{source:I.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case C.Meta:case C.Load:case C.DomContentLoaded:return!1;case C.Plugin:return r;case C.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case C.IncrementalSnapshot:switch(r.data.source){case I.Mutation:return r.data.adds.forEach(o=>{this.replaceIds(o,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(o.node,t)}),r.data.removes.forEach(o=>{this.replaceIds(o,t,["parentId","id"])}),r.data.attributes.forEach(o=>{this.replaceIds(o,t,["id"])}),r.data.texts.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case I.Drag:case I.TouchMove:case I.MouseMove:return r.data.positions.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case I.ViewportResize:return!1;case I.MediaInteraction:case I.MouseInteraction:case I.Scroll:case I.CanvasMutation:case I.Input:return this.replaceIds(r.data,t,["id"]),r;case I.StyleSheetRule:case I.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case I.Font:return r;case I.Selection:return r.data.ranges.forEach(o=>{this.replaceIds(o,t,["start","end"])}),r;case I.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(o=>{this.replaceStyleIds(o,t,["styleId"])}),r}}}replace(t,r,n,o){for(const s of o)!Array.isArray(r[s])&&typeof r[s]!="number"||(Array.isArray(r[s])?r[s]=t.getIds(n,r[s]):r[s]=t.getId(n,r[s]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}}var Er=Object.defineProperty,Lr=Object.defineProperties,Nr=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,bt=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,It=(e,t)=>{for(var r in t||(t={}))xr.call(t,r)&&bt(e,r,t[r]);if(vt)for(var r of vt(t))Dr.call(t,r)&&bt(e,r,t[r]);return e},Ct=(e,t)=>Lr(e,Nr(t));class Fr{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const r=this;this.restorePatches.push(de(Element.prototype,"attachShadow",function(n){return function(o){const s=n.call(this,o);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,this.ownerDocument),s}}))}addShadowRoot(t,r){!ye(t)||this.shadowDoms.has(t)||(this.shadowDoms.add(t),ht(Ct(It({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),mt(Ct(It({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),gt({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0))}observeAttachShadow(t){if(t.contentWindow){const r=this;this.restorePatches.push(de(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(o){const s=n.call(this,o);return this.shadowRoot&&r.addShadowRoot(this.shadowRoot,t.contentDocument),s}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ar=typeof Uint8Array>"u"?[]:new Uint8Array(256),Te=0;Te<he.length;Te++)Ar[he.charCodeAt(Te)]=Te;var _r=function(e){var t=new Uint8Array(e),r,n=t.length,o="";for(r=0;r<n;r+=3)o+=he[t[r]>>2],o+=he[(t[r]&3)<<4|t[r+1]>>4],o+=he[(t[r+1]&15)<<2|t[r+2]>>6],o+=he[t[r+2]&63];return n%3===2?o=o.substring(0,o.length-1)+"=":n%3===1&&(o=o.substring(0,o.length-2)+"=="),o};const kt=new Map;function Pr(e,t){let r=kt.get(e);return r||(r=new Map,kt.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const Mt=(e,t,r)=>{if(!e||!(Ot(e,t)||typeof e=="object"))return;const n=e.constructor.name,o=Pr(r,n);let s=o.indexOf(e);return s===-1&&(s=o.length,o.push(e)),s};function Re(e,t,r){if(e instanceof Array)return e.map(n=>Re(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,o=_r(e);return{rr_type:n,base64:o}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Re(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:o}=e;return{rr_type:n,src:o}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",o=e.toDataURL();return{rr_type:n,src:o}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Re(e.data,t,r),e.width,e.height]};if(Ot(e,t)||typeof e=="object"){const n=e.constructor.name,o=Mt(e,t,r);return{rr_type:n,index:o}}}}return e}const wt=(e,t,r)=>[...e].map(n=>Re(n,t,r)),Ot=(e,t)=>{const r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function");return Boolean(r.find(n=>e instanceof t[n]))};function Wr(e,t,r,n){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const l of s)try{if(typeof t.CanvasRenderingContext2D.prototype[l]!="function")continue;const a=de(t.CanvasRenderingContext2D.prototype,l,function(i){return function(...c){return _(this.canvas,r,n,!0)||setTimeout(()=>{const d=wt([...c],t,this);e(this.canvas,{type:ue["2D"],property:l,args:d})},0),i.apply(this,c)}});o.push(a)}catch{const i=we(t.CanvasRenderingContext2D.prototype,l,{set(c){e(this.canvas,{type:ue["2D"],property:l,args:[c],setter:!0})}});o.push(i)}return()=>{o.forEach(l=>l())}}function Tt(e,t,r){const n=[];try{const o=de(e.HTMLCanvasElement.prototype,"getContext",function(s){return function(l,...a){return _(this,t,r,!0)||"__context"in this||(this.__context=l),s.apply(this,[l,...a])}});n.push(o)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(o=>o())}}function Rt(e,t,r,n,o,s,l){const a=[],i=Object.getOwnPropertyNames(e);for(const c of i)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if(typeof e[c]!="function")continue;const d=de(e,c,function(u){return function(...h){const m=u.apply(this,h);if(Mt(m,l,this),!_(this.canvas,n,o,!0)){const p=wt([...h],l,this),v={type:t,property:c,args:p};r(this.canvas,v)}return m}});a.push(d)}catch{const u=we(e,c,{set(h){r(this.canvas,{type:t,property:c,args:[h],setter:!0})}});a.push(u)}return a}function zr(e,t,r,n,o){const s=[];return s.push(...Rt(t.WebGLRenderingContext.prototype,ue.WebGL,e,r,n,o,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...Rt(t.WebGL2RenderingContext.prototype,ue.WebGL2,e,r,n,o,t)),()=>{s.forEach(l=>l())}}function Gr(e,t){var r=atob(e);if(t){for(var n=new Uint8Array(r.length),o=0,s=r.length;o<s;++o)n[o]=r.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}function Vr(e,t,r){var n=t===void 0?null:t,o=r===void 0?!1:r,s=Gr(e,o),l=s.indexOf(`
`,10)+1,a=s.substring(l)+(n?"//# sourceMappingURL="+n:""),i=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(i)}function Zr(e,t,r){var n;return function(s){return n=n||Vr(e,t,r),new Worker(n,s)}}var jr=Zr("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Zm9yKHZhciByPSJBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OSsvIixwPXR5cGVvZiBVaW50OEFycmF5PiJ1Ij9bXTpuZXcgVWludDhBcnJheSgyNTYpLGY9MDtmPHIubGVuZ3RoO2YrKylwW3IuY2hhckNvZGVBdChmKV09Zjt2YXIgdT1mdW5jdGlvbihzKXt2YXIgZT1uZXcgVWludDhBcnJheShzKSxuLGE9ZS5sZW5ndGgsdD0iIjtmb3Iobj0wO248YTtuKz0zKXQrPXJbZVtuXT4+Ml0sdCs9clsoZVtuXSYzKTw8NHxlW24rMV0+PjRdLHQrPXJbKGVbbisxXSYxNSk8PDJ8ZVtuKzJdPj42XSx0Kz1yW2VbbisyXSY2M107cmV0dXJuIGElMz09PTI/dD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTEpKyI9IjphJTM9PT0xJiYodD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTIpKyI9PSIpLHR9O2NvbnN0IGM9bmV3IE1hcCxsPW5ldyBNYXA7YXN5bmMgZnVuY3Rpb24gdihzLGUsbil7Y29uc3QgYT1gJHtzfS0ke2V9YDtpZigiT2Zmc2NyZWVuQ2FudmFzImluIGdsb2JhbFRoaXMpe2lmKGwuaGFzKGEpKXJldHVybiBsLmdldChhKTtjb25zdCB0PW5ldyBPZmZzY3JlZW5DYW52YXMocyxlKTt0LmdldENvbnRleHQoIjJkIik7Y29uc3QgZz1hd2FpdChhd2FpdCB0LmNvbnZlcnRUb0Jsb2IobikpLmFycmF5QnVmZmVyKCksZD11KGcpO3JldHVybiBsLnNldChhLGQpLGR9ZWxzZSByZXR1cm4iIn1jb25zdCBpPXNlbGY7aS5vbm1lc3NhZ2U9YXN5bmMgZnVuY3Rpb24ocyl7aWYoIk9mZnNjcmVlbkNhbnZhcyJpbiBnbG9iYWxUaGlzKXtjb25zdHtpZDplLGJpdG1hcDpuLHdpZHRoOmEsaGVpZ2h0OnQsZGF0YVVSTE9wdGlvbnM6Z309cy5kYXRhLGQ9dihhLHQsZyksaD1uZXcgT2Zmc2NyZWVuQ2FudmFzKGEsdCk7aC5nZXRDb250ZXh0KCIyZCIpLmRyYXdJbWFnZShuLDAsMCksbi5jbG9zZSgpO2NvbnN0IHc9YXdhaXQgaC5jb252ZXJ0VG9CbG9iKGcpLHk9dy50eXBlLGI9YXdhaXQgdy5hcnJheUJ1ZmZlcigpLG89dShiKTtpZighYy5oYXMoZSkmJmF3YWl0IGQ9PT1vKXJldHVybiBjLnNldChlLG8pLGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpZihjLmdldChlKT09PW8pcmV0dXJuIGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpLnBvc3RNZXNzYWdlKHtpZDplLHR5cGU6eSxiYXNlNjQ6byx3aWR0aDphLGhlaWdodDp0fSksYy5zZXQoZSxvKX1lbHNlIHJldHVybiBpLnBvc3RNZXNzYWdlKHtpZDpzLmRhdGEuaWR9KX19KSgpOwoK",null,!1),Et=Object.getOwnPropertySymbols,Ur=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable,Xr=(e,t)=>{var r={};for(var n in e)Ur.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Et)for(var n of Et(e))t.indexOf(n)<0&&Hr.call(e,n)&&(r[n]=e[n]);return r},Br=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{a(r.next(i))}catch(c){o(c)}},l=i=>{try{a(r.throw(i))}catch(c){o(c)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,l);a((r=r.apply(e,t)).next())});class Yr{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(i,c)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(i)||this.pendingCanvasMutations.set(i,[]),this.pendingCanvasMutations.get(i).push(c)};const{sampling:r="all",win:n,blockClass:o,blockSelector:s,recordCanvas:l,dataURLOptions:a}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,l&&r==="all"&&this.initCanvasMutationObserver(n,o,s),l&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,o,s,{dataURLOptions:a})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,o,s){const l=Tt(r,n,o),a=new Map,i=new jr;i.onmessage=p=>{const{id:v}=p.data;if(a.set(v,!1),!("base64"in p.data))return;const{base64:g,type:S,width:y,height:f}=p.data;this.mutationCb({id:v,type:ue["2D"],commands:[{property:"clearRect",args:[0,0,y,f]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:g}],type:S}]},0,0]}]})};const c=1e3/t;let d=0,u;const h=()=>{const p=[];return r.document.querySelectorAll("canvas").forEach(v=>{_(v,n,o,!0)||p.push(v)}),p},m=p=>{if(d&&p-d<c){u=requestAnimationFrame(m);return}d=p,h().forEach(v=>Br(this,null,function*(){var g;const S=this.mirror.getId(v);if(a.get(S))return;if(a.set(S,!0),["webgl","webgl2"].includes(v.__context)){const f=v.getContext(v.__context);((g=f?.getContextAttributes())==null?void 0:g.preserveDrawingBuffer)===!1&&f?.clear(f.COLOR_BUFFER_BIT)}const y=yield createImageBitmap(v);i.postMessage({id:S,bitmap:y,width:v.width,height:v.height,dataURLOptions:s.dataURLOptions},[y])})),u=requestAnimationFrame(m)};u=requestAnimationFrame(m),this.resetObservers=()=>{l(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Tt(t,r,n),s=Wr(this.processMutation.bind(this),t,r,n),l=zr(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{o(),s(),l()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const o=n.map(l=>Xr(l,["type"])),{type:s}=n[0];this.mutationCb({id:r,type:s,commands:o}),this.pendingCanvasMutations.delete(t)}}class $r{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new sr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},o=[];for(const s of t){let l;if(this.styleMirror.has(s))l=this.styleMirror.getId(s);else{l=this.styleMirror.add(s);const a=Array.from(s.rules||CSSRule);o.push({styleId:l,rules:a.map((i,c)=>({rule:ze(i),index:c}))})}n.styleIds.push(l)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}var Kr=Object.defineProperty,Jr=Object.defineProperties,Qr=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,Nt=(e,t,r)=>t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,V=(e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Nt(e,r,t[r]);if(Lt)for(var r of Lt(t))en.call(t,r)&&Nt(e,r,t[r]);return e},tn=(e,t)=>Jr(e,Qr(t));function L(e){return tn(V({},e),{timestamp:Date.now()})}let T,Ee,Pe,Le=!1;const J=At();function be(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:l="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:i=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:m,maskTextFn:p,hooks:v,packFn:g,sampling:S={},dataURLOptions:y={},mousemoveWait:f,recordCanvas:w=!1,recordCrossOriginIframes:F=!1,userTriggeredOnInput:P=!1,collectFonts:D=!1,inlineImages:O=!1,plugins:X,keepIframeSrcFn:Z=()=>!1,ignoreCSSAttributes:B=new Set([])}=e,Y=F?window.parent===window:!0;let $=!1;if(!Y)try{window.parent.document,$=!1}catch{$=!0}if(Y&&!t)throw new Error("emit function is required");f!==void 0&&S.mousemove===void 0&&(S.mousemove=f),J.reset();const N=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u!==void 0?u:{password:!0},j=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};ar();let Q,te=0;const ne=b=>{for(const G of X||[])G.eventProcessor&&(b=G.eventProcessor(b));return g&&(b=g(b)),b};T=(b,G)=>{var K;if(((K=se[0])==null?void 0:K.isFrozen())&&b.type!==C.FullSnapshot&&!(b.type===C.IncrementalSnapshot&&b.data.source===I.Mutation)&&se.forEach(R=>R.unfreeze()),Y)t?.(ne(b),G);else if($){const R={type:"rrweb",event:ne(b),isCheckout:G};window.parent.postMessage(R,"*")}if(b.type===C.FullSnapshot)Q=b,te=0;else if(b.type===C.IncrementalSnapshot){if(b.data.source===I.Mutation&&b.data.isAttachIframe)return;te++;const R=n&&te>=n,ee=r&&b.timestamp-Q.timestamp>r;(R||ee)&&Ee(!0)}};const z=b=>{T(L({type:C.IncrementalSnapshot,data:V({source:I.Mutation},b)}))},U=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Scroll},b)})),ae=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.CanvasMutation},b)})),E=b=>T(L({type:C.IncrementalSnapshot,data:V({source:I.AdoptedStyleSheet},b)})),q=new $r({mutationCb:z,adoptedStyleSheetCb:E}),re=new Rr({mirror:J,mutationCb:z,stylesheetManager:q,recordCrossOriginIframes:F,wrappedEmit:T});for(const b of X||[])b.getMirror&&b.getMirror({nodeMirror:J,crossOriginIframeMirror:re.crossOriginIframeMirror,crossOriginIframeStyleMirror:re.crossOriginIframeStyleMirror});Pe=new Yr({recordCanvas:w,mutationCb:ae,win:window,blockClass:o,blockSelector:s,mirror:J,sampling:S.canvas,dataURLOptions:y});const me=new Fr({mutationCb:z,scrollCb:U,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskInputOptions:N,dataURLOptions:y,maskTextFn:p,maskInputFn:m,recordCanvas:w,inlineImages:O,sampling:S,slimDOMOptions:j,iframeManager:re,stylesheetManager:q,canvasManager:Pe,keepIframeSrcFn:Z},mirror:J});Ee=(b=!1)=>{var G,K,R,ee,k,H;T(L({type:C.Meta,data:{href:window.location.href,width:Ye(),height:Be()}}),b),q.reset(),se.forEach(W=>W.lock());const Ie=nr(document,{mirror:J,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskAllInputs:N,maskTextFn:p,slimDOM:j,dataURLOptions:y,recordCanvas:w,inlineImages:O,onSerialize:W=>{Je(W,J)&&re.addIframe(W),Qe(W,J)&&q.trackLinkElement(W),qe(W)&&me.addShadowRoot(W.shadowRoot,document)},onIframeLoad:(W,We)=>{re.attachIframe(W,We),me.observeAttachShadow(W)},onStylesheetLoad:(W,We)=>{q.attachLinkElement(W,We)},keepIframeSrcFn:Z});if(!Ie)return console.warn("Failed to snapshot the document");T(L({type:C.FullSnapshot,data:{node:Ie,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:document?.documentElement.scrollLeft||((K=(G=document?.body)==null?void 0:G.parentElement)==null?void 0:K.scrollLeft)||((R=document?.body)==null?void 0:R.scrollLeft)||0,top:window.pageYOffset!==void 0?window.pageYOffset:document?.documentElement.scrollTop||((k=(ee=document?.body)==null?void 0:ee.parentElement)==null?void 0:k.scrollTop)||((H=document?.body)==null?void 0:H.scrollTop)||0}}})),se.forEach(W=>W.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&q.adoptStyleSheets(document.adoptedStyleSheets,J.getId(document))};try{const b=[];b.push(A("DOMContentLoaded",()=>{T(L({type:C.DomContentLoaded,data:{}}))}));const G=R=>{var ee;return Tr({mutationCb:z,mousemoveCb:(k,H)=>T(L({type:C.IncrementalSnapshot,data:{source:H,positions:k}})),mouseInteractionCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.MouseInteraction},k)})),scrollCb:U,viewportResizeCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.ViewportResize},k)})),inputCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Input},k)})),mediaInteractionCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.MediaInteraction},k)})),styleSheetRuleCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.StyleSheetRule},k)})),styleDeclarationCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.StyleDeclaration},k)})),canvasMutationCb:ae,fontCb:k=>T(L({type:C.IncrementalSnapshot,data:V({source:I.Font},k)})),selectionCb:k=>{T(L({type:C.IncrementalSnapshot,data:V({source:I.Selection},k)}))},blockClass:o,ignoreClass:l,maskTextClass:a,maskTextSelector:i,maskInputOptions:N,inlineStylesheet:c,sampling:S,recordCanvas:w,inlineImages:O,userTriggeredOnInput:P,collectFonts:D,doc:R,maskInputFn:m,maskTextFn:p,keepIframeSrcFn:Z,blockSelector:s,slimDOMOptions:j,dataURLOptions:y,mirror:J,iframeManager:re,stylesheetManager:q,shadowDomManager:me,canvasManager:Pe,ignoreCSSAttributes:B,plugins:((ee=X?.filter(k=>k.observer))==null?void 0:ee.map(k=>({observer:k.observer,options:k.options,callback:H=>T(L({type:C.Plugin,data:{plugin:k.name,payload:H}}))})))||[]},v)};re.addLoadListener(R=>{b.push(G(R.contentDocument))});const K=()=>{Ee(),b.push(G(document)),Le=!0};return document.readyState==="interactive"||document.readyState==="complete"?K():b.push(A("load",()=>{T(L({type:C.Load,data:{}})),K()},window)),()=>{b.forEach(R=>R()),Le=!1}}catch(b){console.warn(b)}}return be.addCustomEvent=(e,t)=>{if(!Le)throw new Error("please add custom event after start recording");T(L({type:C.Custom,data:{tag:e,payload:t}}))},be.freezePage=()=>{se.forEach(e=>e.freeze())},be.takeFullSnapshot=e=>{if(!Le)throw new Error("please take full snapshot after start recording");Ee(e)},be.mirror=J,be}();
//# sourceMappingURL=rrweb-record.min.js.map

@@ -7,3 +7,3 @@ export { addCustomEvent, freezePage } from '../index.js';

export { default as record } from '../record/index.js';
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from '../types.js';
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from '../../../types/dist/types.js';
export { Replayer } from '../replay/index.js';

@@ -10,0 +10,0 @@ import * as utils from '../utils.js';

@@ -5,3 +5,2 @@ import record from './record/index.js';

import '../../rrdom/es/rrdom.js';
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from './types.js';
import * as utils from './utils.js';

@@ -8,0 +7,0 @@ export { utils };

import { PLUGIN_NAME } from '../record/index.js';
import { EventType, IncrementalSource } from '../../../types.js';
import { EventType, IncrementalSource } from '../../../../../types/dist/types.js';

@@ -4,0 +4,0 @@ const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';

@@ -0,9 +1,24 @@

import { genId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import CrossOriginIframeMirror from './cross-origin-iframe-mirror.js';
import { EventType, IncrementalSource } from '../../../types/dist/types.js';
class IframeManager {
constructor(options) {
this.iframes = new WeakMap();
this.crossOriginIframeMap = new WeakMap();
this.crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
this.mutationCb = options.mutationCb;
this.wrappedEmit = options.wrappedEmit;
this.stylesheetManager = options.stylesheetManager;
this.recordCrossOriginIframes = options.recordCrossOriginIframes;
this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
this.mirror = options.mirror;
if (this.recordCrossOriginIframes) {
window.addEventListener('message', this.handleMessage.bind(this));
}
}
addIframe(iframeEl) {
this.iframes.set(iframeEl, true);
if (iframeEl.contentWindow)
this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
}

@@ -13,3 +28,3 @@ addLoadListener(cb) {

}
attachIframe(iframeEl, childSn, mirror) {
attachIframe(iframeEl, childSn) {
var _a;

@@ -19,3 +34,3 @@ this.mutationCb({

{
parentId: mirror.getId(iframeEl),
parentId: this.mirror.getId(iframeEl),
nextId: null,

@@ -34,6 +49,152 @@ node: childSn,

iframeEl.contentDocument.adoptedStyleSheets.length > 0)
this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, mirror.getId(iframeEl.contentDocument));
this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
}
handleMessage(message) {
if (message.data.type === 'rrweb') {
const iframeSourceWindow = message.source;
if (!iframeSourceWindow)
return;
const iframeEl = this.crossOriginIframeMap.get(message.source);
if (!iframeEl)
return;
const transformedEvent = this.transformCrossOriginEvent(iframeEl, message.data.event);
if (transformedEvent)
this.wrappedEmit(transformedEvent, message.data.isCheckout);
}
}
transformCrossOriginEvent(iframeEl, e) {
var _a;
switch (e.type) {
case EventType.FullSnapshot: {
this.crossOriginIframeMirror.reset(iframeEl);
this.crossOriginIframeStyleMirror.reset(iframeEl);
this.replaceIdOnNode(e.data.node, iframeEl);
return {
timestamp: e.timestamp,
type: EventType.IncrementalSnapshot,
data: {
source: IncrementalSource.Mutation,
adds: [
{
parentId: this.mirror.getId(iframeEl),
nextId: null,
node: e.data.node,
},
],
removes: [],
texts: [],
attributes: [],
isAttachIframe: true,
},
};
}
case EventType.Meta:
case EventType.Load:
case EventType.DomContentLoaded: {
return false;
}
case EventType.Plugin: {
return e;
}
case EventType.Custom: {
this.replaceIds(e.data.payload, iframeEl, ['id', 'parentId', 'previousId', 'nextId']);
return e;
}
case EventType.IncrementalSnapshot: {
switch (e.data.source) {
case IncrementalSource.Mutation: {
e.data.adds.forEach((n) => {
this.replaceIds(n, iframeEl, [
'parentId',
'nextId',
'previousId',
]);
this.replaceIdOnNode(n.node, iframeEl);
});
e.data.removes.forEach((n) => {
this.replaceIds(n, iframeEl, ['parentId', 'id']);
});
e.data.attributes.forEach((n) => {
this.replaceIds(n, iframeEl, ['id']);
});
e.data.texts.forEach((n) => {
this.replaceIds(n, iframeEl, ['id']);
});
return e;
}
case IncrementalSource.Drag:
case IncrementalSource.TouchMove:
case IncrementalSource.MouseMove: {
e.data.positions.forEach((p) => {
this.replaceIds(p, iframeEl, ['id']);
});
return e;
}
case IncrementalSource.ViewportResize: {
return false;
}
case IncrementalSource.MediaInteraction:
case IncrementalSource.MouseInteraction:
case IncrementalSource.Scroll:
case IncrementalSource.CanvasMutation:
case IncrementalSource.Input: {
this.replaceIds(e.data, iframeEl, ['id']);
return e;
}
case IncrementalSource.StyleSheetRule:
case IncrementalSource.StyleDeclaration: {
this.replaceIds(e.data, iframeEl, ['id']);
this.replaceStyleIds(e.data, iframeEl, ['styleId']);
return e;
}
case IncrementalSource.Font: {
return e;
}
case IncrementalSource.Selection: {
e.data.ranges.forEach((range) => {
this.replaceIds(range, iframeEl, ['start', 'end']);
});
return e;
}
case IncrementalSource.AdoptedStyleSheet: {
this.replaceIds(e.data, iframeEl, ['id']);
this.replaceStyleIds(e.data, iframeEl, ['styleIds']);
(_a = e.data.styles) === null || _a === void 0 ? void 0 : _a.forEach((style) => {
this.replaceStyleIds(style, iframeEl, ['styleId']);
});
return e;
}
}
}
}
}
replace(iframeMirror, obj, iframeEl, keys) {
for (const key of keys) {
if (!Array.isArray(obj[key]) && typeof obj[key] !== 'number')
continue;
if (Array.isArray(obj[key])) {
obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
}
else {
obj[key] = iframeMirror.getId(iframeEl, obj[key]);
}
}
return obj;
}
replaceIds(obj, iframeEl, keys) {
return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
}
replaceStyleIds(obj, iframeEl, keys) {
return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
}
replaceIdOnNode(node, iframeEl) {
this.replaceIds(node, iframeEl, ['id']);
if ('childNodes' in node) {
node.childNodes.forEach((child) => {
this.replaceIdOnNode(child, iframeEl);
});
}
}
}
export { IframeManager };
import { createMirror, snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { initObservers, mutationBuffers } from './observer.js';
import { polyfill, on, getWindowWidth, getWindowHeight, isSerializedIframe, isSerializedStylesheet, hasShadowRoot } from '../utils.js';
import { EventType, IncrementalSource } from '../types.js';
import { EventType, IncrementalSource } from '../../../types/dist/types.js';
import { IframeManager } from './iframe-manager.js';

@@ -16,6 +16,20 @@ import { ShadowDomManager } from './shadow-dom-manager.js';

let canvasManager;
let recording = false;
const mirror = createMirror();
function record(options = {}) {
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = new Set([]), } = options;
if (!emit) {
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordCanvas = false, recordCrossOriginIframes = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = new Set([]), } = options;
const inEmittingFrame = recordCrossOriginIframes
? window.parent === window
: true;
let passEmitsToParent = false;
if (!inEmittingFrame) {
try {
window.parent.document;
passEmitsToParent = false;
}
catch (e) {
passEmitsToParent = true;
}
}
if (inEmittingFrame && !emit) {
throw new Error('emit function is required');

@@ -68,6 +82,2 @@ }

let incrementalSnapshotCount = 0;
for (const plugin of plugins || []) {
if (plugin.getMirror)
plugin.getMirror(mirror);
}
const eventProcessor = (e) => {

@@ -92,3 +102,13 @@ for (const plugin of plugins || []) {

}
emit(eventProcessor(e), isCheckout);
if (inEmittingFrame) {
emit === null || emit === void 0 ? void 0 : emit(eventProcessor(e), isCheckout);
}
else if (passEmitsToParent) {
const message = {
type: 'rrweb',
event: eventProcessor(e),
isCheckout,
};
window.parent.postMessage(message, '*');
}
if (e.type === EventType.FullSnapshot) {

@@ -135,5 +155,16 @@ lastFullSnapshotEvent = e;

const iframeManager = new IframeManager({
mirror,
mutationCb: wrappedMutationEmit,
stylesheetManager: stylesheetManager,
recordCrossOriginIframes,
wrappedEmit,
});
for (const plugin of plugins || []) {
if (plugin.getMirror)
plugin.getMirror({
nodeMirror: mirror,
crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror,
});
}
canvasManager = new CanvasManager({

@@ -210,3 +241,3 @@ recordCanvas,

onIframeLoad: (iframe, childSn) => {
iframeManager.attachIframe(iframe, childSn, mirror);
iframeManager.attachIframe(iframe, childSn);
shadowDomManager.observeAttachShadow(iframe);

@@ -344,2 +375,3 @@ },

handlers.push(observe(document));
recording = true;
};

@@ -361,4 +393,3 @@ if (document.readyState === 'interactive' ||

handlers.forEach((h) => h());
wrappedEmit = undefined;
takeFullSnapshot = undefined;
recording = false;
};

@@ -371,3 +402,3 @@ }

record.addCustomEvent = (tag, payload) => {
if (!wrappedEmit) {
if (!recording) {
throw new Error('please add custom event after start recording');

@@ -387,3 +418,3 @@ }

record.takeFullSnapshot = (isCheckout) => {
if (!takeFullSnapshot) {
if (!recording) {
throw new Error('please take full snapshot after start recording');

@@ -390,0 +421,0 @@ }

@@ -99,3 +99,2 @@ import { isShadowRoot, isNativeShadowDom, maskInputValue, transformAttribute, needMaskingText, IGNORED_NODE, serializeNodeWithId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';

this.emit = () => {
var _a;
if (this.frozen || this.locked) {

@@ -116,11 +115,12 @@ return;

const pushAdd = (n) => {
var _a, _b, _c, _d, _e;
const shadowHost = n.getRootNode
? (_a = n.getRootNode()) === null || _a === void 0 ? void 0 : _a.host
: null;
var _a, _b, _c, _d;
let shadowHost = null;
if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
n.getRootNode().host)
shadowHost = n.getRootNode().host;
let rootShadowHost = shadowHost;
while ((_c = (_b = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _b === void 0 ? void 0 : _b.call(rootShadowHost)) === null || _c === void 0 ? void 0 : _c.host)
rootShadowHost =
((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
null;
while (((_d = (_c = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _c === void 0 ? void 0 : _c.call(rootShadowHost)) === null || _d === void 0 ? void 0 : _d.nodeType) ===
Node.DOCUMENT_FRAGMENT_NODE &&
rootShadowHost.getRootNode().host)
rootShadowHost = rootShadowHost.getRootNode().host;
const notInDoc = !this.doc.contains(n) &&

@@ -163,7 +163,7 @@ (!rootShadowHost || !this.doc.contains(rootShadowHost));

if (hasShadowRoot(n)) {
this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
this.shadowDomManager.addShadowRoot(n.shadowRoot, this.doc);
}
},
onIframeLoad: (iframe, childSn) => {
this.iframeManager.attachIframe(iframe, childSn, this.mirror);
this.iframeManager.attachIframe(iframe, childSn);
this.shadowDomManager.observeAttachShadow(iframe);

@@ -228,10 +228,13 @@ },

else {
const nodeInShadowDom = _node.value;
const shadowHost = nodeInShadowDom.getRootNode
? (_a = nodeInShadowDom.getRootNode()) === null || _a === void 0 ? void 0 : _a.host
: null;
const parentId = this.mirror.getId(shadowHost);
if (parentId !== -1) {
node = _node;
break;
const unhandledNode = _node.value;
if (unhandledNode.parentNode &&
unhandledNode.parentNode.nodeType ===
Node.DOCUMENT_FRAGMENT_NODE) {
const shadowHost = unhandledNode.parentNode
.host;
const parentId = this.mirror.getId(shadowHost);
if (parentId !== -1) {
node = _node;
break;
}
}

@@ -238,0 +241,0 @@ }

import { maskInputValue } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { on, throttle, isBlocked, getWindowHeight, getWindowWidth, hookSetter, patch, isTouchEvent } from '../utils.js';
import { MouseInteractions, IncrementalSource } from '../types.js';
import { MouseInteractions, IncrementalSource } from '../../../types/dist/types.js';
import MutationBuffer from './mutation.js';

@@ -5,0 +5,0 @@

@@ -1,2 +0,2 @@

import { CanvasContext } from '../../../types.js';
import { CanvasContext } from '../../../../../types/dist/types.js';
import { patch, isBlocked, hookSetter } from '../../../utils.js';

@@ -3,0 +3,0 @@ import { serializeArgs } from './serialize-args.js';

import { __rest, __awaiter } from './../../../../../../ext/tslib/tslib.es6.js';
import { isBlocked } from '../../../utils.js';
import { CanvasContext } from '../../../types.js';
import { CanvasContext } from '../../../../../types/dist/types.js';
import initCanvas2DMutationObserver from './2d.js';

@@ -5,0 +5,0 @@ import initCanvasContextObserver from './canvas.js';

@@ -1,2 +0,2 @@

import { CanvasContext } from '../../../types.js';
import { CanvasContext } from '../../../../../types/dist/types.js';
import { patch, isBlocked, hookSetter } from '../../../utils.js';

@@ -9,2 +9,10 @@ import { saveWebGLVar, serializeArgs } from './serialize-args.js';

for (const prop of props) {
if ([
'isContextLost',
'canvas',
'drawingBufferWidth',
'drawingBufferHeight',
].includes(prop)) {
continue;
}
try {

@@ -17,5 +25,5 @@ if (typeof prototype[prop] !== 'function') {

const result = original.apply(this, args);
saveWebGLVar(result, win, prototype);
saveWebGLVar(result, win, this);
if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
const recordArgs = serializeArgs([...args], win, prototype);
const recordArgs = serializeArgs([...args], win, this);
const mutation = {

@@ -22,0 +30,0 @@ type,

import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
import { CanvasContext } from '../../types.js';
import { CanvasContext } from '../../../../types/dist/types.js';
import webglMutation from './webgl.js';

@@ -4,0 +4,0 @@ import canvasMutation$1 from './2d.js';

import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
import { CanvasContext } from '../../types.js';
import { CanvasContext } from '../../../../types/dist/types.js';
import { deserializeArg, variableListFor } from './deserialize-args.js';

@@ -4,0 +4,0 @@

import { interpret as v, createMachine as s, assign as o } from './../../../../ext/@xstate/fsm/es/index.js';
import { EventType, IncrementalSource, ReplayerEvents } from '../types.js';
import { EventType, IncrementalSource, ReplayerEvents } from '../../../types/dist/types.js';
import { addDelay } from './timer.js';

@@ -4,0 +4,0 @@

@@ -1,2 +0,2 @@

import { EventType, IncrementalSource } from '../types.js';
import { EventType, IncrementalSource } from '../../../types/dist/types.js';

@@ -3,0 +3,0 @@ class Timer {

@@ -338,4 +338,7 @@ import { classMatchesRegex, IGNORED_NODE, isShadowRoot } from '../../rrweb-snapshot/es/rrweb-snapshot.js';

}
generateId() {
return this.id++;
}
}
export { StyleSheetMirror, _mirror, getBaseDimension, getNestedRule, getPositionsAndIndex, getWindowHeight, getWindowWidth, hasShadowRoot, hookSetter, isAncestorRemoved, isBlocked, isIgnored, isSerialized, isSerializedIframe, isSerializedStylesheet, isTouchEvent, iterateResolveTree, on, patch, polyfill, queueToResolveTrees, throttle, uniqueTextMutations };

@@ -1179,3 +1179,10 @@ 'use strict';

this.streamMap = new Map();
this.incomingStreams = new Set();
this.outgoingStreams = new Set();
this.streamNodeMap = new Map();
this.canvasWindowMap = new Map();
this.windowPeerMap = new WeakMap();
this.peerWindowMap = new WeakMap();
this.signalSendCallback = signalSendCallback;
window.addEventListener('message', this.windowPostMessageHandler.bind(this));
if (peer)

@@ -1187,4 +1194,5 @@ this.peer = peer;

name: PLUGIN_NAME,
getMirror: (mirror) => {
this.mirror = mirror;
getMirror: ({ nodeMirror, crossOriginIframeMirror }) => {
this.mirror = nodeMirror;
this.crossOriginIframeMirror = crossOriginIframeMirror;
},

@@ -1200,6 +1208,10 @@ options: {},

}
signalReceiveFromCrossOriginIframe(signal, source) {
const peer = this.setupPeer(source);
peer.signal(signal);
}
startStream(id, stream) {
var _a, _b;
if (!this.peer)
return this.setupPeer();
this.setupPeer();
const data = {

@@ -1210,31 +1222,95 @@ nodeId: id,

(_a = this.peer) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(data));
(_b = this.peer) === null || _b === void 0 ? void 0 : _b.addStream(stream);
if (!this.outgoingStreams.has(stream))
(_b = this.peer) === null || _b === void 0 ? void 0 : _b.addStream(stream);
this.outgoingStreams.add(stream);
}
setupPeer() {
if (!this.peer) {
this.peer = new Peer({
setupPeer(source) {
let peer;
if (!source) {
if (this.peer)
return this.peer;
peer = this.peer = new Peer({
initiator: true,
});
this.peer.on('error', (err) => {
this.peer = null;
console.log('error', err);
}
else {
const peerFromMap = this.windowPeerMap.get(source);
if (peerFromMap)
return peerFromMap;
peer = new Peer({
initiator: false,
});
this.peer.on('close', () => {
this.peer = null;
console.log('closing');
});
this.peer.on('signal', (data) => {
this.signalSendCallback(data);
});
this.peer.on('connect', () => {
for (const [id, stream] of this.streamMap) {
this.startStream(id, stream);
this.windowPeerMap.set(source, peer);
this.peerWindowMap.set(peer, source);
}
const resetPeer = (source) => {
if (!source)
return (this.peer = null);
this.windowPeerMap.delete(source);
this.peerWindowMap.delete(peer);
};
peer.on('error', (err) => {
resetPeer(source);
console.log('error', err);
});
peer.on('close', () => {
resetPeer(source);
console.log('closing');
});
peer.on('signal', (data) => {
var _a, _b;
if (this.inRootFrame()) {
if (peer === this.peer) {
this.signalSendCallback(data);
}
});
}
else {
(_a = this.peerWindowMap.get(peer)) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'rrweb-canvas-webrtc',
data: {
type: 'signal',
signal: data,
},
}, '*');
}
}
else {
(_b = window.top) === null || _b === void 0 ? void 0 : _b.postMessage({
type: 'rrweb-canvas-webrtc',
data: {
type: 'signal',
signal: data,
},
}, '*');
}
});
peer.on('connect', () => {
if (this.inRootFrame() && peer !== this.peer)
return;
for (const [id, stream] of this.streamMap) {
this.startStream(id, stream);
}
});
if (!this.inRootFrame())
return peer;
peer.on('data', (data) => {
try {
const json = JSON.parse(data);
this.streamNodeMap.set(json.streamId, json.nodeId);
}
catch (error) {
console.error('Could not parse data', error);
}
this.flushStreams();
});
peer.on('stream', (stream) => {
this.incomingStreams.add(stream);
this.flushStreams();
});
return peer;
}
setupStream(id) {
setupStream(id, rootId) {
var _a;
if (id === -1)
return false;
let stream = this.streamMap.get(id);
let stream = this.streamMap.get(rootId || id);
if (stream)

@@ -1244,8 +1320,84 @@ return stream;

if (!el || !('captureStream' in el))
return false;
return this.setupStreamInCrossOriginIframe(id, rootId || id);
if (!this.inRootFrame()) {
(_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'rrweb-canvas-webrtc',
data: {
type: 'i-have-canvas',
rootId: rootId || id,
},
}, '*');
}
stream = el.captureStream();
this.streamMap.set(id, stream);
this.streamMap.set(rootId || id, stream);
this.setupPeer();
return stream;
}
flushStreams() {
this.incomingStreams.forEach((stream) => {
const nodeId = this.streamNodeMap.get(stream.id);
if (!nodeId)
return;
this.startStream(nodeId, stream);
});
}
inRootFrame() {
return Boolean(window.top && window.top === window);
}
setupStreamInCrossOriginIframe(id, rootId) {
let found = false;
document.querySelectorAll('iframe').forEach((iframe) => {
var _a;
if (found)
return;
const remoteId = this.crossOriginIframeMirror.getRemoteId(iframe, id);
if (remoteId === -1)
return;
found = true;
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'rrweb-canvas-webrtc',
data: {
type: 'who-has-canvas',
id: remoteId,
rootId,
},
}, '*');
});
return found;
}
isCrossOriginIframeMessageEventContent(event) {
return Boolean('type' in event.data &&
'data' in event.data &&
event.data.type ===
'rrweb-canvas-webrtc' &&
event.data.data);
}
windowPostMessageHandler(event) {
if (!this.isCrossOriginIframeMessageEventContent(event))
return;
const { type } = event.data.data;
if (type === 'who-has-canvas') {
const { id, rootId } = event.data.data;
this.setupStream(id, rootId);
}
else if (type === 'signal') {
const { signal } = event.data.data;
const { source } = event;
if (!source || !('self' in source))
return;
if (this.inRootFrame()) {
this.signalReceiveFromCrossOriginIframe(signal, source);
}
else {
this.signalReceive(signal);
}
}
else if (type === 'i-have-canvas') {
const { rootId } = event.data.data;
const { source } = event;
if (!source || !('self' in source))
return;
this.canvasWindowMap.set(rootId, source);
}
}
}

@@ -1252,0 +1404,0 @@

@@ -1190,4 +1190,4 @@ 'use strict';

},
getMirror: (mirror) => {
this.mirror = mirror;
getMirror: (options) => {
this.mirror = options.nodeMirror;
},

@@ -1194,0 +1194,0 @@ };

@@ -54,79 +54,31 @@ 'use strict';

var EventType;
(function (EventType) {
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
EventType[EventType["Load"] = 1] = "Load";
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
EventType[EventType["Meta"] = 4] = "Meta";
EventType[EventType["Custom"] = 5] = "Custom";
EventType[EventType["Plugin"] = 6] = "Plugin";
})(EventType || (EventType = {}));
var IncrementalSource;
(function (IncrementalSource) {
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove";
IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction";
IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll";
IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize";
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove";
IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction";
IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule";
IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation";
IncrementalSource[IncrementalSource["Font"] = 10] = "Font";
IncrementalSource[IncrementalSource["Log"] = 11] = "Log";
IncrementalSource[IncrementalSource["Drag"] = 12] = "Drag";
IncrementalSource[IncrementalSource["StyleDeclaration"] = 13] = "StyleDeclaration";
IncrementalSource[IncrementalSource["Selection"] = 14] = "Selection";
IncrementalSource[IncrementalSource["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
})(IncrementalSource || (IncrementalSource = {}));
var MouseInteractions;
(function (MouseInteractions) {
MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp";
MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown";
MouseInteractions[MouseInteractions["Click"] = 2] = "Click";
MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu";
MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick";
MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus";
MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur";
MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart";
MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed";
MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd";
MouseInteractions[MouseInteractions["TouchCancel"] = 10] = "TouchCancel";
})(MouseInteractions || (MouseInteractions = {}));
var CanvasContext;
(function (CanvasContext) {
CanvasContext[CanvasContext["2D"] = 0] = "2D";
CanvasContext[CanvasContext["WebGL"] = 1] = "WebGL";
CanvasContext[CanvasContext["WebGL2"] = 2] = "WebGL2";
})(CanvasContext || (CanvasContext = {}));
var MediaInteractions;
(function (MediaInteractions) {
MediaInteractions[MediaInteractions["Play"] = 0] = "Play";
MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause";
MediaInteractions[MediaInteractions["Seeked"] = 2] = "Seeked";
MediaInteractions[MediaInteractions["VolumeChange"] = 3] = "VolumeChange";
MediaInteractions[MediaInteractions["RateChange"] = 4] = "RateChange";
})(MediaInteractions || (MediaInteractions = {}));
var ReplayerEvents;
(function (ReplayerEvents) {
ReplayerEvents["Start"] = "start";
ReplayerEvents["Pause"] = "pause";
ReplayerEvents["Resume"] = "resume";
ReplayerEvents["Resize"] = "resize";
ReplayerEvents["Finish"] = "finish";
ReplayerEvents["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded";
ReplayerEvents["LoadStylesheetStart"] = "load-stylesheet-start";
ReplayerEvents["LoadStylesheetEnd"] = "load-stylesheet-end";
ReplayerEvents["SkipStart"] = "skip-start";
ReplayerEvents["SkipEnd"] = "skip-end";
ReplayerEvents["MouseInteraction"] = "mouse-interaction";
ReplayerEvents["EventCast"] = "event-cast";
ReplayerEvents["CustomEvent"] = "custom-event";
ReplayerEvents["Flush"] = "flush";
ReplayerEvents["StateChange"] = "state-change";
ReplayerEvents["PlayBack"] = "play-back";
ReplayerEvents["Destroy"] = "destroy";
})(ReplayerEvents || (ReplayerEvents = {}));
var EventType = /* @__PURE__ */ ((EventType2) => {
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
EventType2[EventType2["Load"] = 1] = "Load";
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
EventType2[EventType2["Meta"] = 4] = "Meta";
EventType2[EventType2["Custom"] = 5] = "Custom";
EventType2[EventType2["Plugin"] = 6] = "Plugin";
return EventType2;
})(EventType || {});
var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
return IncrementalSource2;
})(IncrementalSource || {});

@@ -133,0 +85,0 @@ const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';

@@ -52,80 +52,2 @@ 'use strict';

var EventType;
(function (EventType) {
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
EventType[EventType["Load"] = 1] = "Load";
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
EventType[EventType["Meta"] = 4] = "Meta";
EventType[EventType["Custom"] = 5] = "Custom";
EventType[EventType["Plugin"] = 6] = "Plugin";
})(EventType || (EventType = {}));
var IncrementalSource;
(function (IncrementalSource) {
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove";
IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction";
IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll";
IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize";
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove";
IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction";
IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule";
IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation";
IncrementalSource[IncrementalSource["Font"] = 10] = "Font";
IncrementalSource[IncrementalSource["Log"] = 11] = "Log";
IncrementalSource[IncrementalSource["Drag"] = 12] = "Drag";
IncrementalSource[IncrementalSource["StyleDeclaration"] = 13] = "StyleDeclaration";
IncrementalSource[IncrementalSource["Selection"] = 14] = "Selection";
IncrementalSource[IncrementalSource["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
})(IncrementalSource || (IncrementalSource = {}));
var MouseInteractions;
(function (MouseInteractions) {
MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp";
MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown";
MouseInteractions[MouseInteractions["Click"] = 2] = "Click";
MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu";
MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick";
MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus";
MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur";
MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart";
MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed";
MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd";
MouseInteractions[MouseInteractions["TouchCancel"] = 10] = "TouchCancel";
})(MouseInteractions || (MouseInteractions = {}));
var CanvasContext;
(function (CanvasContext) {
CanvasContext[CanvasContext["2D"] = 0] = "2D";
CanvasContext[CanvasContext["WebGL"] = 1] = "WebGL";
CanvasContext[CanvasContext["WebGL2"] = 2] = "WebGL2";
})(CanvasContext || (CanvasContext = {}));
var MediaInteractions;
(function (MediaInteractions) {
MediaInteractions[MediaInteractions["Play"] = 0] = "Play";
MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause";
MediaInteractions[MediaInteractions["Seeked"] = 2] = "Seeked";
MediaInteractions[MediaInteractions["VolumeChange"] = 3] = "VolumeChange";
MediaInteractions[MediaInteractions["RateChange"] = 4] = "RateChange";
})(MediaInteractions || (MediaInteractions = {}));
var ReplayerEvents;
(function (ReplayerEvents) {
ReplayerEvents["Start"] = "start";
ReplayerEvents["Pause"] = "pause";
ReplayerEvents["Resume"] = "resume";
ReplayerEvents["Resize"] = "resize";
ReplayerEvents["Finish"] = "finish";
ReplayerEvents["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded";
ReplayerEvents["LoadStylesheetStart"] = "load-stylesheet-start";
ReplayerEvents["LoadStylesheetEnd"] = "load-stylesheet-end";
ReplayerEvents["SkipStart"] = "skip-start";
ReplayerEvents["SkipEnd"] = "skip-end";
ReplayerEvents["MouseInteraction"] = "mouse-interaction";
ReplayerEvents["EventCast"] = "event-cast";
ReplayerEvents["CustomEvent"] = "custom-event";
ReplayerEvents["Flush"] = "flush";
ReplayerEvents["StateChange"] = "state-change";
ReplayerEvents["PlayBack"] = "play-back";
ReplayerEvents["Destroy"] = "destroy";
})(ReplayerEvents || (ReplayerEvents = {}));
/*

@@ -132,0 +54,0 @@ * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>

{
"name": "rrweb",
"version": "2.0.0-alpha.3",
"version": "2.0.0-alpha.4",
"description": "record and replay the web",

@@ -53,3 +53,3 @@ "scripts": {

"@types/jest": "^27.4.1",
"@types/jest-image-snapshot": "^4.3.1",
"@types/jest-image-snapshot": "^5.1.0",
"@types/node": "^17.0.21",

@@ -67,6 +67,6 @@ "@types/offscreencanvas": "^2019.6.4",

"jest": "^27.5.1",
"jest-image-snapshot": "^4.5.1",
"jest-image-snapshot": "^5.2.0",
"jest-snapshot": "^23.6.0",
"prettier": "2.2.1",
"puppeteer": "^9.1.1",
"puppeteer": "^11.0.0",
"rollup": "^2.68.0",

@@ -85,2 +85,3 @@ "rollup-plugin-esbuild": "^4.9.1",

"dependencies": {
"@rrweb/types": "^2.0.0-alpha.4",
"@types/css-font-loading-module": "0.0.7",

@@ -91,6 +92,5 @@ "@xstate/fsm": "^1.4.0",

"mitt": "^3.0.0",
"rrdom": "^0.1.6",
"rrweb-snapshot": "^2.0.0-alpha.3"
},
"gitHead": "e86d482ffd2f7b58ae1d6b67702ad5dc32bed0b5"
"rrdom": "^0.1.7",
"rrweb-snapshot": "^2.0.0-alpha.4"
}
}

@@ -5,5 +5,5 @@ import record from './record';

import * as utils from './utils';
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents, } from './types';
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents, } from '@rrweb/types';
declare const addCustomEvent: <T>(tag: string, payload: T) => void;
declare const freezePage: () => void;
export { record, addCustomEvent, freezePage, Replayer, _mirror as mirror, utils, };

@@ -1,2 +0,2 @@

import type { eventWithTime } from '../types';
import type { eventWithTime } from '@rrweb/types';
export declare type PackFn = (event: eventWithTime) => string;

@@ -3,0 +3,0 @@ export declare type UnpackFn = (raw: string) => eventWithTime;

import SimplePeer from 'simple-peer-light';
import type { RecordPlugin } from '../../../types';
import type { RecordPlugin } from '@rrweb/types';
export declare const PLUGIN_NAME = "rrweb/canvas-webrtc@1";
export declare type CrossOriginIframeMessageEventContent = {
type: 'rrweb-canvas-webrtc';
data: {
type: 'signal';
signal: RTCSessionDescriptionInit;
} | {
type: 'who-has-canvas';
rootId: number;
id: number;
} | {
type: 'i-have-canvas';
rootId: number;
};
};
export declare class RRWebPluginCanvasWebRTCRecord {
private peer;
private mirror;
private crossOriginIframeMirror;
private streamMap;
private incomingStreams;
private outgoingStreams;
private streamNodeMap;
private canvasWindowMap;
private windowPeerMap;
private peerWindowMap;
private signalSendCallback;

@@ -15,5 +36,11 @@ constructor({ signalSendCallback, peer, }: {

signalReceive(signal: RTCSessionDescriptionInit): void;
signalReceiveFromCrossOriginIframe(signal: RTCSessionDescriptionInit, source: WindowProxy): void;
private startStream;
setupPeer(): void;
setupStream(id: number): false | MediaStream;
setupPeer(source?: WindowProxy): SimplePeer.Instance;
setupStream(id: number, rootId?: number): boolean | MediaStream;
private flushStreams;
private inRootFrame;
setupStreamInCrossOriginIframe(id: number, rootId: number): boolean;
private isCrossOriginIframeMessageEventContent;
private windowPostMessageHandler;
}

@@ -1,2 +0,2 @@

import type { RecordPlugin } from '../../../types';
import type { RecordPlugin } from '@rrweb/types';
export declare type StringifyOptions = {

@@ -3,0 +3,0 @@ stringLengthLimit?: number;

import { LogLevel, LogData } from '../record';
import { ReplayPlugin } from '../../../types';
import type { ReplayPlugin } from '../../../types';
declare type ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;

@@ -4,0 +4,0 @@ declare type LogReplayConfig = {

@@ -1,2 +0,2 @@

import type { RecordPlugin } from '../../../types';
import type { RecordPlugin } from '@rrweb/types';
export declare type SequentialIdOptions = {

@@ -3,0 +3,0 @@ key: string;

import type { Mirror, serializedNodeWithId } from 'rrweb-snapshot';
import type { mutationCallBack } from '../types';
import CrossOriginIframeMirror from './cross-origin-iframe-mirror';
import type { eventWithTime, mutationCallBack } from '@rrweb/types';
import type { StylesheetManager } from './stylesheet-manager';
export declare class IframeManager {
private iframes;
private crossOriginIframeMap;
crossOriginIframeMirror: CrossOriginIframeMirror;
crossOriginIframeStyleMirror: CrossOriginIframeMirror;
private mirror;
private mutationCb;
private wrappedEmit;
private loadListener?;
private stylesheetManager;
private recordCrossOriginIframes;
constructor(options: {
mirror: Mirror;
mutationCb: mutationCallBack;
stylesheetManager: StylesheetManager;
recordCrossOriginIframes: boolean;
wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
});
addIframe(iframeEl: HTMLIFrameElement): void;
addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown): void;
attachIframe(iframeEl: HTMLIFrameElement, childSn: serializedNodeWithId, mirror: Mirror): void;
attachIframe(iframeEl: HTMLIFrameElement, childSn: serializedNodeWithId): void;
private handleMessage;
private transformCrossOriginEvent;
private replace;
private replaceIds;
private replaceStyleIds;
private replaceIdOnNode;
}

@@ -1,2 +0,3 @@

import { eventWithTime, recordOptions, listenerHandler } from '../types';
import type { recordOptions } from '../types';
import { eventWithTime, listenerHandler } from '@rrweb/types';
declare function record<T = eventWithTime>(options?: recordOptions<T>): listenerHandler | undefined;

@@ -3,0 +4,0 @@ declare namespace record {

@@ -1,2 +0,3 @@

import type { mutationRecord, MutationBufferParam } from '../types';
import type { MutationBufferParam } from '../types';
import type { mutationRecord } from '@rrweb/types';
export default class MutationBuffer {

@@ -3,0 +4,0 @@ private frozen;

@@ -1,2 +0,3 @@

import { observerParam, listenerHandler, hooksParam, MutationBufferParam } from '../types';
import type { observerParam, MutationBufferParam } from '../types';
import { listenerHandler, hooksParam } from '@rrweb/types';
import MutationBuffer from './mutation';

@@ -3,0 +4,0 @@ export declare const mutationBuffers: MutationBuffer[];

@@ -1,2 +0,2 @@

import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '../../../types';
import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '@rrweb/types';
export default function initCanvas2DMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, blockSelector: string | null): listenerHandler;
import type { Mirror, DataURLOptions } from 'rrweb-snapshot';
import type { blockClass, canvasMutationCallback, IWindow } from '../../../types';
import type { blockClass, canvasMutationCallback, IWindow } from '@rrweb/types';
export declare type RafStamps = {

@@ -4,0 +4,0 @@ latestId: number;

@@ -1,2 +0,2 @@

import type { blockClass, IWindow, listenerHandler } from '../../../types';
import type { blockClass, IWindow, listenerHandler } from '@rrweb/types';
export default function initCanvasContextObserver(win: IWindow, blockClass: blockClass, blockSelector: string | null): listenerHandler;

@@ -1,2 +0,2 @@

import type { IWindow, CanvasArg } from '../../../types';
import type { IWindow, CanvasArg } from '@rrweb/types';
export declare function variableListFor(ctx: RenderingContext, ctor: string): unknown[];

@@ -3,0 +3,0 @@ export declare const saveWebGLVar: (value: unknown, win: IWindow, ctx: RenderingContext) => number | void;

import type { Mirror } from 'rrweb-snapshot';
import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '../../../types';
import { blockClass, canvasManagerMutationCallback, IWindow, listenerHandler } from '@rrweb/types';
export default function initCanvasWebGLMutationObserver(cb: canvasManagerMutationCallback, win: IWindow, blockClass: blockClass, blockSelector: string | null, mirror: Mirror): listenerHandler;

@@ -1,2 +0,3 @@

import type { mutationCallBack, scrollCallback, MutationBufferParam, SamplingStrategy } from '../types';
import type { MutationBufferParam } from '../types';
import type { mutationCallBack, scrollCallback, SamplingStrategy } from '@rrweb/types';
import type { Mirror } from 'rrweb-snapshot';

@@ -3,0 +4,0 @@ declare type BypassOptions = Omit<MutationBufferParam, 'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'> & {

import type { serializedNodeWithId } from 'rrweb-snapshot';
import type { adoptedStyleSheetCallback, mutationCallBack } from '../types';
import type { adoptedStyleSheetCallback, mutationCallBack } from '@rrweb/types';
import { StyleSheetMirror } from '../utils';

@@ -4,0 +4,0 @@ export declare class StylesheetManager {

@@ -1,2 +0,2 @@

import type { ImageBitmapDataURLWorkerParams, ImageBitmapDataURLWorkerResponse } from '../../types';
import type { ImageBitmapDataURLWorkerParams, ImageBitmapDataURLWorkerResponse } from '@rrweb/types';
export interface ImageBitmapDataURLRequestWorker {

@@ -3,0 +3,0 @@ postMessage: (message: ImageBitmapDataURLWorkerParams, transfer?: [ImageBitmap]) => void;

import type { Replayer } from '../';
import type { canvasMutationCommand } from '../../types';
import type { canvasMutationCommand } from '@rrweb/types';
export default function canvasMutation({ event, mutation, target, imageMap, errorHandler, }: {

@@ -4,0 +4,0 @@ event: Parameters<Replayer['applyIncremental']>[0];

import type { Replayer } from '../';
import type { CanvasArg, SerializedCanvasArg } from '../../types';
import type { CanvasArg, SerializedCanvasArg } from '@rrweb/types';
export declare function variableListFor(ctx: CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext, ctor: string): any[];

@@ -4,0 +4,0 @@ export declare function isSerializedArg(arg: unknown): arg is SerializedCanvasArg;

import type { Replayer } from '..';
import { canvasMutationData } from '../../types';
import { canvasMutationData } from '@rrweb/types';
export default function canvasMutation({ event, mutation, target, imageMap, canvasEventMap, errorHandler, }: {

@@ -4,0 +4,0 @@ event: Parameters<Replayer['applyIncremental']>[0];

import type { Replayer } from '../';
import { CanvasContext, canvasMutationCommand } from '../../types';
import { CanvasContext, canvasMutationCommand } from '@rrweb/types';
export default function webglMutation({ mutation, target, type, imageMap, errorHandler, }: {

@@ -4,0 +4,0 @@ mutation: canvasMutationCommand;

@@ -5,3 +5,4 @@ import { Mirror } from 'rrweb-snapshot';

import { createPlayerService, createSpeedService } from './machine';
import { eventWithTime, playerConfig, playerMetaData, Handler } from '../types';
import type { playerConfig } from '../types';
import { eventWithTime, playerMetaData, Handler } from '@rrweb/types';
import './styles/style.css';

@@ -8,0 +9,0 @@ export declare class Replayer {

import { StateMachine } from '@xstate/fsm';
import { playerConfig, eventWithTime, Emitter } from '../types';
import type { playerConfig } from '../types';
import { eventWithTime, Emitter } from '@rrweb/types';
import { Timer } from './timer';

@@ -4,0 +5,0 @@ export declare type PlayerContext = {

@@ -1,2 +0,2 @@

import { actionWithDelay, eventWithTime } from '../types';
import { actionWithDelay, eventWithTime } from '@rrweb/types';
export declare class Timer {

@@ -3,0 +3,0 @@ timeOffset: number;

@@ -1,2 +0,2 @@

import type { serializedNodeWithId, Mirror, INode, MaskInputOptions, SlimDOMOptions, MaskInputFn, MaskTextFn, DataURLOptions } from 'rrweb-snapshot';
import type { Mirror, MaskInputOptions, SlimDOMOptions, MaskInputFn, MaskTextFn, DataURLOptions } from 'rrweb-snapshot';
import type { PackFn, UnpackFn } from './packer/base';

@@ -9,142 +9,3 @@ import type { IframeManager } from './record/iframe-manager';

import type { StylesheetManager } from './record/stylesheet-manager';
export declare enum EventType {
DomContentLoaded = 0,
Load = 1,
FullSnapshot = 2,
IncrementalSnapshot = 3,
Meta = 4,
Custom = 5,
Plugin = 6
}
export declare type domContentLoadedEvent = {
type: EventType.DomContentLoaded;
data: unknown;
};
export declare type loadedEvent = {
type: EventType.Load;
data: unknown;
};
export declare type fullSnapshotEvent = {
type: EventType.FullSnapshot;
data: {
node: serializedNodeWithId;
initialOffset: {
top: number;
left: number;
};
};
};
export declare type incrementalSnapshotEvent = {
type: EventType.IncrementalSnapshot;
data: incrementalData;
};
export declare type metaEvent = {
type: EventType.Meta;
data: {
href: string;
width: number;
height: number;
};
};
export declare type customEvent<T = unknown> = {
type: EventType.Custom;
data: {
tag: string;
payload: T;
};
};
export declare type pluginEvent<T = unknown> = {
type: EventType.Plugin;
data: {
plugin: string;
payload: T;
};
};
export declare enum IncrementalSource {
Mutation = 0,
MouseMove = 1,
MouseInteraction = 2,
Scroll = 3,
ViewportResize = 4,
Input = 5,
TouchMove = 6,
MediaInteraction = 7,
StyleSheetRule = 8,
CanvasMutation = 9,
Font = 10,
Log = 11,
Drag = 12,
StyleDeclaration = 13,
Selection = 14,
AdoptedStyleSheet = 15
}
export declare type mutationData = {
source: IncrementalSource.Mutation;
} & mutationCallbackParam;
export declare type mousemoveData = {
source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
positions: mousePosition[];
};
export declare type mouseInteractionData = {
source: IncrementalSource.MouseInteraction;
} & mouseInteractionParam;
export declare type scrollData = {
source: IncrementalSource.Scroll;
} & scrollPosition;
export declare type viewportResizeData = {
source: IncrementalSource.ViewportResize;
} & viewportResizeDimension;
export declare type inputData = {
source: IncrementalSource.Input;
id: number;
} & inputValue;
export declare type mediaInteractionData = {
source: IncrementalSource.MediaInteraction;
} & mediaInteractionParam;
export declare type styleSheetRuleData = {
source: IncrementalSource.StyleSheetRule;
} & styleSheetRuleParam;
export declare type styleDeclarationData = {
source: IncrementalSource.StyleDeclaration;
} & styleDeclarationParam;
export declare type canvasMutationData = {
source: IncrementalSource.CanvasMutation;
} & canvasMutationParam;
export declare type fontData = {
source: IncrementalSource.Font;
} & fontParam;
export declare type selectionData = {
source: IncrementalSource.Selection;
} & selectionParam;
export declare type adoptedStyleSheetData = {
source: IncrementalSource.AdoptedStyleSheet;
} & adoptedStyleSheetParam;
export declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData;
export declare type event = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
export declare type eventWithTime = event & {
timestamp: number;
delay?: number;
};
export declare type canvasEventWithTime = eventWithTime & {
type: EventType.IncrementalSnapshot;
data: canvasMutationData;
};
export declare type blockClass = string | RegExp;
export declare type maskTextClass = string | RegExp;
export declare type SamplingStrategy = Partial<{
mousemove: boolean | number;
mousemoveCallback: number;
mouseInteraction: boolean | Record<string, boolean | undefined>;
scroll: number;
media: number;
input: 'all' | 'last';
canvas: 'all' | number;
}>;
export declare type RecordPlugin<TOptions = unknown> = {
name: string;
observer?: (cb: (...args: Array<unknown>) => void, win: IWindow, options: TOptions) => listenerHandler;
eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend;
getMirror?: (mirror: Mirror) => void;
options: TOptions;
};
import type { addedNodeMutation, blockClass, canvasMutationCallback, eventWithTime, fontCallback, hooksParam, inputCallback, IWindow, KeepIframeSrcFn, listenerHandler, maskTextClass, mediaInteractionCallback, mouseInteractionCallBack, mousemoveCallBack, mutationCallBack, RecordPlugin, SamplingStrategy, scrollCallback, selectionCallback, styleDeclarationCallback, styleSheetRuleCallback, viewportResizeCallback } from '@rrweb/types';
export declare type recordOptions<T> = {

@@ -171,2 +32,3 @@ emit?: (e: T, isCheckout?: boolean) => void;

recordCanvas?: boolean;
recordCrossOriginIframes?: boolean;
userTriggeredOnInput?: boolean;

@@ -223,270 +85,2 @@ collectFonts?: boolean;

export declare type MutationBufferParam = Pick<observerParam, 'mutationCb' | 'blockClass' | 'blockSelector' | 'maskTextClass' | 'maskTextSelector' | 'inlineStylesheet' | 'maskInputOptions' | 'maskTextFn' | 'maskInputFn' | 'keepIframeSrcFn' | 'recordCanvas' | 'inlineImages' | 'slimDOMOptions' | 'dataURLOptions' | 'doc' | 'mirror' | 'iframeManager' | 'stylesheetManager' | 'shadowDomManager' | 'canvasManager'>;
export declare type hooksParam = {
mutation?: mutationCallBack;
mousemove?: mousemoveCallBack;
mouseInteraction?: mouseInteractionCallBack;
scroll?: scrollCallback;
viewportResize?: viewportResizeCallback;
input?: inputCallback;
mediaInteaction?: mediaInteractionCallback;
styleSheetRule?: styleSheetRuleCallback;
styleDeclaration?: styleDeclarationCallback;
canvasMutation?: canvasMutationCallback;
font?: fontCallback;
selection?: selectionCallback;
};
export declare type mutationRecord = {
type: string;
target: Node;
oldValue: string | null;
addedNodes: NodeList;
removedNodes: NodeList;
attributeName: string | null;
};
export declare type textCursor = {
node: Node;
value: string | null;
};
export declare type textMutation = {
id: number;
value: string | null;
};
export declare type styleAttributeValue = {
[key: string]: styleValueWithPriority | string | false;
};
export declare type styleValueWithPriority = [string, string];
export declare type attributeCursor = {
node: Node;
attributes: {
[key: string]: string | styleAttributeValue | null;
};
};
export declare type attributeMutation = {
id: number;
attributes: {
[key: string]: string | styleAttributeValue | null;
};
};
export declare type removedNodeMutation = {
parentId: number;
id: number;
isShadow?: boolean;
};
export declare type addedNodeMutation = {
parentId: number;
previousId?: number | null;
nextId: number | null;
node: serializedNodeWithId;
};
export declare type mutationCallbackParam = {
texts: textMutation[];
attributes: attributeMutation[];
removes: removedNodeMutation[];
adds: addedNodeMutation[];
isAttachIframe?: true;
};
export declare type mutationCallBack = (m: mutationCallbackParam) => void;
export declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;
export declare type mousePosition = {
x: number;
y: number;
id: number;
timeOffset: number;
};
export declare type mouseMovePos = {
x: number;
y: number;
id: number;
debugData: incrementalData;
};
export declare enum MouseInteractions {
MouseUp = 0,
MouseDown = 1,
Click = 2,
ContextMenu = 3,
DblClick = 4,
Focus = 5,
Blur = 6,
TouchStart = 7,
TouchMove_Departed = 8,
TouchEnd = 9,
TouchCancel = 10
}
export declare enum CanvasContext {
'2D' = 0,
WebGL = 1,
WebGL2 = 2
}
export declare type SerializedCanvasArg = {
rr_type: 'ArrayBuffer';
base64: string;
} | {
rr_type: 'Blob';
data: Array<CanvasArg>;
type?: string;
} | {
rr_type: string;
src: string;
} | {
rr_type: string;
args: Array<CanvasArg>;
} | {
rr_type: string;
index: number;
};
export declare type CanvasArg = SerializedCanvasArg | string | number | boolean | null | CanvasArg[];
declare type mouseInteractionParam = {
type: MouseInteractions;
id: number;
x: number;
y: number;
};
export declare type mouseInteractionCallBack = (d: mouseInteractionParam) => void;
export declare type scrollPosition = {
id: number;
x: number;
y: number;
};
export declare type scrollCallback = (p: scrollPosition) => void;
export declare type styleSheetAddRule = {
rule: string;
index?: number | number[];
};
export declare type styleSheetDeleteRule = {
index: number | number[];
};
export declare type styleSheetRuleParam = {
id?: number;
styleId?: number;
removes?: styleSheetDeleteRule[];
adds?: styleSheetAddRule[];
replace?: string;
replaceSync?: string;
};
export declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;
export declare type adoptedStyleSheetParam = {
id: number;
styles?: {
styleId: number;
rules: styleSheetAddRule[];
}[];
styleIds: number[];
};
export declare type adoptedStyleSheetCallback = (a: adoptedStyleSheetParam) => void;
export declare type styleDeclarationParam = {
id?: number;
styleId?: number;
index: number[];
set?: {
property: string;
value: string | null;
priority: string | undefined;
};
remove?: {
property: string;
};
};
export declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;
export declare type canvasMutationCommand = {
property: string;
args: Array<unknown>;
setter?: true;
};
export declare type canvasMutationParam = {
id: number;
type: CanvasContext;
commands: canvasMutationCommand[];
} | ({
id: number;
type: CanvasContext;
} & canvasMutationCommand);
export declare type canvasMutationWithType = {
type: CanvasContext;
} & canvasMutationCommand;
export declare type canvasMutationCallback = (p: canvasMutationParam) => void;
export declare type canvasManagerMutationCallback = (target: HTMLCanvasElement, p: canvasMutationWithType) => void;
export declare type ImageBitmapDataURLWorkerParams = {
id: number;
bitmap: ImageBitmap;
width: number;
height: number;
dataURLOptions: DataURLOptions;
};
export declare type ImageBitmapDataURLWorkerResponse = {
id: number;
} | {
id: number;
type: string;
base64: string;
width: number;
height: number;
};
export declare type fontParam = {
family: string;
fontSource: string;
buffer: boolean;
descriptors?: FontFaceDescriptors;
};
export declare type fontCallback = (p: fontParam) => void;
export declare type viewportResizeDimension = {
width: number;
height: number;
};
export declare type viewportResizeCallback = (d: viewportResizeDimension) => void;
export declare type inputValue = {
text: string;
isChecked: boolean;
userTriggered?: boolean;
};
export declare type inputCallback = (v: inputValue & {
id: number;
}) => void;
export declare const enum MediaInteractions {
Play = 0,
Pause = 1,
Seeked = 2,
VolumeChange = 3,
RateChange = 4
}
export declare type mediaInteractionParam = {
type: MediaInteractions;
id: number;
currentTime?: number;
volume?: number;
muted?: boolean;
playbackRate?: number;
};
export declare type mediaInteractionCallback = (p: mediaInteractionParam) => void;
export declare type DocumentDimension = {
x: number;
y: number;
relativeScale: number;
absoluteScale: number;
};
export declare type SelectionRange = {
start: number;
startOffset: number;
end: number;
endOffset: number;
};
export declare type selectionParam = {
ranges: Array<SelectionRange>;
};
export declare type selectionCallback = (p: selectionParam) => void;
export declare type DeprecatedMirror = {
map: {
[key: number]: INode;
};
getId: (n: Node) => number;
getNode: (id: number) => INode | null;
removeNodeFromMap: (n: Node) => void;
has: (id: number) => boolean;
reset: () => void;
};
export declare type throttleOptions = {
leading?: boolean;
trailing?: boolean;
};
export declare type listenerHandler = () => void;
export declare type hookResetter = () => void;
export declare type ReplayPlugin = {

@@ -500,3 +94,5 @@ handler?: (event: eventWithTime, isSync: boolean, context: {

}) => void;
getMirror?: (mirror: Mirror) => void;
getMirror?: (mirrors: {
nodeMirror: Mirror;
}) => void;
};

@@ -527,7 +123,2 @@ export declare type playerConfig = {

};
export declare type playerMetaData = {
startTime: number;
endTime: number;
totalTime: number;
};
export declare type missingNode = {

@@ -540,33 +131,2 @@ node: Node | RRNode;

};
export declare type actionWithDelay = {
doAction: () => void;
delay: number;
};
export declare type Handler = (event?: unknown) => void;
export declare type Emitter = {
on(type: string, handler: Handler): void;
emit(type: string, event?: unknown): void;
off(type: string, handler: Handler): void;
};
export declare type Arguments<T> = T extends (...payload: infer U) => unknown ? U : unknown;
export declare enum ReplayerEvents {
Start = "start",
Pause = "pause",
Resume = "resume",
Resize = "resize",
Finish = "finish",
FullsnapshotRebuilded = "fullsnapshot-rebuilded",
LoadStylesheetStart = "load-stylesheet-start",
LoadStylesheetEnd = "load-stylesheet-end",
SkipStart = "skip-start",
SkipEnd = "skip-end",
MouseInteraction = "mouse-interaction",
EventCast = "event-cast",
CustomEvent = "custom-event",
Flush = "flush",
StateChange = "state-change",
PlayBack = "play-back",
Destroy = "destroy"
}
export declare type KeepIframeSrcFn = (src: string) => boolean;
declare global {

@@ -577,4 +137,7 @@ interface Window {

}
export declare type IWindow = Window & typeof globalThis;
export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
export {};
export declare type CrossOriginIframeMessageEventContent<T = eventWithTime> = {
type: 'rrweb';
event: T;
isCheckout?: boolean;
};
export declare type CrossOriginIframeMessageEvent = MessageEvent<CrossOriginIframeMessageEventContent>;

@@ -1,2 +0,2 @@

import type { throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, DocumentDimension, IWindow, DeprecatedMirror, textMutation } from './types';
import type { throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, DocumentDimension, IWindow, DeprecatedMirror, textMutation } from '@rrweb/types';
import type { IMirror, Mirror } from 'rrweb-snapshot';

@@ -51,3 +51,4 @@ import type { RRNode, RRIFrameElement } from 'rrdom';

reset(): void;
generateId(): number;
}
export {};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc