@sprig-technologies/sprig-bundled
Version:
npm package for the sprig web sdk with bundled dependencies
1,058 lines (1,057 loc) • 369 kB
JavaScript
var fd = Object.defineProperty;
var gd = (e, t, r) => t in e ? fd(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var ue = (e, t, r) => gd(e, typeof t != "symbol" ? t + "" : t, r);
var yd = Object.create, lo = Object.defineProperty, wd = Object.getOwnPropertyDescriptor, vd = Object.getOwnPropertyNames, bd = Object.getPrototypeOf, Sd = Object.prototype.hasOwnProperty, hr = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Id = hr((e, t) => {
var r;
r = typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, t.exports = r;
}), Cd = hr((e, t) => {
t.exports = function(n) {
if (!n) return !1;
var s = r.call(n);
return s === "[object Function]" || typeof n == "function" && s !== "[object RegExp]" || typeof window < "u" && (n === window.setTimeout || n === window.alert || n === window.confirm || n === window.prompt);
};
var r = Object.prototype.toString;
}), kd = hr((e, t) => {
var r = function(s) {
return s.replace(/^\s+|\s+$/g, "");
}, n = function(s) {
return Object.prototype.toString.call(s) === "[object Array]";
};
t.exports = function(s) {
if (!s) return {};
for (var i = {}, a = r(s).split(`
`), o = 0; o < a.length; o++) {
var l = a[o], c = l.indexOf(":"), u = r(l.slice(0, c)).toLowerCase(), d = r(l.slice(c + 1));
i[u] === void 0 ? i[u] = d : n(i[u]) ? i[u].push(d) : i[u] = [i[u], d];
}
return i;
};
}), Ed = hr((e, t) => {
t.exports = function() {
for (var n = {}, s = 0; s < arguments.length; s++) {
var i = arguments[s];
for (var a in i) r.call(i, a) && (n[a] = i[a]);
}
return n;
};
var r = Object.prototype.hasOwnProperty;
}), xd = hr((e, t) => {
var r = Id(), n = Cd(), s = kd(), i = Ed();
function a(c, u, d) {
var p = c;
return n(u) ? (d = u, typeof c == "string" && (p = { uri: c })) : p = i(u, { uri: c }), p.callback = d, p;
}
function o(c, u, d) {
return l(u = a(c, u, d));
}
function l(c) {
if (c.callback === void 0) throw new Error("callback argument missing");
var u = !1, d = function(R, O, S) {
u || (u = !0, c.callback(R, O, S));
};
function p() {
var R = void 0;
if (R = h.response ? h.response : h.responseText || function(O) {
try {
if (O.responseType === "document") return O.responseXML;
var S = O.responseXML && O.responseXML.documentElement.nodeName === "parsererror";
if (O.responseType === "" && !S) return O.responseXML;
} catch {
}
return null;
}(h), A) try {
R = JSON.parse(R);
} catch {
}
return R;
}
function f(R) {
return clearTimeout(g), R instanceof Error || (R = new Error("" + (R || "Unknown XMLHttpRequest Error"))), R.statusCode = 0, d(R, k);
}
function y() {
if (!m) {
var R;
clearTimeout(g), R = c.useXDR && h.status === void 0 ? 200 : h.status === 1223 ? 204 : h.status;
var O = k, S = null;
return R !== 0 ? (O = { body: p(), statusCode: R, method: I, headers: {}, url: v, rawRequest: h }, h.getAllResponseHeaders && (O.headers = s(h.getAllResponseHeaders()))) : S = new Error("Internal XMLHttpRequest Error"), d(S, O, O.body);
}
}
var h = c.xhr || null;
h || (h = c.cors || c.useXDR ? new o.XDomainRequest() : new o.XMLHttpRequest());
var C, m, g, v = h.url = c.uri || c.url, I = h.method = c.method || "GET", M = c.body || c.data, E = h.headers = c.headers || {}, U = !!c.sync, A = !1, k = { body: void 0, headers: {}, statusCode: 0, method: I, url: v, rawRequest: h };
if ("json" in c && c.json !== !1 && (A = !0, E.accept || E.Accept || (E.Accept = "application/json"), I !== "GET" && I !== "HEAD" && (E["content-type"] || E["Content-Type"] || (E["Content-Type"] = "application/json"), M = JSON.stringify(c.json === !0 ? M : c.json))), h.onreadystatechange = function() {
h.readyState === 4 && setTimeout(y, 0);
}, h.onload = y, h.onerror = f, h.onprogress = function() {
}, h.onabort = function() {
m = !0;
}, h.ontimeout = f, h.open(I, v, !U, c.username, c.password), U || (h.withCredentials = !!c.withCredentials), !U && c.timeout > 0 && (g = setTimeout(function() {
if (!m) {
m = !0, h.abort("timeout");
var R = new Error("XMLHttpRequest timeout");
R.code = "ETIMEDOUT", f(R);
}
}, c.timeout)), h.setRequestHeader) for (C in E) E.hasOwnProperty(C) && h.setRequestHeader(C, E[C]);
else if (c.headers && !function(R) {
for (var O in R) if (R.hasOwnProperty(O)) return !1;
return !0;
}(c.headers)) throw new Error("Headers cannot be set on an XDomainRequest object");
return "responseType" in c && (h.responseType = c.responseType), "beforeSend" in c && typeof c.beforeSend == "function" && c.beforeSend(h), h.send(M || null), h;
}
t.exports = o, t.exports.default = o, o.XMLHttpRequest = r.XMLHttpRequest || function() {
}, o.XDomainRequest = "withCredentials" in new o.XMLHttpRequest() ? o.XMLHttpRequest : r.XDomainRequest, function(c, u) {
for (var d = 0; d < c.length; d++) u(c[d]);
}(["get", "put", "post", "patch", "head", "delete"], function(c) {
o[c === "delete" ? "del" : c] = function(u, d, p) {
return (d = a(u, d, p)).method = c.toUpperCase(), l(d);
};
});
});
function Ai(e, t, ...r) {
if (!e) throw new TypeError(ll(t, r));
}
function ll(e, t) {
let r = 0;
return e.replace(/%[os]/gu, () => cl(t[r++]));
}
function cl(e) {
return typeof e != "object" || e === null ? String(e) : Object.prototype.toString.call(e);
}
var Ue = typeof window < "u" ? window : typeof self < "u" ? self : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : void 0, ct = class {
constructor(e, t) {
this.code = e, this.message = t;
}
warn(...e) {
var t;
try {
let r = ((t = new Error().stack) !== null && t !== void 0 ? t : "").replace(/^(?:.+?\n){2}/gu, `
`);
console.warn(this.message, ...e, r);
} catch {
}
}
}, Rd = new ct("W01", "Unable to initialize event under dispatching."), Ld = new ct("W02", "Assigning any falsy value to 'cancelBubble' property has no effect."), Od = new ct("W03", "Assigning any truthy value to 'returnValue' property has no effect."), Ad = new ct("W04", "Unable to preventDefault on non-cancelable events."), Md = new ct("W05", "Unable to preventDefault inside passive event listener invocation."), Ud = new ct("W06", "An event listener wasn't added because it has been added already: %o, %o"), Kn = new ct("W07", "The %o option value was abandoned because the event listener wasn't added as duplicated."), co = new ct("W08", "The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"), Je = class {
static get NONE() {
return uo;
}
static get CAPTURING_PHASE() {
return po;
}
static get AT_TARGET() {
return ho;
}
static get BUBBLING_PHASE() {
return mo;
}
constructor(e, t) {
Object.defineProperty(this, "isTrusted", { value: !1, enumerable: !0 });
let r = t ?? {};
Cs.set(this, { type: String(e), bubbles: !!r.bubbles, cancelable: !!r.cancelable, composed: !!r.composed, target: null, currentTarget: null, stopPropagationFlag: !1, stopImmediatePropagationFlag: !1, canceledFlag: !1, inPassiveListenerFlag: !1, dispatchFlag: !1, timeStamp: Date.now() });
}
get type() {
return he(this).type;
}
get target() {
return he(this).target;
}
get srcElement() {
return he(this).target;
}
get currentTarget() {
return he(this).currentTarget;
}
composedPath() {
let e = he(this).currentTarget;
return e ? [e] : [];
}
get NONE() {
return uo;
}
get CAPTURING_PHASE() {
return po;
}
get AT_TARGET() {
return ho;
}
get BUBBLING_PHASE() {
return mo;
}
get eventPhase() {
return he(this).dispatchFlag ? 2 : 0;
}
stopPropagation() {
he(this).stopPropagationFlag = !0;
}
get cancelBubble() {
return he(this).stopPropagationFlag;
}
set cancelBubble(e) {
e ? he(this).stopPropagationFlag = !0 : Ld.warn();
}
stopImmediatePropagation() {
let e = he(this);
e.stopPropagationFlag = e.stopImmediatePropagationFlag = !0;
}
get bubbles() {
return he(this).bubbles;
}
get cancelable() {
return he(this).cancelable;
}
get returnValue() {
return !he(this).canceledFlag;
}
set returnValue(e) {
e ? Od.warn() : fo(he(this));
}
preventDefault() {
fo(he(this));
}
get defaultPrevented() {
return he(this).canceledFlag;
}
get composed() {
return he(this).composed;
}
get isTrusted() {
return !1;
}
get timeStamp() {
return he(this).timeStamp;
}
initEvent(e, t = !1, r = !1) {
let n = he(this);
n.dispatchFlag ? Rd.warn() : Cs.set(this, { ...n, type: String(e), bubbles: !!t, cancelable: !!r, target: null, currentTarget: null, stopPropagationFlag: !1, stopImmediatePropagationFlag: !1, canceledFlag: !1 });
}
}, uo = 0, po = 1, ho = 2, mo = 3, Cs = /* @__PURE__ */ new WeakMap();
function he(e, t = "this") {
let r = Cs.get(e);
return Ai(r != null, "'%s' must be an object that Event constructor created, but got another one: %o", t, e), r;
}
function fo(e) {
e.inPassiveListenerFlag ? Md.warn() : e.cancelable ? e.canceledFlag = !0 : Ad.warn();
}
Object.defineProperty(Je, "NONE", { enumerable: !0 }), Object.defineProperty(Je, "CAPTURING_PHASE", { enumerable: !0 }), Object.defineProperty(Je, "AT_TARGET", { enumerable: !0 }), Object.defineProperty(Je, "BUBBLING_PHASE", { enumerable: !0 });
var Xn = Object.getOwnPropertyNames(Je.prototype);
for (let e = 0; e < Xn.length; ++e) Xn[e] !== "constructor" && Object.defineProperty(Je.prototype, Xn[e], { enumerable: !0 });
Ue !== void 0 && Ue.Event !== void 0 && Object.setPrototypeOf(Je.prototype, Ue.Event.prototype);
var yt, go = { INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25 };
function yo(e) {
let t = Object.keys(go);
for (let r = 0; r < t.length; ++r) {
let n = t[r], s = go[n];
Object.defineProperty(e, n, { get: () => s, configurable: !0, enumerable: !0 });
}
}
var mn = class extends Je {
static wrap(e) {
return new (dl(e))(e);
}
constructor(e) {
super(e.type, { bubbles: e.bubbles, cancelable: e.cancelable, composed: e.composed }), e.cancelBubble && super.stopPropagation(), e.defaultPrevented && super.preventDefault(), ul.set(this, { original: e });
let t = Object.keys(e);
for (let r = 0; r < t.length; ++r) {
let n = t[r];
n in this || Object.defineProperty(this, n, pl(e, n));
}
}
stopPropagation() {
super.stopPropagation();
let { original: e } = nt(this);
"stopPropagation" in e && e.stopPropagation();
}
get cancelBubble() {
return super.cancelBubble;
}
set cancelBubble(e) {
super.cancelBubble = e;
let { original: t } = nt(this);
"cancelBubble" in t && (t.cancelBubble = e);
}
stopImmediatePropagation() {
super.stopImmediatePropagation();
let { original: e } = nt(this);
"stopImmediatePropagation" in e && e.stopImmediatePropagation();
}
get returnValue() {
return super.returnValue;
}
set returnValue(e) {
super.returnValue = e;
let { original: t } = nt(this);
"returnValue" in t && (t.returnValue = e);
}
preventDefault() {
super.preventDefault();
let { original: e } = nt(this);
"preventDefault" in e && e.preventDefault();
}
get timeStamp() {
let { original: e } = nt(this);
return "timeStamp" in e ? e.timeStamp : super.timeStamp;
}
}, ul = /* @__PURE__ */ new WeakMap();
function nt(e) {
let t = ul.get(e);
return Ai(t != null, "'this' is expected an Event object, but got", e), t;
}
var fn = /* @__PURE__ */ new WeakMap();
function dl(e) {
let t = Object.getPrototypeOf(e);
if (t == null) return mn;
let r = fn.get(t);
return r == null && (r = function(n, s) {
class i extends n {
}
let a = Object.keys(s);
for (let o = 0; o < a.length; ++o) Object.defineProperty(i.prototype, a[o], pl(s, a[o]));
return i;
}(dl(t), t), fn.set(t, r)), r;
}
function pl(e, t) {
let r = Object.getOwnPropertyDescriptor(e, t);
return { get() {
let n = nt(this).original, s = n[t];
return typeof s == "function" ? s.bind(n) : s;
}, set(n) {
nt(this).original[t] = n;
}, configurable: r.configurable, enumerable: r.enumerable };
}
function hl(e) {
return !(1 & ~e.flags);
}
function wo(e) {
return !(2 & ~e.flags);
}
function vo(e) {
return !(4 & ~e.flags);
}
function Td(e) {
return !(8 & ~e.flags);
}
function Dd({ callback: e }, t, r) {
try {
typeof e == "function" ? e.call(t, r) : typeof e.handleEvent == "function" && e.handleEvent(r);
} catch (n) {
(function(s) {
try {
let i = s instanceof Error ? s : new Error(cl(s));
if (typeof dispatchEvent == "function" && typeof ErrorEvent == "function") dispatchEvent(new ErrorEvent("error", { error: i, message: i.message }));
else if (typeof process < "u" && typeof process.emit == "function") return void process.emit("uncaughtException", i);
console.error(i);
} catch {
}
})(n);
}
}
function ml({ listeners: e }, t, r) {
for (let n = 0; n < e.length; ++n) if (e[n].callback === t && hl(e[n]) === r) return n;
return -1;
}
function bo(e, t, r) {
let n = ml(e, t, r);
return n !== -1 && fl(e, n);
}
function fl(e, t, r = !1) {
let n = e.listeners[t];
return function(s) {
s.flags |= 8;
}(n), n.signal && n.signal.removeEventListener("abort", n.signalListener), e.cow && !r ? (e.cow = !1, e.listeners = e.listeners.filter((s, i) => i !== t), !1) : (e.listeners.splice(t, 1), !0);
}
fn.set(Object.prototype, mn), Ue !== void 0 && Ue.Event !== void 0 && fn.set(Ue.Event.prototype, mn);
var Tn = class {
constructor() {
yl.set(this, /* @__PURE__ */ Object.create(null));
}
addEventListener(e, t, r) {
let n = Zn(this), { callback: s, capture: i, once: a, passive: o, signal: l, type: c } = function(p, f, y) {
var h;
return So(f), typeof y == "object" && y !== null ? { type: String(p), callback: f ?? void 0, capture: !!y.capture, passive: !!y.passive, once: !!y.once, signal: (h = y.signal) !== null && h !== void 0 ? h : void 0 } : { type: String(p), callback: f ?? void 0, capture: !!y, passive: !1, once: !1, signal: void 0 };
}(e, t, r);
if (s == null || l != null && l.aborted) return;
let u = function(p, f) {
var y;
return (y = p[f]) !== null && y !== void 0 ? y : p[f] = { attrCallback: void 0, attrListener: void 0, cow: !1, listeners: [] };
}(n, c), d = ml(u, s, i);
d === -1 ? function(p, f, y, h, C, m) {
let g;
m && (g = bo.bind(null, p, f, y), m.addEventListener("abort", g));
let v = function(I, M, E, U, A, k) {
return { callback: I, flags: (M ? 1 : 0) | (E ? 2 : 0) | (U ? 4 : 0), signal: A, signalListener: k };
}(f, y, h, C, m, g);
p.cow ? (p.cow = !1, p.listeners = [...p.listeners, v]) : p.listeners.push(v);
}(u, s, i, o, a, l) : function(p, f, y, h) {
Ud.warn(hl(p) ? "capture" : "bubble", p.callback), wo(p) !== f && Kn.warn("passive"), vo(p) !== y && Kn.warn("once"), p.signal !== h && Kn.warn("signal");
}(u.listeners[d], o, a, l);
}
removeEventListener(e, t, r) {
let n = Zn(this), { callback: s, capture: i, type: a } = function(l, c, u) {
return So(c), typeof u == "object" && u !== null ? { type: String(l), callback: c ?? void 0, capture: !!u.capture } : { type: String(l), callback: c ?? void 0, capture: !!u };
}(e, t, r), o = n[a];
s != null && o && bo(o, s, i);
}
dispatchEvent(e) {
let t = Zn(this)[String(e.type)];
if (t == null) return !0;
let r = e instanceof Je ? e : mn.wrap(e), n = he(r, "event");
if (n.dispatchFlag) throw s = "This event has been in dispatching.", Ue.DOMException ? new Ue.DOMException(s, "InvalidStateError") : (yt == null && (yt = class gl extends Error {
constructor(a) {
super(a), Error.captureStackTrace && Error.captureStackTrace(this, gl);
}
get code() {
return 11;
}
get name() {
return "InvalidStateError";
}
}, Object.defineProperties(yt.prototype, { code: { enumerable: !0 }, name: { enumerable: !0 } }), yo(yt), yo(yt.prototype)), new yt(s));
var s;
if (n.dispatchFlag = !0, n.target = n.currentTarget = this, !n.stopPropagationFlag) {
let { cow: i, listeners: a } = t;
t.cow = !0;
for (let o = 0; o < a.length; ++o) {
let l = a[o];
if (!Td(l) && (vo(l) && fl(t, o, !i) && (o -= 1), n.inPassiveListenerFlag = wo(l), Dd(l, this, r), n.inPassiveListenerFlag = !1, n.stopImmediatePropagationFlag)) break;
}
i || (t.cow = !1);
}
return n.target = null, n.currentTarget = null, n.stopImmediatePropagationFlag = !1, n.stopPropagationFlag = !1, n.dispatchFlag = !1, !n.canceledFlag;
}
}, yl = /* @__PURE__ */ new WeakMap();
function Zn(e, t = "this") {
let r = yl.get(e);
return Ai(r != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", t, e), r;
}
function So(e) {
if (typeof e != "function" && (typeof e != "object" || e === null || typeof e.handleEvent != "function")) {
if (e == null || typeof e == "object") return void co.warn(e);
throw new TypeError(ll(co.message, [e]));
}
}
var Qn = Object.getOwnPropertyNames(Tn.prototype);
for (let e = 0; e < Qn.length; ++e) Qn[e] !== "constructor" && Object.defineProperty(Tn.prototype, Qn[e], { enumerable: !0 });
Ue !== void 0 && Ue.EventTarget !== void 0 && Object.setPrototypeOf(Tn.prototype, Ue.EventTarget.prototype);
var Io, Pd = ((e, t, r) => (r = e != null ? yd(bd(e)) : {}, ((n, s, i, a) => {
if (s && typeof s == "object" || typeof s == "function") for (let o of vd(s)) !Sd.call(n, o) && o !== i && lo(n, o, { get: () => s[o], enumerable: !(a = wd(s, o)) || a.enumerable });
return n;
})(e && e.__esModule ? r : lo(r, "default", { value: e, enumerable: !0 }), e)))(xd()), Dn = 512e3, Pn = 256, ks = (e, { minChunkSize: t = Pn, maxChunkSize: r = Dn } = {}) => e == null || typeof e == "number" && e >= 256 && e % 256 == 0 && e >= t && e <= r, Es = (e, { minChunkSize: t = Pn, maxChunkSize: r = Dn } = {}) => new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${r}`), _d = class {
constructor(e, t = {}) {
var r, n, s;
if (this.readableStream = e, !ks(t.defaultChunkSize, t)) throw Es(t.defaultChunkSize, t);
this.defaultChunkSize = (r = t.defaultChunkSize) != null ? r : 30720, this.minChunkSize = (n = t.minChunkSize) != null ? n : Pn, this.maxChunkSize = (s = t.maxChunkSize) != null ? s : Dn;
}
get chunkSize() {
var e;
return (e = this._chunkSize) != null ? e : this.defaultChunkSize;
}
set chunkSize(e) {
if (!ks(e, this)) throw Es(e, this);
this._chunkSize = e;
}
get chunkByteSize() {
return 1024 * this.chunkSize;
}
async *[Symbol.asyncIterator]() {
let e, t = this.readableStream.getReader();
try {
for (; ; ) {
let { done: r, value: n } = await t.read();
if (r) {
if (e) {
let i = e;
e = void 0, yield i;
}
break;
}
let s = n instanceof Uint8Array ? new Blob([n], { type: "application/octet-stream" }) : n;
for (e = e ? new Blob([e, s]) : s; e; ) {
if (e.size === this.chunkByteSize) {
let i = e;
e = void 0, yield i;
break;
}
if (e.size < this.chunkByteSize) break;
{
let i = e.slice(0, this.chunkByteSize);
e = e.slice(this.chunkByteSize), yield i;
}
}
}
} finally {
if (e) {
let r = e;
e = void 0, yield r;
}
return void t.releaseLock();
}
}
}, Nd = [200, 201, 202, 204, 308], wl = [408, 502, 503, 504], vl = (e, t) => !!e && Nd.includes(e.statusCode), Fd = (e, t) => t.attemptCount >= t.attempts || !(vl(e) || ((r, { retryCodes: n = wl }) => !r || n.includes(r.statusCode))(e, t)), bl = class {
static createUpload(e) {
return new bl(e);
}
constructor(e) {
this.endpoint = e.endpoint, this.file = e.file, this.headers = e.headers || {}, this.method = e.method || "PUT", this.attempts = e.attempts || 5, this.delayBeforeAttempt = e.delayBeforeAttempt || 1, this.retryCodes = e.retryCodes || wl, this.dynamicChunkSize = e.dynamicChunkSize || !1, this.maxFileBytes = 1024 * (e.maxFileSize || 0), this.chunkCount = 0, this.attemptCount = 0, this.offline = !1, this._paused = !1, this.success = !1, this.nextChunkRangeStart = 0, this.chunkedStreamIterable = new _d(this.file.stream(), { ...e, defaultChunkSize: e.chunkSize }), this.chunkedStreamIterator = this.chunkedStreamIterable[Symbol.asyncIterator](), this.totalChunks = Math.ceil(this.file.size / this.chunkByteSize), this.eventTarget = new Tn(), this.validateOptions(), this.getEndpoint().then(() => this.sendChunks()), typeof window < "u" && (window.addEventListener("online", () => {
!this.offline || (this.offline = !1, this.dispatch("online"), this.sendChunks());
}), window.addEventListener("offline", () => {
this.offline = !0, this.dispatch("offline");
}));
}
get maxChunkSize() {
var e, t;
return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.maxChunkSize) != null ? t : Dn;
}
get minChunkSize() {
var e, t;
return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.minChunkSize) != null ? t : Pn;
}
get chunkSize() {
var e, t;
return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.chunkSize) != null ? t : 30720;
}
set chunkSize(e) {
this.chunkedStreamIterable.chunkSize = e;
}
get chunkByteSize() {
return this.chunkedStreamIterable.chunkByteSize;
}
get totalChunkSize() {
return Math.ceil(this.file.size / this.chunkByteSize);
}
on(e, t) {
this.eventTarget.addEventListener(e, t);
}
once(e, t) {
this.eventTarget.addEventListener(e, t, { once: !0 });
}
off(e, t) {
this.eventTarget.removeEventListener(e, t);
}
get paused() {
return this._paused;
}
abort() {
var e;
this.pause(), (e = this.currentXhr) == null || e.abort();
}
pause() {
this._paused = !0;
}
resume() {
this._paused && (this._paused = !1, this.sendChunks());
}
dispatch(e, t) {
let r = new CustomEvent(e, { detail: t });
this.eventTarget.dispatchEvent(r);
}
validateOptions() {
if (!this.endpoint || typeof this.endpoint != "function" && typeof this.endpoint != "string") throw new TypeError("endpoint must be defined as a string or a function that returns a promise");
if (!(this.file instanceof File)) throw new TypeError("file must be a File object");
if (this.headers && typeof this.headers != "function" && typeof this.headers != "object") throw new TypeError("headers must be null, an object, or a function that returns an object or a promise");
if (!ks(this.chunkSize, { maxChunkSize: this.maxChunkSize, minChunkSize: this.minChunkSize })) throw Es(this.chunkSize, { maxChunkSize: this.maxChunkSize, minChunkSize: this.minChunkSize });
if (this.maxChunkSize && (typeof this.maxChunkSize != "number" || this.maxChunkSize < 256 || this.maxChunkSize % 256 != 0 || this.maxChunkSize < this.chunkSize || this.maxChunkSize < this.minChunkSize)) throw new TypeError(`maxChunkSize must be a positive number in multiples of 256, and larger than or equal to both ${this.minChunkSize} and ${this.chunkSize}`);
if (this.minChunkSize && (typeof this.minChunkSize != "number" || this.minChunkSize < 256 || this.minChunkSize % 256 != 0 || this.minChunkSize > this.chunkSize || this.minChunkSize > this.maxChunkSize)) throw new TypeError(`minChunkSize must be a positive number in multiples of 256, and smaller than ${this.chunkSize} and ${this.maxChunkSize}`);
if (this.maxFileBytes > 0 && this.maxFileBytes < this.file.size) throw new Error(`file size exceeds maximum (${this.file.size} > ${this.maxFileBytes})`);
if (this.attempts && (typeof this.attempts != "number" || this.attempts <= 0)) throw new TypeError("retries must be a positive number");
if (this.delayBeforeAttempt && (typeof this.delayBeforeAttempt != "number" || this.delayBeforeAttempt < 0)) throw new TypeError("delayBeforeAttempt must be a positive number");
}
getEndpoint() {
return typeof this.endpoint == "string" ? (this.endpointValue = this.endpoint, Promise.resolve(this.endpoint)) : this.endpoint(this.file).then((e) => (this.endpointValue = e, this.endpointValue));
}
xhrPromise(e) {
let t = (r) => {
r.upload.onprogress = (n) => {
var s;
let i = this.totalChunks - this.chunkCount, a = (this.file.size - this.nextChunkRangeStart) / this.file.size / i, o = this.nextChunkRangeStart / this.file.size, l = n.loaded / ((s = n.total) != null ? s : this.chunkByteSize) * a;
this.dispatch("progress", Math.min(100 * (o + l), 100));
};
};
return new Promise((r, n) => {
this.currentXhr = (0, Pd.default)({ ...e, beforeSend: t }, (s, i) => (this.currentXhr = void 0, s ? n(s) : r(i)));
});
}
async sendChunk(e) {
let t = this.nextChunkRangeStart, r = t + e.size - 1, n = { ...await (typeof this.headers == "function" ? this.headers() : this.headers), "Content-Type": this.file.type, "Content-Range": `bytes ${t}-${r}/${this.file.size}` };
return this.dispatch("attempt", { chunkNumber: this.chunkCount, totalChunks: this.totalChunks, chunkSize: this.chunkSize }), this.xhrPromise({ headers: n, url: this.endpointValue, method: this.method, body: e });
}
async sendChunkWithRetries(e) {
let t;
try {
this.attemptCount = this.attemptCount + 1, this.lastChunkStart = /* @__PURE__ */ new Date(), t = await this.sendChunk(e);
} catch {
}
let r = { retryCodes: this.retryCodes, attemptCount: this.attemptCount, attempts: this.attempts };
return vl(t) ? (async (n) => {
var s;
let i = ((/* @__PURE__ */ new Date()).getTime() - this.lastChunkStart.getTime()) / 1e3;
if (this.dispatch("chunkSuccess", { chunk: this.chunkCount, chunkSize: this.chunkSize, attempts: this.attemptCount, timeInterval: i, response: n }), this.attemptCount = 0, this.chunkCount = ((s = this.chunkCount) != null ? s : 0) + 1, this.nextChunkRangeStart = this.nextChunkRangeStart + this.chunkByteSize, this.dynamicChunkSize) {
let a = this.chunkSize;
i < 10 ? a = Math.min(2 * this.chunkSize, this.maxChunkSize) : i > 30 && (a = Math.max(this.chunkSize / 2, this.minChunkSize)), this.chunkSize = 256 * Math.ceil(a / 256);
let o = (this.file.size - this.nextChunkRangeStart) / this.chunkByteSize;
this.totalChunks = Math.ceil(this.chunkCount + o);
}
return !0;
})(t) : Fd(t, r) ? (async (n) => (this.dispatch("error", { message: `Server responded with ${n.statusCode}. Stopping upload.`, chunk: this.chunkCount, attempts: this.attemptCount }), !1))(t) : (async () => (this.dispatch("attemptFailure", { message: `An error occured uploading chunk ${this.chunkCount}. ${this.attempts - this.attemptCount} retries left.`, chunkNumber: this.chunkCount, attemptsLeft: this.attempts - this.attemptCount }), new Promise((n) => {
setTimeout(async () => {
if (this._paused || this.offline) return this.pendingChunk = e, void n(!1);
let s = await this.sendChunkWithRetries(e);
n(s);
}, 1e3 * this.delayBeforeAttempt);
})))();
}
async sendChunks() {
if (this.pendingChunk && !this._paused && !this.offline) {
let e = this.pendingChunk;
this.pendingChunk = void 0;
let t = await this.sendChunkWithRetries(e);
this.success && t && this.dispatch("success");
}
for (; !(this.success || this._paused || this.offline); ) {
let { value: e, done: t } = await this.chunkedStreamIterator.next(), r = !e && t;
if (e && (r = await this.sendChunkWithRetries(e)), this.success = !!t, this.success && r && this.dispatch("success"), !r) return;
}
}
}, Bd = bl.createUpload, zd = Object.defineProperty, x = (e, t, r) => ((n, s, i) => s in n ? zd(n, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[s] = i)(e, typeof t != "symbol" ? t + "" : t, r), jd = Object.defineProperty, Co = (e, t, r) => ((n, s, i) => s in n ? jd(n, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[s] = i)(e, typeof t != "symbol" ? t + "" : t, r), me = ((e) => (e[e.Document = 0] = "Document", e[e.DocumentType = 1] = "DocumentType", e[e.Element = 2] = "Element", e[e.Text = 3] = "Text", e[e.CDATA = 4] = "CDATA", e[e.Comment = 5] = "Comment", e))(me || {});
const ko = { Node: ["childNodes", "parentNode", "parentElement", "textContent"], ShadowRoot: ["host", "styleSheets"], Element: ["shadowRoot", "querySelector", "querySelectorAll"], MutationObserver: [] }, Eo = { Node: ["contains", "getRootNode"], ShadowRoot: ["getSelection"], Element: [], MutationObserver: ["constructor"] }, br = {};
function Mi(e) {
if (br[e]) return br[e];
const t = globalThis[e], r = t.prototype, n = e in ko ? ko[e] : void 0, s = !!(n && n.every((o) => {
var l, c;
return !!((c = (l = Object.getOwnPropertyDescriptor(r, o)) == null ? void 0 : l.get) != null && c.toString().includes("[native code]"));
})), i = e in Eo ? Eo[e] : void 0, a = !!(i && i.every((o) => {
var l;
return typeof r[o] == "function" && ((l = r[o]) == null ? void 0 : l.toString().includes("[native code]"));
}));
if (s && a) return br[e] = t.prototype, t.prototype;
try {
const o = document.createElement("iframe");
document.body.appendChild(o);
const l = o.contentWindow;
if (!l) return t.prototype;
const c = l[e].prototype;
return document.body.removeChild(o), c ? br[e] = c : r;
} catch {
return r;
}
}
const es = {};
function et(e, t, r) {
var n;
const s = `${e}.${String(r)}`;
if (es[s]) return es[s].call(t);
const i = Mi(e), a = (n = Object.getOwnPropertyDescriptor(i, r)) == null ? void 0 : n.get;
return a ? (es[s] = a, a.call(t)) : t[r];
}
const ts = {};
function xo(e, t, r) {
const n = `${e}.${String(r)}`;
if (ts[n]) return ts[n].bind(t);
const s = Mi(e)[r];
return typeof s != "function" ? t[r] : (ts[n] = s, s.bind(t));
}
const ge = { childNodes: function(e) {
return et("Node", e, "childNodes");
}, parentNode: function(e) {
return et("Node", e, "parentNode");
}, parentElement: function(e) {
return et("Node", e, "parentElement");
}, textContent: function(e) {
return et("Node", e, "textContent");
}, contains: function(e, t) {
return xo("Node", e, "contains")(t);
}, getRootNode: function(e) {
return xo("Node", e, "getRootNode")();
}, host: function(e) {
return e && "host" in e ? et("ShadowRoot", e, "host") : null;
}, styleSheets: function(e) {
return e.styleSheets;
}, shadowRoot: function(e) {
return e && "shadowRoot" in e ? et("Element", e, "shadowRoot") : null;
}, querySelector: function(e, t) {
return et("Element", e, "querySelector")(t);
}, querySelectorAll: function(e, t) {
return et("Element", e, "querySelectorAll")(t);
}, mutationObserver: function() {
return Mi("MutationObserver").constructor;
} };
function Sl(e) {
return e.nodeType === e.ELEMENT_NODE;
}
function Jt(e) {
const t = e && "host" in e && "mode" in e && ge.host(e) || null;
return !!(t && "shadowRoot" in t && ge.shadowRoot(t) === e);
}
function Kt(e) {
return Object.prototype.toString.call(e) === "[object ShadowRoot]";
}
function Yr(e) {
try {
const r = e.rules || e.cssRules;
return r ? ((t = Array.from(r, (s) => Il(s, e.href)).join("")).includes(" background-clip: text;") && !t.includes(" -webkit-background-clip: text;") && (t = t.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;")), t) : null;
} catch {
return null;
}
var t;
}
function Il(e, t) {
if (function(r) {
return "styleSheet" in r;
}(e)) {
let r;
try {
r = Yr(e.styleSheet) || function(n) {
const { cssText: s } = n;
if (s.split('"').length < 3) return s;
const i = ["@import", `url(${JSON.stringify(n.href)})`];
return n.layerName === "" ? i.push("layer") : n.layerName && i.push(`layer(${n.layerName})`), n.supportsText && i.push(`supports(${n.supportsText})`), n.media.length && i.push(n.media.mediaText), i.join(" ") + ";";
}(e);
} catch {
r = e.cssText;
}
return e.styleSheet.href ? gn(r, e.styleSheet.href) : r;
}
{
let r = e.cssText;
return function(n) {
return "selectorText" in n;
}(e) && e.selectorText.includes(":") && (r = function(n) {
const s = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
return n.replace(s, "$1\\$2");
}(r)), t ? gn(r, t) : r;
}
}
class Cl {
constructor() {
Co(this, "idNodeMap", /* @__PURE__ */ new Map()), Co(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
}
getId(t) {
var r;
return t ? ((r = this.getMeta(t)) == null ? void 0 : r.id) ?? -1 : -1;
}
getNode(t) {
return this.idNodeMap.get(t) || null;
}
getIds() {
return Array.from(this.idNodeMap.keys());
}
getMeta(t) {
return this.nodeMetaMap.get(t) || null;
}
removeNodeFromMap(t) {
const r = this.getId(t);
this.idNodeMap.delete(r), t.childNodes && t.childNodes.forEach((n) => this.removeNodeFromMap(n));
}
has(t) {
return this.idNodeMap.has(t);
}
hasNode(t) {
return this.nodeMetaMap.has(t);
}
add(t, r) {
const n = r.id;
this.idNodeMap.set(n, t), this.nodeMetaMap.set(t, r);
}
replace(t, r) {
const n = this.getNode(t);
if (n) {
const s = this.nodeMetaMap.get(n);
s && this.nodeMetaMap.set(r, s);
}
this.idNodeMap.set(t, r);
}
reset() {
this.idNodeMap = /* @__PURE__ */ new Map(), this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
}
}
function Ui({ element: e, maskInputOptions: t, tagName: r, type: n, value: s, maskInputFn: i }) {
let a = s || "";
const o = n && ht(n);
return (t[r.toLowerCase()] || o && t[o]) && (a = i ? i(a, e) : "*".repeat(a.length)), a;
}
function ht(e) {
return e.toLowerCase();
}
const Ro = "__rrweb_original__";
function Ti(e) {
const t = e.type;
return e.hasAttribute("data-rr-is-password") ? "password" : t ? ht(t) : null;
}
function Lo(e, t) {
let r;
try {
r = new URL(e, t ?? window.location.href);
} catch {
return null;
}
const n = r.pathname.match(/\.([0-9a-z]+)(?:$)/i);
return (n == null ? void 0 : n[1]) ?? null;
}
const Wd = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm, Vd = /^(?:[a-z+]+:)?\/\//i, Gd = /^www\..*/i, Hd = /^(data:)([^,]*),(.*)/i;
function gn(e, t) {
return (e || "").replace(Wd, (r, n, s, i, a, o) => {
const l = s || a || o, c = n || i || "";
if (!l) return r;
if (Vd.test(l) || Gd.test(l)) return `url(${c}${l}${c})`;
if (Hd.test(l)) return `url(${c}${l}${c})`;
if (l[0] === "/") return `url(${c}${function(p) {
let f = "";
return f = p.indexOf("//") > -1 ? p.split("/").slice(0, 3).join("/") : p.split("/")[0], f = f.split("?")[0], f;
}(t) + l}${c})`;
const u = t.split("/"), d = l.split("/");
u.pop();
for (const p of d) p !== "." && (p === ".." ? u.pop() : u.push(p));
return `url(${c}${u.join("/")}${c})`;
});
}
let $d = 1;
const Yd = new RegExp("[^a-z0-9-_:]");
function kl() {
return $d++;
}
let wt, Oo;
const qd = /^[^ \t\n\r\u000c]+/, Jd = /^[, \t\n\r\u000c]+/, Ao = /* @__PURE__ */ new WeakMap();
function _t(e, t) {
return t && t.trim() !== "" ? Di(e, t) : t;
}
function Kd(e) {
return !!(e.tagName === "svg" || e.ownerSVGElement);
}
function Di(e, t) {
let r = Ao.get(e);
if (r || (r = e.createElement("a"), Ao.set(e, r)), t) {
if (t.startsWith("blob:") || t.startsWith("data:")) return t;
} else t = "";
return r.setAttribute("href", t), r.href;
}
function El(e, t, r, n) {
return n && (r === "src" || r === "href" && (t !== "use" || n[0] !== "#") || r === "xlink:href" && n[0] !== "#" ? _t(e, n) : r !== "background" || t !== "table" && t !== "td" && t !== "th" ? r === "srcset" ? function(s, i) {
if (i.trim() === "") return i;
let a = 0;
function o(c) {
let u;
const d = c.exec(i.substring(a));
return d ? (u = d[0], a += u.length, u) : "";
}
const l = [];
for (; o(Jd), !(a >= i.length); ) {
let c = o(qd);
if (c.slice(-1) === ",") c = _t(s, c.substring(0, c.length - 1)), l.push(c);
else {
let u = "";
c = _t(s, c);
let d = !1;
for (; ; ) {
const p = i.charAt(a);
if (p === "") {
l.push((c + u).trim());
break;
}
if (d) p === ")" && (d = !1);
else {
if (p === ",") {
a += 1, l.push((c + u).trim());
break;
}
p === "(" && (d = !0);
}
u += p, a += 1;
}
}
}
return l.join(", ");
}(e, n) : r === "style" ? gn(n, Di(e)) : t === "object" && r === "data" ? _t(e, n) : n : _t(e, n));
}
function xl(e, t, r) {
return (e === "video" || e === "audio") && t === "autoplay";
}
function yn(e, t, r) {
if (!e) return !1;
if (e.nodeType !== e.ELEMENT_NODE) return !!r && yn(ge.parentNode(e), t, r);
for (let n = e.classList.length; n--; ) {
const s = e.classList[n];
if (t.test(s)) return !0;
}
return !!r && yn(ge.parentNode(e), t, r);
}
function Rl(e, t, r, n) {
let s;
if (Sl(e)) {
if (s = e, !ge.childNodes(s).length) return !1;
} else {
if (ge.parentElement(e) === null) return !1;
s = ge.parentElement(e);
}
try {
if (typeof t == "string") {
if (n) {
if (s.closest(`.${t}`)) return !0;
} else if (s.classList.contains(t)) return !0;
} else if (yn(s, t, n)) return !0;
if (r) {
if (n) {
if (s.closest(r)) return !0;
} else if (s.matches(r)) return !0;
}
} catch {
}
return !1;
}
function Xd(e, t) {
const { doc: r, mirror: n, blockClass: s, blockSelector: i, needsMask: a, inlineStylesheet: o, maskInputOptions: l = {}, maskTextFn: c, maskInputFn: u, dataURLOptions: d = {}, inlineImages: p, recordCanvas: f, keepIframeSrcFn: y, newlyAddedElement: h = !1 } = t, C = function(m, g) {
if (!g.hasNode(m)) return;
const v = g.getId(m);
return v === 1 ? void 0 : v;
}(r, n);
switch (e.nodeType) {
case e.DOCUMENT_NODE:
return e.compatMode !== "CSS1Compat" ? { type: me.Document, childNodes: [], compatMode: e.compatMode } : { type: me.Document, childNodes: [] };
case e.DOCUMENT_TYPE_NODE:
return { type: me.DocumentType, name: e.name, publicId: e.publicId, systemId: e.systemId, rootId: C };
case e.ELEMENT_NODE:
return function(m, g) {
const { doc: v, blockClass: I, blockSelector: M, inlineStylesheet: E, maskInputOptions: U = {}, maskInputFn: A, dataURLOptions: k = {}, inlineImages: R, recordCanvas: O, keepIframeSrcFn: S, newlyAddedElement: N = !1, rootId: D } = g, b = function(L, P, F) {
try {
if (typeof P == "string") {
if (L.classList.contains(P)) return !0;
} else for (let q = L.classList.length; q--; ) {
const pe = L.classList[q];
if (P.test(pe)) return !0;
}
if (F) return L.matches(F);
} catch {
}
return !1;
}(m, I, M), w = function(L) {
if (L instanceof HTMLFormElement) return "form";
const P = ht(L.tagName);
return Yd.test(P) ? "div" : P;
}(m);
let T = {};
const B = m.attributes.length;
for (let L = 0; L < B; L++) {
const P = m.attributes[L];
xl(w, P.name, P.value) || (T[P.name] = El(v, w, ht(P.name), P.value));
}
if (w === "link" && E) {
const L = Array.from(v.styleSheets).find((F) => F.href === m.href);
let P = null;
L && (P = Yr(L)), P && (delete T.rel, delete T.href, T._cssText = P);
}
if (w === "style" && m.sheet && !(m.innerText || ge.textContent(m) || "").trim().length) {
const L = Yr(m.sheet);
L && (T._cssText = L);
}
if (w === "input" || w === "textarea" || w === "select") {
const L = m.value, P = m.checked;
T.type !== "radio" && T.type !== "checkbox" && T.type !== "submit" && T.type !== "button" && L ? T.value = Ui({ element: m, type: Ti(m), tagName: w, value: L, maskInputOptions: U, maskInputFn: A }) : P && (T.checked = P);
}
if (w === "option" && (m.selected && !U.select ? T.selected = !0 : delete T.selected), w === "dialog" && m.open && (T.rr_open_mode = m.matches("dialog:modal") ? "modal" : "non-modal"), w === "canvas" && O) {
if (m.__context === "2d") (function(L) {
const P = L.getContext("2d");
if (!P) return !0;
for (let F = 0; F < L.width; F += 50) for (let q = 0; q < L.height; q += 50) {
const pe = P.getImageData, Le = Ro in pe ? pe[Ro] : pe;
if (new Uint32Array(Le.call(P, F, q, Math.min(50, L.width - F), Math.min(50, L.height - q)).data.buffer).some((ye) => ye !== 0)) return !1;
}
return !0;
})(m) || (T.rr_dataURL = m.toDataURL(k.type, k.quality));
else if (!("__context" in m)) {
const L = m.toDataURL(k.type, k.quality), P = v.createElement("canvas");
P.width = m.width, P.height = m.height, L !== P.toDataURL(k.type, k.quality) && (T.rr_dataURL = L);
}
}
if (w === "img" && R) {
wt || (wt = v.createElement("canvas"), Oo = wt.getContext("2d"));
const L = m, P = L.currentSrc || L.getAttribute("src") || "<unknown-src>", F = L.crossOrigin, q = () => {
L.removeEventListener("load", q);
try {
wt.width = L.naturalWidth, wt.height = L.naturalHeight, Oo.drawImage(L, 0, 0), T.rr_dataURL = wt.toDataURL(k.type, k.quality);
} catch (pe) {
if (L.crossOrigin !== "anonymous") return L.crossOrigin = "anonymous", void (L.complete && L.naturalWidth !== 0 ? q() : L.addEventListener("load", q));
console.warn(`Cannot inline img src=${P}! Error: ${pe}`);
}
L.crossOrigin === "anonymous" && (F ? T.crossOrigin = F : L.removeAttribute("crossorigin"));
};
L.complete && L.naturalWidth !== 0 ? q() : L.addEventListener("load", q);
}
if (w === "audio" || w === "video") {
const L = T;
L.rr_mediaState = m.paused ? "paused" : "played", L.rr_mediaCurrentTime = m.currentTime, L.rr_mediaPlaybackRate = m.playbackRate, L.rr_mediaMuted = m.muted, L.rr_mediaLoop = m.loop, L.rr_mediaVolume = m.volume;
}
if (N || (m.scrollLeft && (T.rr_scrollLeft = m.scrollLeft), m.scrollTop && (T.rr_scrollTop = m.scrollTop)), b) {
const { width: L, height: P } = m.getBoundingClientRect();
T = { class: T.class, rr_width: `${L}px`, rr_height: `${P}px` };
}
w !== "iframe" || S(T.src) || (m.contentDocument || (T.rr_src = T.src), delete T.src);
let W;
try {
customElements.get(w) && (W = !0);
} catch {
}
return { type: me.Element, tagName: w, attributes: T, childNodes: [], isSVG: Kd(m) || void 0, needBlock: b, rootId: D, isCustom: W };
}(e, { doc: r, blockClass: s, blockSelector: i, inlineStylesheet: o, maskInputOptions: l, maskInputFn: u, dataURLOptions: d, inlineImages: p, recordCanvas: f, keepIframeSrcFn: y, newlyAddedElement: h, rootId: C });
case e.TEXT_NODE:
return function(m, g) {
var v;
const { needsMask: I, maskTextFn: M, rootId: E } = g, U = ge.parentNode(m), A = U && U.tagName;
let k = ge.textContent(m);
const R = A === "STYLE" || void 0, O = A === "SCRIPT" || void 0;
if (R && k) {
try {
m.nextSibling || m.previousSibling || (v = U.sheet) != null && v.cssRules && (k = Yr(U.sheet));
} catch (S) {
console.warn(`Cannot get CSS styles from text's parentNode. Error: ${S}`, m);
}
k = gn(k, Di(g.doc));
}
return O && (k = "SCRIPT_PLACEHOLDER"), !R && !O && k && I && (k = M ? M(k, ge.parentElement(m)) : k.replace(/[\S]/g, "*")), { type: me.Text, textContent: k || "", isStyle: R, rootId: E };
}(e, { doc: r, needsMask: a, maskTextFn: c, rootId: C });
case e.CDATA_SECTION_NODE:
return { type: me.CDATA, textContent: "", rootId: C };
case e.COMMENT_NODE:
return { type: me.Comment, textContent: ge.textContent(e) || "", rootId: C };
default:
return !1;
}
}
function ee(e) {
return e == null ? "" : e.toLowerCase();
}
function Ct(e, t) {
const { doc: r, mirror: n, blockClass: s, blockSelector: i, maskTextClass: a, maskTextSelector: o, skipChild: l = !1, inlineStylesheet: c = !0, maskInputOptions: u = {}, maskTextFn: d, maskInputFn: p, slimDOMOptions: f, dataURLOptions: y = {}, inlineImages: h = !1, recordCanvas: C = !1, onSerialize: m, onIframeLoad: g, iframeLoadTimeout: v = 5e3, onStylesheetLoad: I, stylesheetLoadTimeout: M = 5e3, keepIframeSrcFn: E = () => !1, newlyAddedElement: U = !1 } = t;
let { needsMask: A } = t, { preserveWhiteSpace: k = !0 } = t;
A || (A = Rl(e, a, o, A === void 0));
const R = Xd(e, { doc: r, mirror: n, blockClass: s, blockSelector: i, needsMask: A, inlineStylesheet: c, maskInputOptions: u, maskTextFn: d, maskInputFn: p, dataURLOptions: y, inlineImages: h, recordCanvas: C, keepIframeSrcFn: E, newlyAddedElement: U });
if (!R) return console.warn(e, "not serialized"), null;
let O;
O = n.hasNode(e) ? n.getId(e) : !function(b, w) {
return !!(w.comment && b.type === me.Comment || b.type === me.Element && (w.script && (b.tagName === "script" || b.tagName === "link" && (b.attributes.rel === "preload" || b.attributes.rel === "modulepreload") && b.attributes.as === "script" || b.tagName === "link" && b.attributes.rel === "prefetch" && typeof b.attributes.href == "string" && Lo(b.attributes.href) === "js") || w.headFavicon && (b.tagName === "link" && b.attributes.rel === "shortcut icon" || b.tagName === "meta" && (ee(b.attributes.name).match(/^msapplication-tile(image|color)$/) || ee(b.attributes.name) === "application-name" || ee(b.attributes.rel) === "icon" || ee(b.attributes.rel) === "apple-touch-icon" || ee(b.attributes.rel) === "shortcut icon")) || b.tagName === "meta" && (w.headMetaDescKeywords && ee(b.attributes.name).match(/^description|keywords$/) || w.headMetaSocial && (ee(b.attributes.property).match(/^(og|twitter|fb):/) || ee(b.attributes.name).match(/^(og|twitter):/) || ee(b.attributes.name) === "pinterest") || w.headMetaRobots && (ee(b.attributes.name) === "robots" || ee(b.attributes.name) === "googlebot" || ee(b.attributes.name) === "bingbot") || w.headMetaHttpEquiv && b.attributes["http-equiv"] !== void 0 || w.headMetaAuthorship && (ee(b.attributes.name) === "author" || ee(b.attributes.name) === "generator" || ee(b.attributes.name) === "framework" || ee(b.attributes.name) === "publisher" || ee(b.attributes.name) === "progid" || ee(b.attributes.property).match(/^article:/) || ee(b.attributes.property).match(/^product:/)) || w.headMetaVerification && (ee(b.attributes.name) === "google-site-verification" || ee(b.attributes.name) === "yandex-verification" || ee(b.attributes.name) === "csrf-token" || ee(b.attributes.name) === "p:domain_verify" || ee(b.attributes.name) === "verify-v1" || ee(b.attributes.name) === "verification" || ee(b.attributes.name) === "shopify-checkout-api-token"))));
}(R, f) && (k || R.type !== me.Text || R.isStyle || R.textContent.replace(/^\s+|\s+$/gm, "").length) ? kl() : -2;
const S = Object.assign(R, { id: O });
if (n.add(e, S), O === -2) return null;
m && m(e);
let N = !l;
if (S.type === me.Element) {
N = N && !S.needBlock, delete S.needBlock;
const b = ge.shadowRoot(e);
b && Kt(b) && (S.isShadowHost = !0);
}
if ((S.type === me.Document || S.type === me.Element) && N) {
f.headWhitespace && S.type === me.Element && S.tagName === "head" && (k = !1);
const b = { doc: r, mirror: n, blockClass: s, blockSelector: i, needsMask: A, maskTextClass: a, maskTextSelector: o, skipChild: l, inlineStylesheet: c, maskInputOptions: u, maskTextFn: d, maskInputFn: p, slimDOMOptions: f, dataURLOptions: y, inlineImages: h, recordCanvas: C, preserveWhiteSpace: k, onSerialize: m, onIframeLoad: g, iframeLoadTimeout: v, onStylesheetLoad: I, stylesheetLoadTimeout: M, keepIframeSrcFn: E };
if (!(S.type === me.Element && S.tagName === "textarea" && S.attributes.value !== void 0)) for (const T of Array.from(ge.childNodes(e))) {
const B = Ct(T, b);
B && S.childNodes.push(B);
}
let w = null;
if (Sl(e) && (w = ge.shadowRoot(e))) for (const T of Array.from(ge.childNodes(w))) {
const B = Ct(T, b);
B && (Kt(w) && (B.isShadow = !0), S.childNodes.push(B));
}
}
const D = ge.parentNode(e);
return D && Jt(D) && Kt(D) && (S.isShadow = !0), S.type === me.Element && S.tagName === "iframe" && function(b, w, T) {
const B = b.contentWindow;
if (!B) return;
let W, L = !1;
try {
W = B.document.readyState;
} catch {