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