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