@highlight-run/rrweb 2.0.17 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/record/rrweb-record.js +3 -3
- package/dist/record/rrweb-record.min.js +3 -3
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.css +1 -1
- package/dist/replay/rrweb-replay-unpack.js +1 -1
- package/dist/replay/rrweb-replay-unpack.min.css +1 -1
- package/dist/replay/rrweb-replay-unpack.min.css.map +1 -1
- package/dist/replay/rrweb-replay-unpack.min.js +1 -1
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.css +1 -1
- package/dist/replay/rrweb-replay.js +1 -1
- package/dist/replay/rrweb-replay.min.css +1 -1
- package/dist/replay/rrweb-replay.min.css.map +1 -1
- package/dist/replay/rrweb-replay.min.js +1 -1
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.css +1 -1
- package/dist/rrweb-all.js +8 -8
- package/dist/rrweb-all.min.css +1 -1
- package/dist/rrweb-all.min.css.map +1 -1
- package/dist/rrweb-all.min.js +8 -8
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.css +1 -1
- package/dist/rrweb.js +5 -5
- package/dist/rrweb.min.css +1 -1
- package/dist/rrweb.min.css.map +1 -1
- package/dist/rrweb.min.js +5 -5
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/all.css +1 -1
- package/es/rrweb/packages/rrweb/src/record/index.js +3 -3
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +3 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +0 -1
- package/lib/record/rrweb-record.js +5 -2
- package/lib/replay/rrweb-replay-unpack.css +1 -1
- package/lib/replay/rrweb-replay-unpack.js +0 -1
- package/lib/replay/rrweb-replay.css +1 -1
- package/lib/replay/rrweb-replay.js +0 -1
- package/lib/rrweb-all.css +1 -1
- package/lib/rrweb-all.js +5 -3
- package/lib/rrweb.css +1 -1
- package/lib/rrweb.js +5 -3
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
.replayer-wrapper{position:relative}.replayer-mouse{position:absolute;width:20px;height:20px;transition:left .05s linear,top .05s linear;background-size:contain;background-position:50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjcgNSAxOCAxOCIgaGVpZ2h0PSIzMDAiIHdpZHRoPSIzMDAiPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik04LjIgMjAuOXYtMTZsMTEuNiAxMS42SDEzbC0uNC4xeiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy4zIDIxLjZsLTMuNiAxLjVMOSAxMmwzLjctMS41eiIvPjxwYXRoIGQ9Ik0xMS4wMyAxNC4yOTNsMS44NDUtLjc3NCAzLjA5NiA3LjM3Ni0xLjg0NC43NzV6Ii8+PHBhdGggZD0iTTkuMiA3LjN2MTEuMmwzLTIuOS40LS4xaDQuOHoiLz48L3N2Zz4=");border-color:transparent}.replayer-mouse:after{background:transparent}.replayer-mouse.active:after{animation:click .2s ease-in-out 1}.replayer-mouse.touch-device{background-image:none;width:70px;height:70px;border-radius:100%;margin-left:-37px;margin-top:-37px;border:4px solid rgba(73,80,246,0);transition:left 0s linear,top 0s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device.touch-active{border-color:#4950f6;transition:left .25s linear,top .25s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device:after{opacity:0}.replayer-mouse.touch-device.active:after{animation:touch-click .2s ease-in-out 1}.replayer-mouse-tail{position:absolute;pointer-events:none}@keyframes click{0%{opacity:.3;width:20px;height:20px;background:transparent}75%{width:24px;height:24px;opacity:.8;background:#dc2626}to{background:transparent}}@keyframes touch-click{0%{opacity:0;width:20px;height:20px}50%{opacity:.5;width:10px;height:10px}}
|
|
1
|
+
.replayer-wrapper{position:relative}.replayer-mouse{position:absolute;width:20px;height:20px;transition:left .05s linear,top .05s linear;background-size:contain;background-position:50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjcgNSAxOCAxOCIgaGVpZ2h0PSIzMDAiIHdpZHRoPSIzMDAiPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik04LjIgMjAuOXYtMTZsMTEuNiAxMS42SDEzbC0uNC4xeiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy4zIDIxLjZsLTMuNiAxLjVMOSAxMmwzLjctMS41eiIvPjxwYXRoIGQ9Ik0xMS4wMyAxNC4yOTNsMS44NDUtLjc3NCAzLjA5NiA3LjM3Ni0xLjg0NC43NzV6Ii8+PHBhdGggZD0iTTkuMiA3LjN2MTEuMmwzLTIuOS40LS4xaDQuOHoiLz48L3N2Zz4=");border-color:transparent}.replayer-mouse:after{background:transparent}.replayer-mouse.active:after{animation:click .2s ease-in-out 1}.replayer-mouse.touch-device{background-image:none;width:70px;height:70px;border-radius:100%;margin-left:-37px;margin-top:-37px;border:4px solid rgba(73,80,246,0);transition:left 0s linear,top 0s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device.touch-active{border-color:#4950f6;transition:left .25s linear,top .25s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device:after{opacity:0}.replayer-mouse.touch-device.active:after{animation:touch-click .2s ease-in-out 1}.replayer-mouse-tail{position:absolute;pointer-events:none}@keyframes click{0%{opacity:.3;width:20px;height:20px;background:transparent}75%{width:24px;height:24px;opacity:.8;background:#dc2626}to{background:transparent}}@keyframes touch-click{0%{opacity:0;width:20px;height:20px}50%{opacity:.5;width:10px;height:10px}}.rr-player{position:relative;background:#fff;float:left;border-radius:5px;box-shadow:0 24px 48px rgba(17,16,62,.12)}.rr-player__frame{overflow:hidden}
|
|
@@ -14,4 +14,4 @@ var rrwebReplay=function(he){"use strict";var A;(function(e){e[e.Document=0]="Do
|
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */function Ge(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(t===void 0||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(l){i={error:l}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}var z;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(z||(z={}));var Ye={type:"xstate.init"};function Te(e){return e===void 0?[]:[].concat(e)}function G(e){return{type:"xstate.assign",assignment:e}}function ze(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function se(e){return function(t){return e===t}}function Xe(e){return typeof e=="string"?{type:e}:e}function Qe(e,t){return{value:e,context:t,actions:[],changed:!1,matches:se(e)}}function qe(e,t,n){var r=t,i=!1;return[e.filter(function(s){if(s.type==="xstate.assign"){i=!0;var a=Object.assign({},r);return typeof s.assignment=="function"?a=s.assignment(r,n):Object.keys(s.assignment).forEach(function(l){a[l]=typeof s.assignment[l]=="function"?s.assignment[l](r,n):s.assignment[l]}),r=a,!1}return!0}),r,i]}function Je(e,t){t===void 0&&(t={});var n=Ge(qe(Te(e.states[e.initial].entry).map(function(a){return ze(a,t.actions)}),e.context,Ye),2),r=n[0],i=n[1],s={config:e,_options:t,initialState:{value:e.initial,actions:r,context:i,matches:se(e.initial)},transition:function(a,l){var c,o,u=typeof a=="string"?{value:a,context:e.context}:a,d=u.value,h=u.context,f=Xe(l),T=e.states[d];if(T.on){var y=Te(T.on[f.type]);try{for(var N=function(O){var re=typeof Symbol=="function"&&Symbol.iterator,g=re&&O[re],m=0;if(g)return g.call(O);if(O&&typeof O.length=="number")return{next:function(){return O&&m>=O.length&&(O=void 0),{value:O&&O[m++],done:!O}}};throw new TypeError(re?"Object is not iterable.":"Symbol.iterator is not defined.")}(y),p=N.next();!p.done;p=N.next()){var v=p.value;if(v===void 0)return Qe(d,h);var w=typeof v=="string"?{target:v}:v,M=w.target,I=w.actions,k=I===void 0?[]:I,$=w.cond,j=$===void 0?function(){return!0}:$,L=M===void 0,te=M??d,H=e.states[te];if(j(h,f)){var ne=Ge(qe((L?Te(k):[].concat(T.exit,k,H.entry).filter(function(O){return O})).map(function(O){return ze(O,s._options.actions)}),h,f),3),ue=ne[0],Ce=ne[1],Se=ne[2],q=M??d;return{value:q,context:Ce,actions:ue,changed:M!==d||ue.length>0||Se,matches:se(q)}}}}catch(O){c={error:O}}finally{try{p&&!p.done&&(o=N.return)&&o.call(N)}finally{if(c)throw c.error}}}return Qe(d,h)}};return s}var Ze=function(e,t){return e.actions.forEach(function(n){var r=n.exec;return r&&r(e.context,t)})};function Ke(e){var t=e.initialState,n=z.NotStarted,r=new Set,i={_machine:e,send:function(s){n===z.Running&&(t=e.transition(t,s),Ze(t,Xe(s)),r.forEach(function(a){return a(t)}))},subscribe:function(s){return r.add(s),s(t),{unsubscribe:function(){return r.delete(s)}}},start:function(s){if(s){var a=typeof s=="object"?s:{context:e.config.context,value:s};t={value:a.value,actions:[],context:a.context,matches:se(a.value)}}return n=z.Running,Ze(t,Ye),i},stop:function(){return n=z.Stopped,r.clear(),i},get state(){return t},get status(){return n}};return i}var tn=Object.defineProperty,nn=Object.defineProperties,rn=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,tt=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))on.call(t,n)&&tt(e,n,t[n]);if(et)for(var n of et(t))sn.call(t,n)&&tt(e,n,t[n]);return e},ce=(e,t)=>nn(e,rn(t));function an(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.type===C.Meta&&r.timestamp<=t)return e.slice(n)}return e}function cn(e,{getCastFn:t,applyEventsSynchronously:n,emitter:r}){const i=Je({id:"player",context:e,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:G({lastPlayedEvent:(s,a)=>a.type==="CAST_EVENT"?a.payload.event:s.lastPlayedEvent}),recordTimeOffset:G((s,a)=>{let l=s.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(l=a.payload.timeOffset),ce(ae({},s),{timeOffset:l,baselineTime:s.events[0].timestamp+l})}),play(s){var a;const{timer:l,events:c,baselineTime:o,lastPlayedEvent:u}=s;l.clear();for(const y of c)ve(y,o);const d=an(c,o);let h=u?.timestamp;u?.type===C.IncrementalSnapshot&&u.data.source===x.MouseMove&&(h=u.timestamp+((a=u.data.positions[0])==null?void 0:a.timeOffset)),o<(h||0)&&r.emit(D.PlayBack);const f=new Array,T=new Array;for(const y of d)if(!(h&&h<o&&(y.timestamp<=h||y===u)))if(y.timestamp<o)f.push(y);else{const N=t(y,!1);T.push({doAction:()=>{N()},delay:y.delay})}n(f),r.emit(D.Flush),l.addActions(T),l.start()},pause(s){s.timer.clear()},resetLastPlayedEvent:G(s=>ce(ae({},s),{lastPlayedEvent:null})),startLive:G({baselineTime:(s,a)=>(s.timer.toggleLiveMode(!0),s.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),replaceEvents:G((s,a)=>{const{events:l,timer:c,baselineTime:o}=s;if(a.type==="REPLACE_EVENTS"){const{events:u}=a.payload;l.length=0;const d=[];for(const h of u)if(ve(h,o),l.push(h),h.timestamp>=c.timeOffset+o){const f=t(h,!1);d.push({doAction:()=>{f()},delay:h.delay})}c.isActive()&&c.replaceActions(d)}return ce(ae({},s),{events:l})}),addEvent:G((s,a)=>{const{baselineTime:l,timer:c,events:o}=s;if(a.type==="ADD_EVENT"){const{event:u}=a.payload;ve(u,l);let d=o.length-1;if(!o[d]||o[d].timestamp<=u.timestamp)o.push(u);else{let T=-1,y=0;for(;y<=d;){const N=Math.floor((y+d)/2);o[N].timestamp<=u.timestamp?y=N+1:d=N-1}T===-1&&(T=y),o.splice(T,0,u)}const h=u.timestamp<l,f=t(u,h);h?f():c.isActive()&&c.addAction({doAction:()=>{f()},delay:u.delay})}return ce(ae({},s),{events:o})})}});return Ke(i)}function ln(e){const t=Je({id:"speed",context:e,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(n,r)=>{"payload"in r&&n.timer.setSpeed(r.payload.speed)},recordSpeed:G({normalSpeed:n=>n.timer.speed}),restoreSpeed:n=>{n.timer.setSpeed(n.normalSpeed)}}});return Ke(t)}const X=`Please stop import mirror directly. Instead of that,\r
|
|
16
16
|
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
17
|
-
or you can use record.mirror to access the mirror instance during recording.`;let nt={map:{},getId(){return console.error(X),-1},getNode(){return console.error(X),null},removeNodeFromMap(){console.error(X)},has(){return console.error(X),!1},reset(){console.error(X)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(nt=new Proxy(nt,{get(e,t,n){return t==="map"&&console.error(X),Reflect.get(e,t,n)}}));function un(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(t){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===t)return!0;while(t=t&&t.parentNode);return!1})}function dn(e){const t={},n=(i,s)=>{const a={value:i,parent:s,children:[]};return t[i.node.id]=a,a},r=[];for(const i of e){const{nextId:s,parentId:a}=i;if(s&&s in t){const l=t[s];if(l.parent){const c=l.parent.children.indexOf(l);l.parent.children.splice(c,0,n(i,l.parent))}else{const c=r.indexOf(l);r.splice(c,0,n(i,null))}continue}if(a in t){const l=t[a];l.children.push(n(i,l));continue}r.push(n(i,null))}return r}function rt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)rt(e.children[n],t)}function Ne(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function it(e,t){var n,r;const i=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!i||i===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=i.getBoundingClientRect(),a=it(i,t),l=s.height/i.clientHeight;return{x:s.x*a.relativeScale+a.x,y:s.y*a.relativeScale+a.y,relativeScale:l,absoluteScale:a.absoluteScale*l}}function ot(e){return Boolean(e?.shadowRoot)}function K(e,t){const n=e[t[0]];return t.length===1?n:K(n.cssRules[t[1]].cssRules,t.slice(2))}function st(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function hn(e){const t=new Set,n=[];for(let r=e.length;r--;){const i=e[r];t.has(i.id)||(n.push(i),t.add(i.id))}return n}const mn=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }",`.${e} { background: currentColor; border-radius: 5px; }`,`.${e}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ee=typeof Uint8Array>"u"?[]:new Uint8Array(256),le=0;le<at.length;le++)ee[at.charCodeAt(le)]=le;var pn=function(e){var t=e.length*.75,n=e.length,r,i=0,s,a,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var o=new ArrayBuffer(t),u=new Uint8Array(o);for(r=0;r<n;r+=4)s=ee[e.charCodeAt(r)],a=ee[e.charCodeAt(r+1)],l=ee[e.charCodeAt(r+2)],c=ee[e.charCodeAt(r+3)],u[i++]=s<<2|a>>4,u[i++]=(a&15)<<4|l>>2,u[i++]=(l&3)<<6|c&63;return o},fn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const ct=new Map;function lt(e,t){let n=ct.get(e);return n||(n=new Map,ct.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function W(e,t,n){return r=>fn(this,null,function*(){if(r&&typeof r=="object"&&"rr_type"in r)if(n&&(n.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=yield W(e,t,n)(r.args);return yield createImageBitmap.apply(null,i)}else if("index"in r){if(n||t===null)return r;const{rr_type:i,index:s}=r;return lt(t,i)[s]}else if("args"in r){const{rr_type:i,args:s}=r,a=window[i];return new a(...yield Promise.all(s.map(W(e,t,n))))}else{if("base64"in r)return pn(r.base64);if("src"in r){const i=e.get(r.src);if(i)return i;{const s=new Image;return s.src=r.src,e.set(r.src,s),s}}else if("data"in r&&r.rr_type==="Blob"){const i=yield Promise.all(r.data.map(W(e,t,n)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return yield Promise.all(r.map(W(e,t,n)));return r})}var gn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function yn(e,t){try{return t===oe.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const vn=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tn(e,t){if(!(t!=null&&t.constructor))return;const{name:n}=t.constructor;if(!vn.includes(n))return;const r=lt(e,n);r.includes(t)||r.push(t)}function Nn(e){return gn(this,arguments,function*({mutation:t,target:n,type:r,imageMap:i,errorHandler:s}){try{const a=yn(n,r);if(!a)return;if(t.setter){a[t.property]=t.args[0];return}const l=a[t.property],c=yield Promise.all(t.args.map(W(i,a))),o=l.apply(a,c);Tn(a,o)}catch(a){s(t,a)}})}var En=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function wn(e){return En(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,errorHandler:s}){try{const a=r.getContext("2d");if(n.setter){a[n.property]=n.args[0];return}const l=a[n.property];if(n.property==="drawImage"&&typeof n.args[0]=="string"){const c=i.get(t);l.apply(a,n.args)}else{const c=yield Promise.all(n.args.map(W(i,a)));l.apply(a,c)}}catch(a){s(n,a)}})}var bn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function ut(e){return bn(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,canvasEventMap:s,errorHandler:a}){try{const l=s.get(t)||n,c="commands"in l?l.commands:[l];if([oe.WebGL,oe.WebGL2].includes(n.type)){for(let o=0;o<c.length;o++){const u=c[o];yield Nn({mutation:u,type:n.type,target:r,imageMap:i,errorHandler:a})}return}for(let o=0;o<c.length;o++){const u=c[o];yield wn({event:t,mutation:u,target:r,imageMap:i,errorHandler:a})}}catch(l){a(n,l)}})}var Dn=Object.defineProperty,Mn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,ht=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&ht(e,n,t[n]);if(dt)for(var n of dt(t))xn.call(t,n)&&ht(e,n,t[n]);return e},Ee=(e,t)=>Mn(e,Cn(t)),we=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const mt=10*1e3,pt=2*1e3,ft=1*1e3,gt=60*60*1e3,Rn=He||Zt,be="[replayer]",De={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Me(e){return e.type==C.IncrementalSnapshot&&(e.data.source==x.TouchMove||e.data.source==x.MouseInteraction&&e.data.type==_.TouchStart)}class An{constructor(t,n){if(this.usingVirtualDom=!1,this.virtualDom=new Y,this.mouseTail=null,this.tailPositions=[],this.emitter=Rn(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=ke(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Tt(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(n!=null&&n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:De,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:pt};this.config=Object.assign({},r,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(D.Resize,this.handleResize),this.setupDom(),this.emitter.on(D.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(c,o,u)=>{ut({event:c,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(B(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const o=this.legacy_missingNodeRetryMap[c],u=ge(o.node,this.mirror,this.virtualDom.mirror);B(u,o.node,l,this.virtualDom.mirror),o.node=u}catch(o){this.config.showWarning&&console.warn(o)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(D.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const i=new en([],n?.speed||r.speed);this.service=cn({events:t.map(l=>n&&n.unpackFn?n.unpackFn(l):l).sort((l,c)=>l.timestamp-c.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(D.StateChange,{player:l})}),this.speedService=ln({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(D.StateChange,{speed:l})});const s=this.service.state.context.events.find(l=>l.type===C.Meta),a=this.service.state.context.events.find(l=>l.type===C.FullSnapshot);if(s){const{width:l,height:c}=s.data;setTimeout(()=>{this.emitter.emit(D.Resize,{width:l,height:c})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Me)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,n){return this.emitter.on(t,n),this}off(t,n){return this.emitter.off(t,n),this}setConfig(t){Object.keys(t).forEach(n=>{this.config[n]=t[n]}),this.config.skipInactive||this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const t=[],n=this.getMetaData(),r=[{timestamp:n.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:n.endTime}];for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a];c.timestamp-l.timestamp>mt?t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!1}):t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!0})}const i=[];let s=t[0];for(let a=1;a<t.length;a++)t[a].active!=t[a-1].active&&(i.push({startTime:s.startTime,endTime:t[a-1].endTime,duration:t[a-1].endTime-s.startTime,active:t[a-1].active}),s=t[a]);s&&t.length>0&&i.push({startTime:s.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-s.startTime,active:t[t.length-1].active}),s=i[0];for(let a=1;a<i.length;a++)(!i[a].active&&i[a].duration>this.config.inactiveThreshold*n.totalTime||!i[a-1].active&&i[a-1].duration>this.config.inactiveThreshold*n.totalTime)&&(this.activityIntervals.push({startTime:s.startTime,endTime:i[a-1].endTime,duration:i[a-1].endTime-s.startTime,active:i[a-1].active}),s=i[a]);s&&i.length>0&&this.activityIntervals.push({startTime:s.startTime,endTime:i[i.length-1].endTime,duration:i[i.length-1].endTime-s.startTime,active:i[i.length-1].active})}return this.activityIntervals}getMetaData(){const t=this.service.state.context.events[0],n=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:n}=this.service.state.context;return t-n[0].timestamp}getMirror(){return this.mirror}play(t=0){var n,r;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(D.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)}pause(t){var n,r;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(D.Pause)}resume(t=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(D.Resume)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const n=this.config.unpackFn?this.config.unpackFn(t):t;Me(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:n}}))}replaceEvents(t){for(const n of t)if(Me(n)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:t}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=ke()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Kt(this.iframe.contentWindow,this.iframe.contentDocument),un(this.iframe.contentWindow))}handleResize(t){this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])!n||(n.setAttribute("width",String(t.width)),n.setAttribute("height",String(t.height)))}applyEventsSynchronously(t){for(const n of t){switch(n.type){case C.DomContentLoaded:case C.Load:case C.Custom:continue;case C.FullSnapshot:case C.Meta:case C.Plugin:case C.IncrementalSnapshot:break}this.getCastFn(n,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(t,n=!1){let r;switch(t.type){case C.DomContentLoaded:case C.Load:break;case C.Custom:r=()=>{this.emitter.emit(D.CustomEvent,t)};break;case C.Meta:r=()=>this.emitter.emit(D.Resize,{width:t.data.width,height:t.data.height});break;case C.FullSnapshot:r=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===t){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(t,n),this.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case C.IncrementalSnapshot:r=()=>{if(this.applyIncremental(t,n),!n&&(this.handleInactivity(t.timestamp),t===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const i of this.service.state.context.events)if(!(i.timestamp<=t.timestamp)&&this.isUserInteraction(i)){i.delay-t.delay>mt*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=i);break}if(this.nextUserInteractionEvent){const i=this.nextUserInteractionEvent.delay-t.delay,s={speed:Math.min(Math.round(i/pt),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:s}),this.emitter.emit(D.SkipStart,s)}}};break}return()=>{r&&r();for(const s of this.config.plugins||[])s.handler(t,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:t}});const i=this.service.state.context.events.length-1;if(t===this.service.state.context.events[i]){const s=()=>{i<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(D.Finish))};t.type===C.IncrementalSnapshot&&t.data.source===x.MouseMove&&t.data.positions.length?setTimeout(()=>{s()},Math.max(0,-t.data.positions[0].timeOffset+50)):s()}this.emitter.emit(D.EventCast,t)}}handleInactivity(t,n){if((t===this.inactiveEndTimestamp||n)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const r of this.getActivityIntervals())if(t>=r.startTime&&t<r.endTime&&!r.active){this.inactiveEndTimestamp=r.endTime;break}if(this.inactiveEndTimestamp){const r=this.inactiveEndTimestamp-t,i={speed:r/gt*this.config.inactiveSkipTime<ft?r/ft:Math.round(Math.max(r,gt)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:i}),this.emitter.emit(D.SkipStart,i)}}}rebuildFullSnapshot(t,n=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const r=[];St(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(r,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:l}of r)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:i,head:s}=this.iframe.contentDocument;this.insertStyleRules(i,s),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(D.FullsnapshotRebuilded,t),n||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,n){const r=mn(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const i=this.virtualDom.createElement("style");this.virtualDom.mirror.add(i,je(i,this.virtualDom.unserializedId)),t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.rules.push({cssText:r[s],type:U.Insert,index:s})}else{const i=document.createElement("style");t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.sheet.insertRule(r[s],s)}}attachDocumentToIframe(t,n){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[];ie(t.node,{doc:n.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:s=>{this.collectIframeAndAttachDocument(i,s);const a=r.getMeta(s);if(a?.type===A.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:l,head:c}=n.contentDocument;this.insertStyleRules(l,c)}},cache:this.cache});for(const{mutationInQueue:s,builtNode:a}of i)this.attachDocumentToIframe(s,a),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==s)}collectIframeAndAttachDocument(t,n){if(Ne(n,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(n));r&&t.push({mutationInQueue:r,builtNode:n})}}waitForStylesheetLoad(){var t;const n=(t=this.iframe.contentDocument)==null?void 0:t.head;if(n){const r=new Set;let i,s=this.service.state;const a=()=>{s=this.service.state};this.emitter.on(D.Start,a),this.emitter.on(D.Pause,a);const l=()=>{this.emitter.off(D.Start,a),this.emitter.off(D.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{c.sheet||(r.add(c),c.addEventListener("load",()=>{r.delete(c),r.size===0&&i!==-1&&(s.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(D.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(D.LoadStylesheetStart),i=setTimeout(()=>{s.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},this.config.loadTimeout))}}hasImageArg(t){for(const n of t)if(!(!n||typeof n!="object")){if("rr_type"in n&&"args"in n){if(this.hasImageArg(n.args))return!0}else if("rr_type"in n&&n.rr_type==="HTMLImageElement"||n instanceof Array&&this.hasImageArg(n))return!0}return!1}getImageArgs(t){const n=[];for(const r of t)!r||typeof r!="object"||("rr_type"in r&&"args"in r?n.push(...this.getImageArgs(r.args)):"rr_type"in r&&r.rr_type==="HTMLImageElement"?n.push(r.src):r instanceof Array&&n.push(...this.getImageArgs(r)));return n}preloadAllImages(){return we(this,null,function*(){this.service.state;const t=()=>{this.service.state};this.emitter.on(D.Start,t),this.emitter.on(D.Pause,t);const n=[];for(const r of this.service.state.context.events)r.type===C.IncrementalSnapshot&&r.data.source===x.CanvasMutation&&(n.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(n)})}preloadImages(t,n){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(n)){const r=document.createElement("canvas"),i=r.getContext("2d"),s=i?.createImageData(r.width,r.height);s?.data,JSON.parse(t.args[0]),i?.putImageData(s,0,0)}}deserializeAndPreloadCanvasEvents(t,n){return we(this,null,function*(){if(!this.canvasEventMap.has(n)){const r={isUnchanged:!0};if("commands"in t){const i=yield Promise.all(t.commands.map(s=>we(this,null,function*(){const a=yield Promise.all(s.args.map(W(this.imageMap,null,r)));return Ee(Q({},s),{args:a})})));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{commands:i}))}else{const i=yield Promise.all(t.args.map(W(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{args:i}))}}})}applyIncremental(t,n){var r,i,s,a,l,c;const{data:o}=t;switch(o.source){case x.Mutation:{try{this.applyMutation(o,n)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case x.Drag:case x.TouchMove:case x.MouseMove:if(n){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,n,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case x.MouseInteraction:{if(o.id===-1||n)break;const u=new Event(_[o.type].toLowerCase()),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(D.MouseInteraction,{type:o.type,target:d});const{triggerFocus:h}=this.config;switch(o.type){case _.Blur:"blur"in d&&d.blur();break;case _.Focus:h&&d.focus&&d.focus({preventScroll:!0});break;case _.Click:case _.TouchStart:case _.TouchEnd:n?(o.type===_.TouchStart?this.touchActive=!0:o.type===_.TouchEnd&&(this.touchActive=!1),this.mousePos={x:o.x,y:o.y,id:o.id,debugData:o}):(o.type===_.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x,o.y,o.id,n,o),o.type===_.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===_.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===_.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case _.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case x.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,n);break}case x.ViewportResize:this.emitter.emit(D.Resize,{width:o.width,height:o.height});break;case x.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case x.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u;try{o.currentTime&&(d.currentTime=o.currentTime),o.volume&&(d.volume=o.volume),o.muted&&(d.muted=o.muted),o.type===ye.Pause&&d.pause(),o.type===ye.Play&&d.play()}catch(h){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${h.message||h}`)}break}case x.StyleSheetRule:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;(i=o.adds)==null||i.forEach(({rule:h,index:f})=>d?.push({cssText:h,index:f,type:U.Insert})),(s=o.removes)==null||s.forEach(({index:h})=>d?.push({index:h,type:U.Remove}))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;(a=o.adds)==null||a.forEach(({rule:h,index:f})=>{try{if(Array.isArray(f)){const{positions:T,index:y}=st(f);K(d.cssRules,T).insertRule(h,y)}else{const T=f===void 0?void 0:Math.min(f,d.cssRules.length);d.insertRule(h,T)}}catch{}}),(l=o.removes)==null||l.forEach(({index:h})=>{try{if(Array.isArray(h)){const{positions:f,index:T}=st(h);K(d.cssRules,f).deleteRule(T||0)}else d?.deleteRule(h)}catch{}})}break}case x.StyleDeclaration:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;o.set&&d.push(Q({type:U.SetProperty,index:o.index},o.set)),o.remove&&d.push(Q({type:U.RemoveProperty,index:o.index},o.remove))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;o.set&&K(d.rules,o.index).style.setProperty(o.set.property,o.set.value,o.set.priority),o.remove&&K(d.rules,o.index).style.removeProperty(o.remove.property)}break}case x.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);ut({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case x.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(c=this.iframe.contentDocument)==null||c.fonts.add(u)}catch(u){this.config.showWarning&&console.warn(u)}break}}}applyMutation(t,n){if(this.config.useVirtualDom&&!this.usingVirtualDom&&n&&(this.usingVirtualDom=!0,Qt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const o in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[o],d=We(u.node,this.virtualDom,this.mirror);d&&(u.node=d)}catch(u){this.config.showWarning&&console.warn(u)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes.forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(f=>f.id===o.parentId)?void 0:this.warnNodeNotFound(t,o.id);let h=r.getNode(o.parentId);if(!h)return this.warnNodeNotFound(t,o.parentId);if(o.isShadow&&ot(h)&&(h=h.shadowRoot),r.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((u=h.rules)==null?void 0:u.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),s=[],a=o=>{let u=null;return o.nextId&&(u=r.getNode(o.nextId)),o.nextId!==null&&o.nextId!==void 0&&o.nextId!==-1&&!u},l=o=>{var u;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let d=r.getNode(o.parentId);if(!d)return o.node.type===A.Document?this.newDocumentQueue.push(o):s.push(o);o.node.isShadow&&(ot(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,f=null;if(o.previousId&&(h=r.getNode(o.previousId)),o.nextId&&(f=r.getNode(o.nextId)),a(o))return s.push(o);if(o.node.rootId&&!r.getNode(o.node.rootId))return;const T=o.node.rootId?r.getNode(o.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ne(d,r)){this.attachDocumentToIframe(o,d);return}const y=ie(o.node,{doc:T,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});if(o.previousId===-1||o.nextId===-1){i[o.node.id]={node:y,mutation:o};return}const N=r.getMeta(d);if(N&&N.type===A.Element&&N.tagName==="textarea"&&o.node.type===A.Text){const p=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const v of p)v.nodeType===d.TEXT_NODE&&d.removeChild(v)}if(h&&h.nextSibling&&h.nextSibling.parentNode)d.insertBefore(y,h.nextSibling);else if(f&&f.parentNode)d.contains(f)?d.insertBefore(y,f):d.insertBefore(y,null);else{if(d===T)for(;T.firstChild;)T.removeChild(T.firstChild);d.appendChild(y)}if(this.usingVirtualDom&&y.nodeName==="#text"&&d.nodeName==="STYLE"&&((u=d.rules)==null?void 0:u.length)>0&&(d.rules=[]),Ne(y,this.mirror)){const p=this.mirror.getId(y),v=this.newDocumentQueue.find(w=>w.parentId===p);v&&(this.attachDocumentToIframe(v,y),this.newDocumentQueue=this.newDocumentQueue.filter(w=>w!==v))}(o.previousId||o.nextId)&&this.legacy_resolveMissingNode(i,d,y,o)};t.adds.forEach(o=>{l(o)});const c=Date.now();for(;s.length;){const o=dn(s);if(s.length=0,Date.now()-c>500){this.warn("Timeout in the loop, please check the resolve tree data:",o);break}for(const u of o)r.getNode(u.value.parentId)?rt(u,d=>{l(d)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),hn(t.texts).forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(h=>h.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);if(d.textContent=o.value,this.usingVirtualDom){const h=d.parentNode;((u=h?.rules)==null?void 0:u.length)>0&&(h.rules=[])}}),t.attributes.forEach(o=>{const u=r.getNode(o.id);if(!u)return t.removes.find(d=>d.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);for(const d in o.attributes)if(typeof d=="string"){const h=o.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{u.setAttribute(d,h)}catch(f){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",f)}else if(d==="style"){const f=h,T=u;for(const y in f)if(f[y]===!1)T.style.removeProperty(y);else if(f[y]instanceof Array){const N=f[y];T.style.setProperty(y,N[0],N[1])}else{const N=f[y];T.style.setProperty(y,N)}}}})}applyScroll(t,n){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const i=this.mirror.getMeta(r);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else if(i?.type===A.Document)r.defaultView.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=t.y,r.scrollLeft=t.x}catch{}}applyInput(t){const n=this.mirror.getNode(t.id);if(!n)return this.debugNodeNotFound(t,t.id);try{n.checked=t.isChecked,n.value=t.text}catch{}}legacy_resolveMissingNode(t,n,r,i){const{previousId:s,nextId:a}=i,l=s&&t[s],c=a&&t[a];if(l){const{node:o,mutation:u}=l;n.insertBefore(o,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}if(c){const{node:o,mutation:u}=c;n.insertBefore(o,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}}moveAndHover(t,n,r,i,s){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(s,r);const l=it(a,this.iframe),c=t*l.absoluteScale+l.x,o=n*l.absoluteScale+l.y;this.mouse.style.left=`${c}px`,this.mouse.style.top=`${o}px`,i||this.drawMouseTail({x:c,y:o}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:n,lineWidth:r,strokeStyle:i,duration:s}=this.config.mouseTail===!0?De:Object.assign({},De,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=r,l.lineCap=n,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(c=>l.lineTo(c.x,c.y)),l.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==t),a()},s/this.speedService.state.context.timer.speed)}hoverElements(t){var n;(n=this.iframe.contentDocument)==null||n.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")});let r=t;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(t){return t.type!==C.IncrementalSnapshot?!1:t.data.source>x.Mutation&&t.data.source<=x.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(D.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,n){this.warn(`Node with id '${n}' not found. `,t)}warnCanvasMutationFailed(t,n){this.warn("Has error on canvas update",n,"canvas mutation:",t)}debugNodeNotFound(t,n){this.debug(be,`Node with id '${n}' not found. `,t)}warn(...t){!this.config.showWarning||console.warn(be,...t)}debug(...t){!this.config.showDebug||console.log(be,...t)}}return he.Replayer=An,Object.defineProperty(he,"__esModule",{value:!0}),he}({});
|
|
17
|
+
or you can use record.mirror to access the mirror instance during recording.`;let nt={map:{},getId(){return console.error(X),-1},getNode(){return console.error(X),null},removeNodeFromMap(){console.error(X)},has(){return console.error(X),!1},reset(){console.error(X)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(nt=new Proxy(nt,{get(e,t,n){return t==="map"&&console.error(X),Reflect.get(e,t,n)}}));function un(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(t){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===t)return!0;while(t=t&&t.parentNode);return!1})}function dn(e){const t={},n=(i,s)=>{const a={value:i,parent:s,children:[]};return t[i.node.id]=a,a},r=[];for(const i of e){const{nextId:s,parentId:a}=i;if(s&&s in t){const l=t[s];if(l.parent){const c=l.parent.children.indexOf(l);l.parent.children.splice(c,0,n(i,l.parent))}else{const c=r.indexOf(l);r.splice(c,0,n(i,null))}continue}if(a in t){const l=t[a];l.children.push(n(i,l));continue}r.push(n(i,null))}return r}function rt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)rt(e.children[n],t)}function Ne(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function it(e,t){var n,r;const i=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!i||i===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=i.getBoundingClientRect(),a=it(i,t),l=s.height/i.clientHeight;return{x:s.x*a.relativeScale+a.x,y:s.y*a.relativeScale+a.y,relativeScale:l,absoluteScale:a.absoluteScale*l}}function ot(e){return Boolean(e?.shadowRoot)}function K(e,t){const n=e[t[0]];return t.length===1?n:K(n.cssRules[t[1]].cssRules,t.slice(2))}function st(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function hn(e){const t=new Set,n=[];for(let r=e.length;r--;){const i=e[r];t.has(i.id)||(n.push(i),t.add(i.id))}return n}const mn=e=>["noscript { display: none !important; }",`.${e} { background: currentColor; border-radius: 5px; }`,`.${e}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ee=typeof Uint8Array>"u"?[]:new Uint8Array(256),le=0;le<at.length;le++)ee[at.charCodeAt(le)]=le;var pn=function(e){var t=e.length*.75,n=e.length,r,i=0,s,a,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var o=new ArrayBuffer(t),u=new Uint8Array(o);for(r=0;r<n;r+=4)s=ee[e.charCodeAt(r)],a=ee[e.charCodeAt(r+1)],l=ee[e.charCodeAt(r+2)],c=ee[e.charCodeAt(r+3)],u[i++]=s<<2|a>>4,u[i++]=(a&15)<<4|l>>2,u[i++]=(l&3)<<6|c&63;return o},fn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const ct=new Map;function lt(e,t){let n=ct.get(e);return n||(n=new Map,ct.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function W(e,t,n){return r=>fn(this,null,function*(){if(r&&typeof r=="object"&&"rr_type"in r)if(n&&(n.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=yield W(e,t,n)(r.args);return yield createImageBitmap.apply(null,i)}else if("index"in r){if(n||t===null)return r;const{rr_type:i,index:s}=r;return lt(t,i)[s]}else if("args"in r){const{rr_type:i,args:s}=r,a=window[i];return new a(...yield Promise.all(s.map(W(e,t,n))))}else{if("base64"in r)return pn(r.base64);if("src"in r){const i=e.get(r.src);if(i)return i;{const s=new Image;return s.src=r.src,e.set(r.src,s),s}}else if("data"in r&&r.rr_type==="Blob"){const i=yield Promise.all(r.data.map(W(e,t,n)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return yield Promise.all(r.map(W(e,t,n)));return r})}var gn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function yn(e,t){try{return t===oe.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const vn=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tn(e,t){if(!(t!=null&&t.constructor))return;const{name:n}=t.constructor;if(!vn.includes(n))return;const r=lt(e,n);r.includes(t)||r.push(t)}function Nn(e){return gn(this,arguments,function*({mutation:t,target:n,type:r,imageMap:i,errorHandler:s}){try{const a=yn(n,r);if(!a)return;if(t.setter){a[t.property]=t.args[0];return}const l=a[t.property],c=yield Promise.all(t.args.map(W(i,a))),o=l.apply(a,c);Tn(a,o)}catch(a){s(t,a)}})}var En=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function wn(e){return En(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,errorHandler:s}){try{const a=r.getContext("2d");if(n.setter){a[n.property]=n.args[0];return}const l=a[n.property];if(n.property==="drawImage"&&typeof n.args[0]=="string"){const c=i.get(t);l.apply(a,n.args)}else{const c=yield Promise.all(n.args.map(W(i,a)));l.apply(a,c)}}catch(a){s(n,a)}})}var bn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function ut(e){return bn(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,canvasEventMap:s,errorHandler:a}){try{const l=s.get(t)||n,c="commands"in l?l.commands:[l];if([oe.WebGL,oe.WebGL2].includes(n.type)){for(let o=0;o<c.length;o++){const u=c[o];yield Nn({mutation:u,type:n.type,target:r,imageMap:i,errorHandler:a})}return}for(let o=0;o<c.length;o++){const u=c[o];yield wn({event:t,mutation:u,target:r,imageMap:i,errorHandler:a})}}catch(l){a(n,l)}})}var Dn=Object.defineProperty,Mn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,ht=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&ht(e,n,t[n]);if(dt)for(var n of dt(t))xn.call(t,n)&&ht(e,n,t[n]);return e},Ee=(e,t)=>Mn(e,Cn(t)),we=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const mt=10*1e3,pt=2*1e3,ft=1*1e3,gt=60*60*1e3,Rn=He||Zt,be="[replayer]",De={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Me(e){return e.type==C.IncrementalSnapshot&&(e.data.source==x.TouchMove||e.data.source==x.MouseInteraction&&e.data.type==_.TouchStart)}class An{constructor(t,n){if(this.usingVirtualDom=!1,this.virtualDom=new Y,this.mouseTail=null,this.tailPositions=[],this.emitter=Rn(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=ke(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Tt(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(n!=null&&n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:De,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:pt};this.config=Object.assign({},r,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(D.Resize,this.handleResize),this.setupDom(),this.emitter.on(D.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(c,o,u)=>{ut({event:c,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(B(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const o=this.legacy_missingNodeRetryMap[c],u=ge(o.node,this.mirror,this.virtualDom.mirror);B(u,o.node,l,this.virtualDom.mirror),o.node=u}catch(o){this.config.showWarning&&console.warn(o)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(D.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const i=new en([],n?.speed||r.speed);this.service=cn({events:t.map(l=>n&&n.unpackFn?n.unpackFn(l):l).sort((l,c)=>l.timestamp-c.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(D.StateChange,{player:l})}),this.speedService=ln({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(D.StateChange,{speed:l})});const s=this.service.state.context.events.find(l=>l.type===C.Meta),a=this.service.state.context.events.find(l=>l.type===C.FullSnapshot);if(s){const{width:l,height:c}=s.data;setTimeout(()=>{this.emitter.emit(D.Resize,{width:l,height:c})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Me)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,n){return this.emitter.on(t,n),this}off(t,n){return this.emitter.off(t,n),this}setConfig(t){Object.keys(t).forEach(n=>{this.config[n]=t[n]}),this.config.skipInactive||this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const t=[],n=this.getMetaData(),r=[{timestamp:n.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:n.endTime}];for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a];c.timestamp-l.timestamp>mt?t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!1}):t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!0})}const i=[];let s=t[0];for(let a=1;a<t.length;a++)t[a].active!=t[a-1].active&&(i.push({startTime:s.startTime,endTime:t[a-1].endTime,duration:t[a-1].endTime-s.startTime,active:t[a-1].active}),s=t[a]);s&&t.length>0&&i.push({startTime:s.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-s.startTime,active:t[t.length-1].active}),s=i[0];for(let a=1;a<i.length;a++)(!i[a].active&&i[a].duration>this.config.inactiveThreshold*n.totalTime||!i[a-1].active&&i[a-1].duration>this.config.inactiveThreshold*n.totalTime)&&(this.activityIntervals.push({startTime:s.startTime,endTime:i[a-1].endTime,duration:i[a-1].endTime-s.startTime,active:i[a-1].active}),s=i[a]);s&&i.length>0&&this.activityIntervals.push({startTime:s.startTime,endTime:i[i.length-1].endTime,duration:i[i.length-1].endTime-s.startTime,active:i[i.length-1].active})}return this.activityIntervals}getMetaData(){const t=this.service.state.context.events[0],n=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:n}=this.service.state.context;return t-n[0].timestamp}getMirror(){return this.mirror}play(t=0){var n,r;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(D.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)}pause(t){var n,r;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(D.Pause)}resume(t=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(D.Resume)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const n=this.config.unpackFn?this.config.unpackFn(t):t;Me(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:n}}))}replaceEvents(t){for(const n of t)if(Me(n)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:t}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=ke()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Kt(this.iframe.contentWindow,this.iframe.contentDocument),un(this.iframe.contentWindow))}handleResize(t){this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])!n||(n.setAttribute("width",String(t.width)),n.setAttribute("height",String(t.height)))}applyEventsSynchronously(t){for(const n of t){switch(n.type){case C.DomContentLoaded:case C.Load:case C.Custom:continue;case C.FullSnapshot:case C.Meta:case C.Plugin:case C.IncrementalSnapshot:break}this.getCastFn(n,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(t,n=!1){let r;switch(t.type){case C.DomContentLoaded:case C.Load:break;case C.Custom:r=()=>{this.emitter.emit(D.CustomEvent,t)};break;case C.Meta:r=()=>this.emitter.emit(D.Resize,{width:t.data.width,height:t.data.height});break;case C.FullSnapshot:r=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===t){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(t,n),this.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case C.IncrementalSnapshot:r=()=>{if(this.applyIncremental(t,n),!n&&(this.handleInactivity(t.timestamp),t===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const i of this.service.state.context.events)if(!(i.timestamp<=t.timestamp)&&this.isUserInteraction(i)){i.delay-t.delay>mt*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=i);break}if(this.nextUserInteractionEvent){const i=this.nextUserInteractionEvent.delay-t.delay,s={speed:Math.min(Math.round(i/pt),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:s}),this.emitter.emit(D.SkipStart,s)}}};break}return()=>{r&&r();for(const s of this.config.plugins||[])s.handler(t,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:t}});const i=this.service.state.context.events.length-1;if(t===this.service.state.context.events[i]){const s=()=>{i<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(D.Finish))};t.type===C.IncrementalSnapshot&&t.data.source===x.MouseMove&&t.data.positions.length?setTimeout(()=>{s()},Math.max(0,-t.data.positions[0].timeOffset+50)):s()}this.emitter.emit(D.EventCast,t)}}handleInactivity(t,n){if((t===this.inactiveEndTimestamp||n)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const r of this.getActivityIntervals())if(t>=r.startTime&&t<r.endTime&&!r.active){this.inactiveEndTimestamp=r.endTime;break}if(this.inactiveEndTimestamp){const r=this.inactiveEndTimestamp-t,i={speed:r/gt*this.config.inactiveSkipTime<ft?r/ft:Math.round(Math.max(r,gt)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:i}),this.emitter.emit(D.SkipStart,i)}}}rebuildFullSnapshot(t,n=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const r=[];St(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(r,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:l}of r)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:i,head:s}=this.iframe.contentDocument;this.insertStyleRules(i,s),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(D.FullsnapshotRebuilded,t),n||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,n){const r=mn(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const i=this.virtualDom.createElement("style");this.virtualDom.mirror.add(i,je(i,this.virtualDom.unserializedId)),t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.rules.push({cssText:r[s],type:U.Insert,index:s})}else{const i=document.createElement("style");t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.sheet.insertRule(r[s],s)}}attachDocumentToIframe(t,n){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[];ie(t.node,{doc:n.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:s=>{this.collectIframeAndAttachDocument(i,s);const a=r.getMeta(s);if(a?.type===A.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:l,head:c}=n.contentDocument;this.insertStyleRules(l,c)}},cache:this.cache});for(const{mutationInQueue:s,builtNode:a}of i)this.attachDocumentToIframe(s,a),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==s)}collectIframeAndAttachDocument(t,n){if(Ne(n,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(n));r&&t.push({mutationInQueue:r,builtNode:n})}}waitForStylesheetLoad(){var t;const n=(t=this.iframe.contentDocument)==null?void 0:t.head;if(n){const r=new Set;let i,s=this.service.state;const a=()=>{s=this.service.state};this.emitter.on(D.Start,a),this.emitter.on(D.Pause,a);const l=()=>{this.emitter.off(D.Start,a),this.emitter.off(D.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{c.sheet||(r.add(c),c.addEventListener("load",()=>{r.delete(c),r.size===0&&i!==-1&&(s.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(D.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(D.LoadStylesheetStart),i=setTimeout(()=>{s.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},this.config.loadTimeout))}}hasImageArg(t){for(const n of t)if(!(!n||typeof n!="object")){if("rr_type"in n&&"args"in n){if(this.hasImageArg(n.args))return!0}else if("rr_type"in n&&n.rr_type==="HTMLImageElement"||n instanceof Array&&this.hasImageArg(n))return!0}return!1}getImageArgs(t){const n=[];for(const r of t)!r||typeof r!="object"||("rr_type"in r&&"args"in r?n.push(...this.getImageArgs(r.args)):"rr_type"in r&&r.rr_type==="HTMLImageElement"?n.push(r.src):r instanceof Array&&n.push(...this.getImageArgs(r)));return n}preloadAllImages(){return we(this,null,function*(){this.service.state;const t=()=>{this.service.state};this.emitter.on(D.Start,t),this.emitter.on(D.Pause,t);const n=[];for(const r of this.service.state.context.events)r.type===C.IncrementalSnapshot&&r.data.source===x.CanvasMutation&&(n.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(n)})}preloadImages(t,n){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(n)){const r=document.createElement("canvas"),i=r.getContext("2d"),s=i?.createImageData(r.width,r.height);s?.data,JSON.parse(t.args[0]),i?.putImageData(s,0,0)}}deserializeAndPreloadCanvasEvents(t,n){return we(this,null,function*(){if(!this.canvasEventMap.has(n)){const r={isUnchanged:!0};if("commands"in t){const i=yield Promise.all(t.commands.map(s=>we(this,null,function*(){const a=yield Promise.all(s.args.map(W(this.imageMap,null,r)));return Ee(Q({},s),{args:a})})));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{commands:i}))}else{const i=yield Promise.all(t.args.map(W(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{args:i}))}}})}applyIncremental(t,n){var r,i,s,a,l,c;const{data:o}=t;switch(o.source){case x.Mutation:{try{this.applyMutation(o,n)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case x.Drag:case x.TouchMove:case x.MouseMove:if(n){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,n,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case x.MouseInteraction:{if(o.id===-1||n)break;const u=new Event(_[o.type].toLowerCase()),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(D.MouseInteraction,{type:o.type,target:d});const{triggerFocus:h}=this.config;switch(o.type){case _.Blur:"blur"in d&&d.blur();break;case _.Focus:h&&d.focus&&d.focus({preventScroll:!0});break;case _.Click:case _.TouchStart:case _.TouchEnd:n?(o.type===_.TouchStart?this.touchActive=!0:o.type===_.TouchEnd&&(this.touchActive=!1),this.mousePos={x:o.x,y:o.y,id:o.id,debugData:o}):(o.type===_.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x,o.y,o.id,n,o),o.type===_.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===_.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===_.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case _.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case x.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,n);break}case x.ViewportResize:this.emitter.emit(D.Resize,{width:o.width,height:o.height});break;case x.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case x.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u;try{o.currentTime&&(d.currentTime=o.currentTime),o.volume&&(d.volume=o.volume),o.muted&&(d.muted=o.muted),o.type===ye.Pause&&d.pause(),o.type===ye.Play&&d.play()}catch(h){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${h.message||h}`)}break}case x.StyleSheetRule:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;(i=o.adds)==null||i.forEach(({rule:h,index:f})=>d?.push({cssText:h,index:f,type:U.Insert})),(s=o.removes)==null||s.forEach(({index:h})=>d?.push({index:h,type:U.Remove}))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;(a=o.adds)==null||a.forEach(({rule:h,index:f})=>{try{if(Array.isArray(f)){const{positions:T,index:y}=st(f);K(d.cssRules,T).insertRule(h,y)}else{const T=f===void 0?void 0:Math.min(f,d.cssRules.length);d.insertRule(h,T)}}catch{}}),(l=o.removes)==null||l.forEach(({index:h})=>{try{if(Array.isArray(h)){const{positions:f,index:T}=st(h);K(d.cssRules,f).deleteRule(T||0)}else d?.deleteRule(h)}catch{}})}break}case x.StyleDeclaration:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;o.set&&d.push(Q({type:U.SetProperty,index:o.index},o.set)),o.remove&&d.push(Q({type:U.RemoveProperty,index:o.index},o.remove))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;o.set&&K(d.rules,o.index).style.setProperty(o.set.property,o.set.value,o.set.priority),o.remove&&K(d.rules,o.index).style.removeProperty(o.remove.property)}break}case x.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);ut({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case x.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(c=this.iframe.contentDocument)==null||c.fonts.add(u)}catch(u){this.config.showWarning&&console.warn(u)}break}}}applyMutation(t,n){if(this.config.useVirtualDom&&!this.usingVirtualDom&&n&&(this.usingVirtualDom=!0,Qt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const o in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[o],d=We(u.node,this.virtualDom,this.mirror);d&&(u.node=d)}catch(u){this.config.showWarning&&console.warn(u)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes.forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(f=>f.id===o.parentId)?void 0:this.warnNodeNotFound(t,o.id);let h=r.getNode(o.parentId);if(!h)return this.warnNodeNotFound(t,o.parentId);if(o.isShadow&&ot(h)&&(h=h.shadowRoot),r.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((u=h.rules)==null?void 0:u.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),s=[],a=o=>{let u=null;return o.nextId&&(u=r.getNode(o.nextId)),o.nextId!==null&&o.nextId!==void 0&&o.nextId!==-1&&!u},l=o=>{var u;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let d=r.getNode(o.parentId);if(!d)return o.node.type===A.Document?this.newDocumentQueue.push(o):s.push(o);o.node.isShadow&&(ot(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,f=null;if(o.previousId&&(h=r.getNode(o.previousId)),o.nextId&&(f=r.getNode(o.nextId)),a(o))return s.push(o);if(o.node.rootId&&!r.getNode(o.node.rootId))return;const T=o.node.rootId?r.getNode(o.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ne(d,r)){this.attachDocumentToIframe(o,d);return}const y=ie(o.node,{doc:T,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});if(o.previousId===-1||o.nextId===-1){i[o.node.id]={node:y,mutation:o};return}const N=r.getMeta(d);if(N&&N.type===A.Element&&N.tagName==="textarea"&&o.node.type===A.Text){const p=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const v of p)v.nodeType===d.TEXT_NODE&&d.removeChild(v)}if(h&&h.nextSibling&&h.nextSibling.parentNode)d.insertBefore(y,h.nextSibling);else if(f&&f.parentNode)d.contains(f)?d.insertBefore(y,f):d.insertBefore(y,null);else{if(d===T)for(;T.firstChild;)T.removeChild(T.firstChild);d.appendChild(y)}if(this.usingVirtualDom&&y.nodeName==="#text"&&d.nodeName==="STYLE"&&((u=d.rules)==null?void 0:u.length)>0&&(d.rules=[]),Ne(y,this.mirror)){const p=this.mirror.getId(y),v=this.newDocumentQueue.find(w=>w.parentId===p);v&&(this.attachDocumentToIframe(v,y),this.newDocumentQueue=this.newDocumentQueue.filter(w=>w!==v))}(o.previousId||o.nextId)&&this.legacy_resolveMissingNode(i,d,y,o)};t.adds.forEach(o=>{l(o)});const c=Date.now();for(;s.length;){const o=dn(s);if(s.length=0,Date.now()-c>500){this.warn("Timeout in the loop, please check the resolve tree data:",o);break}for(const u of o)r.getNode(u.value.parentId)?rt(u,d=>{l(d)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),hn(t.texts).forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(h=>h.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);if(d.textContent=o.value,this.usingVirtualDom){const h=d.parentNode;((u=h?.rules)==null?void 0:u.length)>0&&(h.rules=[])}}),t.attributes.forEach(o=>{const u=r.getNode(o.id);if(!u)return t.removes.find(d=>d.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);for(const d in o.attributes)if(typeof d=="string"){const h=o.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{u.setAttribute(d,h)}catch(f){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",f)}else if(d==="style"){const f=h,T=u;for(const y in f)if(f[y]===!1)T.style.removeProperty(y);else if(f[y]instanceof Array){const N=f[y];T.style.setProperty(y,N[0],N[1])}else{const N=f[y];T.style.setProperty(y,N)}}}})}applyScroll(t,n){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const i=this.mirror.getMeta(r);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else if(i?.type===A.Document)r.defaultView.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=t.y,r.scrollLeft=t.x}catch{}}applyInput(t){const n=this.mirror.getNode(t.id);if(!n)return this.debugNodeNotFound(t,t.id);try{n.checked=t.isChecked,n.value=t.text}catch{}}legacy_resolveMissingNode(t,n,r,i){const{previousId:s,nextId:a}=i,l=s&&t[s],c=a&&t[a];if(l){const{node:o,mutation:u}=l;n.insertBefore(o,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}if(c){const{node:o,mutation:u}=c;n.insertBefore(o,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}}moveAndHover(t,n,r,i,s){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(s,r);const l=it(a,this.iframe),c=t*l.absoluteScale+l.x,o=n*l.absoluteScale+l.y;this.mouse.style.left=`${c}px`,this.mouse.style.top=`${o}px`,i||this.drawMouseTail({x:c,y:o}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:n,lineWidth:r,strokeStyle:i,duration:s}=this.config.mouseTail===!0?De:Object.assign({},De,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=r,l.lineCap=n,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(c=>l.lineTo(c.x,c.y)),l.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==t),a()},s/this.speedService.state.context.timer.speed)}hoverElements(t){var n;(n=this.iframe.contentDocument)==null||n.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")});let r=t;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(t){return t.type!==C.IncrementalSnapshot?!1:t.data.source>x.Mutation&&t.data.source<=x.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(D.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,n){this.warn(`Node with id '${n}' not found. `,t)}warnCanvasMutationFailed(t,n){this.warn("Has error on canvas update",n,"canvas mutation:",t)}debugNodeNotFound(t,n){this.debug(be,`Node with id '${n}' not found. `,t)}warn(...t){!this.config.showWarning||console.warn(be,...t)}debug(...t){!this.config.showDebug||console.log(be,...t)}}return he.Replayer=An,Object.defineProperty(he,"__esModule",{value:!0}),he}({});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.replayer-wrapper{position:relative}.replayer-mouse{position:absolute;width:20px;height:20px;transition:left .05s linear,top .05s linear;background-size:contain;background-position:50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjcgNSAxOCAxOCIgaGVpZ2h0PSIzMDAiIHdpZHRoPSIzMDAiPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik04LjIgMjAuOXYtMTZsMTEuNiAxMS42SDEzbC0uNC4xeiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy4zIDIxLjZsLTMuNiAxLjVMOSAxMmwzLjctMS41eiIvPjxwYXRoIGQ9Ik0xMS4wMyAxNC4yOTNsMS44NDUtLjc3NCAzLjA5NiA3LjM3Ni0xLjg0NC43NzV6Ii8+PHBhdGggZD0iTTkuMiA3LjN2MTEuMmwzLTIuOS40LS4xaDQuOHoiLz48L3N2Zz4=");border-color:transparent}.replayer-mouse:after{background:transparent}.replayer-mouse.active:after{animation:click .2s ease-in-out 1}.replayer-mouse.touch-device{background-image:none;width:70px;height:70px;border-radius:100%;margin-left:-37px;margin-top:-37px;border:4px solid rgba(73,80,246,0);transition:left 0s linear,top 0s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device.touch-active{border-color:#4950f6;transition:left .25s linear,top .25s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device:after{opacity:0}.replayer-mouse.touch-device.active:after{animation:touch-click .2s ease-in-out 1}.replayer-mouse-tail{position:absolute;pointer-events:none}@keyframes click{0%{opacity:.3;width:20px;height:20px;background:transparent}75%{width:24px;height:24px;opacity:.8;background:#dc2626}to{background:transparent}}@keyframes touch-click{0%{opacity:0;width:20px;height:20px}50%{opacity:.5;width:10px;height:10px}}
|
|
1
|
+
.replayer-wrapper{position:relative}.replayer-mouse{position:absolute;width:20px;height:20px;transition:left .05s linear,top .05s linear;background-size:contain;background-position:50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjcgNSAxOCAxOCIgaGVpZ2h0PSIzMDAiIHdpZHRoPSIzMDAiPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik04LjIgMjAuOXYtMTZsMTEuNiAxMS42SDEzbC0uNC4xeiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy4zIDIxLjZsLTMuNiAxLjVMOSAxMmwzLjctMS41eiIvPjxwYXRoIGQ9Ik0xMS4wMyAxNC4yOTNsMS44NDUtLjc3NCAzLjA5NiA3LjM3Ni0xLjg0NC43NzV6Ii8+PHBhdGggZD0iTTkuMiA3LjN2MTEuMmwzLTIuOS40LS4xaDQuOHoiLz48L3N2Zz4=");border-color:transparent}.replayer-mouse:after{background:transparent}.replayer-mouse.active:after{animation:click .2s ease-in-out 1}.replayer-mouse.touch-device{background-image:none;width:70px;height:70px;border-radius:100%;margin-left:-37px;margin-top:-37px;border:4px solid rgba(73,80,246,0);transition:left 0s linear,top 0s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device.touch-active{border-color:#4950f6;transition:left .25s linear,top .25s linear,border-color .2s ease-in-out}.replayer-mouse.touch-device:after{opacity:0}.replayer-mouse.touch-device.active:after{animation:touch-click .2s ease-in-out 1}.replayer-mouse-tail{position:absolute;pointer-events:none}@keyframes click{0%{opacity:.3;width:20px;height:20px;background:transparent}75%{width:24px;height:24px;opacity:.8;background:#dc2626}to{background:transparent}}@keyframes touch-click{0%{opacity:0;width:20px;height:20px}50%{opacity:.5;width:10px;height:10px}}.rr-player{position:relative;background:#fff;float:left;border-radius:5px;box-shadow:0 24px 48px rgba(17,16,62,.12)}.rr-player__frame{overflow:hidden}
|
|
2
2
|
/*# sourceMappingURL=rrweb-replay.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["style.css"],"names":[],"mappings":"AAAA,kBACE,iBACF,CACA,gBACE,iBAAkB,CAClB,UAAW,CACX,WAAY,CACZ,2CAA+C,CAC/C,uBAAwB,CACxB,uBAAkC,CAClC,2BAA4B,CAC5B,0cAAuzB,CACvzB,wBACF,CAEA,sBACE,sBACF,CAEA,6BACE,iCACF,CACA,6BACE,qBAAsB,CACtB,UAAW,CACX,WAAY,CAGZ,kBAAmB,CACnB,iBAAkB,CAClB,gBAAiB,CACjB,kCAAkC,CAClC,oEACF,CACA,0CACE,oBAAkC,CAClC,wEACF,CACA,mCACE,SACF,CACA,0CACE,uCACF,CACA,qBACE,iBAAkB,CAClB,mBACF,CAEA,iBACE,GACE,UAAY,CACZ,UAAW,CACX,WAAY,CACZ,sBACF,CACA,IACE,UAAW,CACX,WAAY,CACZ,UAAY,CACZ,kBACF,CACA,GACE,sBACF,CACF,CAEA,uBACE,GACE,SAAU,CACV,UAAW,CACX,WACF,CACA,IACE,UAAY,CACZ,UAAW,CACX,WACF,CACF","file":"rrweb-replay.min.css","sourcesContent":[".replayer-wrapper {\n position: relative;\n}\n.replayer-mouse {\n position: absolute;\n width: 20px;\n height: 20px;\n transition: left 0.05s linear, top 0.05s linear;\n background-size: contain;\n background-position: center center;\n background-repeat: no-repeat;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iNyA1IDE4IDE4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyOCAyOCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgaGVpZ2h0PSIzMDBweCIgd2lkdGg9IjMwMHB4Ij4NCjxwb2x5Z29uIGZpbGw9IiNGRkZGRkYiIHBvaW50cz0iOC4yLDIwLjkgOC4yLDQuOSAxOS44LDE2LjUgMTMsMTYuNSAxMi42LDE2LjYgIi8+DQo8cG9seWdvbiBmaWxsPSIjRkZGRkZGIiBwb2ludHM9IjE3LjMsMjEuNiAxMy43LDIzLjEgOSwxMiAxMi43LDEwLjUgIi8+DQo8cmVjdCB4PSIxMi41IiB5PSIxMy42IiB0cmFuc2Zvcm09Im1hdHJpeCgwLjkyMjEgLTAuMzg3MSAwLjM4NzEgMC45MjIxIC01Ljc2MDUgNi41OTA5KSIgd2lkdGg9IjIiIGhlaWdodD0iOCIvPg0KPHBvbHlnb24gcG9pbnRzPSI5LjIsNy4zIDkuMiwxOC41IDEyLjIsMTUuNiAxMi42LDE1LjUgMTcuNCwxNS41ICIvPg0KPC9zdmc+DQo=');\n border-color: transparent; /* otherwise we transition from black when .touch-device class is added */\n}\n\n.replayer-mouse::after {\n background: transparent;\n}\n\n.replayer-mouse.active::after {\n animation: click 0.2s ease-in-out 1;\n}\n.replayer-mouse.touch-device {\n background-image: none; /* there's no passive cursor on touch-only screens */\n width: 70px;\n height: 70px;\n border-width: 4px;\n border-style: solid;\n border-radius: 100%;\n margin-left: -37px;\n margin-top: -37px;\n border-color: rgba(73, 80, 246, 0);\n transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out;\n}\n.replayer-mouse.touch-device.touch-active {\n border-color: rgba(73, 80, 246, 1);\n transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out;\n}\n.replayer-mouse.touch-device::after {\n opacity: 0; /* there's no passive cursor on touch-only screens */\n}\n.replayer-mouse.touch-device.active::after {\n animation: touch-click 0.2s ease-in-out 1;\n}\n.replayer-mouse-tail {\n position: absolute;\n pointer-events: none;\n}\n\n@keyframes click {\n 0% {\n opacity: 0.3;\n width: 20px;\n height: 20px;\n background: transparent;\n }\n 75% {\n width: 24px;\n height: 24px;\n opacity: 0.8;\n background: #dc2626;\n }\n 100% {\n background: transparent;\n }\n}\n\n@keyframes touch-click {\n 0% {\n opacity: 0;\n width: 20px;\n height: 20px;\n }\n 50% {\n opacity: 0.5;\n width: 10px;\n height: 10px;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["style.css"],"names":[],"mappings":"AAAA,kBACE,iBACF,CACA,gBACE,iBAAkB,CAClB,UAAW,CACX,WAAY,CACZ,2CAA+C,CAC/C,uBAAwB,CACxB,uBAAkC,CAClC,2BAA4B,CAC5B,0cAAuzB,CACvzB,wBACF,CAEA,sBACE,sBACF,CAEA,6BACE,iCACF,CACA,6BACE,qBAAsB,CACtB,UAAW,CACX,WAAY,CAGZ,kBAAmB,CACnB,iBAAkB,CAClB,gBAAiB,CACjB,kCAAkC,CAClC,oEACF,CACA,0CACE,oBAAkC,CAClC,wEACF,CACA,mCACE,SACF,CACA,0CACE,uCACF,CACA,qBACE,iBAAkB,CAClB,mBACF,CAEA,iBACE,GACE,UAAY,CACZ,UAAW,CACX,WAAY,CACZ,sBACF,CACA,IACE,UAAW,CACX,WAAY,CACZ,UAAY,CACZ,kBACF,CACA,GACE,sBACF,CACF,CAEA,uBACE,GACE,SAAU,CACV,UAAW,CACX,WACF,CACA,IACE,UAAY,CACZ,UAAW,CACX,WACF,CACF,CAEA,WACE,iBAAkB,CAClB,eAAiB,CACjB,UAAW,CACX,iBAAkB,CAClB,yCACF,CAEA,kBACE,eACF","file":"rrweb-replay.min.css","sourcesContent":[".replayer-wrapper {\n position: relative;\n}\n.replayer-mouse {\n position: absolute;\n width: 20px;\n height: 20px;\n transition: left 0.05s linear, top 0.05s linear;\n background-size: contain;\n background-position: center center;\n background-repeat: no-repeat;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iNyA1IDE4IDE4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyOCAyOCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgaGVpZ2h0PSIzMDBweCIgd2lkdGg9IjMwMHB4Ij4NCjxwb2x5Z29uIGZpbGw9IiNGRkZGRkYiIHBvaW50cz0iOC4yLDIwLjkgOC4yLDQuOSAxOS44LDE2LjUgMTMsMTYuNSAxMi42LDE2LjYgIi8+DQo8cG9seWdvbiBmaWxsPSIjRkZGRkZGIiBwb2ludHM9IjE3LjMsMjEuNiAxMy43LDIzLjEgOSwxMiAxMi43LDEwLjUgIi8+DQo8cmVjdCB4PSIxMi41IiB5PSIxMy42IiB0cmFuc2Zvcm09Im1hdHJpeCgwLjkyMjEgLTAuMzg3MSAwLjM4NzEgMC45MjIxIC01Ljc2MDUgNi41OTA5KSIgd2lkdGg9IjIiIGhlaWdodD0iOCIvPg0KPHBvbHlnb24gcG9pbnRzPSI5LjIsNy4zIDkuMiwxOC41IDEyLjIsMTUuNiAxMi42LDE1LjUgMTcuNCwxNS41ICIvPg0KPC9zdmc+DQo=');\n border-color: transparent; /* otherwise we transition from black when .touch-device class is added */\n}\n\n.replayer-mouse::after {\n background: transparent;\n}\n\n.replayer-mouse.active::after {\n animation: click 0.2s ease-in-out 1;\n}\n.replayer-mouse.touch-device {\n background-image: none; /* there's no passive cursor on touch-only screens */\n width: 70px;\n height: 70px;\n border-width: 4px;\n border-style: solid;\n border-radius: 100%;\n margin-left: -37px;\n margin-top: -37px;\n border-color: rgba(73, 80, 246, 0);\n transition: left 0s linear, top 0s linear, border-color 0.2s ease-in-out;\n}\n.replayer-mouse.touch-device.touch-active {\n border-color: rgba(73, 80, 246, 1);\n transition: left 0.25s linear, top 0.25s linear, border-color 0.2s ease-in-out;\n}\n.replayer-mouse.touch-device::after {\n opacity: 0; /* there's no passive cursor on touch-only screens */\n}\n.replayer-mouse.touch-device.active::after {\n animation: touch-click 0.2s ease-in-out 1;\n}\n.replayer-mouse-tail {\n position: absolute;\n pointer-events: none;\n}\n\n@keyframes click {\n 0% {\n opacity: 0.3;\n width: 20px;\n height: 20px;\n background: transparent;\n }\n 75% {\n width: 24px;\n height: 24px;\n opacity: 0.8;\n background: #dc2626;\n }\n 100% {\n background: transparent;\n }\n}\n\n@keyframes touch-click {\n 0% {\n opacity: 0;\n width: 20px;\n height: 20px;\n }\n 50% {\n opacity: 0.5;\n width: 10px;\n height: 10px;\n }\n}\n\n.rr-player {\n position: relative;\n background: white;\n float: left;\n border-radius: 5px;\n box-shadow: 0 24px 48px rgba(17, 16, 62, 0.12);\n}\n\n.rr-player__frame {\n overflow: hidden;\n}\n"]}
|
|
@@ -14,5 +14,5 @@ var rrwebReplay=function(he){"use strict";var A;(function(e){e[e.Document=0]="Do
|
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */function Ge(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(t===void 0||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(l){i={error:l}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}var z;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(z||(z={}));var Ye={type:"xstate.init"};function Te(e){return e===void 0?[]:[].concat(e)}function G(e){return{type:"xstate.assign",assignment:e}}function ze(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function se(e){return function(t){return e===t}}function Xe(e){return typeof e=="string"?{type:e}:e}function Qe(e,t){return{value:e,context:t,actions:[],changed:!1,matches:se(e)}}function qe(e,t,n){var r=t,i=!1;return[e.filter(function(s){if(s.type==="xstate.assign"){i=!0;var a=Object.assign({},r);return typeof s.assignment=="function"?a=s.assignment(r,n):Object.keys(s.assignment).forEach(function(l){a[l]=typeof s.assignment[l]=="function"?s.assignment[l](r,n):s.assignment[l]}),r=a,!1}return!0}),r,i]}function Je(e,t){t===void 0&&(t={});var n=Ge(qe(Te(e.states[e.initial].entry).map(function(a){return ze(a,t.actions)}),e.context,Ye),2),r=n[0],i=n[1],s={config:e,_options:t,initialState:{value:e.initial,actions:r,context:i,matches:se(e.initial)},transition:function(a,l){var c,o,u=typeof a=="string"?{value:a,context:e.context}:a,d=u.value,h=u.context,f=Xe(l),T=e.states[d];if(T.on){var y=Te(T.on[f.type]);try{for(var N=function(O){var re=typeof Symbol=="function"&&Symbol.iterator,g=re&&O[re],m=0;if(g)return g.call(O);if(O&&typeof O.length=="number")return{next:function(){return O&&m>=O.length&&(O=void 0),{value:O&&O[m++],done:!O}}};throw new TypeError(re?"Object is not iterable.":"Symbol.iterator is not defined.")}(y),p=N.next();!p.done;p=N.next()){var v=p.value;if(v===void 0)return Qe(d,h);var w=typeof v=="string"?{target:v}:v,M=w.target,I=w.actions,k=I===void 0?[]:I,$=w.cond,j=$===void 0?function(){return!0}:$,L=M===void 0,te=M??d,H=e.states[te];if(j(h,f)){var ne=Ge(qe((L?Te(k):[].concat(T.exit,k,H.entry).filter(function(O){return O})).map(function(O){return ze(O,s._options.actions)}),h,f),3),ue=ne[0],Ce=ne[1],Se=ne[2],q=M??d;return{value:q,context:Ce,actions:ue,changed:M!==d||ue.length>0||Se,matches:se(q)}}}}catch(O){c={error:O}}finally{try{p&&!p.done&&(o=N.return)&&o.call(N)}finally{if(c)throw c.error}}}return Qe(d,h)}};return s}var Ze=function(e,t){return e.actions.forEach(function(n){var r=n.exec;return r&&r(e.context,t)})};function Ke(e){var t=e.initialState,n=z.NotStarted,r=new Set,i={_machine:e,send:function(s){n===z.Running&&(t=e.transition(t,s),Ze(t,Xe(s)),r.forEach(function(a){return a(t)}))},subscribe:function(s){return r.add(s),s(t),{unsubscribe:function(){return r.delete(s)}}},start:function(s){if(s){var a=typeof s=="object"?s:{context:e.config.context,value:s};t={value:a.value,actions:[],context:a.context,matches:se(a.value)}}return n=z.Running,Ze(t,Ye),i},stop:function(){return n=z.Stopped,r.clear(),i},get state(){return t},get status(){return n}};return i}var tn=Object.defineProperty,nn=Object.defineProperties,rn=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,tt=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))on.call(t,n)&&tt(e,n,t[n]);if(et)for(var n of et(t))sn.call(t,n)&&tt(e,n,t[n]);return e},ce=(e,t)=>nn(e,rn(t));function an(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.type===C.Meta&&r.timestamp<=t)return e.slice(n)}return e}function cn(e,{getCastFn:t,applyEventsSynchronously:n,emitter:r}){const i=Je({id:"player",context:e,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:G({lastPlayedEvent:(s,a)=>a.type==="CAST_EVENT"?a.payload.event:s.lastPlayedEvent}),recordTimeOffset:G((s,a)=>{let l=s.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(l=a.payload.timeOffset),ce(ae({},s),{timeOffset:l,baselineTime:s.events[0].timestamp+l})}),play(s){var a;const{timer:l,events:c,baselineTime:o,lastPlayedEvent:u}=s;l.clear();for(const y of c)ve(y,o);const d=an(c,o);let h=u?.timestamp;u?.type===C.IncrementalSnapshot&&u.data.source===x.MouseMove&&(h=u.timestamp+((a=u.data.positions[0])==null?void 0:a.timeOffset)),o<(h||0)&&r.emit(D.PlayBack);const f=new Array,T=new Array;for(const y of d)if(!(h&&h<o&&(y.timestamp<=h||y===u)))if(y.timestamp<o)f.push(y);else{const N=t(y,!1);T.push({doAction:()=>{N()},delay:y.delay})}n(f),r.emit(D.Flush),l.addActions(T),l.start()},pause(s){s.timer.clear()},resetLastPlayedEvent:G(s=>ce(ae({},s),{lastPlayedEvent:null})),startLive:G({baselineTime:(s,a)=>(s.timer.toggleLiveMode(!0),s.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),replaceEvents:G((s,a)=>{const{events:l,timer:c,baselineTime:o}=s;if(a.type==="REPLACE_EVENTS"){const{events:u}=a.payload;l.length=0;const d=[];for(const h of u)if(ve(h,o),l.push(h),h.timestamp>=c.timeOffset+o){const f=t(h,!1);d.push({doAction:()=>{f()},delay:h.delay})}c.isActive()&&c.replaceActions(d)}return ce(ae({},s),{events:l})}),addEvent:G((s,a)=>{const{baselineTime:l,timer:c,events:o}=s;if(a.type==="ADD_EVENT"){const{event:u}=a.payload;ve(u,l);let d=o.length-1;if(!o[d]||o[d].timestamp<=u.timestamp)o.push(u);else{let T=-1,y=0;for(;y<=d;){const N=Math.floor((y+d)/2);o[N].timestamp<=u.timestamp?y=N+1:d=N-1}T===-1&&(T=y),o.splice(T,0,u)}const h=u.timestamp<l,f=t(u,h);h?f():c.isActive()&&c.addAction({doAction:()=>{f()},delay:u.delay})}return ce(ae({},s),{events:o})})}});return Ke(i)}function ln(e){const t=Je({id:"speed",context:e,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(n,r)=>{"payload"in r&&n.timer.setSpeed(r.payload.speed)},recordSpeed:G({normalSpeed:n=>n.timer.speed}),restoreSpeed:n=>{n.timer.setSpeed(n.normalSpeed)}}});return Ke(t)}const X=`Please stop import mirror directly. Instead of that,\r
|
|
16
16
|
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
17
|
-
or you can use record.mirror to access the mirror instance during recording.`;let nt={map:{},getId(){return console.error(X),-1},getNode(){return console.error(X),null},removeNodeFromMap(){console.error(X)},has(){return console.error(X),!1},reset(){console.error(X)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(nt=new Proxy(nt,{get(e,t,n){return t==="map"&&console.error(X),Reflect.get(e,t,n)}}));function un(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(t){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===t)return!0;while(t=t&&t.parentNode);return!1})}function dn(e){const t={},n=(i,s)=>{const a={value:i,parent:s,children:[]};return t[i.node.id]=a,a},r=[];for(const i of e){const{nextId:s,parentId:a}=i;if(s&&s in t){const l=t[s];if(l.parent){const c=l.parent.children.indexOf(l);l.parent.children.splice(c,0,n(i,l.parent))}else{const c=r.indexOf(l);r.splice(c,0,n(i,null))}continue}if(a in t){const l=t[a];l.children.push(n(i,l));continue}r.push(n(i,null))}return r}function rt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)rt(e.children[n],t)}function Ne(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function it(e,t){var n,r;const i=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!i||i===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=i.getBoundingClientRect(),a=it(i,t),l=s.height/i.clientHeight;return{x:s.x*a.relativeScale+a.x,y:s.y*a.relativeScale+a.y,relativeScale:l,absoluteScale:a.absoluteScale*l}}function ot(e){return Boolean(e?.shadowRoot)}function K(e,t){const n=e[t[0]];return t.length===1?n:K(n.cssRules[t[1]].cssRules,t.slice(2))}function st(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function hn(e){const t=new Set,n=[];for(let r=e.length;r--;){const i=e[r];t.has(i.id)||(n.push(i),t.add(i.id))}return n}const mn=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }",`.${e} { background: currentColor; border-radius: 5px; }`,`.${e}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ee=typeof Uint8Array>"u"?[]:new Uint8Array(256),le=0;le<at.length;le++)ee[at.charCodeAt(le)]=le;var pn=function(e){var t=e.length*.75,n=e.length,r,i=0,s,a,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var o=new ArrayBuffer(t),u=new Uint8Array(o);for(r=0;r<n;r+=4)s=ee[e.charCodeAt(r)],a=ee[e.charCodeAt(r+1)],l=ee[e.charCodeAt(r+2)],c=ee[e.charCodeAt(r+3)],u[i++]=s<<2|a>>4,u[i++]=(a&15)<<4|l>>2,u[i++]=(l&3)<<6|c&63;return o},fn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const ct=new Map;function lt(e,t){let n=ct.get(e);return n||(n=new Map,ct.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function W(e,t,n){return r=>fn(this,null,function*(){if(r&&typeof r=="object"&&"rr_type"in r)if(n&&(n.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=yield W(e,t,n)(r.args);return yield createImageBitmap.apply(null,i)}else if("index"in r){if(n||t===null)return r;const{rr_type:i,index:s}=r;return lt(t,i)[s]}else if("args"in r){const{rr_type:i,args:s}=r,a=window[i];return new a(...yield Promise.all(s.map(W(e,t,n))))}else{if("base64"in r)return pn(r.base64);if("src"in r){const i=e.get(r.src);if(i)return i;{const s=new Image;return s.src=r.src,e.set(r.src,s),s}}else if("data"in r&&r.rr_type==="Blob"){const i=yield Promise.all(r.data.map(W(e,t,n)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return yield Promise.all(r.map(W(e,t,n)));return r})}var gn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function yn(e,t){try{return t===oe.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const vn=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tn(e,t){if(!(t!=null&&t.constructor))return;const{name:n}=t.constructor;if(!vn.includes(n))return;const r=lt(e,n);r.includes(t)||r.push(t)}function Nn(e){return gn(this,arguments,function*({mutation:t,target:n,type:r,imageMap:i,errorHandler:s}){try{const a=yn(n,r);if(!a)return;if(t.setter){a[t.property]=t.args[0];return}const l=a[t.property],c=yield Promise.all(t.args.map(W(i,a))),o=l.apply(a,c);Tn(a,o)}catch(a){s(t,a)}})}var En=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function wn(e){return En(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,errorHandler:s}){try{const a=r.getContext("2d");if(n.setter){a[n.property]=n.args[0];return}const l=a[n.property];if(n.property==="drawImage"&&typeof n.args[0]=="string"){const c=i.get(t);l.apply(a,n.args)}else{const c=yield Promise.all(n.args.map(W(i,a)));l.apply(a,c)}}catch(a){s(n,a)}})}var bn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function ut(e){return bn(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,canvasEventMap:s,errorHandler:a}){try{const l=s.get(t)||n,c="commands"in l?l.commands:[l];if([oe.WebGL,oe.WebGL2].includes(n.type)){for(let o=0;o<c.length;o++){const u=c[o];yield Nn({mutation:u,type:n.type,target:r,imageMap:i,errorHandler:a})}return}for(let o=0;o<c.length;o++){const u=c[o];yield wn({event:t,mutation:u,target:r,imageMap:i,errorHandler:a})}}catch(l){a(n,l)}})}var Dn=Object.defineProperty,Mn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,ht=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&ht(e,n,t[n]);if(dt)for(var n of dt(t))xn.call(t,n)&&ht(e,n,t[n]);return e},Ee=(e,t)=>Mn(e,Cn(t)),we=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const mt=10*1e3,pt=2*1e3,ft=1*1e3,gt=60*60*1e3,Rn=He||Zt,be="[replayer]",De={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Me(e){return e.type==C.IncrementalSnapshot&&(e.data.source==x.TouchMove||e.data.source==x.MouseInteraction&&e.data.type==_.TouchStart)}class An{constructor(t,n){if(this.usingVirtualDom=!1,this.virtualDom=new Y,this.mouseTail=null,this.tailPositions=[],this.emitter=Rn(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=ke(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Tt(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(n!=null&&n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:De,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:pt};this.config=Object.assign({},r,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(D.Resize,this.handleResize),this.setupDom(),this.emitter.on(D.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(c,o,u)=>{ut({event:c,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(B(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const o=this.legacy_missingNodeRetryMap[c],u=ge(o.node,this.mirror,this.virtualDom.mirror);B(u,o.node,l,this.virtualDom.mirror),o.node=u}catch(o){this.config.showWarning&&console.warn(o)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(D.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const i=new en([],n?.speed||r.speed);this.service=cn({events:t.map(l=>n&&n.unpackFn?n.unpackFn(l):l).sort((l,c)=>l.timestamp-c.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(D.StateChange,{player:l})}),this.speedService=ln({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(D.StateChange,{speed:l})});const s=this.service.state.context.events.find(l=>l.type===C.Meta),a=this.service.state.context.events.find(l=>l.type===C.FullSnapshot);if(s){const{width:l,height:c}=s.data;setTimeout(()=>{this.emitter.emit(D.Resize,{width:l,height:c})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Me)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,n){return this.emitter.on(t,n),this}off(t,n){return this.emitter.off(t,n),this}setConfig(t){Object.keys(t).forEach(n=>{this.config[n]=t[n]}),this.config.skipInactive||this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const t=[],n=this.getMetaData(),r=[{timestamp:n.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:n.endTime}];for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a];c.timestamp-l.timestamp>mt?t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!1}):t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!0})}const i=[];let s=t[0];for(let a=1;a<t.length;a++)t[a].active!=t[a-1].active&&(i.push({startTime:s.startTime,endTime:t[a-1].endTime,duration:t[a-1].endTime-s.startTime,active:t[a-1].active}),s=t[a]);s&&t.length>0&&i.push({startTime:s.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-s.startTime,active:t[t.length-1].active}),s=i[0];for(let a=1;a<i.length;a++)(!i[a].active&&i[a].duration>this.config.inactiveThreshold*n.totalTime||!i[a-1].active&&i[a-1].duration>this.config.inactiveThreshold*n.totalTime)&&(this.activityIntervals.push({startTime:s.startTime,endTime:i[a-1].endTime,duration:i[a-1].endTime-s.startTime,active:i[a-1].active}),s=i[a]);s&&i.length>0&&this.activityIntervals.push({startTime:s.startTime,endTime:i[i.length-1].endTime,duration:i[i.length-1].endTime-s.startTime,active:i[i.length-1].active})}return this.activityIntervals}getMetaData(){const t=this.service.state.context.events[0],n=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:n}=this.service.state.context;return t-n[0].timestamp}getMirror(){return this.mirror}play(t=0){var n,r;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(D.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)}pause(t){var n,r;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(D.Pause)}resume(t=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(D.Resume)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const n=this.config.unpackFn?this.config.unpackFn(t):t;Me(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:n}}))}replaceEvents(t){for(const n of t)if(Me(n)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:t}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=ke()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Kt(this.iframe.contentWindow,this.iframe.contentDocument),un(this.iframe.contentWindow))}handleResize(t){this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])!n||(n.setAttribute("width",String(t.width)),n.setAttribute("height",String(t.height)))}applyEventsSynchronously(t){for(const n of t){switch(n.type){case C.DomContentLoaded:case C.Load:case C.Custom:continue;case C.FullSnapshot:case C.Meta:case C.Plugin:case C.IncrementalSnapshot:break}this.getCastFn(n,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(t,n=!1){let r;switch(t.type){case C.DomContentLoaded:case C.Load:break;case C.Custom:r=()=>{this.emitter.emit(D.CustomEvent,t)};break;case C.Meta:r=()=>this.emitter.emit(D.Resize,{width:t.data.width,height:t.data.height});break;case C.FullSnapshot:r=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===t){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(t,n),this.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case C.IncrementalSnapshot:r=()=>{if(this.applyIncremental(t,n),!n&&(this.handleInactivity(t.timestamp),t===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const i of this.service.state.context.events)if(!(i.timestamp<=t.timestamp)&&this.isUserInteraction(i)){i.delay-t.delay>mt*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=i);break}if(this.nextUserInteractionEvent){const i=this.nextUserInteractionEvent.delay-t.delay,s={speed:Math.min(Math.round(i/pt),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:s}),this.emitter.emit(D.SkipStart,s)}}};break}return()=>{r&&r();for(const s of this.config.plugins||[])s.handler(t,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:t}});const i=this.service.state.context.events.length-1;if(t===this.service.state.context.events[i]){const s=()=>{i<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(D.Finish))};t.type===C.IncrementalSnapshot&&t.data.source===x.MouseMove&&t.data.positions.length?setTimeout(()=>{s()},Math.max(0,-t.data.positions[0].timeOffset+50)):s()}this.emitter.emit(D.EventCast,t)}}handleInactivity(t,n){if((t===this.inactiveEndTimestamp||n)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const r of this.getActivityIntervals())if(t>=r.startTime&&t<r.endTime&&!r.active){this.inactiveEndTimestamp=r.endTime;break}if(this.inactiveEndTimestamp){const r=this.inactiveEndTimestamp-t,i={speed:r/gt*this.config.inactiveSkipTime<ft?r/ft:Math.round(Math.max(r,gt)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:i}),this.emitter.emit(D.SkipStart,i)}}}rebuildFullSnapshot(t,n=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const r=[];St(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(r,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:l}of r)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:i,head:s}=this.iframe.contentDocument;this.insertStyleRules(i,s),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(D.FullsnapshotRebuilded,t),n||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,n){const r=mn(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const i=this.virtualDom.createElement("style");this.virtualDom.mirror.add(i,je(i,this.virtualDom.unserializedId)),t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.rules.push({cssText:r[s],type:U.Insert,index:s})}else{const i=document.createElement("style");t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.sheet.insertRule(r[s],s)}}attachDocumentToIframe(t,n){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[];ie(t.node,{doc:n.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:s=>{this.collectIframeAndAttachDocument(i,s);const a=r.getMeta(s);if(a?.type===A.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:l,head:c}=n.contentDocument;this.insertStyleRules(l,c)}},cache:this.cache});for(const{mutationInQueue:s,builtNode:a}of i)this.attachDocumentToIframe(s,a),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==s)}collectIframeAndAttachDocument(t,n){if(Ne(n,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(n));r&&t.push({mutationInQueue:r,builtNode:n})}}waitForStylesheetLoad(){var t;const n=(t=this.iframe.contentDocument)==null?void 0:t.head;if(n){const r=new Set;let i,s=this.service.state;const a=()=>{s=this.service.state};this.emitter.on(D.Start,a),this.emitter.on(D.Pause,a);const l=()=>{this.emitter.off(D.Start,a),this.emitter.off(D.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{c.sheet||(r.add(c),c.addEventListener("load",()=>{r.delete(c),r.size===0&&i!==-1&&(s.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(D.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(D.LoadStylesheetStart),i=setTimeout(()=>{s.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},this.config.loadTimeout))}}hasImageArg(t){for(const n of t)if(!(!n||typeof n!="object")){if("rr_type"in n&&"args"in n){if(this.hasImageArg(n.args))return!0}else if("rr_type"in n&&n.rr_type==="HTMLImageElement"||n instanceof Array&&this.hasImageArg(n))return!0}return!1}getImageArgs(t){const n=[];for(const r of t)!r||typeof r!="object"||("rr_type"in r&&"args"in r?n.push(...this.getImageArgs(r.args)):"rr_type"in r&&r.rr_type==="HTMLImageElement"?n.push(r.src):r instanceof Array&&n.push(...this.getImageArgs(r)));return n}preloadAllImages(){return we(this,null,function*(){this.service.state;const t=()=>{this.service.state};this.emitter.on(D.Start,t),this.emitter.on(D.Pause,t);const n=[];for(const r of this.service.state.context.events)r.type===C.IncrementalSnapshot&&r.data.source===x.CanvasMutation&&(n.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(n)})}preloadImages(t,n){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(n)){const r=document.createElement("canvas"),i=r.getContext("2d"),s=i?.createImageData(r.width,r.height);s?.data,JSON.parse(t.args[0]),i?.putImageData(s,0,0)}}deserializeAndPreloadCanvasEvents(t,n){return we(this,null,function*(){if(!this.canvasEventMap.has(n)){const r={isUnchanged:!0};if("commands"in t){const i=yield Promise.all(t.commands.map(s=>we(this,null,function*(){const a=yield Promise.all(s.args.map(W(this.imageMap,null,r)));return Ee(Q({},s),{args:a})})));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{commands:i}))}else{const i=yield Promise.all(t.args.map(W(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{args:i}))}}})}applyIncremental(t,n){var r,i,s,a,l,c;const{data:o}=t;switch(o.source){case x.Mutation:{try{this.applyMutation(o,n)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case x.Drag:case x.TouchMove:case x.MouseMove:if(n){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,n,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case x.MouseInteraction:{if(o.id===-1||n)break;const u=new Event(_[o.type].toLowerCase()),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(D.MouseInteraction,{type:o.type,target:d});const{triggerFocus:h}=this.config;switch(o.type){case _.Blur:"blur"in d&&d.blur();break;case _.Focus:h&&d.focus&&d.focus({preventScroll:!0});break;case _.Click:case _.TouchStart:case _.TouchEnd:n?(o.type===_.TouchStart?this.touchActive=!0:o.type===_.TouchEnd&&(this.touchActive=!1),this.mousePos={x:o.x,y:o.y,id:o.id,debugData:o}):(o.type===_.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x,o.y,o.id,n,o),o.type===_.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===_.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===_.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case _.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case x.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,n);break}case x.ViewportResize:this.emitter.emit(D.Resize,{width:o.width,height:o.height});break;case x.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case x.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u;try{o.currentTime&&(d.currentTime=o.currentTime),o.volume&&(d.volume=o.volume),o.muted&&(d.muted=o.muted),o.type===ye.Pause&&d.pause(),o.type===ye.Play&&d.play()}catch(h){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${h.message||h}`)}break}case x.StyleSheetRule:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;(i=o.adds)==null||i.forEach(({rule:h,index:f})=>d?.push({cssText:h,index:f,type:U.Insert})),(s=o.removes)==null||s.forEach(({index:h})=>d?.push({index:h,type:U.Remove}))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;(a=o.adds)==null||a.forEach(({rule:h,index:f})=>{try{if(Array.isArray(f)){const{positions:T,index:y}=st(f);K(d.cssRules,T).insertRule(h,y)}else{const T=f===void 0?void 0:Math.min(f,d.cssRules.length);d.insertRule(h,T)}}catch{}}),(l=o.removes)==null||l.forEach(({index:h})=>{try{if(Array.isArray(h)){const{positions:f,index:T}=st(h);K(d.cssRules,f).deleteRule(T||0)}else d?.deleteRule(h)}catch{}})}break}case x.StyleDeclaration:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;o.set&&d.push(Q({type:U.SetProperty,index:o.index},o.set)),o.remove&&d.push(Q({type:U.RemoveProperty,index:o.index},o.remove))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;o.set&&K(d.rules,o.index).style.setProperty(o.set.property,o.set.value,o.set.priority),o.remove&&K(d.rules,o.index).style.removeProperty(o.remove.property)}break}case x.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);ut({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case x.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(c=this.iframe.contentDocument)==null||c.fonts.add(u)}catch(u){this.config.showWarning&&console.warn(u)}break}}}applyMutation(t,n){if(this.config.useVirtualDom&&!this.usingVirtualDom&&n&&(this.usingVirtualDom=!0,Qt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const o in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[o],d=We(u.node,this.virtualDom,this.mirror);d&&(u.node=d)}catch(u){this.config.showWarning&&console.warn(u)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes.forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(f=>f.id===o.parentId)?void 0:this.warnNodeNotFound(t,o.id);let h=r.getNode(o.parentId);if(!h)return this.warnNodeNotFound(t,o.parentId);if(o.isShadow&&ot(h)&&(h=h.shadowRoot),r.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((u=h.rules)==null?void 0:u.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),s=[],a=o=>{let u=null;return o.nextId&&(u=r.getNode(o.nextId)),o.nextId!==null&&o.nextId!==void 0&&o.nextId!==-1&&!u},l=o=>{var u;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let d=r.getNode(o.parentId);if(!d)return o.node.type===A.Document?this.newDocumentQueue.push(o):s.push(o);o.node.isShadow&&(ot(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,f=null;if(o.previousId&&(h=r.getNode(o.previousId)),o.nextId&&(f=r.getNode(o.nextId)),a(o))return s.push(o);if(o.node.rootId&&!r.getNode(o.node.rootId))return;const T=o.node.rootId?r.getNode(o.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ne(d,r)){this.attachDocumentToIframe(o,d);return}const y=ie(o.node,{doc:T,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});if(o.previousId===-1||o.nextId===-1){i[o.node.id]={node:y,mutation:o};return}const N=r.getMeta(d);if(N&&N.type===A.Element&&N.tagName==="textarea"&&o.node.type===A.Text){const p=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const v of p)v.nodeType===d.TEXT_NODE&&d.removeChild(v)}if(h&&h.nextSibling&&h.nextSibling.parentNode)d.insertBefore(y,h.nextSibling);else if(f&&f.parentNode)d.contains(f)?d.insertBefore(y,f):d.insertBefore(y,null);else{if(d===T)for(;T.firstChild;)T.removeChild(T.firstChild);d.appendChild(y)}if(this.usingVirtualDom&&y.nodeName==="#text"&&d.nodeName==="STYLE"&&((u=d.rules)==null?void 0:u.length)>0&&(d.rules=[]),Ne(y,this.mirror)){const p=this.mirror.getId(y),v=this.newDocumentQueue.find(w=>w.parentId===p);v&&(this.attachDocumentToIframe(v,y),this.newDocumentQueue=this.newDocumentQueue.filter(w=>w!==v))}(o.previousId||o.nextId)&&this.legacy_resolveMissingNode(i,d,y,o)};t.adds.forEach(o=>{l(o)});const c=Date.now();for(;s.length;){const o=dn(s);if(s.length=0,Date.now()-c>500){this.warn("Timeout in the loop, please check the resolve tree data:",o);break}for(const u of o)r.getNode(u.value.parentId)?rt(u,d=>{l(d)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),hn(t.texts).forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(h=>h.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);if(d.textContent=o.value,this.usingVirtualDom){const h=d.parentNode;((u=h?.rules)==null?void 0:u.length)>0&&(h.rules=[])}}),t.attributes.forEach(o=>{const u=r.getNode(o.id);if(!u)return t.removes.find(d=>d.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);for(const d in o.attributes)if(typeof d=="string"){const h=o.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{u.setAttribute(d,h)}catch(f){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",f)}else if(d==="style"){const f=h,T=u;for(const y in f)if(f[y]===!1)T.style.removeProperty(y);else if(f[y]instanceof Array){const N=f[y];T.style.setProperty(y,N[0],N[1])}else{const N=f[y];T.style.setProperty(y,N)}}}})}applyScroll(t,n){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const i=this.mirror.getMeta(r);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else if(i?.type===A.Document)r.defaultView.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=t.y,r.scrollLeft=t.x}catch{}}applyInput(t){const n=this.mirror.getNode(t.id);if(!n)return this.debugNodeNotFound(t,t.id);try{n.checked=t.isChecked,n.value=t.text}catch{}}legacy_resolveMissingNode(t,n,r,i){const{previousId:s,nextId:a}=i,l=s&&t[s],c=a&&t[a];if(l){const{node:o,mutation:u}=l;n.insertBefore(o,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}if(c){const{node:o,mutation:u}=c;n.insertBefore(o,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}}moveAndHover(t,n,r,i,s){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(s,r);const l=it(a,this.iframe),c=t*l.absoluteScale+l.x,o=n*l.absoluteScale+l.y;this.mouse.style.left=`${c}px`,this.mouse.style.top=`${o}px`,i||this.drawMouseTail({x:c,y:o}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:n,lineWidth:r,strokeStyle:i,duration:s}=this.config.mouseTail===!0?De:Object.assign({},De,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=r,l.lineCap=n,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(c=>l.lineTo(c.x,c.y)),l.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==t),a()},s/this.speedService.state.context.timer.speed)}hoverElements(t){var n;(n=this.iframe.contentDocument)==null||n.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")});let r=t;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(t){return t.type!==C.IncrementalSnapshot?!1:t.data.source>x.Mutation&&t.data.source<=x.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(D.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,n){this.warn(`Node with id '${n}' not found. `,t)}warnCanvasMutationFailed(t,n){this.warn("Has error on canvas update",n,"canvas mutation:",t)}debugNodeNotFound(t,n){this.debug(be,`Node with id '${n}' not found. `,t)}warn(...t){!this.config.showWarning||console.warn(be,...t)}debug(...t){!this.config.showDebug||console.log(be,...t)}}return he.Replayer=An,Object.defineProperty(he,"__esModule",{value:!0}),he}({});
|
|
17
|
+
or you can use record.mirror to access the mirror instance during recording.`;let nt={map:{},getId(){return console.error(X),-1},getNode(){return console.error(X),null},removeNodeFromMap(){console.error(X)},has(){return console.error(X),!1},reset(){console.error(X)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(nt=new Proxy(nt,{get(e,t,n){return t==="map"&&console.error(X),Reflect.get(e,t,n)}}));function un(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(t){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===t)return!0;while(t=t&&t.parentNode);return!1})}function dn(e){const t={},n=(i,s)=>{const a={value:i,parent:s,children:[]};return t[i.node.id]=a,a},r=[];for(const i of e){const{nextId:s,parentId:a}=i;if(s&&s in t){const l=t[s];if(l.parent){const c=l.parent.children.indexOf(l);l.parent.children.splice(c,0,n(i,l.parent))}else{const c=r.indexOf(l);r.splice(c,0,n(i,null))}continue}if(a in t){const l=t[a];l.children.push(n(i,l));continue}r.push(n(i,null))}return r}function rt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)rt(e.children[n],t)}function Ne(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function it(e,t){var n,r;const i=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!i||i===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=i.getBoundingClientRect(),a=it(i,t),l=s.height/i.clientHeight;return{x:s.x*a.relativeScale+a.x,y:s.y*a.relativeScale+a.y,relativeScale:l,absoluteScale:a.absoluteScale*l}}function ot(e){return Boolean(e?.shadowRoot)}function K(e,t){const n=e[t[0]];return t.length===1?n:K(n.cssRules[t[1]].cssRules,t.slice(2))}function st(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function hn(e){const t=new Set,n=[];for(let r=e.length;r--;){const i=e[r];t.has(i.id)||(n.push(i),t.add(i.id))}return n}const mn=e=>["noscript { display: none !important; }",`.${e} { background: currentColor; border-radius: 5px; }`,`.${e}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ee=typeof Uint8Array>"u"?[]:new Uint8Array(256),le=0;le<at.length;le++)ee[at.charCodeAt(le)]=le;var pn=function(e){var t=e.length*.75,n=e.length,r,i=0,s,a,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var o=new ArrayBuffer(t),u=new Uint8Array(o);for(r=0;r<n;r+=4)s=ee[e.charCodeAt(r)],a=ee[e.charCodeAt(r+1)],l=ee[e.charCodeAt(r+2)],c=ee[e.charCodeAt(r+3)],u[i++]=s<<2|a>>4,u[i++]=(a&15)<<4|l>>2,u[i++]=(l&3)<<6|c&63;return o},fn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const ct=new Map;function lt(e,t){let n=ct.get(e);return n||(n=new Map,ct.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function W(e,t,n){return r=>fn(this,null,function*(){if(r&&typeof r=="object"&&"rr_type"in r)if(n&&(n.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=yield W(e,t,n)(r.args);return yield createImageBitmap.apply(null,i)}else if("index"in r){if(n||t===null)return r;const{rr_type:i,index:s}=r;return lt(t,i)[s]}else if("args"in r){const{rr_type:i,args:s}=r,a=window[i];return new a(...yield Promise.all(s.map(W(e,t,n))))}else{if("base64"in r)return pn(r.base64);if("src"in r){const i=e.get(r.src);if(i)return i;{const s=new Image;return s.src=r.src,e.set(r.src,s),s}}else if("data"in r&&r.rr_type==="Blob"){const i=yield Promise.all(r.data.map(W(e,t,n)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return yield Promise.all(r.map(W(e,t,n)));return r})}var gn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function yn(e,t){try{return t===oe.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const vn=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tn(e,t){if(!(t!=null&&t.constructor))return;const{name:n}=t.constructor;if(!vn.includes(n))return;const r=lt(e,n);r.includes(t)||r.push(t)}function Nn(e){return gn(this,arguments,function*({mutation:t,target:n,type:r,imageMap:i,errorHandler:s}){try{const a=yn(n,r);if(!a)return;if(t.setter){a[t.property]=t.args[0];return}const l=a[t.property],c=yield Promise.all(t.args.map(W(i,a))),o=l.apply(a,c);Tn(a,o)}catch(a){s(t,a)}})}var En=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function wn(e){return En(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,errorHandler:s}){try{const a=r.getContext("2d");if(n.setter){a[n.property]=n.args[0];return}const l=a[n.property];if(n.property==="drawImage"&&typeof n.args[0]=="string"){const c=i.get(t);l.apply(a,n.args)}else{const c=yield Promise.all(n.args.map(W(i,a)));l.apply(a,c)}}catch(a){s(n,a)}})}var bn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});function ut(e){return bn(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,canvasEventMap:s,errorHandler:a}){try{const l=s.get(t)||n,c="commands"in l?l.commands:[l];if([oe.WebGL,oe.WebGL2].includes(n.type)){for(let o=0;o<c.length;o++){const u=c[o];yield Nn({mutation:u,type:n.type,target:r,imageMap:i,errorHandler:a})}return}for(let o=0;o<c.length;o++){const u=c[o];yield wn({event:t,mutation:u,target:r,imageMap:i,errorHandler:a})}}catch(l){a(n,l)}})}var Dn=Object.defineProperty,Mn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,ht=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&ht(e,n,t[n]);if(dt)for(var n of dt(t))xn.call(t,n)&&ht(e,n,t[n]);return e},Ee=(e,t)=>Mn(e,Cn(t)),we=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{l(n.next(c))}catch(o){i(o)}},a=c=>{try{l(n.throw(c))}catch(o){i(o)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);l((n=n.apply(e,t)).next())});const mt=10*1e3,pt=2*1e3,ft=1*1e3,gt=60*60*1e3,Rn=He||Zt,be="[replayer]",De={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Me(e){return e.type==C.IncrementalSnapshot&&(e.data.source==x.TouchMove||e.data.source==x.MouseInteraction&&e.data.type==_.TouchStart)}class An{constructor(t,n){if(this.usingVirtualDom=!1,this.virtualDom=new Y,this.mouseTail=null,this.tailPositions=[],this.emitter=Rn(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=ke(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Tt(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(n!=null&&n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:De,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:pt};this.config=Object.assign({},r,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(D.Resize,this.handleResize),this.setupDom(),this.emitter.on(D.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(c,o,u)=>{ut({event:c,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(B(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const o=this.legacy_missingNodeRetryMap[c],u=ge(o.node,this.mirror,this.virtualDom.mirror);B(u,o.node,l,this.virtualDom.mirror),o.node=u}catch(o){this.config.showWarning&&console.warn(o)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(D.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const i=new en([],n?.speed||r.speed);this.service=cn({events:t.map(l=>n&&n.unpackFn?n.unpackFn(l):l).sort((l,c)=>l.timestamp-c.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(D.StateChange,{player:l})}),this.speedService=ln({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(D.StateChange,{speed:l})});const s=this.service.state.context.events.find(l=>l.type===C.Meta),a=this.service.state.context.events.find(l=>l.type===C.FullSnapshot);if(s){const{width:l,height:c}=s.data;setTimeout(()=>{this.emitter.emit(D.Resize,{width:l,height:c})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Me)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,n){return this.emitter.on(t,n),this}off(t,n){return this.emitter.off(t,n),this}setConfig(t){Object.keys(t).forEach(n=>{this.config[n]=t[n]}),this.config.skipInactive||this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const t=[],n=this.getMetaData(),r=[{timestamp:n.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:n.endTime}];for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a];c.timestamp-l.timestamp>mt?t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!1}):t.push({startTime:l.timestamp,endTime:c.timestamp,duration:c.timestamp-l.timestamp,active:!0})}const i=[];let s=t[0];for(let a=1;a<t.length;a++)t[a].active!=t[a-1].active&&(i.push({startTime:s.startTime,endTime:t[a-1].endTime,duration:t[a-1].endTime-s.startTime,active:t[a-1].active}),s=t[a]);s&&t.length>0&&i.push({startTime:s.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-s.startTime,active:t[t.length-1].active}),s=i[0];for(let a=1;a<i.length;a++)(!i[a].active&&i[a].duration>this.config.inactiveThreshold*n.totalTime||!i[a-1].active&&i[a-1].duration>this.config.inactiveThreshold*n.totalTime)&&(this.activityIntervals.push({startTime:s.startTime,endTime:i[a-1].endTime,duration:i[a-1].endTime-s.startTime,active:i[a-1].active}),s=i[a]);s&&i.length>0&&this.activityIntervals.push({startTime:s.startTime,endTime:i[i.length-1].endTime,duration:i[i.length-1].endTime-s.startTime,active:i[i.length-1].active})}return this.activityIntervals}getMetaData(){const t=this.service.state.context.events[0],n=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:n}=this.service.state.context;return t-n[0].timestamp}getMirror(){return this.mirror}play(t=0){var n,r;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(D.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)}pause(t){var n,r;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(D.Pause)}resume(t=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(D.Resume)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const n=this.config.unpackFn?this.config.unpackFn(t):t;Me(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:n}}))}replaceEvents(t){for(const n of t)if(Me(n)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:t}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=ke()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Kt(this.iframe.contentWindow,this.iframe.contentDocument),un(this.iframe.contentWindow))}handleResize(t){this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])!n||(n.setAttribute("width",String(t.width)),n.setAttribute("height",String(t.height)))}applyEventsSynchronously(t){for(const n of t){switch(n.type){case C.DomContentLoaded:case C.Load:case C.Custom:continue;case C.FullSnapshot:case C.Meta:case C.Plugin:case C.IncrementalSnapshot:break}this.getCastFn(n,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(t,n=!1){let r;switch(t.type){case C.DomContentLoaded:case C.Load:break;case C.Custom:r=()=>{this.emitter.emit(D.CustomEvent,t)};break;case C.Meta:r=()=>this.emitter.emit(D.Resize,{width:t.data.width,height:t.data.height});break;case C.FullSnapshot:r=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===t){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(t,n),this.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case C.IncrementalSnapshot:r=()=>{if(this.applyIncremental(t,n),!n&&(this.handleInactivity(t.timestamp),t===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const i of this.service.state.context.events)if(!(i.timestamp<=t.timestamp)&&this.isUserInteraction(i)){i.delay-t.delay>mt*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=i);break}if(this.nextUserInteractionEvent){const i=this.nextUserInteractionEvent.delay-t.delay,s={speed:Math.min(Math.round(i/pt),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:s}),this.emitter.emit(D.SkipStart,s)}}};break}return()=>{r&&r();for(const s of this.config.plugins||[])s.handler(t,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:t}});const i=this.service.state.context.events.length-1;if(t===this.service.state.context.events[i]){const s=()=>{i<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(D.Finish))};t.type===C.IncrementalSnapshot&&t.data.source===x.MouseMove&&t.data.positions.length?setTimeout(()=>{s()},Math.max(0,-t.data.positions[0].timeOffset+50)):s()}this.emitter.emit(D.EventCast,t)}}handleInactivity(t,n){if((t===this.inactiveEndTimestamp||n)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const r of this.getActivityIntervals())if(t>=r.startTime&&t<r.endTime&&!r.active){this.inactiveEndTimestamp=r.endTime;break}if(this.inactiveEndTimestamp){const r=this.inactiveEndTimestamp-t,i={speed:r/gt*this.config.inactiveSkipTime<ft?r/ft:Math.round(Math.max(r,gt)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:i}),this.emitter.emit(D.SkipStart,i)}}}rebuildFullSnapshot(t,n=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const r=[];St(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(r,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:l}of r)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:i,head:s}=this.iframe.contentDocument;this.insertStyleRules(i,s),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(D.FullsnapshotRebuilded,t),n||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,n){const r=mn(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const i=this.virtualDom.createElement("style");this.virtualDom.mirror.add(i,je(i,this.virtualDom.unserializedId)),t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.rules.push({cssText:r[s],type:U.Insert,index:s})}else{const i=document.createElement("style");t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.sheet.insertRule(r[s],s)}}attachDocumentToIframe(t,n){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[];ie(t.node,{doc:n.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:s=>{this.collectIframeAndAttachDocument(i,s);const a=r.getMeta(s);if(a?.type===A.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:l,head:c}=n.contentDocument;this.insertStyleRules(l,c)}},cache:this.cache});for(const{mutationInQueue:s,builtNode:a}of i)this.attachDocumentToIframe(s,a),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==s)}collectIframeAndAttachDocument(t,n){if(Ne(n,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(n));r&&t.push({mutationInQueue:r,builtNode:n})}}waitForStylesheetLoad(){var t;const n=(t=this.iframe.contentDocument)==null?void 0:t.head;if(n){const r=new Set;let i,s=this.service.state;const a=()=>{s=this.service.state};this.emitter.on(D.Start,a),this.emitter.on(D.Pause,a);const l=()=>{this.emitter.off(D.Start,a),this.emitter.off(D.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{c.sheet||(r.add(c),c.addEventListener("load",()=>{r.delete(c),r.size===0&&i!==-1&&(s.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(D.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(D.LoadStylesheetStart),i=setTimeout(()=>{s.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},this.config.loadTimeout))}}hasImageArg(t){for(const n of t)if(!(!n||typeof n!="object")){if("rr_type"in n&&"args"in n){if(this.hasImageArg(n.args))return!0}else if("rr_type"in n&&n.rr_type==="HTMLImageElement"||n instanceof Array&&this.hasImageArg(n))return!0}return!1}getImageArgs(t){const n=[];for(const r of t)!r||typeof r!="object"||("rr_type"in r&&"args"in r?n.push(...this.getImageArgs(r.args)):"rr_type"in r&&r.rr_type==="HTMLImageElement"?n.push(r.src):r instanceof Array&&n.push(...this.getImageArgs(r)));return n}preloadAllImages(){return we(this,null,function*(){this.service.state;const t=()=>{this.service.state};this.emitter.on(D.Start,t),this.emitter.on(D.Pause,t);const n=[];for(const r of this.service.state.context.events)r.type===C.IncrementalSnapshot&&r.data.source===x.CanvasMutation&&(n.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(n)})}preloadImages(t,n){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(n)){const r=document.createElement("canvas"),i=r.getContext("2d"),s=i?.createImageData(r.width,r.height);s?.data,JSON.parse(t.args[0]),i?.putImageData(s,0,0)}}deserializeAndPreloadCanvasEvents(t,n){return we(this,null,function*(){if(!this.canvasEventMap.has(n)){const r={isUnchanged:!0};if("commands"in t){const i=yield Promise.all(t.commands.map(s=>we(this,null,function*(){const a=yield Promise.all(s.args.map(W(this.imageMap,null,r)));return Ee(Q({},s),{args:a})})));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{commands:i}))}else{const i=yield Promise.all(t.args.map(W(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{args:i}))}}})}applyIncremental(t,n){var r,i,s,a,l,c;const{data:o}=t;switch(o.source){case x.Mutation:{try{this.applyMutation(o,n)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case x.Drag:case x.TouchMove:case x.MouseMove:if(n){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,n,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case x.MouseInteraction:{if(o.id===-1||n)break;const u=new Event(_[o.type].toLowerCase()),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(D.MouseInteraction,{type:o.type,target:d});const{triggerFocus:h}=this.config;switch(o.type){case _.Blur:"blur"in d&&d.blur();break;case _.Focus:h&&d.focus&&d.focus({preventScroll:!0});break;case _.Click:case _.TouchStart:case _.TouchEnd:n?(o.type===_.TouchStart?this.touchActive=!0:o.type===_.TouchEnd&&(this.touchActive=!1),this.mousePos={x:o.x,y:o.y,id:o.id,debugData:o}):(o.type===_.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x,o.y,o.id,n,o),o.type===_.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===_.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===_.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case _.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case x.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,n);break}case x.ViewportResize:this.emitter.emit(D.Resize,{width:o.width,height:o.height});break;case x.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case x.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u;try{o.currentTime&&(d.currentTime=o.currentTime),o.volume&&(d.volume=o.volume),o.muted&&(d.muted=o.muted),o.type===ye.Pause&&d.pause(),o.type===ye.Play&&d.play()}catch(h){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${h.message||h}`)}break}case x.StyleSheetRule:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;(i=o.adds)==null||i.forEach(({rule:h,index:f})=>d?.push({cssText:h,index:f,type:U.Insert})),(s=o.removes)==null||s.forEach(({index:h})=>d?.push({index:h,type:U.Remove}))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;(a=o.adds)==null||a.forEach(({rule:h,index:f})=>{try{if(Array.isArray(f)){const{positions:T,index:y}=st(f);K(d.cssRules,T).insertRule(h,y)}else{const T=f===void 0?void 0:Math.min(f,d.cssRules.length);d.insertRule(h,T)}}catch{}}),(l=o.removes)==null||l.forEach(({index:h})=>{try{if(Array.isArray(h)){const{positions:f,index:T}=st(h);K(d.cssRules,f).deleteRule(T||0)}else d?.deleteRule(h)}catch{}})}break}case x.StyleDeclaration:{if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.rules;o.set&&d.push(Q({type:U.SetProperty,index:o.index},o.set)),o.remove&&d.push(Q({type:U.RemoveProperty,index:o.index},o.remove))}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u.sheet;o.set&&K(d.rules,o.index).style.setProperty(o.set.property,o.set.value,o.set.priority),o.remove&&K(d.rules,o.index).style.removeProperty(o.remove.property)}break}case x.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);ut({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case x.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(c=this.iframe.contentDocument)==null||c.fonts.add(u)}catch(u){this.config.showWarning&&console.warn(u)}break}}}applyMutation(t,n){if(this.config.useVirtualDom&&!this.usingVirtualDom&&n&&(this.usingVirtualDom=!0,Qt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const o in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[o],d=We(u.node,this.virtualDom,this.mirror);d&&(u.node=d)}catch(u){this.config.showWarning&&console.warn(u)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes.forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(f=>f.id===o.parentId)?void 0:this.warnNodeNotFound(t,o.id);let h=r.getNode(o.parentId);if(!h)return this.warnNodeNotFound(t,o.parentId);if(o.isShadow&&ot(h)&&(h=h.shadowRoot),r.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((u=h.rules)==null?void 0:u.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),s=[],a=o=>{let u=null;return o.nextId&&(u=r.getNode(o.nextId)),o.nextId!==null&&o.nextId!==void 0&&o.nextId!==-1&&!u},l=o=>{var u;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let d=r.getNode(o.parentId);if(!d)return o.node.type===A.Document?this.newDocumentQueue.push(o):s.push(o);o.node.isShadow&&(ot(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,f=null;if(o.previousId&&(h=r.getNode(o.previousId)),o.nextId&&(f=r.getNode(o.nextId)),a(o))return s.push(o);if(o.node.rootId&&!r.getNode(o.node.rootId))return;const T=o.node.rootId?r.getNode(o.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ne(d,r)){this.attachDocumentToIframe(o,d);return}const y=ie(o.node,{doc:T,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});if(o.previousId===-1||o.nextId===-1){i[o.node.id]={node:y,mutation:o};return}const N=r.getMeta(d);if(N&&N.type===A.Element&&N.tagName==="textarea"&&o.node.type===A.Text){const p=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const v of p)v.nodeType===d.TEXT_NODE&&d.removeChild(v)}if(h&&h.nextSibling&&h.nextSibling.parentNode)d.insertBefore(y,h.nextSibling);else if(f&&f.parentNode)d.contains(f)?d.insertBefore(y,f):d.insertBefore(y,null);else{if(d===T)for(;T.firstChild;)T.removeChild(T.firstChild);d.appendChild(y)}if(this.usingVirtualDom&&y.nodeName==="#text"&&d.nodeName==="STYLE"&&((u=d.rules)==null?void 0:u.length)>0&&(d.rules=[]),Ne(y,this.mirror)){const p=this.mirror.getId(y),v=this.newDocumentQueue.find(w=>w.parentId===p);v&&(this.attachDocumentToIframe(v,y),this.newDocumentQueue=this.newDocumentQueue.filter(w=>w!==v))}(o.previousId||o.nextId)&&this.legacy_resolveMissingNode(i,d,y,o)};t.adds.forEach(o=>{l(o)});const c=Date.now();for(;s.length;){const o=dn(s);if(s.length=0,Date.now()-c>500){this.warn("Timeout in the loop, please check the resolve tree data:",o);break}for(const u of o)r.getNode(u.value.parentId)?rt(u,d=>{l(d)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),hn(t.texts).forEach(o=>{var u;const d=r.getNode(o.id);if(!d)return t.removes.find(h=>h.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);if(d.textContent=o.value,this.usingVirtualDom){const h=d.parentNode;((u=h?.rules)==null?void 0:u.length)>0&&(h.rules=[])}}),t.attributes.forEach(o=>{const u=r.getNode(o.id);if(!u)return t.removes.find(d=>d.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);for(const d in o.attributes)if(typeof d=="string"){const h=o.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{u.setAttribute(d,h)}catch(f){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",f)}else if(d==="style"){const f=h,T=u;for(const y in f)if(f[y]===!1)T.style.removeProperty(y);else if(f[y]instanceof Array){const N=f[y];T.style.setProperty(y,N[0],N[1])}else{const N=f[y];T.style.setProperty(y,N)}}}})}applyScroll(t,n){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const i=this.mirror.getMeta(r);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else if(i?.type===A.Document)r.defaultView.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=t.y,r.scrollLeft=t.x}catch{}}applyInput(t){const n=this.mirror.getNode(t.id);if(!n)return this.debugNodeNotFound(t,t.id);try{n.checked=t.isChecked,n.value=t.text}catch{}}legacy_resolveMissingNode(t,n,r,i){const{previousId:s,nextId:a}=i,l=s&&t[s],c=a&&t[a];if(l){const{node:o,mutation:u}=l;n.insertBefore(o,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}if(c){const{node:o,mutation:u}=c;n.insertBefore(o,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,n,o,u)}}moveAndHover(t,n,r,i,s){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(s,r);const l=it(a,this.iframe),c=t*l.absoluteScale+l.x,o=n*l.absoluteScale+l.y;this.mouse.style.left=`${c}px`,this.mouse.style.top=`${o}px`,i||this.drawMouseTail({x:c,y:o}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:n,lineWidth:r,strokeStyle:i,duration:s}=this.config.mouseTail===!0?De:Object.assign({},De,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=r,l.lineCap=n,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(c=>l.lineTo(c.x,c.y)),l.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==t),a()},s/this.speedService.state.context.timer.speed)}hoverElements(t){var n;(n=this.iframe.contentDocument)==null||n.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")});let r=t;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(t){return t.type!==C.IncrementalSnapshot?!1:t.data.source>x.Mutation&&t.data.source<=x.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(D.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,n){this.warn(`Node with id '${n}' not found. `,t)}warnCanvasMutationFailed(t,n){this.warn("Has error on canvas update",n,"canvas mutation:",t)}debugNodeNotFound(t,n){this.debug(be,`Node with id '${n}' not found. `,t)}warn(...t){!this.config.showWarning||console.warn(be,...t)}debug(...t){!this.config.showDebug||console.log(be,...t)}}return he.Replayer=An,Object.defineProperty(he,"__esModule",{value:!0}),he}({});
|
|
18
18
|
//# sourceMappingURL=rrweb-replay.min.js.map
|