@progress/kendo-pdfviewer-common 0.3.0-dev.202409251459 → 0.3.0-dev.202410100645

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 (149) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +139 -0
  2. package/dist/es/annotations/annotation-editor-layer.js +780 -0
  3. package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
  4. package/dist/es/annotations/annotation-layer-builder.js +217 -0
  5. package/dist/es/annotations/annotation-layer.js +2793 -0
  6. package/dist/es/annotations/draw-layer-builder.js +65 -0
  7. package/dist/es/annotations/draw-layer.js +220 -0
  8. package/dist/es/annotations/editors/annotation-editor.js +1519 -0
  9. package/dist/es/annotations/editors/free-text-editor.js +783 -0
  10. package/dist/es/annotations/editors/highlight-editor.js +717 -0
  11. package/dist/es/annotations/editors/outliner.js +747 -0
  12. package/dist/es/annotations/helpers/annotation-storage.js +294 -0
  13. package/dist/es/annotations/helpers/color-manager.js +72 -0
  14. package/dist/es/annotations/helpers/command-manager.js +133 -0
  15. package/dist/es/annotations/helpers/id-manager.js +34 -0
  16. package/dist/es/annotations/helpers/image-manager.js +176 -0
  17. package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
  18. package/dist/es/annotations/helpers/tools.js +19 -0
  19. package/dist/es/annotations/shared/display_utils.js +1024 -0
  20. package/dist/es/annotations/shared/event_utils.js +213 -0
  21. package/dist/es/annotations/shared/murmurhash3.js +126 -0
  22. package/dist/es/annotations/shared/scripting_utils.js +90 -0
  23. package/dist/es/annotations/shared/ui_utils.js +823 -0
  24. package/dist/es/annotations/shared/utils.js +909 -0
  25. package/dist/es/common/component.js +33 -0
  26. package/dist/es/common/core.js +91 -0
  27. package/dist/es/common/dom.js +11 -0
  28. package/dist/es/common/main.js +4 -0
  29. package/dist/es/common/math.js +1 -0
  30. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  31. package/dist/es/links/link-service.js +505 -0
  32. package/dist/es/main.js +2 -0
  33. package/dist/es/scroller.js +29 -30
  34. package/dist/es/text/text-layer-builder.js +288 -0
  35. package/dist/es/utils.js +5 -5
  36. package/dist/es/widget/page.js +762 -0
  37. package/dist/es/widget/pdfviewer.js +1659 -0
  38. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  39. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  40. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  41. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  42. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  43. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  44. package/dist/es2015/annotations/draw-layer.js +220 -0
  45. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  46. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  47. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  48. package/dist/es2015/annotations/editors/outliner.js +747 -0
  49. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  50. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  51. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  52. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  53. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  54. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  55. package/dist/es2015/annotations/helpers/tools.js +19 -0
  56. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  57. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  58. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  59. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  60. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  61. package/dist/es2015/annotations/shared/utils.js +909 -0
  62. package/dist/es2015/common/component.js +33 -0
  63. package/dist/es2015/common/core.js +91 -0
  64. package/dist/es2015/common/dom.js +11 -0
  65. package/dist/es2015/common/main.js +4 -0
  66. package/dist/es2015/common/math.js +1 -0
  67. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  68. package/dist/es2015/links/link-service.js +505 -0
  69. package/dist/es2015/main.js +2 -0
  70. package/dist/es2015/scroller.js +29 -30
  71. package/dist/es2015/text/text-layer-builder.js +288 -0
  72. package/dist/es2015/utils.js +5 -5
  73. package/dist/es2015/widget/page.js +762 -0
  74. package/dist/es2015/widget/pdfviewer.js +1659 -0
  75. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  76. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  77. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  78. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  79. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  80. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  81. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  82. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  83. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  84. package/dist/npm/annotations/annotation-layer.js +2794 -0
  85. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  86. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  87. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  88. package/dist/npm/annotations/draw-layer.js +223 -0
  89. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  90. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  91. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  92. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  93. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  94. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  95. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  96. package/dist/npm/annotations/editors/outliner.js +750 -0
  97. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  98. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  99. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  100. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  101. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  102. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  103. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  104. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  105. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  106. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  107. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  108. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  109. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  110. package/dist/npm/annotations/helpers/tools.js +23 -0
  111. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  112. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  113. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  114. package/dist/npm/annotations/shared/event_utils.js +165 -0
  115. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  116. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  117. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  118. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  119. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  120. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  121. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  122. package/dist/npm/annotations/shared/utils.js +872 -0
  123. package/dist/npm/common/component.d.ts +9 -0
  124. package/dist/npm/common/component.js +37 -0
  125. package/dist/npm/common/core.d.ts +18 -0
  126. package/dist/npm/common/core.js +112 -0
  127. package/dist/npm/common/dom.d.ts +3 -0
  128. package/dist/npm/common/dom.js +17 -0
  129. package/dist/npm/common/main.d.ts +4 -0
  130. package/dist/npm/common/main.js +7 -0
  131. package/dist/npm/common/math.d.ts +1 -0
  132. package/dist/npm/common/math.js +5 -0
  133. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  134. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  135. package/dist/npm/links/link-service.d.ts +116 -0
  136. package/dist/npm/links/link-service.js +501 -0
  137. package/dist/npm/main.d.ts +2 -0
  138. package/dist/npm/main.js +2 -0
  139. package/dist/npm/scroller.d.ts +7 -3
  140. package/dist/npm/scroller.js +32 -32
  141. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  142. package/dist/npm/text/text-layer-builder.js +291 -0
  143. package/dist/npm/utils.d.ts +20 -2
  144. package/dist/npm/utils.js +11 -8
  145. package/dist/npm/widget/page.d.ts +75 -0
  146. package/dist/npm/widget/page.js +763 -0
  147. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  148. package/dist/npm/widget/pdfviewer.js +1663 -0
  149. package/package.json +13 -9
@@ -0,0 +1,1030 @@
1
+ "use strict";
2
+ /* Copyright 2015 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getColorValues = exports.getRGB = exports.noContextMenu = void 0;
18
+ // import {
19
+ // BaseCanvasFactory,
20
+ // BaseCMapReaderFactory,
21
+ // BaseFilterFactory,
22
+ // BaseStandardFontDataFactory,
23
+ // BaseSVGFactory,
24
+ // } from "./base_factory.js";
25
+ // import {
26
+ // BaseException,
27
+ // FeatureTest,
28
+ // shadow,
29
+ // stringToBytes,
30
+ // Util,
31
+ // warn,
32
+ // } from "../shared/util.js";
33
+ // const SVG_NS = "http://www.w3.org/2000/svg";
34
+ // class PixelsPerInch {
35
+ // static CSS = 96.0;
36
+ // static PDF = 72.0;
37
+ // static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
38
+ // }
39
+ // /**
40
+ // * FilterFactory aims to create some SVG filters we can use when drawing an
41
+ // * image (or whatever) on a canvas.
42
+ // * Filters aren't applied with ctx.putImageData because it just overwrites the
43
+ // * underlying pixels.
44
+ // * With these filters, it's possible for example to apply some transfer maps on
45
+ // * an image without the need to apply them on the pixel arrays: the renderer
46
+ // * does the magic for us.
47
+ // */
48
+ // class DOMFilterFactory extends BaseFilterFactory {
49
+ // #baseUrl;
50
+ // #_cache;
51
+ // #_defs;
52
+ // #docId;
53
+ // #document;
54
+ // #_hcmCache;
55
+ // #id = 0;
56
+ // constructor({ docId, ownerDocument = globalThis.document } = {}) {
57
+ // super();
58
+ // this.#docId = docId;
59
+ // this.#document = ownerDocument;
60
+ // }
61
+ // get #cache() {
62
+ // return (this.#_cache ||= new Map());
63
+ // }
64
+ // get #hcmCache() {
65
+ // return (this.#_hcmCache ||= new Map());
66
+ // }
67
+ // get #defs() {
68
+ // if (!this.#_defs) {
69
+ // const div = this.#document.createElement("div");
70
+ // const { style } = div;
71
+ // style.visibility = "hidden";
72
+ // style.contain = "strict";
73
+ // style.width = style.height = 0;
74
+ // style.position = "absolute";
75
+ // style.top = style.left = 0;
76
+ // style.zIndex = -1;
77
+ // const svg = this.#document.createElementNS(SVG_NS, "svg");
78
+ // svg.setAttribute("width", 0);
79
+ // svg.setAttribute("height", 0);
80
+ // this.#_defs = this.#document.createElementNS(SVG_NS, "defs");
81
+ // div.append(svg);
82
+ // svg.append(this.#_defs);
83
+ // this.#document.body.append(div);
84
+ // }
85
+ // return this.#_defs;
86
+ // }
87
+ // #createTables(maps) {
88
+ // if (maps.length === 1) {
89
+ // const mapR = maps[0];
90
+ // const buffer = new Array(256);
91
+ // for (let i = 0; i < 256; i++) {
92
+ // buffer[i] = mapR[i] / 255;
93
+ // }
94
+ // const table = buffer.join(",");
95
+ // return [table, table, table];
96
+ // }
97
+ // const [mapR, mapG, mapB] = maps;
98
+ // const bufferR = new Array(256);
99
+ // const bufferG = new Array(256);
100
+ // const bufferB = new Array(256);
101
+ // for (let i = 0; i < 256; i++) {
102
+ // bufferR[i] = mapR[i] / 255;
103
+ // bufferG[i] = mapG[i] / 255;
104
+ // bufferB[i] = mapB[i] / 255;
105
+ // }
106
+ // return [bufferR.join(","), bufferG.join(","), bufferB.join(",")];
107
+ // }
108
+ // #createUrl(id) {
109
+ // if (this.#baseUrl === undefined) {
110
+ // // Unless a `<base>`-element is present a relative URL should work.
111
+ // this.#baseUrl = "";
112
+ // const url = this.#document.URL;
113
+ // if (url !== this.#document.baseURI) {
114
+ // if (isDataScheme(url)) {
115
+ // warn('#createUrl: ignore "data:"-URL for performance reasons.');
116
+ // } else {
117
+ // this.#baseUrl = url.split("#", 1)[0];
118
+ // }
119
+ // }
120
+ // }
121
+ // return `url(${this.#baseUrl}#${id})`;
122
+ // }
123
+ // addFilter(maps) {
124
+ // if (!maps) {
125
+ // return "none";
126
+ // }
127
+ // // When a page is zoomed the page is re-drawn but the maps are likely
128
+ // // the same.
129
+ // let value = this.#cache.get(maps);
130
+ // if (value) {
131
+ // return value;
132
+ // }
133
+ // const [tableR, tableG, tableB] = this.#createTables(maps);
134
+ // const key = maps.length === 1 ? tableR : `${tableR}${tableG}${tableB}`;
135
+ // value = this.#cache.get(key);
136
+ // if (value) {
137
+ // this.#cache.set(maps, value);
138
+ // return value;
139
+ // }
140
+ // // We create a SVG filter: feComponentTransferElement
141
+ // // https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement
142
+ // const id = `g_${this.#docId}_transfer_map_${this.#id++}`;
143
+ // const url = this.#createUrl(id);
144
+ // this.#cache.set(maps, url);
145
+ // this.#cache.set(key, url);
146
+ // const filter = this.#createFilter(id);
147
+ // this.#addTransferMapConversion(tableR, tableG, tableB, filter);
148
+ // return url;
149
+ // }
150
+ // addHCMFilter(fgColor, bgColor) {
151
+ // const key = `${fgColor}-${bgColor}`;
152
+ // const filterName = "base";
153
+ // let info = this.#hcmCache.get(filterName);
154
+ // if (info?.key === key) {
155
+ // return info.url;
156
+ // }
157
+ // if (info) {
158
+ // info.filter?.remove();
159
+ // info.key = key;
160
+ // info.url = "none";
161
+ // info.filter = null;
162
+ // } else {
163
+ // info = {
164
+ // key,
165
+ // url: "none",
166
+ // filter: null,
167
+ // };
168
+ // this.#hcmCache.set(filterName, info);
169
+ // }
170
+ // if (!fgColor || !bgColor) {
171
+ // return info.url;
172
+ // }
173
+ // const fgRGB = this.#getRGB(fgColor);
174
+ // fgColor = Util.makeHexColor(...fgRGB);
175
+ // const bgRGB = this.#getRGB(bgColor);
176
+ // bgColor = Util.makeHexColor(...bgRGB);
177
+ // this.#defs.style.color = "";
178
+ // if (
179
+ // (fgColor === "#000000" && bgColor === "#ffffff") ||
180
+ // fgColor === bgColor
181
+ // ) {
182
+ // return info.url;
183
+ // }
184
+ // // https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance
185
+ // //
186
+ // // Relative luminance:
187
+ // // https://www.w3.org/TR/WCAG20/#relativeluminancedef
188
+ // //
189
+ // // We compute the rounded luminance of the default background color.
190
+ // // Then for every color in the pdf, if its rounded luminance is the
191
+ // // same as the background one then it's replaced by the new
192
+ // // background color else by the foreground one.
193
+ // const map = new Array(256);
194
+ // for (let i = 0; i <= 255; i++) {
195
+ // const x = i / 255;
196
+ // map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
197
+ // }
198
+ // const table = map.join(",");
199
+ // const id = `g_${this.#docId}_hcm_filter`;
200
+ // const filter = (info.filter = this.#createFilter(id));
201
+ // this.#addTransferMapConversion(table, table, table, filter);
202
+ // this.#addGrayConversion(filter);
203
+ // const getSteps = (c, n) => {
204
+ // const start = fgRGB[c] / 255;
205
+ // const end = bgRGB[c] / 255;
206
+ // const arr = new Array(n + 1);
207
+ // for (let i = 0; i <= n; i++) {
208
+ // arr[i] = start + (i / n) * (end - start);
209
+ // }
210
+ // return arr.join(",");
211
+ // };
212
+ // this.#addTransferMapConversion(
213
+ // getSteps(0, 5),
214
+ // getSteps(1, 5),
215
+ // getSteps(2, 5),
216
+ // filter
217
+ // );
218
+ // info.url = this.#createUrl(id);
219
+ // return info.url;
220
+ // }
221
+ // addAlphaFilter(map) {
222
+ // // When a page is zoomed the page is re-drawn but the maps are likely
223
+ // // the same.
224
+ // let value = this.#cache.get(map);
225
+ // if (value) {
226
+ // return value;
227
+ // }
228
+ // const [tableA] = this.#createTables([map]);
229
+ // const key = `alpha_${tableA}`;
230
+ // value = this.#cache.get(key);
231
+ // if (value) {
232
+ // this.#cache.set(map, value);
233
+ // return value;
234
+ // }
235
+ // const id = `g_${this.#docId}_alpha_map_${this.#id++}`;
236
+ // const url = this.#createUrl(id);
237
+ // this.#cache.set(map, url);
238
+ // this.#cache.set(key, url);
239
+ // const filter = this.#createFilter(id);
240
+ // this.#addTransferMapAlphaConversion(tableA, filter);
241
+ // return url;
242
+ // }
243
+ // addLuminosityFilter(map) {
244
+ // // When a page is zoomed the page is re-drawn but the maps are likely
245
+ // // the same.
246
+ // let value = this.#cache.get(map || "luminosity");
247
+ // if (value) {
248
+ // return value;
249
+ // }
250
+ // let tableA, key;
251
+ // if (map) {
252
+ // [tableA] = this.#createTables([map]);
253
+ // key = `luminosity_${tableA}`;
254
+ // } else {
255
+ // key = "luminosity";
256
+ // }
257
+ // value = this.#cache.get(key);
258
+ // if (value) {
259
+ // this.#cache.set(map, value);
260
+ // return value;
261
+ // }
262
+ // const id = `g_${this.#docId}_luminosity_map_${this.#id++}`;
263
+ // const url = this.#createUrl(id);
264
+ // this.#cache.set(map, url);
265
+ // this.#cache.set(key, url);
266
+ // const filter = this.#createFilter(id);
267
+ // this.#addLuminosityConversion(filter);
268
+ // if (map) {
269
+ // this.#addTransferMapAlphaConversion(tableA, filter);
270
+ // }
271
+ // return url;
272
+ // }
273
+ // addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
274
+ // const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
275
+ // let info = this.#hcmCache.get(filterName);
276
+ // if (info?.key === key) {
277
+ // return info.url;
278
+ // }
279
+ // if (info) {
280
+ // info.filter?.remove();
281
+ // info.key = key;
282
+ // info.url = "none";
283
+ // info.filter = null;
284
+ // } else {
285
+ // info = {
286
+ // key,
287
+ // url: "none",
288
+ // filter: null,
289
+ // };
290
+ // this.#hcmCache.set(filterName, info);
291
+ // }
292
+ // if (!fgColor || !bgColor) {
293
+ // return info.url;
294
+ // }
295
+ // const [fgRGB, bgRGB] = [fgColor, bgColor].map(this.#getRGB.bind(this));
296
+ // let fgGray = Math.round(
297
+ // 0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]
298
+ // );
299
+ // let bgGray = Math.round(
300
+ // 0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]
301
+ // );
302
+ // let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(
303
+ // this.#getRGB.bind(this)
304
+ // );
305
+ // if (bgGray < fgGray) {
306
+ // [fgGray, bgGray, newFgRGB, newBgRGB] = [
307
+ // bgGray,
308
+ // fgGray,
309
+ // newBgRGB,
310
+ // newFgRGB,
311
+ // ];
312
+ // }
313
+ // this.#defs.style.color = "";
314
+ // // Now we can create the filters to highlight some canvas parts.
315
+ // // The colors in the pdf will almost be Canvas and CanvasText, hence we
316
+ // // want to filter them to finally get Highlight and HighlightText.
317
+ // // Since we're in HCM the background color and the foreground color should
318
+ // // be really different when converted to grayscale (if they're not then it
319
+ // // means that we've a poor contrast). Once the canvas colors are converted
320
+ // // to grayscale we can easily map them on their new colors.
321
+ // // The grayscale step is important because if we've something like:
322
+ // // fgColor = #FF....
323
+ // // bgColor = #FF....
324
+ // // then we are enable to map the red component on the new red components
325
+ // // which can be different.
326
+ // const getSteps = (fg, bg, n) => {
327
+ // const arr = new Array(256);
328
+ // const step = (bgGray - fgGray) / n;
329
+ // const newStart = fg / 255;
330
+ // const newStep = (bg - fg) / (255 * n);
331
+ // let prev = 0;
332
+ // for (let i = 0; i <= n; i++) {
333
+ // const k = Math.round(fgGray + i * step);
334
+ // const value = newStart + i * newStep;
335
+ // for (let j = prev; j <= k; j++) {
336
+ // arr[j] = value;
337
+ // }
338
+ // prev = k + 1;
339
+ // }
340
+ // for (let i = prev; i < 256; i++) {
341
+ // arr[i] = arr[prev - 1];
342
+ // }
343
+ // return arr.join(",");
344
+ // };
345
+ // const id = `g_${this.#docId}_hcm_${filterName}_filter`;
346
+ // const filter = (info.filter = this.#createFilter(id));
347
+ // this.#addGrayConversion(filter);
348
+ // this.#addTransferMapConversion(
349
+ // getSteps(newFgRGB[0], newBgRGB[0], 5),
350
+ // getSteps(newFgRGB[1], newBgRGB[1], 5),
351
+ // getSteps(newFgRGB[2], newBgRGB[2], 5),
352
+ // filter
353
+ // );
354
+ // info.url = this.#createUrl(id);
355
+ // return info.url;
356
+ // }
357
+ // destroy(keepHCM = false) {
358
+ // if (keepHCM && this.#hcmCache.size !== 0) {
359
+ // return;
360
+ // }
361
+ // if (this.#_defs) {
362
+ // this.#_defs.parentNode.parentNode.remove();
363
+ // this.#_defs = null;
364
+ // }
365
+ // if (this.#_cache) {
366
+ // this.#_cache.clear();
367
+ // this.#_cache = null;
368
+ // }
369
+ // this.#id = 0;
370
+ // }
371
+ // #addLuminosityConversion(filter) {
372
+ // const feColorMatrix = this.#document.createElementNS(
373
+ // SVG_NS,
374
+ // "feColorMatrix"
375
+ // );
376
+ // feColorMatrix.setAttribute("type", "matrix");
377
+ // feColorMatrix.setAttribute(
378
+ // "values",
379
+ // "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"
380
+ // );
381
+ // filter.append(feColorMatrix);
382
+ // }
383
+ // #addGrayConversion(filter) {
384
+ // const feColorMatrix = this.#document.createElementNS(
385
+ // SVG_NS,
386
+ // "feColorMatrix"
387
+ // );
388
+ // feColorMatrix.setAttribute("type", "matrix");
389
+ // feColorMatrix.setAttribute(
390
+ // "values",
391
+ // "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"
392
+ // );
393
+ // filter.append(feColorMatrix);
394
+ // }
395
+ // #createFilter(id) {
396
+ // const filter = this.#document.createElementNS(SVG_NS, "filter");
397
+ // filter.setAttribute("color-interpolation-filters", "sRGB");
398
+ // filter.setAttribute("id", id);
399
+ // this.#defs.append(filter);
400
+ // return filter;
401
+ // }
402
+ // #appendFeFunc(feComponentTransfer, func, table) {
403
+ // const feFunc = this.#document.createElementNS(SVG_NS, func);
404
+ // feFunc.setAttribute("type", "discrete");
405
+ // feFunc.setAttribute("tableValues", table);
406
+ // feComponentTransfer.append(feFunc);
407
+ // }
408
+ // #addTransferMapConversion(rTable, gTable, bTable, filter) {
409
+ // const feComponentTransfer = this.#document.createElementNS(
410
+ // SVG_NS,
411
+ // "feComponentTransfer"
412
+ // );
413
+ // filter.append(feComponentTransfer);
414
+ // this.#appendFeFunc(feComponentTransfer, "feFuncR", rTable);
415
+ // this.#appendFeFunc(feComponentTransfer, "feFuncG", gTable);
416
+ // this.#appendFeFunc(feComponentTransfer, "feFuncB", bTable);
417
+ // }
418
+ // #addTransferMapAlphaConversion(aTable, filter) {
419
+ // const feComponentTransfer = this.#document.createElementNS(
420
+ // SVG_NS,
421
+ // "feComponentTransfer"
422
+ // );
423
+ // filter.append(feComponentTransfer);
424
+ // this.#appendFeFunc(feComponentTransfer, "feFuncA", aTable);
425
+ // }
426
+ // #getRGB(color) {
427
+ // this.#defs.style.color = color;
428
+ // return getRGB(getComputedStyle(this.#defs).getPropertyValue("color"));
429
+ // }
430
+ // }
431
+ // class DOMCanvasFactory extends BaseCanvasFactory {
432
+ // constructor({ ownerDocument = globalThis.document, enableHWA = false } = {}) {
433
+ // super({ enableHWA });
434
+ // this._document = ownerDocument;
435
+ // }
436
+ // /**
437
+ // * @ignore
438
+ // */
439
+ // _createCanvas(width, height) {
440
+ // const canvas = this._document.createElement("canvas");
441
+ // canvas.width = width;
442
+ // canvas.height = height;
443
+ // return canvas;
444
+ // }
445
+ // }
446
+ // async function fetchData(url, type = "text") {
447
+ // if (
448
+ // (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
449
+ // isValidFetchUrl(url, document.baseURI)
450
+ // ) {
451
+ // const response = await fetch(url);
452
+ // if (!response.ok) {
453
+ // throw new Error(response.statusText);
454
+ // }
455
+ // switch (type) {
456
+ // case "arraybuffer":
457
+ // return response.arrayBuffer();
458
+ // case "blob":
459
+ // return response.blob();
460
+ // case "json":
461
+ // return response.json();
462
+ // }
463
+ // return response.text();
464
+ // }
465
+ // // The Fetch API is not supported.
466
+ // return new Promise((resolve, reject) => {
467
+ // const request = new XMLHttpRequest();
468
+ // request.open("GET", url, /* async = */ true);
469
+ // request.responseType = type;
470
+ // request.onreadystatechange = () => {
471
+ // if (request.readyState !== XMLHttpRequest.DONE) {
472
+ // return;
473
+ // }
474
+ // if (request.status === 200 || request.status === 0) {
475
+ // switch (type) {
476
+ // case "arraybuffer":
477
+ // case "blob":
478
+ // case "json":
479
+ // resolve(request.response);
480
+ // return;
481
+ // }
482
+ // resolve(request.responseText);
483
+ // return;
484
+ // }
485
+ // reject(new Error(request.statusText));
486
+ // };
487
+ // request.send(null);
488
+ // });
489
+ // }
490
+ // class DOMCMapReaderFactory extends BaseCMapReaderFactory {
491
+ // /**
492
+ // * @ignore
493
+ // */
494
+ // _fetchData(url, compressionType) {
495
+ // return fetchData(
496
+ // url,
497
+ // /* type = */ this.isCompressed ? "arraybuffer" : "text"
498
+ // ).then(data => ({
499
+ // cMapData:
500
+ // data instanceof ArrayBuffer
501
+ // ? new Uint8Array(data)
502
+ // : stringToBytes(data),
503
+ // compressionType,
504
+ // }));
505
+ // }
506
+ // }
507
+ // class DOMStandardFontDataFactory extends BaseStandardFontDataFactory {
508
+ // /**
509
+ // * @ignore
510
+ // */
511
+ // _fetchData(url) {
512
+ // return fetchData(url, /* type = */ "arraybuffer").then(
513
+ // data => new Uint8Array(data)
514
+ // );
515
+ // }
516
+ // }
517
+ // class DOMSVGFactory extends BaseSVGFactory {
518
+ // /**
519
+ // * @ignore
520
+ // */
521
+ // _createSVG(type) {
522
+ // return document.createElementNS(SVG_NS, type);
523
+ // }
524
+ // }
525
+ // /**
526
+ // * @typedef {Object} PageViewportParameters
527
+ // * @property {Array<number>} viewBox - The xMin, yMin, xMax and
528
+ // * yMax coordinates.
529
+ // * @property {number} scale - The scale of the viewport.
530
+ // * @property {number} rotation - The rotation, in degrees, of the viewport.
531
+ // * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset. The
532
+ // * default value is `0`.
533
+ // * @property {number} [offsetY] - The vertical, i.e. y-axis, offset. The
534
+ // * default value is `0`.
535
+ // * @property {boolean} [dontFlip] - If true, the y-axis will not be flipped.
536
+ // * The default value is `false`.
537
+ // */
538
+ // /**
539
+ // * @typedef {Object} PageViewportCloneParameters
540
+ // * @property {number} [scale] - The scale, overriding the one in the cloned
541
+ // * viewport. The default value is `this.scale`.
542
+ // * @property {number} [rotation] - The rotation, in degrees, overriding the one
543
+ // * in the cloned viewport. The default value is `this.rotation`.
544
+ // * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
545
+ // * The default value is `this.offsetX`.
546
+ // * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
547
+ // * The default value is `this.offsetY`.
548
+ // * @property {boolean} [dontFlip] - If true, the x-axis will not be flipped.
549
+ // * The default value is `false`.
550
+ // */
551
+ // /**
552
+ // * PDF page viewport created based on scale, rotation and offset.
553
+ // */
554
+ // class PageViewport {
555
+ // /**
556
+ // * @param {PageViewportParameters}
557
+ // */
558
+ // constructor({
559
+ // viewBox,
560
+ // scale,
561
+ // rotation,
562
+ // offsetX = 0,
563
+ // offsetY = 0,
564
+ // dontFlip = false,
565
+ // }) {
566
+ // this.viewBox = viewBox;
567
+ // this.scale = scale;
568
+ // this.rotation = rotation;
569
+ // this.offsetX = offsetX;
570
+ // this.offsetY = offsetY;
571
+ // // creating transform to convert pdf coordinate system to the normal
572
+ // // canvas like coordinates taking in account scale and rotation
573
+ // const centerX = (viewBox[2] + viewBox[0]) / 2;
574
+ // const centerY = (viewBox[3] + viewBox[1]) / 2;
575
+ // let rotateA, rotateB, rotateC, rotateD;
576
+ // // Normalize the rotation, by clamping it to the [0, 360) range.
577
+ // rotation %= 360;
578
+ // if (rotation < 0) {
579
+ // rotation += 360;
580
+ // }
581
+ // switch (rotation) {
582
+ // case 180:
583
+ // rotateA = -1;
584
+ // rotateB = 0;
585
+ // rotateC = 0;
586
+ // rotateD = 1;
587
+ // break;
588
+ // case 90:
589
+ // rotateA = 0;
590
+ // rotateB = 1;
591
+ // rotateC = 1;
592
+ // rotateD = 0;
593
+ // break;
594
+ // case 270:
595
+ // rotateA = 0;
596
+ // rotateB = -1;
597
+ // rotateC = -1;
598
+ // rotateD = 0;
599
+ // break;
600
+ // case 0:
601
+ // rotateA = 1;
602
+ // rotateB = 0;
603
+ // rotateC = 0;
604
+ // rotateD = -1;
605
+ // break;
606
+ // default:
607
+ // throw new Error(
608
+ // "PageViewport: Invalid rotation, must be a multiple of 90 degrees."
609
+ // );
610
+ // }
611
+ // if (dontFlip) {
612
+ // rotateC = -rotateC;
613
+ // rotateD = -rotateD;
614
+ // }
615
+ // let offsetCanvasX, offsetCanvasY;
616
+ // let width, height;
617
+ // if (rotateA === 0) {
618
+ // offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
619
+ // offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
620
+ // width = (viewBox[3] - viewBox[1]) * scale;
621
+ // height = (viewBox[2] - viewBox[0]) * scale;
622
+ // } else {
623
+ // offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
624
+ // offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
625
+ // width = (viewBox[2] - viewBox[0]) * scale;
626
+ // height = (viewBox[3] - viewBox[1]) * scale;
627
+ // }
628
+ // // creating transform for the following operations:
629
+ // // translate(-centerX, -centerY), rotate and flip vertically,
630
+ // // scale, and translate(offsetCanvasX, offsetCanvasY)
631
+ // this.transform = [
632
+ // rotateA * scale,
633
+ // rotateB * scale,
634
+ // rotateC * scale,
635
+ // rotateD * scale,
636
+ // offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
637
+ // offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY,
638
+ // ];
639
+ // this.width = width;
640
+ // this.height = height;
641
+ // }
642
+ // /**
643
+ // * The original, un-scaled, viewport dimensions.
644
+ // * @type {Object}
645
+ // */
646
+ // get rawDims() {
647
+ // const { viewBox } = this;
648
+ // return shadow(this, "rawDims", {
649
+ // pageWidth: viewBox[2] - viewBox[0],
650
+ // pageHeight: viewBox[3] - viewBox[1],
651
+ // pageX: viewBox[0],
652
+ // pageY: viewBox[1],
653
+ // });
654
+ // }
655
+ // /**
656
+ // * Clones viewport, with optional additional properties.
657
+ // * @param {PageViewportCloneParameters} [params]
658
+ // * @returns {PageViewport} Cloned viewport.
659
+ // */
660
+ // clone({
661
+ // scale = this.scale,
662
+ // rotation = this.rotation,
663
+ // offsetX = this.offsetX,
664
+ // offsetY = this.offsetY,
665
+ // dontFlip = false,
666
+ // } = {}) {
667
+ // return new PageViewport({
668
+ // viewBox: this.viewBox.slice(),
669
+ // scale,
670
+ // rotation,
671
+ // offsetX,
672
+ // offsetY,
673
+ // dontFlip,
674
+ // });
675
+ // }
676
+ // /**
677
+ // * Converts PDF point to the viewport coordinates. For examples, useful for
678
+ // * converting PDF location into canvas pixel coordinates.
679
+ // * @param {number} x - The x-coordinate.
680
+ // * @param {number} y - The y-coordinate.
681
+ // * @returns {Array} Array containing `x`- and `y`-coordinates of the
682
+ // * point in the viewport coordinate space.
683
+ // * @see {@link convertToPdfPoint}
684
+ // * @see {@link convertToViewportRectangle}
685
+ // */
686
+ // convertToViewportPoint(x, y) {
687
+ // return Util.applyTransform([x, y], this.transform);
688
+ // }
689
+ // /**
690
+ // * Converts PDF rectangle to the viewport coordinates.
691
+ // * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
692
+ // * @returns {Array} Array containing corresponding coordinates of the
693
+ // * rectangle in the viewport coordinate space.
694
+ // * @see {@link convertToViewportPoint}
695
+ // */
696
+ // convertToViewportRectangle(rect) {
697
+ // const topLeft = Util.applyTransform([rect[0], rect[1]], this.transform);
698
+ // const bottomRight = Util.applyTransform([rect[2], rect[3]], this.transform);
699
+ // return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
700
+ // }
701
+ // /**
702
+ // * Converts viewport coordinates to the PDF location. For examples, useful
703
+ // * for converting canvas pixel location into PDF one.
704
+ // * @param {number} x - The x-coordinate.
705
+ // * @param {number} y - The y-coordinate.
706
+ // * @returns {Array} Array containing `x`- and `y`-coordinates of the
707
+ // * point in the PDF coordinate space.
708
+ // * @see {@link convertToViewportPoint}
709
+ // */
710
+ // convertToPdfPoint(x, y) {
711
+ // return Util.applyInverseTransform([x, y], this.transform);
712
+ // }
713
+ // }
714
+ // class RenderingCancelledException extends BaseException {
715
+ // constructor(msg, extraDelay = 0) {
716
+ // super(msg, "RenderingCancelledException");
717
+ // this.extraDelay = extraDelay;
718
+ // }
719
+ // }
720
+ // function isDataScheme(url) {
721
+ // const ii = url.length;
722
+ // let i = 0;
723
+ // while (i < ii && url[i].trim() === "") {
724
+ // i++;
725
+ // }
726
+ // return url.substring(i, i + 5).toLowerCase() === "data:";
727
+ // }
728
+ // function isPdfFile(filename) {
729
+ // return typeof filename === "string" && /\.pdf$/i.test(filename);
730
+ // }
731
+ // /**
732
+ // * Gets the filename from a given URL.
733
+ // * @param {string} url
734
+ // * @returns {string}
735
+ // */
736
+ // function getFilenameFromUrl(url) {
737
+ // [url] = url.split(/[#?]/, 1);
738
+ // return url.substring(url.lastIndexOf("/") + 1);
739
+ // }
740
+ // /**
741
+ // * Returns the filename or guessed filename from the url (see issue 3455).
742
+ // * @param {string} url - The original PDF location.
743
+ // * @param {string} defaultFilename - The value returned if the filename is
744
+ // * unknown, or the protocol is unsupported.
745
+ // * @returns {string} Guessed PDF filename.
746
+ // */
747
+ // function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
748
+ // if (typeof url !== "string") {
749
+ // return defaultFilename;
750
+ // }
751
+ // if (isDataScheme(url)) {
752
+ // warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
753
+ // return defaultFilename;
754
+ // }
755
+ // const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
756
+ // // SCHEME HOST 1.PATH 2.QUERY 3.REF
757
+ // // Pattern to get last matching NAME.pdf
758
+ // const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
759
+ // const splitURI = reURI.exec(url);
760
+ // let suggestedFilename =
761
+ // reFilename.exec(splitURI[1]) ||
762
+ // reFilename.exec(splitURI[2]) ||
763
+ // reFilename.exec(splitURI[3]);
764
+ // if (suggestedFilename) {
765
+ // suggestedFilename = suggestedFilename[0];
766
+ // if (suggestedFilename.includes("%")) {
767
+ // // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
768
+ // try {
769
+ // suggestedFilename = reFilename.exec(
770
+ // decodeURIComponent(suggestedFilename)
771
+ // )[0];
772
+ // } catch {
773
+ // // Possible (extremely rare) errors:
774
+ // // URIError "Malformed URI", e.g. for "%AA.pdf"
775
+ // // TypeError "null has no properties", e.g. for "%2F.pdf"
776
+ // }
777
+ // }
778
+ // }
779
+ // return suggestedFilename || defaultFilename;
780
+ // }
781
+ // class StatTimer {
782
+ // started = Object.create(null);
783
+ // times = [];
784
+ // time(name) {
785
+ // if (name in this.started) {
786
+ // warn(`Timer is already running for ${name}`);
787
+ // }
788
+ // this.started[name] = Date.now();
789
+ // }
790
+ // timeEnd(name) {
791
+ // if (!(name in this.started)) {
792
+ // warn(`Timer has not been started for ${name}`);
793
+ // }
794
+ // this.times.push({
795
+ // name,
796
+ // start: this.started[name],
797
+ // end: Date.now(),
798
+ // });
799
+ // // Remove timer from started so it can be called again.
800
+ // delete this.started[name];
801
+ // }
802
+ // toString() {
803
+ // // Find the longest name for padding purposes.
804
+ // const outBuf = [];
805
+ // let longest = 0;
806
+ // for (const { name } of this.times) {
807
+ // longest = Math.max(name.length, longest);
808
+ // }
809
+ // for (const { name, start, end } of this.times) {
810
+ // outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
811
+ // }
812
+ // return outBuf.join("");
813
+ // }
814
+ // }
815
+ // function isValidFetchUrl(url, baseUrl) {
816
+ // if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
817
+ // throw new Error("Not implemented: isValidFetchUrl");
818
+ // }
819
+ // try {
820
+ // const { protocol } = baseUrl ? new URL(url, baseUrl) : new URL(url);
821
+ // // The Fetch API only supports the http/https protocols, and not file/ftp.
822
+ // return protocol === "http:" || protocol === "https:";
823
+ // } catch {
824
+ // return false; // `new URL()` will throw on incorrect data.
825
+ // }
826
+ // }
827
+ /**
828
+ * Event handler to suppress context menu.
829
+ */
830
+ function noContextMenu(e) {
831
+ e.preventDefault();
832
+ }
833
+ exports.noContextMenu = noContextMenu;
834
+ // // Deprecated API function -- display regardless of the `verbosity` setting.
835
+ // function deprecated(details) {
836
+ // console.log("Deprecated API usage: " + details);
837
+ // }
838
+ // let pdfDateStringRegex;
839
+ // class PDFDateString {
840
+ // /**
841
+ // * Convert a PDF date string to a JavaScript `Date` object.
842
+ // *
843
+ // * The PDF date string format is described in section 7.9.4 of the official
844
+ // * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth
845
+ // * edition) Adobe describes the same format including a trailing apostrophe.
846
+ // * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain
847
+ // * them. We ignore all apostrophes as they are not necessary for date parsing.
848
+ // *
849
+ // * Moreover, Adobe Acrobat doesn't handle changing the date to universal time
850
+ // * and doesn't use the user's time zone (effectively ignoring the HH' and mm'
851
+ // * parts of the date string).
852
+ // *
853
+ // * @param {string} input
854
+ // * @returns {Date|null}
855
+ // */
856
+ // static toDateObject(input) {
857
+ // if (!input || typeof input !== "string") {
858
+ // return null;
859
+ // }
860
+ // // Lazily initialize the regular expression.
861
+ // pdfDateStringRegex ||= new RegExp(
862
+ // "^D:" + // Prefix (required)
863
+ // "(\\d{4})" + // Year (required)
864
+ // "(\\d{2})?" + // Month (optional)
865
+ // "(\\d{2})?" + // Day (optional)
866
+ // "(\\d{2})?" + // Hour (optional)
867
+ // "(\\d{2})?" + // Minute (optional)
868
+ // "(\\d{2})?" + // Second (optional)
869
+ // "([Z|+|-])?" + // Universal time relation (optional)
870
+ // "(\\d{2})?" + // Offset hour (optional)
871
+ // "'?" + // Splitting apostrophe (optional)
872
+ // "(\\d{2})?" + // Offset minute (optional)
873
+ // "'?" // Trailing apostrophe (optional)
874
+ // );
875
+ // // Optional fields that don't satisfy the requirements from the regular
876
+ // // expression (such as incorrect digit counts or numbers that are out of
877
+ // // range) will fall back the defaults from the specification.
878
+ // const matches = pdfDateStringRegex.exec(input);
879
+ // if (!matches) {
880
+ // return null;
881
+ // }
882
+ // // JavaScript's `Date` object expects the month to be between 0 and 11
883
+ // // instead of 1 and 12, so we have to correct for that.
884
+ // const year = parseInt(matches[1], 10);
885
+ // let month = parseInt(matches[2], 10);
886
+ // month = month >= 1 && month <= 12 ? month - 1 : 0;
887
+ // let day = parseInt(matches[3], 10);
888
+ // day = day >= 1 && day <= 31 ? day : 1;
889
+ // let hour = parseInt(matches[4], 10);
890
+ // hour = hour >= 0 && hour <= 23 ? hour : 0;
891
+ // let minute = parseInt(matches[5], 10);
892
+ // minute = minute >= 0 && minute <= 59 ? minute : 0;
893
+ // let second = parseInt(matches[6], 10);
894
+ // second = second >= 0 && second <= 59 ? second : 0;
895
+ // const universalTimeRelation = matches[7] || "Z";
896
+ // let offsetHour = parseInt(matches[8], 10);
897
+ // offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
898
+ // let offsetMinute = parseInt(matches[9], 10) || 0;
899
+ // offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
900
+ // // Universal time relation 'Z' means that the local time is equal to the
901
+ // // universal time, whereas the relations '+'/'-' indicate that the local
902
+ // // time is later respectively earlier than the universal time. Every date
903
+ // // is normalized to universal time.
904
+ // if (universalTimeRelation === "-") {
905
+ // hour += offsetHour;
906
+ // minute += offsetMinute;
907
+ // } else if (universalTimeRelation === "+") {
908
+ // hour -= offsetHour;
909
+ // minute -= offsetMinute;
910
+ // }
911
+ // return new Date(Date.UTC(year, month, day, hour, minute, second));
912
+ // }
913
+ // }
914
+ // /**
915
+ // * NOTE: This is (mostly) intended to support printing of XFA forms.
916
+ // */
917
+ // function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {
918
+ // const { width, height } = xfaPage.attributes.style;
919
+ // const viewBox = [0, 0, parseInt(width), parseInt(height)];
920
+ // return new PageViewport({
921
+ // viewBox,
922
+ // scale,
923
+ // rotation,
924
+ // });
925
+ // }
926
+ function getRGB(color) {
927
+ if (color.startsWith("#")) {
928
+ const colorRGB = parseInt(color.slice(1), 16);
929
+ return [
930
+ (colorRGB & 0xff0000) >> 16,
931
+ (colorRGB & 0x00ff00) >> 8,
932
+ colorRGB & 0x0000ff
933
+ ];
934
+ }
935
+ if (color.startsWith("rgb(")) {
936
+ // getComputedStyle(...).color returns a `rgb(R, G, B)` color.
937
+ return color
938
+ .slice(/* "rgb(".length */ 4, -1) // Strip out "rgb(" and ")".
939
+ .split(",")
940
+ .map(x => parseInt(x, 10));
941
+ }
942
+ if (color.startsWith("rgba(")) {
943
+ return color
944
+ .slice(/* "rgba(".length */ 5, -1) // Strip out "rgba(" and ")".
945
+ .split(",")
946
+ .map(x => parseInt(x, 10))
947
+ .slice(0, 3);
948
+ }
949
+ // warn(`Not a valid color format: "${color}"`);
950
+ return [0, 0, 0];
951
+ }
952
+ exports.getRGB = getRGB;
953
+ function getColorValues(colors) {
954
+ const span = document.createElement("span");
955
+ span.style.visibility = "hidden";
956
+ document.body.append(span);
957
+ for (const name of colors.keys()) {
958
+ span.style.color = name;
959
+ const computedColor = window.getComputedStyle(span).color;
960
+ colors.set(name, getRGB(computedColor));
961
+ }
962
+ span.remove();
963
+ }
964
+ exports.getColorValues = getColorValues;
965
+ // function getCurrentTransform(ctx) {
966
+ // const { a, b, c, d, e, f } = ctx.getTransform();
967
+ // return [a, b, c, d, e, f];
968
+ // }
969
+ // function getCurrentTransformInverse(ctx) {
970
+ // const { a, b, c, d, e, f } = ctx.getTransform().invertSelf();
971
+ // return [a, b, c, d, e, f];
972
+ // }
973
+ // /**
974
+ // * @param {HTMLDivElement} div
975
+ // * @param {PageViewport} viewport
976
+ // * @param {boolean} mustFlip
977
+ // * @param {boolean} mustRotate
978
+ // */
979
+ // function setLayerDimensions(
980
+ // div,
981
+ // viewport,
982
+ // mustFlip = false,
983
+ // mustRotate = true
984
+ // ) {
985
+ // if (viewport instanceof PageViewport) {
986
+ // const { pageWidth, pageHeight } = viewport.rawDims;
987
+ // const { style } = div;
988
+ // const useRound = FeatureTest.isCSSRoundSupported;
989
+ // const w = `var(--scale-factor) * ${pageWidth}px`,
990
+ // h = `var(--scale-factor) * ${pageHeight}px`;
991
+ // const widthStr = useRound ? `round(${w}, 1px)` : `calc(${w})`,
992
+ // heightStr = useRound ? `round(${h}, 1px)` : `calc(${h})`;
993
+ // if (!mustFlip || viewport.rotation % 180 === 0) {
994
+ // style.width = widthStr;
995
+ // style.height = heightStr;
996
+ // } else {
997
+ // style.width = heightStr;
998
+ // style.height = widthStr;
999
+ // }
1000
+ // }
1001
+ // if (mustRotate) {
1002
+ // div.setAttribute("data-main-rotation", viewport.rotation);
1003
+ // }
1004
+ // }
1005
+ // export {
1006
+ // // deprecated,
1007
+ // // DOMCanvasFactory,
1008
+ // // DOMCMapReaderFactory,
1009
+ // // DOMFilterFactory,
1010
+ // // DOMStandardFontDataFactory,
1011
+ // // DOMSVGFactory,
1012
+ // // fetchData,
1013
+ // // getColorValues,
1014
+ // // getCurrentTransform,
1015
+ // // getCurrentTransformInverse,
1016
+ // // getFilenameFromUrl,
1017
+ // // getPdfFilenameFromUrl,
1018
+ // // getRGB,
1019
+ // // getXfaPageViewport,
1020
+ // // isDataScheme,
1021
+ // // isPdfFile,
1022
+ // // isValidFetchUrl,
1023
+ // // noContextMenu,
1024
+ // // PageViewport,
1025
+ // // PDFDateString,
1026
+ // // PixelsPerInch,
1027
+ // // RenderingCancelledException,
1028
+ // setLayerDimensions,
1029
+ // // StatTimer,
1030
+ // };