image-exporter 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +133 -81
  2. package/dist/capture/capture-element.d.ts +8 -0
  3. package/dist/capture/capture-element.d.ts.map +1 -0
  4. package/dist/capture/determine-total-elements.d.ts +9 -0
  5. package/dist/capture/determine-total-elements.d.ts.map +1 -0
  6. package/dist/capture/download-images.d.ts +10 -0
  7. package/dist/capture/download-images.d.ts.map +1 -0
  8. package/dist/capture/get-image-options.d.ts +15 -0
  9. package/dist/capture/get-image-options.d.ts.map +1 -0
  10. package/dist/capture/handle-filenames.d.ts +11 -0
  11. package/dist/capture/handle-filenames.d.ts.map +1 -0
  12. package/dist/capture/index.d.ts +10 -0
  13. package/dist/capture/index.d.ts.map +1 -0
  14. package/dist/capture/remove-hidden-elements.d.ts +2 -0
  15. package/dist/capture/remove-hidden-elements.d.ts.map +1 -0
  16. package/dist/config.d.ts +4 -0
  17. package/dist/config.d.ts.map +1 -0
  18. package/dist/cors-proxy/cleanup.d.ts +7 -0
  19. package/dist/cors-proxy/cleanup.d.ts.map +1 -0
  20. package/dist/cors-proxy/index.d.ts +7 -0
  21. package/dist/cors-proxy/index.d.ts.map +1 -0
  22. package/dist/cors-proxy/is-valid-url.d.ts +7 -0
  23. package/dist/cors-proxy/is-valid-url.d.ts.map +1 -0
  24. package/dist/cors-proxy/proxy-css.d.ts +9 -0
  25. package/dist/cors-proxy/proxy-css.d.ts.map +1 -0
  26. package/dist/cors-proxy/proxy-images.d.ts +9 -0
  27. package/dist/cors-proxy/proxy-images.d.ts.map +1 -0
  28. package/dist/cors-proxy/run.d.ts +9 -0
  29. package/dist/cors-proxy/run.d.ts.map +1 -0
  30. package/dist/index.browser.js +40 -0
  31. package/dist/index.browser.js.map +84 -0
  32. package/dist/index.cjs +14878 -0
  33. package/dist/index.cjs.map +84 -0
  34. package/dist/index.d.ts +5 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +14869 -0
  37. package/dist/index.js.map +83 -0
  38. package/dist/logger.d.ts +26 -0
  39. package/dist/logger.d.ts.map +1 -0
  40. package/package.json +19 -14
  41. package/.gitattributes +0 -2
  42. package/.prettierrc +0 -5
  43. package/bun.lockb +0 -0
  44. package/dist/image-exporter.es.js +0 -4508
  45. package/dist/image-exporter.umd.js +0 -4514
  46. package/src/capture/capture-element.ts +0 -79
  47. package/src/capture/determine-total-elements.ts +0 -40
  48. package/src/capture/download-images.ts +0 -69
  49. package/src/capture/get-image-options.ts +0 -207
  50. package/src/capture/handle-filenames.ts +0 -54
  51. package/src/capture/index.ts +0 -102
  52. package/src/capture/remove-hidden-elements.ts +0 -19
  53. package/src/config.ts +0 -19
  54. package/src/cors-proxy/cleanup.ts +0 -43
  55. package/src/cors-proxy/index.ts +0 -7
  56. package/src/cors-proxy/is-valid-url.ts +0 -22
  57. package/src/cors-proxy/proxy-css.ts +0 -48
  58. package/src/cors-proxy/proxy-images.ts +0 -34
  59. package/src/cors-proxy/run.ts +0 -26
  60. package/src/index.ts +0 -14
  61. package/src/logger.ts +0 -71
  62. package/src/types.d.ts +0 -51
  63. package/vite.config.js +0 -35
@@ -1,4508 +0,0 @@
1
- var _a;
2
- function handleFileNames(imageOptions, filenames) {
3
- let proposedFilename = imageOptions.label;
4
- if (imageOptions.includeScaleInLabel) proposedFilename += `_@${imageOptions.scale}x`;
5
- const extension = `.${imageOptions.format}`;
6
- proposedFilename += extension;
7
- if (!filenames.includes(proposedFilename)) {
8
- filenames.push(proposedFilename);
9
- return proposedFilename;
10
- }
11
- const numberPattern = /-(\d+)$/;
12
- const match = proposedFilename.match(numberPattern);
13
- if (match) {
14
- const baseFilename = proposedFilename.replace(numberPattern, "");
15
- let counter = parseInt(match[1], 10);
16
- while (filenames.includes(`${baseFilename}-${counter}${extension}`)) {
17
- counter++;
18
- }
19
- const newFilename = `${baseFilename}-${counter}${extension}`;
20
- filenames.push(newFilename);
21
- return newFilename;
22
- } else {
23
- const baseFilename = proposedFilename.replace(extension, "");
24
- let counter = 2;
25
- while (filenames.includes(`${baseFilename}-${counter}${extension}`)) {
26
- counter++;
27
- }
28
- const newFilename = `${baseFilename}-${counter}${extension}`;
29
- filenames.push(newFilename);
30
- return newFilename;
31
- }
32
- }
33
- function changeJpegDpi(uint8Array, dpi) {
34
- uint8Array[13] = 1;
35
- uint8Array[14] = dpi >> 8;
36
- uint8Array[15] = dpi & 255;
37
- uint8Array[16] = dpi >> 8;
38
- uint8Array[17] = dpi & 255;
39
- return uint8Array;
40
- }
41
- const _P = "p".charCodeAt(0);
42
- const _H = "H".charCodeAt(0);
43
- const _Y = "Y".charCodeAt(0);
44
- const _S = "s".charCodeAt(0);
45
- let pngDataTable;
46
- function createPngDataTable() {
47
- const crcTable = new Int32Array(256);
48
- for (let n = 0; n < 256; n++) {
49
- let c = n;
50
- for (let k = 0; k < 8; k++) {
51
- c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
52
- }
53
- crcTable[n] = c;
54
- }
55
- return crcTable;
56
- }
57
- function calcCrc(uint8Array) {
58
- let c = -1;
59
- if (!pngDataTable)
60
- pngDataTable = createPngDataTable();
61
- for (let n = 0; n < uint8Array.length; n++) {
62
- c = pngDataTable[(c ^ uint8Array[n]) & 255] ^ c >>> 8;
63
- }
64
- return c ^ -1;
65
- }
66
- function searchStartOfPhys(uint8Array) {
67
- const length = uint8Array.length - 1;
68
- for (let i = length; i >= 4; i--) {
69
- if (uint8Array[i - 4] === 9 && uint8Array[i - 3] === _P && uint8Array[i - 2] === _H && uint8Array[i - 1] === _Y && uint8Array[i] === _S) {
70
- return i - 3;
71
- }
72
- }
73
- return 0;
74
- }
75
- function changePngDpi(uint8Array, dpi, overwritepHYs = false) {
76
- const physChunk = new Uint8Array(13);
77
- dpi *= 39.3701;
78
- physChunk[0] = _P;
79
- physChunk[1] = _H;
80
- physChunk[2] = _Y;
81
- physChunk[3] = _S;
82
- physChunk[4] = dpi >>> 24;
83
- physChunk[5] = dpi >>> 16;
84
- physChunk[6] = dpi >>> 8;
85
- physChunk[7] = dpi & 255;
86
- physChunk[8] = physChunk[4];
87
- physChunk[9] = physChunk[5];
88
- physChunk[10] = physChunk[6];
89
- physChunk[11] = physChunk[7];
90
- physChunk[12] = 1;
91
- const crc = calcCrc(physChunk);
92
- const crcChunk = new Uint8Array(4);
93
- crcChunk[0] = crc >>> 24;
94
- crcChunk[1] = crc >>> 16;
95
- crcChunk[2] = crc >>> 8;
96
- crcChunk[3] = crc & 255;
97
- if (overwritepHYs) {
98
- const startingIndex = searchStartOfPhys(uint8Array);
99
- uint8Array.set(physChunk, startingIndex);
100
- uint8Array.set(crcChunk, startingIndex + 13);
101
- return uint8Array;
102
- } else {
103
- const chunkLength = new Uint8Array(4);
104
- chunkLength[0] = 0;
105
- chunkLength[1] = 0;
106
- chunkLength[2] = 0;
107
- chunkLength[3] = 9;
108
- const finalHeader = new Uint8Array(54);
109
- finalHeader.set(uint8Array, 0);
110
- finalHeader.set(chunkLength, 33);
111
- finalHeader.set(physChunk, 37);
112
- finalHeader.set(crcChunk, 50);
113
- return finalHeader;
114
- }
115
- }
116
- const b64PhysSignature1 = "AAlwSFlz";
117
- const b64PhysSignature2 = "AAAJcEhZ";
118
- const b64PhysSignature3 = "AAAACXBI";
119
- function detectPhysChunkFromDataUrl(dataUrl) {
120
- let b64index = dataUrl.indexOf(b64PhysSignature1);
121
- if (b64index === -1) {
122
- b64index = dataUrl.indexOf(b64PhysSignature2);
123
- }
124
- if (b64index === -1) {
125
- b64index = dataUrl.indexOf(b64PhysSignature3);
126
- }
127
- return b64index;
128
- }
129
- const PREFIX = "[modern-screenshot]";
130
- const IN_BROWSER = typeof window !== "undefined";
131
- const SUPPORT_WEB_WORKER = IN_BROWSER && "Worker" in window;
132
- const SUPPORT_ATOB = IN_BROWSER && "atob" in window;
133
- const SUPPORT_BTOA = IN_BROWSER && "btoa" in window;
134
- const USER_AGENT = IN_BROWSER ? (_a = window.navigator) == null ? void 0 : _a.userAgent : "";
135
- const IN_CHROME = USER_AGENT.includes("Chrome");
136
- const IN_SAFARI = USER_AGENT.includes("AppleWebKit") && !IN_CHROME;
137
- const IN_FIREFOX = USER_AGENT.includes("Firefox");
138
- const isContext = (value) => value && "__CONTEXT__" in value;
139
- const isCssFontFaceRule = (rule) => rule.constructor.name === "CSSFontFaceRule";
140
- const isCSSImportRule = (rule) => rule.constructor.name === "CSSImportRule";
141
- const isElementNode = (node) => node.nodeType === 1;
142
- const isSVGElementNode = (node) => typeof node.className === "object";
143
- const isSVGImageElementNode = (node) => node.tagName === "image";
144
- const isSVGUseElementNode = (node) => node.tagName === "use";
145
- const isHTMLElementNode = (node) => isElementNode(node) && typeof node.style !== "undefined" && !isSVGElementNode(node);
146
- const isCommentNode = (node) => node.nodeType === 8;
147
- const isTextNode = (node) => node.nodeType === 3;
148
- const isImageElement = (node) => node.tagName === "IMG";
149
- const isVideoElement = (node) => node.tagName === "VIDEO";
150
- const isCanvasElement = (node) => node.tagName === "CANVAS";
151
- const isTextareaElement = (node) => node.tagName === "TEXTAREA";
152
- const isInputElement = (node) => node.tagName === "INPUT";
153
- const isStyleElement = (node) => node.tagName === "STYLE";
154
- const isScriptElement = (node) => node.tagName === "SCRIPT";
155
- const isSelectElement = (node) => node.tagName === "SELECT";
156
- const isSlotElement = (node) => node.tagName === "SLOT";
157
- const isIFrameElement = (node) => node.tagName === "IFRAME";
158
- const consoleWarn = (...args) => console.warn(PREFIX, ...args);
159
- function supportWebp(ownerDocument) {
160
- var _a2;
161
- const canvas = (_a2 = ownerDocument == null ? void 0 : ownerDocument.createElement) == null ? void 0 : _a2.call(ownerDocument, "canvas");
162
- if (canvas) {
163
- canvas.height = canvas.width = 1;
164
- }
165
- return Boolean(canvas) && "toDataURL" in canvas && Boolean(canvas.toDataURL("image/webp").includes("image/webp"));
166
- }
167
- const isDataUrl = (url) => url.startsWith("data:");
168
- function resolveUrl(url, baseUrl) {
169
- if (url.match(/^[a-z]+:\/\//i))
170
- return url;
171
- if (IN_BROWSER && url.match(/^\/\//))
172
- return window.location.protocol + url;
173
- if (url.match(/^[a-z]+:/i))
174
- return url;
175
- if (!IN_BROWSER)
176
- return url;
177
- const doc = getDocument().implementation.createHTMLDocument();
178
- const base = doc.createElement("base");
179
- const a = doc.createElement("a");
180
- doc.head.appendChild(base);
181
- doc.body.appendChild(a);
182
- if (baseUrl)
183
- base.href = baseUrl;
184
- a.href = url;
185
- return a.href;
186
- }
187
- function getDocument(target) {
188
- return (target && isElementNode(target) ? target == null ? void 0 : target.ownerDocument : target) ?? window.document;
189
- }
190
- const XMLNS = "http://www.w3.org/2000/svg";
191
- function createSvg(width, height, ownerDocument) {
192
- const svg = getDocument(ownerDocument).createElementNS(XMLNS, "svg");
193
- svg.setAttributeNS(null, "width", width.toString());
194
- svg.setAttributeNS(null, "height", height.toString());
195
- svg.setAttributeNS(null, "viewBox", `0 0 ${width} ${height}`);
196
- return svg;
197
- }
198
- function svgToDataUrl(svg, removeControlCharacter) {
199
- let xhtml = new XMLSerializer().serializeToString(svg);
200
- if (removeControlCharacter) {
201
- xhtml = xhtml.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu, "");
202
- }
203
- return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(xhtml)}`;
204
- }
205
- function readBlob(blob, type) {
206
- return new Promise((resolve, reject) => {
207
- const reader = new FileReader();
208
- reader.onload = () => resolve(reader.result);
209
- reader.onerror = () => reject(reader.error);
210
- reader.onabort = () => reject(new Error(`Failed read blob to ${type}`));
211
- {
212
- reader.readAsDataURL(blob);
213
- }
214
- });
215
- }
216
- const blobToDataUrl = (blob) => readBlob(blob, "dataUrl");
217
- function createImage(url, ownerDocument) {
218
- const img = getDocument(ownerDocument).createElement("img");
219
- img.decoding = "sync";
220
- img.loading = "eager";
221
- img.src = url;
222
- return img;
223
- }
224
- function loadMedia(media, options) {
225
- return new Promise((resolve) => {
226
- const { timeout, ownerDocument, onError: userOnError, onWarn } = options ?? {};
227
- const node = typeof media === "string" ? createImage(media, getDocument(ownerDocument)) : media;
228
- let timer = null;
229
- let removeEventListeners = null;
230
- function onResolve() {
231
- resolve(node);
232
- timer && clearTimeout(timer);
233
- removeEventListeners == null ? void 0 : removeEventListeners();
234
- }
235
- if (timeout) {
236
- timer = setTimeout(onResolve, timeout);
237
- }
238
- if (isVideoElement(node)) {
239
- const currentSrc = node.currentSrc || node.src;
240
- if (!currentSrc) {
241
- if (node.poster) {
242
- return loadMedia(node.poster, options).then(resolve);
243
- }
244
- return onResolve();
245
- }
246
- if (node.readyState >= 2) {
247
- return onResolve();
248
- }
249
- const onLoadeddata = onResolve;
250
- const onError = (error) => {
251
- onWarn == null ? void 0 : onWarn(
252
- "Failed video load",
253
- currentSrc,
254
- error
255
- );
256
- userOnError == null ? void 0 : userOnError(error);
257
- onResolve();
258
- };
259
- removeEventListeners = () => {
260
- node.removeEventListener("loadeddata", onLoadeddata);
261
- node.removeEventListener("error", onError);
262
- };
263
- node.addEventListener("loadeddata", onLoadeddata, { once: true });
264
- node.addEventListener("error", onError, { once: true });
265
- } else {
266
- const currentSrc = isSVGImageElementNode(node) ? node.href.baseVal : node.currentSrc || node.src;
267
- if (!currentSrc) {
268
- return onResolve();
269
- }
270
- const onLoad = async () => {
271
- if (isImageElement(node) && "decode" in node) {
272
- try {
273
- await node.decode();
274
- } catch (error) {
275
- onWarn == null ? void 0 : onWarn(
276
- "Failed to decode image, trying to render anyway",
277
- node.dataset.originalSrc || currentSrc,
278
- error
279
- );
280
- }
281
- }
282
- onResolve();
283
- };
284
- const onError = (error) => {
285
- onWarn == null ? void 0 : onWarn(
286
- "Failed image load",
287
- node.dataset.originalSrc || currentSrc,
288
- error
289
- );
290
- onResolve();
291
- };
292
- if (isImageElement(node) && node.complete) {
293
- return onLoad();
294
- }
295
- removeEventListeners = () => {
296
- node.removeEventListener("load", onLoad);
297
- node.removeEventListener("error", onError);
298
- };
299
- node.addEventListener("load", onLoad, { once: true });
300
- node.addEventListener("error", onError, { once: true });
301
- }
302
- });
303
- }
304
- async function waitUntilLoad(node, options) {
305
- if (isHTMLElementNode(node)) {
306
- if (isImageElement(node) || isVideoElement(node)) {
307
- await loadMedia(node, options);
308
- } else {
309
- await Promise.all(
310
- ["img", "video"].flatMap((selectors) => {
311
- return Array.from(node.querySelectorAll(selectors)).map((el) => loadMedia(el, options));
312
- })
313
- );
314
- }
315
- }
316
- }
317
- const uuid = /* @__PURE__ */ function uuid2() {
318
- let counter = 0;
319
- const random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
320
- return () => {
321
- counter += 1;
322
- return `u${random()}${counter}`;
323
- };
324
- }();
325
- function splitFontFamily(fontFamily) {
326
- return fontFamily == null ? void 0 : fontFamily.split(",").map((val) => val.trim().replace(/"|'/g, "").toLowerCase()).filter(Boolean);
327
- }
328
- let uid = 0;
329
- function createLogger(debug) {
330
- const prefix = `${PREFIX}[#${uid}]`;
331
- uid++;
332
- return {
333
- // eslint-disable-next-line no-console
334
- time: (label) => debug && console.time(`${prefix} ${label}`),
335
- // eslint-disable-next-line no-console
336
- timeEnd: (label) => debug && console.timeEnd(`${prefix} ${label}`),
337
- warn: (...args) => debug && consoleWarn(...args)
338
- };
339
- }
340
- function getDefaultRequestInit(bypassingCache) {
341
- return {
342
- cache: bypassingCache ? "no-cache" : "force-cache"
343
- };
344
- }
345
- async function orCreateContext(node, options) {
346
- return isContext(node) ? node : createContext(node, { ...options, autoDestruct: true });
347
- }
348
- async function createContext(node, options) {
349
- var _a2, _b;
350
- const { scale = 1, workerUrl, workerNumber = 1 } = options || {};
351
- const debug = Boolean(options == null ? void 0 : options.debug);
352
- const features = (options == null ? void 0 : options.features) ?? true;
353
- const ownerDocument = node.ownerDocument ?? (IN_BROWSER ? window.document : void 0);
354
- const ownerWindow = ((_a2 = node.ownerDocument) == null ? void 0 : _a2.defaultView) ?? (IN_BROWSER ? window : void 0);
355
- const requests = /* @__PURE__ */ new Map();
356
- const context = {
357
- // Options
358
- width: 0,
359
- height: 0,
360
- quality: 1,
361
- type: "image/png",
362
- scale,
363
- backgroundColor: null,
364
- style: null,
365
- filter: null,
366
- maximumCanvasSize: 0,
367
- timeout: 3e4,
368
- progress: null,
369
- debug,
370
- fetch: {
371
- requestInit: getDefaultRequestInit((_b = options == null ? void 0 : options.fetch) == null ? void 0 : _b.bypassingCache),
372
- placeholderImage: "data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
373
- bypassingCache: false,
374
- ...options == null ? void 0 : options.fetch
375
- },
376
- fetchFn: null,
377
- font: {},
378
- drawImageInterval: 100,
379
- workerUrl: null,
380
- workerNumber,
381
- onCloneNode: null,
382
- onEmbedNode: null,
383
- onCreateForeignObjectSvg: null,
384
- includeStyleProperties: null,
385
- autoDestruct: false,
386
- ...options,
387
- // InternalContext
388
- __CONTEXT__: true,
389
- log: createLogger(debug),
390
- node,
391
- ownerDocument,
392
- ownerWindow,
393
- dpi: scale === 1 ? null : 96 * scale,
394
- svgStyleElement: createStyleElement(ownerDocument),
395
- svgDefsElement: ownerDocument == null ? void 0 : ownerDocument.createElementNS(XMLNS, "defs"),
396
- svgStyles: /* @__PURE__ */ new Map(),
397
- defaultComputedStyles: /* @__PURE__ */ new Map(),
398
- workers: [
399
- ...Array.from({
400
- length: SUPPORT_WEB_WORKER && workerUrl && workerNumber ? workerNumber : 0
401
- })
402
- ].map(() => {
403
- try {
404
- const worker = new Worker(workerUrl);
405
- worker.onmessage = async (event) => {
406
- var _a3, _b2, _c, _d;
407
- const { url, result } = event.data;
408
- if (result) {
409
- (_b2 = (_a3 = requests.get(url)) == null ? void 0 : _a3.resolve) == null ? void 0 : _b2.call(_a3, result);
410
- } else {
411
- (_d = (_c = requests.get(url)) == null ? void 0 : _c.reject) == null ? void 0 : _d.call(_c, new Error(`Error receiving message from worker: ${url}`));
412
- }
413
- };
414
- worker.onmessageerror = (event) => {
415
- var _a3, _b2;
416
- const { url } = event.data;
417
- (_b2 = (_a3 = requests.get(url)) == null ? void 0 : _a3.reject) == null ? void 0 : _b2.call(_a3, new Error(`Error receiving message from worker: ${url}`));
418
- };
419
- return worker;
420
- } catch (error) {
421
- context.log.warn("Failed to new Worker", error);
422
- return null;
423
- }
424
- }).filter(Boolean),
425
- fontFamilies: /* @__PURE__ */ new Map(),
426
- fontCssTexts: /* @__PURE__ */ new Map(),
427
- acceptOfImage: `${[
428
- supportWebp(ownerDocument) && "image/webp",
429
- "image/svg+xml",
430
- "image/*",
431
- "*/*"
432
- ].filter(Boolean).join(",")};q=0.8`,
433
- requests,
434
- drawImageCount: 0,
435
- tasks: [],
436
- features,
437
- isEnable: (key) => {
438
- if (key === "restoreScrollPosition") {
439
- return typeof features === "boolean" ? false : features[key] ?? false;
440
- }
441
- if (typeof features === "boolean") {
442
- return features;
443
- }
444
- return features[key] ?? true;
445
- }
446
- };
447
- context.log.time("wait until load");
448
- await waitUntilLoad(node, { timeout: context.timeout, onWarn: context.log.warn });
449
- context.log.timeEnd("wait until load");
450
- const { width, height } = resolveBoundingBox(node, context);
451
- context.width = width;
452
- context.height = height;
453
- return context;
454
- }
455
- function createStyleElement(ownerDocument) {
456
- if (!ownerDocument)
457
- return void 0;
458
- const style = ownerDocument.createElement("style");
459
- const cssText = style.ownerDocument.createTextNode(`
460
- .______background-clip--text {
461
- background-clip: text;
462
- -webkit-background-clip: text;
463
- }
464
- `);
465
- style.appendChild(cssText);
466
- return style;
467
- }
468
- function resolveBoundingBox(node, context) {
469
- let { width, height } = context;
470
- if (isElementNode(node) && (!width || !height)) {
471
- const box = node.getBoundingClientRect();
472
- width = width || box.width || Number(node.getAttribute("width")) || 0;
473
- height = height || box.height || Number(node.getAttribute("height")) || 0;
474
- }
475
- return { width, height };
476
- }
477
- async function imageToCanvas(image, context) {
478
- const {
479
- log: log2,
480
- timeout,
481
- drawImageCount,
482
- drawImageInterval
483
- } = context;
484
- log2.time("image to canvas");
485
- const loaded = await loadMedia(image, { timeout, onWarn: context.log.warn });
486
- const { canvas, context2d } = createCanvas(image.ownerDocument, context);
487
- const drawImage = () => {
488
- try {
489
- context2d == null ? void 0 : context2d.drawImage(loaded, 0, 0, canvas.width, canvas.height);
490
- } catch (error) {
491
- context.log.warn("Failed to drawImage", error);
492
- }
493
- };
494
- drawImage();
495
- if (context.isEnable("fixSvgXmlDecode")) {
496
- for (let i = 0; i < drawImageCount; i++) {
497
- await new Promise((resolve) => {
498
- setTimeout(() => {
499
- drawImage();
500
- resolve();
501
- }, i + drawImageInterval);
502
- });
503
- }
504
- }
505
- context.drawImageCount = 0;
506
- log2.timeEnd("image to canvas");
507
- return canvas;
508
- }
509
- function createCanvas(ownerDocument, context) {
510
- const { width, height, scale, backgroundColor, maximumCanvasSize: max } = context;
511
- const canvas = ownerDocument.createElement("canvas");
512
- canvas.width = Math.floor(width * scale);
513
- canvas.height = Math.floor(height * scale);
514
- canvas.style.width = `${width}px`;
515
- canvas.style.height = `${height}px`;
516
- if (max) {
517
- if (canvas.width > max || canvas.height > max) {
518
- if (canvas.width > max && canvas.height > max) {
519
- if (canvas.width > canvas.height) {
520
- canvas.height *= max / canvas.width;
521
- canvas.width = max;
522
- } else {
523
- canvas.width *= max / canvas.height;
524
- canvas.height = max;
525
- }
526
- } else if (canvas.width > max) {
527
- canvas.height *= max / canvas.width;
528
- canvas.width = max;
529
- } else {
530
- canvas.width *= max / canvas.height;
531
- canvas.height = max;
532
- }
533
- }
534
- }
535
- const context2d = canvas.getContext("2d");
536
- if (context2d && backgroundColor) {
537
- context2d.fillStyle = backgroundColor;
538
- context2d.fillRect(0, 0, canvas.width, canvas.height);
539
- }
540
- return { canvas, context2d };
541
- }
542
- function cloneCanvas(canvas, context) {
543
- if (canvas.ownerDocument) {
544
- try {
545
- const dataURL = canvas.toDataURL();
546
- if (dataURL !== "data:,") {
547
- return createImage(dataURL, canvas.ownerDocument);
548
- }
549
- } catch (error) {
550
- context.log.warn("Failed to clone canvas", error);
551
- }
552
- }
553
- const cloned = canvas.cloneNode(false);
554
- const ctx = canvas.getContext("2d");
555
- const clonedCtx = cloned.getContext("2d");
556
- try {
557
- if (ctx && clonedCtx) {
558
- clonedCtx.putImageData(
559
- ctx.getImageData(0, 0, canvas.width, canvas.height),
560
- 0,
561
- 0
562
- );
563
- }
564
- return cloned;
565
- } catch (error) {
566
- context.log.warn("Failed to clone canvas", error);
567
- }
568
- return cloned;
569
- }
570
- function cloneIframe(iframe, context) {
571
- var _a2;
572
- try {
573
- if ((_a2 = iframe == null ? void 0 : iframe.contentDocument) == null ? void 0 : _a2.body) {
574
- return cloneNode(iframe.contentDocument.body, context);
575
- }
576
- } catch (error) {
577
- context.log.warn("Failed to clone iframe", error);
578
- }
579
- return iframe.cloneNode(false);
580
- }
581
- function cloneImage(image) {
582
- const cloned = image.cloneNode(false);
583
- if (image.currentSrc && image.currentSrc !== image.src) {
584
- cloned.src = image.currentSrc;
585
- cloned.srcset = "";
586
- }
587
- if (cloned.loading === "lazy") {
588
- cloned.loading = "eager";
589
- }
590
- return cloned;
591
- }
592
- async function cloneVideo(video, context) {
593
- if (video.ownerDocument && !video.currentSrc && video.poster) {
594
- return createImage(video.poster, video.ownerDocument);
595
- }
596
- const cloned = video.cloneNode(false);
597
- cloned.crossOrigin = "anonymous";
598
- if (video.currentSrc && video.currentSrc !== video.src) {
599
- cloned.src = video.currentSrc;
600
- }
601
- const ownerDocument = cloned.ownerDocument;
602
- if (ownerDocument) {
603
- let canPlay = true;
604
- await loadMedia(cloned, { onError: () => canPlay = false, onWarn: context.log.warn });
605
- if (!canPlay) {
606
- if (video.poster) {
607
- return createImage(video.poster, video.ownerDocument);
608
- }
609
- return cloned;
610
- }
611
- cloned.currentTime = video.currentTime;
612
- await new Promise((resolve) => {
613
- cloned.addEventListener("seeked", resolve, { once: true });
614
- });
615
- const canvas = ownerDocument.createElement("canvas");
616
- canvas.width = video.offsetWidth;
617
- canvas.height = video.offsetHeight;
618
- try {
619
- const ctx = canvas.getContext("2d");
620
- if (ctx)
621
- ctx.drawImage(cloned, 0, 0, canvas.width, canvas.height);
622
- } catch (error) {
623
- context.log.warn("Failed to clone video", error);
624
- if (video.poster) {
625
- return createImage(video.poster, video.ownerDocument);
626
- }
627
- return cloned;
628
- }
629
- return cloneCanvas(canvas, context);
630
- }
631
- return cloned;
632
- }
633
- function cloneElement(node, context) {
634
- if (isCanvasElement(node)) {
635
- return cloneCanvas(node, context);
636
- }
637
- if (isIFrameElement(node)) {
638
- return cloneIframe(node, context);
639
- }
640
- if (isImageElement(node)) {
641
- return cloneImage(node);
642
- }
643
- if (isVideoElement(node)) {
644
- return cloneVideo(node, context);
645
- }
646
- return node.cloneNode(false);
647
- }
648
- function getSandBox(context) {
649
- var _a2;
650
- let sandbox = context.sandbox;
651
- if (!sandbox) {
652
- const { ownerDocument } = context;
653
- try {
654
- if (ownerDocument) {
655
- sandbox = ownerDocument.createElement("iframe");
656
- sandbox.id = `__SANDBOX__-${uuid()}`;
657
- sandbox.width = "0";
658
- sandbox.height = "0";
659
- sandbox.style.visibility = "hidden";
660
- sandbox.style.position = "fixed";
661
- ownerDocument.body.appendChild(sandbox);
662
- (_a2 = sandbox.contentWindow) == null ? void 0 : _a2.document.write('<!DOCTYPE html><meta charset="UTF-8"><title></title><body>');
663
- context.sandbox = sandbox;
664
- }
665
- } catch (error) {
666
- context.log.warn("Failed to getSandBox", error);
667
- }
668
- }
669
- return sandbox;
670
- }
671
- const ignoredStyles = [
672
- "width",
673
- "height",
674
- "-webkit-text-fill-color"
675
- ];
676
- const includedAttributes = [
677
- "stroke",
678
- "fill"
679
- ];
680
- function getDefaultStyle(node, pseudoElement, context) {
681
- const { defaultComputedStyles } = context;
682
- const nodeName = node.nodeName.toLowerCase();
683
- const isSvgNode = isSVGElementNode(node) && nodeName !== "svg";
684
- const attributes = isSvgNode ? includedAttributes.map((name) => [name, node.getAttribute(name)]).filter(([, value]) => value !== null) : [];
685
- const key = [
686
- isSvgNode && "svg",
687
- nodeName,
688
- attributes.map((name, value) => `${name}=${value}`).join(","),
689
- pseudoElement
690
- ].filter(Boolean).join(":");
691
- if (defaultComputedStyles.has(key))
692
- return defaultComputedStyles.get(key);
693
- const sandbox = getSandBox(context);
694
- const sandboxWindow = sandbox == null ? void 0 : sandbox.contentWindow;
695
- if (!sandboxWindow)
696
- return /* @__PURE__ */ new Map();
697
- const sandboxDocument = sandboxWindow == null ? void 0 : sandboxWindow.document;
698
- let root;
699
- let el;
700
- if (isSvgNode) {
701
- root = sandboxDocument.createElementNS(XMLNS, "svg");
702
- el = root.ownerDocument.createElementNS(root.namespaceURI, nodeName);
703
- attributes.forEach(([name, value]) => {
704
- el.setAttributeNS(null, name, value);
705
- });
706
- root.appendChild(el);
707
- } else {
708
- root = el = sandboxDocument.createElement(nodeName);
709
- }
710
- el.textContent = " ";
711
- sandboxDocument.body.appendChild(root);
712
- const computedStyle = sandboxWindow.getComputedStyle(el, pseudoElement);
713
- const styles = /* @__PURE__ */ new Map();
714
- for (let len = computedStyle.length, i = 0; i < len; i++) {
715
- const name = computedStyle.item(i);
716
- if (ignoredStyles.includes(name))
717
- continue;
718
- styles.set(name, computedStyle.getPropertyValue(name));
719
- }
720
- sandboxDocument.body.removeChild(root);
721
- defaultComputedStyles.set(key, styles);
722
- return styles;
723
- }
724
- function getDiffStyle(style, defaultStyle, includeStyleProperties) {
725
- var _a2;
726
- const diffStyle = /* @__PURE__ */ new Map();
727
- const prefixs = [];
728
- const prefixTree = /* @__PURE__ */ new Map();
729
- if (includeStyleProperties) {
730
- for (const name of includeStyleProperties) {
731
- applyTo(name);
732
- }
733
- } else {
734
- for (let len = style.length, i = 0; i < len; i++) {
735
- const name = style.item(i);
736
- applyTo(name);
737
- }
738
- }
739
- for (let len = prefixs.length, i = 0; i < len; i++) {
740
- (_a2 = prefixTree.get(prefixs[i])) == null ? void 0 : _a2.forEach((value, name) => diffStyle.set(name, value));
741
- }
742
- function applyTo(name) {
743
- const value = style.getPropertyValue(name);
744
- const priority = style.getPropertyPriority(name);
745
- const subIndex = name.lastIndexOf("-");
746
- const prefix = subIndex > -1 ? name.substring(0, subIndex) : void 0;
747
- if (prefix) {
748
- let map = prefixTree.get(prefix);
749
- if (!map) {
750
- map = /* @__PURE__ */ new Map();
751
- prefixTree.set(prefix, map);
752
- }
753
- map.set(name, [value, priority]);
754
- }
755
- if (defaultStyle.get(name) === value && !priority)
756
- return;
757
- if (prefix) {
758
- prefixs.push(prefix);
759
- } else {
760
- diffStyle.set(name, [value, priority]);
761
- }
762
- }
763
- return diffStyle;
764
- }
765
- function copyCssStyles(node, cloned, isRoot, context) {
766
- var _a2, _b, _c, _d;
767
- const { ownerWindow, includeStyleProperties, currentParentNodeStyle } = context;
768
- const clonedStyle = cloned.style;
769
- const computedStyle = ownerWindow.getComputedStyle(node);
770
- const defaultStyle = getDefaultStyle(node, null, context);
771
- currentParentNodeStyle == null ? void 0 : currentParentNodeStyle.forEach((_, key) => {
772
- defaultStyle.delete(key);
773
- });
774
- const style = getDiffStyle(computedStyle, defaultStyle, includeStyleProperties);
775
- style.delete("transition-property");
776
- style.delete("all");
777
- style.delete("d");
778
- style.delete("content");
779
- if (isRoot) {
780
- style.delete("margin-top");
781
- style.delete("margin-right");
782
- style.delete("margin-bottom");
783
- style.delete("margin-left");
784
- style.delete("margin-block-start");
785
- style.delete("margin-block-end");
786
- style.delete("margin-inline-start");
787
- style.delete("margin-inline-end");
788
- style.set("box-sizing", ["border-box", ""]);
789
- }
790
- if (((_a2 = style.get("background-clip")) == null ? void 0 : _a2[0]) === "text") {
791
- cloned.classList.add("______background-clip--text");
792
- }
793
- if (IN_CHROME) {
794
- if (!style.has("font-kerning"))
795
- style.set("font-kerning", ["normal", ""]);
796
- if ((((_b = style.get("overflow-x")) == null ? void 0 : _b[0]) === "hidden" || ((_c = style.get("overflow-y")) == null ? void 0 : _c[0]) === "hidden") && ((_d = style.get("text-overflow")) == null ? void 0 : _d[0]) === "ellipsis" && node.scrollWidth === node.clientWidth) {
797
- style.set("text-overflow", ["clip", ""]);
798
- }
799
- }
800
- for (let len = clonedStyle.length, i = 0; i < len; i++) {
801
- clonedStyle.removeProperty(clonedStyle.item(i));
802
- }
803
- style.forEach(([value, priority], name) => {
804
- clonedStyle.setProperty(name, value, priority);
805
- });
806
- return style;
807
- }
808
- function copyInputValue(node, cloned) {
809
- if (isTextareaElement(node) || isInputElement(node) || isSelectElement(node)) {
810
- cloned.setAttribute("value", node.value);
811
- }
812
- }
813
- const pseudoClasses = [
814
- ":before",
815
- ":after"
816
- // ':placeholder', TODO
817
- ];
818
- const scrollbarPseudoClasses = [
819
- ":-webkit-scrollbar",
820
- ":-webkit-scrollbar-button",
821
- // ':-webkit-scrollbar:horizontal', TODO
822
- ":-webkit-scrollbar-thumb",
823
- ":-webkit-scrollbar-track",
824
- ":-webkit-scrollbar-track-piece",
825
- // ':-webkit-scrollbar:vertical', TODO
826
- ":-webkit-scrollbar-corner",
827
- ":-webkit-resizer"
828
- ];
829
- function copyPseudoClass(node, cloned, copyScrollbar, context, addWordToFontFamilies) {
830
- const { ownerWindow, svgStyleElement, svgStyles, currentNodeStyle } = context;
831
- if (!svgStyleElement || !ownerWindow)
832
- return;
833
- function copyBy(pseudoClass) {
834
- var _a2;
835
- const computedStyle = ownerWindow.getComputedStyle(node, pseudoClass);
836
- let content = computedStyle.getPropertyValue("content");
837
- if (!content || content === "none")
838
- return;
839
- addWordToFontFamilies == null ? void 0 : addWordToFontFamilies(content);
840
- content = content.replace(/(')|(")|(counter\(.+\))/g, "");
841
- const klasses = [uuid()];
842
- const defaultStyle = getDefaultStyle(node, pseudoClass, context);
843
- currentNodeStyle == null ? void 0 : currentNodeStyle.forEach((_, key) => {
844
- defaultStyle.delete(key);
845
- });
846
- const style = getDiffStyle(computedStyle, defaultStyle, context.includeStyleProperties);
847
- style.delete("content");
848
- style.delete("-webkit-locale");
849
- if (((_a2 = style.get("background-clip")) == null ? void 0 : _a2[0]) === "text") {
850
- cloned.classList.add("______background-clip--text");
851
- }
852
- const cloneStyle = [
853
- `content: '${content}';`
854
- ];
855
- style.forEach(([value, priority], name) => {
856
- cloneStyle.push(`${name}: ${value}${priority ? " !important" : ""};`);
857
- });
858
- if (cloneStyle.length === 1)
859
- return;
860
- try {
861
- cloned.className = [cloned.className, ...klasses].join(" ");
862
- } catch (err) {
863
- context.log.warn("Failed to copyPseudoClass", err);
864
- return;
865
- }
866
- const cssText = cloneStyle.join("\n ");
867
- let allClasses = svgStyles.get(cssText);
868
- if (!allClasses) {
869
- allClasses = [];
870
- svgStyles.set(cssText, allClasses);
871
- }
872
- allClasses.push(`.${klasses[0]}:${pseudoClass}`);
873
- }
874
- pseudoClasses.forEach(copyBy);
875
- if (copyScrollbar)
876
- scrollbarPseudoClasses.forEach(copyBy);
877
- }
878
- const excludeParentNodes = /* @__PURE__ */ new Set([
879
- "symbol"
880
- // test/fixtures/svg.symbol.html
881
- ]);
882
- async function appendChildNode(node, cloned, child, context, addWordToFontFamilies) {
883
- if (isElementNode(child) && (isStyleElement(child) || isScriptElement(child)))
884
- return;
885
- if (context.filter && !context.filter(child))
886
- return;
887
- if (excludeParentNodes.has(cloned.nodeName) || excludeParentNodes.has(child.nodeName)) {
888
- context.currentParentNodeStyle = void 0;
889
- } else {
890
- context.currentParentNodeStyle = context.currentNodeStyle;
891
- }
892
- const childCloned = await cloneNode(child, context, false, addWordToFontFamilies);
893
- if (context.isEnable("restoreScrollPosition")) {
894
- restoreScrollPosition(node, childCloned);
895
- }
896
- cloned.appendChild(childCloned);
897
- }
898
- async function cloneChildNodes(node, cloned, context, addWordToFontFamilies) {
899
- var _a2;
900
- const firstChild = (isElementNode(node) ? (_a2 = node.shadowRoot) == null ? void 0 : _a2.firstChild : void 0) ?? node.firstChild;
901
- for (let child = firstChild; child; child = child.nextSibling) {
902
- if (isCommentNode(child))
903
- continue;
904
- if (isElementNode(child) && isSlotElement(child) && typeof child.assignedNodes === "function") {
905
- const nodes = child.assignedNodes();
906
- for (let i = 0; i < nodes.length; i++) {
907
- await appendChildNode(node, cloned, nodes[i], context, addWordToFontFamilies);
908
- }
909
- } else {
910
- await appendChildNode(node, cloned, child, context, addWordToFontFamilies);
911
- }
912
- }
913
- }
914
- function restoreScrollPosition(node, chlidCloned) {
915
- if (!isHTMLElementNode(node) || !isHTMLElementNode(chlidCloned))
916
- return;
917
- const { scrollTop, scrollLeft } = node;
918
- if (!scrollTop && !scrollLeft) {
919
- return;
920
- }
921
- const { transform } = chlidCloned.style;
922
- const matrix = new DOMMatrix(transform);
923
- const { a, b, c, d } = matrix;
924
- matrix.a = 1;
925
- matrix.b = 0;
926
- matrix.c = 0;
927
- matrix.d = 1;
928
- matrix.translateSelf(-scrollLeft, -scrollTop);
929
- matrix.a = a;
930
- matrix.b = b;
931
- matrix.c = c;
932
- matrix.d = d;
933
- chlidCloned.style.transform = matrix.toString();
934
- }
935
- function applyCssStyleWithOptions(cloned, context) {
936
- const { backgroundColor, width, height, style: styles } = context;
937
- const clonedStyle = cloned.style;
938
- if (backgroundColor)
939
- clonedStyle.setProperty("background-color", backgroundColor, "important");
940
- if (width)
941
- clonedStyle.setProperty("width", `${width}px`, "important");
942
- if (height)
943
- clonedStyle.setProperty("height", `${height}px`, "important");
944
- if (styles) {
945
- for (const name in styles) clonedStyle[name] = styles[name];
946
- }
947
- }
948
- const NORMAL_ATTRIBUTE_RE = /^[\w-:]+$/;
949
- async function cloneNode(node, context, isRoot = false, addWordToFontFamilies) {
950
- var _a2, _b, _c, _d;
951
- const { ownerDocument, ownerWindow, fontFamilies } = context;
952
- if (ownerDocument && isTextNode(node)) {
953
- if (addWordToFontFamilies && /\S/.test(node.data)) {
954
- addWordToFontFamilies(node.data);
955
- }
956
- return ownerDocument.createTextNode(node.data);
957
- }
958
- if (ownerDocument && ownerWindow && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) {
959
- const cloned2 = await cloneElement(node, context);
960
- if (context.isEnable("removeAbnormalAttributes")) {
961
- const names = cloned2.getAttributeNames();
962
- for (let len = names.length, i = 0; i < len; i++) {
963
- const name = names[i];
964
- if (!NORMAL_ATTRIBUTE_RE.test(name)) {
965
- cloned2.removeAttribute(name);
966
- }
967
- }
968
- }
969
- const style = context.currentNodeStyle = copyCssStyles(node, cloned2, isRoot, context);
970
- if (isRoot)
971
- applyCssStyleWithOptions(cloned2, context);
972
- let copyScrollbar = false;
973
- if (context.isEnable("copyScrollbar")) {
974
- const overflow = [
975
- (_a2 = style.get("overflow-x")) == null ? void 0 : _a2[0],
976
- (_b = style.get("overflow-y")) == null ? void 0 : _b[0]
977
- ];
978
- copyScrollbar = overflow.includes("scroll") || (overflow.includes("auto") || overflow.includes("overlay")) && (node.scrollHeight > node.clientHeight || node.scrollWidth > node.clientWidth);
979
- }
980
- const textTransform = (_c = style.get("text-transform")) == null ? void 0 : _c[0];
981
- const families = splitFontFamily((_d = style.get("font-family")) == null ? void 0 : _d[0]);
982
- const addWordToFontFamilies2 = families ? (word) => {
983
- if (textTransform === "uppercase") {
984
- word = word.toUpperCase();
985
- } else if (textTransform === "lowercase") {
986
- word = word.toLowerCase();
987
- } else if (textTransform === "capitalize") {
988
- word = word[0].toUpperCase() + word.substring(1);
989
- }
990
- families.forEach((family) => {
991
- let fontFamily = fontFamilies.get(family);
992
- if (!fontFamily) {
993
- fontFamilies.set(family, fontFamily = /* @__PURE__ */ new Set());
994
- }
995
- word.split("").forEach((text) => fontFamily.add(text));
996
- });
997
- } : void 0;
998
- copyPseudoClass(
999
- node,
1000
- cloned2,
1001
- copyScrollbar,
1002
- context,
1003
- addWordToFontFamilies2
1004
- );
1005
- copyInputValue(node, cloned2);
1006
- if (!isVideoElement(node)) {
1007
- await cloneChildNodes(
1008
- node,
1009
- cloned2,
1010
- context,
1011
- addWordToFontFamilies2
1012
- );
1013
- }
1014
- return cloned2;
1015
- }
1016
- const cloned = node.cloneNode(false);
1017
- await cloneChildNodes(node, cloned, context);
1018
- return cloned;
1019
- }
1020
- function destroyContext(context) {
1021
- context.ownerDocument = void 0;
1022
- context.ownerWindow = void 0;
1023
- context.svgStyleElement = void 0;
1024
- context.svgDefsElement = void 0;
1025
- context.svgStyles.clear();
1026
- context.defaultComputedStyles.clear();
1027
- if (context.sandbox) {
1028
- try {
1029
- context.sandbox.remove();
1030
- } catch (err) {
1031
- context.log.warn("Failed to destroyContext", err);
1032
- }
1033
- context.sandbox = void 0;
1034
- }
1035
- context.workers = [];
1036
- context.fontFamilies.clear();
1037
- context.fontCssTexts.clear();
1038
- context.requests.clear();
1039
- context.tasks = [];
1040
- }
1041
- function baseFetch(options) {
1042
- const { url, timeout, responseType, ...requestInit } = options;
1043
- const controller = new AbortController();
1044
- const timer = timeout ? setTimeout(() => controller.abort(), timeout) : void 0;
1045
- return fetch(url, { signal: controller.signal, ...requestInit }).then((response) => {
1046
- if (!response.ok) {
1047
- throw new Error("Failed fetch, not 2xx response", { cause: response });
1048
- }
1049
- switch (responseType) {
1050
- case "arrayBuffer":
1051
- return response.arrayBuffer();
1052
- case "dataUrl":
1053
- return response.blob().then(blobToDataUrl);
1054
- case "text":
1055
- default:
1056
- return response.text();
1057
- }
1058
- }).finally(() => clearTimeout(timer));
1059
- }
1060
- function contextFetch(context, options) {
1061
- const { url: rawUrl, requestType = "text", responseType = "text", imageDom } = options;
1062
- let url = rawUrl;
1063
- const {
1064
- timeout,
1065
- acceptOfImage,
1066
- requests,
1067
- fetchFn,
1068
- fetch: {
1069
- requestInit,
1070
- bypassingCache,
1071
- placeholderImage
1072
- },
1073
- font,
1074
- workers,
1075
- fontFamilies
1076
- } = context;
1077
- if (requestType === "image" && (IN_SAFARI || IN_FIREFOX)) {
1078
- context.drawImageCount++;
1079
- }
1080
- let request = requests.get(rawUrl);
1081
- if (!request) {
1082
- if (bypassingCache) {
1083
- if (bypassingCache instanceof RegExp && bypassingCache.test(url)) {
1084
- url += (/\?/.test(url) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
1085
- }
1086
- }
1087
- const canFontMinify = requestType.startsWith("font") && font && font.minify;
1088
- const fontTexts = /* @__PURE__ */ new Set();
1089
- if (canFontMinify) {
1090
- const families = requestType.split(";")[1].split(",");
1091
- families.forEach((family) => {
1092
- if (!fontFamilies.has(family))
1093
- return;
1094
- fontFamilies.get(family).forEach((text) => fontTexts.add(text));
1095
- });
1096
- }
1097
- const needFontMinify = canFontMinify && fontTexts.size;
1098
- const baseFetchOptions = {
1099
- url,
1100
- timeout,
1101
- responseType: needFontMinify ? "arrayBuffer" : responseType,
1102
- headers: requestType === "image" ? { accept: acceptOfImage } : void 0,
1103
- ...requestInit
1104
- };
1105
- request = {
1106
- type: requestType,
1107
- resolve: void 0,
1108
- reject: void 0,
1109
- response: null
1110
- };
1111
- request.response = (async () => {
1112
- if (fetchFn && requestType === "image") {
1113
- const result = await fetchFn(rawUrl);
1114
- if (result)
1115
- return result;
1116
- }
1117
- if (!IN_SAFARI && rawUrl.startsWith("http") && workers.length) {
1118
- return new Promise((resolve, reject) => {
1119
- const worker = workers[requests.size & workers.length - 1];
1120
- worker.postMessage({ rawUrl, ...baseFetchOptions });
1121
- request.resolve = resolve;
1122
- request.reject = reject;
1123
- });
1124
- }
1125
- return baseFetch(baseFetchOptions);
1126
- })().catch((error) => {
1127
- requests.delete(rawUrl);
1128
- if (requestType === "image" && placeholderImage) {
1129
- context.log.warn("Failed to fetch image base64, trying to use placeholder image", url);
1130
- return typeof placeholderImage === "string" ? placeholderImage : placeholderImage(imageDom);
1131
- }
1132
- throw error;
1133
- });
1134
- requests.set(rawUrl, request);
1135
- }
1136
- return request.response;
1137
- }
1138
- async function replaceCssUrlToDataUrl(cssText, baseUrl, context, isImage) {
1139
- if (!hasCssUrl(cssText))
1140
- return cssText;
1141
- for (const [rawUrl, url] of parseCssUrls(cssText, baseUrl)) {
1142
- try {
1143
- const dataUrl = await contextFetch(
1144
- context,
1145
- {
1146
- url,
1147
- requestType: isImage ? "image" : "text",
1148
- responseType: "dataUrl"
1149
- }
1150
- );
1151
- cssText = cssText.replace(toRE(rawUrl), `$1${dataUrl}$3`);
1152
- } catch (error) {
1153
- context.log.warn("Failed to fetch css data url", rawUrl, error);
1154
- }
1155
- }
1156
- return cssText;
1157
- }
1158
- function hasCssUrl(cssText) {
1159
- return /url\((['"]?)([^'"]+?)\1\)/.test(cssText);
1160
- }
1161
- const URL_RE = /url\((['"]?)([^'"]+?)\1\)/g;
1162
- function parseCssUrls(cssText, baseUrl) {
1163
- const result = [];
1164
- cssText.replace(URL_RE, (raw, quotation, url) => {
1165
- result.push([url, resolveUrl(url, baseUrl)]);
1166
- return raw;
1167
- });
1168
- return result.filter(([url]) => !isDataUrl(url));
1169
- }
1170
- function toRE(url) {
1171
- const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
1172
- return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
1173
- }
1174
- const properties = [
1175
- "background-image",
1176
- "border-image-source",
1177
- "-webkit-border-image",
1178
- "-webkit-mask-image",
1179
- "list-style-image"
1180
- ];
1181
- function embedCssStyleImage(style, context) {
1182
- return properties.map((property) => {
1183
- const value = style.getPropertyValue(property);
1184
- if (!value || value === "none") {
1185
- return null;
1186
- }
1187
- if (IN_SAFARI || IN_FIREFOX) {
1188
- context.drawImageCount++;
1189
- }
1190
- return replaceCssUrlToDataUrl(value, null, context, true).then((newValue) => {
1191
- if (!newValue || value === newValue)
1192
- return;
1193
- style.setProperty(
1194
- property,
1195
- newValue,
1196
- style.getPropertyPriority(property)
1197
- );
1198
- });
1199
- }).filter(Boolean);
1200
- }
1201
- function embedImageElement(cloned, context) {
1202
- if (isImageElement(cloned)) {
1203
- const originalSrc = cloned.currentSrc || cloned.src;
1204
- if (!isDataUrl(originalSrc)) {
1205
- return [
1206
- contextFetch(context, {
1207
- url: originalSrc,
1208
- imageDom: cloned,
1209
- requestType: "image",
1210
- responseType: "dataUrl"
1211
- }).then((url) => {
1212
- if (!url)
1213
- return;
1214
- cloned.srcset = "";
1215
- cloned.dataset.originalSrc = originalSrc;
1216
- cloned.src = url || "";
1217
- })
1218
- ];
1219
- }
1220
- if (IN_SAFARI || IN_FIREFOX) {
1221
- context.drawImageCount++;
1222
- }
1223
- } else if (isSVGElementNode(cloned) && !isDataUrl(cloned.href.baseVal)) {
1224
- const originalSrc = cloned.href.baseVal;
1225
- return [
1226
- contextFetch(context, {
1227
- url: originalSrc,
1228
- imageDom: cloned,
1229
- requestType: "image",
1230
- responseType: "dataUrl"
1231
- }).then((url) => {
1232
- if (!url)
1233
- return;
1234
- cloned.dataset.originalSrc = originalSrc;
1235
- cloned.href.baseVal = url || "";
1236
- })
1237
- ];
1238
- }
1239
- return [];
1240
- }
1241
- function embedSvgUse(cloned, context) {
1242
- const { ownerDocument, svgDefsElement } = context;
1243
- const href = cloned.getAttribute("href") ?? cloned.getAttribute("xlink:href");
1244
- if (!href)
1245
- return [];
1246
- const [svgUrl, id] = href.split("#");
1247
- if (id) {
1248
- const query = `#${id}`;
1249
- const definition = ownerDocument == null ? void 0 : ownerDocument.querySelector(`svg ${query}`);
1250
- if (svgUrl) {
1251
- cloned.setAttribute("href", query);
1252
- }
1253
- if (svgDefsElement == null ? void 0 : svgDefsElement.querySelector(query))
1254
- return [];
1255
- if (definition) {
1256
- svgDefsElement == null ? void 0 : svgDefsElement.appendChild(definition.cloneNode(true));
1257
- return [];
1258
- } else if (svgUrl) {
1259
- return [
1260
- contextFetch(context, {
1261
- url: svgUrl,
1262
- responseType: "text"
1263
- }).then((svgData) => {
1264
- svgDefsElement == null ? void 0 : svgDefsElement.insertAdjacentHTML("beforeend", svgData);
1265
- })
1266
- ];
1267
- }
1268
- }
1269
- return [];
1270
- }
1271
- function embedNode(cloned, context) {
1272
- const { tasks } = context;
1273
- if (isElementNode(cloned)) {
1274
- if (isImageElement(cloned) || isSVGImageElementNode(cloned)) {
1275
- tasks.push(...embedImageElement(cloned, context));
1276
- }
1277
- if (isSVGUseElementNode(cloned)) {
1278
- tasks.push(...embedSvgUse(cloned, context));
1279
- }
1280
- }
1281
- if (isHTMLElementNode(cloned)) {
1282
- tasks.push(...embedCssStyleImage(cloned.style, context));
1283
- }
1284
- cloned.childNodes.forEach((child) => {
1285
- embedNode(child, context);
1286
- });
1287
- }
1288
- async function embedWebFont(clone, context) {
1289
- const {
1290
- ownerDocument,
1291
- svgStyleElement,
1292
- fontFamilies,
1293
- fontCssTexts,
1294
- tasks,
1295
- font
1296
- } = context;
1297
- if (!ownerDocument || !svgStyleElement || !fontFamilies.size) {
1298
- return;
1299
- }
1300
- if (font && font.cssText) {
1301
- const cssText = filterPreferredFormat(font.cssText, context);
1302
- svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText}
1303
- `));
1304
- } else {
1305
- const styleSheets = Array.from(ownerDocument.styleSheets).filter((styleSheet) => {
1306
- try {
1307
- return "cssRules" in styleSheet && Boolean(styleSheet.cssRules.length);
1308
- } catch (error) {
1309
- context.log.warn(`Error while reading CSS rules from ${styleSheet.href}`, error);
1310
- return false;
1311
- }
1312
- });
1313
- await Promise.all(
1314
- styleSheets.flatMap((styleSheet) => {
1315
- return Array.from(styleSheet.cssRules).map(async (cssRule, index) => {
1316
- if (isCSSImportRule(cssRule)) {
1317
- let importIndex = index + 1;
1318
- const baseUrl = cssRule.href;
1319
- let cssText = "";
1320
- try {
1321
- cssText = await contextFetch(context, {
1322
- url: baseUrl,
1323
- requestType: "text",
1324
- responseType: "text"
1325
- });
1326
- } catch (error) {
1327
- context.log.warn(`Error fetch remote css import from ${baseUrl}`, error);
1328
- }
1329
- const replacedCssText = cssText.replace(
1330
- URL_RE,
1331
- (raw, quotation, url) => raw.replace(url, resolveUrl(url, baseUrl))
1332
- );
1333
- for (const rule of parseCss(replacedCssText)) {
1334
- try {
1335
- styleSheet.insertRule(
1336
- rule,
1337
- rule.startsWith("@import") ? importIndex += 1 : styleSheet.cssRules.length
1338
- );
1339
- } catch (error) {
1340
- context.log.warn("Error inserting rule from remote css import", { rule, error });
1341
- }
1342
- }
1343
- }
1344
- });
1345
- })
1346
- );
1347
- const cssRules = styleSheets.flatMap((styleSheet) => Array.from(styleSheet.cssRules));
1348
- cssRules.filter((cssRule) => {
1349
- var _a2;
1350
- return isCssFontFaceRule(cssRule) && hasCssUrl(cssRule.style.getPropertyValue("src")) && ((_a2 = splitFontFamily(cssRule.style.getPropertyValue("font-family"))) == null ? void 0 : _a2.some((val) => fontFamilies.has(val)));
1351
- }).forEach((value) => {
1352
- const rule = value;
1353
- const cssText = fontCssTexts.get(rule.cssText);
1354
- if (cssText) {
1355
- svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText}
1356
- `));
1357
- } else {
1358
- tasks.push(
1359
- replaceCssUrlToDataUrl(
1360
- rule.cssText,
1361
- rule.parentStyleSheet ? rule.parentStyleSheet.href : null,
1362
- context
1363
- ).then((cssText2) => {
1364
- cssText2 = filterPreferredFormat(cssText2, context);
1365
- fontCssTexts.set(rule.cssText, cssText2);
1366
- svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText2}
1367
- `));
1368
- })
1369
- );
1370
- }
1371
- });
1372
- }
1373
- }
1374
- const COMMENTS_RE = /(\/\*[\s\S]*?\*\/)/g;
1375
- const KEYFRAMES_RE = /((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;
1376
- function parseCss(source) {
1377
- if (source == null)
1378
- return [];
1379
- const result = [];
1380
- let cssText = source.replace(COMMENTS_RE, "");
1381
- while (true) {
1382
- const matches = KEYFRAMES_RE.exec(cssText);
1383
- if (!matches)
1384
- break;
1385
- result.push(matches[0]);
1386
- }
1387
- cssText = cssText.replace(KEYFRAMES_RE, "");
1388
- const IMPORT_RE = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
1389
- const UNIFIED_RE = new RegExp(
1390
- // eslint-disable-next-line
1391
- "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",
1392
- "gi"
1393
- );
1394
- while (true) {
1395
- let matches = IMPORT_RE.exec(cssText);
1396
- if (!matches) {
1397
- matches = UNIFIED_RE.exec(cssText);
1398
- if (!matches) {
1399
- break;
1400
- } else {
1401
- IMPORT_RE.lastIndex = UNIFIED_RE.lastIndex;
1402
- }
1403
- } else {
1404
- UNIFIED_RE.lastIndex = IMPORT_RE.lastIndex;
1405
- }
1406
- result.push(matches[0]);
1407
- }
1408
- return result;
1409
- }
1410
- const URL_WITH_FORMAT_RE = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
1411
- const FONT_SRC_RE = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
1412
- function filterPreferredFormat(str, context) {
1413
- const { font } = context;
1414
- const preferredFormat = font ? font == null ? void 0 : font.preferredFormat : void 0;
1415
- return preferredFormat ? str.replace(FONT_SRC_RE, (match) => {
1416
- while (true) {
1417
- const [src, , format] = URL_WITH_FORMAT_RE.exec(match) || [];
1418
- if (!format)
1419
- return "";
1420
- if (format === preferredFormat)
1421
- return `src: ${src};`;
1422
- }
1423
- }) : str;
1424
- }
1425
- async function domToForeignObjectSvg(node, options) {
1426
- const context = await orCreateContext(node, options);
1427
- if (isElementNode(context.node) && isSVGElementNode(context.node))
1428
- return context.node;
1429
- const {
1430
- ownerDocument,
1431
- log: log2,
1432
- tasks,
1433
- svgStyleElement,
1434
- svgDefsElement,
1435
- svgStyles,
1436
- font,
1437
- progress,
1438
- autoDestruct,
1439
- onCloneNode,
1440
- onEmbedNode,
1441
- onCreateForeignObjectSvg
1442
- } = context;
1443
- log2.time("clone node");
1444
- const clone = await cloneNode(context.node, context, true);
1445
- if (svgStyleElement && ownerDocument) {
1446
- let allCssText = "";
1447
- svgStyles.forEach((klasses, cssText) => {
1448
- allCssText += `${klasses.join(",\n")} {
1449
- ${cssText}
1450
- }
1451
- `;
1452
- });
1453
- svgStyleElement.appendChild(ownerDocument.createTextNode(allCssText));
1454
- }
1455
- log2.timeEnd("clone node");
1456
- await (onCloneNode == null ? void 0 : onCloneNode(clone));
1457
- if (font !== false && isElementNode(clone)) {
1458
- log2.time("embed web font");
1459
- await embedWebFont(clone, context);
1460
- log2.timeEnd("embed web font");
1461
- }
1462
- log2.time("embed node");
1463
- embedNode(clone, context);
1464
- const count = tasks.length;
1465
- let current = 0;
1466
- const runTask = async () => {
1467
- while (true) {
1468
- const task = tasks.pop();
1469
- if (!task)
1470
- break;
1471
- try {
1472
- await task;
1473
- } catch (error) {
1474
- context.log.warn("Failed to run task", error);
1475
- }
1476
- progress == null ? void 0 : progress(++current, count);
1477
- }
1478
- };
1479
- progress == null ? void 0 : progress(current, count);
1480
- await Promise.all([...Array.from({ length: 4 })].map(runTask));
1481
- log2.timeEnd("embed node");
1482
- await (onEmbedNode == null ? void 0 : onEmbedNode(clone));
1483
- const svg = createForeignObjectSvg(clone, context);
1484
- svgDefsElement && svg.insertBefore(svgDefsElement, svg.children[0]);
1485
- svgStyleElement && svg.insertBefore(svgStyleElement, svg.children[0]);
1486
- autoDestruct && destroyContext(context);
1487
- await (onCreateForeignObjectSvg == null ? void 0 : onCreateForeignObjectSvg(svg));
1488
- return svg;
1489
- }
1490
- function createForeignObjectSvg(clone, context) {
1491
- const { width, height } = context;
1492
- const svg = createSvg(width, height, clone.ownerDocument);
1493
- const foreignObject = svg.ownerDocument.createElementNS(svg.namespaceURI, "foreignObject");
1494
- foreignObject.setAttributeNS(null, "x", "0%");
1495
- foreignObject.setAttributeNS(null, "y", "0%");
1496
- foreignObject.setAttributeNS(null, "width", "100%");
1497
- foreignObject.setAttributeNS(null, "height", "100%");
1498
- foreignObject.append(clone);
1499
- svg.appendChild(foreignObject);
1500
- return svg;
1501
- }
1502
- async function domToCanvas(node, options) {
1503
- var _a2;
1504
- const context = await orCreateContext(node, options);
1505
- const svg = await domToForeignObjectSvg(context);
1506
- const dataUrl = svgToDataUrl(svg, context.isEnable("removeControlCharacter"));
1507
- if (!context.autoDestruct) {
1508
- context.svgStyleElement = createStyleElement(context.ownerDocument);
1509
- context.svgDefsElement = (_a2 = context.ownerDocument) == null ? void 0 : _a2.createElementNS(XMLNS, "defs");
1510
- context.svgStyles.clear();
1511
- }
1512
- const image = createImage(dataUrl, svg.ownerDocument);
1513
- return await imageToCanvas(image, context);
1514
- }
1515
- async function domToDataUrl(node, options) {
1516
- const context = await orCreateContext(node, options);
1517
- const { log: log2, quality, type, dpi } = context;
1518
- const canvas = await domToCanvas(context);
1519
- log2.time("canvas to data url");
1520
- let dataUrl = canvas.toDataURL(type, quality);
1521
- if (["image/png", "image/jpeg"].includes(type) && dpi && SUPPORT_ATOB && SUPPORT_BTOA) {
1522
- const [format, body] = dataUrl.split(",");
1523
- let headerLength = 0;
1524
- let overwritepHYs = false;
1525
- if (type === "image/png") {
1526
- const b64Index = detectPhysChunkFromDataUrl(body);
1527
- if (b64Index >= 0) {
1528
- headerLength = Math.ceil((b64Index + 28) / 3) * 4;
1529
- overwritepHYs = true;
1530
- } else {
1531
- headerLength = 33 / 3 * 4;
1532
- }
1533
- } else if (type === "image/jpeg") {
1534
- headerLength = 18 / 3 * 4;
1535
- }
1536
- const stringHeader = body.substring(0, headerLength);
1537
- const restOfData = body.substring(headerLength);
1538
- const headerBytes = window.atob(stringHeader);
1539
- const uint8Array = new Uint8Array(headerBytes.length);
1540
- for (let i = 0; i < uint8Array.length; i++) {
1541
- uint8Array[i] = headerBytes.charCodeAt(i);
1542
- }
1543
- const finalArray = type === "image/png" ? changePngDpi(uint8Array, dpi, overwritepHYs) : changeJpegDpi(uint8Array, dpi);
1544
- const base64Header = window.btoa(String.fromCharCode(...finalArray));
1545
- dataUrl = [format, ",", base64Header, restOfData].join("");
1546
- }
1547
- log2.timeEnd("canvas to data url");
1548
- return dataUrl;
1549
- }
1550
- async function domToSvg(node, options) {
1551
- const context = await orCreateContext(node, options);
1552
- const { width, height, ownerDocument } = context;
1553
- const dataUrl = await domToDataUrl(context);
1554
- const svg = createSvg(width, height, ownerDocument);
1555
- const svgImage = svg.ownerDocument.createElementNS(svg.namespaceURI, "image");
1556
- svgImage.setAttributeNS(null, "href", dataUrl);
1557
- svgImage.setAttributeNS(null, "height", "100%");
1558
- svgImage.setAttributeNS(null, "width", "100%");
1559
- svg.appendChild(svgImage);
1560
- return svgToDataUrl(svg, context.isEnable("removeControlCharacter"));
1561
- }
1562
- async function domToJpeg(node, options) {
1563
- return domToDataUrl(
1564
- await orCreateContext(node, { ...options, type: "image/jpeg" })
1565
- );
1566
- }
1567
- async function domToPng(node, options) {
1568
- return domToDataUrl(
1569
- await orCreateContext(node, { ...options, type: "image/png" })
1570
- );
1571
- }
1572
- async function domToWebp(node, options) {
1573
- return domToDataUrl(
1574
- await orCreateContext(node, { ...options, type: "image/webp" })
1575
- );
1576
- }
1577
- async function captureElement(element, imageOptions, filenames) {
1578
- try {
1579
- let dataURL = "";
1580
- let htmlToImageOptions = {
1581
- // Ensure quality is a number
1582
- quality: imageOptions.quality,
1583
- // Ensure scale is a number
1584
- scale: imageOptions.scale,
1585
- // Ignores elements with data-ignore-capture attribute
1586
- filter
1587
- };
1588
- const styles = getComputedStyle(element);
1589
- const backgroundColor = styles.backgroundColor;
1590
- const backgroundImage = styles.backgroundImage;
1591
- let cleanUpBackground = false;
1592
- if (backgroundColor === "rgba(0, 0, 0, 0)" && backgroundImage === "none" && imageOptions.format === "jpg") {
1593
- element.style.backgroundColor = "#FFFFFF";
1594
- cleanUpBackground = true;
1595
- }
1596
- switch (imageOptions.format) {
1597
- case "jpg":
1598
- dataURL = await domToJpeg(element, htmlToImageOptions);
1599
- break;
1600
- case "png":
1601
- dataURL = await domToPng(element, htmlToImageOptions);
1602
- break;
1603
- case "svg":
1604
- dataURL = await domToSvg(element, htmlToImageOptions);
1605
- break;
1606
- case "webp":
1607
- dataURL = await domToWebp(element, htmlToImageOptions);
1608
- break;
1609
- }
1610
- if (cleanUpBackground) {
1611
- element.style.backgroundColor = "";
1612
- element.style.backgroundImage = "";
1613
- }
1614
- return {
1615
- dataURL,
1616
- fileName: handleFileNames(imageOptions, filenames)
1617
- };
1618
- } catch (error) {
1619
- console.error("ImageExporter: Error in captureImage", error);
1620
- return { dataURL: "", fileName: "" };
1621
- }
1622
- }
1623
- const filter = (node) => {
1624
- if (node instanceof HTMLElement) {
1625
- return !node.hasAttribute("data-ignore-capture");
1626
- }
1627
- return true;
1628
- };
1629
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1630
- function getDefaultExportFromCjs(x) {
1631
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1632
- }
1633
- var download$2 = { exports: {} };
1634
- var download$1 = download$2.exports;
1635
- var hasRequiredDownload;
1636
- function requireDownload() {
1637
- if (hasRequiredDownload) return download$2.exports;
1638
- hasRequiredDownload = 1;
1639
- (function(module, exports) {
1640
- (function(root, factory) {
1641
- {
1642
- module.exports = factory();
1643
- }
1644
- })(download$1, function() {
1645
- return function download2(data, strFileName, strMimeType) {
1646
- var self2 = window, defaultMime = "application/octet-stream", mimeType = strMimeType || defaultMime, payload = data, url = !strFileName && !strMimeType && payload, anchor = document.createElement("a"), toString = function(a) {
1647
- return String(a);
1648
- }, myBlob = self2.Blob || self2.MozBlob || self2.WebKitBlob || toString, fileName = strFileName || "download", blob, reader;
1649
- myBlob = myBlob.call ? myBlob.bind(self2) : Blob;
1650
- if (String(this) === "true") {
1651
- payload = [payload, mimeType];
1652
- mimeType = payload[0];
1653
- payload = payload[1];
1654
- }
1655
- if (url && url.length < 2048) {
1656
- fileName = url.split("/").pop().split("?")[0];
1657
- anchor.href = url;
1658
- if (anchor.href.indexOf(url) !== -1) {
1659
- var ajax = new XMLHttpRequest();
1660
- ajax.open("GET", url, true);
1661
- ajax.responseType = "blob";
1662
- ajax.onload = function(e) {
1663
- download2(e.target.response, fileName, defaultMime);
1664
- };
1665
- setTimeout(function() {
1666
- ajax.send();
1667
- }, 0);
1668
- return ajax;
1669
- }
1670
- }
1671
- if (/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)) {
1672
- if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
1673
- payload = dataUrlToBlob(payload);
1674
- mimeType = payload.type || defaultMime;
1675
- } else {
1676
- return navigator.msSaveBlob ? (
1677
- // IE10 can't do a[download], only Blobs:
1678
- navigator.msSaveBlob(dataUrlToBlob(payload), fileName)
1679
- ) : saver(payload);
1680
- }
1681
- } else {
1682
- if (/([\x80-\xff])/.test(payload)) {
1683
- var i = 0, tempUiArr = new Uint8Array(payload.length), mx = tempUiArr.length;
1684
- for (i; i < mx; ++i) tempUiArr[i] = payload.charCodeAt(i);
1685
- payload = new myBlob([tempUiArr], { type: mimeType });
1686
- }
1687
- }
1688
- blob = payload instanceof myBlob ? payload : new myBlob([payload], { type: mimeType });
1689
- function dataUrlToBlob(strUrl) {
1690
- var parts = strUrl.split(/[:;,]/), type = parts[1], decoder = parts[2] == "base64" ? atob : decodeURIComponent, binData = decoder(parts.pop()), mx2 = binData.length, i2 = 0, uiArr = new Uint8Array(mx2);
1691
- for (i2; i2 < mx2; ++i2) uiArr[i2] = binData.charCodeAt(i2);
1692
- return new myBlob([uiArr], { type });
1693
- }
1694
- function saver(url2, winMode) {
1695
- if ("download" in anchor) {
1696
- anchor.href = url2;
1697
- anchor.setAttribute("download", fileName);
1698
- anchor.className = "download-js-link";
1699
- anchor.innerHTML = "downloading...";
1700
- anchor.style.display = "none";
1701
- document.body.appendChild(anchor);
1702
- setTimeout(function() {
1703
- anchor.click();
1704
- document.body.removeChild(anchor);
1705
- if (winMode === true) {
1706
- setTimeout(function() {
1707
- self2.URL.revokeObjectURL(anchor.href);
1708
- }, 250);
1709
- }
1710
- }, 66);
1711
- return true;
1712
- }
1713
- if (/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
1714
- if (/^data:/.test(url2)) url2 = "data:" + url2.replace(/^data:([\w\/\-\+]+)/, defaultMime);
1715
- if (!window.open(url2)) {
1716
- if (confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")) {
1717
- location.href = url2;
1718
- }
1719
- }
1720
- return true;
1721
- }
1722
- var f = document.createElement("iframe");
1723
- document.body.appendChild(f);
1724
- if (!winMode && /^data:/.test(url2)) {
1725
- url2 = "data:" + url2.replace(/^data:([\w\/\-\+]+)/, defaultMime);
1726
- }
1727
- f.src = url2;
1728
- setTimeout(function() {
1729
- document.body.removeChild(f);
1730
- }, 333);
1731
- }
1732
- if (navigator.msSaveBlob) {
1733
- return navigator.msSaveBlob(blob, fileName);
1734
- }
1735
- if (self2.URL) {
1736
- saver(self2.URL.createObjectURL(blob), true);
1737
- } else {
1738
- if (typeof blob === "string" || blob.constructor === toString) {
1739
- try {
1740
- return saver("data:" + mimeType + ";base64," + self2.btoa(blob));
1741
- } catch (y) {
1742
- return saver("data:" + mimeType + "," + encodeURIComponent(blob));
1743
- }
1744
- }
1745
- reader = new FileReader();
1746
- reader.onload = function(e) {
1747
- saver(this.result);
1748
- };
1749
- reader.readAsDataURL(blob);
1750
- }
1751
- return true;
1752
- };
1753
- });
1754
- })(download$2);
1755
- return download$2.exports;
1756
- }
1757
- var downloadExports = requireDownload();
1758
- const download = /* @__PURE__ */ getDefaultExportFromCjs(downloadExports);
1759
- function commonjsRequire(path) {
1760
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
1761
- }
1762
- var jszip_min = { exports: {} };
1763
- /*!
1764
-
1765
- JSZip v3.10.1 - A JavaScript class for generating and reading zip files
1766
- <http://stuartk.com/jszip>
1767
-
1768
- (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
1769
- Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
1770
-
1771
- JSZip uses the library pako released under the MIT license :
1772
- https://github.com/nodeca/pako/blob/main/LICENSE
1773
- */
1774
- var hasRequiredJszip_min;
1775
- function requireJszip_min() {
1776
- if (hasRequiredJszip_min) return jszip_min.exports;
1777
- hasRequiredJszip_min = 1;
1778
- (function(module, exports) {
1779
- !function(e) {
1780
- module.exports = e();
1781
- }(function() {
1782
- return function s(a, o, h) {
1783
- function u(r, e2) {
1784
- if (!o[r]) {
1785
- if (!a[r]) {
1786
- var t = "function" == typeof commonjsRequire && commonjsRequire;
1787
- if (!e2 && t) return t(r, true);
1788
- if (l) return l(r, true);
1789
- var n = new Error("Cannot find module '" + r + "'");
1790
- throw n.code = "MODULE_NOT_FOUND", n;
1791
- }
1792
- var i = o[r] = { exports: {} };
1793
- a[r][0].call(i.exports, function(e3) {
1794
- var t2 = a[r][1][e3];
1795
- return u(t2 || e3);
1796
- }, i, i.exports, s, a, o, h);
1797
- }
1798
- return o[r].exports;
1799
- }
1800
- for (var l = "function" == typeof commonjsRequire && commonjsRequire, e = 0; e < h.length; e++) u(h[e]);
1801
- return u;
1802
- }({ 1: [function(e, t, r) {
1803
- var d = e("./utils"), c = e("./support"), p = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1804
- r.encode = function(e2) {
1805
- for (var t2, r2, n, i, s, a, o, h = [], u = 0, l = e2.length, f = l, c2 = "string" !== d.getTypeOf(e2); u < e2.length; ) f = l - u, n = c2 ? (t2 = e2[u++], r2 = u < l ? e2[u++] : 0, u < l ? e2[u++] : 0) : (t2 = e2.charCodeAt(u++), r2 = u < l ? e2.charCodeAt(u++) : 0, u < l ? e2.charCodeAt(u++) : 0), i = t2 >> 2, s = (3 & t2) << 4 | r2 >> 4, a = 1 < f ? (15 & r2) << 2 | n >> 6 : 64, o = 2 < f ? 63 & n : 64, h.push(p.charAt(i) + p.charAt(s) + p.charAt(a) + p.charAt(o));
1806
- return h.join("");
1807
- }, r.decode = function(e2) {
1808
- var t2, r2, n, i, s, a, o = 0, h = 0, u = "data:";
1809
- if (e2.substr(0, u.length) === u) throw new Error("Invalid base64 input, it looks like a data url.");
1810
- var l, f = 3 * (e2 = e2.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4;
1811
- if (e2.charAt(e2.length - 1) === p.charAt(64) && f--, e2.charAt(e2.length - 2) === p.charAt(64) && f--, f % 1 != 0) throw new Error("Invalid base64 input, bad content length.");
1812
- for (l = c.uint8array ? new Uint8Array(0 | f) : new Array(0 | f); o < e2.length; ) t2 = p.indexOf(e2.charAt(o++)) << 2 | (i = p.indexOf(e2.charAt(o++))) >> 4, r2 = (15 & i) << 4 | (s = p.indexOf(e2.charAt(o++))) >> 2, n = (3 & s) << 6 | (a = p.indexOf(e2.charAt(o++))), l[h++] = t2, 64 !== s && (l[h++] = r2), 64 !== a && (l[h++] = n);
1813
- return l;
1814
- };
1815
- }, { "./support": 30, "./utils": 32 }], 2: [function(e, t, r) {
1816
- var n = e("./external"), i = e("./stream/DataWorker"), s = e("./stream/Crc32Probe"), a = e("./stream/DataLengthProbe");
1817
- function o(e2, t2, r2, n2, i2) {
1818
- this.compressedSize = e2, this.uncompressedSize = t2, this.crc32 = r2, this.compression = n2, this.compressedContent = i2;
1819
- }
1820
- o.prototype = { getContentWorker: function() {
1821
- var e2 = new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")), t2 = this;
1822
- return e2.on("end", function() {
1823
- if (this.streamInfo.data_length !== t2.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch");
1824
- }), e2;
1825
- }, getCompressedWorker: function() {
1826
- return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
1827
- } }, o.createWorkerFrom = function(e2, t2, r2) {
1828
- return e2.pipe(new s()).pipe(new a("uncompressedSize")).pipe(t2.compressWorker(r2)).pipe(new a("compressedSize")).withStreamInfo("compression", t2);
1829
- }, t.exports = o;
1830
- }, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(e, t, r) {
1831
- var n = e("./stream/GenericWorker");
1832
- r.STORE = { magic: "\0\0", compressWorker: function() {
1833
- return new n("STORE compression");
1834
- }, uncompressWorker: function() {
1835
- return new n("STORE decompression");
1836
- } }, r.DEFLATE = e("./flate");
1837
- }, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(e, t, r) {
1838
- var n = e("./utils");
1839
- var o = function() {
1840
- for (var e2, t2 = [], r2 = 0; r2 < 256; r2++) {
1841
- e2 = r2;
1842
- for (var n2 = 0; n2 < 8; n2++) e2 = 1 & e2 ? 3988292384 ^ e2 >>> 1 : e2 >>> 1;
1843
- t2[r2] = e2;
1844
- }
1845
- return t2;
1846
- }();
1847
- t.exports = function(e2, t2) {
1848
- return void 0 !== e2 && e2.length ? "string" !== n.getTypeOf(e2) ? function(e3, t3, r2, n2) {
1849
- var i = o, s = n2 + r2;
1850
- e3 ^= -1;
1851
- for (var a = n2; a < s; a++) e3 = e3 >>> 8 ^ i[255 & (e3 ^ t3[a])];
1852
- return -1 ^ e3;
1853
- }(0 | t2, e2, e2.length, 0) : function(e3, t3, r2, n2) {
1854
- var i = o, s = n2 + r2;
1855
- e3 ^= -1;
1856
- for (var a = n2; a < s; a++) e3 = e3 >>> 8 ^ i[255 & (e3 ^ t3.charCodeAt(a))];
1857
- return -1 ^ e3;
1858
- }(0 | t2, e2, e2.length, 0) : 0;
1859
- };
1860
- }, { "./utils": 32 }], 5: [function(e, t, r) {
1861
- r.base64 = false, r.binary = false, r.dir = false, r.createFolders = true, r.date = null, r.compression = null, r.compressionOptions = null, r.comment = null, r.unixPermissions = null, r.dosPermissions = null;
1862
- }, {}], 6: [function(e, t, r) {
1863
- var n = null;
1864
- n = "undefined" != typeof Promise ? Promise : e("lie"), t.exports = { Promise: n };
1865
- }, { lie: 37 }], 7: [function(e, t, r) {
1866
- var n = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Uint32Array, i = e("pako"), s = e("./utils"), a = e("./stream/GenericWorker"), o = n ? "uint8array" : "array";
1867
- function h(e2, t2) {
1868
- a.call(this, "FlateWorker/" + e2), this._pako = null, this._pakoAction = e2, this._pakoOptions = t2, this.meta = {};
1869
- }
1870
- r.magic = "\b\0", s.inherits(h, a), h.prototype.processChunk = function(e2) {
1871
- this.meta = e2.meta, null === this._pako && this._createPako(), this._pako.push(s.transformTo(o, e2.data), false);
1872
- }, h.prototype.flush = function() {
1873
- a.prototype.flush.call(this), null === this._pako && this._createPako(), this._pako.push([], true);
1874
- }, h.prototype.cleanUp = function() {
1875
- a.prototype.cleanUp.call(this), this._pako = null;
1876
- }, h.prototype._createPako = function() {
1877
- this._pako = new i[this._pakoAction]({ raw: true, level: this._pakoOptions.level || -1 });
1878
- var t2 = this;
1879
- this._pako.onData = function(e2) {
1880
- t2.push({ data: e2, meta: t2.meta });
1881
- };
1882
- }, r.compressWorker = function(e2) {
1883
- return new h("Deflate", e2);
1884
- }, r.uncompressWorker = function() {
1885
- return new h("Inflate", {});
1886
- };
1887
- }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(e, t, r) {
1888
- function A(e2, t2) {
1889
- var r2, n2 = "";
1890
- for (r2 = 0; r2 < t2; r2++) n2 += String.fromCharCode(255 & e2), e2 >>>= 8;
1891
- return n2;
1892
- }
1893
- function n(e2, t2, r2, n2, i2, s2) {
1894
- var a, o, h = e2.file, u = e2.compression, l = s2 !== O.utf8encode, f = I.transformTo("string", s2(h.name)), c = I.transformTo("string", O.utf8encode(h.name)), d = h.comment, p = I.transformTo("string", s2(d)), m = I.transformTo("string", O.utf8encode(d)), _ = c.length !== h.name.length, g = m.length !== d.length, b = "", v = "", y = "", w = h.dir, k = h.date, x = { crc32: 0, compressedSize: 0, uncompressedSize: 0 };
1895
- t2 && !r2 || (x.crc32 = e2.crc32, x.compressedSize = e2.compressedSize, x.uncompressedSize = e2.uncompressedSize);
1896
- var S = 0;
1897
- t2 && (S |= 8), l || !_ && !g || (S |= 2048);
1898
- var z = 0, C = 0;
1899
- w && (z |= 16), "UNIX" === i2 ? (C = 798, z |= function(e3, t3) {
1900
- var r3 = e3;
1901
- return e3 || (r3 = t3 ? 16893 : 33204), (65535 & r3) << 16;
1902
- }(h.unixPermissions, w)) : (C = 20, z |= function(e3) {
1903
- return 63 & (e3 || 0);
1904
- }(h.dosPermissions)), a = k.getUTCHours(), a <<= 6, a |= k.getUTCMinutes(), a <<= 5, a |= k.getUTCSeconds() / 2, o = k.getUTCFullYear() - 1980, o <<= 4, o |= k.getUTCMonth() + 1, o <<= 5, o |= k.getUTCDate(), _ && (v = A(1, 1) + A(B(f), 4) + c, b += "up" + A(v.length, 2) + v), g && (y = A(1, 1) + A(B(p), 4) + m, b += "uc" + A(y.length, 2) + y);
1905
- var E = "";
1906
- return E += "\n\0", E += A(S, 2), E += u.magic, E += A(a, 2), E += A(o, 2), E += A(x.crc32, 4), E += A(x.compressedSize, 4), E += A(x.uncompressedSize, 4), E += A(f.length, 2), E += A(b.length, 2), { fileRecord: R.LOCAL_FILE_HEADER + E + f + b, dirRecord: R.CENTRAL_FILE_HEADER + A(C, 2) + E + A(p.length, 2) + "\0\0\0\0" + A(z, 4) + A(n2, 4) + f + b + p };
1907
- }
1908
- var I = e("../utils"), i = e("../stream/GenericWorker"), O = e("../utf8"), B = e("../crc32"), R = e("../signature");
1909
- function s(e2, t2, r2, n2) {
1910
- i.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = t2, this.zipPlatform = r2, this.encodeFileName = n2, this.streamFiles = e2, this.accumulate = false, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = [];
1911
- }
1912
- I.inherits(s, i), s.prototype.push = function(e2) {
1913
- var t2 = e2.meta.percent || 0, r2 = this.entriesCount, n2 = this._sources.length;
1914
- this.accumulate ? this.contentBuffer.push(e2) : (this.bytesWritten += e2.data.length, i.prototype.push.call(this, { data: e2.data, meta: { currentFile: this.currentFile, percent: r2 ? (t2 + 100 * (r2 - n2 - 1)) / r2 : 100 } }));
1915
- }, s.prototype.openedSource = function(e2) {
1916
- this.currentSourceOffset = this.bytesWritten, this.currentFile = e2.file.name;
1917
- var t2 = this.streamFiles && !e2.file.dir;
1918
- if (t2) {
1919
- var r2 = n(e2, t2, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
1920
- this.push({ data: r2.fileRecord, meta: { percent: 0 } });
1921
- } else this.accumulate = true;
1922
- }, s.prototype.closedSource = function(e2) {
1923
- this.accumulate = false;
1924
- var t2 = this.streamFiles && !e2.file.dir, r2 = n(e2, t2, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
1925
- if (this.dirRecords.push(r2.dirRecord), t2) this.push({ data: function(e3) {
1926
- return R.DATA_DESCRIPTOR + A(e3.crc32, 4) + A(e3.compressedSize, 4) + A(e3.uncompressedSize, 4);
1927
- }(e2), meta: { percent: 100 } });
1928
- else for (this.push({ data: r2.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift());
1929
- this.currentFile = null;
1930
- }, s.prototype.flush = function() {
1931
- for (var e2 = this.bytesWritten, t2 = 0; t2 < this.dirRecords.length; t2++) this.push({ data: this.dirRecords[t2], meta: { percent: 100 } });
1932
- var r2 = this.bytesWritten - e2, n2 = function(e3, t3, r3, n3, i2) {
1933
- var s2 = I.transformTo("string", i2(n3));
1934
- return R.CENTRAL_DIRECTORY_END + "\0\0\0\0" + A(e3, 2) + A(e3, 2) + A(t3, 4) + A(r3, 4) + A(s2.length, 2) + s2;
1935
- }(this.dirRecords.length, r2, e2, this.zipComment, this.encodeFileName);
1936
- this.push({ data: n2, meta: { percent: 100 } });
1937
- }, s.prototype.prepareNextSource = function() {
1938
- this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume();
1939
- }, s.prototype.registerPrevious = function(e2) {
1940
- this._sources.push(e2);
1941
- var t2 = this;
1942
- return e2.on("data", function(e3) {
1943
- t2.processChunk(e3);
1944
- }), e2.on("end", function() {
1945
- t2.closedSource(t2.previous.streamInfo), t2._sources.length ? t2.prepareNextSource() : t2.end();
1946
- }), e2.on("error", function(e3) {
1947
- t2.error(e3);
1948
- }), this;
1949
- }, s.prototype.resume = function() {
1950
- return !!i.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), true) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), true));
1951
- }, s.prototype.error = function(e2) {
1952
- var t2 = this._sources;
1953
- if (!i.prototype.error.call(this, e2)) return false;
1954
- for (var r2 = 0; r2 < t2.length; r2++) try {
1955
- t2[r2].error(e2);
1956
- } catch (e3) {
1957
- }
1958
- return true;
1959
- }, s.prototype.lock = function() {
1960
- i.prototype.lock.call(this);
1961
- for (var e2 = this._sources, t2 = 0; t2 < e2.length; t2++) e2[t2].lock();
1962
- }, t.exports = s;
1963
- }, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(e, t, r) {
1964
- var u = e("../compressions"), n = e("./ZipFileWorker");
1965
- r.generateWorker = function(e2, a, t2) {
1966
- var o = new n(a.streamFiles, t2, a.platform, a.encodeFileName), h = 0;
1967
- try {
1968
- e2.forEach(function(e3, t3) {
1969
- h++;
1970
- var r2 = function(e4, t4) {
1971
- var r3 = e4 || t4, n3 = u[r3];
1972
- if (!n3) throw new Error(r3 + " is not a valid compression method !");
1973
- return n3;
1974
- }(t3.options.compression, a.compression), n2 = t3.options.compressionOptions || a.compressionOptions || {}, i = t3.dir, s = t3.date;
1975
- t3._compressWorker(r2, n2).withStreamInfo("file", { name: e3, dir: i, date: s, comment: t3.comment || "", unixPermissions: t3.unixPermissions, dosPermissions: t3.dosPermissions }).pipe(o);
1976
- }), o.entriesCount = h;
1977
- } catch (e3) {
1978
- o.error(e3);
1979
- }
1980
- return o;
1981
- };
1982
- }, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(e, t, r) {
1983
- function n() {
1984
- if (!(this instanceof n)) return new n();
1985
- if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
1986
- this.files = /* @__PURE__ */ Object.create(null), this.comment = null, this.root = "", this.clone = function() {
1987
- var e2 = new n();
1988
- for (var t2 in this) "function" != typeof this[t2] && (e2[t2] = this[t2]);
1989
- return e2;
1990
- };
1991
- }
1992
- (n.prototype = e("./object")).loadAsync = e("./load"), n.support = e("./support"), n.defaults = e("./defaults"), n.version = "3.10.1", n.loadAsync = function(e2, t2) {
1993
- return new n().loadAsync(e2, t2);
1994
- }, n.external = e("./external"), t.exports = n;
1995
- }, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(e, t, r) {
1996
- var u = e("./utils"), i = e("./external"), n = e("./utf8"), s = e("./zipEntries"), a = e("./stream/Crc32Probe"), l = e("./nodejsUtils");
1997
- function f(n2) {
1998
- return new i.Promise(function(e2, t2) {
1999
- var r2 = n2.decompressed.getContentWorker().pipe(new a());
2000
- r2.on("error", function(e3) {
2001
- t2(e3);
2002
- }).on("end", function() {
2003
- r2.streamInfo.crc32 !== n2.decompressed.crc32 ? t2(new Error("Corrupted zip : CRC32 mismatch")) : e2();
2004
- }).resume();
2005
- });
2006
- }
2007
- t.exports = function(e2, o) {
2008
- var h = this;
2009
- return o = u.extend(o || {}, { base64: false, checkCRC32: false, optimizedBinaryString: false, createFolders: false, decodeFileName: n.utf8decode }), l.isNode && l.isStream(e2) ? i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : u.prepareContent("the loaded zip file", e2, true, o.optimizedBinaryString, o.base64).then(function(e3) {
2010
- var t2 = new s(o);
2011
- return t2.load(e3), t2;
2012
- }).then(function(e3) {
2013
- var t2 = [i.Promise.resolve(e3)], r2 = e3.files;
2014
- if (o.checkCRC32) for (var n2 = 0; n2 < r2.length; n2++) t2.push(f(r2[n2]));
2015
- return i.Promise.all(t2);
2016
- }).then(function(e3) {
2017
- for (var t2 = e3.shift(), r2 = t2.files, n2 = 0; n2 < r2.length; n2++) {
2018
- var i2 = r2[n2], s2 = i2.fileNameStr, a2 = u.resolve(i2.fileNameStr);
2019
- h.file(a2, i2.decompressed, { binary: true, optimizedBinaryString: true, date: i2.date, dir: i2.dir, comment: i2.fileCommentStr.length ? i2.fileCommentStr : null, unixPermissions: i2.unixPermissions, dosPermissions: i2.dosPermissions, createFolders: o.createFolders }), i2.dir || (h.file(a2).unsafeOriginalName = s2);
2020
- }
2021
- return t2.zipComment.length && (h.comment = t2.zipComment), h;
2022
- });
2023
- };
2024
- }, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(e, t, r) {
2025
- var n = e("../utils"), i = e("../stream/GenericWorker");
2026
- function s(e2, t2) {
2027
- i.call(this, "Nodejs stream input adapter for " + e2), this._upstreamEnded = false, this._bindStream(t2);
2028
- }
2029
- n.inherits(s, i), s.prototype._bindStream = function(e2) {
2030
- var t2 = this;
2031
- (this._stream = e2).pause(), e2.on("data", function(e3) {
2032
- t2.push({ data: e3, meta: { percent: 0 } });
2033
- }).on("error", function(e3) {
2034
- t2.isPaused ? this.generatedError = e3 : t2.error(e3);
2035
- }).on("end", function() {
2036
- t2.isPaused ? t2._upstreamEnded = true : t2.end();
2037
- });
2038
- }, s.prototype.pause = function() {
2039
- return !!i.prototype.pause.call(this) && (this._stream.pause(), true);
2040
- }, s.prototype.resume = function() {
2041
- return !!i.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), true);
2042
- }, t.exports = s;
2043
- }, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(e, t, r) {
2044
- var i = e("readable-stream").Readable;
2045
- function n(e2, t2, r2) {
2046
- i.call(this, t2), this._helper = e2;
2047
- var n2 = this;
2048
- e2.on("data", function(e3, t3) {
2049
- n2.push(e3) || n2._helper.pause(), r2 && r2(t3);
2050
- }).on("error", function(e3) {
2051
- n2.emit("error", e3);
2052
- }).on("end", function() {
2053
- n2.push(null);
2054
- });
2055
- }
2056
- e("../utils").inherits(n, i), n.prototype._read = function() {
2057
- this._helper.resume();
2058
- }, t.exports = n;
2059
- }, { "../utils": 32, "readable-stream": 16 }], 14: [function(e, t, r) {
2060
- t.exports = { isNode: "undefined" != typeof Buffer, newBufferFrom: function(e2, t2) {
2061
- if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(e2, t2);
2062
- if ("number" == typeof e2) throw new Error('The "data" argument must not be a number');
2063
- return new Buffer(e2, t2);
2064
- }, allocBuffer: function(e2) {
2065
- if (Buffer.alloc) return Buffer.alloc(e2);
2066
- var t2 = new Buffer(e2);
2067
- return t2.fill(0), t2;
2068
- }, isBuffer: function(e2) {
2069
- return Buffer.isBuffer(e2);
2070
- }, isStream: function(e2) {
2071
- return e2 && "function" == typeof e2.on && "function" == typeof e2.pause && "function" == typeof e2.resume;
2072
- } };
2073
- }, {}], 15: [function(e, t, r) {
2074
- function s(e2, t2, r2) {
2075
- var n2, i2 = u.getTypeOf(t2), s2 = u.extend(r2 || {}, f);
2076
- s2.date = s2.date || /* @__PURE__ */ new Date(), null !== s2.compression && (s2.compression = s2.compression.toUpperCase()), "string" == typeof s2.unixPermissions && (s2.unixPermissions = parseInt(s2.unixPermissions, 8)), s2.unixPermissions && 16384 & s2.unixPermissions && (s2.dir = true), s2.dosPermissions && 16 & s2.dosPermissions && (s2.dir = true), s2.dir && (e2 = g(e2)), s2.createFolders && (n2 = _(e2)) && b.call(this, n2, true);
2077
- var a2 = "string" === i2 && false === s2.binary && false === s2.base64;
2078
- r2 && void 0 !== r2.binary || (s2.binary = !a2), (t2 instanceof c && 0 === t2.uncompressedSize || s2.dir || !t2 || 0 === t2.length) && (s2.base64 = false, s2.binary = true, t2 = "", s2.compression = "STORE", i2 = "string");
2079
- var o2 = null;
2080
- o2 = t2 instanceof c || t2 instanceof l ? t2 : p.isNode && p.isStream(t2) ? new m(e2, t2) : u.prepareContent(e2, t2, s2.binary, s2.optimizedBinaryString, s2.base64);
2081
- var h2 = new d(e2, o2, s2);
2082
- this.files[e2] = h2;
2083
- }
2084
- var i = e("./utf8"), u = e("./utils"), l = e("./stream/GenericWorker"), a = e("./stream/StreamHelper"), f = e("./defaults"), c = e("./compressedObject"), d = e("./zipObject"), o = e("./generate"), p = e("./nodejsUtils"), m = e("./nodejs/NodejsStreamInputAdapter"), _ = function(e2) {
2085
- "/" === e2.slice(-1) && (e2 = e2.substring(0, e2.length - 1));
2086
- var t2 = e2.lastIndexOf("/");
2087
- return 0 < t2 ? e2.substring(0, t2) : "";
2088
- }, g = function(e2) {
2089
- return "/" !== e2.slice(-1) && (e2 += "/"), e2;
2090
- }, b = function(e2, t2) {
2091
- return t2 = void 0 !== t2 ? t2 : f.createFolders, e2 = g(e2), this.files[e2] || s.call(this, e2, null, { dir: true, createFolders: t2 }), this.files[e2];
2092
- };
2093
- function h(e2) {
2094
- return "[object RegExp]" === Object.prototype.toString.call(e2);
2095
- }
2096
- var n = { load: function() {
2097
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
2098
- }, forEach: function(e2) {
2099
- var t2, r2, n2;
2100
- for (t2 in this.files) n2 = this.files[t2], (r2 = t2.slice(this.root.length, t2.length)) && t2.slice(0, this.root.length) === this.root && e2(r2, n2);
2101
- }, filter: function(r2) {
2102
- var n2 = [];
2103
- return this.forEach(function(e2, t2) {
2104
- r2(e2, t2) && n2.push(t2);
2105
- }), n2;
2106
- }, file: function(e2, t2, r2) {
2107
- if (1 !== arguments.length) return e2 = this.root + e2, s.call(this, e2, t2, r2), this;
2108
- if (h(e2)) {
2109
- var n2 = e2;
2110
- return this.filter(function(e3, t3) {
2111
- return !t3.dir && n2.test(e3);
2112
- });
2113
- }
2114
- var i2 = this.files[this.root + e2];
2115
- return i2 && !i2.dir ? i2 : null;
2116
- }, folder: function(r2) {
2117
- if (!r2) return this;
2118
- if (h(r2)) return this.filter(function(e3, t3) {
2119
- return t3.dir && r2.test(e3);
2120
- });
2121
- var e2 = this.root + r2, t2 = b.call(this, e2), n2 = this.clone();
2122
- return n2.root = t2.name, n2;
2123
- }, remove: function(r2) {
2124
- r2 = this.root + r2;
2125
- var e2 = this.files[r2];
2126
- if (e2 || ("/" !== r2.slice(-1) && (r2 += "/"), e2 = this.files[r2]), e2 && !e2.dir) delete this.files[r2];
2127
- else for (var t2 = this.filter(function(e3, t3) {
2128
- return t3.name.slice(0, r2.length) === r2;
2129
- }), n2 = 0; n2 < t2.length; n2++) delete this.files[t2[n2].name];
2130
- return this;
2131
- }, generate: function() {
2132
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
2133
- }, generateInternalStream: function(e2) {
2134
- var t2, r2 = {};
2135
- try {
2136
- if ((r2 = u.extend(e2 || {}, { streamFiles: false, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: i.utf8encode })).type = r2.type.toLowerCase(), r2.compression = r2.compression.toUpperCase(), "binarystring" === r2.type && (r2.type = "string"), !r2.type) throw new Error("No output type specified.");
2137
- u.checkSupport(r2.type), "darwin" !== r2.platform && "freebsd" !== r2.platform && "linux" !== r2.platform && "sunos" !== r2.platform || (r2.platform = "UNIX"), "win32" === r2.platform && (r2.platform = "DOS");
2138
- var n2 = r2.comment || this.comment || "";
2139
- t2 = o.generateWorker(this, r2, n2);
2140
- } catch (e3) {
2141
- (t2 = new l("error")).error(e3);
2142
- }
2143
- return new a(t2, r2.type || "string", r2.mimeType);
2144
- }, generateAsync: function(e2, t2) {
2145
- return this.generateInternalStream(e2).accumulate(t2);
2146
- }, generateNodeStream: function(e2, t2) {
2147
- return (e2 = e2 || {}).type || (e2.type = "nodebuffer"), this.generateInternalStream(e2).toNodejsStream(t2);
2148
- } };
2149
- t.exports = n;
2150
- }, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(e, t, r) {
2151
- t.exports = e("stream");
2152
- }, { stream: void 0 }], 17: [function(e, t, r) {
2153
- var n = e("./DataReader");
2154
- function i(e2) {
2155
- n.call(this, e2);
2156
- for (var t2 = 0; t2 < this.data.length; t2++) e2[t2] = 255 & e2[t2];
2157
- }
2158
- e("../utils").inherits(i, n), i.prototype.byteAt = function(e2) {
2159
- return this.data[this.zero + e2];
2160
- }, i.prototype.lastIndexOfSignature = function(e2) {
2161
- for (var t2 = e2.charCodeAt(0), r2 = e2.charCodeAt(1), n2 = e2.charCodeAt(2), i2 = e2.charCodeAt(3), s = this.length - 4; 0 <= s; --s) if (this.data[s] === t2 && this.data[s + 1] === r2 && this.data[s + 2] === n2 && this.data[s + 3] === i2) return s - this.zero;
2162
- return -1;
2163
- }, i.prototype.readAndCheckSignature = function(e2) {
2164
- var t2 = e2.charCodeAt(0), r2 = e2.charCodeAt(1), n2 = e2.charCodeAt(2), i2 = e2.charCodeAt(3), s = this.readData(4);
2165
- return t2 === s[0] && r2 === s[1] && n2 === s[2] && i2 === s[3];
2166
- }, i.prototype.readData = function(e2) {
2167
- if (this.checkOffset(e2), 0 === e2) return [];
2168
- var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2);
2169
- return this.index += e2, t2;
2170
- }, t.exports = i;
2171
- }, { "../utils": 32, "./DataReader": 18 }], 18: [function(e, t, r) {
2172
- var n = e("../utils");
2173
- function i(e2) {
2174
- this.data = e2, this.length = e2.length, this.index = 0, this.zero = 0;
2175
- }
2176
- i.prototype = { checkOffset: function(e2) {
2177
- this.checkIndex(this.index + e2);
2178
- }, checkIndex: function(e2) {
2179
- if (this.length < this.zero + e2 || e2 < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + e2 + "). Corrupted zip ?");
2180
- }, setIndex: function(e2) {
2181
- this.checkIndex(e2), this.index = e2;
2182
- }, skip: function(e2) {
2183
- this.setIndex(this.index + e2);
2184
- }, byteAt: function() {
2185
- }, readInt: function(e2) {
2186
- var t2, r2 = 0;
2187
- for (this.checkOffset(e2), t2 = this.index + e2 - 1; t2 >= this.index; t2--) r2 = (r2 << 8) + this.byteAt(t2);
2188
- return this.index += e2, r2;
2189
- }, readString: function(e2) {
2190
- return n.transformTo("string", this.readData(e2));
2191
- }, readData: function() {
2192
- }, lastIndexOfSignature: function() {
2193
- }, readAndCheckSignature: function() {
2194
- }, readDate: function() {
2195
- var e2 = this.readInt(4);
2196
- return new Date(Date.UTC(1980 + (e2 >> 25 & 127), (e2 >> 21 & 15) - 1, e2 >> 16 & 31, e2 >> 11 & 31, e2 >> 5 & 63, (31 & e2) << 1));
2197
- } }, t.exports = i;
2198
- }, { "../utils": 32 }], 19: [function(e, t, r) {
2199
- var n = e("./Uint8ArrayReader");
2200
- function i(e2) {
2201
- n.call(this, e2);
2202
- }
2203
- e("../utils").inherits(i, n), i.prototype.readData = function(e2) {
2204
- this.checkOffset(e2);
2205
- var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2);
2206
- return this.index += e2, t2;
2207
- }, t.exports = i;
2208
- }, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(e, t, r) {
2209
- var n = e("./DataReader");
2210
- function i(e2) {
2211
- n.call(this, e2);
2212
- }
2213
- e("../utils").inherits(i, n), i.prototype.byteAt = function(e2) {
2214
- return this.data.charCodeAt(this.zero + e2);
2215
- }, i.prototype.lastIndexOfSignature = function(e2) {
2216
- return this.data.lastIndexOf(e2) - this.zero;
2217
- }, i.prototype.readAndCheckSignature = function(e2) {
2218
- return e2 === this.readData(4);
2219
- }, i.prototype.readData = function(e2) {
2220
- this.checkOffset(e2);
2221
- var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2);
2222
- return this.index += e2, t2;
2223
- }, t.exports = i;
2224
- }, { "../utils": 32, "./DataReader": 18 }], 21: [function(e, t, r) {
2225
- var n = e("./ArrayReader");
2226
- function i(e2) {
2227
- n.call(this, e2);
2228
- }
2229
- e("../utils").inherits(i, n), i.prototype.readData = function(e2) {
2230
- if (this.checkOffset(e2), 0 === e2) return new Uint8Array(0);
2231
- var t2 = this.data.subarray(this.zero + this.index, this.zero + this.index + e2);
2232
- return this.index += e2, t2;
2233
- }, t.exports = i;
2234
- }, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(e, t, r) {
2235
- var n = e("../utils"), i = e("../support"), s = e("./ArrayReader"), a = e("./StringReader"), o = e("./NodeBufferReader"), h = e("./Uint8ArrayReader");
2236
- t.exports = function(e2) {
2237
- var t2 = n.getTypeOf(e2);
2238
- return n.checkSupport(t2), "string" !== t2 || i.uint8array ? "nodebuffer" === t2 ? new o(e2) : i.uint8array ? new h(n.transformTo("uint8array", e2)) : new s(n.transformTo("array", e2)) : new a(e2);
2239
- };
2240
- }, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(e, t, r) {
2241
- r.LOCAL_FILE_HEADER = "PK", r.CENTRAL_FILE_HEADER = "PK", r.CENTRAL_DIRECTORY_END = "PK", r.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", r.ZIP64_CENTRAL_DIRECTORY_END = "PK", r.DATA_DESCRIPTOR = "PK\x07\b";
2242
- }, {}], 24: [function(e, t, r) {
2243
- var n = e("./GenericWorker"), i = e("../utils");
2244
- function s(e2) {
2245
- n.call(this, "ConvertWorker to " + e2), this.destType = e2;
2246
- }
2247
- i.inherits(s, n), s.prototype.processChunk = function(e2) {
2248
- this.push({ data: i.transformTo(this.destType, e2.data), meta: e2.meta });
2249
- }, t.exports = s;
2250
- }, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(e, t, r) {
2251
- var n = e("./GenericWorker"), i = e("../crc32");
2252
- function s() {
2253
- n.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0);
2254
- }
2255
- e("../utils").inherits(s, n), s.prototype.processChunk = function(e2) {
2256
- this.streamInfo.crc32 = i(e2.data, this.streamInfo.crc32 || 0), this.push(e2);
2257
- }, t.exports = s;
2258
- }, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(e, t, r) {
2259
- var n = e("../utils"), i = e("./GenericWorker");
2260
- function s(e2) {
2261
- i.call(this, "DataLengthProbe for " + e2), this.propName = e2, this.withStreamInfo(e2, 0);
2262
- }
2263
- n.inherits(s, i), s.prototype.processChunk = function(e2) {
2264
- if (e2) {
2265
- var t2 = this.streamInfo[this.propName] || 0;
2266
- this.streamInfo[this.propName] = t2 + e2.data.length;
2267
- }
2268
- i.prototype.processChunk.call(this, e2);
2269
- }, t.exports = s;
2270
- }, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(e, t, r) {
2271
- var n = e("../utils"), i = e("./GenericWorker");
2272
- function s(e2) {
2273
- i.call(this, "DataWorker");
2274
- var t2 = this;
2275
- this.dataIsReady = false, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = false, e2.then(function(e3) {
2276
- t2.dataIsReady = true, t2.data = e3, t2.max = e3 && e3.length || 0, t2.type = n.getTypeOf(e3), t2.isPaused || t2._tickAndRepeat();
2277
- }, function(e3) {
2278
- t2.error(e3);
2279
- });
2280
- }
2281
- n.inherits(s, i), s.prototype.cleanUp = function() {
2282
- i.prototype.cleanUp.call(this), this.data = null;
2283
- }, s.prototype.resume = function() {
2284
- return !!i.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = true, n.delay(this._tickAndRepeat, [], this)), true);
2285
- }, s.prototype._tickAndRepeat = function() {
2286
- this._tickScheduled = false, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (n.delay(this._tickAndRepeat, [], this), this._tickScheduled = true));
2287
- }, s.prototype._tick = function() {
2288
- if (this.isPaused || this.isFinished) return false;
2289
- var e2 = null, t2 = Math.min(this.max, this.index + 16384);
2290
- if (this.index >= this.max) return this.end();
2291
- switch (this.type) {
2292
- case "string":
2293
- e2 = this.data.substring(this.index, t2);
2294
- break;
2295
- case "uint8array":
2296
- e2 = this.data.subarray(this.index, t2);
2297
- break;
2298
- case "array":
2299
- case "nodebuffer":
2300
- e2 = this.data.slice(this.index, t2);
2301
- }
2302
- return this.index = t2, this.push({ data: e2, meta: { percent: this.max ? this.index / this.max * 100 : 0 } });
2303
- }, t.exports = s;
2304
- }, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(e, t, r) {
2305
- function n(e2) {
2306
- this.name = e2 || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = true, this.isFinished = false, this.isLocked = false, this._listeners = { data: [], end: [], error: [] }, this.previous = null;
2307
- }
2308
- n.prototype = { push: function(e2) {
2309
- this.emit("data", e2);
2310
- }, end: function() {
2311
- if (this.isFinished) return false;
2312
- this.flush();
2313
- try {
2314
- this.emit("end"), this.cleanUp(), this.isFinished = true;
2315
- } catch (e2) {
2316
- this.emit("error", e2);
2317
- }
2318
- return true;
2319
- }, error: function(e2) {
2320
- return !this.isFinished && (this.isPaused ? this.generatedError = e2 : (this.isFinished = true, this.emit("error", e2), this.previous && this.previous.error(e2), this.cleanUp()), true);
2321
- }, on: function(e2, t2) {
2322
- return this._listeners[e2].push(t2), this;
2323
- }, cleanUp: function() {
2324
- this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = [];
2325
- }, emit: function(e2, t2) {
2326
- if (this._listeners[e2]) for (var r2 = 0; r2 < this._listeners[e2].length; r2++) this._listeners[e2][r2].call(this, t2);
2327
- }, pipe: function(e2) {
2328
- return e2.registerPrevious(this);
2329
- }, registerPrevious: function(e2) {
2330
- if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
2331
- this.streamInfo = e2.streamInfo, this.mergeStreamInfo(), this.previous = e2;
2332
- var t2 = this;
2333
- return e2.on("data", function(e3) {
2334
- t2.processChunk(e3);
2335
- }), e2.on("end", function() {
2336
- t2.end();
2337
- }), e2.on("error", function(e3) {
2338
- t2.error(e3);
2339
- }), this;
2340
- }, pause: function() {
2341
- return !this.isPaused && !this.isFinished && (this.isPaused = true, this.previous && this.previous.pause(), true);
2342
- }, resume: function() {
2343
- if (!this.isPaused || this.isFinished) return false;
2344
- var e2 = this.isPaused = false;
2345
- return this.generatedError && (this.error(this.generatedError), e2 = true), this.previous && this.previous.resume(), !e2;
2346
- }, flush: function() {
2347
- }, processChunk: function(e2) {
2348
- this.push(e2);
2349
- }, withStreamInfo: function(e2, t2) {
2350
- return this.extraStreamInfo[e2] = t2, this.mergeStreamInfo(), this;
2351
- }, mergeStreamInfo: function() {
2352
- for (var e2 in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, e2) && (this.streamInfo[e2] = this.extraStreamInfo[e2]);
2353
- }, lock: function() {
2354
- if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
2355
- this.isLocked = true, this.previous && this.previous.lock();
2356
- }, toString: function() {
2357
- var e2 = "Worker " + this.name;
2358
- return this.previous ? this.previous + " -> " + e2 : e2;
2359
- } }, t.exports = n;
2360
- }, {}], 29: [function(e, t, r) {
2361
- var h = e("../utils"), i = e("./ConvertWorker"), s = e("./GenericWorker"), u = e("../base64"), n = e("../support"), a = e("../external"), o = null;
2362
- if (n.nodestream) try {
2363
- o = e("../nodejs/NodejsStreamOutputAdapter");
2364
- } catch (e2) {
2365
- }
2366
- function l(e2, o2) {
2367
- return new a.Promise(function(t2, r2) {
2368
- var n2 = [], i2 = e2._internalType, s2 = e2._outputType, a2 = e2._mimeType;
2369
- e2.on("data", function(e3, t3) {
2370
- n2.push(e3), o2 && o2(t3);
2371
- }).on("error", function(e3) {
2372
- n2 = [], r2(e3);
2373
- }).on("end", function() {
2374
- try {
2375
- var e3 = function(e4, t3, r3) {
2376
- switch (e4) {
2377
- case "blob":
2378
- return h.newBlob(h.transformTo("arraybuffer", t3), r3);
2379
- case "base64":
2380
- return u.encode(t3);
2381
- default:
2382
- return h.transformTo(e4, t3);
2383
- }
2384
- }(s2, function(e4, t3) {
2385
- var r3, n3 = 0, i3 = null, s3 = 0;
2386
- for (r3 = 0; r3 < t3.length; r3++) s3 += t3[r3].length;
2387
- switch (e4) {
2388
- case "string":
2389
- return t3.join("");
2390
- case "array":
2391
- return Array.prototype.concat.apply([], t3);
2392
- case "uint8array":
2393
- for (i3 = new Uint8Array(s3), r3 = 0; r3 < t3.length; r3++) i3.set(t3[r3], n3), n3 += t3[r3].length;
2394
- return i3;
2395
- case "nodebuffer":
2396
- return Buffer.concat(t3);
2397
- default:
2398
- throw new Error("concat : unsupported type '" + e4 + "'");
2399
- }
2400
- }(i2, n2), a2);
2401
- t2(e3);
2402
- } catch (e4) {
2403
- r2(e4);
2404
- }
2405
- n2 = [];
2406
- }).resume();
2407
- });
2408
- }
2409
- function f(e2, t2, r2) {
2410
- var n2 = t2;
2411
- switch (t2) {
2412
- case "blob":
2413
- case "arraybuffer":
2414
- n2 = "uint8array";
2415
- break;
2416
- case "base64":
2417
- n2 = "string";
2418
- }
2419
- try {
2420
- this._internalType = n2, this._outputType = t2, this._mimeType = r2, h.checkSupport(n2), this._worker = e2.pipe(new i(n2)), e2.lock();
2421
- } catch (e3) {
2422
- this._worker = new s("error"), this._worker.error(e3);
2423
- }
2424
- }
2425
- f.prototype = { accumulate: function(e2) {
2426
- return l(this, e2);
2427
- }, on: function(e2, t2) {
2428
- var r2 = this;
2429
- return "data" === e2 ? this._worker.on(e2, function(e3) {
2430
- t2.call(r2, e3.data, e3.meta);
2431
- }) : this._worker.on(e2, function() {
2432
- h.delay(t2, arguments, r2);
2433
- }), this;
2434
- }, resume: function() {
2435
- return h.delay(this._worker.resume, [], this._worker), this;
2436
- }, pause: function() {
2437
- return this._worker.pause(), this;
2438
- }, toNodejsStream: function(e2) {
2439
- if (h.checkSupport("nodestream"), "nodebuffer" !== this._outputType) throw new Error(this._outputType + " is not supported by this method");
2440
- return new o(this, { objectMode: "nodebuffer" !== this._outputType }, e2);
2441
- } }, t.exports = f;
2442
- }, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(e, t, r) {
2443
- if (r.base64 = true, r.array = true, r.string = true, r.arraybuffer = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array, r.nodebuffer = "undefined" != typeof Buffer, r.uint8array = "undefined" != typeof Uint8Array, "undefined" == typeof ArrayBuffer) r.blob = false;
2444
- else {
2445
- var n = new ArrayBuffer(0);
2446
- try {
2447
- r.blob = 0 === new Blob([n], { type: "application/zip" }).size;
2448
- } catch (e2) {
2449
- try {
2450
- var i = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
2451
- i.append(n), r.blob = 0 === i.getBlob("application/zip").size;
2452
- } catch (e3) {
2453
- r.blob = false;
2454
- }
2455
- }
2456
- }
2457
- try {
2458
- r.nodestream = !!e("readable-stream").Readable;
2459
- } catch (e2) {
2460
- r.nodestream = false;
2461
- }
2462
- }, { "readable-stream": 16 }], 31: [function(e, t, s) {
2463
- for (var o = e("./utils"), h = e("./support"), r = e("./nodejsUtils"), n = e("./stream/GenericWorker"), u = new Array(256), i = 0; i < 256; i++) u[i] = 252 <= i ? 6 : 248 <= i ? 5 : 240 <= i ? 4 : 224 <= i ? 3 : 192 <= i ? 2 : 1;
2464
- u[254] = u[254] = 1;
2465
- function a() {
2466
- n.call(this, "utf-8 decode"), this.leftOver = null;
2467
- }
2468
- function l() {
2469
- n.call(this, "utf-8 encode");
2470
- }
2471
- s.utf8encode = function(e2) {
2472
- return h.nodebuffer ? r.newBufferFrom(e2, "utf-8") : function(e3) {
2473
- var t2, r2, n2, i2, s2, a2 = e3.length, o2 = 0;
2474
- for (i2 = 0; i2 < a2; i2++) 55296 == (64512 & (r2 = e3.charCodeAt(i2))) && i2 + 1 < a2 && 56320 == (64512 & (n2 = e3.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), o2 += r2 < 128 ? 1 : r2 < 2048 ? 2 : r2 < 65536 ? 3 : 4;
2475
- for (t2 = h.uint8array ? new Uint8Array(o2) : new Array(o2), i2 = s2 = 0; s2 < o2; i2++) 55296 == (64512 & (r2 = e3.charCodeAt(i2))) && i2 + 1 < a2 && 56320 == (64512 & (n2 = e3.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), r2 < 128 ? t2[s2++] = r2 : (r2 < 2048 ? t2[s2++] = 192 | r2 >>> 6 : (r2 < 65536 ? t2[s2++] = 224 | r2 >>> 12 : (t2[s2++] = 240 | r2 >>> 18, t2[s2++] = 128 | r2 >>> 12 & 63), t2[s2++] = 128 | r2 >>> 6 & 63), t2[s2++] = 128 | 63 & r2);
2476
- return t2;
2477
- }(e2);
2478
- }, s.utf8decode = function(e2) {
2479
- return h.nodebuffer ? o.transformTo("nodebuffer", e2).toString("utf-8") : function(e3) {
2480
- var t2, r2, n2, i2, s2 = e3.length, a2 = new Array(2 * s2);
2481
- for (t2 = r2 = 0; t2 < s2; ) if ((n2 = e3[t2++]) < 128) a2[r2++] = n2;
2482
- else if (4 < (i2 = u[n2])) a2[r2++] = 65533, t2 += i2 - 1;
2483
- else {
2484
- for (n2 &= 2 === i2 ? 31 : 3 === i2 ? 15 : 7; 1 < i2 && t2 < s2; ) n2 = n2 << 6 | 63 & e3[t2++], i2--;
2485
- 1 < i2 ? a2[r2++] = 65533 : n2 < 65536 ? a2[r2++] = n2 : (n2 -= 65536, a2[r2++] = 55296 | n2 >> 10 & 1023, a2[r2++] = 56320 | 1023 & n2);
2486
- }
2487
- return a2.length !== r2 && (a2.subarray ? a2 = a2.subarray(0, r2) : a2.length = r2), o.applyFromCharCode(a2);
2488
- }(e2 = o.transformTo(h.uint8array ? "uint8array" : "array", e2));
2489
- }, o.inherits(a, n), a.prototype.processChunk = function(e2) {
2490
- var t2 = o.transformTo(h.uint8array ? "uint8array" : "array", e2.data);
2491
- if (this.leftOver && this.leftOver.length) {
2492
- if (h.uint8array) {
2493
- var r2 = t2;
2494
- (t2 = new Uint8Array(r2.length + this.leftOver.length)).set(this.leftOver, 0), t2.set(r2, this.leftOver.length);
2495
- } else t2 = this.leftOver.concat(t2);
2496
- this.leftOver = null;
2497
- }
2498
- var n2 = function(e3, t3) {
2499
- var r3;
2500
- for ((t3 = t3 || e3.length) > e3.length && (t3 = e3.length), r3 = t3 - 1; 0 <= r3 && 128 == (192 & e3[r3]); ) r3--;
2501
- return r3 < 0 ? t3 : 0 === r3 ? t3 : r3 + u[e3[r3]] > t3 ? r3 : t3;
2502
- }(t2), i2 = t2;
2503
- n2 !== t2.length && (h.uint8array ? (i2 = t2.subarray(0, n2), this.leftOver = t2.subarray(n2, t2.length)) : (i2 = t2.slice(0, n2), this.leftOver = t2.slice(n2, t2.length))), this.push({ data: s.utf8decode(i2), meta: e2.meta });
2504
- }, a.prototype.flush = function() {
2505
- this.leftOver && this.leftOver.length && (this.push({ data: s.utf8decode(this.leftOver), meta: {} }), this.leftOver = null);
2506
- }, s.Utf8DecodeWorker = a, o.inherits(l, n), l.prototype.processChunk = function(e2) {
2507
- this.push({ data: s.utf8encode(e2.data), meta: e2.meta });
2508
- }, s.Utf8EncodeWorker = l;
2509
- }, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(e, t, a) {
2510
- var o = e("./support"), h = e("./base64"), r = e("./nodejsUtils"), u = e("./external");
2511
- function n(e2) {
2512
- return e2;
2513
- }
2514
- function l(e2, t2) {
2515
- for (var r2 = 0; r2 < e2.length; ++r2) t2[r2] = 255 & e2.charCodeAt(r2);
2516
- return t2;
2517
- }
2518
- e("setimmediate"), a.newBlob = function(t2, r2) {
2519
- a.checkSupport("blob");
2520
- try {
2521
- return new Blob([t2], { type: r2 });
2522
- } catch (e2) {
2523
- try {
2524
- var n2 = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
2525
- return n2.append(t2), n2.getBlob(r2);
2526
- } catch (e3) {
2527
- throw new Error("Bug : can't construct the Blob.");
2528
- }
2529
- }
2530
- };
2531
- var i = { stringifyByChunk: function(e2, t2, r2) {
2532
- var n2 = [], i2 = 0, s2 = e2.length;
2533
- if (s2 <= r2) return String.fromCharCode.apply(null, e2);
2534
- for (; i2 < s2; ) "array" === t2 || "nodebuffer" === t2 ? n2.push(String.fromCharCode.apply(null, e2.slice(i2, Math.min(i2 + r2, s2)))) : n2.push(String.fromCharCode.apply(null, e2.subarray(i2, Math.min(i2 + r2, s2)))), i2 += r2;
2535
- return n2.join("");
2536
- }, stringifyByChar: function(e2) {
2537
- for (var t2 = "", r2 = 0; r2 < e2.length; r2++) t2 += String.fromCharCode(e2[r2]);
2538
- return t2;
2539
- }, applyCanBeUsed: { uint8array: function() {
2540
- try {
2541
- return o.uint8array && 1 === String.fromCharCode.apply(null, new Uint8Array(1)).length;
2542
- } catch (e2) {
2543
- return false;
2544
- }
2545
- }(), nodebuffer: function() {
2546
- try {
2547
- return o.nodebuffer && 1 === String.fromCharCode.apply(null, r.allocBuffer(1)).length;
2548
- } catch (e2) {
2549
- return false;
2550
- }
2551
- }() } };
2552
- function s(e2) {
2553
- var t2 = 65536, r2 = a.getTypeOf(e2), n2 = true;
2554
- if ("uint8array" === r2 ? n2 = i.applyCanBeUsed.uint8array : "nodebuffer" === r2 && (n2 = i.applyCanBeUsed.nodebuffer), n2) for (; 1 < t2; ) try {
2555
- return i.stringifyByChunk(e2, r2, t2);
2556
- } catch (e3) {
2557
- t2 = Math.floor(t2 / 2);
2558
- }
2559
- return i.stringifyByChar(e2);
2560
- }
2561
- function f(e2, t2) {
2562
- for (var r2 = 0; r2 < e2.length; r2++) t2[r2] = e2[r2];
2563
- return t2;
2564
- }
2565
- a.applyFromCharCode = s;
2566
- var c = {};
2567
- c.string = { string: n, array: function(e2) {
2568
- return l(e2, new Array(e2.length));
2569
- }, arraybuffer: function(e2) {
2570
- return c.string.uint8array(e2).buffer;
2571
- }, uint8array: function(e2) {
2572
- return l(e2, new Uint8Array(e2.length));
2573
- }, nodebuffer: function(e2) {
2574
- return l(e2, r.allocBuffer(e2.length));
2575
- } }, c.array = { string: s, array: n, arraybuffer: function(e2) {
2576
- return new Uint8Array(e2).buffer;
2577
- }, uint8array: function(e2) {
2578
- return new Uint8Array(e2);
2579
- }, nodebuffer: function(e2) {
2580
- return r.newBufferFrom(e2);
2581
- } }, c.arraybuffer = { string: function(e2) {
2582
- return s(new Uint8Array(e2));
2583
- }, array: function(e2) {
2584
- return f(new Uint8Array(e2), new Array(e2.byteLength));
2585
- }, arraybuffer: n, uint8array: function(e2) {
2586
- return new Uint8Array(e2);
2587
- }, nodebuffer: function(e2) {
2588
- return r.newBufferFrom(new Uint8Array(e2));
2589
- } }, c.uint8array = { string: s, array: function(e2) {
2590
- return f(e2, new Array(e2.length));
2591
- }, arraybuffer: function(e2) {
2592
- return e2.buffer;
2593
- }, uint8array: n, nodebuffer: function(e2) {
2594
- return r.newBufferFrom(e2);
2595
- } }, c.nodebuffer = { string: s, array: function(e2) {
2596
- return f(e2, new Array(e2.length));
2597
- }, arraybuffer: function(e2) {
2598
- return c.nodebuffer.uint8array(e2).buffer;
2599
- }, uint8array: function(e2) {
2600
- return f(e2, new Uint8Array(e2.length));
2601
- }, nodebuffer: n }, a.transformTo = function(e2, t2) {
2602
- if (t2 = t2 || "", !e2) return t2;
2603
- a.checkSupport(e2);
2604
- var r2 = a.getTypeOf(t2);
2605
- return c[r2][e2](t2);
2606
- }, a.resolve = function(e2) {
2607
- for (var t2 = e2.split("/"), r2 = [], n2 = 0; n2 < t2.length; n2++) {
2608
- var i2 = t2[n2];
2609
- "." === i2 || "" === i2 && 0 !== n2 && n2 !== t2.length - 1 || (".." === i2 ? r2.pop() : r2.push(i2));
2610
- }
2611
- return r2.join("/");
2612
- }, a.getTypeOf = function(e2) {
2613
- return "string" == typeof e2 ? "string" : "[object Array]" === Object.prototype.toString.call(e2) ? "array" : o.nodebuffer && r.isBuffer(e2) ? "nodebuffer" : o.uint8array && e2 instanceof Uint8Array ? "uint8array" : o.arraybuffer && e2 instanceof ArrayBuffer ? "arraybuffer" : void 0;
2614
- }, a.checkSupport = function(e2) {
2615
- if (!o[e2.toLowerCase()]) throw new Error(e2 + " is not supported by this platform");
2616
- }, a.MAX_VALUE_16BITS = 65535, a.MAX_VALUE_32BITS = -1, a.pretty = function(e2) {
2617
- var t2, r2, n2 = "";
2618
- for (r2 = 0; r2 < (e2 || "").length; r2++) n2 += "\\x" + ((t2 = e2.charCodeAt(r2)) < 16 ? "0" : "") + t2.toString(16).toUpperCase();
2619
- return n2;
2620
- }, a.delay = function(e2, t2, r2) {
2621
- setImmediate(function() {
2622
- e2.apply(r2 || null, t2 || []);
2623
- });
2624
- }, a.inherits = function(e2, t2) {
2625
- function r2() {
2626
- }
2627
- r2.prototype = t2.prototype, e2.prototype = new r2();
2628
- }, a.extend = function() {
2629
- var e2, t2, r2 = {};
2630
- for (e2 = 0; e2 < arguments.length; e2++) for (t2 in arguments[e2]) Object.prototype.hasOwnProperty.call(arguments[e2], t2) && void 0 === r2[t2] && (r2[t2] = arguments[e2][t2]);
2631
- return r2;
2632
- }, a.prepareContent = function(r2, e2, n2, i2, s2) {
2633
- return u.Promise.resolve(e2).then(function(n3) {
2634
- return o.blob && (n3 instanceof Blob || -1 !== ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(n3))) && "undefined" != typeof FileReader ? new u.Promise(function(t2, r3) {
2635
- var e3 = new FileReader();
2636
- e3.onload = function(e4) {
2637
- t2(e4.target.result);
2638
- }, e3.onerror = function(e4) {
2639
- r3(e4.target.error);
2640
- }, e3.readAsArrayBuffer(n3);
2641
- }) : n3;
2642
- }).then(function(e3) {
2643
- var t2 = a.getTypeOf(e3);
2644
- return t2 ? ("arraybuffer" === t2 ? e3 = a.transformTo("uint8array", e3) : "string" === t2 && (s2 ? e3 = h.decode(e3) : n2 && true !== i2 && (e3 = function(e4) {
2645
- return l(e4, o.uint8array ? new Uint8Array(e4.length) : new Array(e4.length));
2646
- }(e3))), e3) : u.Promise.reject(new Error("Can't read the data of '" + r2 + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
2647
- });
2648
- };
2649
- }, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, setimmediate: 54 }], 33: [function(e, t, r) {
2650
- var n = e("./reader/readerFor"), i = e("./utils"), s = e("./signature"), a = e("./zipEntry"), o = e("./support");
2651
- function h(e2) {
2652
- this.files = [], this.loadOptions = e2;
2653
- }
2654
- h.prototype = { checkSignature: function(e2) {
2655
- if (!this.reader.readAndCheckSignature(e2)) {
2656
- this.reader.index -= 4;
2657
- var t2 = this.reader.readString(4);
2658
- throw new Error("Corrupted zip or bug: unexpected signature (" + i.pretty(t2) + ", expected " + i.pretty(e2) + ")");
2659
- }
2660
- }, isSignature: function(e2, t2) {
2661
- var r2 = this.reader.index;
2662
- this.reader.setIndex(e2);
2663
- var n2 = this.reader.readString(4) === t2;
2664
- return this.reader.setIndex(r2), n2;
2665
- }, readBlockEndOfCentral: function() {
2666
- this.diskNumber = this.reader.readInt(2), this.diskWithCentralDirStart = this.reader.readInt(2), this.centralDirRecordsOnThisDisk = this.reader.readInt(2), this.centralDirRecords = this.reader.readInt(2), this.centralDirSize = this.reader.readInt(4), this.centralDirOffset = this.reader.readInt(4), this.zipCommentLength = this.reader.readInt(2);
2667
- var e2 = this.reader.readData(this.zipCommentLength), t2 = o.uint8array ? "uint8array" : "array", r2 = i.transformTo(t2, e2);
2668
- this.zipComment = this.loadOptions.decodeFileName(r2);
2669
- }, readBlockZip64EndOfCentral: function() {
2670
- this.zip64EndOfCentralSize = this.reader.readInt(8), this.reader.skip(4), this.diskNumber = this.reader.readInt(4), this.diskWithCentralDirStart = this.reader.readInt(4), this.centralDirRecordsOnThisDisk = this.reader.readInt(8), this.centralDirRecords = this.reader.readInt(8), this.centralDirSize = this.reader.readInt(8), this.centralDirOffset = this.reader.readInt(8), this.zip64ExtensibleData = {};
2671
- for (var e2, t2, r2, n2 = this.zip64EndOfCentralSize - 44; 0 < n2; ) e2 = this.reader.readInt(2), t2 = this.reader.readInt(4), r2 = this.reader.readData(t2), this.zip64ExtensibleData[e2] = { id: e2, length: t2, value: r2 };
2672
- }, readBlockZip64EndOfCentralLocator: function() {
2673
- if (this.diskWithZip64CentralDirStart = this.reader.readInt(4), this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8), this.disksCount = this.reader.readInt(4), 1 < this.disksCount) throw new Error("Multi-volumes zip are not supported");
2674
- }, readLocalFiles: function() {
2675
- var e2, t2;
2676
- for (e2 = 0; e2 < this.files.length; e2++) t2 = this.files[e2], this.reader.setIndex(t2.localHeaderOffset), this.checkSignature(s.LOCAL_FILE_HEADER), t2.readLocalPart(this.reader), t2.handleUTF8(), t2.processAttributes();
2677
- }, readCentralDir: function() {
2678
- var e2;
2679
- for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER); ) (e2 = new a({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(e2);
2680
- if (this.centralDirRecords !== this.files.length && 0 !== this.centralDirRecords && 0 === this.files.length) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
2681
- }, readEndOfCentral: function() {
2682
- var e2 = this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);
2683
- if (e2 < 0) throw !this.isSignature(0, s.LOCAL_FILE_HEADER) ? new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html") : new Error("Corrupted zip: can't find end of central directory");
2684
- this.reader.setIndex(e2);
2685
- var t2 = e2;
2686
- if (this.checkSignature(s.CENTRAL_DIRECTORY_END), this.readBlockEndOfCentral(), this.diskNumber === i.MAX_VALUE_16BITS || this.diskWithCentralDirStart === i.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === i.MAX_VALUE_16BITS || this.centralDirRecords === i.MAX_VALUE_16BITS || this.centralDirSize === i.MAX_VALUE_32BITS || this.centralDirOffset === i.MAX_VALUE_32BITS) {
2687
- if (this.zip64 = true, (e2 = this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR)) < 0) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
2688
- if (this.reader.setIndex(e2), this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR), this.readBlockZip64EndOfCentralLocator(), !this.isSignature(this.relativeOffsetEndOfZip64CentralDir, s.ZIP64_CENTRAL_DIRECTORY_END) && (this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END), this.relativeOffsetEndOfZip64CentralDir < 0)) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
2689
- this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir), this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END), this.readBlockZip64EndOfCentral();
2690
- }
2691
- var r2 = this.centralDirOffset + this.centralDirSize;
2692
- this.zip64 && (r2 += 20, r2 += 12 + this.zip64EndOfCentralSize);
2693
- var n2 = t2 - r2;
2694
- if (0 < n2) this.isSignature(t2, s.CENTRAL_FILE_HEADER) || (this.reader.zero = n2);
2695
- else if (n2 < 0) throw new Error("Corrupted zip: missing " + Math.abs(n2) + " bytes.");
2696
- }, prepareReader: function(e2) {
2697
- this.reader = n(e2);
2698
- }, load: function(e2) {
2699
- this.prepareReader(e2), this.readEndOfCentral(), this.readCentralDir(), this.readLocalFiles();
2700
- } }, t.exports = h;
2701
- }, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(e, t, r) {
2702
- var n = e("./reader/readerFor"), s = e("./utils"), i = e("./compressedObject"), a = e("./crc32"), o = e("./utf8"), h = e("./compressions"), u = e("./support");
2703
- function l(e2, t2) {
2704
- this.options = e2, this.loadOptions = t2;
2705
- }
2706
- l.prototype = { isEncrypted: function() {
2707
- return 1 == (1 & this.bitFlag);
2708
- }, useUTF8: function() {
2709
- return 2048 == (2048 & this.bitFlag);
2710
- }, readLocalPart: function(e2) {
2711
- var t2, r2;
2712
- if (e2.skip(22), this.fileNameLength = e2.readInt(2), r2 = e2.readInt(2), this.fileName = e2.readData(this.fileNameLength), e2.skip(r2), -1 === this.compressedSize || -1 === this.uncompressedSize) throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");
2713
- if (null === (t2 = function(e3) {
2714
- for (var t3 in h) if (Object.prototype.hasOwnProperty.call(h, t3) && h[t3].magic === e3) return h[t3];
2715
- return null;
2716
- }(this.compressionMethod))) throw new Error("Corrupted zip : compression " + s.pretty(this.compressionMethod) + " unknown (inner file : " + s.transformTo("string", this.fileName) + ")");
2717
- this.decompressed = new i(this.compressedSize, this.uncompressedSize, this.crc32, t2, e2.readData(this.compressedSize));
2718
- }, readCentralPart: function(e2) {
2719
- this.versionMadeBy = e2.readInt(2), e2.skip(2), this.bitFlag = e2.readInt(2), this.compressionMethod = e2.readString(2), this.date = e2.readDate(), this.crc32 = e2.readInt(4), this.compressedSize = e2.readInt(4), this.uncompressedSize = e2.readInt(4);
2720
- var t2 = e2.readInt(2);
2721
- if (this.extraFieldsLength = e2.readInt(2), this.fileCommentLength = e2.readInt(2), this.diskNumberStart = e2.readInt(2), this.internalFileAttributes = e2.readInt(2), this.externalFileAttributes = e2.readInt(4), this.localHeaderOffset = e2.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported");
2722
- e2.skip(t2), this.readExtraFields(e2), this.parseZIP64ExtraField(e2), this.fileComment = e2.readData(this.fileCommentLength);
2723
- }, processAttributes: function() {
2724
- this.unixPermissions = null, this.dosPermissions = null;
2725
- var e2 = this.versionMadeBy >> 8;
2726
- this.dir = !!(16 & this.externalFileAttributes), 0 == e2 && (this.dosPermissions = 63 & this.externalFileAttributes), 3 == e2 && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || "/" !== this.fileNameStr.slice(-1) || (this.dir = true);
2727
- }, parseZIP64ExtraField: function() {
2728
- if (this.extraFields[1]) {
2729
- var e2 = n(this.extraFields[1].value);
2730
- this.uncompressedSize === s.MAX_VALUE_32BITS && (this.uncompressedSize = e2.readInt(8)), this.compressedSize === s.MAX_VALUE_32BITS && (this.compressedSize = e2.readInt(8)), this.localHeaderOffset === s.MAX_VALUE_32BITS && (this.localHeaderOffset = e2.readInt(8)), this.diskNumberStart === s.MAX_VALUE_32BITS && (this.diskNumberStart = e2.readInt(4));
2731
- }
2732
- }, readExtraFields: function(e2) {
2733
- var t2, r2, n2, i2 = e2.index + this.extraFieldsLength;
2734
- for (this.extraFields || (this.extraFields = {}); e2.index + 4 < i2; ) t2 = e2.readInt(2), r2 = e2.readInt(2), n2 = e2.readData(r2), this.extraFields[t2] = { id: t2, length: r2, value: n2 };
2735
- e2.setIndex(i2);
2736
- }, handleUTF8: function() {
2737
- var e2 = u.uint8array ? "uint8array" : "array";
2738
- if (this.useUTF8()) this.fileNameStr = o.utf8decode(this.fileName), this.fileCommentStr = o.utf8decode(this.fileComment);
2739
- else {
2740
- var t2 = this.findExtraFieldUnicodePath();
2741
- if (null !== t2) this.fileNameStr = t2;
2742
- else {
2743
- var r2 = s.transformTo(e2, this.fileName);
2744
- this.fileNameStr = this.loadOptions.decodeFileName(r2);
2745
- }
2746
- var n2 = this.findExtraFieldUnicodeComment();
2747
- if (null !== n2) this.fileCommentStr = n2;
2748
- else {
2749
- var i2 = s.transformTo(e2, this.fileComment);
2750
- this.fileCommentStr = this.loadOptions.decodeFileName(i2);
2751
- }
2752
- }
2753
- }, findExtraFieldUnicodePath: function() {
2754
- var e2 = this.extraFields[28789];
2755
- if (e2) {
2756
- var t2 = n(e2.value);
2757
- return 1 !== t2.readInt(1) ? null : a(this.fileName) !== t2.readInt(4) ? null : o.utf8decode(t2.readData(e2.length - 5));
2758
- }
2759
- return null;
2760
- }, findExtraFieldUnicodeComment: function() {
2761
- var e2 = this.extraFields[25461];
2762
- if (e2) {
2763
- var t2 = n(e2.value);
2764
- return 1 !== t2.readInt(1) ? null : a(this.fileComment) !== t2.readInt(4) ? null : o.utf8decode(t2.readData(e2.length - 5));
2765
- }
2766
- return null;
2767
- } }, t.exports = l;
2768
- }, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(e, t, r) {
2769
- function n(e2, t2, r2) {
2770
- this.name = e2, this.dir = r2.dir, this.date = r2.date, this.comment = r2.comment, this.unixPermissions = r2.unixPermissions, this.dosPermissions = r2.dosPermissions, this._data = t2, this._dataBinary = r2.binary, this.options = { compression: r2.compression, compressionOptions: r2.compressionOptions };
2771
- }
2772
- var s = e("./stream/StreamHelper"), i = e("./stream/DataWorker"), a = e("./utf8"), o = e("./compressedObject"), h = e("./stream/GenericWorker");
2773
- n.prototype = { internalStream: function(e2) {
2774
- var t2 = null, r2 = "string";
2775
- try {
2776
- if (!e2) throw new Error("No output type specified.");
2777
- var n2 = "string" === (r2 = e2.toLowerCase()) || "text" === r2;
2778
- "binarystring" !== r2 && "text" !== r2 || (r2 = "string"), t2 = this._decompressWorker();
2779
- var i2 = !this._dataBinary;
2780
- i2 && !n2 && (t2 = t2.pipe(new a.Utf8EncodeWorker())), !i2 && n2 && (t2 = t2.pipe(new a.Utf8DecodeWorker()));
2781
- } catch (e3) {
2782
- (t2 = new h("error")).error(e3);
2783
- }
2784
- return new s(t2, r2, "");
2785
- }, async: function(e2, t2) {
2786
- return this.internalStream(e2).accumulate(t2);
2787
- }, nodeStream: function(e2, t2) {
2788
- return this.internalStream(e2 || "nodebuffer").toNodejsStream(t2);
2789
- }, _compressWorker: function(e2, t2) {
2790
- if (this._data instanceof o && this._data.compression.magic === e2.magic) return this._data.getCompressedWorker();
2791
- var r2 = this._decompressWorker();
2792
- return this._dataBinary || (r2 = r2.pipe(new a.Utf8EncodeWorker())), o.createWorkerFrom(r2, e2, t2);
2793
- }, _decompressWorker: function() {
2794
- return this._data instanceof o ? this._data.getContentWorker() : this._data instanceof h ? this._data : new i(this._data);
2795
- } };
2796
- for (var u = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"], l = function() {
2797
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
2798
- }, f = 0; f < u.length; f++) n.prototype[u[f]] = l;
2799
- t.exports = n;
2800
- }, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(e, l, t) {
2801
- (function(t2) {
2802
- var r, n, e2 = t2.MutationObserver || t2.WebKitMutationObserver;
2803
- if (e2) {
2804
- var i = 0, s = new e2(u), a = t2.document.createTextNode("");
2805
- s.observe(a, { characterData: true }), r = function() {
2806
- a.data = i = ++i % 2;
2807
- };
2808
- } else if (t2.setImmediate || void 0 === t2.MessageChannel) r = "document" in t2 && "onreadystatechange" in t2.document.createElement("script") ? function() {
2809
- var e3 = t2.document.createElement("script");
2810
- e3.onreadystatechange = function() {
2811
- u(), e3.onreadystatechange = null, e3.parentNode.removeChild(e3), e3 = null;
2812
- }, t2.document.documentElement.appendChild(e3);
2813
- } : function() {
2814
- setTimeout(u, 0);
2815
- };
2816
- else {
2817
- var o = new t2.MessageChannel();
2818
- o.port1.onmessage = u, r = function() {
2819
- o.port2.postMessage(0);
2820
- };
2821
- }
2822
- var h = [];
2823
- function u() {
2824
- var e3, t3;
2825
- n = true;
2826
- for (var r2 = h.length; r2; ) {
2827
- for (t3 = h, h = [], e3 = -1; ++e3 < r2; ) t3[e3]();
2828
- r2 = h.length;
2829
- }
2830
- n = false;
2831
- }
2832
- l.exports = function(e3) {
2833
- 1 !== h.push(e3) || n || r();
2834
- };
2835
- }).call(this, "undefined" != typeof commonjsGlobal ? commonjsGlobal : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {});
2836
- }, {}], 37: [function(e, t, r) {
2837
- var i = e("immediate");
2838
- function u() {
2839
- }
2840
- var l = {}, s = ["REJECTED"], a = ["FULFILLED"], n = ["PENDING"];
2841
- function o(e2) {
2842
- if ("function" != typeof e2) throw new TypeError("resolver must be a function");
2843
- this.state = n, this.queue = [], this.outcome = void 0, e2 !== u && d(this, e2);
2844
- }
2845
- function h(e2, t2, r2) {
2846
- this.promise = e2, "function" == typeof t2 && (this.onFulfilled = t2, this.callFulfilled = this.otherCallFulfilled), "function" == typeof r2 && (this.onRejected = r2, this.callRejected = this.otherCallRejected);
2847
- }
2848
- function f(t2, r2, n2) {
2849
- i(function() {
2850
- var e2;
2851
- try {
2852
- e2 = r2(n2);
2853
- } catch (e3) {
2854
- return l.reject(t2, e3);
2855
- }
2856
- e2 === t2 ? l.reject(t2, new TypeError("Cannot resolve promise with itself")) : l.resolve(t2, e2);
2857
- });
2858
- }
2859
- function c(e2) {
2860
- var t2 = e2 && e2.then;
2861
- if (e2 && ("object" == typeof e2 || "function" == typeof e2) && "function" == typeof t2) return function() {
2862
- t2.apply(e2, arguments);
2863
- };
2864
- }
2865
- function d(t2, e2) {
2866
- var r2 = false;
2867
- function n2(e3) {
2868
- r2 || (r2 = true, l.reject(t2, e3));
2869
- }
2870
- function i2(e3) {
2871
- r2 || (r2 = true, l.resolve(t2, e3));
2872
- }
2873
- var s2 = p(function() {
2874
- e2(i2, n2);
2875
- });
2876
- "error" === s2.status && n2(s2.value);
2877
- }
2878
- function p(e2, t2) {
2879
- var r2 = {};
2880
- try {
2881
- r2.value = e2(t2), r2.status = "success";
2882
- } catch (e3) {
2883
- r2.status = "error", r2.value = e3;
2884
- }
2885
- return r2;
2886
- }
2887
- (t.exports = o).prototype.finally = function(t2) {
2888
- if ("function" != typeof t2) return this;
2889
- var r2 = this.constructor;
2890
- return this.then(function(e2) {
2891
- return r2.resolve(t2()).then(function() {
2892
- return e2;
2893
- });
2894
- }, function(e2) {
2895
- return r2.resolve(t2()).then(function() {
2896
- throw e2;
2897
- });
2898
- });
2899
- }, o.prototype.catch = function(e2) {
2900
- return this.then(null, e2);
2901
- }, o.prototype.then = function(e2, t2) {
2902
- if ("function" != typeof e2 && this.state === a || "function" != typeof t2 && this.state === s) return this;
2903
- var r2 = new this.constructor(u);
2904
- this.state !== n ? f(r2, this.state === a ? e2 : t2, this.outcome) : this.queue.push(new h(r2, e2, t2));
2905
- return r2;
2906
- }, h.prototype.callFulfilled = function(e2) {
2907
- l.resolve(this.promise, e2);
2908
- }, h.prototype.otherCallFulfilled = function(e2) {
2909
- f(this.promise, this.onFulfilled, e2);
2910
- }, h.prototype.callRejected = function(e2) {
2911
- l.reject(this.promise, e2);
2912
- }, h.prototype.otherCallRejected = function(e2) {
2913
- f(this.promise, this.onRejected, e2);
2914
- }, l.resolve = function(e2, t2) {
2915
- var r2 = p(c, t2);
2916
- if ("error" === r2.status) return l.reject(e2, r2.value);
2917
- var n2 = r2.value;
2918
- if (n2) d(e2, n2);
2919
- else {
2920
- e2.state = a, e2.outcome = t2;
2921
- for (var i2 = -1, s2 = e2.queue.length; ++i2 < s2; ) e2.queue[i2].callFulfilled(t2);
2922
- }
2923
- return e2;
2924
- }, l.reject = function(e2, t2) {
2925
- e2.state = s, e2.outcome = t2;
2926
- for (var r2 = -1, n2 = e2.queue.length; ++r2 < n2; ) e2.queue[r2].callRejected(t2);
2927
- return e2;
2928
- }, o.resolve = function(e2) {
2929
- if (e2 instanceof this) return e2;
2930
- return l.resolve(new this(u), e2);
2931
- }, o.reject = function(e2) {
2932
- var t2 = new this(u);
2933
- return l.reject(t2, e2);
2934
- }, o.all = function(e2) {
2935
- var r2 = this;
2936
- if ("[object Array]" !== Object.prototype.toString.call(e2)) return this.reject(new TypeError("must be an array"));
2937
- var n2 = e2.length, i2 = false;
2938
- if (!n2) return this.resolve([]);
2939
- var s2 = new Array(n2), a2 = 0, t2 = -1, o2 = new this(u);
2940
- for (; ++t2 < n2; ) h2(e2[t2], t2);
2941
- return o2;
2942
- function h2(e3, t3) {
2943
- r2.resolve(e3).then(function(e4) {
2944
- s2[t3] = e4, ++a2 !== n2 || i2 || (i2 = true, l.resolve(o2, s2));
2945
- }, function(e4) {
2946
- i2 || (i2 = true, l.reject(o2, e4));
2947
- });
2948
- }
2949
- }, o.race = function(e2) {
2950
- var t2 = this;
2951
- if ("[object Array]" !== Object.prototype.toString.call(e2)) return this.reject(new TypeError("must be an array"));
2952
- var r2 = e2.length, n2 = false;
2953
- if (!r2) return this.resolve([]);
2954
- var i2 = -1, s2 = new this(u);
2955
- for (; ++i2 < r2; ) a2 = e2[i2], t2.resolve(a2).then(function(e3) {
2956
- n2 || (n2 = true, l.resolve(s2, e3));
2957
- }, function(e3) {
2958
- n2 || (n2 = true, l.reject(s2, e3));
2959
- });
2960
- var a2;
2961
- return s2;
2962
- };
2963
- }, { immediate: 36 }], 38: [function(e, t, r) {
2964
- var n = {};
2965
- (0, e("./lib/utils/common").assign)(n, e("./lib/deflate"), e("./lib/inflate"), e("./lib/zlib/constants")), t.exports = n;
2966
- }, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(e, t, r) {
2967
- var a = e("./zlib/deflate"), o = e("./utils/common"), h = e("./utils/strings"), i = e("./zlib/messages"), s = e("./zlib/zstream"), u = Object.prototype.toString, l = 0, f = -1, c = 0, d = 8;
2968
- function p(e2) {
2969
- if (!(this instanceof p)) return new p(e2);
2970
- this.options = o.assign({ level: f, method: d, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: c, to: "" }, e2 || {});
2971
- var t2 = this.options;
2972
- t2.raw && 0 < t2.windowBits ? t2.windowBits = -t2.windowBits : t2.gzip && 0 < t2.windowBits && t2.windowBits < 16 && (t2.windowBits += 16), this.err = 0, this.msg = "", this.ended = false, this.chunks = [], this.strm = new s(), this.strm.avail_out = 0;
2973
- var r2 = a.deflateInit2(this.strm, t2.level, t2.method, t2.windowBits, t2.memLevel, t2.strategy);
2974
- if (r2 !== l) throw new Error(i[r2]);
2975
- if (t2.header && a.deflateSetHeader(this.strm, t2.header), t2.dictionary) {
2976
- var n2;
2977
- if (n2 = "string" == typeof t2.dictionary ? h.string2buf(t2.dictionary) : "[object ArrayBuffer]" === u.call(t2.dictionary) ? new Uint8Array(t2.dictionary) : t2.dictionary, (r2 = a.deflateSetDictionary(this.strm, n2)) !== l) throw new Error(i[r2]);
2978
- this._dict_set = true;
2979
- }
2980
- }
2981
- function n(e2, t2) {
2982
- var r2 = new p(t2);
2983
- if (r2.push(e2, true), r2.err) throw r2.msg || i[r2.err];
2984
- return r2.result;
2985
- }
2986
- p.prototype.push = function(e2, t2) {
2987
- var r2, n2, i2 = this.strm, s2 = this.options.chunkSize;
2988
- if (this.ended) return false;
2989
- n2 = t2 === ~~t2 ? t2 : true === t2 ? 4 : 0, "string" == typeof e2 ? i2.input = h.string2buf(e2) : "[object ArrayBuffer]" === u.call(e2) ? i2.input = new Uint8Array(e2) : i2.input = e2, i2.next_in = 0, i2.avail_in = i2.input.length;
2990
- do {
2991
- if (0 === i2.avail_out && (i2.output = new o.Buf8(s2), i2.next_out = 0, i2.avail_out = s2), 1 !== (r2 = a.deflate(i2, n2)) && r2 !== l) return this.onEnd(r2), !(this.ended = true);
2992
- 0 !== i2.avail_out && (0 !== i2.avail_in || 4 !== n2 && 2 !== n2) || ("string" === this.options.to ? this.onData(h.buf2binstring(o.shrinkBuf(i2.output, i2.next_out))) : this.onData(o.shrinkBuf(i2.output, i2.next_out)));
2993
- } while ((0 < i2.avail_in || 0 === i2.avail_out) && 1 !== r2);
2994
- return 4 === n2 ? (r2 = a.deflateEnd(this.strm), this.onEnd(r2), this.ended = true, r2 === l) : 2 !== n2 || (this.onEnd(l), !(i2.avail_out = 0));
2995
- }, p.prototype.onData = function(e2) {
2996
- this.chunks.push(e2);
2997
- }, p.prototype.onEnd = function(e2) {
2998
- e2 === l && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = o.flattenChunks(this.chunks)), this.chunks = [], this.err = e2, this.msg = this.strm.msg;
2999
- }, r.Deflate = p, r.deflate = n, r.deflateRaw = function(e2, t2) {
3000
- return (t2 = t2 || {}).raw = true, n(e2, t2);
3001
- }, r.gzip = function(e2, t2) {
3002
- return (t2 = t2 || {}).gzip = true, n(e2, t2);
3003
- };
3004
- }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(e, t, r) {
3005
- var c = e("./zlib/inflate"), d = e("./utils/common"), p = e("./utils/strings"), m = e("./zlib/constants"), n = e("./zlib/messages"), i = e("./zlib/zstream"), s = e("./zlib/gzheader"), _ = Object.prototype.toString;
3006
- function a(e2) {
3007
- if (!(this instanceof a)) return new a(e2);
3008
- this.options = d.assign({ chunkSize: 16384, windowBits: 0, to: "" }, e2 || {});
3009
- var t2 = this.options;
3010
- t2.raw && 0 <= t2.windowBits && t2.windowBits < 16 && (t2.windowBits = -t2.windowBits, 0 === t2.windowBits && (t2.windowBits = -15)), !(0 <= t2.windowBits && t2.windowBits < 16) || e2 && e2.windowBits || (t2.windowBits += 32), 15 < t2.windowBits && t2.windowBits < 48 && 0 == (15 & t2.windowBits) && (t2.windowBits |= 15), this.err = 0, this.msg = "", this.ended = false, this.chunks = [], this.strm = new i(), this.strm.avail_out = 0;
3011
- var r2 = c.inflateInit2(this.strm, t2.windowBits);
3012
- if (r2 !== m.Z_OK) throw new Error(n[r2]);
3013
- this.header = new s(), c.inflateGetHeader(this.strm, this.header);
3014
- }
3015
- function o(e2, t2) {
3016
- var r2 = new a(t2);
3017
- if (r2.push(e2, true), r2.err) throw r2.msg || n[r2.err];
3018
- return r2.result;
3019
- }
3020
- a.prototype.push = function(e2, t2) {
3021
- var r2, n2, i2, s2, a2, o2, h = this.strm, u = this.options.chunkSize, l = this.options.dictionary, f = false;
3022
- if (this.ended) return false;
3023
- n2 = t2 === ~~t2 ? t2 : true === t2 ? m.Z_FINISH : m.Z_NO_FLUSH, "string" == typeof e2 ? h.input = p.binstring2buf(e2) : "[object ArrayBuffer]" === _.call(e2) ? h.input = new Uint8Array(e2) : h.input = e2, h.next_in = 0, h.avail_in = h.input.length;
3024
- do {
3025
- if (0 === h.avail_out && (h.output = new d.Buf8(u), h.next_out = 0, h.avail_out = u), (r2 = c.inflate(h, m.Z_NO_FLUSH)) === m.Z_NEED_DICT && l && (o2 = "string" == typeof l ? p.string2buf(l) : "[object ArrayBuffer]" === _.call(l) ? new Uint8Array(l) : l, r2 = c.inflateSetDictionary(this.strm, o2)), r2 === m.Z_BUF_ERROR && true === f && (r2 = m.Z_OK, f = false), r2 !== m.Z_STREAM_END && r2 !== m.Z_OK) return this.onEnd(r2), !(this.ended = true);
3026
- h.next_out && (0 !== h.avail_out && r2 !== m.Z_STREAM_END && (0 !== h.avail_in || n2 !== m.Z_FINISH && n2 !== m.Z_SYNC_FLUSH) || ("string" === this.options.to ? (i2 = p.utf8border(h.output, h.next_out), s2 = h.next_out - i2, a2 = p.buf2string(h.output, i2), h.next_out = s2, h.avail_out = u - s2, s2 && d.arraySet(h.output, h.output, i2, s2, 0), this.onData(a2)) : this.onData(d.shrinkBuf(h.output, h.next_out)))), 0 === h.avail_in && 0 === h.avail_out && (f = true);
3027
- } while ((0 < h.avail_in || 0 === h.avail_out) && r2 !== m.Z_STREAM_END);
3028
- return r2 === m.Z_STREAM_END && (n2 = m.Z_FINISH), n2 === m.Z_FINISH ? (r2 = c.inflateEnd(this.strm), this.onEnd(r2), this.ended = true, r2 === m.Z_OK) : n2 !== m.Z_SYNC_FLUSH || (this.onEnd(m.Z_OK), !(h.avail_out = 0));
3029
- }, a.prototype.onData = function(e2) {
3030
- this.chunks.push(e2);
3031
- }, a.prototype.onEnd = function(e2) {
3032
- e2 === m.Z_OK && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = d.flattenChunks(this.chunks)), this.chunks = [], this.err = e2, this.msg = this.strm.msg;
3033
- }, r.Inflate = a, r.inflate = o, r.inflateRaw = function(e2, t2) {
3034
- return (t2 = t2 || {}).raw = true, o(e2, t2);
3035
- }, r.ungzip = o;
3036
- }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(e, t, r) {
3037
- var n = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Int32Array;
3038
- r.assign = function(e2) {
3039
- for (var t2 = Array.prototype.slice.call(arguments, 1); t2.length; ) {
3040
- var r2 = t2.shift();
3041
- if (r2) {
3042
- if ("object" != typeof r2) throw new TypeError(r2 + "must be non-object");
3043
- for (var n2 in r2) r2.hasOwnProperty(n2) && (e2[n2] = r2[n2]);
3044
- }
3045
- }
3046
- return e2;
3047
- }, r.shrinkBuf = function(e2, t2) {
3048
- return e2.length === t2 ? e2 : e2.subarray ? e2.subarray(0, t2) : (e2.length = t2, e2);
3049
- };
3050
- var i = { arraySet: function(e2, t2, r2, n2, i2) {
3051
- if (t2.subarray && e2.subarray) e2.set(t2.subarray(r2, r2 + n2), i2);
3052
- else for (var s2 = 0; s2 < n2; s2++) e2[i2 + s2] = t2[r2 + s2];
3053
- }, flattenChunks: function(e2) {
3054
- var t2, r2, n2, i2, s2, a;
3055
- for (t2 = n2 = 0, r2 = e2.length; t2 < r2; t2++) n2 += e2[t2].length;
3056
- for (a = new Uint8Array(n2), t2 = i2 = 0, r2 = e2.length; t2 < r2; t2++) s2 = e2[t2], a.set(s2, i2), i2 += s2.length;
3057
- return a;
3058
- } }, s = { arraySet: function(e2, t2, r2, n2, i2) {
3059
- for (var s2 = 0; s2 < n2; s2++) e2[i2 + s2] = t2[r2 + s2];
3060
- }, flattenChunks: function(e2) {
3061
- return [].concat.apply([], e2);
3062
- } };
3063
- r.setTyped = function(e2) {
3064
- e2 ? (r.Buf8 = Uint8Array, r.Buf16 = Uint16Array, r.Buf32 = Int32Array, r.assign(r, i)) : (r.Buf8 = Array, r.Buf16 = Array, r.Buf32 = Array, r.assign(r, s));
3065
- }, r.setTyped(n);
3066
- }, {}], 42: [function(e, t, r) {
3067
- var h = e("./common"), i = true, s = true;
3068
- try {
3069
- String.fromCharCode.apply(null, [0]);
3070
- } catch (e2) {
3071
- i = false;
3072
- }
3073
- try {
3074
- String.fromCharCode.apply(null, new Uint8Array(1));
3075
- } catch (e2) {
3076
- s = false;
3077
- }
3078
- for (var u = new h.Buf8(256), n = 0; n < 256; n++) u[n] = 252 <= n ? 6 : 248 <= n ? 5 : 240 <= n ? 4 : 224 <= n ? 3 : 192 <= n ? 2 : 1;
3079
- function l(e2, t2) {
3080
- if (t2 < 65537 && (e2.subarray && s || !e2.subarray && i)) return String.fromCharCode.apply(null, h.shrinkBuf(e2, t2));
3081
- for (var r2 = "", n2 = 0; n2 < t2; n2++) r2 += String.fromCharCode(e2[n2]);
3082
- return r2;
3083
- }
3084
- u[254] = u[254] = 1, r.string2buf = function(e2) {
3085
- var t2, r2, n2, i2, s2, a = e2.length, o = 0;
3086
- for (i2 = 0; i2 < a; i2++) 55296 == (64512 & (r2 = e2.charCodeAt(i2))) && i2 + 1 < a && 56320 == (64512 & (n2 = e2.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), o += r2 < 128 ? 1 : r2 < 2048 ? 2 : r2 < 65536 ? 3 : 4;
3087
- for (t2 = new h.Buf8(o), i2 = s2 = 0; s2 < o; i2++) 55296 == (64512 & (r2 = e2.charCodeAt(i2))) && i2 + 1 < a && 56320 == (64512 & (n2 = e2.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), r2 < 128 ? t2[s2++] = r2 : (r2 < 2048 ? t2[s2++] = 192 | r2 >>> 6 : (r2 < 65536 ? t2[s2++] = 224 | r2 >>> 12 : (t2[s2++] = 240 | r2 >>> 18, t2[s2++] = 128 | r2 >>> 12 & 63), t2[s2++] = 128 | r2 >>> 6 & 63), t2[s2++] = 128 | 63 & r2);
3088
- return t2;
3089
- }, r.buf2binstring = function(e2) {
3090
- return l(e2, e2.length);
3091
- }, r.binstring2buf = function(e2) {
3092
- for (var t2 = new h.Buf8(e2.length), r2 = 0, n2 = t2.length; r2 < n2; r2++) t2[r2] = e2.charCodeAt(r2);
3093
- return t2;
3094
- }, r.buf2string = function(e2, t2) {
3095
- var r2, n2, i2, s2, a = t2 || e2.length, o = new Array(2 * a);
3096
- for (r2 = n2 = 0; r2 < a; ) if ((i2 = e2[r2++]) < 128) o[n2++] = i2;
3097
- else if (4 < (s2 = u[i2])) o[n2++] = 65533, r2 += s2 - 1;
3098
- else {
3099
- for (i2 &= 2 === s2 ? 31 : 3 === s2 ? 15 : 7; 1 < s2 && r2 < a; ) i2 = i2 << 6 | 63 & e2[r2++], s2--;
3100
- 1 < s2 ? o[n2++] = 65533 : i2 < 65536 ? o[n2++] = i2 : (i2 -= 65536, o[n2++] = 55296 | i2 >> 10 & 1023, o[n2++] = 56320 | 1023 & i2);
3101
- }
3102
- return l(o, n2);
3103
- }, r.utf8border = function(e2, t2) {
3104
- var r2;
3105
- for ((t2 = t2 || e2.length) > e2.length && (t2 = e2.length), r2 = t2 - 1; 0 <= r2 && 128 == (192 & e2[r2]); ) r2--;
3106
- return r2 < 0 ? t2 : 0 === r2 ? t2 : r2 + u[e2[r2]] > t2 ? r2 : t2;
3107
- };
3108
- }, { "./common": 41 }], 43: [function(e, t, r) {
3109
- t.exports = function(e2, t2, r2, n) {
3110
- for (var i = 65535 & e2 | 0, s = e2 >>> 16 & 65535 | 0, a = 0; 0 !== r2; ) {
3111
- for (r2 -= a = 2e3 < r2 ? 2e3 : r2; s = s + (i = i + t2[n++] | 0) | 0, --a; ) ;
3112
- i %= 65521, s %= 65521;
3113
- }
3114
- return i | s << 16 | 0;
3115
- };
3116
- }, {}], 44: [function(e, t, r) {
3117
- t.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 };
3118
- }, {}], 45: [function(e, t, r) {
3119
- var o = function() {
3120
- for (var e2, t2 = [], r2 = 0; r2 < 256; r2++) {
3121
- e2 = r2;
3122
- for (var n = 0; n < 8; n++) e2 = 1 & e2 ? 3988292384 ^ e2 >>> 1 : e2 >>> 1;
3123
- t2[r2] = e2;
3124
- }
3125
- return t2;
3126
- }();
3127
- t.exports = function(e2, t2, r2, n) {
3128
- var i = o, s = n + r2;
3129
- e2 ^= -1;
3130
- for (var a = n; a < s; a++) e2 = e2 >>> 8 ^ i[255 & (e2 ^ t2[a])];
3131
- return -1 ^ e2;
3132
- };
3133
- }, {}], 46: [function(e, t, r) {
3134
- var h, c = e("../utils/common"), u = e("./trees"), d = e("./adler32"), p = e("./crc32"), n = e("./messages"), l = 0, f = 4, m = 0, _ = -2, g = -1, b = 4, i = 2, v = 8, y = 9, s = 286, a = 30, o = 19, w = 2 * s + 1, k = 15, x = 3, S = 258, z = S + x + 1, C = 42, E = 113, A = 1, I = 2, O = 3, B = 4;
3135
- function R(e2, t2) {
3136
- return e2.msg = n[t2], t2;
3137
- }
3138
- function T(e2) {
3139
- return (e2 << 1) - (4 < e2 ? 9 : 0);
3140
- }
3141
- function D(e2) {
3142
- for (var t2 = e2.length; 0 <= --t2; ) e2[t2] = 0;
3143
- }
3144
- function F(e2) {
3145
- var t2 = e2.state, r2 = t2.pending;
3146
- r2 > e2.avail_out && (r2 = e2.avail_out), 0 !== r2 && (c.arraySet(e2.output, t2.pending_buf, t2.pending_out, r2, e2.next_out), e2.next_out += r2, t2.pending_out += r2, e2.total_out += r2, e2.avail_out -= r2, t2.pending -= r2, 0 === t2.pending && (t2.pending_out = 0));
3147
- }
3148
- function N(e2, t2) {
3149
- u._tr_flush_block(e2, 0 <= e2.block_start ? e2.block_start : -1, e2.strstart - e2.block_start, t2), e2.block_start = e2.strstart, F(e2.strm);
3150
- }
3151
- function U(e2, t2) {
3152
- e2.pending_buf[e2.pending++] = t2;
3153
- }
3154
- function P(e2, t2) {
3155
- e2.pending_buf[e2.pending++] = t2 >>> 8 & 255, e2.pending_buf[e2.pending++] = 255 & t2;
3156
- }
3157
- function L(e2, t2) {
3158
- var r2, n2, i2 = e2.max_chain_length, s2 = e2.strstart, a2 = e2.prev_length, o2 = e2.nice_match, h2 = e2.strstart > e2.w_size - z ? e2.strstart - (e2.w_size - z) : 0, u2 = e2.window, l2 = e2.w_mask, f2 = e2.prev, c2 = e2.strstart + S, d2 = u2[s2 + a2 - 1], p2 = u2[s2 + a2];
3159
- e2.prev_length >= e2.good_match && (i2 >>= 2), o2 > e2.lookahead && (o2 = e2.lookahead);
3160
- do {
3161
- if (u2[(r2 = t2) + a2] === p2 && u2[r2 + a2 - 1] === d2 && u2[r2] === u2[s2] && u2[++r2] === u2[s2 + 1]) {
3162
- s2 += 2, r2++;
3163
- do {
3164
- } while (u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && u2[++s2] === u2[++r2] && s2 < c2);
3165
- if (n2 = S - (c2 - s2), s2 = c2 - S, a2 < n2) {
3166
- if (e2.match_start = t2, o2 <= (a2 = n2)) break;
3167
- d2 = u2[s2 + a2 - 1], p2 = u2[s2 + a2];
3168
- }
3169
- }
3170
- } while ((t2 = f2[t2 & l2]) > h2 && 0 != --i2);
3171
- return a2 <= e2.lookahead ? a2 : e2.lookahead;
3172
- }
3173
- function j(e2) {
3174
- var t2, r2, n2, i2, s2, a2, o2, h2, u2, l2, f2 = e2.w_size;
3175
- do {
3176
- if (i2 = e2.window_size - e2.lookahead - e2.strstart, e2.strstart >= f2 + (f2 - z)) {
3177
- for (c.arraySet(e2.window, e2.window, f2, f2, 0), e2.match_start -= f2, e2.strstart -= f2, e2.block_start -= f2, t2 = r2 = e2.hash_size; n2 = e2.head[--t2], e2.head[t2] = f2 <= n2 ? n2 - f2 : 0, --r2; ) ;
3178
- for (t2 = r2 = f2; n2 = e2.prev[--t2], e2.prev[t2] = f2 <= n2 ? n2 - f2 : 0, --r2; ) ;
3179
- i2 += f2;
3180
- }
3181
- if (0 === e2.strm.avail_in) break;
3182
- if (a2 = e2.strm, o2 = e2.window, h2 = e2.strstart + e2.lookahead, u2 = i2, l2 = void 0, l2 = a2.avail_in, u2 < l2 && (l2 = u2), r2 = 0 === l2 ? 0 : (a2.avail_in -= l2, c.arraySet(o2, a2.input, a2.next_in, l2, h2), 1 === a2.state.wrap ? a2.adler = d(a2.adler, o2, l2, h2) : 2 === a2.state.wrap && (a2.adler = p(a2.adler, o2, l2, h2)), a2.next_in += l2, a2.total_in += l2, l2), e2.lookahead += r2, e2.lookahead + e2.insert >= x) for (s2 = e2.strstart - e2.insert, e2.ins_h = e2.window[s2], e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[s2 + 1]) & e2.hash_mask; e2.insert && (e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[s2 + x - 1]) & e2.hash_mask, e2.prev[s2 & e2.w_mask] = e2.head[e2.ins_h], e2.head[e2.ins_h] = s2, s2++, e2.insert--, !(e2.lookahead + e2.insert < x)); ) ;
3183
- } while (e2.lookahead < z && 0 !== e2.strm.avail_in);
3184
- }
3185
- function Z(e2, t2) {
3186
- for (var r2, n2; ; ) {
3187
- if (e2.lookahead < z) {
3188
- if (j(e2), e2.lookahead < z && t2 === l) return A;
3189
- if (0 === e2.lookahead) break;
3190
- }
3191
- if (r2 = 0, e2.lookahead >= x && (e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[e2.strstart + x - 1]) & e2.hash_mask, r2 = e2.prev[e2.strstart & e2.w_mask] = e2.head[e2.ins_h], e2.head[e2.ins_h] = e2.strstart), 0 !== r2 && e2.strstart - r2 <= e2.w_size - z && (e2.match_length = L(e2, r2)), e2.match_length >= x) if (n2 = u._tr_tally(e2, e2.strstart - e2.match_start, e2.match_length - x), e2.lookahead -= e2.match_length, e2.match_length <= e2.max_lazy_match && e2.lookahead >= x) {
3192
- for (e2.match_length--; e2.strstart++, e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[e2.strstart + x - 1]) & e2.hash_mask, r2 = e2.prev[e2.strstart & e2.w_mask] = e2.head[e2.ins_h], e2.head[e2.ins_h] = e2.strstart, 0 != --e2.match_length; ) ;
3193
- e2.strstart++;
3194
- } else e2.strstart += e2.match_length, e2.match_length = 0, e2.ins_h = e2.window[e2.strstart], e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[e2.strstart + 1]) & e2.hash_mask;
3195
- else n2 = u._tr_tally(e2, 0, e2.window[e2.strstart]), e2.lookahead--, e2.strstart++;
3196
- if (n2 && (N(e2, false), 0 === e2.strm.avail_out)) return A;
3197
- }
3198
- return e2.insert = e2.strstart < x - 1 ? e2.strstart : x - 1, t2 === f ? (N(e2, true), 0 === e2.strm.avail_out ? O : B) : e2.last_lit && (N(e2, false), 0 === e2.strm.avail_out) ? A : I;
3199
- }
3200
- function W(e2, t2) {
3201
- for (var r2, n2, i2; ; ) {
3202
- if (e2.lookahead < z) {
3203
- if (j(e2), e2.lookahead < z && t2 === l) return A;
3204
- if (0 === e2.lookahead) break;
3205
- }
3206
- if (r2 = 0, e2.lookahead >= x && (e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[e2.strstart + x - 1]) & e2.hash_mask, r2 = e2.prev[e2.strstart & e2.w_mask] = e2.head[e2.ins_h], e2.head[e2.ins_h] = e2.strstart), e2.prev_length = e2.match_length, e2.prev_match = e2.match_start, e2.match_length = x - 1, 0 !== r2 && e2.prev_length < e2.max_lazy_match && e2.strstart - r2 <= e2.w_size - z && (e2.match_length = L(e2, r2), e2.match_length <= 5 && (1 === e2.strategy || e2.match_length === x && 4096 < e2.strstart - e2.match_start) && (e2.match_length = x - 1)), e2.prev_length >= x && e2.match_length <= e2.prev_length) {
3207
- for (i2 = e2.strstart + e2.lookahead - x, n2 = u._tr_tally(e2, e2.strstart - 1 - e2.prev_match, e2.prev_length - x), e2.lookahead -= e2.prev_length - 1, e2.prev_length -= 2; ++e2.strstart <= i2 && (e2.ins_h = (e2.ins_h << e2.hash_shift ^ e2.window[e2.strstart + x - 1]) & e2.hash_mask, r2 = e2.prev[e2.strstart & e2.w_mask] = e2.head[e2.ins_h], e2.head[e2.ins_h] = e2.strstart), 0 != --e2.prev_length; ) ;
3208
- if (e2.match_available = 0, e2.match_length = x - 1, e2.strstart++, n2 && (N(e2, false), 0 === e2.strm.avail_out)) return A;
3209
- } else if (e2.match_available) {
3210
- if ((n2 = u._tr_tally(e2, 0, e2.window[e2.strstart - 1])) && N(e2, false), e2.strstart++, e2.lookahead--, 0 === e2.strm.avail_out) return A;
3211
- } else e2.match_available = 1, e2.strstart++, e2.lookahead--;
3212
- }
3213
- return e2.match_available && (n2 = u._tr_tally(e2, 0, e2.window[e2.strstart - 1]), e2.match_available = 0), e2.insert = e2.strstart < x - 1 ? e2.strstart : x - 1, t2 === f ? (N(e2, true), 0 === e2.strm.avail_out ? O : B) : e2.last_lit && (N(e2, false), 0 === e2.strm.avail_out) ? A : I;
3214
- }
3215
- function M(e2, t2, r2, n2, i2) {
3216
- this.good_length = e2, this.max_lazy = t2, this.nice_length = r2, this.max_chain = n2, this.func = i2;
3217
- }
3218
- function H() {
3219
- this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = v, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new c.Buf16(2 * w), this.dyn_dtree = new c.Buf16(2 * (2 * a + 1)), this.bl_tree = new c.Buf16(2 * (2 * o + 1)), D(this.dyn_ltree), D(this.dyn_dtree), D(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new c.Buf16(k + 1), this.heap = new c.Buf16(2 * s + 1), D(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new c.Buf16(2 * s + 1), D(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0;
3220
- }
3221
- function G(e2) {
3222
- var t2;
3223
- return e2 && e2.state ? (e2.total_in = e2.total_out = 0, e2.data_type = i, (t2 = e2.state).pending = 0, t2.pending_out = 0, t2.wrap < 0 && (t2.wrap = -t2.wrap), t2.status = t2.wrap ? C : E, e2.adler = 2 === t2.wrap ? 0 : 1, t2.last_flush = l, u._tr_init(t2), m) : R(e2, _);
3224
- }
3225
- function K(e2) {
3226
- var t2 = G(e2);
3227
- return t2 === m && function(e3) {
3228
- e3.window_size = 2 * e3.w_size, D(e3.head), e3.max_lazy_match = h[e3.level].max_lazy, e3.good_match = h[e3.level].good_length, e3.nice_match = h[e3.level].nice_length, e3.max_chain_length = h[e3.level].max_chain, e3.strstart = 0, e3.block_start = 0, e3.lookahead = 0, e3.insert = 0, e3.match_length = e3.prev_length = x - 1, e3.match_available = 0, e3.ins_h = 0;
3229
- }(e2.state), t2;
3230
- }
3231
- function Y(e2, t2, r2, n2, i2, s2) {
3232
- if (!e2) return _;
3233
- var a2 = 1;
3234
- if (t2 === g && (t2 = 6), n2 < 0 ? (a2 = 0, n2 = -n2) : 15 < n2 && (a2 = 2, n2 -= 16), i2 < 1 || y < i2 || r2 !== v || n2 < 8 || 15 < n2 || t2 < 0 || 9 < t2 || s2 < 0 || b < s2) return R(e2, _);
3235
- 8 === n2 && (n2 = 9);
3236
- var o2 = new H();
3237
- return (e2.state = o2).strm = e2, o2.wrap = a2, o2.gzhead = null, o2.w_bits = n2, o2.w_size = 1 << o2.w_bits, o2.w_mask = o2.w_size - 1, o2.hash_bits = i2 + 7, o2.hash_size = 1 << o2.hash_bits, o2.hash_mask = o2.hash_size - 1, o2.hash_shift = ~~((o2.hash_bits + x - 1) / x), o2.window = new c.Buf8(2 * o2.w_size), o2.head = new c.Buf16(o2.hash_size), o2.prev = new c.Buf16(o2.w_size), o2.lit_bufsize = 1 << i2 + 6, o2.pending_buf_size = 4 * o2.lit_bufsize, o2.pending_buf = new c.Buf8(o2.pending_buf_size), o2.d_buf = 1 * o2.lit_bufsize, o2.l_buf = 3 * o2.lit_bufsize, o2.level = t2, o2.strategy = s2, o2.method = r2, K(e2);
3238
- }
3239
- h = [new M(0, 0, 0, 0, function(e2, t2) {
3240
- var r2 = 65535;
3241
- for (r2 > e2.pending_buf_size - 5 && (r2 = e2.pending_buf_size - 5); ; ) {
3242
- if (e2.lookahead <= 1) {
3243
- if (j(e2), 0 === e2.lookahead && t2 === l) return A;
3244
- if (0 === e2.lookahead) break;
3245
- }
3246
- e2.strstart += e2.lookahead, e2.lookahead = 0;
3247
- var n2 = e2.block_start + r2;
3248
- if ((0 === e2.strstart || e2.strstart >= n2) && (e2.lookahead = e2.strstart - n2, e2.strstart = n2, N(e2, false), 0 === e2.strm.avail_out)) return A;
3249
- if (e2.strstart - e2.block_start >= e2.w_size - z && (N(e2, false), 0 === e2.strm.avail_out)) return A;
3250
- }
3251
- return e2.insert = 0, t2 === f ? (N(e2, true), 0 === e2.strm.avail_out ? O : B) : (e2.strstart > e2.block_start && (N(e2, false), e2.strm.avail_out), A);
3252
- }), new M(4, 4, 8, 4, Z), new M(4, 5, 16, 8, Z), new M(4, 6, 32, 32, Z), new M(4, 4, 16, 16, W), new M(8, 16, 32, 32, W), new M(8, 16, 128, 128, W), new M(8, 32, 128, 256, W), new M(32, 128, 258, 1024, W), new M(32, 258, 258, 4096, W)], r.deflateInit = function(e2, t2) {
3253
- return Y(e2, t2, v, 15, 8, 0);
3254
- }, r.deflateInit2 = Y, r.deflateReset = K, r.deflateResetKeep = G, r.deflateSetHeader = function(e2, t2) {
3255
- return e2 && e2.state ? 2 !== e2.state.wrap ? _ : (e2.state.gzhead = t2, m) : _;
3256
- }, r.deflate = function(e2, t2) {
3257
- var r2, n2, i2, s2;
3258
- if (!e2 || !e2.state || 5 < t2 || t2 < 0) return e2 ? R(e2, _) : _;
3259
- if (n2 = e2.state, !e2.output || !e2.input && 0 !== e2.avail_in || 666 === n2.status && t2 !== f) return R(e2, 0 === e2.avail_out ? -5 : _);
3260
- if (n2.strm = e2, r2 = n2.last_flush, n2.last_flush = t2, n2.status === C) if (2 === n2.wrap) e2.adler = 0, U(n2, 31), U(n2, 139), U(n2, 8), n2.gzhead ? (U(n2, (n2.gzhead.text ? 1 : 0) + (n2.gzhead.hcrc ? 2 : 0) + (n2.gzhead.extra ? 4 : 0) + (n2.gzhead.name ? 8 : 0) + (n2.gzhead.comment ? 16 : 0)), U(n2, 255 & n2.gzhead.time), U(n2, n2.gzhead.time >> 8 & 255), U(n2, n2.gzhead.time >> 16 & 255), U(n2, n2.gzhead.time >> 24 & 255), U(n2, 9 === n2.level ? 2 : 2 <= n2.strategy || n2.level < 2 ? 4 : 0), U(n2, 255 & n2.gzhead.os), n2.gzhead.extra && n2.gzhead.extra.length && (U(n2, 255 & n2.gzhead.extra.length), U(n2, n2.gzhead.extra.length >> 8 & 255)), n2.gzhead.hcrc && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending, 0)), n2.gzindex = 0, n2.status = 69) : (U(n2, 0), U(n2, 0), U(n2, 0), U(n2, 0), U(n2, 0), U(n2, 9 === n2.level ? 2 : 2 <= n2.strategy || n2.level < 2 ? 4 : 0), U(n2, 3), n2.status = E);
3261
- else {
3262
- var a2 = v + (n2.w_bits - 8 << 4) << 8;
3263
- a2 |= (2 <= n2.strategy || n2.level < 2 ? 0 : n2.level < 6 ? 1 : 6 === n2.level ? 2 : 3) << 6, 0 !== n2.strstart && (a2 |= 32), a2 += 31 - a2 % 31, n2.status = E, P(n2, a2), 0 !== n2.strstart && (P(n2, e2.adler >>> 16), P(n2, 65535 & e2.adler)), e2.adler = 1;
3264
- }
3265
- if (69 === n2.status) if (n2.gzhead.extra) {
3266
- for (i2 = n2.pending; n2.gzindex < (65535 & n2.gzhead.extra.length) && (n2.pending !== n2.pending_buf_size || (n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), F(e2), i2 = n2.pending, n2.pending !== n2.pending_buf_size)); ) U(n2, 255 & n2.gzhead.extra[n2.gzindex]), n2.gzindex++;
3267
- n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), n2.gzindex === n2.gzhead.extra.length && (n2.gzindex = 0, n2.status = 73);
3268
- } else n2.status = 73;
3269
- if (73 === n2.status) if (n2.gzhead.name) {
3270
- i2 = n2.pending;
3271
- do {
3272
- if (n2.pending === n2.pending_buf_size && (n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), F(e2), i2 = n2.pending, n2.pending === n2.pending_buf_size)) {
3273
- s2 = 1;
3274
- break;
3275
- }
3276
- s2 = n2.gzindex < n2.gzhead.name.length ? 255 & n2.gzhead.name.charCodeAt(n2.gzindex++) : 0, U(n2, s2);
3277
- } while (0 !== s2);
3278
- n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), 0 === s2 && (n2.gzindex = 0, n2.status = 91);
3279
- } else n2.status = 91;
3280
- if (91 === n2.status) if (n2.gzhead.comment) {
3281
- i2 = n2.pending;
3282
- do {
3283
- if (n2.pending === n2.pending_buf_size && (n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), F(e2), i2 = n2.pending, n2.pending === n2.pending_buf_size)) {
3284
- s2 = 1;
3285
- break;
3286
- }
3287
- s2 = n2.gzindex < n2.gzhead.comment.length ? 255 & n2.gzhead.comment.charCodeAt(n2.gzindex++) : 0, U(n2, s2);
3288
- } while (0 !== s2);
3289
- n2.gzhead.hcrc && n2.pending > i2 && (e2.adler = p(e2.adler, n2.pending_buf, n2.pending - i2, i2)), 0 === s2 && (n2.status = 103);
3290
- } else n2.status = 103;
3291
- if (103 === n2.status && (n2.gzhead.hcrc ? (n2.pending + 2 > n2.pending_buf_size && F(e2), n2.pending + 2 <= n2.pending_buf_size && (U(n2, 255 & e2.adler), U(n2, e2.adler >> 8 & 255), e2.adler = 0, n2.status = E)) : n2.status = E), 0 !== n2.pending) {
3292
- if (F(e2), 0 === e2.avail_out) return n2.last_flush = -1, m;
3293
- } else if (0 === e2.avail_in && T(t2) <= T(r2) && t2 !== f) return R(e2, -5);
3294
- if (666 === n2.status && 0 !== e2.avail_in) return R(e2, -5);
3295
- if (0 !== e2.avail_in || 0 !== n2.lookahead || t2 !== l && 666 !== n2.status) {
3296
- var o2 = 2 === n2.strategy ? function(e3, t3) {
3297
- for (var r3; ; ) {
3298
- if (0 === e3.lookahead && (j(e3), 0 === e3.lookahead)) {
3299
- if (t3 === l) return A;
3300
- break;
3301
- }
3302
- if (e3.match_length = 0, r3 = u._tr_tally(e3, 0, e3.window[e3.strstart]), e3.lookahead--, e3.strstart++, r3 && (N(e3, false), 0 === e3.strm.avail_out)) return A;
3303
- }
3304
- return e3.insert = 0, t3 === f ? (N(e3, true), 0 === e3.strm.avail_out ? O : B) : e3.last_lit && (N(e3, false), 0 === e3.strm.avail_out) ? A : I;
3305
- }(n2, t2) : 3 === n2.strategy ? function(e3, t3) {
3306
- for (var r3, n3, i3, s3, a3 = e3.window; ; ) {
3307
- if (e3.lookahead <= S) {
3308
- if (j(e3), e3.lookahead <= S && t3 === l) return A;
3309
- if (0 === e3.lookahead) break;
3310
- }
3311
- if (e3.match_length = 0, e3.lookahead >= x && 0 < e3.strstart && (n3 = a3[i3 = e3.strstart - 1]) === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]) {
3312
- s3 = e3.strstart + S;
3313
- do {
3314
- } while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && i3 < s3);
3315
- e3.match_length = S - (s3 - i3), e3.match_length > e3.lookahead && (e3.match_length = e3.lookahead);
3316
- }
3317
- if (e3.match_length >= x ? (r3 = u._tr_tally(e3, 1, e3.match_length - x), e3.lookahead -= e3.match_length, e3.strstart += e3.match_length, e3.match_length = 0) : (r3 = u._tr_tally(e3, 0, e3.window[e3.strstart]), e3.lookahead--, e3.strstart++), r3 && (N(e3, false), 0 === e3.strm.avail_out)) return A;
3318
- }
3319
- return e3.insert = 0, t3 === f ? (N(e3, true), 0 === e3.strm.avail_out ? O : B) : e3.last_lit && (N(e3, false), 0 === e3.strm.avail_out) ? A : I;
3320
- }(n2, t2) : h[n2.level].func(n2, t2);
3321
- if (o2 !== O && o2 !== B || (n2.status = 666), o2 === A || o2 === O) return 0 === e2.avail_out && (n2.last_flush = -1), m;
3322
- if (o2 === I && (1 === t2 ? u._tr_align(n2) : 5 !== t2 && (u._tr_stored_block(n2, 0, 0, false), 3 === t2 && (D(n2.head), 0 === n2.lookahead && (n2.strstart = 0, n2.block_start = 0, n2.insert = 0))), F(e2), 0 === e2.avail_out)) return n2.last_flush = -1, m;
3323
- }
3324
- return t2 !== f ? m : n2.wrap <= 0 ? 1 : (2 === n2.wrap ? (U(n2, 255 & e2.adler), U(n2, e2.adler >> 8 & 255), U(n2, e2.adler >> 16 & 255), U(n2, e2.adler >> 24 & 255), U(n2, 255 & e2.total_in), U(n2, e2.total_in >> 8 & 255), U(n2, e2.total_in >> 16 & 255), U(n2, e2.total_in >> 24 & 255)) : (P(n2, e2.adler >>> 16), P(n2, 65535 & e2.adler)), F(e2), 0 < n2.wrap && (n2.wrap = -n2.wrap), 0 !== n2.pending ? m : 1);
3325
- }, r.deflateEnd = function(e2) {
3326
- var t2;
3327
- return e2 && e2.state ? (t2 = e2.state.status) !== C && 69 !== t2 && 73 !== t2 && 91 !== t2 && 103 !== t2 && t2 !== E && 666 !== t2 ? R(e2, _) : (e2.state = null, t2 === E ? R(e2, -3) : m) : _;
3328
- }, r.deflateSetDictionary = function(e2, t2) {
3329
- var r2, n2, i2, s2, a2, o2, h2, u2, l2 = t2.length;
3330
- if (!e2 || !e2.state) return _;
3331
- if (2 === (s2 = (r2 = e2.state).wrap) || 1 === s2 && r2.status !== C || r2.lookahead) return _;
3332
- for (1 === s2 && (e2.adler = d(e2.adler, t2, l2, 0)), r2.wrap = 0, l2 >= r2.w_size && (0 === s2 && (D(r2.head), r2.strstart = 0, r2.block_start = 0, r2.insert = 0), u2 = new c.Buf8(r2.w_size), c.arraySet(u2, t2, l2 - r2.w_size, r2.w_size, 0), t2 = u2, l2 = r2.w_size), a2 = e2.avail_in, o2 = e2.next_in, h2 = e2.input, e2.avail_in = l2, e2.next_in = 0, e2.input = t2, j(r2); r2.lookahead >= x; ) {
3333
- for (n2 = r2.strstart, i2 = r2.lookahead - (x - 1); r2.ins_h = (r2.ins_h << r2.hash_shift ^ r2.window[n2 + x - 1]) & r2.hash_mask, r2.prev[n2 & r2.w_mask] = r2.head[r2.ins_h], r2.head[r2.ins_h] = n2, n2++, --i2; ) ;
3334
- r2.strstart = n2, r2.lookahead = x - 1, j(r2);
3335
- }
3336
- return r2.strstart += r2.lookahead, r2.block_start = r2.strstart, r2.insert = r2.lookahead, r2.lookahead = 0, r2.match_length = r2.prev_length = x - 1, r2.match_available = 0, e2.next_in = o2, e2.input = h2, e2.avail_in = a2, r2.wrap = s2, m;
3337
- }, r.deflateInfo = "pako deflate (from Nodeca project)";
3338
- }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(e, t, r) {
3339
- t.exports = function() {
3340
- this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = false;
3341
- };
3342
- }, {}], 48: [function(e, t, r) {
3343
- t.exports = function(e2, t2) {
3344
- var r2, n, i, s, a, o, h, u, l, f, c, d, p, m, _, g, b, v, y, w, k, x, S, z, C;
3345
- r2 = e2.state, n = e2.next_in, z = e2.input, i = n + (e2.avail_in - 5), s = e2.next_out, C = e2.output, a = s - (t2 - e2.avail_out), o = s + (e2.avail_out - 257), h = r2.dmax, u = r2.wsize, l = r2.whave, f = r2.wnext, c = r2.window, d = r2.hold, p = r2.bits, m = r2.lencode, _ = r2.distcode, g = (1 << r2.lenbits) - 1, b = (1 << r2.distbits) - 1;
3346
- e: do {
3347
- p < 15 && (d += z[n++] << p, p += 8, d += z[n++] << p, p += 8), v = m[d & g];
3348
- t: for (; ; ) {
3349
- if (d >>>= y = v >>> 24, p -= y, 0 === (y = v >>> 16 & 255)) C[s++] = 65535 & v;
3350
- else {
3351
- if (!(16 & y)) {
3352
- if (0 == (64 & y)) {
3353
- v = m[(65535 & v) + (d & (1 << y) - 1)];
3354
- continue t;
3355
- }
3356
- if (32 & y) {
3357
- r2.mode = 12;
3358
- break e;
3359
- }
3360
- e2.msg = "invalid literal/length code", r2.mode = 30;
3361
- break e;
3362
- }
3363
- w = 65535 & v, (y &= 15) && (p < y && (d += z[n++] << p, p += 8), w += d & (1 << y) - 1, d >>>= y, p -= y), p < 15 && (d += z[n++] << p, p += 8, d += z[n++] << p, p += 8), v = _[d & b];
3364
- r: for (; ; ) {
3365
- if (d >>>= y = v >>> 24, p -= y, !(16 & (y = v >>> 16 & 255))) {
3366
- if (0 == (64 & y)) {
3367
- v = _[(65535 & v) + (d & (1 << y) - 1)];
3368
- continue r;
3369
- }
3370
- e2.msg = "invalid distance code", r2.mode = 30;
3371
- break e;
3372
- }
3373
- if (k = 65535 & v, p < (y &= 15) && (d += z[n++] << p, (p += 8) < y && (d += z[n++] << p, p += 8)), h < (k += d & (1 << y) - 1)) {
3374
- e2.msg = "invalid distance too far back", r2.mode = 30;
3375
- break e;
3376
- }
3377
- if (d >>>= y, p -= y, (y = s - a) < k) {
3378
- if (l < (y = k - y) && r2.sane) {
3379
- e2.msg = "invalid distance too far back", r2.mode = 30;
3380
- break e;
3381
- }
3382
- if (S = c, (x = 0) === f) {
3383
- if (x += u - y, y < w) {
3384
- for (w -= y; C[s++] = c[x++], --y; ) ;
3385
- x = s - k, S = C;
3386
- }
3387
- } else if (f < y) {
3388
- if (x += u + f - y, (y -= f) < w) {
3389
- for (w -= y; C[s++] = c[x++], --y; ) ;
3390
- if (x = 0, f < w) {
3391
- for (w -= y = f; C[s++] = c[x++], --y; ) ;
3392
- x = s - k, S = C;
3393
- }
3394
- }
3395
- } else if (x += f - y, y < w) {
3396
- for (w -= y; C[s++] = c[x++], --y; ) ;
3397
- x = s - k, S = C;
3398
- }
3399
- for (; 2 < w; ) C[s++] = S[x++], C[s++] = S[x++], C[s++] = S[x++], w -= 3;
3400
- w && (C[s++] = S[x++], 1 < w && (C[s++] = S[x++]));
3401
- } else {
3402
- for (x = s - k; C[s++] = C[x++], C[s++] = C[x++], C[s++] = C[x++], 2 < (w -= 3); ) ;
3403
- w && (C[s++] = C[x++], 1 < w && (C[s++] = C[x++]));
3404
- }
3405
- break;
3406
- }
3407
- }
3408
- break;
3409
- }
3410
- } while (n < i && s < o);
3411
- n -= w = p >> 3, d &= (1 << (p -= w << 3)) - 1, e2.next_in = n, e2.next_out = s, e2.avail_in = n < i ? i - n + 5 : 5 - (n - i), e2.avail_out = s < o ? o - s + 257 : 257 - (s - o), r2.hold = d, r2.bits = p;
3412
- };
3413
- }, {}], 49: [function(e, t, r) {
3414
- var I = e("../utils/common"), O = e("./adler32"), B = e("./crc32"), R = e("./inffast"), T = e("./inftrees"), D = 1, F = 2, N = 0, U = -2, P = 1, n = 852, i = 592;
3415
- function L(e2) {
3416
- return (e2 >>> 24 & 255) + (e2 >>> 8 & 65280) + ((65280 & e2) << 8) + ((255 & e2) << 24);
3417
- }
3418
- function s() {
3419
- this.mode = 0, this.last = false, this.wrap = 0, this.havedict = false, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new I.Buf16(320), this.work = new I.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
3420
- }
3421
- function a(e2) {
3422
- var t2;
3423
- return e2 && e2.state ? (t2 = e2.state, e2.total_in = e2.total_out = t2.total = 0, e2.msg = "", t2.wrap && (e2.adler = 1 & t2.wrap), t2.mode = P, t2.last = 0, t2.havedict = 0, t2.dmax = 32768, t2.head = null, t2.hold = 0, t2.bits = 0, t2.lencode = t2.lendyn = new I.Buf32(n), t2.distcode = t2.distdyn = new I.Buf32(i), t2.sane = 1, t2.back = -1, N) : U;
3424
- }
3425
- function o(e2) {
3426
- var t2;
3427
- return e2 && e2.state ? ((t2 = e2.state).wsize = 0, t2.whave = 0, t2.wnext = 0, a(e2)) : U;
3428
- }
3429
- function h(e2, t2) {
3430
- var r2, n2;
3431
- return e2 && e2.state ? (n2 = e2.state, t2 < 0 ? (r2 = 0, t2 = -t2) : (r2 = 1 + (t2 >> 4), t2 < 48 && (t2 &= 15)), t2 && (t2 < 8 || 15 < t2) ? U : (null !== n2.window && n2.wbits !== t2 && (n2.window = null), n2.wrap = r2, n2.wbits = t2, o(e2))) : U;
3432
- }
3433
- function u(e2, t2) {
3434
- var r2, n2;
3435
- return e2 ? (n2 = new s(), (e2.state = n2).window = null, (r2 = h(e2, t2)) !== N && (e2.state = null), r2) : U;
3436
- }
3437
- var l, f, c = true;
3438
- function j(e2) {
3439
- if (c) {
3440
- var t2;
3441
- for (l = new I.Buf32(512), f = new I.Buf32(32), t2 = 0; t2 < 144; ) e2.lens[t2++] = 8;
3442
- for (; t2 < 256; ) e2.lens[t2++] = 9;
3443
- for (; t2 < 280; ) e2.lens[t2++] = 7;
3444
- for (; t2 < 288; ) e2.lens[t2++] = 8;
3445
- for (T(D, e2.lens, 0, 288, l, 0, e2.work, { bits: 9 }), t2 = 0; t2 < 32; ) e2.lens[t2++] = 5;
3446
- T(F, e2.lens, 0, 32, f, 0, e2.work, { bits: 5 }), c = false;
3447
- }
3448
- e2.lencode = l, e2.lenbits = 9, e2.distcode = f, e2.distbits = 5;
3449
- }
3450
- function Z(e2, t2, r2, n2) {
3451
- var i2, s2 = e2.state;
3452
- return null === s2.window && (s2.wsize = 1 << s2.wbits, s2.wnext = 0, s2.whave = 0, s2.window = new I.Buf8(s2.wsize)), n2 >= s2.wsize ? (I.arraySet(s2.window, t2, r2 - s2.wsize, s2.wsize, 0), s2.wnext = 0, s2.whave = s2.wsize) : (n2 < (i2 = s2.wsize - s2.wnext) && (i2 = n2), I.arraySet(s2.window, t2, r2 - n2, i2, s2.wnext), (n2 -= i2) ? (I.arraySet(s2.window, t2, r2 - n2, n2, 0), s2.wnext = n2, s2.whave = s2.wsize) : (s2.wnext += i2, s2.wnext === s2.wsize && (s2.wnext = 0), s2.whave < s2.wsize && (s2.whave += i2))), 0;
3453
- }
3454
- r.inflateReset = o, r.inflateReset2 = h, r.inflateResetKeep = a, r.inflateInit = function(e2) {
3455
- return u(e2, 15);
3456
- }, r.inflateInit2 = u, r.inflate = function(e2, t2) {
3457
- var r2, n2, i2, s2, a2, o2, h2, u2, l2, f2, c2, d, p, m, _, g, b, v, y, w, k, x, S, z, C = 0, E = new I.Buf8(4), A = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
3458
- if (!e2 || !e2.state || !e2.output || !e2.input && 0 !== e2.avail_in) return U;
3459
- 12 === (r2 = e2.state).mode && (r2.mode = 13), a2 = e2.next_out, i2 = e2.output, h2 = e2.avail_out, s2 = e2.next_in, n2 = e2.input, o2 = e2.avail_in, u2 = r2.hold, l2 = r2.bits, f2 = o2, c2 = h2, x = N;
3460
- e: for (; ; ) switch (r2.mode) {
3461
- case P:
3462
- if (0 === r2.wrap) {
3463
- r2.mode = 13;
3464
- break;
3465
- }
3466
- for (; l2 < 16; ) {
3467
- if (0 === o2) break e;
3468
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3469
- }
3470
- if (2 & r2.wrap && 35615 === u2) {
3471
- E[r2.check = 0] = 255 & u2, E[1] = u2 >>> 8 & 255, r2.check = B(r2.check, E, 2, 0), l2 = u2 = 0, r2.mode = 2;
3472
- break;
3473
- }
3474
- if (r2.flags = 0, r2.head && (r2.head.done = false), !(1 & r2.wrap) || (((255 & u2) << 8) + (u2 >> 8)) % 31) {
3475
- e2.msg = "incorrect header check", r2.mode = 30;
3476
- break;
3477
- }
3478
- if (8 != (15 & u2)) {
3479
- e2.msg = "unknown compression method", r2.mode = 30;
3480
- break;
3481
- }
3482
- if (l2 -= 4, k = 8 + (15 & (u2 >>>= 4)), 0 === r2.wbits) r2.wbits = k;
3483
- else if (k > r2.wbits) {
3484
- e2.msg = "invalid window size", r2.mode = 30;
3485
- break;
3486
- }
3487
- r2.dmax = 1 << k, e2.adler = r2.check = 1, r2.mode = 512 & u2 ? 10 : 12, l2 = u2 = 0;
3488
- break;
3489
- case 2:
3490
- for (; l2 < 16; ) {
3491
- if (0 === o2) break e;
3492
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3493
- }
3494
- if (r2.flags = u2, 8 != (255 & r2.flags)) {
3495
- e2.msg = "unknown compression method", r2.mode = 30;
3496
- break;
3497
- }
3498
- if (57344 & r2.flags) {
3499
- e2.msg = "unknown header flags set", r2.mode = 30;
3500
- break;
3501
- }
3502
- r2.head && (r2.head.text = u2 >> 8 & 1), 512 & r2.flags && (E[0] = 255 & u2, E[1] = u2 >>> 8 & 255, r2.check = B(r2.check, E, 2, 0)), l2 = u2 = 0, r2.mode = 3;
3503
- case 3:
3504
- for (; l2 < 32; ) {
3505
- if (0 === o2) break e;
3506
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3507
- }
3508
- r2.head && (r2.head.time = u2), 512 & r2.flags && (E[0] = 255 & u2, E[1] = u2 >>> 8 & 255, E[2] = u2 >>> 16 & 255, E[3] = u2 >>> 24 & 255, r2.check = B(r2.check, E, 4, 0)), l2 = u2 = 0, r2.mode = 4;
3509
- case 4:
3510
- for (; l2 < 16; ) {
3511
- if (0 === o2) break e;
3512
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3513
- }
3514
- r2.head && (r2.head.xflags = 255 & u2, r2.head.os = u2 >> 8), 512 & r2.flags && (E[0] = 255 & u2, E[1] = u2 >>> 8 & 255, r2.check = B(r2.check, E, 2, 0)), l2 = u2 = 0, r2.mode = 5;
3515
- case 5:
3516
- if (1024 & r2.flags) {
3517
- for (; l2 < 16; ) {
3518
- if (0 === o2) break e;
3519
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3520
- }
3521
- r2.length = u2, r2.head && (r2.head.extra_len = u2), 512 & r2.flags && (E[0] = 255 & u2, E[1] = u2 >>> 8 & 255, r2.check = B(r2.check, E, 2, 0)), l2 = u2 = 0;
3522
- } else r2.head && (r2.head.extra = null);
3523
- r2.mode = 6;
3524
- case 6:
3525
- if (1024 & r2.flags && (o2 < (d = r2.length) && (d = o2), d && (r2.head && (k = r2.head.extra_len - r2.length, r2.head.extra || (r2.head.extra = new Array(r2.head.extra_len)), I.arraySet(r2.head.extra, n2, s2, d, k)), 512 & r2.flags && (r2.check = B(r2.check, n2, d, s2)), o2 -= d, s2 += d, r2.length -= d), r2.length)) break e;
3526
- r2.length = 0, r2.mode = 7;
3527
- case 7:
3528
- if (2048 & r2.flags) {
3529
- if (0 === o2) break e;
3530
- for (d = 0; k = n2[s2 + d++], r2.head && k && r2.length < 65536 && (r2.head.name += String.fromCharCode(k)), k && d < o2; ) ;
3531
- if (512 & r2.flags && (r2.check = B(r2.check, n2, d, s2)), o2 -= d, s2 += d, k) break e;
3532
- } else r2.head && (r2.head.name = null);
3533
- r2.length = 0, r2.mode = 8;
3534
- case 8:
3535
- if (4096 & r2.flags) {
3536
- if (0 === o2) break e;
3537
- for (d = 0; k = n2[s2 + d++], r2.head && k && r2.length < 65536 && (r2.head.comment += String.fromCharCode(k)), k && d < o2; ) ;
3538
- if (512 & r2.flags && (r2.check = B(r2.check, n2, d, s2)), o2 -= d, s2 += d, k) break e;
3539
- } else r2.head && (r2.head.comment = null);
3540
- r2.mode = 9;
3541
- case 9:
3542
- if (512 & r2.flags) {
3543
- for (; l2 < 16; ) {
3544
- if (0 === o2) break e;
3545
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3546
- }
3547
- if (u2 !== (65535 & r2.check)) {
3548
- e2.msg = "header crc mismatch", r2.mode = 30;
3549
- break;
3550
- }
3551
- l2 = u2 = 0;
3552
- }
3553
- r2.head && (r2.head.hcrc = r2.flags >> 9 & 1, r2.head.done = true), e2.adler = r2.check = 0, r2.mode = 12;
3554
- break;
3555
- case 10:
3556
- for (; l2 < 32; ) {
3557
- if (0 === o2) break e;
3558
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3559
- }
3560
- e2.adler = r2.check = L(u2), l2 = u2 = 0, r2.mode = 11;
3561
- case 11:
3562
- if (0 === r2.havedict) return e2.next_out = a2, e2.avail_out = h2, e2.next_in = s2, e2.avail_in = o2, r2.hold = u2, r2.bits = l2, 2;
3563
- e2.adler = r2.check = 1, r2.mode = 12;
3564
- case 12:
3565
- if (5 === t2 || 6 === t2) break e;
3566
- case 13:
3567
- if (r2.last) {
3568
- u2 >>>= 7 & l2, l2 -= 7 & l2, r2.mode = 27;
3569
- break;
3570
- }
3571
- for (; l2 < 3; ) {
3572
- if (0 === o2) break e;
3573
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3574
- }
3575
- switch (r2.last = 1 & u2, l2 -= 1, 3 & (u2 >>>= 1)) {
3576
- case 0:
3577
- r2.mode = 14;
3578
- break;
3579
- case 1:
3580
- if (j(r2), r2.mode = 20, 6 !== t2) break;
3581
- u2 >>>= 2, l2 -= 2;
3582
- break e;
3583
- case 2:
3584
- r2.mode = 17;
3585
- break;
3586
- case 3:
3587
- e2.msg = "invalid block type", r2.mode = 30;
3588
- }
3589
- u2 >>>= 2, l2 -= 2;
3590
- break;
3591
- case 14:
3592
- for (u2 >>>= 7 & l2, l2 -= 7 & l2; l2 < 32; ) {
3593
- if (0 === o2) break e;
3594
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3595
- }
3596
- if ((65535 & u2) != (u2 >>> 16 ^ 65535)) {
3597
- e2.msg = "invalid stored block lengths", r2.mode = 30;
3598
- break;
3599
- }
3600
- if (r2.length = 65535 & u2, l2 = u2 = 0, r2.mode = 15, 6 === t2) break e;
3601
- case 15:
3602
- r2.mode = 16;
3603
- case 16:
3604
- if (d = r2.length) {
3605
- if (o2 < d && (d = o2), h2 < d && (d = h2), 0 === d) break e;
3606
- I.arraySet(i2, n2, s2, d, a2), o2 -= d, s2 += d, h2 -= d, a2 += d, r2.length -= d;
3607
- break;
3608
- }
3609
- r2.mode = 12;
3610
- break;
3611
- case 17:
3612
- for (; l2 < 14; ) {
3613
- if (0 === o2) break e;
3614
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3615
- }
3616
- if (r2.nlen = 257 + (31 & u2), u2 >>>= 5, l2 -= 5, r2.ndist = 1 + (31 & u2), u2 >>>= 5, l2 -= 5, r2.ncode = 4 + (15 & u2), u2 >>>= 4, l2 -= 4, 286 < r2.nlen || 30 < r2.ndist) {
3617
- e2.msg = "too many length or distance symbols", r2.mode = 30;
3618
- break;
3619
- }
3620
- r2.have = 0, r2.mode = 18;
3621
- case 18:
3622
- for (; r2.have < r2.ncode; ) {
3623
- for (; l2 < 3; ) {
3624
- if (0 === o2) break e;
3625
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3626
- }
3627
- r2.lens[A[r2.have++]] = 7 & u2, u2 >>>= 3, l2 -= 3;
3628
- }
3629
- for (; r2.have < 19; ) r2.lens[A[r2.have++]] = 0;
3630
- if (r2.lencode = r2.lendyn, r2.lenbits = 7, S = { bits: r2.lenbits }, x = T(0, r2.lens, 0, 19, r2.lencode, 0, r2.work, S), r2.lenbits = S.bits, x) {
3631
- e2.msg = "invalid code lengths set", r2.mode = 30;
3632
- break;
3633
- }
3634
- r2.have = 0, r2.mode = 19;
3635
- case 19:
3636
- for (; r2.have < r2.nlen + r2.ndist; ) {
3637
- for (; g = (C = r2.lencode[u2 & (1 << r2.lenbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l2); ) {
3638
- if (0 === o2) break e;
3639
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3640
- }
3641
- if (b < 16) u2 >>>= _, l2 -= _, r2.lens[r2.have++] = b;
3642
- else {
3643
- if (16 === b) {
3644
- for (z = _ + 2; l2 < z; ) {
3645
- if (0 === o2) break e;
3646
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3647
- }
3648
- if (u2 >>>= _, l2 -= _, 0 === r2.have) {
3649
- e2.msg = "invalid bit length repeat", r2.mode = 30;
3650
- break;
3651
- }
3652
- k = r2.lens[r2.have - 1], d = 3 + (3 & u2), u2 >>>= 2, l2 -= 2;
3653
- } else if (17 === b) {
3654
- for (z = _ + 3; l2 < z; ) {
3655
- if (0 === o2) break e;
3656
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3657
- }
3658
- l2 -= _, k = 0, d = 3 + (7 & (u2 >>>= _)), u2 >>>= 3, l2 -= 3;
3659
- } else {
3660
- for (z = _ + 7; l2 < z; ) {
3661
- if (0 === o2) break e;
3662
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3663
- }
3664
- l2 -= _, k = 0, d = 11 + (127 & (u2 >>>= _)), u2 >>>= 7, l2 -= 7;
3665
- }
3666
- if (r2.have + d > r2.nlen + r2.ndist) {
3667
- e2.msg = "invalid bit length repeat", r2.mode = 30;
3668
- break;
3669
- }
3670
- for (; d--; ) r2.lens[r2.have++] = k;
3671
- }
3672
- }
3673
- if (30 === r2.mode) break;
3674
- if (0 === r2.lens[256]) {
3675
- e2.msg = "invalid code -- missing end-of-block", r2.mode = 30;
3676
- break;
3677
- }
3678
- if (r2.lenbits = 9, S = { bits: r2.lenbits }, x = T(D, r2.lens, 0, r2.nlen, r2.lencode, 0, r2.work, S), r2.lenbits = S.bits, x) {
3679
- e2.msg = "invalid literal/lengths set", r2.mode = 30;
3680
- break;
3681
- }
3682
- if (r2.distbits = 6, r2.distcode = r2.distdyn, S = { bits: r2.distbits }, x = T(F, r2.lens, r2.nlen, r2.ndist, r2.distcode, 0, r2.work, S), r2.distbits = S.bits, x) {
3683
- e2.msg = "invalid distances set", r2.mode = 30;
3684
- break;
3685
- }
3686
- if (r2.mode = 20, 6 === t2) break e;
3687
- case 20:
3688
- r2.mode = 21;
3689
- case 21:
3690
- if (6 <= o2 && 258 <= h2) {
3691
- e2.next_out = a2, e2.avail_out = h2, e2.next_in = s2, e2.avail_in = o2, r2.hold = u2, r2.bits = l2, R(e2, c2), a2 = e2.next_out, i2 = e2.output, h2 = e2.avail_out, s2 = e2.next_in, n2 = e2.input, o2 = e2.avail_in, u2 = r2.hold, l2 = r2.bits, 12 === r2.mode && (r2.back = -1);
3692
- break;
3693
- }
3694
- for (r2.back = 0; g = (C = r2.lencode[u2 & (1 << r2.lenbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l2); ) {
3695
- if (0 === o2) break e;
3696
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3697
- }
3698
- if (g && 0 == (240 & g)) {
3699
- for (v = _, y = g, w = b; g = (C = r2.lencode[w + ((u2 & (1 << v + y) - 1) >> v)]) >>> 16 & 255, b = 65535 & C, !(v + (_ = C >>> 24) <= l2); ) {
3700
- if (0 === o2) break e;
3701
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3702
- }
3703
- u2 >>>= v, l2 -= v, r2.back += v;
3704
- }
3705
- if (u2 >>>= _, l2 -= _, r2.back += _, r2.length = b, 0 === g) {
3706
- r2.mode = 26;
3707
- break;
3708
- }
3709
- if (32 & g) {
3710
- r2.back = -1, r2.mode = 12;
3711
- break;
3712
- }
3713
- if (64 & g) {
3714
- e2.msg = "invalid literal/length code", r2.mode = 30;
3715
- break;
3716
- }
3717
- r2.extra = 15 & g, r2.mode = 22;
3718
- case 22:
3719
- if (r2.extra) {
3720
- for (z = r2.extra; l2 < z; ) {
3721
- if (0 === o2) break e;
3722
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3723
- }
3724
- r2.length += u2 & (1 << r2.extra) - 1, u2 >>>= r2.extra, l2 -= r2.extra, r2.back += r2.extra;
3725
- }
3726
- r2.was = r2.length, r2.mode = 23;
3727
- case 23:
3728
- for (; g = (C = r2.distcode[u2 & (1 << r2.distbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l2); ) {
3729
- if (0 === o2) break e;
3730
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3731
- }
3732
- if (0 == (240 & g)) {
3733
- for (v = _, y = g, w = b; g = (C = r2.distcode[w + ((u2 & (1 << v + y) - 1) >> v)]) >>> 16 & 255, b = 65535 & C, !(v + (_ = C >>> 24) <= l2); ) {
3734
- if (0 === o2) break e;
3735
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3736
- }
3737
- u2 >>>= v, l2 -= v, r2.back += v;
3738
- }
3739
- if (u2 >>>= _, l2 -= _, r2.back += _, 64 & g) {
3740
- e2.msg = "invalid distance code", r2.mode = 30;
3741
- break;
3742
- }
3743
- r2.offset = b, r2.extra = 15 & g, r2.mode = 24;
3744
- case 24:
3745
- if (r2.extra) {
3746
- for (z = r2.extra; l2 < z; ) {
3747
- if (0 === o2) break e;
3748
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3749
- }
3750
- r2.offset += u2 & (1 << r2.extra) - 1, u2 >>>= r2.extra, l2 -= r2.extra, r2.back += r2.extra;
3751
- }
3752
- if (r2.offset > r2.dmax) {
3753
- e2.msg = "invalid distance too far back", r2.mode = 30;
3754
- break;
3755
- }
3756
- r2.mode = 25;
3757
- case 25:
3758
- if (0 === h2) break e;
3759
- if (d = c2 - h2, r2.offset > d) {
3760
- if ((d = r2.offset - d) > r2.whave && r2.sane) {
3761
- e2.msg = "invalid distance too far back", r2.mode = 30;
3762
- break;
3763
- }
3764
- p = d > r2.wnext ? (d -= r2.wnext, r2.wsize - d) : r2.wnext - d, d > r2.length && (d = r2.length), m = r2.window;
3765
- } else m = i2, p = a2 - r2.offset, d = r2.length;
3766
- for (h2 < d && (d = h2), h2 -= d, r2.length -= d; i2[a2++] = m[p++], --d; ) ;
3767
- 0 === r2.length && (r2.mode = 21);
3768
- break;
3769
- case 26:
3770
- if (0 === h2) break e;
3771
- i2[a2++] = r2.length, h2--, r2.mode = 21;
3772
- break;
3773
- case 27:
3774
- if (r2.wrap) {
3775
- for (; l2 < 32; ) {
3776
- if (0 === o2) break e;
3777
- o2--, u2 |= n2[s2++] << l2, l2 += 8;
3778
- }
3779
- if (c2 -= h2, e2.total_out += c2, r2.total += c2, c2 && (e2.adler = r2.check = r2.flags ? B(r2.check, i2, c2, a2 - c2) : O(r2.check, i2, c2, a2 - c2)), c2 = h2, (r2.flags ? u2 : L(u2)) !== r2.check) {
3780
- e2.msg = "incorrect data check", r2.mode = 30;
3781
- break;
3782
- }
3783
- l2 = u2 = 0;
3784
- }
3785
- r2.mode = 28;
3786
- case 28:
3787
- if (r2.wrap && r2.flags) {
3788
- for (; l2 < 32; ) {
3789
- if (0 === o2) break e;
3790
- o2--, u2 += n2[s2++] << l2, l2 += 8;
3791
- }
3792
- if (u2 !== (4294967295 & r2.total)) {
3793
- e2.msg = "incorrect length check", r2.mode = 30;
3794
- break;
3795
- }
3796
- l2 = u2 = 0;
3797
- }
3798
- r2.mode = 29;
3799
- case 29:
3800
- x = 1;
3801
- break e;
3802
- case 30:
3803
- x = -3;
3804
- break e;
3805
- case 31:
3806
- return -4;
3807
- case 32:
3808
- default:
3809
- return U;
3810
- }
3811
- return e2.next_out = a2, e2.avail_out = h2, e2.next_in = s2, e2.avail_in = o2, r2.hold = u2, r2.bits = l2, (r2.wsize || c2 !== e2.avail_out && r2.mode < 30 && (r2.mode < 27 || 4 !== t2)) && Z(e2, e2.output, e2.next_out, c2 - e2.avail_out) ? (r2.mode = 31, -4) : (f2 -= e2.avail_in, c2 -= e2.avail_out, e2.total_in += f2, e2.total_out += c2, r2.total += c2, r2.wrap && c2 && (e2.adler = r2.check = r2.flags ? B(r2.check, i2, c2, e2.next_out - c2) : O(r2.check, i2, c2, e2.next_out - c2)), e2.data_type = r2.bits + (r2.last ? 64 : 0) + (12 === r2.mode ? 128 : 0) + (20 === r2.mode || 15 === r2.mode ? 256 : 0), (0 == f2 && 0 === c2 || 4 === t2) && x === N && (x = -5), x);
3812
- }, r.inflateEnd = function(e2) {
3813
- if (!e2 || !e2.state) return U;
3814
- var t2 = e2.state;
3815
- return t2.window && (t2.window = null), e2.state = null, N;
3816
- }, r.inflateGetHeader = function(e2, t2) {
3817
- var r2;
3818
- return e2 && e2.state ? 0 == (2 & (r2 = e2.state).wrap) ? U : ((r2.head = t2).done = false, N) : U;
3819
- }, r.inflateSetDictionary = function(e2, t2) {
3820
- var r2, n2 = t2.length;
3821
- return e2 && e2.state ? 0 !== (r2 = e2.state).wrap && 11 !== r2.mode ? U : 11 === r2.mode && O(1, t2, n2, 0) !== r2.check ? -3 : Z(e2, t2, n2, n2) ? (r2.mode = 31, -4) : (r2.havedict = 1, N) : U;
3822
- }, r.inflateInfo = "pako inflate (from Nodeca project)";
3823
- }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(e, t, r) {
3824
- var D = e("../utils/common"), F = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], N = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], U = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0], P = [16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
3825
- t.exports = function(e2, t2, r2, n, i, s, a, o) {
3826
- var h, u, l, f, c, d, p, m, _, g = o.bits, b = 0, v = 0, y = 0, w = 0, k = 0, x = 0, S = 0, z = 0, C = 0, E = 0, A = null, I = 0, O = new D.Buf16(16), B = new D.Buf16(16), R = null, T = 0;
3827
- for (b = 0; b <= 15; b++) O[b] = 0;
3828
- for (v = 0; v < n; v++) O[t2[r2 + v]]++;
3829
- for (k = g, w = 15; 1 <= w && 0 === O[w]; w--) ;
3830
- if (w < k && (k = w), 0 === w) return i[s++] = 20971520, i[s++] = 20971520, o.bits = 1, 0;
3831
- for (y = 1; y < w && 0 === O[y]; y++) ;
3832
- for (k < y && (k = y), b = z = 1; b <= 15; b++) if (z <<= 1, (z -= O[b]) < 0) return -1;
3833
- if (0 < z && (0 === e2 || 1 !== w)) return -1;
3834
- for (B[1] = 0, b = 1; b < 15; b++) B[b + 1] = B[b] + O[b];
3835
- for (v = 0; v < n; v++) 0 !== t2[r2 + v] && (a[B[t2[r2 + v]]++] = v);
3836
- if (d = 0 === e2 ? (A = R = a, 19) : 1 === e2 ? (A = F, I -= 257, R = N, T -= 257, 256) : (A = U, R = P, -1), b = y, c = s, S = v = E = 0, l = -1, f = (C = 1 << (x = k)) - 1, 1 === e2 && 852 < C || 2 === e2 && 592 < C) return 1;
3837
- for (; ; ) {
3838
- for (p = b - S, _ = a[v] < d ? (m = 0, a[v]) : a[v] > d ? (m = R[T + a[v]], A[I + a[v]]) : (m = 96, 0), h = 1 << b - S, y = u = 1 << x; i[c + (E >> S) + (u -= h)] = p << 24 | m << 16 | _ | 0, 0 !== u; ) ;
3839
- for (h = 1 << b - 1; E & h; ) h >>= 1;
3840
- if (0 !== h ? (E &= h - 1, E += h) : E = 0, v++, 0 == --O[b]) {
3841
- if (b === w) break;
3842
- b = t2[r2 + a[v]];
3843
- }
3844
- if (k < b && (E & f) !== l) {
3845
- for (0 === S && (S = k), c += y, z = 1 << (x = b - S); x + S < w && !((z -= O[x + S]) <= 0); ) x++, z <<= 1;
3846
- if (C += 1 << x, 1 === e2 && 852 < C || 2 === e2 && 592 < C) return 1;
3847
- i[l = E & f] = k << 24 | x << 16 | c - s | 0;
3848
- }
3849
- }
3850
- return 0 !== E && (i[c + E] = b - S << 24 | 64 << 16 | 0), o.bits = k, 0;
3851
- };
3852
- }, { "../utils/common": 41 }], 51: [function(e, t, r) {
3853
- t.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" };
3854
- }, {}], 52: [function(e, t, r) {
3855
- var i = e("../utils/common"), o = 0, h = 1;
3856
- function n(e2) {
3857
- for (var t2 = e2.length; 0 <= --t2; ) e2[t2] = 0;
3858
- }
3859
- var s = 0, a = 29, u = 256, l = u + 1 + a, f = 30, c = 19, _ = 2 * l + 1, g = 15, d = 16, p = 7, m = 256, b = 16, v = 17, y = 18, w = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], k = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], x = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], S = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], z = new Array(2 * (l + 2));
3860
- n(z);
3861
- var C = new Array(2 * f);
3862
- n(C);
3863
- var E = new Array(512);
3864
- n(E);
3865
- var A = new Array(256);
3866
- n(A);
3867
- var I = new Array(a);
3868
- n(I);
3869
- var O, B, R, T = new Array(f);
3870
- function D(e2, t2, r2, n2, i2) {
3871
- this.static_tree = e2, this.extra_bits = t2, this.extra_base = r2, this.elems = n2, this.max_length = i2, this.has_stree = e2 && e2.length;
3872
- }
3873
- function F(e2, t2) {
3874
- this.dyn_tree = e2, this.max_code = 0, this.stat_desc = t2;
3875
- }
3876
- function N(e2) {
3877
- return e2 < 256 ? E[e2] : E[256 + (e2 >>> 7)];
3878
- }
3879
- function U(e2, t2) {
3880
- e2.pending_buf[e2.pending++] = 255 & t2, e2.pending_buf[e2.pending++] = t2 >>> 8 & 255;
3881
- }
3882
- function P(e2, t2, r2) {
3883
- e2.bi_valid > d - r2 ? (e2.bi_buf |= t2 << e2.bi_valid & 65535, U(e2, e2.bi_buf), e2.bi_buf = t2 >> d - e2.bi_valid, e2.bi_valid += r2 - d) : (e2.bi_buf |= t2 << e2.bi_valid & 65535, e2.bi_valid += r2);
3884
- }
3885
- function L(e2, t2, r2) {
3886
- P(e2, r2[2 * t2], r2[2 * t2 + 1]);
3887
- }
3888
- function j(e2, t2) {
3889
- for (var r2 = 0; r2 |= 1 & e2, e2 >>>= 1, r2 <<= 1, 0 < --t2; ) ;
3890
- return r2 >>> 1;
3891
- }
3892
- function Z(e2, t2, r2) {
3893
- var n2, i2, s2 = new Array(g + 1), a2 = 0;
3894
- for (n2 = 1; n2 <= g; n2++) s2[n2] = a2 = a2 + r2[n2 - 1] << 1;
3895
- for (i2 = 0; i2 <= t2; i2++) {
3896
- var o2 = e2[2 * i2 + 1];
3897
- 0 !== o2 && (e2[2 * i2] = j(s2[o2]++, o2));
3898
- }
3899
- }
3900
- function W(e2) {
3901
- var t2;
3902
- for (t2 = 0; t2 < l; t2++) e2.dyn_ltree[2 * t2] = 0;
3903
- for (t2 = 0; t2 < f; t2++) e2.dyn_dtree[2 * t2] = 0;
3904
- for (t2 = 0; t2 < c; t2++) e2.bl_tree[2 * t2] = 0;
3905
- e2.dyn_ltree[2 * m] = 1, e2.opt_len = e2.static_len = 0, e2.last_lit = e2.matches = 0;
3906
- }
3907
- function M(e2) {
3908
- 8 < e2.bi_valid ? U(e2, e2.bi_buf) : 0 < e2.bi_valid && (e2.pending_buf[e2.pending++] = e2.bi_buf), e2.bi_buf = 0, e2.bi_valid = 0;
3909
- }
3910
- function H(e2, t2, r2, n2) {
3911
- var i2 = 2 * t2, s2 = 2 * r2;
3912
- return e2[i2] < e2[s2] || e2[i2] === e2[s2] && n2[t2] <= n2[r2];
3913
- }
3914
- function G(e2, t2, r2) {
3915
- for (var n2 = e2.heap[r2], i2 = r2 << 1; i2 <= e2.heap_len && (i2 < e2.heap_len && H(t2, e2.heap[i2 + 1], e2.heap[i2], e2.depth) && i2++, !H(t2, n2, e2.heap[i2], e2.depth)); ) e2.heap[r2] = e2.heap[i2], r2 = i2, i2 <<= 1;
3916
- e2.heap[r2] = n2;
3917
- }
3918
- function K(e2, t2, r2) {
3919
- var n2, i2, s2, a2, o2 = 0;
3920
- if (0 !== e2.last_lit) for (; n2 = e2.pending_buf[e2.d_buf + 2 * o2] << 8 | e2.pending_buf[e2.d_buf + 2 * o2 + 1], i2 = e2.pending_buf[e2.l_buf + o2], o2++, 0 === n2 ? L(e2, i2, t2) : (L(e2, (s2 = A[i2]) + u + 1, t2), 0 !== (a2 = w[s2]) && P(e2, i2 -= I[s2], a2), L(e2, s2 = N(--n2), r2), 0 !== (a2 = k[s2]) && P(e2, n2 -= T[s2], a2)), o2 < e2.last_lit; ) ;
3921
- L(e2, m, t2);
3922
- }
3923
- function Y(e2, t2) {
3924
- var r2, n2, i2, s2 = t2.dyn_tree, a2 = t2.stat_desc.static_tree, o2 = t2.stat_desc.has_stree, h2 = t2.stat_desc.elems, u2 = -1;
3925
- for (e2.heap_len = 0, e2.heap_max = _, r2 = 0; r2 < h2; r2++) 0 !== s2[2 * r2] ? (e2.heap[++e2.heap_len] = u2 = r2, e2.depth[r2] = 0) : s2[2 * r2 + 1] = 0;
3926
- for (; e2.heap_len < 2; ) s2[2 * (i2 = e2.heap[++e2.heap_len] = u2 < 2 ? ++u2 : 0)] = 1, e2.depth[i2] = 0, e2.opt_len--, o2 && (e2.static_len -= a2[2 * i2 + 1]);
3927
- for (t2.max_code = u2, r2 = e2.heap_len >> 1; 1 <= r2; r2--) G(e2, s2, r2);
3928
- for (i2 = h2; r2 = e2.heap[1], e2.heap[1] = e2.heap[e2.heap_len--], G(e2, s2, 1), n2 = e2.heap[1], e2.heap[--e2.heap_max] = r2, e2.heap[--e2.heap_max] = n2, s2[2 * i2] = s2[2 * r2] + s2[2 * n2], e2.depth[i2] = (e2.depth[r2] >= e2.depth[n2] ? e2.depth[r2] : e2.depth[n2]) + 1, s2[2 * r2 + 1] = s2[2 * n2 + 1] = i2, e2.heap[1] = i2++, G(e2, s2, 1), 2 <= e2.heap_len; ) ;
3929
- e2.heap[--e2.heap_max] = e2.heap[1], function(e3, t3) {
3930
- var r3, n3, i3, s3, a3, o3, h3 = t3.dyn_tree, u3 = t3.max_code, l2 = t3.stat_desc.static_tree, f2 = t3.stat_desc.has_stree, c2 = t3.stat_desc.extra_bits, d2 = t3.stat_desc.extra_base, p2 = t3.stat_desc.max_length, m2 = 0;
3931
- for (s3 = 0; s3 <= g; s3++) e3.bl_count[s3] = 0;
3932
- for (h3[2 * e3.heap[e3.heap_max] + 1] = 0, r3 = e3.heap_max + 1; r3 < _; r3++) p2 < (s3 = h3[2 * h3[2 * (n3 = e3.heap[r3]) + 1] + 1] + 1) && (s3 = p2, m2++), h3[2 * n3 + 1] = s3, u3 < n3 || (e3.bl_count[s3]++, a3 = 0, d2 <= n3 && (a3 = c2[n3 - d2]), o3 = h3[2 * n3], e3.opt_len += o3 * (s3 + a3), f2 && (e3.static_len += o3 * (l2[2 * n3 + 1] + a3)));
3933
- if (0 !== m2) {
3934
- do {
3935
- for (s3 = p2 - 1; 0 === e3.bl_count[s3]; ) s3--;
3936
- e3.bl_count[s3]--, e3.bl_count[s3 + 1] += 2, e3.bl_count[p2]--, m2 -= 2;
3937
- } while (0 < m2);
3938
- for (s3 = p2; 0 !== s3; s3--) for (n3 = e3.bl_count[s3]; 0 !== n3; ) u3 < (i3 = e3.heap[--r3]) || (h3[2 * i3 + 1] !== s3 && (e3.opt_len += (s3 - h3[2 * i3 + 1]) * h3[2 * i3], h3[2 * i3 + 1] = s3), n3--);
3939
- }
3940
- }(e2, t2), Z(s2, u2, e2.bl_count);
3941
- }
3942
- function X(e2, t2, r2) {
3943
- var n2, i2, s2 = -1, a2 = t2[1], o2 = 0, h2 = 7, u2 = 4;
3944
- for (0 === a2 && (h2 = 138, u2 = 3), t2[2 * (r2 + 1) + 1] = 65535, n2 = 0; n2 <= r2; n2++) i2 = a2, a2 = t2[2 * (n2 + 1) + 1], ++o2 < h2 && i2 === a2 || (o2 < u2 ? e2.bl_tree[2 * i2] += o2 : 0 !== i2 ? (i2 !== s2 && e2.bl_tree[2 * i2]++, e2.bl_tree[2 * b]++) : o2 <= 10 ? e2.bl_tree[2 * v]++ : e2.bl_tree[2 * y]++, s2 = i2, u2 = (o2 = 0) === a2 ? (h2 = 138, 3) : i2 === a2 ? (h2 = 6, 3) : (h2 = 7, 4));
3945
- }
3946
- function V(e2, t2, r2) {
3947
- var n2, i2, s2 = -1, a2 = t2[1], o2 = 0, h2 = 7, u2 = 4;
3948
- for (0 === a2 && (h2 = 138, u2 = 3), n2 = 0; n2 <= r2; n2++) if (i2 = a2, a2 = t2[2 * (n2 + 1) + 1], !(++o2 < h2 && i2 === a2)) {
3949
- if (o2 < u2) for (; L(e2, i2, e2.bl_tree), 0 != --o2; ) ;
3950
- else 0 !== i2 ? (i2 !== s2 && (L(e2, i2, e2.bl_tree), o2--), L(e2, b, e2.bl_tree), P(e2, o2 - 3, 2)) : o2 <= 10 ? (L(e2, v, e2.bl_tree), P(e2, o2 - 3, 3)) : (L(e2, y, e2.bl_tree), P(e2, o2 - 11, 7));
3951
- s2 = i2, u2 = (o2 = 0) === a2 ? (h2 = 138, 3) : i2 === a2 ? (h2 = 6, 3) : (h2 = 7, 4);
3952
- }
3953
- }
3954
- n(T);
3955
- var q = false;
3956
- function J(e2, t2, r2, n2) {
3957
- P(e2, (s << 1) + (n2 ? 1 : 0), 3), function(e3, t3, r3, n3) {
3958
- M(e3), U(e3, r3), U(e3, ~r3), i.arraySet(e3.pending_buf, e3.window, t3, r3, e3.pending), e3.pending += r3;
3959
- }(e2, t2, r2);
3960
- }
3961
- r._tr_init = function(e2) {
3962
- q || (function() {
3963
- var e3, t2, r2, n2, i2, s2 = new Array(g + 1);
3964
- for (n2 = r2 = 0; n2 < a - 1; n2++) for (I[n2] = r2, e3 = 0; e3 < 1 << w[n2]; e3++) A[r2++] = n2;
3965
- for (A[r2 - 1] = n2, n2 = i2 = 0; n2 < 16; n2++) for (T[n2] = i2, e3 = 0; e3 < 1 << k[n2]; e3++) E[i2++] = n2;
3966
- for (i2 >>= 7; n2 < f; n2++) for (T[n2] = i2 << 7, e3 = 0; e3 < 1 << k[n2] - 7; e3++) E[256 + i2++] = n2;
3967
- for (t2 = 0; t2 <= g; t2++) s2[t2] = 0;
3968
- for (e3 = 0; e3 <= 143; ) z[2 * e3 + 1] = 8, e3++, s2[8]++;
3969
- for (; e3 <= 255; ) z[2 * e3 + 1] = 9, e3++, s2[9]++;
3970
- for (; e3 <= 279; ) z[2 * e3 + 1] = 7, e3++, s2[7]++;
3971
- for (; e3 <= 287; ) z[2 * e3 + 1] = 8, e3++, s2[8]++;
3972
- for (Z(z, l + 1, s2), e3 = 0; e3 < f; e3++) C[2 * e3 + 1] = 5, C[2 * e3] = j(e3, 5);
3973
- O = new D(z, w, u + 1, l, g), B = new D(C, k, 0, f, g), R = new D(new Array(0), x, 0, c, p);
3974
- }(), q = true), e2.l_desc = new F(e2.dyn_ltree, O), e2.d_desc = new F(e2.dyn_dtree, B), e2.bl_desc = new F(e2.bl_tree, R), e2.bi_buf = 0, e2.bi_valid = 0, W(e2);
3975
- }, r._tr_stored_block = J, r._tr_flush_block = function(e2, t2, r2, n2) {
3976
- var i2, s2, a2 = 0;
3977
- 0 < e2.level ? (2 === e2.strm.data_type && (e2.strm.data_type = function(e3) {
3978
- var t3, r3 = 4093624447;
3979
- for (t3 = 0; t3 <= 31; t3++, r3 >>>= 1) if (1 & r3 && 0 !== e3.dyn_ltree[2 * t3]) return o;
3980
- if (0 !== e3.dyn_ltree[18] || 0 !== e3.dyn_ltree[20] || 0 !== e3.dyn_ltree[26]) return h;
3981
- for (t3 = 32; t3 < u; t3++) if (0 !== e3.dyn_ltree[2 * t3]) return h;
3982
- return o;
3983
- }(e2)), Y(e2, e2.l_desc), Y(e2, e2.d_desc), a2 = function(e3) {
3984
- var t3;
3985
- for (X(e3, e3.dyn_ltree, e3.l_desc.max_code), X(e3, e3.dyn_dtree, e3.d_desc.max_code), Y(e3, e3.bl_desc), t3 = c - 1; 3 <= t3 && 0 === e3.bl_tree[2 * S[t3] + 1]; t3--) ;
3986
- return e3.opt_len += 3 * (t3 + 1) + 5 + 5 + 4, t3;
3987
- }(e2), i2 = e2.opt_len + 3 + 7 >>> 3, (s2 = e2.static_len + 3 + 7 >>> 3) <= i2 && (i2 = s2)) : i2 = s2 = r2 + 5, r2 + 4 <= i2 && -1 !== t2 ? J(e2, t2, r2, n2) : 4 === e2.strategy || s2 === i2 ? (P(e2, 2 + (n2 ? 1 : 0), 3), K(e2, z, C)) : (P(e2, 4 + (n2 ? 1 : 0), 3), function(e3, t3, r3, n3) {
3988
- var i3;
3989
- for (P(e3, t3 - 257, 5), P(e3, r3 - 1, 5), P(e3, n3 - 4, 4), i3 = 0; i3 < n3; i3++) P(e3, e3.bl_tree[2 * S[i3] + 1], 3);
3990
- V(e3, e3.dyn_ltree, t3 - 1), V(e3, e3.dyn_dtree, r3 - 1);
3991
- }(e2, e2.l_desc.max_code + 1, e2.d_desc.max_code + 1, a2 + 1), K(e2, e2.dyn_ltree, e2.dyn_dtree)), W(e2), n2 && M(e2);
3992
- }, r._tr_tally = function(e2, t2, r2) {
3993
- return e2.pending_buf[e2.d_buf + 2 * e2.last_lit] = t2 >>> 8 & 255, e2.pending_buf[e2.d_buf + 2 * e2.last_lit + 1] = 255 & t2, e2.pending_buf[e2.l_buf + e2.last_lit] = 255 & r2, e2.last_lit++, 0 === t2 ? e2.dyn_ltree[2 * r2]++ : (e2.matches++, t2--, e2.dyn_ltree[2 * (A[r2] + u + 1)]++, e2.dyn_dtree[2 * N(t2)]++), e2.last_lit === e2.lit_bufsize - 1;
3994
- }, r._tr_align = function(e2) {
3995
- P(e2, 2, 3), L(e2, m, z), function(e3) {
3996
- 16 === e3.bi_valid ? (U(e3, e3.bi_buf), e3.bi_buf = 0, e3.bi_valid = 0) : 8 <= e3.bi_valid && (e3.pending_buf[e3.pending++] = 255 & e3.bi_buf, e3.bi_buf >>= 8, e3.bi_valid -= 8);
3997
- }(e2);
3998
- };
3999
- }, { "../utils/common": 41 }], 53: [function(e, t, r) {
4000
- t.exports = function() {
4001
- this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
4002
- };
4003
- }, {}], 54: [function(e, t, r) {
4004
- (function(e2) {
4005
- !function(r2, n) {
4006
- if (!r2.setImmediate) {
4007
- var i, s, t2, a, o = 1, h = {}, u = false, l = r2.document, e3 = Object.getPrototypeOf && Object.getPrototypeOf(r2);
4008
- e3 = e3 && e3.setTimeout ? e3 : r2, i = "[object process]" === {}.toString.call(r2.process) ? function(e4) {
4009
- process.nextTick(function() {
4010
- c(e4);
4011
- });
4012
- } : function() {
4013
- if (r2.postMessage && !r2.importScripts) {
4014
- var e4 = true, t3 = r2.onmessage;
4015
- return r2.onmessage = function() {
4016
- e4 = false;
4017
- }, r2.postMessage("", "*"), r2.onmessage = t3, e4;
4018
- }
4019
- }() ? (a = "setImmediate$" + Math.random() + "$", r2.addEventListener ? r2.addEventListener("message", d, false) : r2.attachEvent("onmessage", d), function(e4) {
4020
- r2.postMessage(a + e4, "*");
4021
- }) : r2.MessageChannel ? ((t2 = new MessageChannel()).port1.onmessage = function(e4) {
4022
- c(e4.data);
4023
- }, function(e4) {
4024
- t2.port2.postMessage(e4);
4025
- }) : l && "onreadystatechange" in l.createElement("script") ? (s = l.documentElement, function(e4) {
4026
- var t3 = l.createElement("script");
4027
- t3.onreadystatechange = function() {
4028
- c(e4), t3.onreadystatechange = null, s.removeChild(t3), t3 = null;
4029
- }, s.appendChild(t3);
4030
- }) : function(e4) {
4031
- setTimeout(c, 0, e4);
4032
- }, e3.setImmediate = function(e4) {
4033
- "function" != typeof e4 && (e4 = new Function("" + e4));
4034
- for (var t3 = new Array(arguments.length - 1), r3 = 0; r3 < t3.length; r3++) t3[r3] = arguments[r3 + 1];
4035
- var n2 = { callback: e4, args: t3 };
4036
- return h[o] = n2, i(o), o++;
4037
- }, e3.clearImmediate = f;
4038
- }
4039
- function f(e4) {
4040
- delete h[e4];
4041
- }
4042
- function c(e4) {
4043
- if (u) setTimeout(c, 0, e4);
4044
- else {
4045
- var t3 = h[e4];
4046
- if (t3) {
4047
- u = true;
4048
- try {
4049
- !function(e5) {
4050
- var t4 = e5.callback, r3 = e5.args;
4051
- switch (r3.length) {
4052
- case 0:
4053
- t4();
4054
- break;
4055
- case 1:
4056
- t4(r3[0]);
4057
- break;
4058
- case 2:
4059
- t4(r3[0], r3[1]);
4060
- break;
4061
- case 3:
4062
- t4(r3[0], r3[1], r3[2]);
4063
- break;
4064
- default:
4065
- t4.apply(n, r3);
4066
- }
4067
- }(t3);
4068
- } finally {
4069
- f(e4), u = false;
4070
- }
4071
- }
4072
- }
4073
- }
4074
- function d(e4) {
4075
- e4.source === r2 && "string" == typeof e4.data && 0 === e4.data.indexOf(a) && c(+e4.data.slice(a.length));
4076
- }
4077
- }("undefined" == typeof self ? void 0 === e2 ? this : e2 : self);
4078
- }).call(this, "undefined" != typeof commonjsGlobal ? commonjsGlobal : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {});
4079
- }, {}] }, {}, [10])(10);
4080
- });
4081
- })(jszip_min);
4082
- return jszip_min.exports;
4083
- }
4084
- var jszip_minExports = requireJszip_min();
4085
- const JSZip = /* @__PURE__ */ getDefaultExportFromCjs(jszip_minExports);
4086
- async function downloadImages(images, config) {
4087
- if (images.length === 1) {
4088
- const image = images[0];
4089
- await download(image.dataURL, image.fileName);
4090
- } else if (images.length > 1) {
4091
- const imagesBlob = await zipUpImages(images);
4092
- if (imagesBlob) await download(imagesBlob, parseLabel(config));
4093
- }
4094
- }
4095
- async function zipUpImages(images) {
4096
- const zip = new JSZip();
4097
- try {
4098
- images.forEach((image) => {
4099
- const content = image.dataURL.split(",")[1];
4100
- zip.file(image.fileName, content, { base64: true });
4101
- });
4102
- } catch (error) {
4103
- console.error("Image Exporter - Error adding images to ZIP:", error);
4104
- return;
4105
- }
4106
- try {
4107
- const imagesBlob = await zip.generateAsync({ type: "blob" });
4108
- return imagesBlob;
4109
- } catch (error) {
4110
- console.error("Image Exporter - Error generating ZIP:", error);
4111
- return;
4112
- }
4113
- }
4114
- function parseLabel(config) {
4115
- try {
4116
- let label = config.zipLabel;
4117
- label = label.replace(/\s+/g, "-");
4118
- return label.replace(/[^a-zA-Z0-9-_]/g, "");
4119
- } catch (error) {
4120
- console.error(error);
4121
- return "images";
4122
- }
4123
- }
4124
- const log = {
4125
- info: (...messages) => logAction(messages, "info"),
4126
- error: (...messages) => logAction(messages, "error"),
4127
- verbose: (...messages) => logAction(messages, "verbose"),
4128
- progress: (progress, total) => logProgress(progress, total),
4129
- group: {
4130
- open: (...messages) => logAction(messages, "group"),
4131
- close: (...messages) => logAction(messages, "groupEnd")
4132
- }
4133
- };
4134
- async function logAction(messages, type = "info") {
4135
- const combinedMessage = messages.map((msg) => typeof msg === "object" ? JSON.stringify(msg) : msg).join(" ");
4136
- switch (type) {
4137
- case "info":
4138
- if (loggingLevel === "info" || loggingLevel === "verbose") {
4139
- console.log(...messages);
4140
- }
4141
- break;
4142
- case "error":
4143
- if (loggingLevel === "error" || loggingLevel === "verbose") {
4144
- console.error(...messages);
4145
- }
4146
- break;
4147
- case "verbose":
4148
- if (loggingLevel === "verbose") {
4149
- console.log(...messages);
4150
- }
4151
- break;
4152
- case "group":
4153
- console.group(...messages);
4154
- break;
4155
- case "groupEnd":
4156
- console.groupEnd();
4157
- break;
4158
- }
4159
- if (windowLogging) window.imageExporterLogs.push({ message: combinedMessage, type });
4160
- }
4161
- async function logProgress(progress, total) {
4162
- if (windowLogging) {
4163
- window.imageExporterProgress.push([progress, total]);
4164
- }
4165
- }
4166
- window.imageExporterLogs = [];
4167
- window.imageExporterProgress = [];
4168
- function isValidUrl(string) {
4169
- try {
4170
- const url = new URL(string);
4171
- if (url.protocol === "data:") {
4172
- return false;
4173
- }
4174
- if (url.protocol !== "http:" && url.protocol !== "https:") {
4175
- return false;
4176
- }
4177
- return true;
4178
- } catch (_) {
4179
- return false;
4180
- }
4181
- }
4182
- async function proxyCSS(config) {
4183
- const stylesheetElements = document.querySelectorAll('link[rel="stylesheet"]');
4184
- log.verbose("stylesheet elements to proxy", stylesheetElements.length);
4185
- for (let stylesheetElement of stylesheetElements) {
4186
- const stylesheetURL = stylesheetElement.getAttribute("href");
4187
- if (!stylesheetURL) continue;
4188
- if (stylesheetURL.startsWith("data:")) continue;
4189
- if (stylesheetURL.startsWith(config.corsProxyBaseUrl)) continue;
4190
- if (!isValidUrl(stylesheetURL)) continue;
4191
- stylesheetElement.setAttribute("crossorigin", "anonymous");
4192
- const proxiedURL = config.corsProxyBaseUrl + encodeURIComponent(stylesheetURL);
4193
- try {
4194
- const response = await fetch(proxiedURL);
4195
- let cssContent = await response.text();
4196
- const styleElement = document.createElement("style");
4197
- styleElement.textContent = cssContent;
4198
- styleElement.setAttribute(
4199
- "original-link-element",
4200
- encodeURIComponent(stylesheetElement.outerHTML)
4201
- );
4202
- stylesheetElement.insertAdjacentElement("afterend", styleElement);
4203
- stylesheetElement.remove();
4204
- log.verbose("Proxied: ", stylesheetURL);
4205
- } catch (error) {
4206
- console.error("Error fetching CSS:", error);
4207
- }
4208
- }
4209
- }
4210
- async function proxyImages(config, elements) {
4211
- try {
4212
- const elementArray = Array.from(elements);
4213
- if (!elementArray.length) return;
4214
- log.verbose("images to proxy", elementArray.length);
4215
- for (const element of elementArray) {
4216
- const images = Array.from(element.querySelectorAll("img"));
4217
- for (const img of images) {
4218
- if (isValidUrl(img.src) && !img.src.startsWith(config.corsProxyBaseUrl)) {
4219
- img.setAttribute("original-src", img.src);
4220
- img.src = config.corsProxyBaseUrl + encodeURIComponent(img.src);
4221
- log.verbose("Proxied: ", img.src);
4222
- }
4223
- }
4224
- }
4225
- } catch (e) {
4226
- console.error("ImageExporter: Error in proxyImages", e);
4227
- return;
4228
- }
4229
- }
4230
- async function runCorsProxy(config, elements) {
4231
- try {
4232
- log.verbose("running CORS proxy");
4233
- if (!config.corsProxyBaseUrl || !isValidUrl(config.corsProxyBaseUrl)) return;
4234
- await proxyCSS(config);
4235
- await proxyImages(config, elements);
4236
- } catch (e) {
4237
- console.error("ImageExporter: Error in runCorsProxy", e);
4238
- }
4239
- }
4240
- async function cleanUpCorsProxy() {
4241
- await restoreCSS();
4242
- await restoreImages();
4243
- }
4244
- async function restoreCSS() {
4245
- const styleElements = document.querySelectorAll("style[original-link-element]");
4246
- for (let styleElement of styleElements) {
4247
- const originalLinkElementHTML = decodeURIComponent(
4248
- styleElement.getAttribute("original-link-element")
4249
- );
4250
- const tempContainer = document.createElement("div");
4251
- tempContainer.innerHTML = originalLinkElementHTML;
4252
- styleElement.parentNode.insertBefore(tempContainer.firstChild, styleElement);
4253
- styleElement.remove();
4254
- log.verbose("Restored: ", originalLinkElementHTML);
4255
- }
4256
- }
4257
- async function restoreImages() {
4258
- const imageElements = document.querySelectorAll(
4259
- "img[original-src]"
4260
- );
4261
- for (let imageElement of imageElements) {
4262
- const originalSrc = imageElement.getAttribute("original-src");
4263
- imageElement.src = originalSrc;
4264
- imageElement.removeAttribute("original-src");
4265
- log.verbose("Restored: ", originalSrc);
4266
- }
4267
- }
4268
- const corsProxy = {
4269
- run: runCorsProxy,
4270
- cleanUp: cleanUpCorsProxy
4271
- };
4272
- async function getImageOptions(element, config) {
4273
- return {
4274
- label: parseLabel2(),
4275
- format: parseFormat(),
4276
- scale: parseScale(),
4277
- quality: parseQuality(),
4278
- includeScaleInLabel: parseIncludeScaleInLabel()
4279
- };
4280
- function parseLabel2() {
4281
- try {
4282
- const label = element.dataset.label || config.defaultImageLabel;
4283
- if (label === "") return config.defaultImageLabel;
4284
- const endsWithSpecial = /@\d+x$/.test(label);
4285
- let cleanedLabel = label;
4286
- const regex = /[^a-zA-Z0-9-_]/g;
4287
- if (endsWithSpecial) {
4288
- const match = label.match(/@\d+x$/);
4289
- if (!match) return config.defaultImageLabel;
4290
- cleanedLabel = label.slice(0, -match[0].length).replace(regex, "") + match[0];
4291
- } else {
4292
- cleanedLabel = label.replace(regex, "");
4293
- }
4294
- return cleanedLabel;
4295
- } catch (error) {
4296
- console.error(error);
4297
- return config.defaultImageLabel;
4298
- }
4299
- }
4300
- function parseFormat() {
4301
- try {
4302
- let format = element.dataset.format || config.format;
4303
- format = format.trim().toLowerCase();
4304
- if (format === "jpg" || format === "png" || format === "svg" || format === "webp") {
4305
- return format;
4306
- } else {
4307
- throw new Error(
4308
- `ImageExporter: provided format is not valid.
4309
- Provided: ${format}
4310
- Element: ${element}
4311
- Accepted values: jpg, png, svg,
4312
- Defaulting to: ${config.format}`
4313
- );
4314
- }
4315
- } catch (error) {
4316
- console.error(error);
4317
- return config.format;
4318
- }
4319
- }
4320
- function parseScale() {
4321
- try {
4322
- const scaleAsString = element.dataset.scale;
4323
- if (!scaleAsString) return config.scale;
4324
- if (scaleAsString.includes(",")) {
4325
- const scales = scaleAsString.trim().split(",").map((scale) => parseFloat(scale));
4326
- if (scales.some((scale) => isNaN(scale))) {
4327
- throw new Error(
4328
- `ImageExporter: provided scale is not valid.
4329
- Provided: ${scaleAsString}
4330
- Element: ${element}
4331
- Accepted values: number or csv numbers e.g. (1,2)
4332
- Defaulting to ${config.scale}`
4333
- );
4334
- }
4335
- return scales;
4336
- } else {
4337
- const scaleAsNumber = parseFloat(scaleAsString.trim());
4338
- if (isNaN(scaleAsNumber)) {
4339
- throw new Error(
4340
- `ImageExporter: provided scale is not valid.
4341
- Provided: ${scaleAsString}
4342
- Element: ${element}
4343
- Accepted values: number or csv numbers e.g. (1,2)
4344
- Defaulting to: ${config.scale}`
4345
- );
4346
- }
4347
- return scaleAsNumber;
4348
- }
4349
- } catch (error) {
4350
- console.error(error);
4351
- return config.scale;
4352
- }
4353
- }
4354
- function parseQuality() {
4355
- try {
4356
- const qualityAsString = element.dataset.quality;
4357
- if (!qualityAsString) return config.quality;
4358
- const qualityAsNumber = parseFloat(qualityAsString.trim());
4359
- if (isNaN(qualityAsNumber)) {
4360
- throw new Error(
4361
- `ImageExporter: provided quality is not valid.
4362
- Provided: ${qualityAsString}
4363
- Element: ${element}
4364
- Accepted values: number
4365
- Defaulting to: ${config.quality}`
4366
- );
4367
- }
4368
- return qualityAsNumber;
4369
- } catch (error) {
4370
- console.error(error);
4371
- return config.quality;
4372
- }
4373
- }
4374
- function parseIncludeScaleInLabel() {
4375
- try {
4376
- let includeScaleInLabel = element.dataset.includeScaleInLabel;
4377
- if (!includeScaleInLabel) return config.includeScaleInLabel;
4378
- includeScaleInLabel = includeScaleInLabel.trim();
4379
- if (includeScaleInLabel === "true" || includeScaleInLabel === "false") {
4380
- return includeScaleInLabel === "true";
4381
- } else {
4382
- throw new Error(
4383
- `ImageExporter: provided includeScaleInLabel is not valid.
4384
- Provided: ${includeScaleInLabel}
4385
- Element: ${element}
4386
- Accepted values: true or false
4387
- Defaulting to: ${config.includeScaleInLabel}`
4388
- );
4389
- }
4390
- } catch (error) {
4391
- console.error(error);
4392
- return config.includeScaleInLabel;
4393
- }
4394
- }
4395
- }
4396
- const defaultImageOptions = {
4397
- label: "image",
4398
- format: "jpg",
4399
- scale: 1,
4400
- quality: 1,
4401
- includeScaleInLabel: false
4402
- };
4403
- const defaultConfig = {
4404
- ...defaultImageOptions,
4405
- downloadImages: true,
4406
- defaultImageLabel: "image",
4407
- zipLabel: "images",
4408
- corsProxyBaseUrl: "",
4409
- enableWindowLogging: true,
4410
- loggingLevel: "none"
4411
- };
4412
- function removeHiddenElements(elements) {
4413
- elements = Array.from(elements);
4414
- return elements.filter((element) => isVisible(element));
4415
- }
4416
- function isVisible(element) {
4417
- const computedStyle = window.getComputedStyle(element);
4418
- return element.offsetParent !== null && element.style.display !== "none" && computedStyle.visibility === "visible" && computedStyle.opacity !== "0" && computedStyle.width !== "0" && computedStyle.height !== "0";
4419
- }
4420
- async function determineTotalElements(elements) {
4421
- try {
4422
- let totalElements = 0;
4423
- for (const element of elements) {
4424
- const scaleAsString = element.dataset.scale;
4425
- if (!scaleAsString) continue;
4426
- if (scaleAsString.includes(",")) {
4427
- const scales = scaleAsString.trim().split(",").map((scale) => parseFloat(scale));
4428
- if (scales.some((scale) => isNaN(scale))) continue;
4429
- totalElements += scales.length;
4430
- } else {
4431
- const scaleAsNumber = parseFloat(scaleAsString.trim());
4432
- if (isNaN(scaleAsNumber)) {
4433
- continue;
4434
- } else {
4435
- totalElements++;
4436
- }
4437
- }
4438
- }
4439
- return totalElements;
4440
- } catch (error) {
4441
- return 1;
4442
- }
4443
- }
4444
- let windowLogging = true;
4445
- let loggingLevel = "none";
4446
- async function capture(elements, userConfig = defaultConfig) {
4447
- log.group.open("image-exporter");
4448
- try {
4449
- const config = { ...defaultConfig, ...userConfig };
4450
- windowLogging = config.enableWindowLogging;
4451
- loggingLevel = config.loggingLevel;
4452
- log.verbose("config", config);
4453
- if (elements instanceof HTMLElement) elements = [elements];
4454
- const originalLength = elements.length;
4455
- elements = removeHiddenElements(elements);
4456
- const totalElements = await determineTotalElements(elements);
4457
- if (originalLength !== elements.length)
4458
- log.verbose(
4459
- "Skipping capture of hidden elements: ",
4460
- originalLength - elements.length
4461
- );
4462
- log.verbose("Element to capture", elements.length);
4463
- if (userConfig.corsProxyBaseUrl) await corsProxy.run(config, elements);
4464
- let images = [];
4465
- let filenames = [];
4466
- let imageNumber = 1;
4467
- for (const element of elements) {
4468
- const imageOptions = await getImageOptions(element, config);
4469
- log.verbose("Image options", imageOptions);
4470
- if (imageOptions.scale instanceof Array) {
4471
- log.verbose("Multi-scale capture");
4472
- imageOptions.includeScaleInLabel = true;
4473
- for (const scale of imageOptions.scale) {
4474
- log.progress(imageNumber++, totalElements);
4475
- const image = await captureElement(
4476
- element,
4477
- { ...imageOptions, scale },
4478
- filenames
4479
- );
4480
- images.push(image);
4481
- }
4482
- } else if (typeof imageOptions.scale === "number") {
4483
- log.progress(imageNumber++, totalElements);
4484
- log.verbose("Single-scale capture");
4485
- const image = await captureElement(
4486
- element,
4487
- imageOptions,
4488
- filenames
4489
- );
4490
- images.push(image);
4491
- }
4492
- }
4493
- if (userConfig.downloadImages) await downloadImages(images, config);
4494
- if (userConfig.corsProxyBaseUrl) await corsProxy.cleanUp();
4495
- return images;
4496
- } catch (error) {
4497
- log.error(error);
4498
- return null;
4499
- } finally {
4500
- log.group.close();
4501
- }
4502
- }
4503
- if (typeof window !== "undefined") {
4504
- window.imageExporter = capture;
4505
- }
4506
- export {
4507
- capture
4508
- };