@vouchfor/embeds 0.0.0-experiment.f7614ec → 0.0.0-experiment.f958e09

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/dist/es/embeds.js +1139 -7
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +38 -0
  6. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  7. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +1 -1
  8. package/dist/es/src/components/PlayerEmbed/index.d.ts +5 -3
  9. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +1 -1
  10. package/dist/es/src/index.d.ts +1 -0
  11. package/dist/iife/dialog-embed/embed.iife.js +1750 -0
  12. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  13. package/dist/iife/embeds.iife.js +559 -381
  14. package/dist/iife/embeds.iife.js.map +1 -1
  15. package/dist/iife/player-embed/embed.iife.js +1612 -0
  16. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  17. package/package.json +39 -30
  18. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  19. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  20. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  21. package/src/components/DialogEmbed/index.ts +97 -0
  22. package/src/components/PlayerEmbed/controllers/event-forwarder.ts +2 -1
  23. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +1 -1
  24. package/src/components/PlayerEmbed/index.ts +6 -3
  25. package/src/components/PlayerEmbed/tests/data.ts +1 -1
  26. package/src/index.ts +1 -0
  27. package/dist/es/browser-0a211a9c.js +0 -433
  28. package/dist/es/browser-0a211a9c.js.map +0 -1
  29. package/dist/es/index-b6636843.js +0 -9984
  30. package/dist/es/index-b6636843.js.map +0 -1
@@ -1,433 +0,0 @@
1
- var I = Object.defineProperty;
2
- var q = (o, e, t) => e in o ? I(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var U = (o, e, t) => (q(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { c as G, g as H } from "./index-b6636843.js";
5
- function J(o, e) {
6
- for (var t = 0; t < e.length; t++) {
7
- const r = e[t];
8
- if (typeof r != "string" && !Array.isArray(r)) {
9
- for (const n in r)
10
- if (n !== "default" && !(n in o)) {
11
- const i = Object.getOwnPropertyDescriptor(r, n);
12
- i && Object.defineProperty(o, n, i.get ? i : {
13
- enumerable: !0,
14
- get: () => r[n]
15
- });
16
- }
17
- }
18
- }
19
- return Object.freeze(Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }));
20
- }
21
- function h(o) {
22
- if (typeof o != "string")
23
- throw new TypeError("Path must be a string. Received " + JSON.stringify(o));
24
- }
25
- function L(o, e) {
26
- for (var t = "", r = 0, n = -1, i = 0, a, s = 0; s <= o.length; ++s) {
27
- if (s < o.length)
28
- a = o.charCodeAt(s);
29
- else {
30
- if (a === 47)
31
- break;
32
- a = 47;
33
- }
34
- if (a === 47) {
35
- if (!(n === s - 1 || i === 1))
36
- if (n !== s - 1 && i === 2) {
37
- if (t.length < 2 || r !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
38
- if (t.length > 2) {
39
- var l = t.lastIndexOf("/");
40
- if (l !== t.length - 1) {
41
- l === -1 ? (t = "", r = 0) : (t = t.slice(0, l), r = t.length - 1 - t.lastIndexOf("/")), n = s, i = 0;
42
- continue;
43
- }
44
- } else if (t.length === 2 || t.length === 1) {
45
- t = "", r = 0, n = s, i = 0;
46
- continue;
47
- }
48
- }
49
- e && (t.length > 0 ? t += "/.." : t = "..", r = 2);
50
- } else
51
- t.length > 0 ? t += "/" + o.slice(n + 1, s) : t = o.slice(n + 1, s), r = s - n - 1;
52
- n = s, i = 0;
53
- } else
54
- a === 46 && i !== -1 ? ++i : i = -1;
55
- }
56
- return t;
57
- }
58
- function V(o, e) {
59
- var t = e.dir || e.root, r = e.base || (e.name || "") + (e.ext || "");
60
- return t ? t === e.root ? t + r : t + o + r : r;
61
- }
62
- var p = {
63
- // path.resolve([from ...], to)
64
- resolve: function() {
65
- for (var e = "", t = !1, r, n = arguments.length - 1; n >= -1 && !t; n--) {
66
- var i;
67
- n >= 0 ? i = arguments[n] : (r === void 0 && (r = process.cwd()), i = r), h(i), i.length !== 0 && (e = i + "/" + e, t = i.charCodeAt(0) === 47);
68
- }
69
- return e = L(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
70
- },
71
- normalize: function(e) {
72
- if (h(e), e.length === 0)
73
- return ".";
74
- var t = e.charCodeAt(0) === 47, r = e.charCodeAt(e.length - 1) === 47;
75
- return e = L(e, !t), e.length === 0 && !t && (e = "."), e.length > 0 && r && (e += "/"), t ? "/" + e : e;
76
- },
77
- isAbsolute: function(e) {
78
- return h(e), e.length > 0 && e.charCodeAt(0) === 47;
79
- },
80
- join: function() {
81
- if (arguments.length === 0)
82
- return ".";
83
- for (var e, t = 0; t < arguments.length; ++t) {
84
- var r = arguments[t];
85
- h(r), r.length > 0 && (e === void 0 ? e = r : e += "/" + r);
86
- }
87
- return e === void 0 ? "." : p.normalize(e);
88
- },
89
- relative: function(e, t) {
90
- if (h(e), h(t), e === t || (e = p.resolve(e), t = p.resolve(t), e === t))
91
- return "";
92
- for (var r = 1; r < e.length && e.charCodeAt(r) === 47; ++r)
93
- ;
94
- for (var n = e.length, i = n - r, a = 1; a < t.length && t.charCodeAt(a) === 47; ++a)
95
- ;
96
- for (var s = t.length, l = s - a, u = i < l ? i : l, c = -1, f = 0; f <= u; ++f) {
97
- if (f === u) {
98
- if (l > u) {
99
- if (t.charCodeAt(a + f) === 47)
100
- return t.slice(a + f + 1);
101
- if (f === 0)
102
- return t.slice(a + f);
103
- } else
104
- i > u && (e.charCodeAt(r + f) === 47 ? c = f : f === 0 && (c = 0));
105
- break;
106
- }
107
- var g = e.charCodeAt(r + f), v = t.charCodeAt(a + f);
108
- if (g !== v)
109
- break;
110
- g === 47 && (c = f);
111
- }
112
- var d = "";
113
- for (f = r + c + 1; f <= n; ++f)
114
- (f === n || e.charCodeAt(f) === 47) && (d.length === 0 ? d += ".." : d += "/..");
115
- return d.length > 0 ? d + t.slice(a + c) : (a += c, t.charCodeAt(a) === 47 && ++a, t.slice(a));
116
- },
117
- _makeLong: function(e) {
118
- return e;
119
- },
120
- dirname: function(e) {
121
- if (h(e), e.length === 0)
122
- return ".";
123
- for (var t = e.charCodeAt(0), r = t === 47, n = -1, i = !0, a = e.length - 1; a >= 1; --a)
124
- if (t = e.charCodeAt(a), t === 47) {
125
- if (!i) {
126
- n = a;
127
- break;
128
- }
129
- } else
130
- i = !1;
131
- return n === -1 ? r ? "/" : "." : r && n === 1 ? "//" : e.slice(0, n);
132
- },
133
- basename: function(e, t) {
134
- if (t !== void 0 && typeof t != "string")
135
- throw new TypeError('"ext" argument must be a string');
136
- h(e);
137
- var r = 0, n = -1, i = !0, a;
138
- if (t !== void 0 && t.length > 0 && t.length <= e.length) {
139
- if (t.length === e.length && t === e)
140
- return "";
141
- var s = t.length - 1, l = -1;
142
- for (a = e.length - 1; a >= 0; --a) {
143
- var u = e.charCodeAt(a);
144
- if (u === 47) {
145
- if (!i) {
146
- r = a + 1;
147
- break;
148
- }
149
- } else
150
- l === -1 && (i = !1, l = a + 1), s >= 0 && (u === t.charCodeAt(s) ? --s === -1 && (n = a) : (s = -1, n = l));
151
- }
152
- return r === n ? n = l : n === -1 && (n = e.length), e.slice(r, n);
153
- } else {
154
- for (a = e.length - 1; a >= 0; --a)
155
- if (e.charCodeAt(a) === 47) {
156
- if (!i) {
157
- r = a + 1;
158
- break;
159
- }
160
- } else
161
- n === -1 && (i = !1, n = a + 1);
162
- return n === -1 ? "" : e.slice(r, n);
163
- }
164
- },
165
- extname: function(e) {
166
- h(e);
167
- for (var t = -1, r = 0, n = -1, i = !0, a = 0, s = e.length - 1; s >= 0; --s) {
168
- var l = e.charCodeAt(s);
169
- if (l === 47) {
170
- if (!i) {
171
- r = s + 1;
172
- break;
173
- }
174
- continue;
175
- }
176
- n === -1 && (i = !1, n = s + 1), l === 46 ? t === -1 ? t = s : a !== 1 && (a = 1) : t !== -1 && (a = -1);
177
- }
178
- return t === -1 || n === -1 || // We saw a non-dot character immediately before the dot
179
- a === 0 || // The (right-most) trimmed path component is exactly '..'
180
- a === 1 && t === n - 1 && t === r + 1 ? "" : e.slice(t, n);
181
- },
182
- format: function(e) {
183
- if (e === null || typeof e != "object")
184
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
185
- return V("/", e);
186
- },
187
- parse: function(e) {
188
- h(e);
189
- var t = { root: "", dir: "", base: "", ext: "", name: "" };
190
- if (e.length === 0)
191
- return t;
192
- var r = e.charCodeAt(0), n = r === 47, i;
193
- n ? (t.root = "/", i = 1) : i = 0;
194
- for (var a = -1, s = 0, l = -1, u = !0, c = e.length - 1, f = 0; c >= i; --c) {
195
- if (r = e.charCodeAt(c), r === 47) {
196
- if (!u) {
197
- s = c + 1;
198
- break;
199
- }
200
- continue;
201
- }
202
- l === -1 && (u = !1, l = c + 1), r === 46 ? a === -1 ? a = c : f !== 1 && (f = 1) : a !== -1 && (f = -1);
203
- }
204
- return a === -1 || l === -1 || // We saw a non-dot character immediately before the dot
205
- f === 0 || // The (right-most) trimmed path component is exactly '..'
206
- f === 1 && a === l - 1 && a === s + 1 ? l !== -1 && (s === 0 && n ? t.base = t.name = e.slice(1, l) : t.base = t.name = e.slice(s, l)) : (s === 0 && n ? (t.name = e.slice(1, a), t.base = e.slice(1, l)) : (t.name = e.slice(s, a), t.base = e.slice(s, l)), t.ext = e.slice(a, l)), s > 0 ? t.dir = e.slice(0, s - 1) : n && (t.dir = "/"), t;
207
- },
208
- sep: "/",
209
- delimiter: ":",
210
- win32: null,
211
- posix: null
212
- };
213
- p.posix = p;
214
- var W = p;
215
- const { basename: B, extname: Y } = W;
216
- class Z {
217
- constructor() {
218
- let e = (() => typeof G > "u")(), t = "image/png", r = "image/jpeg", n = "image/jpeg", i = "image/webp", a = "application/pdf", s = "image/svg+xml";
219
- Object.assign(this, {
220
- toMime: this.toMime.bind(this),
221
- fromMime: this.fromMime.bind(this),
222
- expected: e ? '"png", "jpg", or "webp"' : '"png", "jpg", "pdf", or "svg"',
223
- formats: e ? { png: t, jpg: r, jpeg: n, webp: i } : { png: t, jpg: r, jpeg: n, pdf: a, svg: s },
224
- mimes: e ? { [t]: "png", [r]: "jpg", [i]: "webp" } : { [t]: "png", [r]: "jpg", [a]: "pdf", [s]: "svg" }
225
- });
226
- }
227
- toMime(e) {
228
- return this.formats[(e || "").replace(/^\./, "").toLowerCase()];
229
- }
230
- fromMime(e) {
231
- return this.mimes[e];
232
- }
233
- }
234
- function K(o, { filename: e = "", extension: t = "", format: m, page: n, quality: i, matte: a, density: s, outline: l, archive: v } = {}) {
235
- var { fromMime: c, toMime: f, expected: g } = new Z(), v = v || "canvas", d = m || t.replace(/@\d+x$/i, "") || Y(e), m = c(f(d) || d), y = f(m), b = o.length;
236
- if (!d)
237
- throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");
238
- if (!m)
239
- throw new Error(`Unsupported file format "${d}" (expected ${g})`);
240
- if (!b)
241
- throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");
242
- let C, E, z = e.replace(/{(\d*)}/g, (D, A) => (E = !0, A = parseInt(A, 10), C = isFinite(A) ? A : isFinite(C) ? C : -1, "{}")), w = n > 0 ? n - 1 : n < 0 ? b + n : void 0;
243
- if (isFinite(w) && w < 0 || w >= b)
244
- throw new RangeError(
245
- b == 1 ? `Canvas only has a ‘page 1’ (${w} is out of bounds)` : `Canvas has pages 1–${b} (${w} is out of bounds)`
246
- );
247
- if (o = isFinite(w) ? [o[w]] : E || m == "pdf" ? o : o.slice(-1), i === void 0)
248
- i = 0.92;
249
- else if (typeof i != "number" || !isFinite(i) || i < 0 || i > 1)
250
- throw new TypeError("The quality option must be an number in the 0.0–1.0 range");
251
- if (s === void 0) {
252
- let D = (t || B(e, d)).match(/@(\d+)x$/i);
253
- s = D ? parseInt(D[1], 10) : 1;
254
- } else if (typeof s != "number" || !Number.isInteger(s) || s < 1)
255
- throw new TypeError("The density option must be a non-negative integer");
256
- return l === void 0 ? l = !0 : m == "svg" && (l = !!l), { filename: e, pattern: z, format: m, mime: y, pages: o, padding: C, quality: i, matte: a, density: s, outline: l, archive: v };
257
- }
258
- class j {
259
- static for(e) {
260
- return new j().append(e).get();
261
- }
262
- constructor() {
263
- this.crc = -1;
264
- }
265
- get() {
266
- return ~this.crc;
267
- }
268
- append(e) {
269
- for (var t = this.crc | 0, r = this.table, n = 0, i = e.length | 0; n < i; n++)
270
- t = t >>> 8 ^ r[(t ^ e[n]) & 255];
271
- return this.crc = t, this;
272
- }
273
- }
274
- j.prototype.table = (() => {
275
- var o, e, t, r = [];
276
- for (o = 0; o < 256; o++) {
277
- for (t = o, e = 0; e < 8; e++)
278
- t = t & 1 ? t >>> 1 ^ 3988292384 : t >>> 1;
279
- r[o] = t;
280
- }
281
- return r;
282
- })();
283
- function S(o) {
284
- let e = new Uint8Array(o), t = new DataView(e.buffer), r = {
285
- array: e,
286
- view: t,
287
- size: o,
288
- set8(n, i) {
289
- return t.setUint8(n, i), r;
290
- },
291
- set16(n, i) {
292
- return t.setUint16(n, i, !0), r;
293
- },
294
- set32(n, i) {
295
- return t.setUint32(n, i, !0), r;
296
- },
297
- bytes(n, i) {
298
- return e.set(i, n), r;
299
- }
300
- };
301
- return r;
302
- }
303
- const x = class x {
304
- constructor(e) {
305
- let t = /* @__PURE__ */ new Date();
306
- Object.assign(this, {
307
- directory: e,
308
- offset: 0,
309
- files: [],
310
- time: (t.getHours() << 6 | t.getMinutes()) << 5 | t.getSeconds() / 2,
311
- date: (t.getFullYear() - 1980 << 4 | t.getMonth() + 1) << 5 | t.getDate()
312
- }), this.add(e);
313
- }
314
- async add(e, t) {
315
- let r = !t, n = x.encoder.encode(`${this.directory}/${r ? "" : e}`), i = new Uint8Array(r ? 0 : await t.arrayBuffer()), a = 30 + n.length, s = a + i.length, l = 16, { offset: u } = this, c = S(26).set32(0, 134742036).set16(6, this.time).set16(8, this.date).set32(10, j.for(i)).set32(14, i.length).set32(18, i.length).set16(22, n.length);
316
- u += a;
317
- let f = S(a + i.length + l).set32(0, 67324752).bytes(4, c.array).bytes(30, n).bytes(a, i);
318
- u += i.length, f.set32(s, 134695760).bytes(s + 4, c.array.slice(10, 22)), u += l, this.files.push({ offset: u, folder: r, name: n, header: c, payload: f }), this.offset = u;
319
- }
320
- toBuffer() {
321
- let e = this.files.reduce((f, { name: g }) => 46 + g.length + f, 0), t = S(e + 22), r = 0;
322
- for (var { offset: n, name: i, header: a, folder: s } of this.files)
323
- t.set32(r, 33639248).set16(r + 4, 20).bytes(r + 6, a.array).set8(r + 38, s ? 16 : 0).set32(r + 42, n).bytes(r + 46, i), r += 46 + i.length;
324
- t.set32(r, 101010256).set16(r + 8, this.files.length).set16(r + 10, this.files.length).set32(r + 12, e).set32(r + 16, this.offset);
325
- let l = new Uint8Array(this.offset + t.size), u = 0;
326
- for (var { payload: c } of this.files)
327
- l.set(c.array, u), u += c.size;
328
- return l.set(t.array, u), l;
329
- }
330
- get blob() {
331
- return new Blob([this.toBuffer()], { type: "application/zip" });
332
- }
333
- };
334
- U(x, "encoder", new TextEncoder());
335
- let k = x;
336
- const $ = (o, e, t, r) => {
337
- if (r) {
338
- let { width: n, height: i } = o, a = Object.assign(document.createElement("canvas"), { width: n, height: i }), s = a.getContext("2d");
339
- s.fillStyle = r, s.fillRect(0, 0, n, i), s.drawImage(o, 0, 0), o = a;
340
- }
341
- return new Promise((n, i) => o.toBlob(n, e, t));
342
- }, N = (...o) => $(...o).then((e) => e.arrayBuffer()), Q = async (o, e, t, r, n) => {
343
- T(n, await $(o, e, t, r));
344
- }, X = async (o, e, t, r, n, i, a) => {
345
- let s = (c) => i.replace("{}", String(c + 1).padStart(a, "0")), l = B(n, ".zip") || "archive", u = new k(l);
346
- await Promise.all(o.map(async (c, f) => {
347
- let g = s(f);
348
- await u.add(g, await $(c, e, t, r));
349
- })), T(`${l}.zip`, u.blob);
350
- }, T = (o, e) => {
351
- const t = window.URL.createObjectURL(e), r = document.createElement("a");
352
- r.style.display = "none", r.href = t, r.setAttribute("download", o), typeof r.download > "u" && r.setAttribute("target", "_blank"), document.body.appendChild(r), r.click(), document.body.removeChild(r), setTimeout(() => window.URL.revokeObjectURL(t), 100);
353
- }, ee = (o, e, t) => o.map((r) => {
354
- if (e == 1 && !t)
355
- return r.canvas;
356
- let n = document.createElement("canvas"), i = n.getContext("2d"), a = r.canvas ? r.canvas : r;
357
- return n.width = a.width * e, n.height = a.height * e, t && (i.fillStyle = t, i.fillRect(0, 0, n.width, n.height)), i.scale(e, e), i.drawImage(a, 0, 0), n;
358
- });
359
- var te = { asBuffer: N, asDownload: Q, asZipDownload: X, atScale: ee, options: K };
360
- const { asBuffer: P, asDownload: re, asZipDownload: ne, atScale: O, options: R } = te, M = Symbol.for("toDataURL"), ie = (o) => {
361
- let e = Object.assign(new F(), { crossOrigin: "Anonymous", src: o });
362
- return e.decode().then(() => e);
363
- };
364
- class ae {
365
- constructor(e, t) {
366
- let r = document.createElement("canvas"), n = [];
367
- Object.defineProperty(r, "async", { value: !0, writable: !1, enumerable: !0 });
368
- for (var [i, a] of Object.entries({
369
- png: () => P(r, "image/png"),
370
- jpg: () => P(r, "image/jpeg"),
371
- pages: () => n.concat(r).map((s) => s.getContext("2d"))
372
- }))
373
- Object.defineProperty(r, i, { get: a });
374
- return Object.assign(r, {
375
- width: e,
376
- height: t,
377
- newPage(...s) {
378
- var { width: u, height: c } = r, l = Object.assign(document.createElement("canvas"), { width: u, height: c });
379
- l.getContext("2d").drawImage(r, 0, 0), n.push(l);
380
- var [u, c] = s.length ? s : [u, c];
381
- return Object.assign(r, { width: u, height: c }).getContext("2d");
382
- },
383
- saveAs(s, l) {
384
- l = typeof l == "number" ? { quality: l } : l;
385
- let u = R(this.pages, { filename: s, ...l }), { pattern: c, padding: f, mime: g, quality: v, matte: d, density: m, archive: y } = u, b = O(u.pages, m);
386
- return f == null ? re(b[0], g, v, d, s) : ne(b, g, v, d, y, c, f);
387
- },
388
- toBuffer(s = "png", l = {}) {
389
- l = typeof l == "number" ? { quality: l } : l;
390
- let u = R(this.pages, { extension: s, ...l }), { mime: c, quality: f, matte: g, pages: v, density: d } = u, m = O(v, d, g)[0];
391
- return P(m, c, f, g);
392
- },
393
- [M]: r.toDataURL.bind(r),
394
- toDataURL(s = "png", l = {}) {
395
- l = typeof l == "number" ? { quality: l } : l;
396
- let u = R(this.pages, { extension: s, ...l }), { mime: c, quality: f, matte: g, pages: v, density: d } = u, m = O(v, d, g)[0], y = m[m === r ? M : "toDataURL"](c, f);
397
- return Promise.resolve(y);
398
- }
399
- });
400
- }
401
- }
402
- const {
403
- CanvasRenderingContext2D: se,
404
- CanvasGradient: oe,
405
- CanvasPattern: le,
406
- Image: F,
407
- ImageData: fe,
408
- Path2D: ce,
409
- DOMMatrix: ue,
410
- DOMRect: de,
411
- DOMPoint: ge
412
- } = window;
413
- var _ = {
414
- Canvas: ae,
415
- loadImage: ie,
416
- CanvasRenderingContext2D: se,
417
- CanvasGradient: oe,
418
- CanvasPattern: le,
419
- Image: F,
420
- ImageData: fe,
421
- Path2D: ce,
422
- DOMMatrix: ue,
423
- DOMRect: de,
424
- DOMPoint: ge
425
- };
426
- const me = /* @__PURE__ */ H(_), be = /* @__PURE__ */ J({
427
- __proto__: null,
428
- default: me
429
- }, [_]);
430
- export {
431
- be as b
432
- };
433
- //# sourceMappingURL=browser-0a211a9c.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-0a211a9c.js","sources":["../../../../node_modules/path-browserify/index.js","../../../../node_modules/skia-canvas/lib/io.js","../../../../node_modules/skia-canvas/lib/browser.js"],"sourcesContent":["// 'path' module extracted from Node.js v8.11.1 (only the posix part)\n// transplited with Babel\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));\n }\n}\n\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n var res = '';\n var lastSegmentLength = 0;\n var lastSlash = -1;\n var dots = 0;\n var code;\n for (var i = 0; i <= path.length; ++i) {\n if (i < path.length)\n code = path.charCodeAt(i);\n else if (code === 47 /*/*/)\n break;\n else\n code = 47 /*/*/;\n if (code === 47 /*/*/) {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n } else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {\n if (res.length > 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0)\n res += '/..';\n else\n res = '..';\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\nfunction _format(sep, pathObject) {\n var dir = pathObject.dir || pathObject.root;\n var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\n\nvar posix = {\n // path.resolve([from ...], to)\n resolve: function resolve() {\n var resolvedPath = '';\n var resolvedAbsolute = false;\n var cwd;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path;\n if (i >= 0)\n path = arguments[i];\n else {\n if (cwd === undefined)\n cwd = process.cwd();\n path = cwd;\n }\n\n assertPath(path);\n\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0)\n return '/' + resolvedPath;\n else\n return '/';\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return '.';\n }\n },\n\n normalize: function normalize(path) {\n assertPath(path);\n\n if (path.length === 0) return '.';\n\n var isAbsolute = path.charCodeAt(0) === 47 /*/*/;\n var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;\n\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n\n if (path.length === 0 && !isAbsolute) path = '.';\n if (path.length > 0 && trailingSeparator) path += '/';\n\n if (isAbsolute) return '/' + path;\n return path;\n },\n\n isAbsolute: function isAbsolute(path) {\n assertPath(path);\n return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;\n },\n\n join: function join() {\n if (arguments.length === 0)\n return '.';\n var joined;\n for (var i = 0; i < arguments.length; ++i) {\n var arg = arguments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += '/' + arg;\n }\n }\n if (joined === undefined)\n return '.';\n return posix.normalize(joined);\n },\n\n relative: function relative(from, to) {\n assertPath(from);\n assertPath(to);\n\n if (from === to) return '';\n\n from = posix.resolve(from);\n to = posix.resolve(to);\n\n if (from === to) return '';\n\n // Trim any leading backslashes\n var fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/)\n break;\n }\n var fromEnd = from.length;\n var fromLen = fromEnd - fromStart;\n\n // Trim any leading backslashes\n var toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/)\n break;\n }\n var toEnd = to.length;\n var toLen = toEnd - toStart;\n\n // Compare paths to find the longest common path from root\n var length = fromLen < toLen ? fromLen : toLen;\n var lastCommonSep = -1;\n var i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n var fromCode = from.charCodeAt(fromStart + i);\n var toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode)\n break;\n else if (fromCode === 47 /*/*/)\n lastCommonSep = i;\n }\n\n var out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0)\n out += '..';\n else\n out += '/..';\n }\n }\n\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0)\n return out + to.slice(toStart + lastCommonSep);\n else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/)\n ++toStart;\n return to.slice(toStart);\n }\n },\n\n _makeLong: function _makeLong(path) {\n return path;\n },\n\n dirname: function dirname(path) {\n assertPath(path);\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) return '//';\n return path.slice(0, end);\n },\n\n basename: function basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string');\n assertPath(path);\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return '';\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n }\n },\n\n extname: function extname(path) {\n assertPath(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject);\n }\n return _format('/', pathObject);\n },\n\n parse: function parse(path) {\n assertPath(path);\n\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0) return ret;\n var code = path.charCodeAt(0);\n var isAbsolute = code === 47 /*/*/;\n var start;\n if (isAbsolute) {\n ret.root = '/';\n start = 1;\n } else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';\n\n return ret;\n },\n\n sep: '/',\n delimiter: ':',\n win32: null,\n posix: null\n};\n\nposix.posix = posix;\n\nmodule.exports = posix;\n","\"use strict\"\n\nconst {basename, extname} = require('path')\n\n//\n// Mime type <-> File extension mappings\n//\n\nclass Format{\n constructor(){\n let isWeb = (() => typeof global=='undefined')(),\n png = \"image/png\",\n jpg = \"image/jpeg\",\n jpeg = \"image/jpeg\",\n webp = \"image/webp\",\n pdf = \"application/pdf\",\n svg = \"image/svg+xml\"\n\n Object.assign(this, {\n toMime: this.toMime.bind(this),\n fromMime: this.fromMime.bind(this),\n expected: isWeb ? `\"png\", \"jpg\", or \"webp\"`\n : `\"png\", \"jpg\", \"pdf\", or \"svg\"`,\n formats: isWeb ? {png, jpg, jpeg, webp}\n : {png, jpg, jpeg, pdf, svg},\n mimes: isWeb ? {[png]: \"png\", [jpg]: \"jpg\", [webp]: \"webp\"}\n : {[png]: \"png\", [jpg]: \"jpg\", [pdf]: \"pdf\", [svg]: \"svg\"},\n })\n }\n\n toMime(ext){\n return this.formats[(ext||'').replace(/^\\./, '').toLowerCase()]\n }\n\n fromMime(mime){\n return this.mimes[mime]\n }\n}\n\n//\n// Validation of the options dict shared by the Canvas saveAs, toBuffer, and toDataURL methods\n//\n\nfunction options(pages, {filename='', extension='', format, page, quality, matte, density, outline, archive}={}){\n var {fromMime, toMime, expected} = new Format(),\n archive = archive || 'canvas',\n ext = format || extension.replace(/@\\d+x$/i,'') || extname(filename),\n format = fromMime(toMime(ext) || ext),\n mime = toMime(format),\n pp = pages.length\n\n if(!ext) throw new Error(`Cannot determine image format (use a filename extension or 'format' argument)`)\n if (!format) throw new Error(`Unsupported file format \"${ext}\" (expected ${expected})`)\n if (!pp) throw new RangeError(`Canvas has no associated contexts (try calling getContext or newPage first)`)\n\n let padding, isSequence, pattern = filename.replace(/{(\\d*)}/g, (_, width) => {\n isSequence = true\n width = parseInt(width, 10)\n padding = isFinite(width) ? width : isFinite(padding) ? padding : -1\n return \"{}\"\n })\n\n // allow negative indexing if a specific page is specified\n let idx = page > 0 ? page - 1\n : page < 0 ? pp + page\n : undefined;\n\n if (isFinite(idx) && idx < 0 || idx >= pp) throw new RangeError(\n pp == 1 ? `Canvas only has a ‘page 1’ (${idx} is out of bounds)`\n : `Canvas has pages 1–${pp} (${idx} is out of bounds)`\n )\n\n pages = isFinite(idx) ? [pages[idx]]\n : isSequence || format=='pdf' ? pages\n : pages.slice(-1) // default to the 'current' context\n\n if (quality===undefined){\n quality = 0.92\n }else{\n if (typeof quality!='number' || !isFinite(quality) || quality<0 || quality>1){\n throw new TypeError(\"The quality option must be an number in the 0.0–1.0 range\")\n }\n }\n\n if (density===undefined){\n let m = (extension || basename(filename, ext)).match(/@(\\d+)x$/i)\n density = m ? parseInt(m[1], 10) : 1\n }else if (typeof density!='number' || !Number.isInteger(density) || density<1){\n throw new TypeError(\"The density option must be a non-negative integer\")\n }\n\n if (outline===undefined){\n outline = true\n }else if (format == 'svg'){\n outline = !!outline\n }\n\n return {filename, pattern, format, mime, pages, padding, quality, matte, density, outline, archive}\n}\n\n//\n// Zip (pace Phil Katz & q.v. https://github.com/jimmywarting/StreamSaver.js)\n//\n\nclass Crc32 {\n static for(data){\n return new Crc32().append(data).get()\n }\n\n constructor(){ this.crc = -1 }\n\n get(){ return ~this.crc }\n\n append(data){\n var crc = this.crc | 0,\n table = this.table\n for (var offset = 0, len = data.length | 0; offset < len; offset++) {\n crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF]\n }\n this.crc = crc\n return this\n }\n\n}\n\nCrc32.prototype.table = (() => {\n var i, j, t, table = []\n for (i = 0; i < 256; i++) {\n t = i\n for (j = 0; j < 8; j++) {\n t = (t & 1)\n ? (t >>> 1) ^ 0xEDB88320\n : t >>> 1\n }\n table[i] = t\n }\n return table\n})()\n\nfunction calloc(size){\n let array = new Uint8Array(size),\n view = new DataView(array.buffer),\n buf = {\n array, view, size,\n set8(at, to){ view.setUint8(at, to); return buf },\n set16(at, to){ view.setUint16(at, to, true); return buf },\n set32(at, to){ view.setUint32(at, to, true); return buf },\n bytes(at, to){ array.set(to, at); return buf },\n }\n return buf\n}\n\nclass Zip{\n static encoder = new TextEncoder()\n\n constructor(directory){\n let now = new Date()\n Object.assign(this, {\n directory,\n offset: 0,\n files: [],\n time: (((now.getHours() << 6) | now.getMinutes()) << 5) | now.getSeconds() / 2,\n date: ((((now.getFullYear() - 1980) << 4) | (now.getMonth() + 1)) << 5) | now.getDate(),\n })\n this.add(directory)\n }\n\n async add(filename, blob){\n let folder = !blob,\n name = Zip.encoder.encode(`${this.directory}/${folder ? '' : filename}`),\n data = new Uint8Array(folder ? 0 : await blob.arrayBuffer()),\n preamble = 30 + name.length,\n descriptor = preamble + data.length,\n postamble = 16,\n {offset} = this\n\n let header = calloc(26)\n .set32(0, 0x08080014) // zip version\n .set16(6, this.time) // time\n .set16(8, this.date) // date\n .set32(10, Crc32.for(data)) // checksum\n .set32(14, data.length) // compressed size (w/ zero compression)\n .set32(18, data.length) // un-compressed size\n .set16(22, name.length) // filename length (utf8 bytes)\n offset += preamble\n\n let payload = calloc(preamble + data.length + postamble)\n .set32(0, 0x04034b50) // local header signature\n .bytes(4, header.array) // ...header fields...\n .bytes(30, name) // filename\n .bytes(preamble, data) // blob bytes\n offset += data.length\n\n payload\n .set32(descriptor, 0x08074b50) // signature\n .bytes(descriptor + 4, header.array.slice(10,22)) // length & filemame\n offset += postamble\n\n this.files.push({offset, folder, name, header, payload})\n this.offset = offset\n }\n\n toBuffer(){\n // central directory record\n let length = this.files.reduce((len, {name}) => 46 + name.length + len, 0),\n cdr = calloc(length + 22),\n index = 0\n\n for (var {offset, name, header, folder} of this.files){\n cdr.set32(index, 0x02014b50) // archive file signature\n .set16(index + 4, 0x0014) // version\n .bytes(index + 6, header.array) // ...header fields...\n .set8(index + 38, folder ? 0x10 : 0) // is_dir flag\n .set32(index + 42, offset) // file offset\n .bytes(index + 46, name) // filename\n index += 46 + name.length\n }\n cdr.set32(index, 0x06054b50) // signature\n .set16(index + 8, this.files.length) // № files per-segment\n .set16(index + 10, this.files.length) // № files this segment\n .set32(index + 12, length) // central directory length\n .set32(index + 16, this.offset) // file-offset of directory\n\n // concatenated zipfile data\n let output = new Uint8Array(this.offset + cdr.size),\n cursor = 0;\n\n for (var {payload} of this.files){\n output.set(payload.array, cursor)\n cursor += payload.size\n }\n output.set(cdr.array, cursor)\n\n return output\n }\n\n get blob(){\n return new Blob([this.toBuffer()], {type:\"application/zip\"})\n }\n}\n\n\n//\n// Browser helpers for converting canvas elements to blobs/buffers/files/zips\n//\n\nconst asBlob = (canvas, mime, quality, matte) => {\n if (matte){\n let {width, height} = canvas,\n comp = Object.assign(document.createElement('canvas'), {width, height}),\n ctx = comp.getContext(\"2d\")\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, width, height)\n ctx.drawImage(canvas, 0, 0)\n canvas = comp\n }\n\n return new Promise((res, rej) => canvas.toBlob(res, mime, quality))\n}\n\nconst asBuffer = (...args) => asBlob(...args).then(b => b.arrayBuffer())\n\nconst asDownload = async (canvas, mime, quality, matte, filename) => {\n _download(filename, await asBlob(canvas, mime, quality, matte))\n}\n\nconst asZipDownload = async (pages, mime, quality, matte, archive, pattern, padding) => {\n let filenames = i => pattern.replace('{}', String(i+1).padStart(padding, '0')),\n folder = basename(archive, '.zip') || 'archive',\n zip = new Zip(folder)\n\n await Promise.all(pages.map(async (page, i) => {\n let filename = filenames(i) // serialize filename(s) before awaiting\n await zip.add(filename, await asBlob(page, mime, quality, matte))\n }))\n\n _download(`${folder}.zip`, zip.blob)\n}\n\nconst _download = (filename, blob) => {\n const href = window.URL.createObjectURL(blob),\n link = document.createElement('a')\n link.style.display = 'none'\n link.href = href\n link.setAttribute('download', filename)\n if (typeof link.download === 'undefined') {\n link.setAttribute('target', '_blank')\n }\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n setTimeout(() => window.URL.revokeObjectURL(href), 100)\n}\n\nconst atScale = (pages, density, matte) => pages.map(page => {\n if (density == 1 && !matte) return page.canvas\n\n let scaled = document.createElement('canvas'),\n ctx = scaled.getContext(\"2d\"),\n src = page.canvas ? page.canvas : page\n scaled.width = src.width * density\n scaled.height = src.height * density\n if (matte){\n ctx.fillStyle = matte\n ctx.fillRect(0, 0, scaled.width, scaled.height)\n }\n ctx.scale(density, density)\n ctx.drawImage(src, 0, 0)\n return scaled\n})\n\nmodule.exports = {asBuffer, asDownload, asZipDownload, atScale, options}\n","\"use strict\"\n\nconst {asBuffer, asDownload, asZipDownload, atScale, options} = require('./io')\n\n//\n// Browser equivalents of the skia-canvas convenience initializers and polyfills for\n// the Canvas object’s newPage & export methods\n//\n\nconst _toURL_ = Symbol.for(\"toDataURL\")\n\nconst loadImage = src => {\n let img = Object.assign(new Image(), {crossOrigin:'Anonymous', src})\n return img.decode().then(() => img)\n}\n\nclass Canvas{\n constructor(width, height){\n let elt = document.createElement('canvas'),\n pages = []\n\n Object.defineProperty(elt, \"async\", {value:true, writable:false, enumerable:true})\n\n for (var [prop, get] of Object.entries({\n png: () => asBuffer(elt, 'image/png'),\n jpg: () => asBuffer(elt, 'image/jpeg'),\n pages: () => pages.concat(elt).map(c => c.getContext(\"2d\")),\n })) Object.defineProperty(elt, prop, {get})\n\n return Object.assign(elt, {\n width, height,\n\n newPage(...size){\n var {width, height} = elt,\n page = Object.assign(document.createElement('canvas'), {width, height})\n page.getContext(\"2d\").drawImage(elt, 0, 0)\n pages.push(page)\n\n var [width, height] = size.length ? size : [width, height]\n return Object.assign(elt, {width, height}).getContext(\"2d\")\n },\n\n saveAs(filename, args){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {filename, ...args}),\n {pattern, padding, mime, quality, matte, density, archive} = opts,\n pages = atScale(opts.pages, density);\n return padding==undefined ? asDownload(pages[0], mime, quality, matte, filename)\n : asZipDownload(pages, mime, quality, matte, archive, pattern, padding)\n },\n\n toBuffer(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0]\n return asBuffer(canvas, mime, quality, matte)\n },\n\n [_toURL_]: elt.toDataURL.bind(elt),\n toDataURL(extension=\"png\", args={}){\n args = typeof args=='number' ? {quality:args} : args\n let opts = options(this.pages, {extension, ...args}),\n {mime, quality, matte, pages, density} = opts,\n canvas = atScale(pages, density, matte)[0],\n url = canvas[canvas===elt ? _toURL_ : 'toDataURL'](mime, quality);\n return Promise.resolve(url)\n }\n })\n }\n}\n\nconst {CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint} = window;\n\nmodule.exports = {\n Canvas, loadImage,\n CanvasRenderingContext2D, CanvasGradient, CanvasPattern,\n Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint\n}"],"names":["assertPath","path","normalizeStringPosix","allowAboveRoot","res","lastSegmentLength","lastSlash","dots","code","i","lastSlashIndex","_format","sep","pathObject","dir","base","posix","resolvedPath","resolvedAbsolute","cwd","isAbsolute","trailingSeparator","joined","arg","from","to","fromStart","fromEnd","fromLen","toStart","toEnd","toLen","length","lastCommonSep","fromCode","toCode","out","hasRoot","end","matchedSlash","ext","start","extIdx","firstNonSlashEnd","startDot","startPart","preDotState","ret","pathBrowserify","basename","extname","require$$0","Format","isWeb","global","png","jpg","jpeg","webp","pdf","svg","mime","options","pages","filename","extension","format","page","quality","matte","density","outline","archive","fromMime","toMime","expected","pp","padding","isSequence","pattern","_","width","idx","m","Crc32","data","crc","table","offset","len","j","calloc","size","array","view","buf","at","_Zip","directory","now","blob","folder","name","preamble","descriptor","postamble","header","payload","cdr","index","output","cursor","__publicField","Zip","asBlob","canvas","height","comp","ctx","rej","asBuffer","args","b","asDownload","_download","asZipDownload","filenames","zip","href","link","atScale","scaled","src","io","_toURL_","loadImage","img","Image","Canvas","elt","prop","get","c","opts","url","CanvasRenderingContext2D","CanvasGradient","CanvasPattern","ImageData","Path2D","DOMMatrix","DOMRect","DOMPoint","browser"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,EAAWC,GAAM;AACxB,MAAI,OAAOA,KAAS;AAClB,UAAM,IAAI,UAAU,qCAAqC,KAAK,UAAUA,CAAI,CAAC;AAEjF;AAGA,SAASC,EAAqBD,GAAME,GAAgB;AAMlD,WALIC,IAAM,IACNC,IAAoB,GACpBC,IAAY,IACZC,IAAO,GACPC,GACKC,IAAI,GAAGA,KAAKR,EAAK,QAAQ,EAAEQ,GAAG;AACrC,QAAIA,IAAIR,EAAK;AACX,MAAAO,IAAOP,EAAK,WAAWQ,CAAC;AAAA,SACrB;AAAA,UAAID,MAAS;AAChB;AAEA,MAAAA,IAAO;AAAA;AACT,QAAIA,MAAS,IAAU;AACrB,UAAI,EAAAF,MAAcG,IAAI,KAAKF,MAAS;AAE7B,YAAID,MAAcG,IAAI,KAAKF,MAAS,GAAG;AAC5C,cAAIH,EAAI,SAAS,KAAKC,MAAsB,KAAKD,EAAI,WAAWA,EAAI,SAAS,CAAC,MAAM,MAAYA,EAAI,WAAWA,EAAI,SAAS,CAAC,MAAM;AACjI,gBAAIA,EAAI,SAAS,GAAG;AAClB,kBAAIM,IAAiBN,EAAI,YAAY,GAAG;AACxC,kBAAIM,MAAmBN,EAAI,SAAS,GAAG;AACrC,gBAAIM,MAAmB,MACrBN,IAAM,IACNC,IAAoB,MAEpBD,IAAMA,EAAI,MAAM,GAAGM,CAAc,GACjCL,IAAoBD,EAAI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