static/replay.js
Rama main · réplica de lectura del repositorio original.
/*!
* The bundle below is rrweb v2.0.0-alpha.11 (dist/rrweb.min.js), reformatted but
* otherwise unmodified: https://github.com/rrweb-io/rrweb
* Betterlytics' own recorder wrapper follows it at the end of this file.
*
* MIT License
*
* Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors) and SmartX Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* The rrweb bundle inlines rrweb-snapshot and rrdom (same project, same terms),
* plus @xstate/fsm (MIT, (c) 2015 David Khourshid), base64-arraybuffer
* (MIT, (c) 2012 Niklas von Hertzen) and mitt (MIT, (c) 2021 Jason Miller), all
* under the MIT terms above, and tslib (0BSD, (c) Microsoft Corporation) whose
* notice is retained inline further down.
*/
var rrweb = (function (re) {
"use strict";
var N;
(function (t) {
(t[(t.Document = 0)] = "Document"),
(t[(t.DocumentType = 1)] = "DocumentType"),
(t[(t.Element = 2)] = "Element"),
(t[(t.Text = 3)] = "Text"),
(t[(t.CDATA = 4)] = "CDATA"),
(t[(t.Comment = 5)] = "Comment");
})(N || (N = {}));
function Bt(t) {
return t.nodeType === t.ELEMENT_NODE;
}
function Pe(t) {
var e = t?.host;
return Boolean(e?.shadowRoot === t);
}
function We(t) {
return Object.prototype.toString.call(t) === "[object ShadowRoot]";
}
function mn(t) {
return (
t.includes(" background-clip: text;") &&
!t.includes(" -webkit-background-clip: text;") &&
(t = t.replace(
" background-clip: text;",
" -webkit-background-clip: text; background-clip: text;"
)),
t
);
}
function fn(t) {
var e = t.cssText;
if (e.split('"').length < 3) return e;
var r = ["@import", "url(".concat(JSON.stringify(t.href), ")")];
return (
t.layerName === ""
? r.push("layer")
: t.layerName && r.push("layer(".concat(t.layerName, ")")),
t.supportsText && r.push("supports(".concat(t.supportsText, ")")),
t.media.length && r.push(t.media.mediaText),
r.join(" ") + ";"
);
}
function Ye(t) {
try {
var e = t.rules || t.cssRules;
return e ? mn(Array.from(e).map(Gt).join("")) : null;
} catch {
return null;
}
}
function Gt(t) {
var e;
if (gn(t))
try {
e = Ye(t.styleSheet) || fn(t);
} catch {}
return yn(e || t.cssText);
}
function yn(t) {
if (t.includes(":")) {
var e = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
return t.replace(e, "$1\\$2");
}
return t;
}
function gn(t) {
return "styleSheet" in t;
}
var dt = (function () {
function t() {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}
return (
(t.prototype.getId = function (e) {
var r;
if (!e) return -1;
var n = (r = this.getMeta(e)) === null || r === void 0 ? void 0 : r.id;
return n ?? -1;
}),
(t.prototype.getNode = function (e) {
return this.idNodeMap.get(e) || null;
}),
(t.prototype.getIds = function () {
return Array.from(this.idNodeMap.keys());
}),
(t.prototype.getMeta = function (e) {
return this.nodeMetaMap.get(e) || null;
}),
(t.prototype.removeNodeFromMap = function (e) {
var r = this,
n = this.getId(e);
this.idNodeMap.delete(n),
e.childNodes &&
e.childNodes.forEach(function (o) {
return r.removeNodeFromMap(o);
});
}),
(t.prototype.has = function (e) {
return this.idNodeMap.has(e);
}),
(t.prototype.hasNode = function (e) {
return this.nodeMetaMap.has(e);
}),
(t.prototype.add = function (e, r) {
var n = r.id;
this.idNodeMap.set(n, e), this.nodeMetaMap.set(e, r);
}),
(t.prototype.replace = function (e, r) {
var n = this.getNode(e);
if (n) {
var o = this.nodeMetaMap.get(n);
o && this.nodeMetaMap.set(r, o);
}
this.idNodeMap.set(e, r);
}),
(t.prototype.reset = function () {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}),
t
);
})();
function jt() {
return new dt();
}
function ht(t) {
var e = t.element,
r = t.maskInputOptions,
n = t.tagName,
o = t.type,
a = t.value,
i = t.maskInputFn,
l = a || "",
s = o && ge(o);
return (
(r[n.toLowerCase()] || (s && r[s])) &&
(i ? (l = i(l, e)) : (l = "*".repeat(l.length))),
l
);
}
function ge(t) {
return t.toLowerCase();
}
var zt = "__rrweb_original__";
function vn(t) {
var e = t.getContext("2d");
if (!e) return !0;
for (var r = 50, n = 0; n < t.width; n += r)
for (var o = 0; o < t.height; o += r) {
var a = e.getImageData,
i = zt in a ? a[zt] : a,
l = new Uint32Array(
i.call(
e,
n,
o,
Math.min(r, t.width - n),
Math.min(r, t.height - o)
).data.buffer
);
if (
l.some(function (s) {
return s !== 0;
})
)
return !1;
}
return !0;
}
function Sn(t, e) {
return !t || !e || t.type !== e.type
? !1
: t.type === N.Document
? t.compatMode === e.compatMode
: t.type === N.DocumentType
? t.name === e.name &&
t.publicId === e.publicId &&
t.systemId === e.systemId
: t.type === N.Comment || t.type === N.Text || t.type === N.CDATA
? t.textContent === e.textContent
: t.type === N.Element
? t.tagName === e.tagName &&
JSON.stringify(t.attributes) === JSON.stringify(e.attributes) &&
t.isSVG === e.isSVG &&
t.needBlock === e.needBlock
: !1;
}
function pt(t) {
var e = t.type;
return t.hasAttribute("data-rr-is-password")
? "password"
: e
? ge(e)
: null;
}
var bn = 1,
wn = new RegExp("[^a-z0-9-_:]"),
$e = -2;
function Ht() {
return bn++;
}
function Cn(t) {
if (t instanceof HTMLFormElement) return "form";
var e = ge(t.tagName);
return wn.test(e) ? "div" : e;
}
function En(t) {
var e = "";
return (
t.indexOf("//") > -1
? (e = t.split("/").slice(0, 3).join("/"))
: (e = t.split("/")[0]),
(e = e.split("?")[0]),
e
);
}
var Te,
Yt,
Tn = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,
Nn = /^(?:[a-z+]+:)?\/\//i,
Mn = /^www\..*/i,
In = /^(data:)([^,]*),(.*)/i;
function Xe(t, e) {
return (t || "").replace(Tn, function (r, n, o, a, i, l) {
var s = o || i || l,
c = n || a || "";
if (!s) return r;
if (Nn.test(s) || Mn.test(s) || In.test(s))
return "url(".concat(c).concat(s).concat(c, ")");
if (s[0] === "/")
return "url("
.concat(c)
.concat(En(e) + s)
.concat(c, ")");
var u = e.split("/"),
d = s.split("/");
u.pop();
for (var h = 0, m = d; h < m.length; h++) {
var p = m[h];
p !== "." && (p === ".." ? u.pop() : u.push(p));
}
return "url(".concat(c).concat(u.join("/")).concat(c, ")");
});
}
var Dn = /^[^ \t\n\r\u000c]+/,
kn = /^[, \t\n\r\u000c]+/;
function Rn(t, e) {
if (e.trim() === "") return e;
var r = 0;
function n(c) {
var u,
d = c.exec(e.substring(r));
return d ? ((u = d[0]), (r += u.length), u) : "";
}
for (var o = []; n(kn), !(r >= e.length); ) {
var a = n(Dn);
if (a.slice(-1) === ",")
(a = Ze(t, a.substring(0, a.length - 1))), o.push(a);
else {
var i = "";
a = Ze(t, a);
for (var l = !1; ; ) {
var s = e.charAt(r);
if (s === "") {
o.push((a + i).trim());
break;
} else if (l) s === ")" && (l = !1);
else if (s === ",") {
(r += 1), o.push((a + i).trim());
break;
} else s === "(" && (l = !0);
(i += s), (r += 1);
}
}
}
return o.join(", ");
}
function Ze(t, e) {
if (!e || e.trim() === "") return e;
var r = t.createElement("a");
return (r.href = e), r.href;
}
function xn(t) {
return Boolean(t.tagName === "svg" || t.ownerSVGElement);
}
function mt() {
var t = document.createElement("a");
return (t.href = ""), t.href;
}
function Xt(t, e, r, n) {
return (
n &&
(r === "src" ||
(r === "href" && !(e === "use" && n[0] === "#")) ||
(r === "xlink:href" && n[0] !== "#") ||
(r === "background" && (e === "table" || e === "td" || e === "th"))
? Ze(t, n)
: r === "srcset"
? Rn(t, n)
: r === "style"
? Xe(n, mt())
: e === "object" && r === "data"
? Ze(t, n)
: n)
);
}
function Zt(t, e, r) {
return (t === "video" || t === "audio") && e === "autoplay";
}
function On(t, e, r) {
try {
if (typeof e == "string") {
if (t.classList.contains(e)) return !0;
} else
for (var n = t.classList.length; n--; ) {
var o = t.classList[n];
if (e.test(o)) return !0;
}
if (r) return t.matches(r);
} catch {}
return !1;
}
function Ke(t, e, r) {
if (!t) return !1;
if (t.nodeType !== t.ELEMENT_NODE) return r ? Ke(t.parentNode, e, r) : !1;
for (var n = t.classList.length; n--; ) {
var o = t.classList[n];
if (e.test(o)) return !0;
}
return r ? Ke(t.parentNode, e, r) : !1;
}
function Kt(t, e, r) {
try {
var n = t.nodeType === t.ELEMENT_NODE ? t : t.parentElement;
if (n === null) return !1;
if (typeof e == "string") {
if (n.classList.contains(e) || n.closest(".".concat(e))) return !0;
} else if (Ke(n, e, !0)) return !0;
if (r && (n.matches(r) || n.closest(r))) return !0;
} catch {}
return !1;
}
function Ln(t, e, r) {
var n = t.contentWindow;
if (n) {
var o = !1,
a;
try {
a = n.document.readyState;
} catch {
return;
}
if (a !== "complete") {
var i = setTimeout(function () {
o || (e(), (o = !0));
}, r);
t.addEventListener("load", function () {
clearTimeout(i), (o = !0), e();
});
return;
}
var l = "about:blank";
if (n.location.href !== l || t.src === l || t.src === "")
return setTimeout(e, 0), t.addEventListener("load", e);
t.addEventListener("load", e);
}
}
function An(t, e, r) {
var n = !1,
o;
try {
o = t.sheet;
} catch {
return;
}
if (!o) {
var a = setTimeout(function () {
n || (e(), (n = !0));
}, r);
t.addEventListener("load", function () {
clearTimeout(a), (n = !0), e();
});
}
}
function _n(t, e) {
var r = e.doc,
n = e.mirror,
o = e.blockClass,
a = e.blockSelector,
i = e.maskTextClass,
l = e.maskTextSelector,
s = e.inlineStylesheet,
c = e.maskInputOptions,
u = c === void 0 ? {} : c,
d = e.maskTextFn,
h = e.maskInputFn,
m = e.dataURLOptions,
p = m === void 0 ? {} : m,
v = e.inlineImages,
b = e.recordCanvas,
f = e.keepIframeSrcFn,
y = e.newlyAddedElement,
g = y === void 0 ? !1 : y,
C = Fn(r, n);
switch (t.nodeType) {
case t.DOCUMENT_NODE:
return t.compatMode !== "CSS1Compat"
? { type: N.Document, childNodes: [], compatMode: t.compatMode }
: { type: N.Document, childNodes: [] };
case t.DOCUMENT_TYPE_NODE:
return {
type: N.DocumentType,
name: t.name,
publicId: t.publicId,
systemId: t.systemId,
rootId: C,
};
case t.ELEMENT_NODE:
return Wn(t, {
doc: r,
blockClass: o,
blockSelector: a,
inlineStylesheet: s,
maskInputOptions: u,
maskInputFn: h,
dataURLOptions: p,
inlineImages: v,
recordCanvas: b,
keepIframeSrcFn: f,
newlyAddedElement: g,
rootId: C,
});
case t.TEXT_NODE:
return Pn(t, {
maskTextClass: i,
maskTextSelector: l,
maskTextFn: d,
rootId: C,
});
case t.CDATA_SECTION_NODE:
return { type: N.CDATA, textContent: "", rootId: C };
case t.COMMENT_NODE:
return { type: N.Comment, textContent: t.textContent || "", rootId: C };
default:
return !1;
}
}
function Fn(t, e) {
if (e.hasNode(t)) {
var r = e.getId(t);
return r === 1 ? void 0 : r;
}
}
function Pn(t, e) {
var r,
n = e.maskTextClass,
o = e.maskTextSelector,
a = e.maskTextFn,
i = e.rootId,
l = t.parentNode && t.parentNode.tagName,
s = t.textContent,
c = l === "STYLE" ? !0 : void 0,
u = l === "SCRIPT" ? !0 : void 0;
if (c && s) {
try {
t.nextSibling ||
t.previousSibling ||
(!((r = t.parentNode.sheet) === null || r === void 0) &&
r.cssRules &&
(s = Ye(t.parentNode.sheet)));
} catch (d) {
console.warn(
"Cannot get CSS styles from text's parentNode. Error: ".concat(d),
t
);
}
s = Xe(s, mt());
}
return (
u && (s = "SCRIPT_PLACEHOLDER"),
!c && !u && s && Kt(t, n, o) && (s = a ? a(s) : s.replace(/[\S]/g, "*")),
{ type: N.Text, textContent: s || "", isStyle: c, rootId: i }
);
}
function Wn(t, e) {
for (
var r = e.doc,
n = e.blockClass,
o = e.blockSelector,
a = e.inlineStylesheet,
i = e.maskInputOptions,
l = i === void 0 ? {} : i,
s = e.maskInputFn,
c = e.dataURLOptions,
u = c === void 0 ? {} : c,
d = e.inlineImages,
h = e.recordCanvas,
m = e.keepIframeSrcFn,
p = e.newlyAddedElement,
v = p === void 0 ? !1 : p,
b = e.rootId,
f = On(t, n, o),
y = Cn(t),
g = {},
C = t.attributes.length,
M = 0;
M < C;
M++
) {
var R = t.attributes[M];
Zt(y, R.name, R.value) || (g[R.name] = Xt(r, y, ge(R.name), R.value));
}
if (y === "link" && a) {
var _ = Array.from(r.styleSheets).find(function (D) {
return D.href === t.href;
}),
P = null;
_ && (P = Ye(_)),
P && (delete g.rel, delete g.href, (g._cssText = Xe(P, _.href)));
}
if (
y === "style" &&
t.sheet &&
!(t.innerText || t.textContent || "").trim().length
) {
var P = Ye(t.sheet);
P && (g._cssText = Xe(P, mt()));
}
if (y === "input" || y === "textarea" || y === "select") {
var Z = t.value,
K = t.checked;
if (
g.type !== "radio" &&
g.type !== "checkbox" &&
g.type !== "submit" &&
g.type !== "button" &&
Z
) {
var Y = pt(t);
g.value = ht({
element: t,
type: Y,
tagName: y,
value: Z,
maskInputOptions: l,
maskInputFn: s,
});
} else K && (g.checked = K);
}
if (
(y === "option" &&
(t.selected && !l.select ? (g.selected = !0) : delete g.selected),
y === "canvas" && h)
) {
if (t.__context === "2d")
vn(t) || (g.rr_dataURL = t.toDataURL(u.type, u.quality));
else if (!("__context" in t)) {
var J = t.toDataURL(u.type, u.quality),
Q = document.createElement("canvas");
(Q.width = t.width), (Q.height = t.height);
var ie = Q.toDataURL(u.type, u.quality);
J !== ie && (g.rr_dataURL = J);
}
}
if (y === "img" && d) {
Te || ((Te = r.createElement("canvas")), (Yt = Te.getContext("2d")));
var U = t,
j = U.crossOrigin;
U.crossOrigin = "anonymous";
var F = function () {
U.removeEventListener("load", F);
try {
(Te.width = U.naturalWidth),
(Te.height = U.naturalHeight),
Yt.drawImage(U, 0, 0),
(g.rr_dataURL = Te.toDataURL(u.type, u.quality));
} catch (D) {
console.warn(
"Cannot inline img src=".concat(U.currentSrc, "! Error: ").concat(D)
);
}
j ? (g.crossOrigin = j) : U.removeAttribute("crossorigin");
};
U.complete && U.naturalWidth !== 0 ? F() : U.addEventListener("load", F);
}
if (
((y === "audio" || y === "video") &&
((g.rr_mediaState = t.paused ? "paused" : "played"),
(g.rr_mediaCurrentTime = t.currentTime)),
v ||
(t.scrollLeft && (g.rr_scrollLeft = t.scrollLeft),
t.scrollTop && (g.rr_scrollTop = t.scrollTop)),
f)
) {
var q = t.getBoundingClientRect(),
w = q.width,
S = q.height;
g = {
class: g.class,
rr_width: "".concat(w, "px"),
rr_height: "".concat(S, "px"),
};
}
return (
y === "iframe" &&
!m(g.src) &&
(t.contentDocument || (g.rr_src = g.src), delete g.src),
{
type: N.Element,
tagName: y,
attributes: g,
childNodes: [],
isSVG: xn(t) || void 0,
needBlock: f,
rootId: b,
}
);
}
function $(t) {
return t == null ? "" : t.toLowerCase();
}
function $n(t, e) {
return !!(
(e.comment && t.type === N.Comment) ||
(t.type === N.Element &&
((e.script &&
(t.tagName === "script" ||
(t.tagName === "link" &&
(t.attributes.rel === "preload" ||
t.attributes.rel === "modulepreload") &&
t.attributes.as === "script") ||
(t.tagName === "link" &&
t.attributes.rel === "prefetch" &&
typeof t.attributes.href == "string" &&
t.attributes.href.endsWith(".js")))) ||
(e.headFavicon &&
((t.tagName === "link" && t.attributes.rel === "shortcut icon") ||
(t.tagName === "meta" &&
($(t.attributes.name).match(
/^msapplication-tile(image|color)$/
) ||
$(t.attributes.name) === "application-name" ||
$(t.attributes.rel) === "icon" ||
$(t.attributes.rel) === "apple-touch-icon" ||
$(t.attributes.rel) === "shortcut icon")))) ||
(t.tagName === "meta" &&
((e.headMetaDescKeywords &&
$(t.attributes.name).match(/^description|keywords$/)) ||
(e.headMetaSocial &&
($(t.attributes.property).match(/^(og|twitter|fb):/) ||
$(t.attributes.name).match(/^(og|twitter):/) ||
$(t.attributes.name) === "pinterest")) ||
(e.headMetaRobots &&
($(t.attributes.name) === "robots" ||
$(t.attributes.name) === "googlebot" ||
$(t.attributes.name) === "bingbot")) ||
(e.headMetaHttpEquiv && t.attributes["http-equiv"] !== void 0) ||
(e.headMetaAuthorship &&
($(t.attributes.name) === "author" ||
$(t.attributes.name) === "generator" ||
$(t.attributes.name) === "framework" ||
$(t.attributes.name) === "publisher" ||
$(t.attributes.name) === "progid" ||
$(t.attributes.property).match(/^article:/) ||
$(t.attributes.property).match(/^product:/))) ||
(e.headMetaVerification &&
($(t.attributes.name) === "google-site-verification" ||
$(t.attributes.name) === "yandex-verification" ||
$(t.attributes.name) === "csrf-token" ||
$(t.attributes.name) === "p:domain_verify" ||
$(t.attributes.name) === "verify-v1" ||
$(t.attributes.name) === "verification" ||
$(t.attributes.name) === "shopify-checkout-api-token"))))))
);
}
function Ne(t, e) {
var r = e.doc,
n = e.mirror,
o = e.blockClass,
a = e.blockSelector,
i = e.maskTextClass,
l = e.maskTextSelector,
s = e.skipChild,
c = s === void 0 ? !1 : s,
u = e.inlineStylesheet,
d = u === void 0 ? !0 : u,
h = e.maskInputOptions,
m = h === void 0 ? {} : h,
p = e.maskTextFn,
v = e.maskInputFn,
b = e.slimDOMOptions,
f = e.dataURLOptions,
y = f === void 0 ? {} : f,
g = e.inlineImages,
C = g === void 0 ? !1 : g,
M = e.recordCanvas,
R = M === void 0 ? !1 : M,
_ = e.onSerialize,
P = e.onIframeLoad,
Z = e.iframeLoadTimeout,
K = Z === void 0 ? 5e3 : Z,
Y = e.onStylesheetLoad,
J = e.stylesheetLoadTimeout,
Q = J === void 0 ? 5e3 : J,
ie = e.keepIframeSrcFn,
U =
ie === void 0
? function () {
return !1;
}
: ie,
j = e.newlyAddedElement,
F = j === void 0 ? !1 : j,
q = e.preserveWhiteSpace,
w = q === void 0 ? !0 : q,
S = _n(t, {
doc: r,
mirror: n,
blockClass: o,
blockSelector: a,
maskTextClass: i,
maskTextSelector: l,
inlineStylesheet: d,
maskInputOptions: m,
maskTextFn: p,
maskInputFn: v,
dataURLOptions: y,
inlineImages: C,
recordCanvas: R,
keepIframeSrcFn: U,
newlyAddedElement: F,
});
if (!S) return console.warn(t, "not serialized"), null;
var D;
n.hasNode(t)
? (D = n.getId(t))
: $n(S, b) ||
(!w &&
S.type === N.Text &&
!S.isStyle &&
!S.textContent.replace(/^\s+|\s+$/gm, "").length)
? (D = $e)
: (D = Ht());
var I = Object.assign(S, { id: D });
if ((n.add(t, I), D === $e)) return null;
_ && _(t);
var H = !c;
if (I.type === N.Element) {
(H = H && !I.needBlock), delete I.needBlock;
var de = t.shadowRoot;
de && We(de) && (I.isShadowHost = !0);
}
if ((I.type === N.Document || I.type === N.Element) && H) {
b.headWhitespace &&
I.type === N.Element &&
I.tagName === "head" &&
(w = !1);
for (
var ut = {
doc: r,
mirror: n,
blockClass: o,
blockSelector: a,
maskTextClass: i,
maskTextSelector: l,
skipChild: c,
inlineStylesheet: d,
maskInputOptions: m,
maskTextFn: p,
maskInputFn: v,
slimDOMOptions: b,
dataURLOptions: y,
inlineImages: C,
recordCanvas: R,
preserveWhiteSpace: w,
onSerialize: _,
onIframeLoad: P,
iframeLoadTimeout: K,
onStylesheetLoad: Y,
stylesheetLoadTimeout: Q,
keepIframeSrcFn: U,
},
le = 0,
he = Array.from(t.childNodes);
le < he.length;
le++
) {
var Ee = he[le],
ce = Ne(Ee, ut);
ce && I.childNodes.push(ce);
}
if (Bt(t) && t.shadowRoot)
for (
var k = 0, ne = Array.from(t.shadowRoot.childNodes);
k < ne.length;
k++
) {
var Ee = ne[k],
ce = Ne(Ee, ut);
ce && (We(t.shadowRoot) && (ce.isShadow = !0), I.childNodes.push(ce));
}
}
return (
t.parentNode && Pe(t.parentNode) && We(t.parentNode) && (I.isShadow = !0),
I.type === N.Element &&
I.tagName === "iframe" &&
Ln(
t,
function () {
var W = t.contentDocument;
if (W && P) {
var X = Ne(W, {
doc: W,
mirror: n,
blockClass: o,
blockSelector: a,
maskTextClass: i,
maskTextSelector: l,
skipChild: !1,
inlineStylesheet: d,
maskInputOptions: m,
maskTextFn: p,
maskInputFn: v,
slimDOMOptions: b,
dataURLOptions: y,
inlineImages: C,
recordCanvas: R,
preserveWhiteSpace: w,
onSerialize: _,
onIframeLoad: P,
iframeLoadTimeout: K,
onStylesheetLoad: Y,
stylesheetLoadTimeout: Q,
keepIframeSrcFn: U,
});
X && P(t, X);
}
},
K
),
I.type === N.Element &&
I.tagName === "link" &&
I.attributes.rel === "stylesheet" &&
An(
t,
function () {
if (Y) {
var W = Ne(t, {
doc: r,
mirror: n,
blockClass: o,
blockSelector: a,
maskTextClass: i,
maskTextSelector: l,
skipChild: !1,
inlineStylesheet: d,
maskInputOptions: m,
maskTextFn: p,
maskInputFn: v,
slimDOMOptions: b,
dataURLOptions: y,
inlineImages: C,
recordCanvas: R,
preserveWhiteSpace: w,
onSerialize: _,
onIframeLoad: P,
iframeLoadTimeout: K,
onStylesheetLoad: Y,
stylesheetLoadTimeout: Q,
keepIframeSrcFn: U,
});
W && Y(t, W);
}
},
Q
),
I
);
}
function Un(t, e) {
var r = e || {},
n = r.mirror,
o = n === void 0 ? new dt() : n,
a = r.blockClass,
i = a === void 0 ? "rr-block" : a,
l = r.blockSelector,
s = l === void 0 ? null : l,
c = r.maskTextClass,
u = c === void 0 ? "rr-mask" : c,
d = r.maskTextSelector,
h = d === void 0 ? null : d,
m = r.inlineStylesheet,
p = m === void 0 ? !0 : m,
v = r.inlineImages,
b = v === void 0 ? !1 : v,
f = r.recordCanvas,
y = f === void 0 ? !1 : f,
g = r.maskAllInputs,
C = g === void 0 ? !1 : g,
M = r.maskTextFn,
R = r.maskInputFn,
_ = r.slimDOM,
P = _ === void 0 ? !1 : _,
Z = r.dataURLOptions,
K = r.preserveWhiteSpace,
Y = r.onSerialize,
J = r.onIframeLoad,
Q = r.iframeLoadTimeout,
ie = r.onStylesheetLoad,
U = r.stylesheetLoadTimeout,
j = r.keepIframeSrcFn,
F =
j === void 0
? function () {
return !1;
}
: j,
q =
C === !0
? {
color: !0,
date: !0,
"datetime-local": !0,
email: !0,
month: !0,
number: !0,
range: !0,
search: !0,
tel: !0,
text: !0,
time: !0,
url: !0,
week: !0,
textarea: !0,
select: !0,
password: !0,
}
: C === !1
? { password: !0 }
: C,
w =
P === !0 || P === "all"
? {
script: !0,
comment: !0,
headFavicon: !0,
headWhitespace: !0,
headMetaDescKeywords: P === "all",
headMetaSocial: !0,
headMetaRobots: !0,
headMetaHttpEquiv: !0,
headMetaAuthorship: !0,
headMetaVerification: !0,
}
: P === !1
? {}
: P;
return Ne(t, {
doc: t,
mirror: o,
blockClass: i,
blockSelector: s,
maskTextClass: u,
maskTextSelector: h,
skipChild: !1,
inlineStylesheet: p,
maskInputOptions: q,
maskTextFn: M,
maskInputFn: R,
slimDOMOptions: w,
dataURLOptions: Z,
inlineImages: b,
recordCanvas: y,
preserveWhiteSpace: K,
onSerialize: Y,
onIframeLoad: J,
iframeLoadTimeout: Q,
onStylesheetLoad: ie,
stylesheetLoadTimeout: U,
keepIframeSrcFn: F,
newlyAddedElement: !1,
});
}
var Jt = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
function Vn(t, e) {
e === void 0 && (e = {});
var r = 1,
n = 1;
function o(w) {
var S = w.match(/\n/g);
S && (r += S.length);
var D = w.lastIndexOf(`
`);
n = D === -1 ? n + w.length : w.length - D;
}
function a() {
var w = { line: r, column: n };
return function (S) {
return (S.position = new i(w)), p(), S;
};
}
var i = (function () {
function w(S) {
(this.start = S),
(this.end = { line: r, column: n }),
(this.source = e.source);
}
return w;
})();
i.prototype.content = t;
var l = [];
function s(w) {
var S = new Error(
""
.concat(e.source || "", ":")
.concat(r, ":")
.concat(n, ": ")
.concat(w)
);
if (
((S.reason = w),
(S.filename = e.source),
(S.line = r),
(S.column = n),
(S.source = t),
e.silent)
)
l.push(S);
else throw S;
}
function c() {
var w = h();
return {
type: "stylesheet",
stylesheet: { source: e.source, rules: w, parsingErrors: l },
};
}
function u() {
return m(/^{\s*/);
}
function d() {
return m(/^}/);
}
function h() {
var w,
S = [];
for (p(), v(S); t.length && t.charAt(0) !== "}" && (w = F() || q()); )
w && (S.push(w), v(S));
return S;
}
function m(w) {
var S = w.exec(t);
if (S) {
var D = S[0];
return o(D), (t = t.slice(D.length)), S;
}
}
function p() {
m(/^\s*/);
}
function v(w) {
w === void 0 && (w = []);
for (var S; (S = b()); ) S && w.push(S), (S = b());
return w;
}
function b() {
var w = a();
if (!(t.charAt(0) !== "/" || t.charAt(1) !== "*")) {
for (
var S = 2;
t.charAt(S) !== "" &&
(t.charAt(S) !== "*" || t.charAt(S + 1) !== "/");
)
++S;
if (((S += 2), t.charAt(S - 1) === ""))
return s("End of comment missing");
var D = t.slice(2, S - 2);
return (
(n += 2),
o(D),
(t = t.slice(S)),
(n += 2),
w({ type: "comment", comment: D })
);
}
}
function f() {
var w = m(/^([^{]+)/);
if (w)
return pe(w[0])
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "")
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (S) {
return S.replace(/,/g, "\u200C");
})
.split(/\s*(?![^(]*\)),\s*/)
.map(function (S) {
return S.replace(/\u200C/g, ",");
});
}
function y() {
var w = a(),
S = m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
if (S) {
var D = pe(S[0]);
if (!m(/^:\s*/)) return s("property missing ':'");
var I = m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),
H = w({
type: "declaration",
property: D.replace(Jt, ""),
value: I ? pe(I[0]).replace(Jt, "") : "",
});
return m(/^[;\s]*/), H;
}
}
function g() {
var w = [];
if (!u()) return s("missing '{'");
v(w);
for (var S; (S = y()); ) S !== !1 && (w.push(S), v(w)), (S = y());
return d() ? w : s("missing '}'");
}
function C() {
for (
var w, S = [], D = a();
(w = m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/));
)
S.push(w[1]), m(/^,\s*/);
if (S.length)
return D({ type: "keyframe", values: S, declarations: g() });
}
function M() {
var w = a(),
S = m(/^@([-\w]+)?keyframes\s*/);
if (S) {
var D = S[1];
if (((S = m(/^([-\w]+)\s*/)), !S)) return s("@keyframes missing name");
var I = S[1];
if (!u()) return s("@keyframes missing '{'");
for (var H, de = v(); (H = C()); ) de.push(H), (de = de.concat(v()));
return d()
? w({ type: "keyframes", name: I, vendor: D, keyframes: de })
: s("@keyframes missing '}'");
}
}
function R() {
var w = a(),
S = m(/^@supports *([^{]+)/);
if (S) {
var D = pe(S[1]);
if (!u()) return s("@supports missing '{'");
var I = v().concat(h());
return d()
? w({ type: "supports", supports: D, rules: I })
: s("@supports missing '}'");
}
}
function _() {
var w = a(),
S = m(/^@host\s*/);
if (S) {
if (!u()) return s("@host missing '{'");
var D = v().concat(h());
return d() ? w({ type: "host", rules: D }) : s("@host missing '}'");
}
}
function P() {
var w = a(),
S = m(/^@media *([^{]+)/);
if (S) {
var D = pe(S[1]);
if (!u()) return s("@media missing '{'");
var I = v().concat(h());
return d()
? w({ type: "media", media: D, rules: I })
: s("@media missing '}'");
}
}
function Z() {
var w = a(),
S = m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
if (S)
return w({ type: "custom-media", name: pe(S[1]), media: pe(S[2]) });
}
function K() {
var w = a(),
S = m(/^@page */);
if (S) {
var D = f() || [];
if (!u()) return s("@page missing '{'");
for (var I = v(), H; (H = y()); ) I.push(H), (I = I.concat(v()));
return d()
? w({ type: "page", selectors: D, declarations: I })
: s("@page missing '}'");
}
}
function Y() {
var w = a(),
S = m(/^@([-\w]+)?document *([^{]+)/);
if (S) {
var D = pe(S[1]),
I = pe(S[2]);
if (!u()) return s("@document missing '{'");
var H = v().concat(h());
return d()
? w({ type: "document", document: I, vendor: D, rules: H })
: s("@document missing '}'");
}
}
function J() {
var w = a(),
S = m(/^@font-face\s*/);
if (S) {
if (!u()) return s("@font-face missing '{'");
for (var D = v(), I; (I = y()); ) D.push(I), (D = D.concat(v()));
return d()
? w({ type: "font-face", declarations: D })
: s("@font-face missing '}'");
}
}
var Q = j("import"),
ie = j("charset"),
U = j("namespace");
function j(w) {
var S = new RegExp("^@" + w + "\\s*([^;]+);");
return function () {
var D = a(),
I = m(S);
if (I) {
var H = { type: w };
return (H[w] = I[1].trim()), D(H);
}
};
}
function F() {
if (t[0] === "@")
return (
M() ||
P() ||
Z() ||
R() ||
Q() ||
ie() ||
U() ||
Y() ||
K() ||
_() ||
J()
);
}
function q() {
var w = a(),
S = f();
return S
? (v(), w({ type: "rule", selectors: S, declarations: g() }))
: s("selector missing");
}
return ft(c());
}
function pe(t) {
return t ? t.replace(/^\s+|\s+$/g, "") : "";
}
function ft(t, e) {
for (
var r = t && typeof t.type == "string",
n = r ? t : e,
o = 0,
a = Object.keys(t);
o < a.length;
o++
) {
var i = a[o],
l = t[i];
Array.isArray(l)
? l.forEach(function (s) {
ft(s, n);
})
: l && typeof l == "object" && ft(l, n);
}
return (
r &&
Object.defineProperty(t, "parent", {
configurable: !0,
writable: !0,
enumerable: !1,
value: e || null,
}),
t
);
}
var Qt = {
script: "noscript",
altglyph: "altGlyph",
altglyphdef: "altGlyphDef",
altglyphitem: "altGlyphItem",
animatecolor: "animateColor",
animatemotion: "animateMotion",
animatetransform: "animateTransform",
clippath: "clipPath",
feblend: "feBlend",
fecolormatrix: "feColorMatrix",
fecomponenttransfer: "feComponentTransfer",
fecomposite: "feComposite",
feconvolvematrix: "feConvolveMatrix",
fediffuselighting: "feDiffuseLighting",
fedisplacementmap: "feDisplacementMap",
fedistantlight: "feDistantLight",
fedropshadow: "feDropShadow",
feflood: "feFlood",
fefunca: "feFuncA",
fefuncb: "feFuncB",
fefuncg: "feFuncG",
fefuncr: "feFuncR",
fegaussianblur: "feGaussianBlur",
feimage: "feImage",
femerge: "feMerge",
femergenode: "feMergeNode",
femorphology: "feMorphology",
feoffset: "feOffset",
fepointlight: "fePointLight",
fespecularlighting: "feSpecularLighting",
fespotlight: "feSpotLight",
fetile: "feTile",
feturbulence: "feTurbulence",
foreignobject: "foreignObject",
glyphref: "glyphRef",
lineargradient: "linearGradient",
radialgradient: "radialGradient",
};
function Bn(t) {
var e = Qt[t.tagName] ? Qt[t.tagName] : t.tagName;
return e === "link" && t.attributes._cssText && (e = "style"), e;
}
function Gn(t) {
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
var qt = /([^\\]):hover/,
jn = new RegExp(qt.source, "g");
function er(t, e) {
var r = e?.stylesWithHoverClass.get(t);
if (r) return r;
var n = Vn(t, { silent: !0 });
if (!n.stylesheet) return t;
var o = [];
if (
(n.stylesheet.rules.forEach(function (l) {
"selectors" in l &&
(l.selectors || []).forEach(function (s) {
qt.test(s) && o.push(s);
});
}),
o.length === 0)
)
return t;
var a = new RegExp(
o
.filter(function (l, s) {
return o.indexOf(l) === s;
})
.sort(function (l, s) {
return s.length - l.length;
})
.map(function (l) {
return Gn(l);
})
.join("|"),
"g"
),
i = t.replace(a, function (l) {
var s = l.replace(jn, "$1.\\:hover");
return "".concat(l, ", ").concat(s);
});
return e?.stylesWithHoverClass.set(t, i), i;
}
function tr() {
var t = new Map();
return { stylesWithHoverClass: t };
}
function zn(t, e) {
var r = e.doc,
n = e.hackCss,
o = e.cache;
switch (t.type) {
case N.Document:
return r.implementation.createDocument(null, "", null);
case N.DocumentType:
return r.implementation.createDocumentType(
t.name || "html",
t.publicId,
t.systemId
);
case N.Element: {
var a = Bn(t),
i;
t.isSVG
? (i = r.createElementNS("http://www.w3.org/2000/svg", a))
: (i = r.createElement(a));
var l = {};
for (var s in t.attributes)
if (Object.prototype.hasOwnProperty.call(t.attributes, s)) {
var c = t.attributes[s];
if (
!(a === "option" && s === "selected" && c === !1) &&
c !== null
) {
if ((c === !0 && (c = ""), s.startsWith("rr_"))) {
l[s] = c;
continue;
}
var u = a === "textarea" && s === "value",
d = a === "style" && s === "_cssText";
if (
(d && n && typeof c == "string" && (c = er(c, o)),
(u || d) && typeof c == "string")
) {
for (
var h = r.createTextNode(c),
m = 0,
p = Array.from(i.childNodes);
m < p.length;
m++
) {
var v = p[m];
v.nodeType === i.TEXT_NODE && i.removeChild(v);
}
i.appendChild(h);
continue;
}
try {
if (t.isSVG && s === "xlink:href")
i.setAttributeNS(
"http://www.w3.org/1999/xlink",
s,
c.toString()
);
else if (
s === "onload" ||
s === "onclick" ||
s.substring(0, 7) === "onmouse"
)
i.setAttribute("_" + s, c.toString());
else if (
a === "meta" &&
t.attributes["http-equiv"] === "Content-Security-Policy" &&
s === "content"
) {
i.setAttribute("csp-content", c.toString());
continue;
} else
(a === "link" &&
(t.attributes.rel === "preload" ||
t.attributes.rel === "modulepreload") &&
t.attributes.as === "script") ||
(a === "link" &&
t.attributes.rel === "prefetch" &&
typeof t.attributes.href == "string" &&
t.attributes.href.endsWith(".js")) ||
(a === "img" &&
t.attributes.srcset &&
t.attributes.rr_dataURL
? i.setAttribute(
"rrweb-original-srcset",
t.attributes.srcset
)
: i.setAttribute(s, c.toString()));
} catch {}
}
}
var b = function (y) {
var g = l[y];
if (a === "canvas" && y === "rr_dataURL") {
var C = document.createElement("img");
(C.onload = function () {
var R = i.getContext("2d");
R && R.drawImage(C, 0, 0, C.width, C.height);
}),
(C.src = g.toString()),
i.RRNodeType && (i.rr_dataURL = g.toString());
} else if (a === "img" && y === "rr_dataURL") {
var M = i;
M.currentSrc.startsWith("data:") ||
(M.setAttribute("rrweb-original-src", t.attributes.src),
(M.src = g.toString()));
}
if (y === "rr_width") i.style.width = g.toString();
else if (y === "rr_height") i.style.height = g.toString();
else if (y === "rr_mediaCurrentTime" && typeof g == "number")
i.currentTime = g;
else if (y === "rr_mediaState")
switch (g) {
case "played":
i.play().catch(function (R) {
return console.warn("media playback error", R);
});
break;
case "paused":
i.pause();
break;
}
};
for (var f in l) b(f);
if (t.isShadowHost)
if (!i.shadowRoot) i.attachShadow({ mode: "open" });
else
for (; i.shadowRoot.firstChild; )
i.shadowRoot.removeChild(i.shadowRoot.firstChild);
return i;
}
case N.Text:
return r.createTextNode(
t.isStyle && n ? er(t.textContent, o) : t.textContent
);
case N.CDATA:
return r.createCDATASection(t.textContent);
case N.Comment:
return r.createComment(t.textContent);
default:
return null;
}
}
function Ue(t, e) {
var r = e.doc,
n = e.mirror,
o = e.skipChild,
a = o === void 0 ? !1 : o,
i = e.hackCss,
l = i === void 0 ? !0 : i,
s = e.afterAppend,
c = e.cache;
if (n.has(t.id)) {
var u = n.getNode(t.id),
d = n.getMeta(u);
if (Sn(d, t)) return n.getNode(t.id);
}
var h = zn(t, { doc: r, hackCss: l, cache: c });
if (!h) return null;
if (
(t.rootId && n.getNode(t.rootId) !== r && n.replace(t.rootId, r),
t.type === N.Document &&
(r.close(),
r.open(),
t.compatMode === "BackCompat" &&
t.childNodes &&
t.childNodes[0].type !== N.DocumentType &&
(t.childNodes[0].type === N.Element &&
"xmlns" in t.childNodes[0].attributes &&
t.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml"
? r.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
)
: r.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'
)),
(h = r)),
n.add(h, t),
(t.type === N.Document || t.type === N.Element) && !a)
)
for (
var m = function (f) {
var y = Ue(f, {
doc: r,
mirror: n,
skipChild: !1,
hackCss: l,
afterAppend: s,
cache: c,
});
if (!y) return console.warn("Failed to rebuild", f), "continue";
if (f.isShadow && Bt(h) && h.shadowRoot)
h.shadowRoot.appendChild(y);
else if (t.type === N.Document && f.type == N.Element) {
var g = y,
C = null;
g.childNodes.forEach(function (M) {
M.nodeName === "BODY" && (C = M);
}),
C
? (g.removeChild(C), h.appendChild(y), g.appendChild(C))
: h.appendChild(y);
} else h.appendChild(y);
s && s(y, f.id);
},
p = 0,
v = t.childNodes;
p < v.length;
p++
) {
var b = v[p];
m(b);
}
return h;
}
function Hn(t, e) {
function r(i) {
e(i);
}
for (var n = 0, o = t.getIds(); n < o.length; n++) {
var a = o[n];
t.has(a) && r(t.getNode(a));
}
}
function Yn(t, e) {
var r = e.getMeta(t);
if (r?.type === N.Element) {
var n = t;
for (var o in r.attributes)
if (
Object.prototype.hasOwnProperty.call(r.attributes, o) &&
o.startsWith("rr_")
) {
var a = r.attributes[o];
o === "rr_scrollLeft" && (n.scrollLeft = a),
o === "rr_scrollTop" && (n.scrollTop = a);
}
}
}
function Xn(t, e) {
var r = e.doc,
n = e.onVisit,
o = e.hackCss,
a = o === void 0 ? !0 : o,
i = e.afterAppend,
l = e.cache,
s = e.mirror,
c = s === void 0 ? new dt() : s,
u = Ue(t, {
doc: r,
mirror: c,
skipChild: !1,
hackCss: a,
afterAppend: i,
cache: l,
});
return (
Hn(c, function (d) {
n && n(d), Yn(d, c);
}),
u
);
}
function ee(t, e, r = document) {
const n = { capture: !0, passive: !0 };
return r.addEventListener(t, e, n), () => r.removeEventListener(t, e, n);
}
const Me = `Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;
(re.mirror = {
map: {},
getId() {
return console.error(Me), -1;
},
getNode() {
return console.error(Me), null;
},
removeNodeFromMap() {
console.error(Me);
},
has() {
return console.error(Me), !1;
},
reset() {
console.error(Me);
},
}),
typeof window < "u" &&
window.Proxy &&
window.Reflect &&
(re.mirror = new Proxy(re.mirror, {
get(t, e, r) {
return e === "map" && console.error(Me), Reflect.get(t, e, r);
},
}));
function Ie(t, e, r = {}) {
let n = null,
o = 0;
return function (...a) {
const i = Date.now();
!o && r.leading === !1 && (o = i);
const l = e - (i - o),
s = this;
l <= 0 || l > e
? (n && (clearTimeout(n), (n = null)), (o = i), t.apply(s, a))
: !n &&
r.trailing !== !1 &&
(n = setTimeout(() => {
(o = r.leading === !1 ? 0 : Date.now()), (n = null), t.apply(s, a);
}, l));
};
}
function Ve(t, e, r, n, o = window) {
const a = o.Object.getOwnPropertyDescriptor(t, e);
return (
o.Object.defineProperty(
t,
e,
n
? r
: {
set(i) {
setTimeout(() => {
r.set.call(this, i);
}, 0),
a && a.set && a.set.call(this, i);
},
}
),
() => Ve(t, e, a || {}, !0)
);
}
function De(t, e, r) {
try {
if (!(e in t)) return () => {};
const n = t[e],
o = r(n);
return (
typeof o == "function" &&
((o.prototype = o.prototype || {}),
Object.defineProperties(o, {
__rrweb_original__: { enumerable: !1, value: n },
})),
(t[e] = o),
() => {
t[e] = n;
}
);
} catch {
return () => {};
}
}
let Be = Date.now;
/[1-9][0-9]{12}/.test(Date.now().toString()) ||
(Be = () => new Date().getTime());
function yt(t) {
var e, r, n, o, a, i;
const l = t.document;
return {
left: l.scrollingElement
? l.scrollingElement.scrollLeft
: t.pageXOffset !== void 0
? t.pageXOffset
: l?.documentElement.scrollLeft ||
((r = (e = l?.body) == null ? void 0 : e.parentElement) == null
? void 0
: r.scrollLeft) ||
((n = l?.body) == null ? void 0 : n.scrollLeft) ||
0,
top: l.scrollingElement
? l.scrollingElement.scrollTop
: t.pageYOffset !== void 0
? t.pageYOffset
: l?.documentElement.scrollTop ||
((a = (o = l?.body) == null ? void 0 : o.parentElement) == null
? void 0
: a.scrollTop) ||
((i = l?.body) == null ? void 0 : i.scrollTop) ||
0,
};
}
function gt() {
return (
window.innerHeight ||
(document.documentElement && document.documentElement.clientHeight) ||
(document.body && document.body.clientHeight)
);
}
function vt() {
return (
window.innerWidth ||
(document.documentElement && document.documentElement.clientWidth) ||
(document.body && document.body.clientWidth)
);
}
function te(t, e, r, n) {
if (!t) return !1;
const o = t.nodeType === t.ELEMENT_NODE ? t : t.parentElement;
if (!o) return !1;
try {
if (typeof e == "string") {
if (o.classList.contains(e) || (n && o.closest("." + e) !== null))
return !0;
} else if (Ke(o, e, n)) return !0;
} catch {}
return !!(r && (o.matches(r) || (n && o.closest(r) !== null)));
}
function rr(t, e) {
return e.getId(t) !== -1;
}
function Je(t, e) {
return e.getId(t) === $e;
}
function St(t, e) {
if (Pe(t)) return !1;
const r = e.getId(t);
return e.has(r)
? t.parentNode && t.parentNode.nodeType === t.DOCUMENT_NODE
? !1
: t.parentNode
? St(t.parentNode, e)
: !0
: !0;
}
function Qe(t) {
return Boolean(t.changedTouches);
}
function bt(t = window) {
"NodeList" in t &&
!t.NodeList.prototype.forEach &&
(t.NodeList.prototype.forEach = Array.prototype.forEach),
"DOMTokenList" in t &&
!t.DOMTokenList.prototype.forEach &&
(t.DOMTokenList.prototype.forEach = Array.prototype.forEach),
Node.prototype.contains ||
(Node.prototype.contains = (...e) => {
let r = e[0];
if (!(0 in e)) throw new TypeError("1 argument is required");
do if (this === r) return !0;
while ((r = r && r.parentNode));
return !1;
});
}
function nr(t) {
const e = {},
r = (o, a) => {
const i = { value: o, parent: a, children: [] };
return (e[o.node.id] = i), i;
},
n = [];
for (const o of t) {
const { nextId: a, parentId: i } = o;
if (a && a in e) {
const l = e[a];
if (l.parent) {
const s = l.parent.children.indexOf(l);
l.parent.children.splice(s, 0, r(o, l.parent));
} else {
const s = n.indexOf(l);
n.splice(s, 0, r(o, null));
}
continue;
}
if (i in e) {
const l = e[i];
l.children.push(r(o, l));
continue;
}
n.push(r(o, null));
}
return n;
}
function wt(t, e) {
e(t.value);
for (let r = t.children.length - 1; r >= 0; r--) wt(t.children[r], e);
}
function ke(t, e) {
return Boolean(t.nodeName === "IFRAME" && e.getMeta(t));
}
function Ct(t, e) {
return Boolean(
t.nodeName === "LINK" &&
t.nodeType === t.ELEMENT_NODE &&
t.getAttribute &&
t.getAttribute("rel") === "stylesheet" &&
e.getMeta(t)
);
}
function Et(t, e) {
var r, n;
const o =
(n = (r = t.ownerDocument) == null ? void 0 : r.defaultView) == null
? void 0
: n.frameElement;
if (!o || o === e)
return { x: 0, y: 0, relativeScale: 1, absoluteScale: 1 };
const a = o.getBoundingClientRect(),
i = Et(o, e),
l = a.height / o.clientHeight;
return {
x: a.x * i.relativeScale + i.x,
y: a.y * i.relativeScale + i.y,
relativeScale: l,
absoluteScale: i.absoluteScale * l,
};
}
function ve(t) {
return Boolean(t?.shadowRoot);
}
function Re(t, e) {
const r = t[e[0]];
return e.length === 1 ? r : Re(r.cssRules[e[1]].cssRules, e.slice(2));
}
function Tt(t) {
const e = [...t],
r = e.pop();
return { positions: e, index: r };
}
function or(t) {
const e = new Set(),
r = [];
for (let n = t.length; n--; ) {
const o = t[n];
e.has(o.id) || (r.push(o), e.add(o.id));
}
return r;
}
class Nt {
constructor() {
(this.id = 1),
(this.styleIDMap = new WeakMap()),
(this.idStyleMap = new Map());
}
getId(e) {
var r;
return (r = this.styleIDMap.get(e)) != null ? r : -1;
}
has(e) {
return this.styleIDMap.has(e);
}
add(e, r) {
if (this.has(e)) return this.getId(e);
let n;
return (
r === void 0 ? (n = this.id++) : (n = r),
this.styleIDMap.set(e, n),
this.idStyleMap.set(n, e),
n
);
}
getStyle(e) {
return this.idStyleMap.get(e) || null;
}
reset() {
(this.styleIDMap = new WeakMap()),
(this.idStyleMap = new Map()),
(this.id = 1);
}
generateId() {
return this.id++;
}
}
function Mt(t) {
var e, r;
let n = null;
return (
((r = (e = t.getRootNode) == null ? void 0 : e.call(t)) == null
? void 0
: r.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
t.getRootNode().host &&
(n = t.getRootNode().host),
n
);
}
function sr(t) {
let e = t,
r;
for (; (r = Mt(e)); ) e = r;
return e;
}
function ir(t) {
const e = t.ownerDocument;
if (!e) return !1;
const r = sr(t);
return e.contains(r);
}
function It(t) {
const e = t.ownerDocument;
return e ? e.contains(t) || ir(t) : !1;
}
var Zn = Object.freeze({
__proto__: null,
on: ee,
get _mirror() {
return re.mirror;
},
throttle: Ie,
hookSetter: Ve,
patch: De,
get nowTimestamp() {
return Be;
},
getWindowScroll: yt,
getWindowHeight: gt,
getWindowWidth: vt,
isBlocked: te,
isSerialized: rr,
isIgnored: Je,
isAncestorRemoved: St,
legacy_isTouchEvent: Qe,
polyfill: bt,
queueToResolveTrees: nr,
iterateResolveTree: wt,
isSerializedIframe: ke,
isSerializedStylesheet: Ct,
getBaseDimension: Et,
hasShadowRoot: ve,
getNestedRule: Re,
getPositionsAndIndex: Tt,
uniqueTextMutations: or,
StyleSheetMirror: Nt,
getShadowHost: Mt,
getRootShadowHost: sr,
shadowHostInDom: ir,
inDom: It,
}),
T = ((t) => (
(t[(t.DomContentLoaded = 0)] = "DomContentLoaded"),
(t[(t.Load = 1)] = "Load"),
(t[(t.FullSnapshot = 2)] = "FullSnapshot"),
(t[(t.IncrementalSnapshot = 3)] = "IncrementalSnapshot"),
(t[(t.Meta = 4)] = "Meta"),
(t[(t.Custom = 5)] = "Custom"),
(t[(t.Plugin = 6)] = "Plugin"),
t
))(T || {}),
E = ((t) => (
(t[(t.Mutation = 0)] = "Mutation"),
(t[(t.MouseMove = 1)] = "MouseMove"),
(t[(t.MouseInteraction = 2)] = "MouseInteraction"),
(t[(t.Scroll = 3)] = "Scroll"),
(t[(t.ViewportResize = 4)] = "ViewportResize"),
(t[(t.Input = 5)] = "Input"),
(t[(t.TouchMove = 6)] = "TouchMove"),
(t[(t.MediaInteraction = 7)] = "MediaInteraction"),
(t[(t.StyleSheetRule = 8)] = "StyleSheetRule"),
(t[(t.CanvasMutation = 9)] = "CanvasMutation"),
(t[(t.Font = 10)] = "Font"),
(t[(t.Log = 11)] = "Log"),
(t[(t.Drag = 12)] = "Drag"),
(t[(t.StyleDeclaration = 13)] = "StyleDeclaration"),
(t[(t.Selection = 14)] = "Selection"),
(t[(t.AdoptedStyleSheet = 15)] = "AdoptedStyleSheet"),
t
))(E || {}),
L = ((t) => (
(t[(t.MouseUp = 0)] = "MouseUp"),
(t[(t.MouseDown = 1)] = "MouseDown"),
(t[(t.Click = 2)] = "Click"),
(t[(t.ContextMenu = 3)] = "ContextMenu"),
(t[(t.DblClick = 4)] = "DblClick"),
(t[(t.Focus = 5)] = "Focus"),
(t[(t.Blur = 6)] = "Blur"),
(t[(t.TouchStart = 7)] = "TouchStart"),
(t[(t.TouchMove_Departed = 8)] = "TouchMove_Departed"),
(t[(t.TouchEnd = 9)] = "TouchEnd"),
(t[(t.TouchCancel = 10)] = "TouchCancel"),
t
))(L || {}),
me = ((t) => (
(t[(t.Mouse = 0)] = "Mouse"),
(t[(t.Pen = 1)] = "Pen"),
(t[(t.Touch = 2)] = "Touch"),
t
))(me || {}),
fe = ((t) => (
(t[(t["2D"] = 0)] = "2D"),
(t[(t.WebGL = 1)] = "WebGL"),
(t[(t.WebGL2 = 2)] = "WebGL2"),
t
))(fe || {}),
ye = ((t) => (
(t[(t.Play = 0)] = "Play"),
(t[(t.Pause = 1)] = "Pause"),
(t[(t.Seeked = 2)] = "Seeked"),
(t[(t.VolumeChange = 3)] = "VolumeChange"),
(t[(t.RateChange = 4)] = "RateChange"),
t
))(ye || {}),
A = ((t) => (
(t.Start = "start"),
(t.Pause = "pause"),
(t.Resume = "resume"),
(t.Resize = "resize"),
(t.Finish = "finish"),
(t.FullsnapshotRebuilded = "fullsnapshot-rebuilded"),
(t.LoadStylesheetStart = "load-stylesheet-start"),
(t.LoadStylesheetEnd = "load-stylesheet-end"),
(t.SkipStart = "skip-start"),
(t.SkipEnd = "skip-end"),
(t.MouseInteraction = "mouse-interaction"),
(t.EventCast = "event-cast"),
(t.CustomEvent = "custom-event"),
(t.Flush = "flush"),
(t.StateChange = "state-change"),
(t.PlayBack = "play-back"),
(t.Destroy = "destroy"),
t
))(A || {});
function ar(t) {
return "__ln" in t;
}
class Kn {
constructor() {
(this.length = 0), (this.head = null), (this.tail = null);
}
get(e) {
if (e >= this.length) throw new Error("Position outside of list range");
let r = this.head;
for (let n = 0; n < e; n++) r = r?.next || null;
return r;
}
addNode(e) {
const r = { value: e, previous: null, next: null };
if (((e.__ln = r), e.previousSibling && ar(e.previousSibling))) {
const n = e.previousSibling.__ln.next;
(r.next = n),
(r.previous = e.previousSibling.__ln),
(e.previousSibling.__ln.next = r),
n && (n.previous = r);
} else if (
e.nextSibling &&
ar(e.nextSibling) &&
e.nextSibling.__ln.previous
) {
const n = e.nextSibling.__ln.previous;
(r.previous = n),
(r.next = e.nextSibling.__ln),
(e.nextSibling.__ln.previous = r),
n && (n.next = r);
} else
this.head && (this.head.previous = r),
(r.next = this.head),
(this.head = r);
r.next === null && (this.tail = r), this.length++;
}
removeNode(e) {
const r = e.__ln;
!this.head ||
(r.previous
? ((r.previous.next = r.next),
r.next ? (r.next.previous = r.previous) : (this.tail = r.previous))
: ((this.head = r.next),
this.head ? (this.head.previous = null) : (this.tail = null)),
e.__ln && delete e.__ln,
this.length--);
}
}
const lr = (t, e) => `${t}@${e}`;
class Jn {
constructor() {
(this.frozen = !1),
(this.locked = !1),
(this.texts = []),
(this.attributes = []),
(this.removes = []),
(this.mapRemoves = []),
(this.movedMap = {}),
(this.addedSet = new Set()),
(this.movedSet = new Set()),
(this.droppedSet = new Set()),
(this.processMutations = (e) => {
e.forEach(this.processMutation), this.emit();
}),
(this.emit = () => {
if (this.frozen || this.locked) return;
const e = [],
r = new Set(),
n = new Kn(),
o = (s) => {
let c = s,
u = $e;
for (; u === $e; )
(c = c && c.nextSibling), (u = c && this.mirror.getId(c));
return u;
},
a = (s) => {
if (!s.parentNode || !It(s)) return;
const c = Pe(s.parentNode)
? this.mirror.getId(Mt(s))
: this.mirror.getId(s.parentNode),
u = o(s);
if (c === -1 || u === -1) return n.addNode(s);
const d = Ne(s, {
doc: this.doc,
mirror: this.mirror,
blockClass: this.blockClass,
blockSelector: this.blockSelector,
maskTextClass: this.maskTextClass,
maskTextSelector: this.maskTextSelector,
skipChild: !0,
newlyAddedElement: !0,
inlineStylesheet: this.inlineStylesheet,
maskInputOptions: this.maskInputOptions,
maskTextFn: this.maskTextFn,
maskInputFn: this.maskInputFn,
slimDOMOptions: this.slimDOMOptions,
dataURLOptions: this.dataURLOptions,
recordCanvas: this.recordCanvas,
inlineImages: this.inlineImages,
onSerialize: (h) => {
ke(h, this.mirror) && this.iframeManager.addIframe(h),
Ct(h, this.mirror) &&
this.stylesheetManager.trackLinkElement(h),
ve(s) &&
this.shadowDomManager.addShadowRoot(
s.shadowRoot,
this.doc
);
},
onIframeLoad: (h, m) => {
this.iframeManager.attachIframe(h, m),
this.shadowDomManager.observeAttachShadow(h);
},
onStylesheetLoad: (h, m) => {
this.stylesheetManager.attachLinkElement(h, m);
},
});
d && (e.push({ parentId: c, nextId: u, node: d }), r.add(d.id));
};
for (; this.mapRemoves.length; )
this.mirror.removeNodeFromMap(this.mapRemoves.shift());
for (const s of this.movedSet)
(cr(this.removes, s, this.mirror) &&
!this.movedSet.has(s.parentNode)) ||
a(s);
for (const s of this.addedSet)
(!dr(this.droppedSet, s) && !cr(this.removes, s, this.mirror)) ||
dr(this.movedSet, s)
? a(s)
: this.droppedSet.add(s);
let i = null;
for (; n.length; ) {
let s = null;
if (i) {
const c = this.mirror.getId(i.value.parentNode),
u = o(i.value);
c !== -1 && u !== -1 && (s = i);
}
if (!s) {
let c = n.tail;
for (; c; ) {
const u = c;
if (((c = c.previous), u)) {
const d = this.mirror.getId(u.value.parentNode);
if (o(u.value) === -1) continue;
if (d !== -1) {
s = u;
break;
} else {
const h = u.value;
if (
h.parentNode &&
h.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE
) {
const m = h.parentNode.host;
if (this.mirror.getId(m) !== -1) {
s = u;
break;
}
}
}
}
}
}
if (!s) {
for (; n.head; ) n.removeNode(n.head.value);
break;
}
(i = s.previous), n.removeNode(s.value), a(s.value);
}
const l = {
texts: this.texts
.map((s) => ({ id: this.mirror.getId(s.node), value: s.value }))
.filter((s) => !r.has(s.id))
.filter((s) => this.mirror.has(s.id)),
attributes: this.attributes
.map((s) => {
const { attributes: c } = s;
if (typeof c.style == "string") {
const u = JSON.stringify(s.styleDiff),
d = JSON.stringify(s._unchangedStyles);
u.length < c.style.length &&
(u + d).split("var(").length ===
c.style.split("var(").length &&
(c.style = s.styleDiff);
}
return { id: this.mirror.getId(s.node), attributes: c };
})
.filter((s) => !r.has(s.id))
.filter((s) => this.mirror.has(s.id)),
removes: this.removes,
adds: e,
};
(!l.texts.length &&
!l.attributes.length &&
!l.removes.length &&
!l.adds.length) ||
((this.texts = []),
(this.attributes = []),
(this.removes = []),
(this.addedSet = new Set()),
(this.movedSet = new Set()),
(this.droppedSet = new Set()),
(this.movedMap = {}),
this.mutationCb(l));
}),
(this.processMutation = (e) => {
if (Je(e.target, this.mirror)) return;
let r;
try {
r = document.implementation.createHTMLDocument();
} catch {
r = this.doc;
}
switch (e.type) {
case "characterData": {
const n = e.target.textContent;
!te(e.target, this.blockClass, this.blockSelector, !1) &&
n !== e.oldValue &&
this.texts.push({
value:
Kt(e.target, this.maskTextClass, this.maskTextSelector) && n
? this.maskTextFn
? this.maskTextFn(n)
: n.replace(/[\S]/g, "*")
: n,
node: e.target,
});
break;
}
case "attributes": {
const n = e.target;
let o = e.attributeName,
a = e.target.getAttribute(o);
if (o === "value") {
const l = pt(n);
a = ht({
element: n,
maskInputOptions: this.maskInputOptions,
tagName: n.tagName,
type: l,
value: a,
maskInputFn: this.maskInputFn,
});
}
if (
te(e.target, this.blockClass, this.blockSelector, !1) ||
a === e.oldValue
)
return;
let i = this.attributes.find((l) => l.node === e.target);
if (
n.tagName === "IFRAME" &&
o === "src" &&
!this.keepIframeSrcFn(a)
)
if (!n.contentDocument) o = "rr_src";
else return;
if (
(i ||
((i = {
node: e.target,
attributes: {},
styleDiff: {},
_unchangedStyles: {},
}),
this.attributes.push(i)),
o === "type" &&
n.tagName === "INPUT" &&
(e.oldValue || "").toLowerCase() === "password" &&
n.setAttribute("data-rr-is-password", "true"),
!Zt(n.tagName, o) &&
((i.attributes[o] = Xt(this.doc, ge(n.tagName), ge(o), a)),
o === "style"))
) {
const l = r.createElement("span");
e.oldValue && l.setAttribute("style", e.oldValue);
for (const s of Array.from(n.style)) {
const c = n.style.getPropertyValue(s),
u = n.style.getPropertyPriority(s);
c !== l.style.getPropertyValue(s) ||
u !== l.style.getPropertyPriority(s)
? u === ""
? (i.styleDiff[s] = c)
: (i.styleDiff[s] = [c, u])
: (i._unchangedStyles[s] = [c, u]);
}
for (const s of Array.from(l.style))
n.style.getPropertyValue(s) === "" && (i.styleDiff[s] = !1);
}
break;
}
case "childList": {
if (te(e.target, this.blockClass, this.blockSelector, !0)) return;
e.addedNodes.forEach((n) => this.genAdds(n, e.target)),
e.removedNodes.forEach((n) => {
const o = this.mirror.getId(n),
a = Pe(e.target)
? this.mirror.getId(e.target.host)
: this.mirror.getId(e.target);
te(e.target, this.blockClass, this.blockSelector, !1) ||
Je(n, this.mirror) ||
!rr(n, this.mirror) ||
(this.addedSet.has(n)
? (Dt(this.addedSet, n), this.droppedSet.add(n))
: (this.addedSet.has(e.target) && o === -1) ||
St(e.target, this.mirror) ||
(this.movedSet.has(n) && this.movedMap[lr(o, a)]
? Dt(this.movedSet, n)
: this.removes.push({
parentId: a,
id: o,
isShadow:
Pe(e.target) && We(e.target) ? !0 : void 0,
})),
this.mapRemoves.push(n));
});
break;
}
}
}),
(this.genAdds = (e, r) => {
if (
!this.processedNodeManager.inOtherBuffer(e, this) &&
!(this.addedSet.has(e) || this.movedSet.has(e))
) {
if (this.mirror.hasNode(e)) {
if (Je(e, this.mirror)) return;
this.movedSet.add(e);
let n = null;
r && this.mirror.hasNode(r) && (n = this.mirror.getId(r)),
n &&
n !== -1 &&
(this.movedMap[lr(this.mirror.getId(e), n)] = !0);
} else this.addedSet.add(e), this.droppedSet.delete(e);
te(e, this.blockClass, this.blockSelector, !1) ||
(e.childNodes.forEach((n) => this.genAdds(n)),
ve(e) &&
e.shadowRoot.childNodes.forEach((n) => {
this.processedNodeManager.add(n, this), this.genAdds(n, e);
}));
}
});
}
init(e) {
[
"mutationCb",
"blockClass",
"blockSelector",
"maskTextClass",
"maskTextSelector",
"inlineStylesheet",
"maskInputOptions",
"maskTextFn",
"maskInputFn",
"keepIframeSrcFn",
"recordCanvas",
"inlineImages",
"slimDOMOptions",
"dataURLOptions",
"doc",
"mirror",
"iframeManager",
"stylesheetManager",
"shadowDomManager",
"canvasManager",
"processedNodeManager",
].forEach((r) => {
this[r] = e[r];
});
}
freeze() {
(this.frozen = !0), this.canvasManager.freeze();
}
unfreeze() {
(this.frozen = !1), this.canvasManager.unfreeze(), this.emit();
}
isFrozen() {
return this.frozen;
}
lock() {
(this.locked = !0), this.canvasManager.lock();
}
unlock() {
(this.locked = !1), this.canvasManager.unlock(), this.emit();
}
reset() {
this.shadowDomManager.reset(), this.canvasManager.reset();
}
}
function Dt(t, e) {
t.delete(e), e.childNodes.forEach((r) => Dt(t, r));
}
function cr(t, e, r) {
return t.length === 0 ? !1 : ur(t, e, r);
}
function ur(t, e, r) {
const { parentNode: n } = e;
if (!n) return !1;
const o = r.getId(n);
return t.some((a) => a.id === o) ? !0 : ur(t, n, r);
}
function dr(t, e) {
return t.size === 0 ? !1 : hr(t, e);
}
function hr(t, e) {
const { parentNode: r } = e;
return r ? (t.has(r) ? !0 : hr(t, r)) : !1;
}
let Ge;
function Qn(t) {
Ge = t;
}
function qn() {
Ge = void 0;
}
const x = (t) =>
Ge
? (...e) => {
try {
return t(...e);
} catch (r) {
if (Ge && Ge(r) === !0) return;
throw r;
}
}
: t;
var eo = Object.defineProperty,
to = Object.defineProperties,
ro = Object.getOwnPropertyDescriptors,
pr = Object.getOwnPropertySymbols,
no = Object.prototype.hasOwnProperty,
oo = Object.prototype.propertyIsEnumerable,
mr = (t, e, r) =>
e in t
? eo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
: (t[e] = r),
kt = (t, e) => {
for (var r in e || (e = {})) no.call(e, r) && mr(t, r, e[r]);
if (pr) for (var r of pr(e)) oo.call(e, r) && mr(t, r, e[r]);
return t;
},
so = (t, e) => to(t, ro(e));
const we = [];
function je(t) {
try {
if ("composedPath" in t) {
const e = t.composedPath();
if (e.length) return e[0];
} else if ("path" in t && t.path.length) return t.path[0];
} catch {}
return t && t.target;
}
function fr(t, e) {
var r, n;
const o = new Jn();
we.push(o), o.init(t);
let a = window.MutationObserver || window.__rrMutationObserver;
const i =
(n = (r = window?.Zone) == null ? void 0 : r.__symbol__) == null
? void 0
: n.call(r, "MutationObserver");
i && window[i] && (a = window[i]);
const l = new a(x(o.processMutations.bind(o)));
return (
l.observe(e, {
attributes: !0,
attributeOldValue: !0,
characterData: !0,
characterDataOldValue: !0,
childList: !0,
subtree: !0,
}),
l
);
}
function io({ mousemoveCb: t, sampling: e, doc: r, mirror: n }) {
if (e.mousemove === !1) return () => {};
const o = typeof e.mousemove == "number" ? e.mousemove : 50,
a = typeof e.mousemoveCallback == "number" ? e.mousemoveCallback : 500;
let i = [],
l;
const s = Ie(
x((d) => {
const h = Date.now() - l;
t(
i.map((m) => ((m.timeOffset -= h), m)),
d
),
(i = []),
(l = null);
}),
a
),
c = x(
Ie(
x((d) => {
const h = je(d),
{ clientX: m, clientY: p } = Qe(d) ? d.changedTouches[0] : d;
l || (l = Be()),
i.push({ x: m, y: p, id: n.getId(h), timeOffset: Be() - l }),
s(
typeof DragEvent < "u" && d instanceof DragEvent
? E.Drag
: d instanceof MouseEvent
? E.MouseMove
: E.TouchMove
);
}),
o,
{ trailing: !1 }
)
),
u = [ee("mousemove", c, r), ee("touchmove", c, r), ee("drag", c, r)];
return x(() => {
u.forEach((d) => d());
});
}
function ao({
mouseInteractionCb: t,
doc: e,
mirror: r,
blockClass: n,
blockSelector: o,
sampling: a,
}) {
if (a.mouseInteraction === !1) return () => {};
const i =
a.mouseInteraction === !0 || a.mouseInteraction === void 0
? {}
: a.mouseInteraction,
l = [];
let s = null;
const c = (u) => (d) => {
const h = je(d);
if (te(h, n, o, !0)) return;
let m = null,
p = u;
if ("pointerType" in d) {
switch (d.pointerType) {
case "mouse":
m = me.Mouse;
break;
case "touch":
m = me.Touch;
break;
case "pen":
m = me.Pen;
break;
}
m === me.Touch
? L[u] === L.MouseDown
? (p = "TouchStart")
: L[u] === L.MouseUp && (p = "TouchEnd")
: me.Pen;
} else Qe(d) && (m = me.Touch);
m !== null
? ((s = m),
((p.startsWith("Touch") && m === me.Touch) ||
(p.startsWith("Mouse") && m === me.Mouse)) &&
(m = null))
: L[u] === L.Click && ((m = s), (s = null));
const v = Qe(d) ? d.changedTouches[0] : d;
if (!v) return;
const b = r.getId(h),
{ clientX: f, clientY: y } = v;
x(t)(
kt({ type: L[p], id: b, x: f, y }, m !== null && { pointerType: m })
);
};
return (
Object.keys(L)
.filter(
(u) =>
Number.isNaN(Number(u)) && !u.endsWith("_Departed") && i[u] !== !1
)
.forEach((u) => {
let d = ge(u);
const h = c(u);
if (window.PointerEvent)
switch (L[u]) {
case L.MouseDown:
case L.MouseUp:
d = d.replace("mouse", "pointer");
break;
case L.TouchStart:
case L.TouchEnd:
return;
}
l.push(ee(d, h, e));
}),
x(() => {
l.forEach((u) => u());
})
);
}
function yr({
scrollCb: t,
doc: e,
mirror: r,
blockClass: n,
blockSelector: o,
sampling: a,
}) {
const i = x(
Ie(
x((l) => {
const s = je(l);
if (!s || te(s, n, o, !0)) return;
const c = r.getId(s);
if (s === e && e.defaultView) {
const u = yt(e.defaultView);
t({ id: c, x: u.left, y: u.top });
} else t({ id: c, x: s.scrollLeft, y: s.scrollTop });
}),
a.scroll || 100
)
);
return ee("scroll", i, e);
}
function lo({ viewportResizeCb: t }, { win: e }) {
let r = -1,
n = -1;
const o = x(
Ie(
x(() => {
const a = gt(),
i = vt();
(r !== a || n !== i) &&
(t({ width: Number(i), height: Number(a) }), (r = a), (n = i));
}),
200
)
);
return ee("resize", o, e);
}
function gr(t, e) {
const r = kt({}, t);
return e || delete r.userTriggered, r;
}
const co = ["INPUT", "TEXTAREA", "SELECT"],
vr = new WeakMap();
function uo({
inputCb: t,
doc: e,
mirror: r,
blockClass: n,
blockSelector: o,
ignoreClass: a,
ignoreSelector: i,
maskInputOptions: l,
maskInputFn: s,
sampling: c,
userTriggeredOnInput: u,
}) {
function d(f) {
let y = je(f);
const g = f.isTrusted,
C = y && y.tagName;
if (
(y && C === "OPTION" && (y = y.parentElement),
!y ||
!C ||
co.indexOf(C) < 0 ||
te(y, n, o, !0) ||
y.classList.contains(a) ||
(i && y.matches(i)))
)
return;
let M = y.value,
R = !1;
const _ = pt(y) || "";
_ === "radio" || _ === "checkbox"
? (R = y.checked)
: (l[C.toLowerCase()] || l[_]) &&
(M = ht({
element: y,
maskInputOptions: l,
tagName: C,
type: _,
value: M,
maskInputFn: s,
})),
h(y, x(gr)({ text: M, isChecked: R, userTriggered: g }, u));
const P = y.name;
_ === "radio" &&
P &&
R &&
e.querySelectorAll(`input[type="radio"][name="${P}"]`).forEach((Z) => {
Z !== y &&
h(Z, x(gr)({ text: Z.value, isChecked: !R, userTriggered: !1 }, u));
});
}
function h(f, y) {
const g = vr.get(f);
if (!g || g.text !== y.text || g.isChecked !== y.isChecked) {
vr.set(f, y);
const C = r.getId(f);
x(t)(so(kt({}, y), { id: C }));
}
}
const m = (c.input === "last" ? ["change"] : ["input", "change"]).map((f) =>
ee(f, x(d), e)
),
p = e.defaultView;
if (!p)
return () => {
m.forEach((f) => f());
};
const v = p.Object.getOwnPropertyDescriptor(
p.HTMLInputElement.prototype,
"value"
),
b = [
[p.HTMLInputElement.prototype, "value"],
[p.HTMLInputElement.prototype, "checked"],
[p.HTMLSelectElement.prototype, "value"],
[p.HTMLTextAreaElement.prototype, "value"],
[p.HTMLSelectElement.prototype, "selectedIndex"],
[p.HTMLOptionElement.prototype, "selected"],
];
return (
v &&
v.set &&
m.push(
...b.map((f) =>
Ve(
f[0],
f[1],
{
set() {
x(d)({ target: this, isTrusted: !1 });
},
},
!1,
p
)
)
),
x(() => {
m.forEach((f) => f());
})
);
}
function qe(t) {
const e = [];
function r(n, o) {
if (
(et("CSSGroupingRule") && n.parentRule instanceof CSSGroupingRule) ||
(et("CSSMediaRule") && n.parentRule instanceof CSSMediaRule) ||
(et("CSSSupportsRule") && n.parentRule instanceof CSSSupportsRule) ||
(et("CSSConditionRule") && n.parentRule instanceof CSSConditionRule)
) {
const a = Array.from(n.parentRule.cssRules).indexOf(n);
o.unshift(a);
} else if (n.parentStyleSheet) {
const a = Array.from(n.parentStyleSheet.cssRules).indexOf(n);
o.unshift(a);
}
return o;
}
return r(t, e);
}
function Se(t, e, r) {
let n, o;
return t
? (t.ownerNode ? (n = e.getId(t.ownerNode)) : (o = r.getId(t)),
{ styleId: o, id: n })
: {};
}
function ho(
{ styleSheetRuleCb: t, mirror: e, stylesheetManager: r },
{ win: n }
) {
if (!n.CSSStyleSheet || !n.CSSStyleSheet.prototype) return () => {};
const o = n.CSSStyleSheet.prototype.insertRule;
n.CSSStyleSheet.prototype.insertRule = new Proxy(o, {
apply: x((u, d, h) => {
const [m, p] = h,
{ id: v, styleId: b } = Se(d, e, r.styleMirror);
return (
((v && v !== -1) || (b && b !== -1)) &&
t({ id: v, styleId: b, adds: [{ rule: m, index: p }] }),
u.apply(d, h)
);
}),
});
const a = n.CSSStyleSheet.prototype.deleteRule;
n.CSSStyleSheet.prototype.deleteRule = new Proxy(a, {
apply: x((u, d, h) => {
const [m] = h,
{ id: p, styleId: v } = Se(d, e, r.styleMirror);
return (
((p && p !== -1) || (v && v !== -1)) &&
t({ id: p, styleId: v, removes: [{ index: m }] }),
u.apply(d, h)
);
}),
});
let i;
n.CSSStyleSheet.prototype.replace &&
((i = n.CSSStyleSheet.prototype.replace),
(n.CSSStyleSheet.prototype.replace = new Proxy(i, {
apply: x((u, d, h) => {
const [m] = h,
{ id: p, styleId: v } = Se(d, e, r.styleMirror);
return (
((p && p !== -1) || (v && v !== -1)) &&
t({ id: p, styleId: v, replace: m }),
u.apply(d, h)
);
}),
})));
let l;
n.CSSStyleSheet.prototype.replaceSync &&
((l = n.CSSStyleSheet.prototype.replaceSync),
(n.CSSStyleSheet.prototype.replaceSync = new Proxy(l, {
apply: x((u, d, h) => {
const [m] = h,
{ id: p, styleId: v } = Se(d, e, r.styleMirror);
return (
((p && p !== -1) || (v && v !== -1)) &&
t({ id: p, styleId: v, replaceSync: m }),
u.apply(d, h)
);
}),
})));
const s = {};
tt("CSSGroupingRule")
? (s.CSSGroupingRule = n.CSSGroupingRule)
: (tt("CSSMediaRule") && (s.CSSMediaRule = n.CSSMediaRule),
tt("CSSConditionRule") && (s.CSSConditionRule = n.CSSConditionRule),
tt("CSSSupportsRule") && (s.CSSSupportsRule = n.CSSSupportsRule));
const c = {};
return (
Object.entries(s).forEach(([u, d]) => {
(c[u] = {
insertRule: d.prototype.insertRule,
deleteRule: d.prototype.deleteRule,
}),
(d.prototype.insertRule = new Proxy(c[u].insertRule, {
apply: x((h, m, p) => {
const [v, b] = p,
{ id: f, styleId: y } = Se(
m.parentStyleSheet,
e,
r.styleMirror
);
return (
((f && f !== -1) || (y && y !== -1)) &&
t({
id: f,
styleId: y,
adds: [{ rule: v, index: [...qe(m), b || 0] }],
}),
h.apply(m, p)
);
}),
})),
(d.prototype.deleteRule = new Proxy(c[u].deleteRule, {
apply: x((h, m, p) => {
const [v] = p,
{ id: b, styleId: f } = Se(
m.parentStyleSheet,
e,
r.styleMirror
);
return (
((b && b !== -1) || (f && f !== -1)) &&
t({ id: b, styleId: f, removes: [{ index: [...qe(m), v] }] }),
h.apply(m, p)
);
}),
}));
}),
x(() => {
(n.CSSStyleSheet.prototype.insertRule = o),
(n.CSSStyleSheet.prototype.deleteRule = a),
i && (n.CSSStyleSheet.prototype.replace = i),
l && (n.CSSStyleSheet.prototype.replaceSync = l),
Object.entries(s).forEach(([u, d]) => {
(d.prototype.insertRule = c[u].insertRule),
(d.prototype.deleteRule = c[u].deleteRule);
});
})
);
}
function Sr({ mirror: t, stylesheetManager: e }, r) {
var n, o, a;
let i = null;
r.nodeName === "#document" ? (i = t.getId(r)) : (i = t.getId(r.host));
const l =
r.nodeName === "#document"
? (n = r.defaultView) == null
? void 0
: n.Document
: (a = (o = r.ownerDocument) == null ? void 0 : o.defaultView) == null
? void 0
: a.ShadowRoot,
s = Object.getOwnPropertyDescriptor(l?.prototype, "adoptedStyleSheets");
return i === null || i === -1 || !l || !s
? () => {}
: (Object.defineProperty(r, "adoptedStyleSheets", {
configurable: s.configurable,
enumerable: s.enumerable,
get() {
var c;
return (c = s.get) == null ? void 0 : c.call(this);
},
set(c) {
var u;
const d = (u = s.set) == null ? void 0 : u.call(this, c);
if (i !== null && i !== -1)
try {
e.adoptStyleSheets(c, i);
} catch {}
return d;
},
}),
x(() => {
Object.defineProperty(r, "adoptedStyleSheets", {
configurable: s.configurable,
enumerable: s.enumerable,
get: s.get,
set: s.set,
});
}));
}
function po(
{
styleDeclarationCb: t,
mirror: e,
ignoreCSSAttributes: r,
stylesheetManager: n,
},
{ win: o }
) {
const a = o.CSSStyleDeclaration.prototype.setProperty;
o.CSSStyleDeclaration.prototype.setProperty = new Proxy(a, {
apply: x((l, s, c) => {
var u;
const [d, h, m] = c;
if (r.has(d)) return a.apply(s, [d, h, m]);
const { id: p, styleId: v } = Se(
(u = s.parentRule) == null ? void 0 : u.parentStyleSheet,
e,
n.styleMirror
);
return (
((p && p !== -1) || (v && v !== -1)) &&
t({
id: p,
styleId: v,
set: { property: d, value: h, priority: m },
index: qe(s.parentRule),
}),
l.apply(s, c)
);
}),
});
const i = o.CSSStyleDeclaration.prototype.removeProperty;
return (
(o.CSSStyleDeclaration.prototype.removeProperty = new Proxy(i, {
apply: x((l, s, c) => {
var u;
const [d] = c;
if (r.has(d)) return i.apply(s, [d]);
const { id: h, styleId: m } = Se(
(u = s.parentRule) == null ? void 0 : u.parentStyleSheet,
e,
n.styleMirror
);
return (
((h && h !== -1) || (m && m !== -1)) &&
t({
id: h,
styleId: m,
remove: { property: d },
index: qe(s.parentRule),
}),
l.apply(s, c)
);
}),
})),
x(() => {
(o.CSSStyleDeclaration.prototype.setProperty = a),
(o.CSSStyleDeclaration.prototype.removeProperty = i);
})
);
}
function mo({
mediaInteractionCb: t,
blockClass: e,
blockSelector: r,
mirror: n,
sampling: o,
doc: a,
}) {
const i = x((s) =>
Ie(
x((c) => {
const u = je(c);
if (!u || te(u, e, r, !0)) return;
const { currentTime: d, volume: h, muted: m, playbackRate: p } = u;
t({
type: s,
id: n.getId(u),
currentTime: d,
volume: h,
muted: m,
playbackRate: p,
});
}),
o.media || 500
)
),
l = [
ee("play", i(ye.Play), a),
ee("pause", i(ye.Pause), a),
ee("seeked", i(ye.Seeked), a),
ee("volumechange", i(ye.VolumeChange), a),
ee("ratechange", i(ye.RateChange), a),
];
return x(() => {
l.forEach((s) => s());
});
}
function fo({ fontCb: t, doc: e }) {
const r = e.defaultView;
if (!r) return () => {};
const n = [],
o = new WeakMap(),
a = r.FontFace;
r.FontFace = function (l, s, c) {
const u = new a(l, s, c);
return (
o.set(u, {
family: l,
buffer: typeof s != "string",
descriptors: c,
fontSource:
typeof s == "string"
? s
: JSON.stringify(Array.from(new Uint8Array(s))),
}),
u
);
};
const i = De(e.fonts, "add", function (l) {
return function (s) {
return (
setTimeout(
x(() => {
const c = o.get(s);
c && (t(c), o.delete(s));
}),
0
),
l.apply(this, [s])
);
};
});
return (
n.push(() => {
r.FontFace = a;
}),
n.push(i),
x(() => {
n.forEach((l) => l());
})
);
}
function yo(t) {
const {
doc: e,
mirror: r,
blockClass: n,
blockSelector: o,
selectionCb: a,
} = t;
let i = !0;
const l = x(() => {
const s = e.getSelection();
if (!s || (i && s?.isCollapsed)) return;
i = s.isCollapsed || !1;
const c = [],
u = s.rangeCount || 0;
for (let d = 0; d < u; d++) {
const h = s.getRangeAt(d),
{
startContainer: m,
startOffset: p,
endContainer: v,
endOffset: b,
} = h;
te(m, n, o, !0) ||
te(v, n, o, !0) ||
c.push({
start: r.getId(m),
startOffset: p,
end: r.getId(v),
endOffset: b,
});
}
a({ ranges: c });
});
return l(), ee("selectionchange", l);
}
function go(t, e) {
const {
mutationCb: r,
mousemoveCb: n,
mouseInteractionCb: o,
scrollCb: a,
viewportResizeCb: i,
inputCb: l,
mediaInteractionCb: s,
styleSheetRuleCb: c,
styleDeclarationCb: u,
canvasMutationCb: d,
fontCb: h,
selectionCb: m,
} = t;
(t.mutationCb = (...p) => {
e.mutation && e.mutation(...p), r(...p);
}),
(t.mousemoveCb = (...p) => {
e.mousemove && e.mousemove(...p), n(...p);
}),
(t.mouseInteractionCb = (...p) => {
e.mouseInteraction && e.mouseInteraction(...p), o(...p);
}),
(t.scrollCb = (...p) => {
e.scroll && e.scroll(...p), a(...p);
}),
(t.viewportResizeCb = (...p) => {
e.viewportResize && e.viewportResize(...p), i(...p);
}),
(t.inputCb = (...p) => {
e.input && e.input(...p), l(...p);
}),
(t.mediaInteractionCb = (...p) => {
e.mediaInteaction && e.mediaInteaction(...p), s(...p);
}),
(t.styleSheetRuleCb = (...p) => {
e.styleSheetRule && e.styleSheetRule(...p), c(...p);
}),
(t.styleDeclarationCb = (...p) => {
e.styleDeclaration && e.styleDeclaration(...p), u(...p);
}),
(t.canvasMutationCb = (...p) => {
e.canvasMutation && e.canvasMutation(...p), d(...p);
}),
(t.fontCb = (...p) => {
e.font && e.font(...p), h(...p);
}),
(t.selectionCb = (...p) => {
e.selection && e.selection(...p), m(...p);
});
}
function vo(t, e = {}) {
const r = t.doc.defaultView;
if (!r) return () => {};
go(t, e);
const n = fr(t, t.doc),
o = io(t),
a = ao(t),
i = yr(t),
l = lo(t, { win: r }),
s = uo(t),
c = mo(t),
u = ho(t, { win: r }),
d = Sr(t, t.doc),
h = po(t, { win: r }),
m = t.collectFonts ? fo(t) : () => {},
p = yo(t),
v = [];
for (const b of t.plugins) v.push(b.observer(b.callback, r, b.options));
return x(() => {
we.forEach((b) => b.reset()),
n.disconnect(),
o(),
a(),
i(),
l(),
s(),
c(),
u(),
d(),
h(),
m(),
p(),
v.forEach((b) => b());
});
}
function et(t) {
return typeof window[t] < "u";
}
function tt(t) {
return Boolean(
typeof window[t] < "u" &&
window[t].prototype &&
"insertRule" in window[t].prototype &&
"deleteRule" in window[t].prototype
);
}
class br {
constructor(e) {
(this.generateIdFn = e),
(this.iframeIdToRemoteIdMap = new WeakMap()),
(this.iframeRemoteIdToIdMap = new WeakMap());
}
getId(e, r, n, o) {
const a = n || this.getIdToRemoteIdMap(e),
i = o || this.getRemoteIdToIdMap(e);
let l = a.get(r);
return l || ((l = this.generateIdFn()), a.set(r, l), i.set(l, r)), l;
}
getIds(e, r) {
const n = this.getIdToRemoteIdMap(e),
o = this.getRemoteIdToIdMap(e);
return r.map((a) => this.getId(e, a, n, o));
}
getRemoteId(e, r, n) {
const o = n || this.getRemoteIdToIdMap(e);
return typeof r != "number" ? r : o.get(r) || -1;
}
getRemoteIds(e, r) {
const n = this.getRemoteIdToIdMap(e);
return r.map((o) => this.getRemoteId(e, o, n));
}
reset(e) {
if (!e) {
(this.iframeIdToRemoteIdMap = new WeakMap()),
(this.iframeRemoteIdToIdMap = new WeakMap());
return;
}
this.iframeIdToRemoteIdMap.delete(e),
this.iframeRemoteIdToIdMap.delete(e);
}
getIdToRemoteIdMap(e) {
let r = this.iframeIdToRemoteIdMap.get(e);
return r || ((r = new Map()), this.iframeIdToRemoteIdMap.set(e, r)), r;
}
getRemoteIdToIdMap(e) {
let r = this.iframeRemoteIdToIdMap.get(e);
return r || ((r = new Map()), this.iframeRemoteIdToIdMap.set(e, r)), r;
}
}
class So {
constructor(e) {
(this.iframes = new WeakMap()),
(this.crossOriginIframeMap = new WeakMap()),
(this.crossOriginIframeMirror = new br(Ht)),
(this.crossOriginIframeRootIdMap = new WeakMap()),
(this.mutationCb = e.mutationCb),
(this.wrappedEmit = e.wrappedEmit),
(this.stylesheetManager = e.stylesheetManager),
(this.recordCrossOriginIframes = e.recordCrossOriginIframes),
(this.crossOriginIframeStyleMirror = new br(
this.stylesheetManager.styleMirror.generateId.bind(
this.stylesheetManager.styleMirror
)
)),
(this.mirror = e.mirror),
this.recordCrossOriginIframes &&
window.addEventListener("message", this.handleMessage.bind(this));
}
addIframe(e) {
this.iframes.set(e, !0),
e.contentWindow && this.crossOriginIframeMap.set(e.contentWindow, e);
}
addLoadListener(e) {
this.loadListener = e;
}
attachIframe(e, r) {
var n;
this.mutationCb({
adds: [{ parentId: this.mirror.getId(e), nextId: null, node: r }],
removes: [],
texts: [],
attributes: [],
isAttachIframe: !0,
}),
(n = this.loadListener) == null || n.call(this, e),
e.contentDocument &&
e.contentDocument.adoptedStyleSheets &&
e.contentDocument.adoptedStyleSheets.length > 0 &&
this.stylesheetManager.adoptStyleSheets(
e.contentDocument.adoptedStyleSheets,
this.mirror.getId(e.contentDocument)
);
}
handleMessage(e) {
const r = e;
if (r.data.type !== "rrweb" || r.origin !== r.data.origin || !e.source)
return;
const n = this.crossOriginIframeMap.get(e.source);
if (!n) return;
const o = this.transformCrossOriginEvent(n, r.data.event);
o && this.wrappedEmit(o, r.data.isCheckout);
}
transformCrossOriginEvent(e, r) {
var n;
switch (r.type) {
case T.FullSnapshot: {
this.crossOriginIframeMirror.reset(e),
this.crossOriginIframeStyleMirror.reset(e),
this.replaceIdOnNode(r.data.node, e);
const o = r.data.node.id;
return (
this.crossOriginIframeRootIdMap.set(e, o),
this.patchRootIdOnNode(r.data.node, o),
{
timestamp: r.timestamp,
type: T.IncrementalSnapshot,
data: {
source: E.Mutation,
adds: [
{
parentId: this.mirror.getId(e),
nextId: null,
node: r.data.node,
},
],
removes: [],
texts: [],
attributes: [],
isAttachIframe: !0,
},
}
);
}
case T.Meta:
case T.Load:
case T.DomContentLoaded:
return !1;
case T.Plugin:
return r;
case T.Custom:
return (
this.replaceIds(r.data.payload, e, [
"id",
"parentId",
"previousId",
"nextId",
]),
r
);
case T.IncrementalSnapshot:
switch (r.data.source) {
case E.Mutation:
return (
r.data.adds.forEach((o) => {
this.replaceIds(o, e, ["parentId", "nextId", "previousId"]),
this.replaceIdOnNode(o.node, e);
const a = this.crossOriginIframeRootIdMap.get(e);
a && this.patchRootIdOnNode(o.node, a);
}),
r.data.removes.forEach((o) => {
this.replaceIds(o, e, ["parentId", "id"]);
}),
r.data.attributes.forEach((o) => {
this.replaceIds(o, e, ["id"]);
}),
r.data.texts.forEach((o) => {
this.replaceIds(o, e, ["id"]);
}),
r
);
case E.Drag:
case E.TouchMove:
case E.MouseMove:
return (
r.data.positions.forEach((o) => {
this.replaceIds(o, e, ["id"]);
}),
r
);
case E.ViewportResize:
return !1;
case E.MediaInteraction:
case E.MouseInteraction:
case E.Scroll:
case E.CanvasMutation:
case E.Input:
return this.replaceIds(r.data, e, ["id"]), r;
case E.StyleSheetRule:
case E.StyleDeclaration:
return (
this.replaceIds(r.data, e, ["id"]),
this.replaceStyleIds(r.data, e, ["styleId"]),
r
);
case E.Font:
return r;
case E.Selection:
return (
r.data.ranges.forEach((o) => {
this.replaceIds(o, e, ["start", "end"]);
}),
r
);
case E.AdoptedStyleSheet:
return (
this.replaceIds(r.data, e, ["id"]),
this.replaceStyleIds(r.data, e, ["styleIds"]),
(n = r.data.styles) == null ||
n.forEach((o) => {
this.replaceStyleIds(o, e, ["styleId"]);
}),
r
);
}
}
}
replace(e, r, n, o) {
for (const a of o)
(!Array.isArray(r[a]) && typeof r[a] != "number") ||
(Array.isArray(r[a])
? (r[a] = e.getIds(n, r[a]))
: (r[a] = e.getId(n, r[a])));
return r;
}
replaceIds(e, r, n) {
return this.replace(this.crossOriginIframeMirror, e, r, n);
}
replaceStyleIds(e, r, n) {
return this.replace(this.crossOriginIframeStyleMirror, e, r, n);
}
replaceIdOnNode(e, r) {
this.replaceIds(e, r, ["id", "rootId"]),
"childNodes" in e &&
e.childNodes.forEach((n) => {
this.replaceIdOnNode(n, r);
});
}
patchRootIdOnNode(e, r) {
e.type !== N.Document && !e.rootId && (e.rootId = r),
"childNodes" in e &&
e.childNodes.forEach((n) => {
this.patchRootIdOnNode(n, r);
});
}
}
var bo = Object.defineProperty,
wo = Object.defineProperties,
Co = Object.getOwnPropertyDescriptors,
wr = Object.getOwnPropertySymbols,
Eo = Object.prototype.hasOwnProperty,
To = Object.prototype.propertyIsEnumerable,
Cr = (t, e, r) =>
e in t
? bo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
: (t[e] = r),
Er = (t, e) => {
for (var r in e || (e = {})) Eo.call(e, r) && Cr(t, r, e[r]);
if (wr) for (var r of wr(e)) To.call(e, r) && Cr(t, r, e[r]);
return t;
},
Tr = (t, e) => wo(t, Co(e));
class No {
constructor(e) {
(this.shadowDoms = new WeakSet()),
(this.restoreHandlers = []),
(this.mutationCb = e.mutationCb),
(this.scrollCb = e.scrollCb),
(this.bypassOptions = e.bypassOptions),
(this.mirror = e.mirror),
this.init();
}
init() {
this.reset(), this.patchAttachShadow(Element, document);
}
addShadowRoot(e, r) {
if (!We(e) || this.shadowDoms.has(e)) return;
this.shadowDoms.add(e);
const n = fr(
Tr(Er({}, this.bypassOptions), {
doc: r,
mutationCb: this.mutationCb,
mirror: this.mirror,
shadowDomManager: this,
}),
e
);
this.restoreHandlers.push(() => n.disconnect()),
this.restoreHandlers.push(
yr(
Tr(Er({}, this.bypassOptions), {
scrollCb: this.scrollCb,
doc: e,
mirror: this.mirror,
})
)
),
setTimeout(() => {
e.adoptedStyleSheets &&
e.adoptedStyleSheets.length > 0 &&
this.bypassOptions.stylesheetManager.adoptStyleSheets(
e.adoptedStyleSheets,
this.mirror.getId(e.host)
),
this.restoreHandlers.push(
Sr(
{
mirror: this.mirror,
stylesheetManager: this.bypassOptions.stylesheetManager,
},
e
)
);
}, 0);
}
observeAttachShadow(e) {
!e.contentWindow ||
!e.contentDocument ||
this.patchAttachShadow(e.contentWindow.Element, e.contentDocument);
}
patchAttachShadow(e, r) {
const n = this;
this.restoreHandlers.push(
De(e.prototype, "attachShadow", function (o) {
return function (a) {
const i = o.call(this, a);
return (
this.shadowRoot &&
It(this) &&
n.addShadowRoot(this.shadowRoot, r),
i
);
};
})
);
}
reset() {
this.restoreHandlers.forEach((e) => {
try {
e();
} catch {}
}),
(this.restoreHandlers = []),
(this.shadowDoms = new WeakSet());
}
}
for (
var xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256),
rt = 0;
rt < xe.length;
rt++
)
ze[xe.charCodeAt(rt)] = rt;
var Mo = function (t) {
var e = new Uint8Array(t),
r,
n = e.length,
o = "";
for (r = 0; r < n; r += 3)
(o += xe[e[r] >> 2]),
(o += xe[((e[r] & 3) << 4) | (e[r + 1] >> 4)]),
(o += xe[((e[r + 1] & 15) << 2) | (e[r + 2] >> 6)]),
(o += xe[e[r + 2] & 63]);
return (
n % 3 === 2
? (o = o.substring(0, o.length - 1) + "=")
: n % 3 === 1 && (o = o.substring(0, o.length - 2) + "=="),
o
);
},
Io = function (t) {
var e = t.length * 0.75,
r = t.length,
n,
o = 0,
a,
i,
l,
s;
t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
var c = new ArrayBuffer(e),
u = new Uint8Array(c);
for (n = 0; n < r; n += 4)
(a = ze[t.charCodeAt(n)]),
(i = ze[t.charCodeAt(n + 1)]),
(l = ze[t.charCodeAt(n + 2)]),
(s = ze[t.charCodeAt(n + 3)]),
(u[o++] = (a << 2) | (i >> 4)),
(u[o++] = ((i & 15) << 4) | (l >> 2)),
(u[o++] = ((l & 3) << 6) | (s & 63));
return c;
};
const Nr = new Map();
function Do(t, e) {
let r = Nr.get(t);
return (
r || ((r = new Map()), Nr.set(t, r)), r.has(e) || r.set(e, []), r.get(e)
);
}
const Mr = (t, e, r) => {
if (!t || !(Dr(t, e) || typeof t == "object")) return;
const n = t.constructor.name,
o = Do(r, n);
let a = o.indexOf(t);
return a === -1 && ((a = o.length), o.push(t)), a;
};
function nt(t, e, r) {
if (t instanceof Array) return t.map((n) => nt(n, e, r));
if (t === null) return t;
if (
t instanceof Float32Array ||
t instanceof Float64Array ||
t instanceof Int32Array ||
t instanceof Uint32Array ||
t instanceof Uint8Array ||
t instanceof Uint16Array ||
t instanceof Int16Array ||
t instanceof Int8Array ||
t instanceof Uint8ClampedArray
)
return { rr_type: t.constructor.name, args: [Object.values(t)] };
if (t instanceof ArrayBuffer) {
const n = t.constructor.name,
o = Mo(t);
return { rr_type: n, base64: o };
} else {
if (t instanceof DataView)
return {
rr_type: t.constructor.name,
args: [nt(t.buffer, e, r), t.byteOffset, t.byteLength],
};
if (t instanceof HTMLImageElement) {
const n = t.constructor.name,
{ src: o } = t;
return { rr_type: n, src: o };
} else if (t instanceof HTMLCanvasElement) {
const n = "HTMLImageElement",
o = t.toDataURL();
return { rr_type: n, src: o };
} else {
if (t instanceof ImageData)
return {
rr_type: t.constructor.name,
args: [nt(t.data, e, r), t.width, t.height],
};
if (Dr(t, e) || typeof t == "object") {
const n = t.constructor.name,
o = Mr(t, e, r);
return { rr_type: n, index: o };
}
}
}
return t;
}
const Ir = (t, e, r) => [...t].map((n) => nt(n, e, r)),
Dr = (t, e) => {
const r = [
"WebGLActiveInfo",
"WebGLBuffer",
"WebGLFramebuffer",
"WebGLProgram",
"WebGLRenderbuffer",
"WebGLShader",
"WebGLShaderPrecisionFormat",
"WebGLTexture",
"WebGLUniformLocation",
"WebGLVertexArrayObject",
"WebGLVertexArrayObjectOES",
].filter((n) => typeof e[n] == "function");
return Boolean(r.find((n) => t instanceof e[n]));
};
function ko(t, e, r, n) {
const o = [],
a = Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);
for (const i of a)
try {
if (typeof e.CanvasRenderingContext2D.prototype[i] != "function")
continue;
const l = De(e.CanvasRenderingContext2D.prototype, i, function (s) {
return function (...c) {
return (
te(this.canvas, r, n, !0) ||
setTimeout(() => {
const u = Ir([...c], e, this);
t(this.canvas, { type: fe["2D"], property: i, args: u });
}, 0),
s.apply(this, c)
);
};
});
o.push(l);
} catch {
const s = Ve(e.CanvasRenderingContext2D.prototype, i, {
set(c) {
t(this.canvas, {
type: fe["2D"],
property: i,
args: [c],
setter: !0,
});
},
});
o.push(s);
}
return () => {
o.forEach((i) => i());
};
}
function Ro(t) {
return t === "experimental-webgl" ? "webgl" : t;
}
function kr(t, e, r, n) {
const o = [];
try {
const a = De(t.HTMLCanvasElement.prototype, "getContext", function (i) {
return function (l, ...s) {
if (!te(this, e, r, !0)) {
const c = Ro(l);
if (
("__context" in this || (this.__context = c),
n && ["webgl", "webgl2"].includes(c))
)
if (s[0] && typeof s[0] == "object") {
const u = s[0];
u.preserveDrawingBuffer || (u.preserveDrawingBuffer = !0);
} else s.splice(0, 1, { preserveDrawingBuffer: !0 });
}
return i.apply(this, [l, ...s]);
};
});
o.push(a);
} catch {
console.error("failed to patch HTMLCanvasElement.prototype.getContext");
}
return () => {
o.forEach((a) => a());
};
}
function Rr(t, e, r, n, o, a, i) {
const l = [],
s = Object.getOwnPropertyNames(t);
for (const c of s)
if (
![
"isContextLost",
"canvas",
"drawingBufferWidth",
"drawingBufferHeight",
].includes(c)
)
try {
if (typeof t[c] != "function") continue;
const u = De(t, c, function (d) {
return function (...h) {
const m = d.apply(this, h);
if (
(Mr(m, i, this),
"tagName" in this.canvas && !te(this.canvas, n, o, !0))
) {
const p = Ir([...h], i, this),
v = { type: e, property: c, args: p };
r(this.canvas, v);
}
return m;
};
});
l.push(u);
} catch {
const d = Ve(t, c, {
set(h) {
r(this.canvas, { type: e, property: c, args: [h], setter: !0 });
},
});
l.push(d);
}
return l;
}
function xo(t, e, r, n, o) {
const a = [];
return (
a.push(...Rr(e.WebGLRenderingContext.prototype, fe.WebGL, t, r, n, o, e)),
typeof e.WebGL2RenderingContext < "u" &&
a.push(
...Rr(e.WebGL2RenderingContext.prototype, fe.WebGL2, t, r, n, o, e)
),
() => {
a.forEach((i) => i());
}
);
}
function Oo(t, e) {
var r = atob(t);
if (e) {
for (var n = new Uint8Array(r.length), o = 0, a = r.length; o < a; ++o)
n[o] = r.charCodeAt(o);
return String.fromCharCode.apply(null, new Uint16Array(n.buffer));
}
return r;
}
function Lo(t, e, r) {
var n = e === void 0 ? null : e,
o = r === void 0 ? !1 : r,
a = Oo(t, o),
i =
a.indexOf(
`
`,
10
) + 1,
l = a.substring(i) + (n ? "//# sourceMappingURL=" + n : ""),
s = new Blob([l], { type: "application/javascript" });
return URL.createObjectURL(s);
}
function Ao(t, e, r) {
var n;
return function (a) {
return (n = n || Lo(t, e, r)), new Worker(n, a);
};
}
var _o = Ao(
"Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Zm9yKHZhciByPSJBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OSsvIixwPXR5cGVvZiBVaW50OEFycmF5PiJ1Ij9bXTpuZXcgVWludDhBcnJheSgyNTYpLGY9MDtmPHIubGVuZ3RoO2YrKylwW3IuY2hhckNvZGVBdChmKV09Zjt2YXIgdT1mdW5jdGlvbihzKXt2YXIgZT1uZXcgVWludDhBcnJheShzKSxuLGE9ZS5sZW5ndGgsdD0iIjtmb3Iobj0wO248YTtuKz0zKXQrPXJbZVtuXT4+Ml0sdCs9clsoZVtuXSYzKTw8NHxlW24rMV0+PjRdLHQrPXJbKGVbbisxXSYxNSk8PDJ8ZVtuKzJdPj42XSx0Kz1yW2VbbisyXSY2M107cmV0dXJuIGElMz09PTI/dD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTEpKyI9IjphJTM9PT0xJiYodD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTIpKyI9PSIpLHR9O2NvbnN0IGM9bmV3IE1hcCxsPW5ldyBNYXA7YXN5bmMgZnVuY3Rpb24gdihzLGUsbil7Y29uc3QgYT1gJHtzfS0ke2V9YDtpZigiT2Zmc2NyZWVuQ2FudmFzImluIGdsb2JhbFRoaXMpe2lmKGwuaGFzKGEpKXJldHVybiBsLmdldChhKTtjb25zdCB0PW5ldyBPZmZzY3JlZW5DYW52YXMocyxlKTt0LmdldENvbnRleHQoIjJkIik7Y29uc3QgZz1hd2FpdChhd2FpdCB0LmNvbnZlcnRUb0Jsb2IobikpLmFycmF5QnVmZmVyKCksZD11KGcpO3JldHVybiBsLnNldChhLGQpLGR9ZWxzZSByZXR1cm4iIn1jb25zdCBpPXNlbGY7aS5vbm1lc3NhZ2U9YXN5bmMgZnVuY3Rpb24ocyl7aWYoIk9mZnNjcmVlbkNhbnZhcyJpbiBnbG9iYWxUaGlzKXtjb25zdHtpZDplLGJpdG1hcDpuLHdpZHRoOmEsaGVpZ2h0OnQsZGF0YVVSTE9wdGlvbnM6Z309cy5kYXRhLGQ9dihhLHQsZyksaD1uZXcgT2Zmc2NyZWVuQ2FudmFzKGEsdCk7aC5nZXRDb250ZXh0KCIyZCIpLmRyYXdJbWFnZShuLDAsMCksbi5jbG9zZSgpO2NvbnN0IHc9YXdhaXQgaC5jb252ZXJ0VG9CbG9iKGcpLHk9dy50eXBlLGI9YXdhaXQgdy5hcnJheUJ1ZmZlcigpLG89dShiKTtpZighYy5oYXMoZSkmJmF3YWl0IGQ9PT1vKXJldHVybiBjLnNldChlLG8pLGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpZihjLmdldChlKT09PW8pcmV0dXJuIGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpLnBvc3RNZXNzYWdlKHtpZDplLHR5cGU6eSxiYXNlNjQ6byx3aWR0aDphLGhlaWdodDp0fSksYy5zZXQoZSxvKX1lbHNlIHJldHVybiBpLnBvc3RNZXNzYWdlKHtpZDpzLmRhdGEuaWR9KX19KSgpOwoK",
null,
!1
),
xr = Object.getOwnPropertySymbols,
Fo = Object.prototype.hasOwnProperty,
Po = Object.prototype.propertyIsEnumerable,
Wo = (t, e) => {
var r = {};
for (var n in t) Fo.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]);
if (t != null && xr)
for (var n of xr(t)) e.indexOf(n) < 0 && Po.call(t, n) && (r[n] = t[n]);
return r;
},
$o = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) =>
s.done ? n(s.value) : Promise.resolve(s.value).then(a, i);
l((r = r.apply(t, e)).next());
});
class Uo {
constructor(e) {
(this.pendingCanvasMutations = new Map()),
(this.rafStamps = { latestId: 0, invokeId: null }),
(this.frozen = !1),
(this.locked = !1),
(this.processMutation = (s, c) => {
((this.rafStamps.invokeId &&
this.rafStamps.latestId !== this.rafStamps.invokeId) ||
!this.rafStamps.invokeId) &&
(this.rafStamps.invokeId = this.rafStamps.latestId),
this.pendingCanvasMutations.has(s) ||
this.pendingCanvasMutations.set(s, []),
this.pendingCanvasMutations.get(s).push(c);
});
const {
sampling: r = "all",
win: n,
blockClass: o,
blockSelector: a,
recordCanvas: i,
dataURLOptions: l,
} = e;
(this.mutationCb = e.mutationCb),
(this.mirror = e.mirror),
i && r === "all" && this.initCanvasMutationObserver(n, o, a),
i &&
typeof r == "number" &&
this.initCanvasFPSObserver(r, n, o, a, { dataURLOptions: l });
}
reset() {
this.pendingCanvasMutations.clear(),
this.resetObservers && this.resetObservers();
}
freeze() {
this.frozen = !0;
}
unfreeze() {
this.frozen = !1;
}
lock() {
this.locked = !0;
}
unlock() {
this.locked = !1;
}
initCanvasFPSObserver(e, r, n, o, a) {
const i = kr(r, n, o, !0),
l = new Map(),
s = new _o();
s.onmessage = (p) => {
const { id: v } = p.data;
if ((l.set(v, !1), !("base64" in p.data))) return;
const { base64: b, type: f, width: y, height: g } = p.data;
this.mutationCb({
id: v,
type: fe["2D"],
commands: [
{ property: "clearRect", args: [0, 0, y, g] },
{
property: "drawImage",
args: [
{
rr_type: "ImageBitmap",
args: [
{
rr_type: "Blob",
data: [{ rr_type: "ArrayBuffer", base64: b }],
type: f,
},
],
},
0,
0,
],
},
],
});
};
const c = 1e3 / e;
let u = 0,
d;
const h = () => {
const p = [];
return (
r.document.querySelectorAll("canvas").forEach((v) => {
te(v, n, o, !0) || p.push(v);
}),
p
);
},
m = (p) => {
if (u && p - u < c) {
d = requestAnimationFrame(m);
return;
}
(u = p),
h().forEach((v) =>
$o(this, null, function* () {
var b;
const f = this.mirror.getId(v);
if (l.get(f)) return;
if ((l.set(f, !0), ["webgl", "webgl2"].includes(v.__context))) {
const g = v.getContext(v.__context);
((b = g?.getContextAttributes()) == null
? void 0
: b.preserveDrawingBuffer) === !1 &&
g.clear(g.COLOR_BUFFER_BIT);
}
const y = yield createImageBitmap(v);
s.postMessage(
{
id: f,
bitmap: y,
width: v.width,
height: v.height,
dataURLOptions: a.dataURLOptions,
},
[y]
);
})
),
(d = requestAnimationFrame(m));
};
(d = requestAnimationFrame(m)),
(this.resetObservers = () => {
i(), cancelAnimationFrame(d);
});
}
initCanvasMutationObserver(e, r, n) {
this.startRAFTimestamping(), this.startPendingCanvasMutationFlusher();
const o = kr(e, r, n, !1),
a = ko(this.processMutation.bind(this), e, r, n),
i = xo(this.processMutation.bind(this), e, r, n, this.mirror);
this.resetObservers = () => {
o(), a(), i();
};
}
startPendingCanvasMutationFlusher() {
requestAnimationFrame(() => this.flushPendingCanvasMutations());
}
startRAFTimestamping() {
const e = (r) => {
(this.rafStamps.latestId = r), requestAnimationFrame(e);
};
requestAnimationFrame(e);
}
flushPendingCanvasMutations() {
this.pendingCanvasMutations.forEach((e, r) => {
const n = this.mirror.getId(r);
this.flushPendingCanvasMutationFor(r, n);
}),
requestAnimationFrame(() => this.flushPendingCanvasMutations());
}
flushPendingCanvasMutationFor(e, r) {
if (this.frozen || this.locked) return;
const n = this.pendingCanvasMutations.get(e);
if (!n || r === -1) return;
const o = n.map((i) => Wo(i, ["type"])),
{ type: a } = n[0];
this.mutationCb({ id: r, type: a, commands: o }),
this.pendingCanvasMutations.delete(e);
}
}
class Vo {
constructor(e) {
(this.trackedLinkElements = new WeakSet()),
(this.styleMirror = new Nt()),
(this.mutationCb = e.mutationCb),
(this.adoptedStyleSheetCb = e.adoptedStyleSheetCb);
}
attachLinkElement(e, r) {
"_cssText" in r.attributes &&
this.mutationCb({
adds: [],
removes: [],
texts: [],
attributes: [{ id: r.id, attributes: r.attributes }],
}),
this.trackLinkElement(e);
}
trackLinkElement(e) {
this.trackedLinkElements.has(e) ||
(this.trackedLinkElements.add(e), this.trackStylesheetInLinkElement(e));
}
adoptStyleSheets(e, r) {
if (e.length === 0) return;
const n = { id: r, styleIds: [] },
o = [];
for (const a of e) {
let i;
if (this.styleMirror.has(a)) i = this.styleMirror.getId(a);
else {
i = this.styleMirror.add(a);
const l = Array.from(a.rules || CSSRule);
o.push({
styleId: i,
rules: l.map((s, c) => ({ rule: Gt(s), index: c })),
});
}
n.styleIds.push(i);
}
o.length > 0 && (n.styles = o), this.adoptedStyleSheetCb(n);
}
reset() {
this.styleMirror.reset(), (this.trackedLinkElements = new WeakSet());
}
trackStylesheetInLinkElement(e) {}
}
class Bo {
constructor() {
(this.nodeMap = new WeakMap()),
(this.loop = !0),
this.periodicallyClear();
}
periodicallyClear() {
requestAnimationFrame(() => {
this.clear(), this.loop && this.periodicallyClear();
});
}
inOtherBuffer(e, r) {
const n = this.nodeMap.get(e);
return n && Array.from(n).some((o) => o !== r);
}
add(e, r) {
this.nodeMap.set(e, (this.nodeMap.get(e) || new Set()).add(r));
}
clear() {
this.nodeMap = new WeakMap();
}
destroy() {
this.loop = !1;
}
}
var Go = Object.defineProperty,
jo = Object.defineProperties,
zo = Object.getOwnPropertyDescriptors,
Or = Object.getOwnPropertySymbols,
Ho = Object.prototype.hasOwnProperty,
Yo = Object.prototype.propertyIsEnumerable,
Lr = (t, e, r) =>
e in t
? Go(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
: (t[e] = r),
oe = (t, e) => {
for (var r in e || (e = {})) Ho.call(e, r) && Lr(t, r, e[r]);
if (Or) for (var r of Or(e)) Yo.call(e, r) && Lr(t, r, e[r]);
return t;
},
Xo = (t, e) => jo(t, zo(e));
function z(t) {
return Xo(oe({}, t), { timestamp: Be() });
}
let G,
ot,
Rt,
st = !1;
const ae = jt();
function Ce(t = {}) {
const {
emit: e,
checkoutEveryNms: r,
checkoutEveryNth: n,
blockClass: o = "rr-block",
blockSelector: a = null,
ignoreClass: i = "rr-ignore",
ignoreSelector: l = null,
maskTextClass: s = "rr-mask",
maskTextSelector: c = null,
inlineStylesheet: u = !0,
maskAllInputs: d,
maskInputOptions: h,
slimDOMOptions: m,
maskInputFn: p,
maskTextFn: v,
hooks: b,
packFn: f,
sampling: y = {},
dataURLOptions: g = {},
mousemoveWait: C,
recordCanvas: M = !1,
recordCrossOriginIframes: R = !1,
recordAfter: _ = t.recordAfter === "DOMContentLoaded"
? t.recordAfter
: "load",
userTriggeredOnInput: P = !1,
collectFonts: Z = !1,
inlineImages: K = !1,
plugins: Y,
keepIframeSrcFn: J = () => !1,
ignoreCSSAttributes: Q = new Set([]),
errorHandler: ie,
} = t;
Qn(ie);
const U = R ? window.parent === window : !0;
let j = !1;
if (!U)
try {
window.parent.document && (j = !1);
} catch {
j = !0;
}
if (U && !e) throw new Error("emit function is required");
C !== void 0 && y.mousemove === void 0 && (y.mousemove = C), ae.reset();
const F =
d === !0
? {
color: !0,
date: !0,
"datetime-local": !0,
email: !0,
month: !0,
number: !0,
range: !0,
search: !0,
tel: !0,
text: !0,
time: !0,
url: !0,
week: !0,
textarea: !0,
select: !0,
password: !0,
}
: h !== void 0
? h
: { password: !0 },
q =
m === !0 || m === "all"
? {
script: !0,
comment: !0,
headFavicon: !0,
headWhitespace: !0,
headMetaSocial: !0,
headMetaRobots: !0,
headMetaHttpEquiv: !0,
headMetaVerification: !0,
headMetaAuthorship: m === "all",
headMetaDescKeywords: m === "all",
}
: m || {};
bt();
let w,
S = 0;
const D = (k) => {
for (const ne of Y || []) ne.eventProcessor && (k = ne.eventProcessor(k));
return f && !j && (k = f(k)), k;
};
G = (k, ne) => {
var W;
if (
(((W = we[0]) == null ? void 0 : W.isFrozen()) &&
k.type !== T.FullSnapshot &&
!(k.type === T.IncrementalSnapshot && k.data.source === E.Mutation) &&
we.forEach((X) => X.unfreeze()),
U)
)
e?.(D(k), ne);
else if (j) {
const X = {
type: "rrweb",
event: D(k),
origin: window.location.origin,
isCheckout: ne,
};
window.parent.postMessage(X, "*");
}
if (k.type === T.FullSnapshot) (w = k), (S = 0);
else if (k.type === T.IncrementalSnapshot) {
if (k.data.source === E.Mutation && k.data.isAttachIframe) return;
S++;
const X = n && S >= n,
Fe = r && k.timestamp - w.timestamp > r;
(X || Fe) && ot(!0);
}
};
const I = (k) => {
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.Mutation }, k),
})
);
},
H = (k) =>
G(
z({ type: T.IncrementalSnapshot, data: oe({ source: E.Scroll }, k) })
),
de = (k) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.CanvasMutation }, k),
})
),
ut = (k) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.AdoptedStyleSheet }, k),
})
),
le = new Vo({ mutationCb: I, adoptedStyleSheetCb: ut }),
he = new So({
mirror: ae,
mutationCb: I,
stylesheetManager: le,
recordCrossOriginIframes: R,
wrappedEmit: G,
});
for (const k of Y || [])
k.getMirror &&
k.getMirror({
nodeMirror: ae,
crossOriginIframeMirror: he.crossOriginIframeMirror,
crossOriginIframeStyleMirror: he.crossOriginIframeStyleMirror,
});
const Ee = new Bo();
Rt = new Uo({
recordCanvas: M,
mutationCb: de,
win: window,
blockClass: o,
blockSelector: a,
mirror: ae,
sampling: y.canvas,
dataURLOptions: g,
});
const ce = new No({
mutationCb: I,
scrollCb: H,
bypassOptions: {
blockClass: o,
blockSelector: a,
maskTextClass: s,
maskTextSelector: c,
inlineStylesheet: u,
maskInputOptions: F,
dataURLOptions: g,
maskTextFn: v,
maskInputFn: p,
recordCanvas: M,
inlineImages: K,
sampling: y,
slimDOMOptions: q,
iframeManager: he,
stylesheetManager: le,
canvasManager: Rt,
keepIframeSrcFn: J,
processedNodeManager: Ee,
},
mirror: ae,
});
ot = (k = !1) => {
G(
z({
type: T.Meta,
data: { href: window.location.href, width: vt(), height: gt() },
}),
k
),
le.reset(),
ce.init(),
we.forEach((W) => W.lock());
const ne = Un(document, {
mirror: ae,
blockClass: o,
blockSelector: a,
maskTextClass: s,
maskTextSelector: c,
inlineStylesheet: u,
maskAllInputs: F,
maskTextFn: v,
slimDOM: q,
dataURLOptions: g,
recordCanvas: M,
inlineImages: K,
onSerialize: (W) => {
ke(W, ae) && he.addIframe(W),
Ct(W, ae) && le.trackLinkElement(W),
ve(W) && ce.addShadowRoot(W.shadowRoot, document);
},
onIframeLoad: (W, X) => {
he.attachIframe(W, X), ce.observeAttachShadow(W);
},
onStylesheetLoad: (W, X) => {
le.attachLinkElement(W, X);
},
keepIframeSrcFn: J,
});
if (!ne) return console.warn("Failed to snapshot the document");
G(
z({
type: T.FullSnapshot,
data: { node: ne, initialOffset: yt(window) },
}),
k
),
we.forEach((W) => W.unlock()),
document.adoptedStyleSheets &&
document.adoptedStyleSheets.length > 0 &&
le.adoptStyleSheets(document.adoptedStyleSheets, ae.getId(document));
};
try {
const k = [],
ne = (X) => {
var Fe;
return x(vo)(
{
mutationCb: I,
mousemoveCb: (V, Vt) =>
G(
z({
type: T.IncrementalSnapshot,
data: { source: Vt, positions: V },
})
),
mouseInteractionCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.MouseInteraction }, V),
})
),
scrollCb: H,
viewportResizeCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.ViewportResize }, V),
})
),
inputCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.Input }, V),
})
),
mediaInteractionCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.MediaInteraction }, V),
})
),
styleSheetRuleCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.StyleSheetRule }, V),
})
),
styleDeclarationCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.StyleDeclaration }, V),
})
),
canvasMutationCb: de,
fontCb: (V) =>
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.Font }, V),
})
),
selectionCb: (V) => {
G(
z({
type: T.IncrementalSnapshot,
data: oe({ source: E.Selection }, V),
})
);
},
blockClass: o,
ignoreClass: i,
ignoreSelector: l,
maskTextClass: s,
maskTextSelector: c,
maskInputOptions: F,
inlineStylesheet: u,
sampling: y,
recordCanvas: M,
inlineImages: K,
userTriggeredOnInput: P,
collectFonts: Z,
doc: X,
maskInputFn: p,
maskTextFn: v,
keepIframeSrcFn: J,
blockSelector: a,
slimDOMOptions: q,
dataURLOptions: g,
mirror: ae,
iframeManager: he,
stylesheetManager: le,
shadowDomManager: ce,
processedNodeManager: Ee,
canvasManager: Rt,
ignoreCSSAttributes: Q,
plugins:
((Fe = Y?.filter((V) => V.observer)) == null
? void 0
: Fe.map((V) => ({
observer: V.observer,
options: V.options,
callback: (Vt) =>
G(
z({
type: T.Plugin,
data: { plugin: V.name, payload: Vt },
})
),
}))) || [],
},
b
);
};
he.addLoadListener((X) => {
try {
k.push(ne(X.contentDocument));
} catch (Fe) {
console.warn(Fe);
}
});
const W = () => {
ot(), k.push(ne(document)), (st = !0);
};
return (
document.readyState === "interactive" ||
document.readyState === "complete"
? W()
: (k.push(
ee("DOMContentLoaded", () => {
G(z({ type: T.DomContentLoaded, data: {} })),
_ === "DOMContentLoaded" && W();
})
),
k.push(
ee(
"load",
() => {
G(z({ type: T.Load, data: {} })), _ === "load" && W();
},
window
)
)),
() => {
k.forEach((X) => X()), Ee.destroy(), (st = !1), qn();
}
);
} catch (k) {
console.warn(k);
}
}
(Ce.addCustomEvent = (t, e) => {
if (!st) throw new Error("please add custom event after start recording");
G(z({ type: T.Custom, data: { tag: t, payload: e } }));
}),
(Ce.freezePage = () => {
we.forEach((t) => t.freeze());
}),
(Ce.takeFullSnapshot = (t) => {
if (!st)
throw new Error("please take full snapshot after start recording");
ot(t);
}),
(Ce.mirror = ae);
var O;
(function (t) {
(t[(t.Document = 0)] = "Document"),
(t[(t.DocumentType = 1)] = "DocumentType"),
(t[(t.Element = 2)] = "Element"),
(t[(t.Text = 3)] = "Text"),
(t[(t.CDATA = 4)] = "CDATA"),
(t[(t.Comment = 5)] = "Comment");
})(O || (O = {}));
var Zo = (function () {
function t() {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}
return (
(t.prototype.getId = function (e) {
var r;
if (!e) return -1;
var n = (r = this.getMeta(e)) === null || r === void 0 ? void 0 : r.id;
return n ?? -1;
}),
(t.prototype.getNode = function (e) {
return this.idNodeMap.get(e) || null;
}),
(t.prototype.getIds = function () {
return Array.from(this.idNodeMap.keys());
}),
(t.prototype.getMeta = function (e) {
return this.nodeMetaMap.get(e) || null;
}),
(t.prototype.removeNodeFromMap = function (e) {
var r = this,
n = this.getId(e);
this.idNodeMap.delete(n),
e.childNodes &&
e.childNodes.forEach(function (o) {
return r.removeNodeFromMap(o);
});
}),
(t.prototype.has = function (e) {
return this.idNodeMap.has(e);
}),
(t.prototype.hasNode = function (e) {
return this.nodeMetaMap.has(e);
}),
(t.prototype.add = function (e, r) {
var n = r.id;
this.idNodeMap.set(n, e), this.nodeMetaMap.set(e, r);
}),
(t.prototype.replace = function (e, r) {
var n = this.getNode(e);
if (n) {
var o = this.nodeMetaMap.get(n);
o && this.nodeMetaMap.set(r, o);
}
this.idNodeMap.set(e, r);
}),
(t.prototype.reset = function () {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}),
t
);
})();
function Ko() {
return new Zo();
}
function Jo(t) {
const e = {},
r = /;(?![^(]*\))/g,
n = /:(.+)/,
o = /\/\*.*?\*\//g;
return (
t
.replace(o, "")
.split(r)
.forEach(function (a) {
if (a) {
const i = a.split(n);
i.length > 1 && (e[xt(i[0].trim())] = i[1].trim());
}
}),
e
);
}
function Ar(t) {
const e = [];
for (const r in t) {
const n = t[r];
if (typeof n != "string") continue;
const o = ts(r);
e.push(`${o}: ${n};`);
}
return e.join(" ");
}
const Qo = /-([a-z])/g,
qo = /^--[a-zA-Z0-9-]+$/,
xt = (t) =>
qo.test(t) ? t : t.replace(Qo, (e, r) => (r ? r.toUpperCase() : "")),
es = /\B([A-Z])/g,
ts = (t) => t.replace(es, "-$1").toLowerCase();
class se {
constructor(...e) {
(this.parentElement = null),
(this.parentNode = null),
(this.firstChild = null),
(this.lastChild = null),
(this.previousSibling = null),
(this.nextSibling = null),
(this.ELEMENT_NODE = B.ELEMENT_NODE),
(this.TEXT_NODE = B.TEXT_NODE);
}
get childNodes() {
const e = [];
let r = this.firstChild;
for (; r; ) e.push(r), (r = r.nextSibling);
return e;
}
contains(e) {
if (e instanceof se) {
if (e.ownerDocument !== this.ownerDocument) return !1;
if (e === this) return !0;
} else return !1;
for (; e.parentNode; ) {
if (e.parentNode === this) return !0;
e = e.parentNode;
}
return !1;
}
appendChild(e) {
throw new Error(
"RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method."
);
}
insertBefore(e, r) {
throw new Error(
"RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method."
);
}
removeChild(e) {
throw new Error(
"RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method."
);
}
toString() {
return "RRNode";
}
}
function rs(t) {
return class pn extends t {
constructor(...r) {
super(r),
(this.nodeType = B.DOCUMENT_NODE),
(this.nodeName = "#document"),
(this.compatMode = "CSS1Compat"),
(this.RRNodeType = O.Document),
(this.textContent = null),
(this.ownerDocument = this);
}
get documentElement() {
return (
this.childNodes.find(
(r) => r.RRNodeType === O.Element && r.tagName === "HTML"
) || null
);
}
get body() {
var r;
return (
((r = this.documentElement) === null || r === void 0
? void 0
: r.childNodes.find(
(n) => n.RRNodeType === O.Element && n.tagName === "BODY"
)) || null
);
}
get head() {
var r;
return (
((r = this.documentElement) === null || r === void 0
? void 0
: r.childNodes.find(
(n) => n.RRNodeType === O.Element && n.tagName === "HEAD"
)) || null
);
}
get implementation() {
return this;
}
get firstElementChild() {
return this.documentElement;
}
appendChild(r) {
const n = r.RRNodeType;
if (
(n === O.Element || n === O.DocumentType) &&
this.childNodes.some((a) => a.RRNodeType === n)
)
throw new Error(
`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${
n === O.Element ? "RRElement" : "RRDoctype"
} on RRDocument allowed.`
);
const o = Ot(this, r);
return (o.parentElement = null), o;
}
insertBefore(r, n) {
const o = r.RRNodeType;
if (
(o === O.Element || o === O.DocumentType) &&
this.childNodes.some((i) => i.RRNodeType === o)
)
throw new Error(
`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${
o === O.Element ? "RRElement" : "RRDoctype"
} on RRDocument allowed.`
);
const a = Ur(this, r, n);
return (a.parentElement = null), a;
}
removeChild(r) {
return Vr(this, r);
}
open() {
(this.firstChild = null), (this.lastChild = null);
}
close() {}
write(r) {
let n;
if (
(r ===
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
? (n = "-//W3C//DTD XHTML 1.0 Transitional//EN")
: r ===
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">' &&
(n = "-//W3C//DTD HTML 4.0 Transitional//EN"),
n)
) {
const o = this.createDocumentType("html", n, "");
this.open(), this.appendChild(o);
}
}
createDocument(r, n, o) {
return new pn();
}
createDocumentType(r, n, o) {
const a = new (_r(se))(r, n, o);
return (a.ownerDocument = this), a;
}
createElement(r) {
const n = new (Fr(se))(r);
return (n.ownerDocument = this), n;
}
createElementNS(r, n) {
return this.createElement(n);
}
createTextNode(r) {
const n = new (Pr(se))(r);
return (n.ownerDocument = this), n;
}
createComment(r) {
const n = new (Wr(se))(r);
return (n.ownerDocument = this), n;
}
createCDATASection(r) {
const n = new ($r(se))(r);
return (n.ownerDocument = this), n;
}
toString() {
return "RRDocument";
}
};
}
function _r(t) {
return class extends t {
constructor(e, r, n) {
super(),
(this.nodeType = B.DOCUMENT_TYPE_NODE),
(this.RRNodeType = O.DocumentType),
(this.name = e),
(this.publicId = r),
(this.systemId = n),
(this.nodeName = e),
(this.textContent = null);
}
toString() {
return "RRDocumentType";
}
};
}
function Fr(t) {
return class extends t {
constructor(e) {
super(),
(this.nodeType = B.ELEMENT_NODE),
(this.RRNodeType = O.Element),
(this.attributes = {}),
(this.shadowRoot = null),
(this.tagName = e.toUpperCase()),
(this.nodeName = e.toUpperCase());
}
get textContent() {
let e = "";
return this.childNodes.forEach((r) => (e += r.textContent)), e;
}
set textContent(e) {
(this.firstChild = null),
(this.lastChild = null),
this.appendChild(this.ownerDocument.createTextNode(e));
}
get classList() {
return new os(this.attributes.class, (e) => {
this.attributes.class = e;
});
}
get id() {
return this.attributes.id || "";
}
get className() {
return this.attributes.class || "";
}
get style() {
const e = this.attributes.style ? Jo(this.attributes.style) : {},
r = /\B([A-Z])/g;
return (
(e.setProperty = (n, o, a) => {
if (r.test(n)) return;
const i = xt(n);
o ? (e[i] = o) : delete e[i],
a === "important" && (e[i] += " !important"),
(this.attributes.style = Ar(e));
}),
(e.removeProperty = (n) => {
if (r.test(n)) return "";
const o = xt(n),
a = e[o] || "";
return delete e[o], (this.attributes.style = Ar(e)), a;
}),
e
);
}
getAttribute(e) {
return this.attributes[e] || null;
}
setAttribute(e, r) {
this.attributes[e] = r;
}
setAttributeNS(e, r, n) {
this.setAttribute(r, n);
}
removeAttribute(e) {
delete this.attributes[e];
}
appendChild(e) {
return Ot(this, e);
}
insertBefore(e, r) {
return Ur(this, e, r);
}
removeChild(e) {
return Vr(this, e);
}
attachShadow(e) {
const r = this.ownerDocument.createElement("SHADOWROOT");
return (this.shadowRoot = r), r;
}
dispatchEvent(e) {
return !0;
}
toString() {
let e = "";
for (const r in this.attributes) e += `${r}="${this.attributes[r]}" `;
return `${this.tagName} ${e}`;
}
};
}
function ns(t) {
return class extends t {
attachShadow(e) {
throw new Error(
"RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow"
);
}
play() {
this.paused = !1;
}
pause() {
this.paused = !0;
}
};
}
function Pr(t) {
return class extends t {
constructor(e) {
super(),
(this.nodeType = B.TEXT_NODE),
(this.nodeName = "#text"),
(this.RRNodeType = O.Text),
(this.data = e);
}
get textContent() {
return this.data;
}
set textContent(e) {
this.data = e;
}
toString() {
return `RRText text=${JSON.stringify(this.data)}`;
}
};
}
function Wr(t) {
return class extends t {
constructor(e) {
super(),
(this.nodeType = B.COMMENT_NODE),
(this.nodeName = "#comment"),
(this.RRNodeType = O.Comment),
(this.data = e);
}
get textContent() {
return this.data;
}
set textContent(e) {
this.data = e;
}
toString() {
return `RRComment text=${JSON.stringify(this.data)}`;
}
};
}
function $r(t) {
return class extends t {
constructor(e) {
super(),
(this.nodeName = "#cdata-section"),
(this.nodeType = B.CDATA_SECTION_NODE),
(this.RRNodeType = O.CDATA),
(this.data = e);
}
get textContent() {
return this.data;
}
set textContent(e) {
this.data = e;
}
toString() {
return `RRCDATASection data=${JSON.stringify(this.data)}`;
}
};
}
class os {
constructor(e, r) {
if (
((this.classes = []),
(this.add = (...n) => {
for (const o of n) {
const a = String(o);
this.classes.indexOf(a) >= 0 || this.classes.push(a);
}
this.onChange && this.onChange(this.classes.join(" "));
}),
(this.remove = (...n) => {
(this.classes = this.classes.filter((o) => n.indexOf(o) === -1)),
this.onChange && this.onChange(this.classes.join(" "));
}),
e)
) {
const n = e.trim().split(/\s+/);
this.classes.push(...n);
}
this.onChange = r;
}
}
function Ot(t, e) {
return (
e.parentNode && e.parentNode.removeChild(e),
t.lastChild
? ((t.lastChild.nextSibling = e), (e.previousSibling = t.lastChild))
: ((t.firstChild = e), (e.previousSibling = null)),
(t.lastChild = e),
(e.nextSibling = null),
(e.parentNode = t),
(e.parentElement = t),
(e.ownerDocument = t.ownerDocument),
e
);
}
function Ur(t, e, r) {
if (!r) return Ot(t, e);
if (r.parentNode !== t)
throw new Error(
"Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."
);
return (
e === r ||
(e.parentNode && e.parentNode.removeChild(e),
(e.previousSibling = r.previousSibling),
(r.previousSibling = e),
(e.nextSibling = r),
e.previousSibling
? (e.previousSibling.nextSibling = e)
: (t.firstChild = e),
(e.parentElement = t),
(e.parentNode = t),
(e.ownerDocument = t.ownerDocument)),
e
);
}
function Vr(t, e) {
if (e.parentNode !== t)
throw new Error(
"Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode."
);
return (
e.previousSibling
? (e.previousSibling.nextSibling = e.nextSibling)
: (t.firstChild = e.nextSibling),
e.nextSibling
? (e.nextSibling.previousSibling = e.previousSibling)
: (t.lastChild = e.previousSibling),
(e.previousSibling = null),
(e.nextSibling = null),
(e.parentElement = null),
(e.parentNode = null),
e
);
}
var B;
(function (t) {
(t[(t.PLACEHOLDER = 0)] = "PLACEHOLDER"),
(t[(t.ELEMENT_NODE = 1)] = "ELEMENT_NODE"),
(t[(t.ATTRIBUTE_NODE = 2)] = "ATTRIBUTE_NODE"),
(t[(t.TEXT_NODE = 3)] = "TEXT_NODE"),
(t[(t.CDATA_SECTION_NODE = 4)] = "CDATA_SECTION_NODE"),
(t[(t.ENTITY_REFERENCE_NODE = 5)] = "ENTITY_REFERENCE_NODE"),
(t[(t.ENTITY_NODE = 6)] = "ENTITY_NODE"),
(t[(t.PROCESSING_INSTRUCTION_NODE = 7)] = "PROCESSING_INSTRUCTION_NODE"),
(t[(t.COMMENT_NODE = 8)] = "COMMENT_NODE"),
(t[(t.DOCUMENT_NODE = 9)] = "DOCUMENT_NODE"),
(t[(t.DOCUMENT_TYPE_NODE = 10)] = "DOCUMENT_TYPE_NODE"),
(t[(t.DOCUMENT_FRAGMENT_NODE = 11)] = "DOCUMENT_FRAGMENT_NODE");
})(B || (B = {}));
const Lt = {
svg: "http://www.w3.org/2000/svg",
"xlink:href": "http://www.w3.org/1999/xlink",
xmlns: "http://www.w3.org/2000/xmlns/",
},
ss = {
altglyph: "altGlyph",
altglyphdef: "altGlyphDef",
altglyphitem: "altGlyphItem",
animatecolor: "animateColor",
animatemotion: "animateMotion",
animatetransform: "animateTransform",
clippath: "clipPath",
feblend: "feBlend",
fecolormatrix: "feColorMatrix",
fecomponenttransfer: "feComponentTransfer",
fecomposite: "feComposite",
feconvolvematrix: "feConvolveMatrix",
fediffuselighting: "feDiffuseLighting",
fedisplacementmap: "feDisplacementMap",
fedistantlight: "feDistantLight",
fedropshadow: "feDropShadow",
feflood: "feFlood",
fefunca: "feFuncA",
fefuncb: "feFuncB",
fefuncg: "feFuncG",
fefuncr: "feFuncR",
fegaussianblur: "feGaussianBlur",
feimage: "feImage",
femerge: "feMerge",
femergenode: "feMergeNode",
femorphology: "feMorphology",
feoffset: "feOffset",
fepointlight: "fePointLight",
fespecularlighting: "feSpecularLighting",
fespotlight: "feSpotLight",
fetile: "feTile",
feturbulence: "feTurbulence",
foreignobject: "foreignObject",
glyphref: "glyphRef",
lineargradient: "linearGradient",
radialgradient: "radialGradient",
};
let ue = null;
function it(t, e, r, n = e.mirror || e.ownerDocument.mirror) {
(t = is(t, e, r, n)), Br(t, e, r, n), as(t, e, r, n);
}
function is(t, e, r, n) {
var o;
if (
(r.afterAppend &&
!ue &&
((ue = new WeakSet()),
setTimeout(() => {
ue = null;
}, 0)),
!At(t, e))
) {
const a = at(e, r.mirror, n);
(o = t.parentNode) === null || o === void 0 || o.replaceChild(a, t),
(t = a);
}
switch (e.RRNodeType) {
case O.Document: {
if (!Oe(t, e, r.mirror, n)) {
const a = n.getMeta(e);
a &&
(r.mirror.removeNodeFromMap(t),
t.close(),
t.open(),
r.mirror.add(t, a),
ue?.add(t));
}
break;
}
case O.Element: {
const a = t,
i = e;
switch (i.tagName) {
case "IFRAME": {
const l = t.contentDocument;
if (!l) break;
it(l, e.contentDocument, r, n);
break;
}
}
i.shadowRoot &&
(a.shadowRoot || a.attachShadow({ mode: "open" }),
Br(a.shadowRoot, i.shadowRoot, r, n));
break;
}
}
return t;
}
function as(t, e, r, n) {
var o;
switch (e.RRNodeType) {
case O.Document: {
const a = e.scrollData;
a && r.applyScroll(a, !0);
break;
}
case O.Element: {
const a = t,
i = e;
switch (
(ls(a, i, n),
i.scrollData && r.applyScroll(i.scrollData, !0),
i.inputData && r.applyInput(i.inputData),
i.tagName)
) {
case "AUDIO":
case "VIDEO": {
const l = t,
s = i;
s.paused !== void 0 && (s.paused ? l.pause() : l.play()),
s.muted !== void 0 && (l.muted = s.muted),
s.volume !== void 0 && (l.volume = s.volume),
s.currentTime !== void 0 && (l.currentTime = s.currentTime),
s.playbackRate !== void 0 && (l.playbackRate = s.playbackRate);
break;
}
case "CANVAS": {
const l = e;
if (l.rr_dataURL !== null) {
const s = document.createElement("img");
(s.onload = () => {
const c = a.getContext("2d");
c && c.drawImage(s, 0, 0, s.width, s.height);
}),
(s.src = l.rr_dataURL);
}
l.canvasMutations.forEach((s) =>
r.applyCanvas(s.event, s.mutation, t)
);
break;
}
case "STYLE": {
const l = a.sheet;
l && e.rules.forEach((s) => r.applyStyleSheetMutation(s, l));
break;
}
}
break;
}
case O.Text:
case O.Comment:
case O.CDATA: {
t.textContent !== e.data && (t.textContent = e.data);
break;
}
}
ue != null &&
ue.has(t) &&
(ue.delete(t),
(o = r.afterAppend) === null ||
o === void 0 ||
o.call(r, t, r.mirror.getId(t)));
}
function ls(t, e, r) {
const n = t.attributes,
o = e.attributes;
for (const a in o) {
const i = o[a],
l = r.getMeta(e);
if (l?.isSVG && Lt[a]) t.setAttributeNS(Lt[a], a, i);
else if (e.tagName === "CANVAS" && a === "rr_dataURL") {
const s = document.createElement("img");
(s.src = i),
(s.onload = () => {
const c = t.getContext("2d");
c && c.drawImage(s, 0, 0, s.width, s.height);
});
} else {
if (e.tagName === "IFRAME" && a === "srcdoc") continue;
t.setAttribute(a, i);
}
}
for (const { name: a } of Array.from(n)) a in o || t.removeAttribute(a);
e.scrollLeft && (t.scrollLeft = e.scrollLeft),
e.scrollTop && (t.scrollTop = e.scrollTop);
}
function Br(t, e, r, n) {
const o = Array.from(t.childNodes),
a = e.childNodes;
if (o.length === 0 && a.length === 0) return;
let i = 0,
l = o.length - 1,
s = 0,
c = a.length - 1,
u = o[i],
d = o[l],
h = a[s],
m = a[c],
p,
v;
for (; i <= l && s <= c; )
if (u === void 0) u = o[++i];
else if (d === void 0) d = o[--l];
else if (Oe(u, h, r.mirror, n)) (u = o[++i]), (h = a[++s]);
else if (Oe(d, m, r.mirror, n)) (d = o[--l]), (m = a[--c]);
else if (Oe(u, m, r.mirror, n)) {
try {
t.insertBefore(u, d.nextSibling);
} catch (y) {
console.warn(y);
}
(u = o[++i]), (m = a[--c]);
} else if (Oe(d, h, r.mirror, n)) {
try {
t.insertBefore(d, u);
} catch (y) {
console.warn(y);
}
(d = o[--l]), (h = a[++s]);
} else {
if (!p) {
p = {};
for (let g = i; g <= l; g++) {
const C = o[g];
C && r.mirror.hasNode(C) && (p[r.mirror.getId(C)] = g);
}
}
v = p[n.getId(h)];
const y = o[v];
if (v !== void 0 && y && Oe(y, h, r.mirror, n)) {
try {
t.insertBefore(y, u);
} catch (g) {
console.warn(g);
}
o[v] = void 0;
} else {
const g = at(h, r.mirror, n);
t.nodeName === "#document" &&
u &&
((g.nodeType === g.DOCUMENT_TYPE_NODE &&
u.nodeType === u.DOCUMENT_TYPE_NODE) ||
(g.nodeType === g.ELEMENT_NODE &&
u.nodeType === u.ELEMENT_NODE)) &&
(t.removeChild(u), r.mirror.removeNodeFromMap(u), (u = o[++i]));
try {
t.insertBefore(g, u || null);
} catch (C) {
console.warn(C);
}
}
h = a[++s];
}
if (i > l) {
const y = a[c + 1];
let g = null;
for (y && (g = r.mirror.getNode(n.getId(y))); s <= c; ++s) {
const C = at(a[s], r.mirror, n);
try {
t.insertBefore(C, g);
} catch (M) {
console.warn(M);
}
}
} else if (s > c)
for (; i <= l; i++) {
const y = o[i];
if (!(!y || y.parentNode !== t))
try {
t.removeChild(y), r.mirror.removeNodeFromMap(y);
} catch (g) {
console.warn(g);
}
}
let b = t.firstChild,
f = e.firstChild;
for (; b !== null && f !== null; )
it(b, f, r, n), (b = b.nextSibling), (f = f.nextSibling);
}
function at(t, e, r) {
const n = r.getId(t),
o = r.getMeta(t);
let a = null;
if ((n > -1 && (a = e.getNode(n)), a !== null && At(a, t))) return a;
switch (t.RRNodeType) {
case O.Document:
a = new Document();
break;
case O.DocumentType:
a = document.implementation.createDocumentType(
t.name,
t.publicId,
t.systemId
);
break;
case O.Element: {
let i = t.tagName.toLowerCase();
(i = ss[i] || i),
o && "isSVG" in o && o?.isSVG
? (a = document.createElementNS(Lt.svg, i))
: (a = document.createElement(t.tagName));
break;
}
case O.Text:
a = document.createTextNode(t.data);
break;
case O.Comment:
a = document.createComment(t.data);
break;
case O.CDATA:
a = document.createCDATASection(t.data);
break;
}
o && e.add(a, Object.assign({}, o));
try {
ue?.add(a);
} catch {}
return a;
}
function At(t, e) {
return t.nodeType !== e.nodeType
? !1
: t.nodeType !== t.ELEMENT_NODE || t.tagName.toUpperCase() === e.tagName;
}
function Oe(t, e, r, n) {
const o = r.getId(t),
a = n.getId(e);
return o === -1 || o !== a ? !1 : At(t, e);
}
class Le extends rs(se) {
get unserializedId() {
return this._unserializedId--;
}
constructor(e) {
super(),
(this.UNSERIALIZED_STARTING_ID = -2),
(this._unserializedId = this.UNSERIALIZED_STARTING_ID),
(this.mirror = Ss()),
(this.scrollData = null),
e && (this.mirror = e);
}
createDocument(e, r, n) {
return new Le();
}
createDocumentType(e, r, n) {
const o = new cs(e, r, n);
return (o.ownerDocument = this), o;
}
createElement(e) {
const r = e.toUpperCase();
let n;
switch (r) {
case "AUDIO":
case "VIDEO":
n = new us(r);
break;
case "IFRAME":
n = new ps(r, this.mirror);
break;
case "CANVAS":
n = new ds(r);
break;
case "STYLE":
n = new hs(r);
break;
default:
n = new He(r);
break;
}
return (n.ownerDocument = this), n;
}
createComment(e) {
const r = new fs(e);
return (r.ownerDocument = this), r;
}
createCDATASection(e) {
const r = new ys(e);
return (r.ownerDocument = this), r;
}
createTextNode(e) {
const r = new ms(e);
return (r.ownerDocument = this), r;
}
destroyTree() {
(this.firstChild = null), (this.lastChild = null), this.mirror.reset();
}
open() {
super.open(), (this._unserializedId = this.UNSERIALIZED_STARTING_ID);
}
}
const cs = _r(se);
class He extends Fr(se) {
constructor() {
super(...arguments), (this.inputData = null), (this.scrollData = null);
}
}
class us extends ns(He) {}
class ds extends He {
constructor() {
super(...arguments),
(this.rr_dataURL = null),
(this.canvasMutations = []);
}
getContext() {
return null;
}
}
class hs extends He {
constructor() {
super(...arguments), (this.rules = []);
}
}
class ps extends He {
constructor(e, r) {
super(e),
(this.contentDocument = new Le()),
(this.contentDocument.mirror = r);
}
}
const ms = Pr(se),
fs = Wr(se),
ys = $r(se);
function gs(t) {
return t instanceof HTMLFormElement ? "FORM" : t.tagName.toUpperCase();
}
function Gr(t, e, r, n) {
let o;
switch (t.nodeType) {
case B.DOCUMENT_NODE:
n && n.nodeName === "IFRAME"
? (o = n.contentDocument)
: ((o = e), (o.compatMode = t.compatMode));
break;
case B.DOCUMENT_TYPE_NODE: {
const i = t;
o = e.createDocumentType(i.name, i.publicId, i.systemId);
break;
}
case B.ELEMENT_NODE: {
const i = t,
l = gs(i);
o = e.createElement(l);
const s = o;
for (const { name: c, value: u } of Array.from(i.attributes))
s.attributes[c] = u;
i.scrollLeft && (s.scrollLeft = i.scrollLeft),
i.scrollTop && (s.scrollTop = i.scrollTop);
break;
}
case B.TEXT_NODE:
o = e.createTextNode(t.textContent || "");
break;
case B.CDATA_SECTION_NODE:
o = e.createCDATASection(t.data);
break;
case B.COMMENT_NODE:
o = e.createComment(t.textContent || "");
break;
case B.DOCUMENT_FRAGMENT_NODE:
o = n.attachShadow({ mode: "open" });
break;
default:
return null;
}
let a = r.getMeta(t);
return (
e instanceof Le &&
(a || ((a = jr(o, e.unserializedId)), r.add(t, a)),
e.mirror.add(o, Object.assign({}, a))),
o
);
}
function vs(t, e = Ko(), r = new Le()) {
function n(o, a) {
const i = Gr(o, r, e, a);
if (i !== null)
if (
(a?.nodeName !== "IFRAME" &&
o.nodeType !== B.DOCUMENT_FRAGMENT_NODE &&
(a?.appendChild(i), (i.parentNode = a), (i.parentElement = a)),
o.nodeName === "IFRAME")
) {
const l = o.contentDocument;
l && n(l, i);
} else
(o.nodeType === B.DOCUMENT_NODE ||
o.nodeType === B.ELEMENT_NODE ||
o.nodeType === B.DOCUMENT_FRAGMENT_NODE) &&
(o.nodeType === B.ELEMENT_NODE &&
o.shadowRoot &&
n(o.shadowRoot, i),
o.childNodes.forEach((l) => n(l, i)));
}
return n(t, null), r;
}
function Ss() {
return new bs();
}
class bs {
constructor() {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}
getId(e) {
var r;
if (!e) return -1;
const n = (r = this.getMeta(e)) === null || r === void 0 ? void 0 : r.id;
return n ?? -1;
}
getNode(e) {
return this.idNodeMap.get(e) || null;
}
getIds() {
return Array.from(this.idNodeMap.keys());
}
getMeta(e) {
return this.nodeMetaMap.get(e) || null;
}
removeNodeFromMap(e) {
const r = this.getId(e);
this.idNodeMap.delete(r),
e.childNodes && e.childNodes.forEach((n) => this.removeNodeFromMap(n));
}
has(e) {
return this.idNodeMap.has(e);
}
hasNode(e) {
return this.nodeMetaMap.has(e);
}
add(e, r) {
const n = r.id;
this.idNodeMap.set(n, e), this.nodeMetaMap.set(e, r);
}
replace(e, r) {
const n = this.getNode(e);
if (n) {
const o = this.nodeMetaMap.get(n);
o && this.nodeMetaMap.set(r, o);
}
this.idNodeMap.set(e, r);
}
reset() {
(this.idNodeMap = new Map()), (this.nodeMetaMap = new WeakMap());
}
}
function jr(t, e) {
switch (t.RRNodeType) {
case O.Document:
return { id: e, type: t.RRNodeType, childNodes: [] };
case O.DocumentType: {
const r = t;
return {
id: e,
type: t.RRNodeType,
name: r.name,
publicId: r.publicId,
systemId: r.systemId,
};
}
case O.Element:
return {
id: e,
type: t.RRNodeType,
tagName: t.tagName.toLowerCase(),
attributes: {},
childNodes: [],
};
case O.Text:
return { id: e, type: t.RRNodeType, textContent: t.textContent || "" };
case O.Comment:
return { id: e, type: t.RRNodeType, textContent: t.textContent || "" };
case O.CDATA:
return { id: e, type: t.RRNodeType, textContent: "" };
}
}
function zr(t) {
return {
all: (t = t || new Map()),
on: function (e, r) {
var n = t.get(e);
n ? n.push(r) : t.set(e, [r]);
},
off: function (e, r) {
var n = t.get(e);
n && (r ? n.splice(n.indexOf(r) >>> 0, 1) : t.set(e, []));
},
emit: function (e, r) {
var n = t.get(e);
n &&
n.slice().map(function (o) {
o(r);
}),
(n = t.get("*")) &&
n.slice().map(function (o) {
o(e, r);
});
},
};
}
var ws = Object.freeze({ __proto__: null, default: zr });
function Cs(t = window, e = document) {
if (
"scrollBehavior" in e.documentElement.style &&
t.__forceSmoothScrollPolyfill__ !== !0
)
return;
const r = t.HTMLElement || t.Element,
n = 468,
o = {
scroll: t.scroll || t.scrollTo,
scrollBy: t.scrollBy,
elementScroll: r.prototype.scroll || s,
scrollIntoView: r.prototype.scrollIntoView,
},
a =
t.performance && t.performance.now
? t.performance.now.bind(t.performance)
: Date.now;
function i(f) {
const y = ["MSIE ", "Trident/", "Edge/"];
return new RegExp(y.join("|")).test(f);
}
const l = i(t.navigator.userAgent) ? 1 : 0;
function s(f, y) {
(this.scrollLeft = f), (this.scrollTop = y);
}
function c(f) {
return 0.5 * (1 - Math.cos(Math.PI * f));
}
function u(f) {
if (
f === null ||
typeof f != "object" ||
f.behavior === void 0 ||
f.behavior === "auto" ||
f.behavior === "instant"
)
return !0;
if (typeof f == "object" && f.behavior === "smooth") return !1;
throw new TypeError(
"behavior member of ScrollOptions " +
f.behavior +
" is not a valid value for enumeration ScrollBehavior."
);
}
function d(f, y) {
if (y === "Y") return f.clientHeight + l < f.scrollHeight;
if (y === "X") return f.clientWidth + l < f.scrollWidth;
}
function h(f, y) {
const g = t.getComputedStyle(f, null)["overflow" + y];
return g === "auto" || g === "scroll";
}
function m(f) {
const y = d(f, "Y") && h(f, "Y"),
g = d(f, "X") && h(f, "X");
return y || g;
}
function p(f) {
for (; f !== e.body && m(f) === !1; ) f = f.parentNode || f.host;
return f;
}
function v(f) {
const y = a();
let g,
C,
M,
R = (y - f.startTime) / n;
(R = R > 1 ? 1 : R),
(g = c(R)),
(C = f.startX + (f.x - f.startX) * g),
(M = f.startY + (f.y - f.startY) * g),
f.method.call(f.scrollable, C, M),
(C !== f.x || M !== f.y) && t.requestAnimationFrame(v.bind(t, f));
}
function b(f, y, g) {
let C, M, R, _;
const P = a();
f === e.body
? ((C = t),
(M = t.scrollX || t.pageXOffset),
(R = t.scrollY || t.pageYOffset),
(_ = o.scroll))
: ((C = f), (M = f.scrollLeft), (R = f.scrollTop), (_ = s)),
v({
scrollable: C,
method: _,
startTime: P,
startX: M,
startY: R,
x: y,
y: g,
});
}
(t.scroll = t.scrollTo =
function () {
if (arguments[0] !== void 0) {
if (u(arguments[0]) === !0) {
o.scroll.call(
t,
arguments[0].left !== void 0
? arguments[0].left
: typeof arguments[0] != "object"
? arguments[0]
: t.scrollX || t.pageXOffset,
arguments[0].top !== void 0
? arguments[0].top
: arguments[1] !== void 0
? arguments[1]
: t.scrollY || t.pageYOffset
);
return;
}
b.call(
t,
e.body,
arguments[0].left !== void 0
? ~~arguments[0].left
: t.scrollX || t.pageXOffset,
arguments[0].top !== void 0
? ~~arguments[0].top
: t.scrollY || t.pageYOffset
);
}
}),
(t.scrollBy = function () {
if (arguments[0] !== void 0) {
if (u(arguments[0])) {
o.scrollBy.call(
t,
arguments[0].left !== void 0
? arguments[0].left
: typeof arguments[0] != "object"
? arguments[0]
: 0,
arguments[0].top !== void 0
? arguments[0].top
: arguments[1] !== void 0
? arguments[1]
: 0
);
return;
}
b.call(
t,
e.body,
~~arguments[0].left + (t.scrollX || t.pageXOffset),
~~arguments[0].top + (t.scrollY || t.pageYOffset)
);
}
}),
(r.prototype.scroll = r.prototype.scrollTo =
function () {
if (arguments[0] === void 0) return;
if (u(arguments[0]) === !0) {
if (typeof arguments[0] == "number" && arguments[1] === void 0)
throw new SyntaxError("Value could not be converted");
o.elementScroll.call(
this,
arguments[0].left !== void 0
? ~~arguments[0].left
: typeof arguments[0] != "object"
? ~~arguments[0]
: this.scrollLeft,
arguments[0].top !== void 0
? ~~arguments[0].top
: arguments[1] !== void 0
? ~~arguments[1]
: this.scrollTop
);
return;
}
const f = arguments[0].left,
y = arguments[0].top;
b.call(
this,
this,
typeof f > "u" ? this.scrollLeft : ~~f,
typeof y > "u" ? this.scrollTop : ~~y
);
}),
(r.prototype.scrollBy = function () {
if (arguments[0] !== void 0) {
if (u(arguments[0]) === !0) {
o.elementScroll.call(
this,
arguments[0].left !== void 0
? ~~arguments[0].left + this.scrollLeft
: ~~arguments[0] + this.scrollLeft,
arguments[0].top !== void 0
? ~~arguments[0].top + this.scrollTop
: ~~arguments[1] + this.scrollTop
);
return;
}
this.scroll({
left: ~~arguments[0].left + this.scrollLeft,
top: ~~arguments[0].top + this.scrollTop,
behavior: arguments[0].behavior,
});
}
}),
(r.prototype.scrollIntoView = function () {
if (u(arguments[0]) === !0) {
o.scrollIntoView.call(
this,
arguments[0] === void 0 ? !0 : arguments[0]
);
return;
}
const f = p(this),
y = f.getBoundingClientRect(),
g = this.getBoundingClientRect();
f !== e.body
? (b.call(
this,
f,
f.scrollLeft + g.left - y.left,
f.scrollTop + g.top - y.top
),
t.getComputedStyle(f).position !== "fixed" &&
t.scrollBy({ left: y.left, top: y.top, behavior: "smooth" }))
: t.scrollBy({ left: g.left, top: g.top, behavior: "smooth" });
});
}
class Es {
constructor(e = [], r) {
(this.timeOffset = 0),
(this.raf = null),
(this.actions = e),
(this.speed = r.speed);
}
addAction(e) {
const r = this.raf === !0;
if (
!this.actions.length ||
this.actions[this.actions.length - 1].delay <= e.delay
)
this.actions.push(e);
else {
const n = this.findActionIndex(e);
this.actions.splice(n, 0, e);
}
r && (this.raf = requestAnimationFrame(this.rafCheck.bind(this)));
}
start() {
(this.timeOffset = 0),
(this.lastTimestamp = performance.now()),
(this.raf = requestAnimationFrame(this.rafCheck.bind(this)));
}
rafCheck() {
const e = performance.now();
for (
this.timeOffset += (e - this.lastTimestamp) * this.speed,
this.lastTimestamp = e;
this.actions.length;
) {
const r = this.actions[0];
if (this.timeOffset >= r.delay) this.actions.shift(), r.doAction();
else break;
}
this.actions.length > 0
? (this.raf = requestAnimationFrame(this.rafCheck.bind(this)))
: (this.raf = !0);
}
clear() {
this.raf &&
(this.raf !== !0 && cancelAnimationFrame(this.raf), (this.raf = null)),
(this.actions.length = 0);
}
setSpeed(e) {
this.speed = e;
}
isActive() {
return this.raf !== null;
}
findActionIndex(e) {
let r = 0,
n = this.actions.length - 1;
for (; r <= n; ) {
const o = Math.floor((r + n) / 2);
if (this.actions[o].delay < e.delay) r = o + 1;
else if (this.actions[o].delay > e.delay) n = o - 1;
else return o + 1;
}
return r;
}
}
function Hr(t, e) {
if (
t.type === T.IncrementalSnapshot &&
t.data.source === E.MouseMove &&
t.data.positions &&
t.data.positions.length
) {
const r = t.data.positions[0].timeOffset,
n = t.timestamp + r;
return (t.delay = n - e), n - e;
}
return (t.delay = t.timestamp - e), t.delay;
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ function Yr(
t,
e
) {
var r = typeof Symbol == "function" && t[Symbol.iterator];
if (!r) return t;
var n,
o,
a = r.call(t),
i = [];
try {
for (; (e === void 0 || e-- > 0) && !(n = a.next()).done; )
i.push(n.value);
} catch (l) {
o = { error: l };
} finally {
try {
n && !n.done && (r = a.return) && r.call(a);
} finally {
if (o) throw o.error;
}
}
return i;
}
var Ae;
(function (t) {
(t[(t.NotStarted = 0)] = "NotStarted"),
(t[(t.Running = 1)] = "Running"),
(t[(t.Stopped = 2)] = "Stopped");
})(Ae || (Ae = {}));
var Xr = { type: "xstate.init" };
function _t(t) {
return t === void 0 ? [] : [].concat(t);
}
function _e(t) {
return { type: "xstate.assign", assignment: t };
}
function Zr(t, e) {
return typeof (t = typeof t == "string" && e && e[t] ? e[t] : t) == "string"
? { type: t }
: typeof t == "function"
? { type: t.name, exec: t }
: t;
}
function lt(t) {
return function (e) {
return t === e;
};
}
function Kr(t) {
return typeof t == "string" ? { type: t } : t;
}
function Jr(t, e) {
return { value: t, context: e, actions: [], changed: !1, matches: lt(t) };
}
function Qr(t, e, r) {
var n = e,
o = !1;
return [
t.filter(function (a) {
if (a.type === "xstate.assign") {
o = !0;
var i = Object.assign({}, n);
return (
typeof a.assignment == "function"
? (i = a.assignment(n, r))
: Object.keys(a.assignment).forEach(function (l) {
i[l] =
typeof a.assignment[l] == "function"
? a.assignment[l](n, r)
: a.assignment[l];
}),
(n = i),
!1
);
}
return !0;
}),
n,
o,
];
}
function qr(t, e) {
e === void 0 && (e = {});
var r = Yr(
Qr(
_t(t.states[t.initial].entry).map(function (i) {
return Zr(i, e.actions);
}),
t.context,
Xr
),
2
),
n = r[0],
o = r[1],
a = {
config: t,
_options: e,
initialState: {
value: t.initial,
actions: n,
context: o,
matches: lt(t.initial),
},
transition: function (i, l) {
var s,
c,
u = typeof i == "string" ? { value: i, context: t.context } : i,
d = u.value,
h = u.context,
m = Kr(l),
p = t.states[d];
if (p.on) {
var v = _t(p.on[m.type]);
try {
for (
var b = (function (F) {
var q = typeof Symbol == "function" && Symbol.iterator,
w = q && F[q],
S = 0;
if (w) return w.call(F);
if (F && typeof F.length == "number")
return {
next: function () {
return (
F && S >= F.length && (F = void 0),
{ value: F && F[S++], done: !F }
);
},
};
throw new TypeError(
q
? "Object is not iterable."
: "Symbol.iterator is not defined."
);
})(v),
f = b.next();
!f.done;
f = b.next()
) {
var y = f.value;
if (y === void 0) return Jr(d, h);
var g = typeof y == "string" ? { target: y } : y,
C = g.target,
M = g.actions,
R = M === void 0 ? [] : M,
_ = g.cond,
P =
_ === void 0
? function () {
return !0;
}
: _,
Z = C === void 0,
K = C ?? d,
Y = t.states[K];
if (P(h, m)) {
var J = Yr(
Qr(
(Z
? _t(R)
: [].concat(p.exit, R, Y.entry).filter(function (F) {
return F;
})
).map(function (F) {
return Zr(F, a._options.actions);
}),
h,
m
),
3
),
Q = J[0],
ie = J[1],
U = J[2],
j = C ?? d;
return {
value: j,
context: ie,
actions: Q,
changed: C !== d || Q.length > 0 || U,
matches: lt(j),
};
}
}
} catch (F) {
s = { error: F };
} finally {
try {
f && !f.done && (c = b.return) && c.call(b);
} finally {
if (s) throw s.error;
}
}
}
return Jr(d, h);
},
};
return a;
}
var en = function (t, e) {
return t.actions.forEach(function (r) {
var n = r.exec;
return n && n(t.context, e);
});
};
function tn(t) {
var e = t.initialState,
r = Ae.NotStarted,
n = new Set(),
o = {
_machine: t,
send: function (a) {
r === Ae.Running &&
((e = t.transition(e, a)),
en(e, Kr(a)),
n.forEach(function (i) {
return i(e);
}));
},
subscribe: function (a) {
return (
n.add(a),
a(e),
{
unsubscribe: function () {
return n.delete(a);
},
}
);
},
start: function (a) {
if (a) {
var i =
typeof a == "object"
? a
: { context: t.config.context, value: a };
e = {
value: i.value,
actions: [],
context: i.context,
matches: lt(i.value),
};
}
return (r = Ae.Running), en(e, Xr), o;
},
stop: function () {
return (r = Ae.Stopped), n.clear(), o;
},
get state() {
return e;
},
get status() {
return r;
},
};
return o;
}
var Ts = Object.defineProperty,
Ns = Object.defineProperties,
Ms = Object.getOwnPropertyDescriptors,
rn = Object.getOwnPropertySymbols,
Is = Object.prototype.hasOwnProperty,
Ds = Object.prototype.propertyIsEnumerable,
nn = (t, e, r) =>
e in t
? Ts(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
: (t[e] = r),
Ft = (t, e) => {
for (var r in e || (e = {})) Is.call(e, r) && nn(t, r, e[r]);
if (rn) for (var r of rn(e)) Ds.call(e, r) && nn(t, r, e[r]);
return t;
},
Pt = (t, e) => Ns(t, Ms(e));
function ks(t, e) {
for (let r = t.length - 1; r >= 0; r--) {
const n = t[r];
if (n.type === T.Meta && n.timestamp <= e) return t.slice(r);
}
return t;
}
function Rs(t, { getCastFn: e, applyEventsSynchronously: r, emitter: n }) {
const o = qr(
{
id: "player",
context: t,
initial: "paused",
states: {
playing: {
on: {
PAUSE: { target: "paused", actions: ["pause"] },
CAST_EVENT: { target: "playing", actions: "castEvent" },
END: {
target: "paused",
actions: ["resetLastPlayedEvent", "pause"],
},
ADD_EVENT: { target: "playing", actions: ["addEvent"] },
},
},
paused: {
on: {
PLAY: {
target: "playing",
actions: ["recordTimeOffset", "play"],
},
CAST_EVENT: { target: "paused", actions: "castEvent" },
TO_LIVE: { target: "live", actions: ["startLive"] },
ADD_EVENT: { target: "paused", actions: ["addEvent"] },
},
},
live: {
on: {
ADD_EVENT: { target: "live", actions: ["addEvent"] },
CAST_EVENT: { target: "live", actions: ["castEvent"] },
},
},
},
},
{
actions: {
castEvent: _e({
lastPlayedEvent: (a, i) =>
i.type === "CAST_EVENT" ? i.payload.event : a.lastPlayedEvent,
}),
recordTimeOffset: _e((a, i) => {
let l = a.timeOffset;
return (
"payload" in i &&
"timeOffset" in i.payload &&
(l = i.payload.timeOffset),
Pt(Ft({}, a), {
timeOffset: l,
baselineTime: a.events[0].timestamp + l,
})
);
}),
play(a) {
var i;
const {
timer: l,
events: s,
baselineTime: c,
lastPlayedEvent: u,
} = a;
l.clear();
for (const p of s) Hr(p, c);
const d = ks(s, c);
let h = u?.timestamp;
u?.type === T.IncrementalSnapshot &&
u.data.source === E.MouseMove &&
(h =
u.timestamp +
((i = u.data.positions[0]) == null ? void 0 : i.timeOffset)),
c < (h || 0) && n.emit(A.PlayBack);
const m = new Array();
for (const p of d)
if (!(h && h < c && (p.timestamp <= h || p === u)))
if (p.timestamp < c) m.push(p);
else {
const v = e(p, !1);
l.addAction({
doAction: () => {
v();
},
delay: p.delay,
});
}
r(m), n.emit(A.Flush), l.start();
},
pause(a) {
a.timer.clear();
},
resetLastPlayedEvent: _e((a) =>
Pt(Ft({}, a), { lastPlayedEvent: null })
),
startLive: _e({
baselineTime: (a, i) => (
a.timer.start(),
i.type === "TO_LIVE" && i.payload.baselineTime
? i.payload.baselineTime
: Date.now()
),
}),
addEvent: _e((a, i) => {
const { baselineTime: l, timer: s, events: c } = a;
if (i.type === "ADD_EVENT") {
const { event: u } = i.payload;
Hr(u, l);
let d = c.length - 1;
if (!c[d] || c[d].timestamp <= u.timestamp) c.push(u);
else {
let p = -1,
v = 0;
for (; v <= d; ) {
const b = Math.floor((v + d) / 2);
c[b].timestamp <= u.timestamp ? (v = b + 1) : (d = b - 1);
}
p === -1 && (p = v), c.splice(p, 0, u);
}
const h = u.timestamp < l,
m = e(u, h);
h
? m()
: s.isActive() &&
s.addAction({
doAction: () => {
m();
},
delay: u.delay,
});
}
return Pt(Ft({}, a), { events: c });
}),
},
}
);
return tn(o);
}
function xs(t) {
const e = qr(
{
id: "speed",
context: t,
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: (r, n) => {
"payload" in n && r.timer.setSpeed(n.payload.speed);
},
recordSpeed: _e({ normalSpeed: (r) => r.timer.speed }),
restoreSpeed: (r) => {
r.timer.setSpeed(r.normalSpeed);
},
},
}
);
return tn(e);
}
const Os = (t) => [
`.${t} { background: currentColor }`,
"noscript { display: none !important; }",
];
var Ls = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) => (s.done ? n(s.value) : Promise.resolve(s.value).then(a, i));
l((r = r.apply(t, e)).next());
});
const on = new Map();
function sn(t, e) {
let r = on.get(t);
return (
r || ((r = new Map()), on.set(t, r)), r.has(e) || r.set(e, []), r.get(e)
);
}
function be(t, e, r) {
return (n) =>
Ls(this, null, function* () {
if (n && typeof n == "object" && "rr_type" in n)
if (
(r && (r.isUnchanged = !1),
n.rr_type === "ImageBitmap" && "args" in n)
) {
const o = yield be(t, e, r)(n.args);
return yield createImageBitmap.apply(null, o);
} else if ("index" in n) {
if (r || e === null) return n;
const { rr_type: o, index: a } = n;
return sn(e, o)[a];
} else if ("args" in n) {
const { rr_type: o, args: a } = n,
i = window[o];
return new i(...(yield Promise.all(a.map(be(t, e, r)))));
} else {
if ("base64" in n) return Io(n.base64);
if ("src" in n) {
const o = t.get(n.src);
if (o) return o;
{
const a = new Image();
return (a.src = n.src), t.set(n.src, a), a;
}
} else if ("data" in n && n.rr_type === "Blob") {
const o = yield Promise.all(n.data.map(be(t, e, r)));
return new Blob(o, { type: n.type });
}
}
else if (Array.isArray(n)) return yield Promise.all(n.map(be(t, e, r)));
return n;
});
}
var As = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) => (s.done ? n(s.value) : Promise.resolve(s.value).then(a, i));
l((r = r.apply(t, e)).next());
});
function _s(t, e) {
try {
return e === fe.WebGL
? t.getContext("webgl") || t.getContext("experimental-webgl")
: t.getContext("webgl2");
} catch {
return null;
}
}
const Fs = [
"WebGLActiveInfo",
"WebGLBuffer",
"WebGLFramebuffer",
"WebGLProgram",
"WebGLRenderbuffer",
"WebGLShader",
"WebGLShaderPrecisionFormat",
"WebGLTexture",
"WebGLUniformLocation",
"WebGLVertexArrayObject",
];
function Ps(t, e) {
if (!(e != null && e.constructor)) return;
const { name: r } = e.constructor;
if (!Fs.includes(r)) return;
const n = sn(t, r);
n.includes(e) || n.push(e);
}
function Ws(t) {
return As(
this,
arguments,
function* ({
mutation: e,
target: r,
type: n,
imageMap: o,
errorHandler: a,
}) {
try {
const i = _s(r, n);
if (!i) return;
if (e.setter) {
i[e.property] = e.args[0];
return;
}
const l = i[e.property],
s = yield Promise.all(e.args.map(be(o, i))),
c = l.apply(i, s);
Ps(i, c);
} catch (i) {
a(e, i);
}
}
);
}
var an = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) => (s.done ? n(s.value) : Promise.resolve(s.value).then(a, i));
l((r = r.apply(t, e)).next());
});
function $s(t) {
return an(
this,
arguments,
function* ({
event: e,
mutations: r,
target: n,
imageMap: o,
errorHandler: a,
}) {
const i = n.getContext("2d");
if (!i) {
a(r[0], new Error("Canvas context is null"));
return;
}
const l = r.map((s) =>
an(this, null, function* () {
return Promise.all(s.args.map(be(o, i)));
})
);
(yield Promise.all(l)).forEach((s, c) => {
const u = r[c];
try {
if (u.setter) {
i[u.property] = u.args[0];
return;
}
const d = i[u.property];
u.property === "drawImage" && typeof u.args[0] == "string"
? (o.get(e), d.apply(i, u.args))
: d.apply(i, s);
} catch (d) {
a(u, d);
}
});
}
);
}
var Us = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) => (s.done ? n(s.value) : Promise.resolve(s.value).then(a, i));
l((r = r.apply(t, e)).next());
});
function ln(t) {
return Us(
this,
arguments,
function* ({
event: e,
mutation: r,
target: n,
imageMap: o,
canvasEventMap: a,
errorHandler: i,
}) {
try {
const l = a.get(e) || r,
s = "commands" in l ? l.commands : [l];
if ([fe.WebGL, fe.WebGL2].includes(r.type)) {
for (let c = 0; c < s.length; c++) {
const u = s[c];
yield Ws({
mutation: u,
type: r.type,
target: n,
imageMap: o,
errorHandler: i,
});
}
return;
}
yield $s({
event: e,
mutations: s,
target: n,
imageMap: o,
errorHandler: i,
});
} catch (l) {
i(r, l);
}
}
);
}
var Vs = Object.defineProperty,
Bs = Object.defineProperties,
Gs = Object.getOwnPropertyDescriptors,
cn = Object.getOwnPropertySymbols,
js = Object.prototype.hasOwnProperty,
zs = Object.prototype.propertyIsEnumerable,
un = (t, e, r) =>
e in t
? Vs(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
: (t[e] = r),
ct = (t, e) => {
for (var r in e || (e = {})) js.call(e, r) && un(t, r, e[r]);
if (cn) for (var r of cn(e)) zs.call(e, r) && un(t, r, e[r]);
return t;
},
Wt = (t, e) => Bs(t, Gs(e)),
$t = (t, e, r) =>
new Promise((n, o) => {
var a = (s) => {
try {
l(r.next(s));
} catch (c) {
o(c);
}
},
i = (s) => {
try {
l(r.throw(s));
} catch (c) {
o(c);
}
},
l = (s) =>
s.done ? n(s.value) : Promise.resolve(s.value).then(a, i);
l((r = r.apply(t, e)).next());
});
const Hs = 10 * 1e3,
Ys = 5 * 1e3,
Xs = zr || ws,
dn = "[replayer]",
Ut = { duration: 500, lineCap: "round", lineWidth: 3, strokeStyle: "red" };
function hn(t) {
return (
t.type == T.IncrementalSnapshot &&
(t.data.source == E.TouchMove ||
(t.data.source == E.MouseInteraction && t.data.type == L.TouchStart))
);
}
class Zs {
constructor(e, r) {
if (
((this.usingVirtualDom = !1),
(this.virtualDom = new Le()),
(this.mouseTail = null),
(this.tailPositions = []),
(this.emitter = Xs()),
(this.legacy_missingNodeRetryMap = {}),
(this.cache = tr()),
(this.imageMap = new Map()),
(this.canvasEventMap = new Map()),
(this.mirror = jt()),
(this.styleMirror = new Nt()),
(this.firstFullSnapshot = null),
(this.newDocumentQueue = []),
(this.mousePos = null),
(this.touchActive = null),
(this.lastMouseDownEvent = null),
(this.lastSelectionData = null),
(this.constructedStyleMutations = []),
(this.adoptedStyleSheets = []),
(this.handleResize = (l) => {
this.iframe.style.display = "inherit";
for (const s of [this.mouseTail, this.iframe])
!s ||
(s.setAttribute("width", String(l.width)),
s.setAttribute("height", String(l.height)));
}),
(this.applyEventsSynchronously = (l) => {
for (const s of l) {
switch (s.type) {
case T.DomContentLoaded:
case T.Load:
case T.Custom:
continue;
case T.FullSnapshot:
case T.Meta:
case T.Plugin:
case T.IncrementalSnapshot:
break;
}
this.getCastFn(s, !0)();
}
}),
(this.getCastFn = (l, s = !1) => {
let c;
switch (l.type) {
case T.DomContentLoaded:
case T.Load:
break;
case T.Custom:
c = () => {
this.emitter.emit(A.CustomEvent, l);
};
break;
case T.Meta:
c = () =>
this.emitter.emit(A.Resize, {
width: l.data.width,
height: l.data.height,
});
break;
case T.FullSnapshot:
c = () => {
var u;
if (this.firstFullSnapshot) {
if (this.firstFullSnapshot === l) {
this.firstFullSnapshot = !0;
return;
}
} else this.firstFullSnapshot = !0;
this.rebuildFullSnapshot(l, s),
(u = this.iframe.contentWindow) == null ||
u.scrollTo(l.data.initialOffset),
this.styleMirror.reset();
};
break;
case T.IncrementalSnapshot:
c = () => {
if (
(this.applyIncremental(l, s),
!s &&
(l === this.nextUserInteractionEvent &&
((this.nextUserInteractionEvent = null),
this.backToNormal()),
this.config.skipInactive && !this.nextUserInteractionEvent))
) {
for (const u of this.service.state.context.events)
if (
!(u.timestamp <= l.timestamp) &&
this.isUserInteraction(u)
) {
u.delay - l.delay >
Hs * this.speedService.state.context.timer.speed &&
(this.nextUserInteractionEvent = u);
break;
}
if (this.nextUserInteractionEvent) {
const u = this.nextUserInteractionEvent.delay - l.delay,
d = {
speed: Math.min(
Math.round(u / Ys),
this.config.maxSpeed
),
};
this.speedService.send({
type: "FAST_FORWARD",
payload: d,
}),
this.emitter.emit(A.SkipStart, d);
}
}
};
break;
}
return () => {
c && c();
for (const d of this.config.plugins || [])
d.handler && d.handler(l, s, { replayer: this });
this.service.send({ type: "CAST_EVENT", payload: { event: l } });
const u = this.service.state.context.events.length - 1;
if (
!this.config.liveMode &&
l === this.service.state.context.events[u]
) {
const d = () => {
u < this.service.state.context.events.length - 1 ||
(this.backToNormal(),
this.service.send("END"),
this.emitter.emit(A.Finish));
};
let h = 50;
l.type === T.IncrementalSnapshot &&
l.data.source === E.MouseMove &&
l.data.positions.length &&
(h += Math.max(0, -l.data.positions[0].timeOffset)),
setTimeout(d, h);
}
this.emitter.emit(A.EventCast, l);
};
}),
!(r != null && r.liveMode) && e.length < 2)
)
throw new Error("Replayer need at least 2 events.");
const n = {
speed: 1,
maxSpeed: 360,
root: document.body,
loadTimeout: 0,
skipInactive: !1,
showWarning: !0,
showDebug: !1,
blockClass: "rr-block",
liveMode: !1,
insertStyleRules: [],
triggerFocus: !0,
UNSAFE_replayCanvas: !1,
pauseAnimation: !0,
mouseTail: Ut,
useVirtualDom: !0,
logger: console,
};
(this.config = Object.assign({}, n, r)),
(this.handleResize = this.handleResize.bind(this)),
(this.getCastFn = this.getCastFn.bind(this)),
(this.applyEventsSynchronously =
this.applyEventsSynchronously.bind(this)),
this.emitter.on(A.Resize, this.handleResize),
this.setupDom();
for (const l of this.config.plugins || [])
l.getMirror && l.getMirror({ nodeMirror: this.mirror });
this.emitter.on(A.Flush, () => {
if (this.usingVirtualDom) {
const l = {
mirror: this.mirror,
applyCanvas: (s, c, u) => {
ln({
event: s,
mutation: c,
target: u,
imageMap: this.imageMap,
canvasEventMap: this.canvasEventMap,
errorHandler: this.warnCanvasMutationFailed.bind(this),
});
},
applyInput: this.applyInput.bind(this),
applyScroll: this.applyScroll.bind(this),
applyStyleSheetMutation: (s, c) => {
s.source === E.StyleSheetRule
? this.applyStyleSheetRule(s, c)
: s.source === E.StyleDeclaration &&
this.applyStyleDeclaration(s, c);
},
afterAppend: (s, c) => {
for (const u of this.config.plugins || [])
u.onBuild && u.onBuild(s, { id: c, replayer: this });
},
};
if (this.iframe.contentDocument)
try {
it(
this.iframe.contentDocument,
this.virtualDom,
l,
this.virtualDom.mirror
);
} catch (s) {
console.warn(s);
}
if (
(this.virtualDom.destroyTree(),
(this.usingVirtualDom = !1),
Object.keys(this.legacy_missingNodeRetryMap).length)
)
for (const s in this.legacy_missingNodeRetryMap)
try {
const c = this.legacy_missingNodeRetryMap[s],
u = at(c.node, this.mirror, this.virtualDom.mirror);
it(u, c.node, l, this.virtualDom.mirror), (c.node = u);
} catch (c) {
this.warn(c);
}
this.constructedStyleMutations.forEach((s) => {
this.applyStyleSheetMutation(s);
}),
(this.constructedStyleMutations = []),
this.adoptedStyleSheets.forEach((s) => {
this.applyAdoptedStyleSheet(s);
}),
(this.adoptedStyleSheets = []);
}
if (
(this.mousePos &&
(this.moveAndHover(
this.mousePos.x,
this.mousePos.y,
this.mousePos.id,
!0,
this.mousePos.debugData
),
(this.mousePos = null)),
this.touchActive === !0
? this.mouse.classList.add("touch-active")
: this.touchActive === !1 &&
this.mouse.classList.remove("touch-active"),
(this.touchActive = null),
this.lastMouseDownEvent)
) {
const [l, s] = this.lastMouseDownEvent;
l.dispatchEvent(s);
}
(this.lastMouseDownEvent = null),
this.lastSelectionData &&
(this.applySelection(this.lastSelectionData),
(this.lastSelectionData = null));
}),
this.emitter.on(A.PlayBack, () => {
(this.firstFullSnapshot = null),
this.mirror.reset(),
this.styleMirror.reset();
});
const o = new Es([], { speed: this.config.speed });
(this.service = Rs(
{
events: e
.map((l) => (r && r.unpackFn ? r.unpackFn(l) : l))
.sort((l, s) => l.timestamp - s.timestamp),
timer: o,
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(A.StateChange, { player: l });
}),
(this.speedService = xs({ normalSpeed: -1, timer: o })),
this.speedService.start(),
this.speedService.subscribe((l) => {
this.emitter.emit(A.StateChange, { speed: l });
});
const a = this.service.state.context.events.find(
(l) => l.type === T.Meta
),
i = this.service.state.context.events.find(
(l) => l.type === T.FullSnapshot
);
if (a) {
const { width: l, height: s } = a.data;
setTimeout(() => {
this.emitter.emit(A.Resize, { width: l, height: s });
}, 0);
}
i &&
setTimeout(() => {
var l;
this.firstFullSnapshot ||
((this.firstFullSnapshot = i),
this.rebuildFullSnapshot(i),
(l = this.iframe.contentWindow) == null ||
l.scrollTo(i.data.initialOffset));
}, 1),
this.service.state.context.events.find(hn) &&
this.mouse.classList.add("touch-device");
}
get timer() {
return this.service.state.context.timer;
}
on(e, r) {
return this.emitter.on(e, r), this;
}
off(e, r) {
return this.emitter.off(e, r), this;
}
setConfig(e) {
Object.keys(e).forEach((r) => {
e[r], (this.config[r] = e[r]);
}),
this.config.skipInactive || this.backToNormal(),
typeof e.speed < "u" &&
this.speedService.send({
type: "SET_SPEED",
payload: { speed: e.speed },
}),
typeof e.mouseTail < "u" &&
(e.mouseTail === !1
? this.mouseTail && (this.mouseTail.style.display = "none")
: (this.mouseTail ||
((this.mouseTail = document.createElement("canvas")),
(this.mouseTail.width = Number.parseFloat(this.iframe.width)),
(this.mouseTail.height = Number.parseFloat(this.iframe.height)),
this.mouseTail.classList.add("replayer-mouse-tail"),
this.wrapper.insertBefore(this.mouseTail, this.iframe)),
(this.mouseTail.style.display = "inherit")));
}
getMetaData() {
const e = this.service.state.context.events[0],
r =
this.service.state.context.events[
this.service.state.context.events.length - 1
];
return {
startTime: e.timestamp,
endTime: r.timestamp,
totalTime: r.timestamp - e.timestamp,
};
}
getCurrentTime() {
return this.timer.timeOffset + this.getTimeOffset();
}
getTimeOffset() {
const { baselineTime: e, events: r } = this.service.state.context;
return e - r[0].timestamp;
}
getMirror() {
return this.mirror;
}
play(e = 0) {
var r, n;
this.service.state.matches("paused")
? this.service.send({ type: "PLAY", payload: { timeOffset: e } })
: (this.service.send({ type: "PAUSE" }),
this.service.send({ type: "PLAY", payload: { timeOffset: e } })),
(n =
(r = this.iframe.contentDocument) == null
? void 0
: r.getElementsByTagName("html")[0]) == null ||
n.classList.remove("rrweb-paused"),
this.emitter.emit(A.Start);
}
pause(e) {
var r, n;
e === void 0 &&
this.service.state.matches("playing") &&
this.service.send({ type: "PAUSE" }),
typeof e == "number" &&
(this.play(e), this.service.send({ type: "PAUSE" })),
(n =
(r = this.iframe.contentDocument) == null
? void 0
: r.getElementsByTagName("html")[0]) == null ||
n.classList.add("rrweb-paused"),
this.emitter.emit(A.Pause);
}
resume(e = 0) {
this.warn(
"The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface."
),
this.play(e),
this.emitter.emit(A.Resume);
}
destroy() {
this.pause(),
this.config.root.removeChild(this.wrapper),
this.emitter.emit(A.Destroy);
}
startLive(e) {
this.service.send({ type: "TO_LIVE", payload: { baselineTime: e } });
}
addEvent(e) {
const r = this.config.unpackFn ? this.config.unpackFn(e) : e;
hn(r) && this.mouse.classList.add("touch-device"),
Promise.resolve().then(() =>
this.service.send({ type: "ADD_EVENT", payload: { event: r } })
);
}
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 = tr();
}
setupDom() {
(this.wrapper = document.createElement("div")),
this.wrapper.classList.add("replayer-wrapper"),
this.config.root.appendChild(this.wrapper),
(this.mouse = document.createElement("div")),
this.mouse.classList.add("replayer-mouse"),
this.wrapper.appendChild(this.mouse),
this.config.mouseTail !== !1 &&
((this.mouseTail = document.createElement("canvas")),
this.mouseTail.classList.add("replayer-mouse-tail"),
(this.mouseTail.style.display = "inherit"),
this.wrapper.appendChild(this.mouseTail)),
(this.iframe = document.createElement("iframe"));
const e = ["allow-same-origin"];
this.config.UNSAFE_replayCanvas && e.push("allow-scripts"),
(this.iframe.style.display = "none"),
this.iframe.setAttribute("sandbox", e.join(" ")),
this.disableInteract(),
this.wrapper.appendChild(this.iframe),
this.iframe.contentWindow &&
this.iframe.contentDocument &&
(Cs(this.iframe.contentWindow, this.iframe.contentDocument),
bt(this.iframe.contentWindow));
}
rebuildFullSnapshot(e, r = !1) {
if (!this.iframe.contentDocument)
return this.warn("Looks like your replayer has been destroyed.");
Object.keys(this.legacy_missingNodeRetryMap).length &&
this.warn(
"Found unresolved missing node map",
this.legacy_missingNodeRetryMap
),
(this.legacy_missingNodeRetryMap = {});
const n = [],
o = (l, s) => {
this.collectIframeAndAttachDocument(n, l);
for (const c of this.config.plugins || [])
c.onBuild && c.onBuild(l, { id: s, replayer: this });
};
this.usingVirtualDom &&
(this.virtualDom.destroyTree(), (this.usingVirtualDom = !1)),
this.mirror.reset(),
Xn(e.data.node, {
doc: this.iframe.contentDocument,
afterAppend: o,
cache: this.cache,
mirror: this.mirror,
}),
o(this.iframe.contentDocument, e.data.node.id);
for (const { mutationInQueue: l, builtNode: s } of n)
this.attachDocumentToIframe(l, s),
(this.newDocumentQueue = this.newDocumentQueue.filter(
(c) => c !== l
));
const { documentElement: a, head: i } = this.iframe.contentDocument;
this.insertStyleRules(a, i),
this.service.state.matches("playing") ||
this.iframe.contentDocument
.getElementsByTagName("html")[0]
.classList.add("rrweb-paused"),
this.emitter.emit(A.FullsnapshotRebuilded, e),
r || this.waitForStylesheetLoad(),
this.config.UNSAFE_replayCanvas && this.preloadAllImages();
}
insertStyleRules(e, r) {
var n;
const o = Os(this.config.blockClass).concat(this.config.insertStyleRules);
if (
(this.config.pauseAnimation &&
o.push(
"html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"
),
this.usingVirtualDom)
) {
const a = this.virtualDom.createElement("style");
this.virtualDom.mirror.add(a, jr(a, this.virtualDom.unserializedId)),
e.insertBefore(a, r),
a.rules.push({
source: E.StyleSheetRule,
adds: o.map((i, l) => ({ rule: i, index: l })),
});
} else {
const a = document.createElement("style");
e.insertBefore(a, r);
for (let i = 0; i < o.length; i++)
(n = a.sheet) == null || n.insertRule(o[i], i);
}
}
attachDocumentToIframe(e, r) {
const n = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror,
o = [],
a = (i, l) => {
this.collectIframeAndAttachDocument(o, i);
const s = n.getMeta(i);
if (s?.type === N.Element && s?.tagName.toUpperCase() === "HTML") {
const { documentElement: c, head: u } = r.contentDocument;
this.insertStyleRules(c, u);
}
if (!this.usingVirtualDom)
for (const c of this.config.plugins || [])
c.onBuild && c.onBuild(i, { id: l, replayer: this });
};
Ue(e.node, {
doc: r.contentDocument,
mirror: n,
hackCss: !0,
skipChild: !1,
afterAppend: a,
cache: this.cache,
}),
a(r.contentDocument, e.node.id);
for (const { mutationInQueue: i, builtNode: l } of o)
this.attachDocumentToIframe(i, l),
(this.newDocumentQueue = this.newDocumentQueue.filter(
(s) => s !== i
));
}
collectIframeAndAttachDocument(e, r) {
if (ke(r, this.mirror)) {
const n = this.newDocumentQueue.find(
(o) => o.parentId === this.mirror.getId(r)
);
n && e.push({ mutationInQueue: n, builtNode: r });
}
}
waitForStylesheetLoad() {
var e;
const r = (e = this.iframe.contentDocument) == null ? void 0 : e.head;
if (r) {
const n = new Set();
let o,
a = this.service.state;
const i = () => {
a = this.service.state;
};
this.emitter.on(A.Start, i), this.emitter.on(A.Pause, i);
const l = () => {
this.emitter.off(A.Start, i), this.emitter.off(A.Pause, i);
};
r.querySelectorAll('link[rel="stylesheet"]').forEach((s) => {
s.sheet ||
(n.add(s),
s.addEventListener("load", () => {
n.delete(s),
n.size === 0 &&
o !== -1 &&
(a.matches("playing") && this.play(this.getCurrentTime()),
this.emitter.emit(A.LoadStylesheetEnd),
o && clearTimeout(o),
l());
}));
}),
n.size > 0 &&
(this.service.send({ type: "PAUSE" }),
this.emitter.emit(A.LoadStylesheetStart),
(o = setTimeout(() => {
a.matches("playing") && this.play(this.getCurrentTime()),
(o = -1),
l();
}, this.config.loadTimeout)));
}
}
preloadAllImages() {
return $t(this, null, function* () {
this.service.state;
const e = () => {
this.service.state;
};
this.emitter.on(A.Start, e), this.emitter.on(A.Pause, e);
const r = [];
for (const n of this.service.state.context.events)
n.type === T.IncrementalSnapshot &&
n.data.source === E.CanvasMutation &&
(r.push(this.deserializeAndPreloadCanvasEvents(n.data, n)),
("commands" in n.data ? n.data.commands : [n.data]).forEach((o) => {
this.preloadImages(o, n);
}));
return Promise.all(r);
});
}
preloadImages(e, r) {
if (
e.property === "drawImage" &&
typeof e.args[0] == "string" &&
!this.imageMap.has(r)
) {
const n = document.createElement("canvas"),
o = n.getContext("2d"),
a = o?.createImageData(n.width, n.height);
a?.data, JSON.parse(e.args[0]), o?.putImageData(a, 0, 0);
}
}
deserializeAndPreloadCanvasEvents(e, r) {
return $t(this, null, function* () {
if (!this.canvasEventMap.has(r)) {
const n = { isUnchanged: !0 };
if ("commands" in e) {
const o = yield Promise.all(
e.commands.map((a) =>
$t(this, null, function* () {
const i = yield Promise.all(
a.args.map(be(this.imageMap, null, n))
);
return Wt(ct({}, a), { args: i });
})
)
);
n.isUnchanged === !1 &&
this.canvasEventMap.set(r, Wt(ct({}, e), { commands: o }));
} else {
const o = yield Promise.all(e.args.map(be(this.imageMap, null, n)));
n.isUnchanged === !1 &&
this.canvasEventMap.set(r, Wt(ct({}, e), { args: o }));
}
}
});
}
applyIncremental(e, r) {
var n, o, a;
const { data: i } = e;
switch (i.source) {
case E.Mutation: {
try {
this.applyMutation(i, r);
} catch (l) {
this.warn(`Exception in mutation ${l.message || l}`, i);
}
break;
}
case E.Drag:
case E.TouchMove:
case E.MouseMove:
if (r) {
const l = i.positions[i.positions.length - 1];
this.mousePos = { x: l.x, y: l.y, id: l.id, debugData: i };
} else
i.positions.forEach((l) => {
const s = {
doAction: () => {
this.moveAndHover(l.x, l.y, l.id, r, i);
},
delay:
l.timeOffset +
e.timestamp -
this.service.state.context.baselineTime,
};
this.timer.addAction(s);
}),
this.timer.addAction({
doAction() {},
delay:
e.delay -
((n = i.positions[0]) == null ? void 0 : n.timeOffset),
});
break;
case E.MouseInteraction: {
if (i.id === -1) break;
const l = new Event(ge(L[i.type])),
s = this.mirror.getNode(i.id);
if (!s) return this.debugNodeNotFound(i, i.id);
this.emitter.emit(A.MouseInteraction, { type: i.type, target: s });
const { triggerFocus: c } = this.config;
switch (i.type) {
case L.Blur:
"blur" in s && s.blur();
break;
case L.Focus:
c && s.focus && s.focus({ preventScroll: !0 });
break;
case L.Click:
case L.TouchStart:
case L.TouchEnd:
case L.MouseDown:
case L.MouseUp:
r
? (i.type === L.TouchStart
? (this.touchActive = !0)
: i.type === L.TouchEnd && (this.touchActive = !1),
i.type === L.MouseDown
? (this.lastMouseDownEvent = [s, l])
: i.type === L.MouseUp && (this.lastMouseDownEvent = null),
(this.mousePos = { x: i.x, y: i.y, id: i.id, debugData: i }))
: (i.type === L.TouchStart && (this.tailPositions.length = 0),
this.moveAndHover(i.x, i.y, i.id, r, i),
i.type === L.Click
? (this.mouse.classList.remove("active"),
this.mouse.offsetWidth,
this.mouse.classList.add("active"))
: i.type === L.TouchStart
? (this.mouse.offsetWidth,
this.mouse.classList.add("touch-active"))
: i.type === L.TouchEnd
? this.mouse.classList.remove("touch-active")
: s.dispatchEvent(l));
break;
case L.TouchCancel:
r
? (this.touchActive = !1)
: this.mouse.classList.remove("touch-active");
break;
default:
s.dispatchEvent(l);
}
break;
}
case E.Scroll: {
if (i.id === -1) break;
if (this.usingVirtualDom) {
const l = this.virtualDom.mirror.getNode(i.id);
if (!l) return this.debugNodeNotFound(i, i.id);
l.scrollData = i;
break;
}
this.applyScroll(i, r);
break;
}
case E.ViewportResize:
this.emitter.emit(A.Resize, { width: i.width, height: i.height });
break;
case E.Input: {
if (i.id === -1) break;
if (this.usingVirtualDom) {
const l = this.virtualDom.mirror.getNode(i.id);
if (!l) return this.debugNodeNotFound(i, i.id);
l.inputData = i;
break;
}
this.applyInput(i);
break;
}
case E.MediaInteraction: {
const l = this.usingVirtualDom
? this.virtualDom.mirror.getNode(i.id)
: this.mirror.getNode(i.id);
if (!l) return this.debugNodeNotFound(i, i.id);
const s = l;
try {
i.currentTime !== void 0 && (s.currentTime = i.currentTime),
i.volume !== void 0 && (s.volume = i.volume),
i.muted !== void 0 && (s.muted = i.muted),
i.type === ye.Pause && s.pause(),
i.type === ye.Play && s.play(),
i.type === ye.RateChange && (s.playbackRate = i.playbackRate);
} catch (c) {
this.warn(`Failed to replay media interactions: ${c.message || c}`);
}
break;
}
case E.StyleSheetRule:
case E.StyleDeclaration: {
this.usingVirtualDom
? i.styleId
? this.constructedStyleMutations.push(i)
: i.id &&
((o = this.virtualDom.mirror.getNode(i.id)) == null ||
o.rules.push(i))
: this.applyStyleSheetMutation(i);
break;
}
case E.CanvasMutation: {
if (!this.config.UNSAFE_replayCanvas) return;
if (this.usingVirtualDom) {
const l = this.virtualDom.mirror.getNode(i.id);
if (!l) return this.debugNodeNotFound(i, i.id);
l.canvasMutations.push({ event: e, mutation: i });
} else {
const l = this.mirror.getNode(i.id);
if (!l) return this.debugNodeNotFound(i, i.id);
ln({
event: e,
mutation: i,
target: l,
imageMap: this.imageMap,
canvasEventMap: this.canvasEventMap,
errorHandler: this.warnCanvasMutationFailed.bind(this),
});
}
break;
}
case E.Font: {
try {
const l = new FontFace(
i.family,
i.buffer
? new Uint8Array(JSON.parse(i.fontSource))
: i.fontSource,
i.descriptors
);
(a = this.iframe.contentDocument) == null || a.fonts.add(l);
} catch (l) {
this.warn(l);
}
break;
}
case E.Selection: {
if (r) {
this.lastSelectionData = i;
break;
}
this.applySelection(i);
break;
}
case E.AdoptedStyleSheet: {
this.usingVirtualDom
? this.adoptedStyleSheets.push(i)
: this.applyAdoptedStyleSheet(i);
break;
}
}
}
applyMutation(e, r) {
if (
this.config.useVirtualDom &&
!this.usingVirtualDom &&
r &&
((this.usingVirtualDom = !0),
vs(this.iframe.contentDocument, this.mirror, this.virtualDom),
Object.keys(this.legacy_missingNodeRetryMap).length)
)
for (const c in this.legacy_missingNodeRetryMap)
try {
const u = this.legacy_missingNodeRetryMap[c],
d = Gr(u.node, this.virtualDom, this.mirror);
d && (u.node = d);
} catch (u) {
this.warn(u);
}
const n = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
(e.removes = e.removes.filter((c) =>
n.getNode(c.id) ? !0 : (this.warnNodeNotFound(e, c.id), !1)
)),
e.removes.forEach((c) => {
var u;
const d = n.getNode(c.id);
if (!d) return;
let h = n.getNode(c.parentId);
if (!h) return this.warnNodeNotFound(e, c.parentId);
if (
(c.isShadow && ve(h) && (h = h.shadowRoot),
n.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 (m) {
if (m instanceof DOMException)
this.warn("parent could not remove child in mutation", h, d, e);
else throw m;
}
});
const o = ct({}, this.legacy_missingNodeRetryMap),
a = [],
i = (c) => {
let u = null;
return (
c.nextId && (u = n.getNode(c.nextId)),
c.nextId !== null && c.nextId !== void 0 && c.nextId !== -1 && !u
);
},
l = (c) => {
var u, d;
if (!this.iframe.contentDocument)
return this.warn("Looks like your replayer has been destroyed.");
let h = n.getNode(c.parentId);
if (!h)
return c.node.type === N.Document
? this.newDocumentQueue.push(c)
: a.push(c);
c.node.isShadow &&
(ve(h) || h.attachShadow({ mode: "open" }), (h = h.shadowRoot));
let m = null,
p = null;
if (
(c.previousId && (m = n.getNode(c.previousId)),
c.nextId && (p = n.getNode(c.nextId)),
i(c))
)
return a.push(c);
if (c.node.rootId && !n.getNode(c.node.rootId)) return;
const v = c.node.rootId
? n.getNode(c.node.rootId)
: this.usingVirtualDom
? this.virtualDom
: this.iframe.contentDocument;
if (ke(h, n)) {
this.attachDocumentToIframe(c, h);
return;
}
const b = (g, C) => {
if (!this.usingVirtualDom)
for (const M of this.config.plugins || [])
M.onBuild && M.onBuild(g, { id: C, replayer: this });
},
f = Ue(c.node, {
doc: v,
mirror: n,
skipChild: !0,
hackCss: !0,
cache: this.cache,
afterAppend: b,
});
if (c.previousId === -1 || c.nextId === -1) {
o[c.node.id] = { node: f, mutation: c };
return;
}
const y = n.getMeta(h);
if (
y &&
y.type === N.Element &&
y.tagName === "textarea" &&
c.node.type === N.Text
) {
const g = Array.isArray(h.childNodes)
? h.childNodes
: Array.from(h.childNodes);
for (const C of g) C.nodeType === h.TEXT_NODE && h.removeChild(C);
} else if (y?.type === N.Document) {
const g = h;
c.node.type === N.DocumentType &&
((u = g.childNodes[0]) == null ? void 0 : u.nodeType) ===
Node.DOCUMENT_TYPE_NODE &&
g.removeChild(g.childNodes[0]),
f.nodeName === "HTML" &&
g.documentElement &&
g.removeChild(g.documentElement);
}
if (
(m && m.nextSibling && m.nextSibling.parentNode
? h.insertBefore(f, m.nextSibling)
: p && p.parentNode
? h.contains(p)
? h.insertBefore(f, p)
: h.insertBefore(f, null)
: h.appendChild(f),
b(f, c.node.id),
this.usingVirtualDom &&
f.nodeName === "#text" &&
h.nodeName === "STYLE" &&
((d = h.rules) == null ? void 0 : d.length) > 0 &&
(h.rules = []),
ke(f, this.mirror))
) {
const g = this.mirror.getId(f),
C = this.newDocumentQueue.find((M) => M.parentId === g);
C &&
(this.attachDocumentToIframe(C, f),
(this.newDocumentQueue = this.newDocumentQueue.filter(
(M) => M !== C
)));
}
(c.previousId || c.nextId) &&
this.legacy_resolveMissingNode(o, h, f, c);
};
e.adds.forEach((c) => {
l(c);
});
const s = Date.now();
for (; a.length; ) {
const c = nr(a);
if (((a.length = 0), Date.now() - s > 500)) {
this.warn(
"Timeout in the loop, please check the resolve tree data:",
c
);
break;
}
for (const u of c)
n.getNode(u.value.parentId)
? wt(u, (d) => {
l(d);
})
: this.debug(
"Drop resolve tree since there is no parent for the root node.",
u
);
}
Object.keys(o).length &&
Object.assign(this.legacy_missingNodeRetryMap, o),
or(e.texts).forEach((c) => {
var u;
const d = n.getNode(c.id);
if (!d)
return e.removes.find((h) => h.id === c.id)
? void 0
: this.warnNodeNotFound(e, c.id);
if (((d.textContent = c.value), this.usingVirtualDom)) {
const h = d.parentNode;
((u = h?.rules) == null ? void 0 : u.length) > 0 && (h.rules = []);
}
}),
e.attributes.forEach((c) => {
const u = n.getNode(c.id);
if (!u)
return e.removes.find((d) => d.id === c.id)
? void 0
: this.warnNodeNotFound(e, c.id);
for (const d in c.attributes)
if (typeof d == "string") {
const h = c.attributes[d];
if (h === null) u.removeAttribute(d);
else if (typeof h == "string")
try {
if (
d === "_cssText" &&
(u.nodeName === "LINK" || u.nodeName === "STYLE")
)
try {
const m = n.getMeta(u);
Object.assign(m.attributes, c.attributes);
const p = Ue(m, {
doc: u.ownerDocument,
mirror: n,
skipChild: !0,
hackCss: !0,
cache: this.cache,
}),
v = u.nextSibling,
b = u.parentNode;
if (p && b) {
b.removeChild(u),
b.insertBefore(p, v),
n.replace(c.id, p);
break;
}
} catch {}
u.setAttribute(d, h);
} catch (m) {
this.warn(
"An error occurred may due to the checkout feature.",
m
);
}
else if (d === "style") {
const m = h,
p = u;
for (const v in m)
if (m[v] === !1) p.style.removeProperty(v);
else if (m[v] instanceof Array) {
const b = m[v];
p.style.setProperty(v, b[0], b[1]);
} else {
const b = m[v];
p.style.setProperty(v, b);
}
}
}
});
}
applyScroll(e, r) {
var n, o;
const a = this.mirror.getNode(e.id);
if (!a) return this.debugNodeNotFound(e, e.id);
const i = this.mirror.getMeta(a);
if (a === this.iframe.contentDocument)
(n = this.iframe.contentWindow) == null ||
n.scrollTo({ top: e.y, left: e.x, behavior: r ? "auto" : "smooth" });
else if (i?.type === N.Document)
(o = a.defaultView) == null ||
o.scrollTo({ top: e.y, left: e.x, behavior: r ? "auto" : "smooth" });
else
try {
a.scrollTo({ top: e.y, left: e.x, behavior: r ? "auto" : "smooth" });
} catch {}
}
applyInput(e) {
const r = this.mirror.getNode(e.id);
if (!r) return this.debugNodeNotFound(e, e.id);
try {
(r.checked = e.isChecked), (r.value = e.text);
} catch {}
}
applySelection(e) {
try {
const r = new Set(),
n = e.ranges.map(
({ start: o, startOffset: a, end: i, endOffset: l }) => {
const s = this.mirror.getNode(o),
c = this.mirror.getNode(i);
if (!s || !c) return;
const u = new Range();
u.setStart(s, a), u.setEnd(c, l);
const d = s.ownerDocument,
h = d?.getSelection();
return h && r.add(h), { range: u, selection: h };
}
);
r.forEach((o) => o.removeAllRanges()),
n.forEach((o) => {
var a;
return (
o && ((a = o.selection) == null ? void 0 : a.addRange(o.range))
);
});
} catch {}
}
applyStyleSheetMutation(e) {
var r;
let n = null;
e.styleId
? (n = this.styleMirror.getStyle(e.styleId))
: e.id &&
(n =
((r = this.mirror.getNode(e.id)) == null ? void 0 : r.sheet) ||
null),
n &&
(e.source === E.StyleSheetRule
? this.applyStyleSheetRule(e, n)
: e.source === E.StyleDeclaration &&
this.applyStyleDeclaration(e, n));
}
applyStyleSheetRule(e, r) {
var n, o, a, i;
if (
((n = e.adds) == null ||
n.forEach(({ rule: l, index: s }) => {
try {
if (Array.isArray(s)) {
const { positions: c, index: u } = Tt(s);
Re(r.cssRules, c).insertRule(l, u);
} else {
const c =
s === void 0 ? void 0 : Math.min(s, r.cssRules.length);
r?.insertRule(l, c);
}
} catch {}
}),
(o = e.removes) == null ||
o.forEach(({ index: l }) => {
try {
if (Array.isArray(l)) {
const { positions: s, index: c } = Tt(l);
Re(r.cssRules, s).deleteRule(c || 0);
} else r?.deleteRule(l);
} catch {}
}),
e.replace)
)
try {
(a = r.replace) == null || a.call(r, e.replace);
} catch {}
if (e.replaceSync)
try {
(i = r.replaceSync) == null || i.call(r, e.replaceSync);
} catch {}
}
applyStyleDeclaration(e, r) {
e.set &&
Re(r.rules, e.index).style.setProperty(
e.set.property,
e.set.value,
e.set.priority
),
e.remove &&
Re(r.rules, e.index).style.removeProperty(e.remove.property);
}
applyAdoptedStyleSheet(e) {
var r;
const n = this.mirror.getNode(e.id);
if (!n) return;
(r = e.styles) == null ||
r.forEach((l) => {
var s;
let c = null,
u = null;
if (
(ve(n)
? (u =
((s = n.ownerDocument) == null ? void 0 : s.defaultView) ||
null)
: n.nodeName === "#document" && (u = n.defaultView),
!!u)
)
try {
(c = new u.CSSStyleSheet()),
this.styleMirror.add(c, l.styleId),
this.applyStyleSheetRule(
{ source: E.StyleSheetRule, adds: l.rules },
c
);
} catch {}
});
const o = 10;
let a = 0;
const i = (l, s) => {
const c = s
.map((u) => this.styleMirror.getStyle(u))
.filter((u) => u !== null);
ve(l)
? (l.shadowRoot.adoptedStyleSheets = c)
: l.nodeName === "#document" && (l.adoptedStyleSheets = c),
c.length !== s.length &&
a < o &&
(setTimeout(() => i(l, s), 0 + 100 * a), a++);
};
i(n, e.styleIds);
}
legacy_resolveMissingNode(e, r, n, o) {
const { previousId: a, nextId: i } = o,
l = a && e[a],
s = i && e[i];
if (l) {
const { node: c, mutation: u } = l;
r.insertBefore(c, n),
delete e[u.node.id],
delete this.legacy_missingNodeRetryMap[u.node.id],
(u.previousId || u.nextId) &&
this.legacy_resolveMissingNode(e, r, c, u);
}
if (s) {
const { node: c, mutation: u } = s;
r.insertBefore(c, n.nextSibling),
delete e[u.node.id],
delete this.legacy_missingNodeRetryMap[u.node.id],
(u.previousId || u.nextId) &&
this.legacy_resolveMissingNode(e, r, c, u);
}
}
moveAndHover(e, r, n, o, a) {
const i = this.mirror.getNode(n);
if (!i) return this.debugNodeNotFound(a, n);
const l = Et(i, this.iframe),
s = e * l.absoluteScale + l.x,
c = r * l.absoluteScale + l.y;
(this.mouse.style.left = `${s}px`),
(this.mouse.style.top = `${c}px`),
o || this.drawMouseTail({ x: s, y: c }),
this.hoverElements(i);
}
drawMouseTail(e) {
if (!this.mouseTail) return;
const {
lineCap: r,
lineWidth: n,
strokeStyle: o,
duration: a,
} = this.config.mouseTail === !0
? Ut
: Object.assign({}, Ut, this.config.mouseTail),
i = () => {
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 = n),
(l.lineCap = r),
(l.strokeStyle = o),
l.moveTo(this.tailPositions[0].x, this.tailPositions[0].y),
this.tailPositions.forEach((s) => l.lineTo(s.x, s.y)),
l.stroke());
};
this.tailPositions.push(e),
i(),
setTimeout(() => {
(this.tailPositions = this.tailPositions.filter((l) => l !== e)), i();
}, a / this.speedService.state.context.timer.speed);
}
hoverElements(e) {
var r;
(r = this.lastHoveredRootNode || this.iframe.contentDocument) == null ||
r.querySelectorAll(".\\:hover").forEach((o) => {
o.classList.remove(":hover");
}),
(this.lastHoveredRootNode = e.getRootNode());
let n = e;
for (; n; )
n.classList && n.classList.add(":hover"), (n = n.parentElement);
}
isUserInteraction(e) {
return e.type !== T.IncrementalSnapshot
? !1
: e.data.source > E.Mutation && e.data.source <= E.Input;
}
backToNormal() {
(this.nextUserInteractionEvent = null),
!this.speedService.state.matches("normal") &&
(this.speedService.send({ type: "BACK_TO_NORMAL" }),
this.emitter.emit(A.SkipEnd, {
speed: this.speedService.state.context.normalSpeed,
}));
}
warnNodeNotFound(e, r) {
this.warn(`Node with id '${r}' not found. `, e);
}
warnCanvasMutationFailed(e, r) {
this.warn("Has error on canvas update", r, "canvas mutation:", e);
}
debugNodeNotFound(e, r) {
this.debug(`Node with id '${r}' not found. `, e);
}
warn(...e) {
!this.config.showWarning || this.config.logger.warn(dn, ...e);
}
debug(...e) {
!this.config.showDebug || this.config.logger.log(dn, ...e);
}
}
const { addCustomEvent: Ks } = Ce,
{ freezePage: Js } = Ce;
return (
(re.EventType = T),
(re.IncrementalSource = E),
(re.MouseInteractions = L),
(re.Replayer = Zs),
(re.ReplayerEvents = A),
(re.addCustomEvent = Ks),
(re.freezePage = Js),
(re.record = Ce),
(re.utils = Zn),
Object.defineProperty(re, "__esModule", { value: !0 }),
re
);
})({});
//# sourceMappingURL=rrweb.min.js.map
// Betterlytics
(function () {
if (window.__betterlytics_replay_initialized__) {
return;
}
var handoff = window.__betterlytics_replay_config__;
if (!handoff || !handoff.siteId || !handoff.serverUrl || !handoff.script) {
// A cached analytics.js older than the handoff still writes data-server-url onto its own tag before loading us
var legacyScript = document.querySelector(
"script[data-site-id][data-server-url]"
);
if (!legacyScript) {
console.warn(
"Betterlytics: replay.js needs a newer analytics.js; replay disabled"
);
return;
}
handoff = {
siteId: legacyScript.getAttribute("data-site-id"),
serverUrl: legacyScript.getAttribute("data-server-url"),
script: legacyScript,
};
}
window.__betterlytics_replay_initialized__ = true;
var script = handoff.script;
var siteId = handoff.siteId;
var serverUrl = handoff.serverUrl;
var urlPatterns =
script
.getAttribute("data-dynamic-urls")
?.split(",")
.map(function (p) {
p = p.trim();
return {
original: p,
regex: new RegExp(
`^${p.replace(/\*\*/g, "(.+)").replace(/\*/g, "([^/]+)")}`
),
};
}) ?? [];
var disableReplayOnUrls =
script
.getAttribute("data-disable-replay-on-urls")
?.split(",")
.map(function (p) {
p = p.trim();
return {
original: p,
regex: new RegExp(
`^${p.replace(/\*\*/g, "(.+)").replace(/\*/g, "([^/]+)")}`
),
};
}) ?? [];
var minReplayDurationSec = parseInt(
script.getAttribute("data-replay-min-duration") || "15",
10
);
var idleCutoffMs = (function () {
var secs = parseInt(
script.getAttribute("data-replay-idle-cutoff") || "600",
10
);
if (isNaN(secs) || secs < 1) secs = 600;
return secs * 1000;
})();
var maxDurationMs = (function () {
var secs = parseInt(
script.getAttribute("data-replay-max-duration") || "1200",
10
);
if (isNaN(secs) || secs < 1) secs = 1200;
return secs * 1000;
})();
if (isNaN(minReplayDurationSec) || minReplayDurationSec < 0) {
minReplayDurationSec = 0;
}
var apiBase = null;
try {
apiBase = new URL(serverUrl).origin;
} catch (e) {}
var enableReplayOnError = script.getAttribute("data-replay-on-error") === "true";
var isSampledRecording = window.__betterlytics_replay_sampled__ === true;
// Track current path for SPA navigation
var currentPath = window.location.pathname;
function normalize(url) {
var urlObj = new URL(url);
var pathname = urlObj.pathname;
for (var i = 0; i < urlPatterns.length; i++) {
var match = urlPatterns[i].regex.exec(pathname);
if (match) {
var normalizedPath = `${urlPatterns[i].original.replace(
/\*\*/g,
"*"
)}${pathname.slice(match[0].length)}`;
return `${urlObj.origin}${normalizedPath}${urlObj.search}${urlObj.hash}`;
}
}
return url;
}
// Recordings keep only origin plus normalized path; normalize leaves the query string and hash
function normalizePageUrl(url) {
var urlObj = new URL(normalize(url));
return urlObj.origin + urlObj.pathname;
}
const cacheIsReplayEnabledOnPage = new Map();
function isReplayEnabledOnPage() {
var pathname = window.location.pathname;
if (cacheIsReplayEnabledOnPage.has(pathname)) {
return cacheIsReplayEnabledOnPage.get(pathname);
}
for (var i = 0; i < disableReplayOnUrls.length; i++) {
var match = disableReplayOnUrls[i].regex.exec(pathname);
if (match) {
cacheIsReplayEnabledOnPage.set(pathname, false);
return false;
}
}
cacheIsReplayEnabledOnPage.set(pathname, true);
return true;
}
// Emit a rrweb custom event for pageview and optionally force a full snapshot (useful for SPA route changes)
function emitReplayPageview(url, takeSnapshot) {
try {
if (window.rrweb && window.rrweb.record) {
if (typeof window.rrweb.record.addCustomEvent === "function") {
window.rrweb.record.addCustomEvent("Pageview", {
url: normalizePageUrl(url),
});
}
if (
takeSnapshot &&
typeof window.rrweb.record.takeFullSnapshot === "function"
) {
window.rrweb.record.takeFullSnapshot();
}
}
} catch (_) {}
}
function emitReplayBlacklist() {
try {
if (window.rrweb && window.rrweb.record) {
if (typeof window.rrweb.record.addCustomEvent === "function") {
window.rrweb.record.addCustomEvent("Blacklist", {});
}
}
} catch {}
}
function encodeReplayChunk(json) {
var encoder = new TextEncoder();
var rawBytes = encoder.encode(json);
if (typeof CompressionStream === "undefined") {
return Promise.resolve({ bytes: rawBytes, encoding: null });
}
try {
var stream = new CompressionStream("gzip");
var writable = stream.writable.getWriter();
writable.write(rawBytes);
writable.close();
return new Response(stream.readable)
.arrayBuffer()
.then(function (buf) {
return { bytes: new Uint8Array(buf), encoding: "gzip" };
})
.catch(function () {
return { bytes: rawBytes, encoding: null };
});
} catch (e) {
return Promise.resolve({ bytes: rawBytes, encoding: null });
}
}
(function initSessionReplay() {
if (!apiBase) return;
var pageNonce = Math.random().toString(36).slice(2, 8);
var state = {
initialized: false,
recordingStop: null,
isRecording: false,
disabled: false,
buffer: [],
bufferSizes: [],
approxBytes: 0,
startedAt: Date.now(),
lastActivity: Date.now(),
flushTimer: null,
holdTimer: null,
ongoingFlush: null,
flushRequested: false,
stopping: false,
consecutiveFlushErrors: 0,
chunkSeq: 0,
retryQueue: [],
errorMatrix: [[]],
errorCheckoutTimer: null,
errorLastFlushAt: 0,
errorFlushPending: false,
rageBurst: null,
rageTimer: null,
// First page recorded in this page load; every segment reports it as the replay's start URL
startUrl: null,
};
var config = {
maxChunkMs: 20000,
maxUncompressedBytes: 256 * 1024,
maxConsecutiveFlushErrors: 3,
};
var errorSourcesByEvent = new WeakMap();
var MAX_ERROR_METADATA_BYTES = 256 * 1024;
var MAX_ERROR_SOURCES = 128;
var MAX_ERROR_SOURCE_BYTES = 16 * 1024;
// A rage click is a burst of clicks, each close to and soon after the previous one
var RAGE_CLICK_MIN_CLICKS = 3;
var RAGE_CLICK_MAX_DISTANCE_PX = 30;
var RAGE_CLICK_MAX_GAP_MS = 1000;
var RAGE_CLICK_MAX_SELECTOR_CHARS = 200;
function hasReachedMinDuration() {
if (!minReplayDurationSec) return true;
return (
Math.floor((Date.now() - state.startedAt) / 1000) >=
minReplayDurationSec
);
}
function uploadSegment(payload) {
var qs =
"site_id=" +
encodeURIComponent(siteId) +
"&url=" +
encodeURIComponent(state.startUrl || normalizePageUrl(window.location.href)) +
"&screen_resolution=" +
window.screen.width +
"x" +
window.screen.height;
if (payload.startedAtMs) {
qs += "&started_at_ms=" + payload.startedAtMs;
}
if (payload.lastEventTs) {
qs += "&ended_at_ms=" + payload.lastEventTs;
}
qs += "&event_count=" + payload.eventCount;
if (payload.rageClickCount) {
qs += "&rage_click_count=" + payload.rageClickCount;
}
qs += "&chunk_id=" + encodeURIComponent(payload.chunkId);
if (payload.encoding === "gzip") {
qs += "&encoding=gzip";
}
if (payload.format) {
qs += "&format=" + payload.format;
}
return fetch(apiBase + "/replay/segment?" + qs, {
method: "POST",
body: payload.bytes,
// keepalive lets the request finish after page unload; browsers cap keepalive bodies at ~64KB
keepalive: payload.bytes.byteLength <= 60000,
}).then(function (r) {
if (!r || r.status >= 400) {
var err = new Error();
err.status = r ? r.status : 0;
throw err;
}
});
}
function handleFlushError(chunk, err) {
var terminal = err && err.status >= 400 && err.status < 500;
state.consecutiveFlushErrors += 1;
if (terminal || state.consecutiveFlushErrors >= config.maxConsecutiveFlushErrors) {
state.disabled = true;
state.buffer = [];
state.bufferSizes = [];
state.approxBytes = 0;
state.retryQueue = [];
try {
stopRecording();
} catch (_) {}
} else if (state.retryQueue.indexOf(chunk) === -1) {
state.retryQueue.push(chunk);
}
}
function collectChunkErrors(events) {
var encoder = new TextEncoder();
var entries = [];
var bySource = new Map();
var budget = 2;
events.forEach(function (event) {
var raw = errorSourcesByEvent.get(event);
if (typeof raw !== "string" || encoder.encode(raw).byteLength > MAX_ERROR_SOURCE_BYTES) return;
var prior = bySource.get(raw);
if (prior) {
prior.count = Math.min(4294967295, prior.count + 1);
return;
}
var entry = { error_exceptions: raw, count: 1 };
var cost = encoder.encode(JSON.stringify(entry)).byteLength + 1 + 9;
if (entries.length >= MAX_ERROR_SOURCES || budget + cost > MAX_ERROR_METADATA_BYTES) return;
entries.push(entry);
bySource.set(raw, entry);
budget += cost;
});
return entries;
}
function countRageClicks(events) {
var count = 0;
events.forEach(function (event) {
if (event.type === 5 && event.data && event.data.tag === "rage_click") count++;
});
return count;
}
function buildChunk(events, lastEventTs, startedAtMs) {
var seq = state.chunkSeq++;
var chunkId = pageNonce + "-" + (seq < 10000 ? ("000" + seq).slice(-4) : seq);
var errors = collectChunkErrors(events);
var rageClickCount = countRageClicks(events);
return encodeReplayChunk(JSON.stringify(events)).then(function (enc) {
if (errors.length) {
var metadata = new TextEncoder().encode(JSON.stringify(errors));
var body = new Uint8Array(4 + metadata.byteLength + enc.bytes.byteLength);
new DataView(body.buffer).setUint32(0, metadata.byteLength, false);
body.set(metadata, 4);
body.set(enc.bytes, 4 + metadata.byteLength);
enc.bytes = body;
enc.format = "errors_v1";
}
enc.lastEventTs = lastEventTs;
enc.startedAtMs = startedAtMs || state.startedAt;
enc.eventCount = events.length;
enc.rageClickCount = rageClickCount;
enc.chunkId = chunkId;
return enc;
});
}
function sendChunk(chunk) {
return uploadSegment(chunk).then(
function () {
state.consecutiveFlushErrors = 0;
var idx = state.retryQueue.indexOf(chunk);
if (idx !== -1) state.retryQueue.splice(idx, 1);
},
function (err) {
try {
handleFlushError(chunk, err);
} catch (_) {}
}
);
}
function buildEventsChunk(events) {
var lastEventTs = state.lastActivity;
var last = events[events.length - 1];
if (last && typeof last.timestamp === "number") {
lastEventTs = last.timestamp;
}
var firstEventTs = lastEventTs;
var first = events[0];
if (first && typeof first.timestamp === "number") {
firstEventTs = first.timestamp;
}
return buildChunk(events, lastEventTs, firstEventTs);
}
// Number of leading events that fit in one chunk; an event over the target goes alone.
// A Meta event always shares its chunk with the full snapshot after it, since the player
// needs both in the first segment it loads.
function chunkLength(events, sizes) {
var count = 0;
var bytes = 0;
while (
count < sizes.length &&
(count === 0 || bytes + sizes[count] <= config.maxUncompressedBytes)
) {
bytes += sizes[count];
count++;
}
if (count < events.length && events[count - 1] && events[count - 1].type === 4) {
count++;
}
return count;
}
function flush(force) {
if (state.disabled) return Promise.resolve();
if (state.ongoingFlush && !force) {
state.flushRequested = true;
return state.ongoingFlush;
}
var pending;
var leftBehind = false;
if (state.retryQueue.length > 0) {
pending = Promise.resolve(state.retryQueue[0]);
} else {
if (state.buffer.length === 0) return Promise.resolve();
if (!hasReachedMinDuration()) return Promise.resolve();
var count = chunkLength(state.buffer, state.bufferSizes);
var events = state.buffer.splice(0, count);
state.bufferSizes.splice(0, count).forEach(function (size) {
state.approxBytes -= size;
});
if (state.buffer.length === 0) state.approxBytes = 0;
leftBehind = state.buffer.length > 0;
pending = buildEventsChunk(events);
}
state.flushRequested = false;
var upload = pending
.then(sendChunk)
.finally(function () {
if (state.ongoingFlush === upload) state.ongoingFlush = null;
});
state.ongoingFlush = upload;
// Keep uploading back to back while a backlog remains, e.g. right after the hold ends
return upload.then(function () {
if (state.disabled || state.retryQueue.length > 0) return;
if (
leftBehind ||
state.flushRequested ||
state.approxBytes >= config.maxUncompressedBytes
) {
return flush();
}
});
}
function flushAll() {
return flush().then(function () {
if (state.disabled) return;
if (!hasReachedMinDuration()) return;
if (state.buffer.length === 0 && state.retryQueue.length === 0) return;
return new Promise(function (r) {
try {
setTimeout(r, 0);
} catch (_) {
r();
}
}).then(flushAll);
});
}
function stopFlushTimer() {
if (state.flushTimer) {
clearInterval(state.flushTimer);
state.flushTimer = null;
}
if (state.holdTimer) {
clearTimeout(state.holdTimer);
state.holdTimer = null;
}
}
function startFlushLoop() {
stopFlushTimer();
state.flushTimer = setInterval(function () {
if (Date.now() - state.lastActivity > idleCutoffMs) {
stopRecording();
return;
}
if (Date.now() - state.startedAt > maxDurationMs) {
stopRecording();
return;
}
if (state.buffer.length > 0 || state.retryQueue.length > 0) {
flush();
}
}, Math.max(3000, config.maxChunkMs));
if (minReplayDurationSec) {
state.holdTimer = setTimeout(function () {
state.holdTimer = null;
if (state.buffer.length > 0) flush();
}, Math.max(0, state.startedAt + minReplayDurationSec * 1000 - Date.now()) + 100);
}
}
var ERROR_CHECKOUT_INTERVAL_MS = 60 * 1000;
function startErrorCheckoutTimer() {
if (state.errorCheckoutTimer) clearInterval(state.errorCheckoutTimer);
state.errorCheckoutTimer = setInterval(function () {
if (window.rrweb && window.rrweb.record && typeof window.rrweb.record.takeFullSnapshot === 'function') {
window.rrweb.record.takeFullSnapshot(true);
}
}, ERROR_CHECKOUT_INTERVAL_MS);
}
function stopErrorCheckoutTimer() {
if (state.errorCheckoutTimer) {
clearInterval(state.errorCheckoutTimer);
state.errorCheckoutTimer = null;
}
}
function flushErrorMatrix() {
if (state.disabled) return Promise.resolve();
state.errorFlushPending = false;
state.errorLastFlushAt = Date.now();
if (state.retryQueue.length > 0) {
return sendChunk(state.retryQueue[0]).catch(function () {});
}
// An open burst would otherwise land in a fresh buffer that may never be uploaded
if (state.rageBurst) emitRageBurst(state.rageBurst);
var events = state.errorMatrix[0].concat(state.errorMatrix[1] || []);
if (events.length === 0) return Promise.resolve();
// The ring buffer drops its oldest pages; start the replay at the checkout Meta that opens it
if (events[0].type === 4) state.startUrl = events[0].data.href;
state.errorMatrix = [[]];
var sizes = events.map(function (e) {
return estimateEventSize(e) + 1;
});
var groups = [];
while (events.length > 0) {
var count = chunkLength(events, sizes);
sizes.splice(0, count);
groups.push(events.splice(0, count));
}
return groups
.reduce(function (prev, group) {
return prev.then(function () {
if (state.disabled) return;
return buildEventsChunk(group).then(sendChunk);
});
}, Promise.resolve())
.catch(function () {});
}
function notifyError(errorType, errorExceptionsJson) {
// Recording is stopped here, so an upload would hold no error marker
if (!isReplayEnabledOnPage()) return;
try {
if (window.rrweb && typeof window.rrweb.record.addCustomEvent === "function") {
var parsed = null;
try { parsed = JSON.parse(errorExceptionsJson); } catch (_) {}
window.rrweb.record.addCustomEvent("client_error", {
type: errorType,
message: (parsed && parsed[0] && parsed[0].value) || "",
__betterlyticsErrorExceptions: errorExceptionsJson,
});
}
} catch (_) {}
var now = Date.now();
if (now - state.errorLastFlushAt < 10000) return;
state.errorLastFlushAt = now;
state.errorFlushPending = true;
var timer = null;
function doFlush() {
if (!state.errorFlushPending) return;
state.errorFlushPending = false;
if (timer) { clearTimeout(timer); timer = null; }
window.removeEventListener("beforeunload", doFlush);
if (isSampledRecording) {
flush();
} else if (enableReplayOnError) {
flushErrorMatrix();
}
}
window.addEventListener("beforeunload", doFlush);
timer = setTimeout(doFlush, 3000);
}
function stopRecording() {
if (state.stopping) return;
state.stopping = true;
endRageBurst();
try {
if (state.recordingStop) {
state.recordingStop();
state.recordingStop = null;
}
} catch (e) {}
stopFlushTimer();
stopErrorCheckoutTimer();
flushAll()
.catch(function () {})
.finally(function () {
state.initialized = false;
state.isRecording = false;
state.stopping = false;
});
}
function estimateEventSize(ev) {
try {
return JSON.stringify(ev).length | 0;
} catch (_) {
return 0;
}
}
function shortSelector(node) {
var el = node && node.nodeType === 1 ? node : node && node.parentElement;
var parts = [];
while (el && el.nodeType === 1 && parts.length < 3) {
var part = el.tagName.toLowerCase();
if (el.id) {
parts.unshift(part + "#" + el.id);
break;
}
var classes =
typeof el.className === "string"
? el.className.trim().split(/\s+/).filter(Boolean).slice(0, 2)
: [];
if (classes.length) part += "." + classes.join(".");
parts.unshift(part);
if (part === "body" || part === "html") break;
el = el.parentElement;
}
return parts.join(" > ").slice(0, RAGE_CLICK_MAX_SELECTOR_CHARS);
}
function endRageBurst() {
if (state.rageTimer) {
clearTimeout(state.rageTimer);
state.rageTimer = null;
}
var burst = state.rageBurst;
state.rageBurst = null;
if (burst) emitRageBurst(burst);
}
// Emits once per burst; a burst emitted early stays open so later clicks still extend it
function emitRageBurst(burst) {
if (burst.emitted || burst.clickCount < RAGE_CLICK_MIN_CLICKS) return;
burst.emitted = true;
try {
if (window.rrweb && typeof window.rrweb.record.addCustomEvent === "function") {
window.rrweb.record.addCustomEvent("rage_click", {
timestamp: burst.firstTs,
x: burst.x,
y: burst.y,
clickCount: burst.clickCount,
selector: burst.selector,
});
}
} catch (_) {}
}
function trackClick(e) {
var data = e.data;
if (typeof data.x !== "number" || typeof data.y !== "number") return;
// Clicks from the keyboard or el.click() have no position
if (data.x === 0 && data.y === 0) return;
var burst = state.rageBurst;
var continues =
burst &&
e.timestamp - burst.lastTs <= RAGE_CLICK_MAX_GAP_MS &&
Math.abs(data.x - burst.lastX) + Math.abs(data.y - burst.lastY) <=
RAGE_CLICK_MAX_DISTANCE_PX;
if (continues) {
burst.clickCount++;
burst.lastTs = e.timestamp;
burst.lastX = data.x;
burst.lastY = data.y;
if (burst.clickCount === RAGE_CLICK_MIN_CLICKS) {
// The first click's element may already be gone from the mirror
var node = null;
try {
node = window.rrweb.record.mirror.getNode(data.id);
} catch (_) {}
burst.selector = shortSelector(node);
}
} else {
endRageBurst();
state.rageBurst = {
firstTs: e.timestamp,
lastTs: e.timestamp,
x: data.x,
y: data.y,
lastX: data.x,
lastY: data.y,
clickCount: 1,
selector: "",
};
}
if (state.rageTimer) clearTimeout(state.rageTimer);
state.rageTimer = setTimeout(endRageBurst, RAGE_CLICK_MAX_GAP_MS);
}
function handleRecordingEmit(e, isCheckout) {
// Rage clicks are only built from clicks recorded on an enabled page, so a burst
// flushed on navigation to a disabled page still gets through
if (
isReplayEnabledOnPage() === false &&
(e.type == 5 && (e.data.tag === "Blacklist" || e.data.tag === "rage_click")) === false
) {
return;
}
if (e.type === 5 && e.data.tag === "client_error" && e.data.payload) {
var raw = e.data.payload.__betterlyticsErrorExceptions;
if (typeof raw === "string") errorSourcesByEvent.set(e, raw);
delete e.data.payload.__betterlyticsErrorExceptions;
}
if (e.type === 4 && e.data && typeof e.data.href === "string") {
e.data.href = normalizePageUrl(e.data.href);
}
state.lastActivity = Math.max(state.lastActivity, e.timestamp);
if (isSampledRecording) {
// Case 1: push to regular buffer, periodic S3 flushes.
var size = estimateEventSize(e) + 1;
state.buffer.push(e);
state.bufferSizes.push(size);
state.approxBytes += size;
if (state.approxBytes >= config.maxUncompressedBytes) {
flush();
}
} else if (enableReplayOnError) {
// Case 2: maintain two-segment ring buffer, no periodic flushes.
// Rotate on the checkout's Meta so each segment starts with Meta + FullSnapshot.
if (isCheckout && e.type === 4) {
state.errorMatrix.push([]);
if (state.errorMatrix.length > 2) state.errorMatrix.shift();
}
state.errorMatrix[state.errorMatrix.length - 1].push(e);
}
// IncrementalSnapshot > MouseInteraction > Click; taps also produce a click
if (e.type === 3 && e.data.source === 2 && e.data.type === 2) {
trackClick(e);
}
}
function startRecording() {
// A deferred start can land after an in-app move to a page with replay turned off
if (!window.rrweb || state.initialized || state.disabled || !isReplayEnabledOnPage()) {
return;
}
state.initialized = true;
state.startedAt = Date.now();
state.lastActivity = Date.now();
var isCoarsePointer = false;
try {
isCoarsePointer = !!(
window.matchMedia && window.matchMedia("(pointer: coarse)").matches
);
} catch (_) {}
state.recordingStop = window.rrweb.record({
emit: handleRecordingEmit,
checkoutEveryNms: isSampledRecording ? 5 * 60 * 1000 : undefined,
maskAllInputs: true,
maskInputOptions: {
text: true,
password: true,
email: true,
number: true,
tel: true,
textArea: true,
select: true,
search: true,
},
blockClass: "rr-block",
ignoreClass: "rr-ignore",
maskTextSelector: `
input[type=password],
[data-rrweb-mask],
[contenteditable="true"],
*
`,
blockSelector:
"svg[class^='recharts'], svg[class*=' recharts'], .recharts-wrapper, img, iframe",
slimDOMOptions: {
script: true,
comment: true,
headFavicon: true,
headWhitespace: true,
headMetaDescKeywords: true,
headMetaSocial: true,
headMetaRobots: true,
headMetaHttpEquiv: true,
headMetaAuthorship: true,
headMetaVerification: true,
},
sampling: {
mousemove: isCoarsePointer ? false : 120,
input: "last",
media: 1000,
scroll: 150,
mouseInteraction: true,
},
});
if (!state.startUrl) state.startUrl = normalizePageUrl(window.location.href);
emitReplayPageview(window.location.href, false);
if (isSampledRecording) {
startFlushLoop();
} else if (enableReplayOnError) {
startErrorCheckoutTimer();
}
state.isRecording = true;
}
function startRecordingDeferred() {
let started = false;
function doStart() {
if (started) return;
started = true;
try {
startRecording();
} catch (_) {}
}
const root = document.body || document.documentElement;
if (!root) {
setTimeout(doStart, 0);
return;
}
const observer = new MutationObserver((mutations) => {
if (mutations && mutations.length > 0) {
observer.disconnect();
requestAnimationFrame(() => {
requestAnimationFrame(doStart);
});
}
});
observer.observe(root, { childList: true, subtree: true });
setTimeout(() => {
observer.disconnect();
doStart();
}, 1000);
}
function handleNavigationChange() {
if (currentPath === window.location.pathname) return;
currentPath = window.location.pathname;
if (isReplayEnabledOnPage()) {
if (state.isRecording === false) {
startRecordingDeferred();
} else {
// Send the previous page's events first, so the new full snapshot starts its own chunk
if (isSampledRecording) flush();
emitReplayPageview(window.location.href, true);
}
} else {
// Emit a burst from the previous page before the blacklist hides it
endRageBurst();
emitReplayBlacklist();
stopRecording();
}
}
function setupEventListeners() {
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "hidden") {
endRageBurst();
flush(true);
}
});
window.addEventListener("beforeunload", function () {
stopRecording();
});
window.addEventListener("pagehide", function () {
stopRecording();
});
if (window.history.pushState) {
var originalPushState = history.pushState;
history.pushState = function () {
originalPushState.apply(this, arguments);
handleNavigationChange();
};
window.addEventListener("popstate", handleNavigationChange);
if (window.history.replaceState) {
var originalReplaceState = history.replaceState;
history.replaceState = function () {
originalReplaceState.apply(this, arguments);
handleNavigationChange();
};
}
}
}
window.__betterlytics_replay__ = {
stop: function () { stopRecording(); },
notifyError: notifyError,
};
setupEventListeners();
if (isReplayEnabledOnPage()) {
startRecordingDeferred();
} else {
emitReplayBlacklist();
stopRecording();
}
})();
})();