leesto-connect 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,833 @@
1
+ function me(e, t) {
2
+ return e[13] = 1, e[14] = t >> 8, e[15] = t & 255, e[16] = t >> 8, e[17] = t & 255, e;
3
+ }
4
+ var Y = 112, K = 72, J = 89, Q = 115, L;
5
+ function ge() {
6
+ const e = /* @__PURE__ */ new Int32Array(256);
7
+ for (let t = 0; t < 256; t++) {
8
+ let r = t;
9
+ for (let n = 0; n < 8; n++) r = r & 1 ? 3988292384 ^ r >>> 1 : r >>> 1;
10
+ e[t] = r;
11
+ }
12
+ return e;
13
+ }
14
+ function he(e) {
15
+ let t = -1;
16
+ L || (L = ge());
17
+ for (let r = 0; r < e.length; r++) t = L[(t ^ e[r]) & 255] ^ t >>> 8;
18
+ return t ^ -1;
19
+ }
20
+ function pe(e) {
21
+ const t = e.length - 1;
22
+ for (let r = t; r >= 4; r--) if (e[r - 4] === 9 && e[r - 3] === Y && e[r - 2] === K && e[r - 1] === J && e[r] === Q) return r - 3;
23
+ return 0;
24
+ }
25
+ function we(e, t, r = !1) {
26
+ const n = /* @__PURE__ */ new Uint8Array(13);
27
+ t *= 39.3701, n[0] = Y, n[1] = K, n[2] = J, n[3] = Q, n[4] = t >>> 24, n[5] = t >>> 16, n[6] = t >>> 8, n[7] = t & 255, n[8] = n[4], n[9] = n[5], n[10] = n[6], n[11] = n[7], n[12] = 1;
28
+ const s = he(n), o = /* @__PURE__ */ new Uint8Array(4);
29
+ if (o[0] = s >>> 24, o[1] = s >>> 16, o[2] = s >>> 8, o[3] = s & 255, r) {
30
+ const i = pe(e);
31
+ return e.set(n, i), e.set(o, i + 13), e;
32
+ } else {
33
+ const i = /* @__PURE__ */ new Uint8Array(4);
34
+ i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 9;
35
+ const a = /* @__PURE__ */ new Uint8Array(54);
36
+ return a.set(e, 0), a.set(i, 33), a.set(n, 37), a.set(o, 50), a;
37
+ }
38
+ }
39
+ var ye = "AAlwSFlz", Se = "AAAJcEhZ", be = "AAAACXBI";
40
+ function ve(e) {
41
+ let t = e.indexOf(ye);
42
+ return t === -1 && (t = e.indexOf(Se)), t === -1 && (t = e.indexOf(be)), t;
43
+ }
44
+ var Z = "[modern-screenshot]", N = typeof window < "u", Ee = N && "Worker" in window, Ce = N && "atob" in window, Ne = N && "btoa" in window, M = N ? window.navigator?.userAgent : "", ee = M.includes("Chrome"), k = M.includes("AppleWebKit") && !ee, W = M.includes("Firefox"), Te = (e) => e && "__CONTEXT__" in e, Ae = (e) => e.constructor.name === "CSSFontFaceRule", Re = (e) => e.constructor.name === "CSSImportRule", De = (e) => e.constructor.name === "CSSLayerBlockRule", E = (e) => e.nodeType === 1, I = (e) => typeof e.className == "object", te = (e) => e.tagName === "image", Fe = (e) => e.tagName === "use", R = (e) => E(e) && typeof e.style < "u" && !I(e), Ie = (e) => e.nodeType === 8, ke = (e) => e.nodeType === 3, A = (e) => e.tagName === "IMG", _ = (e) => e.tagName === "VIDEO", _e = (e) => e.tagName === "CANVAS", Pe = (e) => e.tagName === "TEXTAREA", Ue = (e) => e.tagName === "INPUT", xe = (e) => e.tagName === "STYLE", $e = (e) => e.tagName === "SCRIPT", Le = (e) => e.tagName === "SELECT", Oe = (e) => e.tagName === "SLOT", Be = (e) => e.tagName === "IFRAME", Me = (...e) => console.warn(Z, ...e);
45
+ function We(e) {
46
+ const t = e?.createElement?.("canvas");
47
+ return t && (t.height = t.width = 1), !!t && "toDataURL" in t && !!t.toDataURL("image/webp").includes("image/webp");
48
+ }
49
+ var O = (e) => e.startsWith("data:");
50
+ function re(e, t) {
51
+ if (e.match(/^[a-z]+:\/\//i)) return e;
52
+ if (N && e.match(/^\/\//)) return window.location.protocol + e;
53
+ if (e.match(/^[a-z]+:/i) || !N) return e;
54
+ const r = P().implementation.createHTMLDocument(), n = r.createElement("base"), s = r.createElement("a");
55
+ return r.head.appendChild(n), r.body.appendChild(s), t && (n.href = t), s.href = e, s.href;
56
+ }
57
+ function P(e) {
58
+ return (e && E(e) ? e?.ownerDocument : e) ?? window.document;
59
+ }
60
+ var U = "http://www.w3.org/2000/svg";
61
+ function qe(e, t, r) {
62
+ const n = P(r).createElementNS(U, "svg");
63
+ return n.setAttributeNS(null, "width", e.toString()), n.setAttributeNS(null, "height", t.toString()), n.setAttributeNS(null, "viewBox", `0 0 ${e} ${t}`), n;
64
+ }
65
+ function je(e, t) {
66
+ let r = new XMLSerializer().serializeToString(e);
67
+ return t && (r = r.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu, "")), `data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`;
68
+ }
69
+ function Ve(e, t) {
70
+ return new Promise((r, n) => {
71
+ const s = new FileReader();
72
+ s.onload = () => r(s.result), s.onerror = () => n(s.error), s.onabort = () => n(/* @__PURE__ */ new Error(`Failed read blob to ${t}`)), t === "dataUrl" ? s.readAsDataURL(e) : t === "arrayBuffer" && s.readAsArrayBuffer(e);
73
+ });
74
+ }
75
+ var He = (e) => Ve(e, "dataUrl");
76
+ function T(e, t) {
77
+ const r = P(t).createElement("img");
78
+ return r.decoding = "sync", r.loading = "eager", r.src = e, r;
79
+ }
80
+ function D(e, t) {
81
+ return new Promise((r) => {
82
+ const { timeout: n, ownerDocument: s, onError: o, onWarn: i } = t ?? {}, a = typeof e == "string" ? T(e, P(s)) : e;
83
+ let c = null, u = null;
84
+ function l() {
85
+ r(a), c && clearTimeout(c), u?.();
86
+ }
87
+ if (n && (c = setTimeout(l, n)), _(a)) {
88
+ const m = a.currentSrc || a.src;
89
+ if (!m)
90
+ return a.poster ? D(a.poster, t).then(r) : l();
91
+ if (a.readyState >= 2) return l();
92
+ const g = l, d = (h) => {
93
+ i?.("Failed video load", m, h), o?.(h), l();
94
+ };
95
+ u = () => {
96
+ a.removeEventListener("loadeddata", g), a.removeEventListener("error", d);
97
+ }, a.addEventListener("loadeddata", g, { once: !0 }), a.addEventListener("error", d, { once: !0 });
98
+ } else {
99
+ const m = te(a) ? a.href.baseVal : a.currentSrc || a.src;
100
+ if (!m) return l();
101
+ const g = async () => {
102
+ if (A(a) && "decode" in a) try {
103
+ await a.decode();
104
+ } catch (h) {
105
+ i?.("Failed to decode image, trying to render anyway", a.dataset.originalSrc || m, h);
106
+ }
107
+ l();
108
+ }, d = (h) => {
109
+ i?.("Failed image load", a.dataset.originalSrc || m, h), l();
110
+ };
111
+ if (A(a) && a.complete) return g();
112
+ u = () => {
113
+ a.removeEventListener("load", g), a.removeEventListener("error", d);
114
+ }, a.addEventListener("load", g, { once: !0 }), a.addEventListener("error", d, { once: !0 });
115
+ }
116
+ });
117
+ }
118
+ async function ze(e, t) {
119
+ R(e) && (A(e) || _(e) ? await D(e, t) : await Promise.all(["img", "video"].flatMap((r) => Array.from(e.querySelectorAll(r)).map((n) => D(n, t)))));
120
+ }
121
+ var ne = /* @__PURE__ */ (function() {
122
+ let t = 0;
123
+ const r = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
124
+ return () => (t += 1, `u${r()}${t}`);
125
+ })();
126
+ function ae(e) {
127
+ return e?.split(",").map((t) => t.trim().replace(/"|'/g, "").toLowerCase()).filter(Boolean);
128
+ }
129
+ var j = 0;
130
+ function Xe(e) {
131
+ const t = `${Z}[#${j}]`;
132
+ return j++, {
133
+ time: (r) => e && console.time(`${t} ${r}`),
134
+ timeEnd: (r) => e && console.timeEnd(`${t} ${r}`),
135
+ warn: (...r) => e && Me(...r)
136
+ };
137
+ }
138
+ function Ge(e) {
139
+ return { cache: e ? "no-cache" : "force-cache" };
140
+ }
141
+ async function x(e, t) {
142
+ return Te(e) ? e : Ye(e, {
143
+ ...t,
144
+ autoDestruct: !0
145
+ });
146
+ }
147
+ async function Ye(e, t) {
148
+ const { scale: r = 1, workerUrl: n, workerNumber: s = 1 } = t || {}, o = !!t?.debug, i = t?.features ?? !0, a = e.ownerDocument ?? (N ? window.document : void 0), c = e.ownerDocument?.defaultView ?? (N ? window : void 0), u = /* @__PURE__ */ new Map(), l = {
149
+ width: 0,
150
+ height: 0,
151
+ quality: 1,
152
+ type: "image/png",
153
+ scale: r,
154
+ backgroundColor: null,
155
+ style: null,
156
+ filter: null,
157
+ maximumCanvasSize: 0,
158
+ timeout: 3e4,
159
+ progress: null,
160
+ debug: o,
161
+ fetch: {
162
+ requestInit: Ge(t?.fetch?.bypassingCache),
163
+ placeholderImage: "data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
164
+ bypassingCache: !1,
165
+ ...t?.fetch
166
+ },
167
+ fetchFn: null,
168
+ font: {},
169
+ drawImageInterval: 100,
170
+ workerUrl: null,
171
+ workerNumber: s,
172
+ onCloneEachNode: null,
173
+ onCloneNode: null,
174
+ onEmbedNode: null,
175
+ onCreateForeignObjectSvg: null,
176
+ includeStyleProperties: null,
177
+ autoDestruct: !1,
178
+ ...t,
179
+ __CONTEXT__: !0,
180
+ log: Xe(o),
181
+ node: e,
182
+ ownerDocument: a,
183
+ ownerWindow: c,
184
+ dpi: r === 1 ? null : 96 * r,
185
+ svgStyleElement: oe(a),
186
+ svgDefsElement: a?.createElementNS(U, "defs"),
187
+ svgStyles: /* @__PURE__ */ new Map(),
188
+ defaultComputedStyles: /* @__PURE__ */ new Map(),
189
+ workers: [...Array.from({ length: Ee && n && s ? s : 0 })].map(() => {
190
+ try {
191
+ const d = new Worker(n);
192
+ return d.onmessage = async (h) => {
193
+ const { url: f, result: p } = h.data;
194
+ p ? u.get(f)?.resolve?.(p) : u.get(f)?.reject?.(/* @__PURE__ */ new Error(`Error receiving message from worker: ${f}`));
195
+ }, d.onmessageerror = (h) => {
196
+ const { url: f } = h.data;
197
+ u.get(f)?.reject?.(/* @__PURE__ */ new Error(`Error receiving message from worker: ${f}`));
198
+ }, d;
199
+ } catch (d) {
200
+ return l.log.warn("Failed to new Worker", d), null;
201
+ }
202
+ }).filter(Boolean),
203
+ fontFamilies: /* @__PURE__ */ new Map(),
204
+ fontCssTexts: /* @__PURE__ */ new Map(),
205
+ acceptOfImage: `${[
206
+ We(a) && "image/webp",
207
+ "image/svg+xml",
208
+ "image/*",
209
+ "*/*"
210
+ ].filter(Boolean).join(",")};q=0.8`,
211
+ requests: u,
212
+ drawImageCount: 0,
213
+ tasks: [],
214
+ features: i,
215
+ isEnable: (d) => d === "restoreScrollPosition" ? typeof i == "boolean" ? !1 : i[d] ?? !1 : typeof i == "boolean" ? i : i[d] ?? !0,
216
+ shadowRoots: []
217
+ };
218
+ l.log.time("wait until load"), await ze(e, {
219
+ timeout: l.timeout,
220
+ onWarn: l.log.warn
221
+ }), l.log.timeEnd("wait until load");
222
+ const { width: m, height: g } = Ke(e, l);
223
+ return l.width = m, l.height = g, l;
224
+ }
225
+ function oe(e) {
226
+ if (!e) return;
227
+ const t = e.createElement("style"), r = t.ownerDocument.createTextNode(`
228
+ .______background-clip--text {
229
+ background-clip: text;
230
+ -webkit-background-clip: text;
231
+ }
232
+ `);
233
+ return t.appendChild(r), t;
234
+ }
235
+ function Ke(e, t) {
236
+ let { width: r, height: n } = t;
237
+ if (E(e) && (!r || !n)) {
238
+ const s = e.getBoundingClientRect();
239
+ r = r || s.width || Number(e.getAttribute("width")) || 0, n = n || s.height || Number(e.getAttribute("height")) || 0;
240
+ }
241
+ return {
242
+ width: r,
243
+ height: n
244
+ };
245
+ }
246
+ async function Je(e, t) {
247
+ const { log: r, timeout: n, drawImageCount: s, drawImageInterval: o } = t;
248
+ r.time("image to canvas");
249
+ const i = await D(e, {
250
+ timeout: n,
251
+ onWarn: t.log.warn
252
+ }), { canvas: a, context2d: c } = Qe(e.ownerDocument, t), u = () => {
253
+ try {
254
+ c?.drawImage(i, 0, 0, a.width, a.height);
255
+ } catch (l) {
256
+ t.log.warn("Failed to drawImage", l);
257
+ }
258
+ };
259
+ if (u(), t.isEnable("fixSvgXmlDecode")) for (let l = 0; l < s; l++) await new Promise((m) => {
260
+ setTimeout(() => {
261
+ c?.clearRect(0, 0, a.width, a.height), u(), m();
262
+ }, l + o);
263
+ });
264
+ return t.drawImageCount = 0, r.timeEnd("image to canvas"), a;
265
+ }
266
+ function Qe(e, t) {
267
+ const { width: r, height: n, scale: s, backgroundColor: o, maximumCanvasSize: i } = t, a = e.createElement("canvas");
268
+ a.width = Math.floor(r * s), a.height = Math.floor(n * s), a.style.width = `${r}px`, a.style.height = `${n}px`, i && (a.width > i || a.height > i) && (a.width > i && a.height > i ? a.width > a.height ? (a.height *= i / a.width, a.width = i) : (a.width *= i / a.height, a.height = i) : a.width > i ? (a.height *= i / a.width, a.width = i) : (a.width *= i / a.height, a.height = i));
269
+ const c = a.getContext("2d");
270
+ return c && o && (c.fillStyle = o, c.fillRect(0, 0, a.width, a.height)), {
271
+ canvas: a,
272
+ context2d: c
273
+ };
274
+ }
275
+ function se(e, t) {
276
+ if (e.ownerDocument) try {
277
+ const o = e.toDataURL();
278
+ if (o !== "data:,") return T(o, e.ownerDocument);
279
+ } catch (o) {
280
+ t.log.warn("Failed to clone canvas", o);
281
+ }
282
+ const r = e.cloneNode(!1), n = e.getContext("2d"), s = r.getContext("2d");
283
+ try {
284
+ return n && s && s.putImageData(n.getImageData(0, 0, e.width, e.height), 0, 0), r;
285
+ } catch (o) {
286
+ t.log.warn("Failed to clone canvas", o);
287
+ }
288
+ return r;
289
+ }
290
+ function Ze(e, t) {
291
+ try {
292
+ if (e?.contentDocument?.documentElement) return q(e.contentDocument.documentElement, t);
293
+ } catch (r) {
294
+ t.log.warn("Failed to clone iframe", r);
295
+ }
296
+ return e.cloneNode(!1);
297
+ }
298
+ function et(e) {
299
+ const t = e.cloneNode(!1);
300
+ return e.currentSrc && e.currentSrc !== e.src && (t.src = e.currentSrc, t.srcset = ""), t.loading === "lazy" && (t.loading = "eager"), t;
301
+ }
302
+ async function tt(e, t) {
303
+ if (e.ownerDocument && !e.currentSrc && e.poster) return T(e.poster, e.ownerDocument);
304
+ const r = e.cloneNode(!1);
305
+ r.crossOrigin = "anonymous", e.currentSrc && e.currentSrc !== e.src && (r.src = e.currentSrc);
306
+ const n = r.ownerDocument;
307
+ if (n) {
308
+ let s = !0;
309
+ if (await D(r, {
310
+ onError: () => s = !1,
311
+ onWarn: t.log.warn
312
+ }), !s)
313
+ return e.poster ? T(e.poster, e.ownerDocument) : r;
314
+ r.currentTime = e.currentTime, await new Promise((i) => {
315
+ r.addEventListener("seeked", i, { once: !0 });
316
+ });
317
+ const o = n.createElement("canvas");
318
+ o.width = e.offsetWidth, o.height = e.offsetHeight;
319
+ try {
320
+ const i = o.getContext("2d");
321
+ i && i.drawImage(r, 0, 0, o.width, o.height);
322
+ } catch (i) {
323
+ return t.log.warn("Failed to clone video", i), e.poster ? T(e.poster, e.ownerDocument) : r;
324
+ }
325
+ return se(o, t);
326
+ }
327
+ return r;
328
+ }
329
+ function rt(e, t) {
330
+ return _e(e) ? se(e, t) : Be(e) ? Ze(e, t) : A(e) ? et(e) : _(e) ? tt(e, t) : e.cloneNode(!1);
331
+ }
332
+ function nt(e) {
333
+ let t = e.sandbox;
334
+ if (!t) {
335
+ const { ownerDocument: r } = e;
336
+ try {
337
+ r && (t = r.createElement("iframe"), t.id = `__SANDBOX__${ne()}`, t.width = "0", t.height = "0", t.style.visibility = "hidden", t.style.position = "fixed", r.body.appendChild(t), t.srcdoc = '<!DOCTYPE html><meta charset="UTF-8"><title></title><body>', e.sandbox = t);
338
+ } catch (n) {
339
+ e.log.warn("Failed to getSandBox", n);
340
+ }
341
+ }
342
+ return t;
343
+ }
344
+ var at = [
345
+ "width",
346
+ "height",
347
+ "-webkit-text-fill-color"
348
+ ], ot = ["stroke", "fill"];
349
+ function ie(e, t, r) {
350
+ const { defaultComputedStyles: n } = r, s = e.nodeName.toLowerCase(), o = I(e) && s !== "svg", i = o ? ot.map((h) => [h, e.getAttribute(h)]).filter(([, h]) => h !== null) : [], a = [
351
+ o && "svg",
352
+ s,
353
+ i.map((h, f) => `${h}=${f}`).join(","),
354
+ t
355
+ ].filter(Boolean).join(":");
356
+ if (n.has(a)) return n.get(a);
357
+ const c = nt(r)?.contentWindow;
358
+ if (!c) return /* @__PURE__ */ new Map();
359
+ const u = c?.document;
360
+ let l, m;
361
+ o ? (l = u.createElementNS(U, "svg"), m = l.ownerDocument.createElementNS(l.namespaceURI, s), i.forEach(([h, f]) => {
362
+ m.setAttributeNS(null, h, f);
363
+ }), l.appendChild(m)) : l = m = u.createElement(s), m.textContent = " ", u.body.appendChild(l);
364
+ const g = c.getComputedStyle(m, t), d = /* @__PURE__ */ new Map();
365
+ for (let h = g.length, f = 0; f < h; f++) {
366
+ const p = g.item(f);
367
+ at.includes(p) || d.set(p, g.getPropertyValue(p));
368
+ }
369
+ return u.body.removeChild(l), n.set(a, d), d;
370
+ }
371
+ function le(e, t, r) {
372
+ const n = /* @__PURE__ */ new Map(), s = [], o = /* @__PURE__ */ new Map();
373
+ if (r) for (const a of r) i(a);
374
+ else for (let a = e.length, c = 0; c < a; c++) i(e.item(c));
375
+ for (let a = s.length, c = 0; c < a; c++) o.get(s[c])?.forEach((u, l) => n.set(l, u));
376
+ function i(a) {
377
+ const c = e.getPropertyValue(a), u = e.getPropertyPriority(a), l = a.lastIndexOf("-"), m = l > -1 ? a.substring(0, l) : void 0;
378
+ if (m) {
379
+ let g = o.get(m);
380
+ g || (g = /* @__PURE__ */ new Map(), o.set(m, g)), g.set(a, [c, u]);
381
+ }
382
+ t.get(a) === c && !u || (m ? s.push(m) : n.set(a, [c, u]));
383
+ }
384
+ return n;
385
+ }
386
+ function st(e, t, r, n) {
387
+ const { ownerWindow: s, includeStyleProperties: o, currentParentNodeStyle: i } = n, a = t.style, c = s.getComputedStyle(e), u = ie(e, null, n);
388
+ i?.forEach((m, g) => {
389
+ u.delete(g);
390
+ });
391
+ const l = le(c, u, o);
392
+ l.delete("transition-property"), l.delete("all"), l.delete("d"), l.delete("content"), r && (l.delete("position"), l.delete("margin-top"), l.delete("margin-right"), l.delete("margin-bottom"), l.delete("margin-left"), l.delete("margin-block-start"), l.delete("margin-block-end"), l.delete("margin-inline-start"), l.delete("margin-inline-end"), l.set("box-sizing", ["border-box", ""])), l.get("background-clip")?.[0] === "text" && t.classList.add("______background-clip--text"), ee && (l.has("font-kerning") || l.set("font-kerning", ["normal", ""]), (l.get("overflow-x")?.[0] === "hidden" || l.get("overflow-y")?.[0] === "hidden") && l.get("text-overflow")?.[0] === "ellipsis" && e.scrollWidth === e.clientWidth && l.set("text-overflow", ["clip", ""]));
393
+ for (let m = a.length, g = 0; g < m; g++) a.removeProperty(a.item(g));
394
+ return l.forEach(([m, g], d) => {
395
+ a.setProperty(d, m, g);
396
+ }), l;
397
+ }
398
+ function it(e, t) {
399
+ (Pe(e) || Ue(e) || Le(e)) && t.setAttribute("value", e.value);
400
+ }
401
+ var lt = ["::before", "::after"], ct = [
402
+ "::-webkit-scrollbar",
403
+ "::-webkit-scrollbar-button",
404
+ "::-webkit-scrollbar-thumb",
405
+ "::-webkit-scrollbar-track",
406
+ "::-webkit-scrollbar-track-piece",
407
+ "::-webkit-scrollbar-corner",
408
+ "::-webkit-resizer"
409
+ ];
410
+ function ut(e, t, r, n, s) {
411
+ const { ownerWindow: o, svgStyleElement: i, svgStyles: a, currentNodeStyle: c } = n;
412
+ if (!i || !o) return;
413
+ function u(l) {
414
+ const m = o.getComputedStyle(e, l);
415
+ let g = m.getPropertyValue("content");
416
+ if (!g || g === "none") return;
417
+ s?.(g), g = g.replace(/(')|(")|(counter\(.+\))/g, "");
418
+ const d = [ne()], h = ie(e, l, n);
419
+ c?.forEach((S, b) => {
420
+ h.delete(b);
421
+ });
422
+ const f = le(m, h, n.includeStyleProperties);
423
+ f.delete("content"), f.delete("-webkit-locale"), f.get("background-clip")?.[0] === "text" && t.classList.add("______background-clip--text");
424
+ const p = [`content: '${g}';`];
425
+ if (f.forEach(([S, b], C) => {
426
+ p.push(`${C}: ${S}${b ? " !important" : ""};`);
427
+ }), p.length === 1) return;
428
+ try {
429
+ t.className = [t.className, ...d].join(" ");
430
+ } catch (S) {
431
+ n.log.warn("Failed to copyPseudoClass", S);
432
+ return;
433
+ }
434
+ const y = p.join(`
435
+ `);
436
+ let w = a.get(y);
437
+ w || (w = [], a.set(y, w)), w.push(`.${d[0]}${l}`);
438
+ }
439
+ lt.forEach(u), r && ct.forEach(u);
440
+ }
441
+ var V = /* @__PURE__ */ new Set(["symbol"]);
442
+ async function H(e, t, r, n, s) {
443
+ if (E(r) && (xe(r) || $e(r)) || n.filter && !n.filter(r)) return;
444
+ V.has(t.nodeName) || V.has(r.nodeName) ? n.currentParentNodeStyle = void 0 : n.currentParentNodeStyle = n.currentNodeStyle;
445
+ const o = await q(r, n, !1, s);
446
+ n.isEnable("restoreScrollPosition") && ft(e, o), t.appendChild(o);
447
+ }
448
+ async function z(e, t, r, n) {
449
+ let s = e.firstChild;
450
+ E(e) && e.shadowRoot && (s = e.shadowRoot?.firstChild, r.shadowRoots.push(e.shadowRoot));
451
+ for (let o = s; o; o = o.nextSibling)
452
+ if (!Ie(o))
453
+ if (E(o) && Oe(o) && typeof o.assignedNodes == "function") {
454
+ const i = o.assignedNodes();
455
+ for (let a = 0; a < i.length; a++) await H(e, t, i[a], r, n);
456
+ } else await H(e, t, o, r, n);
457
+ }
458
+ function ft(e, t) {
459
+ if (!R(e) || !R(t)) return;
460
+ const { scrollTop: r, scrollLeft: n } = e;
461
+ if (!r && !n) return;
462
+ const { transform: s } = t.style, o = new DOMMatrix(s), { a: i, b: a, c, d: u } = o;
463
+ o.a = 1, o.b = 0, o.c = 0, o.d = 1, o.translateSelf(-n, -r), o.a = i, o.b = a, o.c = c, o.d = u, t.style.transform = o.toString();
464
+ }
465
+ function dt(e, t) {
466
+ const { backgroundColor: r, width: n, height: s, style: o } = t, i = e.style;
467
+ if (r && i.setProperty("background-color", r, "important"), n && i.setProperty("width", `${n}px`, "important"), s && i.setProperty("height", `${s}px`, "important"), o) for (const a in o) i[a] = o[a];
468
+ }
469
+ var mt = /^[\w-:]+$/;
470
+ async function q(e, t, r = !1, n) {
471
+ const { ownerDocument: s, ownerWindow: o, fontFamilies: i, onCloneEachNode: a } = t;
472
+ if (s && ke(e))
473
+ return n && /\S/.test(e.data) && n(e.data), s.createTextNode(e.data);
474
+ if (s && o && E(e) && (R(e) || I(e))) {
475
+ const u = await rt(e, t);
476
+ if (t.isEnable("removeAbnormalAttributes")) {
477
+ const f = u.getAttributeNames();
478
+ for (let p = f.length, y = 0; y < p; y++) {
479
+ const w = f[y];
480
+ mt.test(w) || u.removeAttribute(w);
481
+ }
482
+ }
483
+ const l = t.currentNodeStyle = st(e, u, r, t);
484
+ r && dt(u, t);
485
+ let m = !1;
486
+ if (t.isEnable("copyScrollbar")) {
487
+ const f = [l.get("overflow-x")?.[0], l.get("overflow-y")?.[0]];
488
+ m = f.includes("scroll") || (f.includes("auto") || f.includes("overlay")) && (e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth);
489
+ }
490
+ const g = l.get("text-transform")?.[0], d = ae(l.get("font-family")?.[0]), h = d ? (f) => {
491
+ g === "uppercase" ? f = f.toUpperCase() : g === "lowercase" ? f = f.toLowerCase() : g === "capitalize" && (f = f[0].toUpperCase() + f.substring(1)), d.forEach((p) => {
492
+ let y = i.get(p);
493
+ y || i.set(p, y = /* @__PURE__ */ new Set()), f.split("").forEach((w) => y.add(w));
494
+ });
495
+ } : void 0;
496
+ return ut(e, u, m, t, h), it(e, u), _(e) || await z(e, u, t, h), await a?.(u), u;
497
+ }
498
+ const c = e.cloneNode(!1);
499
+ return await z(e, c, t), await a?.(c), c;
500
+ }
501
+ function gt(e) {
502
+ if (e.ownerDocument = void 0, e.ownerWindow = void 0, e.svgStyleElement = void 0, e.svgDefsElement = void 0, e.svgStyles.clear(), e.defaultComputedStyles.clear(), e.sandbox) {
503
+ try {
504
+ e.sandbox.remove();
505
+ } catch (t) {
506
+ e.log.warn("Failed to destroyContext", t);
507
+ }
508
+ e.sandbox = void 0;
509
+ }
510
+ e.workers = [], e.fontFamilies.clear(), e.fontCssTexts.clear(), e.requests.clear(), e.tasks = [], e.shadowRoots = [];
511
+ }
512
+ function ht(e) {
513
+ const { url: t, timeout: r, responseType: n, ...s } = e, o = new AbortController(), i = r ? setTimeout(() => o.abort(), r) : void 0;
514
+ return fetch(t, {
515
+ signal: o.signal,
516
+ ...s
517
+ }).then((a) => {
518
+ if (!a.ok) throw new Error("Failed fetch, not 2xx response", { cause: a });
519
+ switch (n) {
520
+ case "arrayBuffer":
521
+ return a.arrayBuffer();
522
+ case "dataUrl":
523
+ return a.blob().then(He);
524
+ default:
525
+ return a.text();
526
+ }
527
+ }).finally(() => clearTimeout(i));
528
+ }
529
+ function F(e, t) {
530
+ const { url: r, requestType: n = "text", responseType: s = "text", imageDom: o } = t;
531
+ let i = r;
532
+ const { timeout: a, acceptOfImage: c, requests: u, fetchFn: l, fetch: { requestInit: m, bypassingCache: g, placeholderImage: d }, font: h, workers: f, fontFamilies: p } = e;
533
+ n === "image" && (k || W) && e.drawImageCount++;
534
+ let y = u.get(r);
535
+ if (!y) {
536
+ g && g instanceof RegExp && g.test(i) && (i += (/\?/.test(i) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
537
+ const w = n.startsWith("font") && h && h.minify, S = /* @__PURE__ */ new Set();
538
+ w && n.split(";")[1].split(",").forEach((v) => {
539
+ p.has(v) && p.get(v).forEach(($) => S.add($));
540
+ });
541
+ const b = w && S.size, C = {
542
+ url: i,
543
+ timeout: a,
544
+ responseType: b ? "arrayBuffer" : s,
545
+ headers: n === "image" ? { accept: c } : void 0,
546
+ ...m
547
+ };
548
+ y = {
549
+ type: n,
550
+ resolve: void 0,
551
+ reject: void 0,
552
+ response: null
553
+ }, y.response = (async () => {
554
+ if (l && n === "image") {
555
+ const v = await l(r);
556
+ if (v) return v;
557
+ }
558
+ return !k && r.startsWith("http") && f.length ? new Promise((v, $) => {
559
+ f[u.size & f.length - 1].postMessage({
560
+ rawUrl: r,
561
+ ...C
562
+ }), y.resolve = v, y.reject = $;
563
+ }) : ht(C);
564
+ })().catch((v) => {
565
+ if (u.delete(r), n === "image" && d)
566
+ return e.log.warn("Failed to fetch image base64, trying to use placeholder image", i), typeof d == "string" ? d : d(o);
567
+ throw v;
568
+ }), u.set(r, y);
569
+ }
570
+ return y.response;
571
+ }
572
+ async function ce(e, t, r, n) {
573
+ if (!ue(e)) return e;
574
+ for (const [s, o] of pt(e, t)) try {
575
+ const i = await F(r, {
576
+ url: o,
577
+ requestType: n ? "image" : "text",
578
+ responseType: "dataUrl"
579
+ });
580
+ e = e.replace(wt(s), `$1${i}$3`);
581
+ } catch (i) {
582
+ r.log.warn("Failed to fetch css data url", s, i);
583
+ }
584
+ return e;
585
+ }
586
+ function ue(e) {
587
+ return /url\((['"]?)([^'"]+?)\1\)/.test(e);
588
+ }
589
+ var fe = /url\((['"]?)([^'"]+?)\1\)/g;
590
+ function pt(e, t) {
591
+ const r = [];
592
+ return e.replace(fe, (n, s, o) => (r.push([o, re(o, t)]), n)), r.filter(([n]) => !O(n));
593
+ }
594
+ function wt(e) {
595
+ const t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
596
+ return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
597
+ }
598
+ var yt = [
599
+ "background-image",
600
+ "border-image-source",
601
+ "-webkit-border-image",
602
+ "-webkit-mask-image",
603
+ "list-style-image"
604
+ ];
605
+ function St(e, t) {
606
+ return yt.map((r) => {
607
+ const n = e.getPropertyValue(r);
608
+ return !n || n === "none" ? null : ((k || W) && t.drawImageCount++, ce(n, null, t, !0).then((s) => {
609
+ !s || n === s || e.setProperty(r, s, e.getPropertyPriority(r));
610
+ }));
611
+ }).filter(Boolean);
612
+ }
613
+ function bt(e, t) {
614
+ if (A(e)) {
615
+ const r = e.currentSrc || e.src;
616
+ if (!O(r)) return [F(t, {
617
+ url: r,
618
+ imageDom: e,
619
+ requestType: "image",
620
+ responseType: "dataUrl"
621
+ }).then((n) => {
622
+ n && (e.srcset = "", e.dataset.originalSrc = r, e.src = n || "");
623
+ })];
624
+ (k || W) && t.drawImageCount++;
625
+ } else if (I(e) && !O(e.href.baseVal)) {
626
+ const r = e.href.baseVal;
627
+ return [F(t, {
628
+ url: r,
629
+ imageDom: e,
630
+ requestType: "image",
631
+ responseType: "dataUrl"
632
+ }).then((n) => {
633
+ n && (e.dataset.originalSrc = r, e.href.baseVal = n || "");
634
+ })];
635
+ }
636
+ return [];
637
+ }
638
+ function vt(e, t) {
639
+ const { ownerDocument: r, svgDefsElement: n } = t, s = e.getAttribute("href") ?? e.getAttribute("xlink:href");
640
+ if (!s) return [];
641
+ const [o, i] = s.split("#");
642
+ if (i) {
643
+ const a = `#${i}`, c = t.shadowRoots.reduce((u, l) => u ?? l.querySelector(`svg ${a}`), r?.querySelector(`svg ${a}`));
644
+ if (o && e.setAttribute("href", a), n?.querySelector(a)) return [];
645
+ if (c)
646
+ return n?.appendChild(c.cloneNode(!0)), [];
647
+ if (o) return [F(t, {
648
+ url: o,
649
+ responseType: "text"
650
+ }).then((u) => {
651
+ n?.insertAdjacentHTML("beforeend", u);
652
+ })];
653
+ }
654
+ return [];
655
+ }
656
+ function de(e, t) {
657
+ const { tasks: r } = t;
658
+ E(e) && ((A(e) || te(e)) && r.push(...bt(e, t)), Fe(e) && r.push(...vt(e, t))), R(e) && r.push(...St(e.style, t)), e.childNodes.forEach((n) => {
659
+ de(n, t);
660
+ });
661
+ }
662
+ async function Et(e, t) {
663
+ const { ownerDocument: r, svgStyleElement: n, fontFamilies: s, fontCssTexts: o, tasks: i, font: a } = t;
664
+ if (!(!r || !n || !s.size))
665
+ if (a && a.cssText) {
666
+ const c = G(a.cssText, t);
667
+ n.appendChild(r.createTextNode(`${c}
668
+ `));
669
+ } else {
670
+ const c = Array.from(r.styleSheets).filter((d) => {
671
+ try {
672
+ return "cssRules" in d && !!d.cssRules.length;
673
+ } catch (h) {
674
+ return t.log.warn(`Error while reading CSS rules from ${d.href}`, h), !1;
675
+ }
676
+ }), u = r.implementation.createHTMLDocument(""), l = u.createElement("style");
677
+ u.head.appendChild(l);
678
+ const m = l.sheet;
679
+ await Promise.all(c.flatMap((d) => Array.from(d.cssRules).map(async (h) => {
680
+ if (Re(h)) {
681
+ const f = h.href;
682
+ let p = "";
683
+ try {
684
+ p = await F(t, {
685
+ url: f,
686
+ requestType: "text",
687
+ responseType: "text"
688
+ });
689
+ } catch (w) {
690
+ t.log.warn(`Error fetch remote css import from ${f}`, w);
691
+ }
692
+ const y = p.replace(fe, (w, S, b) => w.replace(b, re(b, f)));
693
+ for (const w of Nt(y)) try {
694
+ m.insertRule(w, m.cssRules.length);
695
+ } catch (S) {
696
+ t.log.warn("Error inserting rule from remote css import", {
697
+ rule: w,
698
+ error: S
699
+ });
700
+ }
701
+ }
702
+ }))), m.cssRules.length && c.push(m);
703
+ const g = [];
704
+ c.forEach((d) => {
705
+ B(d.cssRules, g);
706
+ }), g.filter((d) => Ae(d) && ue(d.style.getPropertyValue("src")) && ae(d.style.getPropertyValue("font-family"))?.some((h) => s.has(h))).forEach((d) => {
707
+ const h = d, f = o.get(h.cssText);
708
+ f ? n.appendChild(r.createTextNode(`${f}
709
+ `)) : i.push(ce(h.cssText, h.parentStyleSheet ? h.parentStyleSheet.href : null, t).then((p) => {
710
+ p = G(p, t), o.set(h.cssText, p), n.appendChild(r.createTextNode(`${p}
711
+ `));
712
+ }));
713
+ });
714
+ }
715
+ }
716
+ var Ct = /(\/\*[\s\S]*?\*\/)/g, X = /((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;
717
+ function Nt(e) {
718
+ if (e == null) return [];
719
+ const t = [];
720
+ let r = e.replace(Ct, "");
721
+ for (; ; ) {
722
+ const o = X.exec(r);
723
+ if (!o) break;
724
+ t.push(o[0]);
725
+ }
726
+ r = r.replace(X, "");
727
+ const n = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, s = /* @__PURE__ */ new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
728
+ for (; ; ) {
729
+ let o = n.exec(r);
730
+ if (o)
731
+ s.lastIndex = n.lastIndex;
732
+ else if (o = s.exec(r), o) n.lastIndex = s.lastIndex;
733
+ else break;
734
+ t.push(o[0]);
735
+ }
736
+ return t;
737
+ }
738
+ var Tt = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, At = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
739
+ function G(e, t) {
740
+ const { font: r } = t, n = r ? r?.preferredFormat : void 0;
741
+ return n ? e.replace(At, (s) => {
742
+ for (; ; ) {
743
+ const [o, , i] = Tt.exec(s) || [];
744
+ if (!i) return "";
745
+ if (i === n) return `src: ${o};`;
746
+ }
747
+ }) : e;
748
+ }
749
+ function B(e, t = []) {
750
+ for (const r of Array.from(e)) De(r) ? t.push(...B(r.cssRules)) : "cssRules" in r ? B(r.cssRules, t) : t.push(r);
751
+ return t;
752
+ }
753
+ var Rt = /\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;
754
+ function Dt(e) {
755
+ return Rt.test(e.innerHTML);
756
+ }
757
+ async function Ft(e, t) {
758
+ const r = await x(e, t);
759
+ if (E(r.node) && I(r.node) && !Dt(r.node)) return r.node;
760
+ const { ownerDocument: n, log: s, tasks: o, svgStyleElement: i, svgDefsElement: a, svgStyles: c, font: u, progress: l, autoDestruct: m, onCloneNode: g, onEmbedNode: d, onCreateForeignObjectSvg: h } = r;
761
+ s.time("clone node");
762
+ const f = await q(r.node, r, !0);
763
+ if (i && n) {
764
+ let b = "";
765
+ c.forEach((C, v) => {
766
+ b += `${C.join(`,
767
+ `)} {
768
+ ${v}
769
+ }
770
+ `;
771
+ }), i.appendChild(n.createTextNode(b));
772
+ }
773
+ s.timeEnd("clone node"), await g?.(f), u !== !1 && E(f) && (s.time("embed web font"), await Et(f, r), s.timeEnd("embed web font")), s.time("embed node"), de(f, r);
774
+ const p = o.length;
775
+ let y = 0;
776
+ const w = async () => {
777
+ for (; ; ) {
778
+ const b = o.pop();
779
+ if (!b) break;
780
+ try {
781
+ await b;
782
+ } catch (C) {
783
+ r.log.warn("Failed to run task", C);
784
+ }
785
+ l?.(++y, p);
786
+ }
787
+ };
788
+ l?.(y, p), await Promise.all([...Array.from({ length: 4 })].map(w)), s.timeEnd("embed node"), await d?.(f);
789
+ const S = It(f, r);
790
+ return a && S.insertBefore(a, S.children[0]), i && S.insertBefore(i, S.children[0]), m && gt(r), await h?.(S), S;
791
+ }
792
+ function It(e, t) {
793
+ const { width: r, height: n } = t, s = qe(r, n, e.ownerDocument), o = s.ownerDocument.createElementNS(s.namespaceURI, "foreignObject");
794
+ return o.setAttributeNS(null, "x", "0%"), o.setAttributeNS(null, "y", "0%"), o.setAttributeNS(null, "width", "100%"), o.setAttributeNS(null, "height", "100%"), o.append(e), s.appendChild(o), s;
795
+ }
796
+ async function kt(e, t) {
797
+ const r = await x(e, t), n = await Ft(r), s = je(n, r.isEnable("removeControlCharacter"));
798
+ return r.autoDestruct || (r.svgStyleElement = oe(r.ownerDocument), r.svgDefsElement = r.ownerDocument?.createElementNS(U, "defs"), r.svgStyles.clear()), await Je(T(s, n.ownerDocument), r);
799
+ }
800
+ async function _t(e, t) {
801
+ const r = await x(e, t), { log: n, quality: s, type: o, dpi: i } = r, a = await kt(r);
802
+ n.time("canvas to data url");
803
+ let c = a.toDataURL(o, s);
804
+ if (["image/png", "image/jpeg"].includes(o) && i && Ce && Ne) {
805
+ const [u, l] = c.split(",");
806
+ let m = 0, g = !1;
807
+ if (o === "image/png") {
808
+ const w = ve(l);
809
+ w >= 0 ? (m = Math.ceil((w + 28) / 3) * 4, g = !0) : m = 44;
810
+ } else o === "image/jpeg" && (m = 24);
811
+ const d = l.substring(0, m), h = l.substring(m), f = window.atob(d), p = new Uint8Array(f.length);
812
+ for (let w = 0; w < p.length; w++) p[w] = f.charCodeAt(w);
813
+ const y = o === "image/png" ? we(p, i, g) : me(p, i);
814
+ c = [
815
+ u,
816
+ ",",
817
+ window.btoa(String.fromCharCode(...y)),
818
+ h
819
+ ].join("");
820
+ }
821
+ return n.timeEnd("canvas to data url"), c;
822
+ }
823
+ async function Pt(e, t) {
824
+ return _t(await x(e, {
825
+ ...t,
826
+ type: "image/png"
827
+ }));
828
+ }
829
+ export {
830
+ Pt as domToPng
831
+ };
832
+
833
+ //# sourceMappingURL=dist-BTlWkbvW.js.map