@pdfmergy-embedpdf/plugin-attachment 2.6.3

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 (45) hide show
  1. package/dist/index.cjs +2 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1571 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/attachment-plugin.d.ts +11 -0
  7. package/dist/lib/index.d.ts +7 -0
  8. package/dist/lib/manifest.d.ts +4 -0
  9. package/dist/lib/types.d.ts +13 -0
  10. package/dist/preact/core.d.ts +1 -0
  11. package/dist/preact/index.cjs +2 -0
  12. package/dist/preact/index.cjs.map +1 -0
  13. package/dist/preact/index.d.ts +1 -0
  14. package/dist/preact/index.js +1984 -0
  15. package/dist/preact/index.js.map +1 -0
  16. package/dist/react/core.d.ts +1 -0
  17. package/dist/react/index.cjs +2 -0
  18. package/dist/react/index.cjs.map +1 -0
  19. package/dist/react/index.d.ts +1 -0
  20. package/dist/react/index.js +1983 -0
  21. package/dist/react/index.js.map +1 -0
  22. package/dist/shared/hooks/index.d.ts +1 -0
  23. package/dist/shared/hooks/use-attachment.d.ts +11 -0
  24. package/dist/shared/index.d.ts +2 -0
  25. package/dist/shared-preact/hooks/index.d.ts +1 -0
  26. package/dist/shared-preact/hooks/use-attachment.d.ts +11 -0
  27. package/dist/shared-preact/index.d.ts +2 -0
  28. package/dist/shared-react/hooks/index.d.ts +1 -0
  29. package/dist/shared-react/hooks/use-attachment.d.ts +11 -0
  30. package/dist/shared-react/index.d.ts +2 -0
  31. package/dist/svelte/hooks/index.d.ts +1 -0
  32. package/dist/svelte/hooks/use-attachment.d.ts +11 -0
  33. package/dist/svelte/index.cjs +2 -0
  34. package/dist/svelte/index.cjs.map +1 -0
  35. package/dist/svelte/index.d.ts +1 -0
  36. package/dist/svelte/index.js +1952 -0
  37. package/dist/svelte/index.js.map +1 -0
  38. package/dist/vue/hooks/index.d.ts +1 -0
  39. package/dist/vue/hooks/use-attachment.d.ts +3 -0
  40. package/dist/vue/index.cjs +2 -0
  41. package/dist/vue/index.cjs.map +1 -0
  42. package/dist/vue/index.d.ts +2 -0
  43. package/dist/vue/index.js +1956 -0
  44. package/dist/vue/index.js.map +1 -0
  45. package/package.json +80 -0
@@ -0,0 +1,1952 @@
1
+ import * as $ from "svelte/internal/client";
2
+ import "svelte/internal/disclose-version";
3
+ const pdfContext = $.proxy({
4
+ registry: null,
5
+ coreState: null,
6
+ isInitializing: true,
7
+ pluginsReady: false,
8
+ activeDocumentId: null,
9
+ activeDocument: null,
10
+ documents: {},
11
+ documentStates: []
12
+ });
13
+ function usePlugin(pluginId) {
14
+ const { registry } = pdfContext;
15
+ const state = $.proxy({ plugin: null, isLoading: true, ready: new Promise(() => {
16
+ }) });
17
+ if (registry === null) {
18
+ return state;
19
+ }
20
+ const plugin = registry.getPlugin(pluginId);
21
+ if (!plugin) {
22
+ throw new Error(`Plugin ${pluginId} not found`);
23
+ }
24
+ state.plugin = plugin;
25
+ state.isLoading = false;
26
+ state.ready = plugin.ready();
27
+ return state;
28
+ }
29
+ function useCapability(pluginId) {
30
+ const p = usePlugin(pluginId);
31
+ const state = $.proxy({
32
+ provides: null,
33
+ isLoading: true,
34
+ ready: new Promise(() => {
35
+ })
36
+ });
37
+ $.user_effect(() => {
38
+ if (!p.plugin) {
39
+ state.provides = null;
40
+ state.isLoading = p.isLoading;
41
+ state.ready = p.ready;
42
+ return;
43
+ }
44
+ if (!p.plugin.provides) {
45
+ throw new Error(`Plugin ${pluginId} does not provide a capability`);
46
+ }
47
+ state.provides = p.plugin.provides();
48
+ state.isLoading = p.isLoading;
49
+ state.ready = p.ready;
50
+ });
51
+ return state;
52
+ }
53
+ const PdfSoftHyphenMarker$2 = "­";
54
+ const PdfZeroWidthSpace$2 = "​";
55
+ const PdfWordJoiner$2 = "⁠";
56
+ const PdfBomOrZwnbsp$2 = "\uFEFF";
57
+ const PdfNonCharacterFFFE$2 = "￾";
58
+ const PdfNonCharacterFFFF$2 = "￿";
59
+ const PdfUnwantedTextMarkers$2 = Object.freeze([
60
+ PdfSoftHyphenMarker$2,
61
+ PdfZeroWidthSpace$2,
62
+ PdfWordJoiner$2,
63
+ PdfBomOrZwnbsp$2,
64
+ PdfNonCharacterFFFE$2,
65
+ PdfNonCharacterFFFF$2
66
+ ]);
67
+ new RegExp(`[${PdfUnwantedTextMarkers$2.join("")}]`, "g");
68
+ var PdfStandardFont$2 = /* @__PURE__ */ ((PdfStandardFont2) => {
69
+ PdfStandardFont2[PdfStandardFont2["Unknown"] = -1] = "Unknown";
70
+ PdfStandardFont2[PdfStandardFont2["Courier"] = 0] = "Courier";
71
+ PdfStandardFont2[PdfStandardFont2["Courier_Bold"] = 1] = "Courier_Bold";
72
+ PdfStandardFont2[PdfStandardFont2["Courier_BoldOblique"] = 2] = "Courier_BoldOblique";
73
+ PdfStandardFont2[PdfStandardFont2["Courier_Oblique"] = 3] = "Courier_Oblique";
74
+ PdfStandardFont2[PdfStandardFont2["Helvetica"] = 4] = "Helvetica";
75
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Bold"] = 5] = "Helvetica_Bold";
76
+ PdfStandardFont2[PdfStandardFont2["Helvetica_BoldOblique"] = 6] = "Helvetica_BoldOblique";
77
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Oblique"] = 7] = "Helvetica_Oblique";
78
+ PdfStandardFont2[PdfStandardFont2["Times_Roman"] = 8] = "Times_Roman";
79
+ PdfStandardFont2[PdfStandardFont2["Times_Bold"] = 9] = "Times_Bold";
80
+ PdfStandardFont2[PdfStandardFont2["Times_BoldItalic"] = 10] = "Times_BoldItalic";
81
+ PdfStandardFont2[PdfStandardFont2["Times_Italic"] = 11] = "Times_Italic";
82
+ PdfStandardFont2[PdfStandardFont2["Symbol"] = 12] = "Symbol";
83
+ PdfStandardFont2[PdfStandardFont2["ZapfDingbats"] = 13] = "ZapfDingbats";
84
+ return PdfStandardFont2;
85
+ })(PdfStandardFont$2 || {});
86
+ var PdfTextAlignment$2 = /* @__PURE__ */ ((PdfTextAlignment2) => {
87
+ PdfTextAlignment2[PdfTextAlignment2["Left"] = 0] = "Left";
88
+ PdfTextAlignment2[PdfTextAlignment2["Center"] = 1] = "Center";
89
+ PdfTextAlignment2[PdfTextAlignment2["Right"] = 2] = "Right";
90
+ return PdfTextAlignment2;
91
+ })(PdfTextAlignment$2 || {});
92
+ var PdfBlendMode$2 = /* @__PURE__ */ ((PdfBlendMode2) => {
93
+ PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
94
+ PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
95
+ PdfBlendMode2[PdfBlendMode2["Screen"] = 2] = "Screen";
96
+ PdfBlendMode2[PdfBlendMode2["Overlay"] = 3] = "Overlay";
97
+ PdfBlendMode2[PdfBlendMode2["Darken"] = 4] = "Darken";
98
+ PdfBlendMode2[PdfBlendMode2["Lighten"] = 5] = "Lighten";
99
+ PdfBlendMode2[PdfBlendMode2["ColorDodge"] = 6] = "ColorDodge";
100
+ PdfBlendMode2[PdfBlendMode2["ColorBurn"] = 7] = "ColorBurn";
101
+ PdfBlendMode2[PdfBlendMode2["HardLight"] = 8] = "HardLight";
102
+ PdfBlendMode2[PdfBlendMode2["SoftLight"] = 9] = "SoftLight";
103
+ PdfBlendMode2[PdfBlendMode2["Difference"] = 10] = "Difference";
104
+ PdfBlendMode2[PdfBlendMode2["Exclusion"] = 11] = "Exclusion";
105
+ PdfBlendMode2[PdfBlendMode2["Hue"] = 12] = "Hue";
106
+ PdfBlendMode2[PdfBlendMode2["Saturation"] = 13] = "Saturation";
107
+ PdfBlendMode2[PdfBlendMode2["Color"] = 14] = "Color";
108
+ PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
109
+ return PdfBlendMode2;
110
+ })(PdfBlendMode$2 || {});
111
+ const PdfAnnotationFlagName$2 = Object.freeze({
112
+ [
113
+ 1
114
+ /* INVISIBLE */
115
+ ]: "invisible",
116
+ [
117
+ 2
118
+ /* HIDDEN */
119
+ ]: "hidden",
120
+ [
121
+ 4
122
+ /* PRINT */
123
+ ]: "print",
124
+ [
125
+ 8
126
+ /* NO_ZOOM */
127
+ ]: "noZoom",
128
+ [
129
+ 16
130
+ /* NO_ROTATE */
131
+ ]: "noRotate",
132
+ [
133
+ 32
134
+ /* NO_VIEW */
135
+ ]: "noView",
136
+ [
137
+ 64
138
+ /* READ_ONLY */
139
+ ]: "readOnly",
140
+ [
141
+ 128
142
+ /* LOCKED */
143
+ ]: "locked",
144
+ [
145
+ 256
146
+ /* TOGGLE_NOVIEW */
147
+ ]: "toggleNoView"
148
+ });
149
+ Object.entries(
150
+ PdfAnnotationFlagName$2
151
+ ).reduce(
152
+ (acc, [bit, name]) => {
153
+ acc[name] = Number(bit);
154
+ return acc;
155
+ },
156
+ {}
157
+ );
158
+ var PdfPermissionFlag$1 = /* @__PURE__ */ ((PdfPermissionFlag2) => {
159
+ PdfPermissionFlag2[PdfPermissionFlag2["Print"] = 4] = "Print";
160
+ PdfPermissionFlag2[PdfPermissionFlag2["ModifyContents"] = 8] = "ModifyContents";
161
+ PdfPermissionFlag2[PdfPermissionFlag2["CopyContents"] = 16] = "CopyContents";
162
+ PdfPermissionFlag2[PdfPermissionFlag2["ModifyAnnotations"] = 32] = "ModifyAnnotations";
163
+ PdfPermissionFlag2[PdfPermissionFlag2["FillForms"] = 256] = "FillForms";
164
+ PdfPermissionFlag2[PdfPermissionFlag2["ExtractForAccessibility"] = 512] = "ExtractForAccessibility";
165
+ PdfPermissionFlag2[PdfPermissionFlag2["AssembleDocument"] = 1024] = "AssembleDocument";
166
+ PdfPermissionFlag2[PdfPermissionFlag2["PrintHighQuality"] = 2048] = "PrintHighQuality";
167
+ PdfPermissionFlag2[PdfPermissionFlag2["AllowAll"] = 3900] = "AllowAll";
168
+ return PdfPermissionFlag2;
169
+ })(PdfPermissionFlag$1 || {});
170
+ const TEXT_ALIGNMENT_INFOS$2 = Object.freeze([
171
+ { id: PdfTextAlignment$2.Left, label: "Left", css: "left" },
172
+ { id: PdfTextAlignment$2.Center, label: "Center", css: "center" },
173
+ { id: PdfTextAlignment$2.Right, label: "Right", css: "right" }
174
+ ]);
175
+ TEXT_ALIGNMENT_INFOS$2.reduce(
176
+ (m, info) => {
177
+ m[info.id] = info;
178
+ return m;
179
+ },
180
+ {}
181
+ );
182
+ TEXT_ALIGNMENT_INFOS$2.reduce(
183
+ (m, info) => {
184
+ m[info.css] = info.id;
185
+ return m;
186
+ },
187
+ {}
188
+ );
189
+ TEXT_ALIGNMENT_INFOS$2.map((info) => ({
190
+ value: info.id,
191
+ label: info.label
192
+ }));
193
+ var PdfStandardFontFamily$2 = /* @__PURE__ */ ((PdfStandardFontFamily2) => {
194
+ PdfStandardFontFamily2["Courier"] = "Courier";
195
+ PdfStandardFontFamily2["Helvetica"] = "Helvetica";
196
+ PdfStandardFontFamily2["Times"] = "Times";
197
+ PdfStandardFontFamily2["Symbol"] = "Symbol";
198
+ PdfStandardFontFamily2["ZapfDingbats"] = "ZapfDingbats";
199
+ PdfStandardFontFamily2["Unknown"] = "Unknown";
200
+ return PdfStandardFontFamily2;
201
+ })(PdfStandardFontFamily$2 || {});
202
+ PdfStandardFont$2.Helvetica;
203
+ const HELVETICA_DESC$2 = {
204
+ id: PdfStandardFont$2.Helvetica,
205
+ family: "Helvetica",
206
+ bold: false,
207
+ italic: false,
208
+ label: "Helvetica",
209
+ css: "Helvetica, Arial, sans-serif"
210
+ };
211
+ const STANDARD_FONT_DESCRIPTORS$2 = Object.freeze([
212
+ {
213
+ id: PdfStandardFont$2.Courier,
214
+ family: "Courier",
215
+ bold: false,
216
+ italic: false,
217
+ label: "Courier",
218
+ css: "Courier, monospace"
219
+ },
220
+ {
221
+ id: PdfStandardFont$2.Courier_Bold,
222
+ family: "Courier",
223
+ bold: true,
224
+ italic: false,
225
+ label: "Courier Bold",
226
+ css: "Courier, monospace"
227
+ },
228
+ {
229
+ id: PdfStandardFont$2.Courier_BoldOblique,
230
+ family: "Courier",
231
+ bold: true,
232
+ italic: true,
233
+ label: "Courier Bold Oblique",
234
+ css: "Courier, monospace"
235
+ },
236
+ {
237
+ id: PdfStandardFont$2.Courier_Oblique,
238
+ family: "Courier",
239
+ bold: false,
240
+ italic: true,
241
+ label: "Courier Oblique",
242
+ css: "Courier, monospace"
243
+ },
244
+ HELVETICA_DESC$2,
245
+ {
246
+ id: PdfStandardFont$2.Helvetica_Bold,
247
+ family: "Helvetica",
248
+ bold: true,
249
+ italic: false,
250
+ label: "Helvetica Bold",
251
+ css: "Helvetica, Arial, sans-serif"
252
+ },
253
+ {
254
+ id: PdfStandardFont$2.Helvetica_BoldOblique,
255
+ family: "Helvetica",
256
+ bold: true,
257
+ italic: true,
258
+ label: "Helvetica Bold Oblique",
259
+ css: "Helvetica, Arial, sans-serif"
260
+ },
261
+ {
262
+ id: PdfStandardFont$2.Helvetica_Oblique,
263
+ family: "Helvetica",
264
+ bold: false,
265
+ italic: true,
266
+ label: "Helvetica Oblique",
267
+ css: "Helvetica, Arial, sans-serif"
268
+ },
269
+ {
270
+ id: PdfStandardFont$2.Times_Roman,
271
+ family: "Times",
272
+ bold: false,
273
+ italic: false,
274
+ label: "Times Roman",
275
+ css: '"Times New Roman", Times, serif'
276
+ },
277
+ {
278
+ id: PdfStandardFont$2.Times_Bold,
279
+ family: "Times",
280
+ bold: true,
281
+ italic: false,
282
+ label: "Times Bold",
283
+ css: '"Times New Roman", Times, serif'
284
+ },
285
+ {
286
+ id: PdfStandardFont$2.Times_BoldItalic,
287
+ family: "Times",
288
+ bold: true,
289
+ italic: true,
290
+ label: "Times Bold Italic",
291
+ css: '"Times New Roman", Times, serif'
292
+ },
293
+ {
294
+ id: PdfStandardFont$2.Times_Italic,
295
+ family: "Times",
296
+ bold: false,
297
+ italic: true,
298
+ label: "Times Italic",
299
+ css: '"Times New Roman", Times, serif'
300
+ },
301
+ {
302
+ id: PdfStandardFont$2.Symbol,
303
+ family: "Symbol",
304
+ bold: false,
305
+ italic: false,
306
+ label: "Symbol",
307
+ css: "Symbol, serif"
308
+ },
309
+ {
310
+ id: PdfStandardFont$2.ZapfDingbats,
311
+ family: "ZapfDingbats",
312
+ bold: false,
313
+ italic: false,
314
+ label: "Zapf Dingbats",
315
+ css: "ZapfDingbats, serif"
316
+ }
317
+ ]);
318
+ STANDARD_FONT_DESCRIPTORS$2.reduce((m, d) => (m[d.id] = d, m), {});
319
+ const familyStyleToId$2 = /* @__PURE__ */ new Map();
320
+ for (const d of STANDARD_FONT_DESCRIPTORS$2) {
321
+ familyStyleToId$2.set(`${d.family}_${d.bold}_${d.italic}`, d.id);
322
+ }
323
+ Object.values(PdfStandardFontFamily$2).filter(
324
+ (f) => f !== "Unknown"
325
+ /* Unknown */
326
+ ).map((family) => ({ value: family, label: family }));
327
+ [
328
+ ...new Set(STANDARD_FONT_DESCRIPTORS$2.map((d) => d.family))
329
+ ];
330
+ const BLEND_MODE_INFOS$2 = Object.freeze([
331
+ { id: PdfBlendMode$2.Normal, label: "Normal", css: "normal" },
332
+ { id: PdfBlendMode$2.Multiply, label: "Multiply", css: "multiply" },
333
+ { id: PdfBlendMode$2.Screen, label: "Screen", css: "screen" },
334
+ { id: PdfBlendMode$2.Overlay, label: "Overlay", css: "overlay" },
335
+ { id: PdfBlendMode$2.Darken, label: "Darken", css: "darken" },
336
+ { id: PdfBlendMode$2.Lighten, label: "Lighten", css: "lighten" },
337
+ { id: PdfBlendMode$2.ColorDodge, label: "Color Dodge", css: "color-dodge" },
338
+ { id: PdfBlendMode$2.ColorBurn, label: "Color Burn", css: "color-burn" },
339
+ { id: PdfBlendMode$2.HardLight, label: "Hard Light", css: "hard-light" },
340
+ { id: PdfBlendMode$2.SoftLight, label: "Soft Light", css: "soft-light" },
341
+ { id: PdfBlendMode$2.Difference, label: "Difference", css: "difference" },
342
+ { id: PdfBlendMode$2.Exclusion, label: "Exclusion", css: "exclusion" },
343
+ { id: PdfBlendMode$2.Hue, label: "Hue", css: "hue" },
344
+ { id: PdfBlendMode$2.Saturation, label: "Saturation", css: "saturation" },
345
+ { id: PdfBlendMode$2.Color, label: "Color", css: "color" },
346
+ { id: PdfBlendMode$2.Luminosity, label: "Luminosity", css: "luminosity" }
347
+ ]);
348
+ BLEND_MODE_INFOS$2.reduce(
349
+ (m, info) => {
350
+ m[info.id] = info;
351
+ return m;
352
+ },
353
+ {}
354
+ );
355
+ BLEND_MODE_INFOS$2.reduce(
356
+ (m, info) => {
357
+ m[info.css] = info.id;
358
+ return m;
359
+ },
360
+ {}
361
+ );
362
+ BLEND_MODE_INFOS$2.map((info) => ({
363
+ value: info.id,
364
+ label: info.label
365
+ }));
366
+ BLEND_MODE_INFOS$2.map((info) => info.id);
367
+ ({
368
+ print: PdfPermissionFlag$1.Print,
369
+ modifyContents: PdfPermissionFlag$1.ModifyContents,
370
+ copyContents: PdfPermissionFlag$1.CopyContents,
371
+ modifyAnnotations: PdfPermissionFlag$1.ModifyAnnotations,
372
+ fillForms: PdfPermissionFlag$1.FillForms,
373
+ extractForAccessibility: PdfPermissionFlag$1.ExtractForAccessibility,
374
+ assembleDocument: PdfPermissionFlag$1.AssembleDocument,
375
+ printHighQuality: PdfPermissionFlag$1.PrintHighQuality
376
+ });
377
+ [
378
+ PdfPermissionFlag$1.Print,
379
+ PdfPermissionFlag$1.ModifyContents,
380
+ PdfPermissionFlag$1.CopyContents,
381
+ PdfPermissionFlag$1.ModifyAnnotations,
382
+ PdfPermissionFlag$1.FillForms,
383
+ PdfPermissionFlag$1.ExtractForAccessibility,
384
+ PdfPermissionFlag$1.AssembleDocument,
385
+ PdfPermissionFlag$1.PrintHighQuality
386
+ ];
387
+ ({
388
+ [PdfPermissionFlag$1.Print]: "print",
389
+ [PdfPermissionFlag$1.ModifyContents]: "modifyContents",
390
+ [PdfPermissionFlag$1.CopyContents]: "copyContents",
391
+ [PdfPermissionFlag$1.ModifyAnnotations]: "modifyAnnotations",
392
+ [PdfPermissionFlag$1.FillForms]: "fillForms",
393
+ [PdfPermissionFlag$1.ExtractForAccessibility]: "extractForAccessibility",
394
+ [PdfPermissionFlag$1.AssembleDocument]: "assembleDocument",
395
+ [PdfPermissionFlag$1.PrintHighQuality]: "printHighQuality"
396
+ });
397
+ $.from_html(`<!> <!>`, 1);
398
+ $.from_html(`<!> <!>`, 1);
399
+ const PdfSoftHyphenMarker$1 = "­";
400
+ const PdfZeroWidthSpace$1 = "​";
401
+ const PdfWordJoiner$1 = "⁠";
402
+ const PdfBomOrZwnbsp$1 = "\uFEFF";
403
+ const PdfNonCharacterFFFE$1 = "￾";
404
+ const PdfNonCharacterFFFF$1 = "￿";
405
+ const PdfUnwantedTextMarkers$1 = Object.freeze([
406
+ PdfSoftHyphenMarker$1,
407
+ PdfZeroWidthSpace$1,
408
+ PdfWordJoiner$1,
409
+ PdfBomOrZwnbsp$1,
410
+ PdfNonCharacterFFFE$1,
411
+ PdfNonCharacterFFFF$1
412
+ ]);
413
+ new RegExp(`[${PdfUnwantedTextMarkers$1.join("")}]`, "g");
414
+ var PdfStandardFont$1 = /* @__PURE__ */ ((PdfStandardFont2) => {
415
+ PdfStandardFont2[PdfStandardFont2["Unknown"] = -1] = "Unknown";
416
+ PdfStandardFont2[PdfStandardFont2["Courier"] = 0] = "Courier";
417
+ PdfStandardFont2[PdfStandardFont2["Courier_Bold"] = 1] = "Courier_Bold";
418
+ PdfStandardFont2[PdfStandardFont2["Courier_BoldOblique"] = 2] = "Courier_BoldOblique";
419
+ PdfStandardFont2[PdfStandardFont2["Courier_Oblique"] = 3] = "Courier_Oblique";
420
+ PdfStandardFont2[PdfStandardFont2["Helvetica"] = 4] = "Helvetica";
421
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Bold"] = 5] = "Helvetica_Bold";
422
+ PdfStandardFont2[PdfStandardFont2["Helvetica_BoldOblique"] = 6] = "Helvetica_BoldOblique";
423
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Oblique"] = 7] = "Helvetica_Oblique";
424
+ PdfStandardFont2[PdfStandardFont2["Times_Roman"] = 8] = "Times_Roman";
425
+ PdfStandardFont2[PdfStandardFont2["Times_Bold"] = 9] = "Times_Bold";
426
+ PdfStandardFont2[PdfStandardFont2["Times_BoldItalic"] = 10] = "Times_BoldItalic";
427
+ PdfStandardFont2[PdfStandardFont2["Times_Italic"] = 11] = "Times_Italic";
428
+ PdfStandardFont2[PdfStandardFont2["Symbol"] = 12] = "Symbol";
429
+ PdfStandardFont2[PdfStandardFont2["ZapfDingbats"] = 13] = "ZapfDingbats";
430
+ return PdfStandardFont2;
431
+ })(PdfStandardFont$1 || {});
432
+ var PdfTextAlignment$1 = /* @__PURE__ */ ((PdfTextAlignment2) => {
433
+ PdfTextAlignment2[PdfTextAlignment2["Left"] = 0] = "Left";
434
+ PdfTextAlignment2[PdfTextAlignment2["Center"] = 1] = "Center";
435
+ PdfTextAlignment2[PdfTextAlignment2["Right"] = 2] = "Right";
436
+ return PdfTextAlignment2;
437
+ })(PdfTextAlignment$1 || {});
438
+ var PdfBlendMode$1 = /* @__PURE__ */ ((PdfBlendMode2) => {
439
+ PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
440
+ PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
441
+ PdfBlendMode2[PdfBlendMode2["Screen"] = 2] = "Screen";
442
+ PdfBlendMode2[PdfBlendMode2["Overlay"] = 3] = "Overlay";
443
+ PdfBlendMode2[PdfBlendMode2["Darken"] = 4] = "Darken";
444
+ PdfBlendMode2[PdfBlendMode2["Lighten"] = 5] = "Lighten";
445
+ PdfBlendMode2[PdfBlendMode2["ColorDodge"] = 6] = "ColorDodge";
446
+ PdfBlendMode2[PdfBlendMode2["ColorBurn"] = 7] = "ColorBurn";
447
+ PdfBlendMode2[PdfBlendMode2["HardLight"] = 8] = "HardLight";
448
+ PdfBlendMode2[PdfBlendMode2["SoftLight"] = 9] = "SoftLight";
449
+ PdfBlendMode2[PdfBlendMode2["Difference"] = 10] = "Difference";
450
+ PdfBlendMode2[PdfBlendMode2["Exclusion"] = 11] = "Exclusion";
451
+ PdfBlendMode2[PdfBlendMode2["Hue"] = 12] = "Hue";
452
+ PdfBlendMode2[PdfBlendMode2["Saturation"] = 13] = "Saturation";
453
+ PdfBlendMode2[PdfBlendMode2["Color"] = 14] = "Color";
454
+ PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
455
+ return PdfBlendMode2;
456
+ })(PdfBlendMode$1 || {});
457
+ const PdfAnnotationFlagName$1 = Object.freeze({
458
+ [
459
+ 1
460
+ /* INVISIBLE */
461
+ ]: "invisible",
462
+ [
463
+ 2
464
+ /* HIDDEN */
465
+ ]: "hidden",
466
+ [
467
+ 4
468
+ /* PRINT */
469
+ ]: "print",
470
+ [
471
+ 8
472
+ /* NO_ZOOM */
473
+ ]: "noZoom",
474
+ [
475
+ 16
476
+ /* NO_ROTATE */
477
+ ]: "noRotate",
478
+ [
479
+ 32
480
+ /* NO_VIEW */
481
+ ]: "noView",
482
+ [
483
+ 64
484
+ /* READ_ONLY */
485
+ ]: "readOnly",
486
+ [
487
+ 128
488
+ /* LOCKED */
489
+ ]: "locked",
490
+ [
491
+ 256
492
+ /* TOGGLE_NOVIEW */
493
+ ]: "toggleNoView"
494
+ });
495
+ Object.entries(
496
+ PdfAnnotationFlagName$1
497
+ ).reduce(
498
+ (acc, [bit, name]) => {
499
+ acc[name] = Number(bit);
500
+ return acc;
501
+ },
502
+ {}
503
+ );
504
+ var PdfPermissionFlag = /* @__PURE__ */ ((PdfPermissionFlag2) => {
505
+ PdfPermissionFlag2[PdfPermissionFlag2["Print"] = 4] = "Print";
506
+ PdfPermissionFlag2[PdfPermissionFlag2["ModifyContents"] = 8] = "ModifyContents";
507
+ PdfPermissionFlag2[PdfPermissionFlag2["CopyContents"] = 16] = "CopyContents";
508
+ PdfPermissionFlag2[PdfPermissionFlag2["ModifyAnnotations"] = 32] = "ModifyAnnotations";
509
+ PdfPermissionFlag2[PdfPermissionFlag2["FillForms"] = 256] = "FillForms";
510
+ PdfPermissionFlag2[PdfPermissionFlag2["ExtractForAccessibility"] = 512] = "ExtractForAccessibility";
511
+ PdfPermissionFlag2[PdfPermissionFlag2["AssembleDocument"] = 1024] = "AssembleDocument";
512
+ PdfPermissionFlag2[PdfPermissionFlag2["PrintHighQuality"] = 2048] = "PrintHighQuality";
513
+ PdfPermissionFlag2[PdfPermissionFlag2["AllowAll"] = 3900] = "AllowAll";
514
+ return PdfPermissionFlag2;
515
+ })(PdfPermissionFlag || {});
516
+ class PermissionDeniedError extends Error {
517
+ constructor(requiredFlags, currentPermissions) {
518
+ const flagNames = requiredFlags.map((f) => PdfPermissionFlag[f]).join(", ");
519
+ super(`Permission denied. Required: ${flagNames}`);
520
+ this.requiredFlags = requiredFlags;
521
+ this.currentPermissions = currentPermissions;
522
+ this.name = "PermissionDeniedError";
523
+ }
524
+ }
525
+ const TEXT_ALIGNMENT_INFOS$1 = Object.freeze([
526
+ { id: PdfTextAlignment$1.Left, label: "Left", css: "left" },
527
+ { id: PdfTextAlignment$1.Center, label: "Center", css: "center" },
528
+ { id: PdfTextAlignment$1.Right, label: "Right", css: "right" }
529
+ ]);
530
+ TEXT_ALIGNMENT_INFOS$1.reduce(
531
+ (m, info) => {
532
+ m[info.id] = info;
533
+ return m;
534
+ },
535
+ {}
536
+ );
537
+ TEXT_ALIGNMENT_INFOS$1.reduce(
538
+ (m, info) => {
539
+ m[info.css] = info.id;
540
+ return m;
541
+ },
542
+ {}
543
+ );
544
+ TEXT_ALIGNMENT_INFOS$1.map((info) => ({
545
+ value: info.id,
546
+ label: info.label
547
+ }));
548
+ var PdfStandardFontFamily$1 = /* @__PURE__ */ ((PdfStandardFontFamily2) => {
549
+ PdfStandardFontFamily2["Courier"] = "Courier";
550
+ PdfStandardFontFamily2["Helvetica"] = "Helvetica";
551
+ PdfStandardFontFamily2["Times"] = "Times";
552
+ PdfStandardFontFamily2["Symbol"] = "Symbol";
553
+ PdfStandardFontFamily2["ZapfDingbats"] = "ZapfDingbats";
554
+ PdfStandardFontFamily2["Unknown"] = "Unknown";
555
+ return PdfStandardFontFamily2;
556
+ })(PdfStandardFontFamily$1 || {});
557
+ PdfStandardFont$1.Helvetica;
558
+ const HELVETICA_DESC$1 = {
559
+ id: PdfStandardFont$1.Helvetica,
560
+ family: "Helvetica",
561
+ bold: false,
562
+ italic: false,
563
+ label: "Helvetica",
564
+ css: "Helvetica, Arial, sans-serif"
565
+ };
566
+ const STANDARD_FONT_DESCRIPTORS$1 = Object.freeze([
567
+ {
568
+ id: PdfStandardFont$1.Courier,
569
+ family: "Courier",
570
+ bold: false,
571
+ italic: false,
572
+ label: "Courier",
573
+ css: "Courier, monospace"
574
+ },
575
+ {
576
+ id: PdfStandardFont$1.Courier_Bold,
577
+ family: "Courier",
578
+ bold: true,
579
+ italic: false,
580
+ label: "Courier Bold",
581
+ css: "Courier, monospace"
582
+ },
583
+ {
584
+ id: PdfStandardFont$1.Courier_BoldOblique,
585
+ family: "Courier",
586
+ bold: true,
587
+ italic: true,
588
+ label: "Courier Bold Oblique",
589
+ css: "Courier, monospace"
590
+ },
591
+ {
592
+ id: PdfStandardFont$1.Courier_Oblique,
593
+ family: "Courier",
594
+ bold: false,
595
+ italic: true,
596
+ label: "Courier Oblique",
597
+ css: "Courier, monospace"
598
+ },
599
+ HELVETICA_DESC$1,
600
+ {
601
+ id: PdfStandardFont$1.Helvetica_Bold,
602
+ family: "Helvetica",
603
+ bold: true,
604
+ italic: false,
605
+ label: "Helvetica Bold",
606
+ css: "Helvetica, Arial, sans-serif"
607
+ },
608
+ {
609
+ id: PdfStandardFont$1.Helvetica_BoldOblique,
610
+ family: "Helvetica",
611
+ bold: true,
612
+ italic: true,
613
+ label: "Helvetica Bold Oblique",
614
+ css: "Helvetica, Arial, sans-serif"
615
+ },
616
+ {
617
+ id: PdfStandardFont$1.Helvetica_Oblique,
618
+ family: "Helvetica",
619
+ bold: false,
620
+ italic: true,
621
+ label: "Helvetica Oblique",
622
+ css: "Helvetica, Arial, sans-serif"
623
+ },
624
+ {
625
+ id: PdfStandardFont$1.Times_Roman,
626
+ family: "Times",
627
+ bold: false,
628
+ italic: false,
629
+ label: "Times Roman",
630
+ css: '"Times New Roman", Times, serif'
631
+ },
632
+ {
633
+ id: PdfStandardFont$1.Times_Bold,
634
+ family: "Times",
635
+ bold: true,
636
+ italic: false,
637
+ label: "Times Bold",
638
+ css: '"Times New Roman", Times, serif'
639
+ },
640
+ {
641
+ id: PdfStandardFont$1.Times_BoldItalic,
642
+ family: "Times",
643
+ bold: true,
644
+ italic: true,
645
+ label: "Times Bold Italic",
646
+ css: '"Times New Roman", Times, serif'
647
+ },
648
+ {
649
+ id: PdfStandardFont$1.Times_Italic,
650
+ family: "Times",
651
+ bold: false,
652
+ italic: true,
653
+ label: "Times Italic",
654
+ css: '"Times New Roman", Times, serif'
655
+ },
656
+ {
657
+ id: PdfStandardFont$1.Symbol,
658
+ family: "Symbol",
659
+ bold: false,
660
+ italic: false,
661
+ label: "Symbol",
662
+ css: "Symbol, serif"
663
+ },
664
+ {
665
+ id: PdfStandardFont$1.ZapfDingbats,
666
+ family: "ZapfDingbats",
667
+ bold: false,
668
+ italic: false,
669
+ label: "Zapf Dingbats",
670
+ css: "ZapfDingbats, serif"
671
+ }
672
+ ]);
673
+ STANDARD_FONT_DESCRIPTORS$1.reduce((m, d) => (m[d.id] = d, m), {});
674
+ const familyStyleToId$1 = /* @__PURE__ */ new Map();
675
+ for (const d of STANDARD_FONT_DESCRIPTORS$1) {
676
+ familyStyleToId$1.set(`${d.family}_${d.bold}_${d.italic}`, d.id);
677
+ }
678
+ Object.values(PdfStandardFontFamily$1).filter(
679
+ (f) => f !== "Unknown"
680
+ /* Unknown */
681
+ ).map((family) => ({ value: family, label: family }));
682
+ [
683
+ ...new Set(STANDARD_FONT_DESCRIPTORS$1.map((d) => d.family))
684
+ ];
685
+ const BLEND_MODE_INFOS$1 = Object.freeze([
686
+ { id: PdfBlendMode$1.Normal, label: "Normal", css: "normal" },
687
+ { id: PdfBlendMode$1.Multiply, label: "Multiply", css: "multiply" },
688
+ { id: PdfBlendMode$1.Screen, label: "Screen", css: "screen" },
689
+ { id: PdfBlendMode$1.Overlay, label: "Overlay", css: "overlay" },
690
+ { id: PdfBlendMode$1.Darken, label: "Darken", css: "darken" },
691
+ { id: PdfBlendMode$1.Lighten, label: "Lighten", css: "lighten" },
692
+ { id: PdfBlendMode$1.ColorDodge, label: "Color Dodge", css: "color-dodge" },
693
+ { id: PdfBlendMode$1.ColorBurn, label: "Color Burn", css: "color-burn" },
694
+ { id: PdfBlendMode$1.HardLight, label: "Hard Light", css: "hard-light" },
695
+ { id: PdfBlendMode$1.SoftLight, label: "Soft Light", css: "soft-light" },
696
+ { id: PdfBlendMode$1.Difference, label: "Difference", css: "difference" },
697
+ { id: PdfBlendMode$1.Exclusion, label: "Exclusion", css: "exclusion" },
698
+ { id: PdfBlendMode$1.Hue, label: "Hue", css: "hue" },
699
+ { id: PdfBlendMode$1.Saturation, label: "Saturation", css: "saturation" },
700
+ { id: PdfBlendMode$1.Color, label: "Color", css: "color" },
701
+ { id: PdfBlendMode$1.Luminosity, label: "Luminosity", css: "luminosity" }
702
+ ]);
703
+ BLEND_MODE_INFOS$1.reduce(
704
+ (m, info) => {
705
+ m[info.id] = info;
706
+ return m;
707
+ },
708
+ {}
709
+ );
710
+ BLEND_MODE_INFOS$1.reduce(
711
+ (m, info) => {
712
+ m[info.css] = info.id;
713
+ return m;
714
+ },
715
+ {}
716
+ );
717
+ BLEND_MODE_INFOS$1.map((info) => ({
718
+ value: info.id,
719
+ label: info.label
720
+ }));
721
+ BLEND_MODE_INFOS$1.map((info) => info.id);
722
+ const START_LOADING_DOCUMENT = "START_LOADING_DOCUMENT";
723
+ const SET_DOCUMENT_LOADED = "SET_DOCUMENT_LOADED";
724
+ const CLOSE_DOCUMENT = "CLOSE_DOCUMENT";
725
+ const SET_SCALE = "SET_SCALE";
726
+ const SET_ROTATION = "SET_ROTATION";
727
+ ({
728
+ print: PdfPermissionFlag.Print,
729
+ modifyContents: PdfPermissionFlag.ModifyContents,
730
+ copyContents: PdfPermissionFlag.CopyContents,
731
+ modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,
732
+ fillForms: PdfPermissionFlag.FillForms,
733
+ extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,
734
+ assembleDocument: PdfPermissionFlag.AssembleDocument,
735
+ printHighQuality: PdfPermissionFlag.PrintHighQuality
736
+ });
737
+ const ALL_PERMISSION_FLAGS = [
738
+ PdfPermissionFlag.Print,
739
+ PdfPermissionFlag.ModifyContents,
740
+ PdfPermissionFlag.CopyContents,
741
+ PdfPermissionFlag.ModifyAnnotations,
742
+ PdfPermissionFlag.FillForms,
743
+ PdfPermissionFlag.ExtractForAccessibility,
744
+ PdfPermissionFlag.AssembleDocument,
745
+ PdfPermissionFlag.PrintHighQuality
746
+ ];
747
+ const PERMISSION_FLAG_TO_NAME = {
748
+ [PdfPermissionFlag.Print]: "print",
749
+ [PdfPermissionFlag.ModifyContents]: "modifyContents",
750
+ [PdfPermissionFlag.CopyContents]: "copyContents",
751
+ [PdfPermissionFlag.ModifyAnnotations]: "modifyAnnotations",
752
+ [PdfPermissionFlag.FillForms]: "fillForms",
753
+ [PdfPermissionFlag.ExtractForAccessibility]: "extractForAccessibility",
754
+ [PdfPermissionFlag.AssembleDocument]: "assembleDocument",
755
+ [PdfPermissionFlag.PrintHighQuality]: "printHighQuality"
756
+ };
757
+ function getPermissionOverride(overrides, flag) {
758
+ if (!overrides) return void 0;
759
+ if (flag in overrides) {
760
+ return overrides[flag];
761
+ }
762
+ const name = PERMISSION_FLAG_TO_NAME[flag];
763
+ if (name && name in overrides) {
764
+ return overrides[name];
765
+ }
766
+ return void 0;
767
+ }
768
+ function getEffectivePermission(state, documentId, flag) {
769
+ var _a;
770
+ const docState = state.documents[documentId];
771
+ const docConfig = docState == null ? void 0 : docState.permissions;
772
+ const globalConfig = state.globalPermissions;
773
+ const pdfPermissions = ((_a = docState == null ? void 0 : docState.document) == null ? void 0 : _a.permissions) ?? PdfPermissionFlag.AllowAll;
774
+ const docOverride = getPermissionOverride(docConfig == null ? void 0 : docConfig.overrides, flag);
775
+ if (docOverride !== void 0) {
776
+ return docOverride;
777
+ }
778
+ const globalOverride = getPermissionOverride(globalConfig == null ? void 0 : globalConfig.overrides, flag);
779
+ if (globalOverride !== void 0) {
780
+ return globalOverride;
781
+ }
782
+ const enforce = (docConfig == null ? void 0 : docConfig.enforceDocumentPermissions) ?? (globalConfig == null ? void 0 : globalConfig.enforceDocumentPermissions) ?? true;
783
+ if (!enforce) return true;
784
+ return (pdfPermissions & flag) !== 0;
785
+ }
786
+ function getEffectivePermissions(state, documentId) {
787
+ return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {
788
+ return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;
789
+ }, 0);
790
+ }
791
+ class BasePlugin {
792
+ constructor(id, registry) {
793
+ this.id = id;
794
+ this.registry = registry;
795
+ this.cooldownActions = {};
796
+ this.debouncedTimeouts = {};
797
+ this.unsubscribeFromState = null;
798
+ this.unsubscribeFromCoreStore = null;
799
+ this.unsubscribeFromStartLoadingDocument = null;
800
+ this.unsubscribeFromSetDocumentLoaded = null;
801
+ this.unsubscribeFromCloseDocument = null;
802
+ this.unsubscribeFromSetScale = null;
803
+ this.unsubscribeFromSetRotation = null;
804
+ if (id !== this.constructor.id) {
805
+ throw new Error(
806
+ `Plugin ID mismatch: ${id} !== ${this.constructor.id}`
807
+ );
808
+ }
809
+ this.engine = this.registry.getEngine();
810
+ this.logger = this.registry.getLogger();
811
+ this.coreStore = this.registry.getStore();
812
+ this.pluginStore = this.coreStore.getPluginStore(this.id);
813
+ this.unsubscribeFromState = this.pluginStore.subscribeToState((action, newState, oldState) => {
814
+ this.onStoreUpdated(oldState, newState);
815
+ });
816
+ this.unsubscribeFromCoreStore = this.coreStore.subscribe((action, newState, oldState) => {
817
+ this.onCoreStoreUpdated(oldState, newState);
818
+ if (newState.core.activeDocumentId !== oldState.core.activeDocumentId) {
819
+ this.onActiveDocumentChanged(
820
+ oldState.core.activeDocumentId,
821
+ newState.core.activeDocumentId
822
+ );
823
+ }
824
+ });
825
+ this.unsubscribeFromStartLoadingDocument = this.coreStore.onAction(
826
+ START_LOADING_DOCUMENT,
827
+ (action) => {
828
+ this.onDocumentLoadingStarted(action.payload.documentId);
829
+ }
830
+ );
831
+ this.unsubscribeFromSetDocumentLoaded = this.coreStore.onAction(
832
+ SET_DOCUMENT_LOADED,
833
+ (action) => {
834
+ this.onDocumentLoaded(action.payload.documentId);
835
+ }
836
+ );
837
+ this.unsubscribeFromCloseDocument = this.coreStore.onAction(CLOSE_DOCUMENT, (action) => {
838
+ this.onDocumentClosed(action.payload.documentId);
839
+ });
840
+ this.unsubscribeFromSetScale = this.coreStore.onAction(SET_SCALE, (action, state) => {
841
+ const targetId = action.payload.documentId ?? state.core.activeDocumentId;
842
+ if (targetId) {
843
+ this.onScaleChanged(targetId, action.payload.scale);
844
+ }
845
+ });
846
+ this.unsubscribeFromSetRotation = this.coreStore.onAction(SET_ROTATION, (action, state) => {
847
+ const targetId = action.payload.documentId ?? state.core.activeDocumentId;
848
+ if (targetId) {
849
+ this.onRotationChanged(targetId, action.payload.rotation);
850
+ }
851
+ });
852
+ this.readyPromise = new Promise((resolve) => {
853
+ this.readyResolve = resolve;
854
+ });
855
+ this.readyResolve();
856
+ }
857
+ provides() {
858
+ if (!this._capability) {
859
+ const cap = this.buildCapability();
860
+ this._capability = Object.freeze(cap);
861
+ }
862
+ return this._capability;
863
+ }
864
+ /**
865
+ * Get a copy of the current state
866
+ */
867
+ get state() {
868
+ return this.pluginStore.getState();
869
+ }
870
+ /**
871
+ * Get a copy of the current core state
872
+ */
873
+ get coreState() {
874
+ return this.coreStore.getState();
875
+ }
876
+ /**
877
+ * @deprecated use `this.state` Get a copy of the current state
878
+ */
879
+ getState() {
880
+ return this.pluginStore.getState();
881
+ }
882
+ /**
883
+ * @deprecated use `this.coreState` Get a copy of the current core state
884
+ */
885
+ getCoreState() {
886
+ return this.coreStore.getState();
887
+ }
888
+ /**
889
+ * Core Dispatch
890
+ */
891
+ dispatchCoreAction(action) {
892
+ return this.coreStore.dispatchToCore(action);
893
+ }
894
+ /**
895
+ * Dispatch an action to all plugins
896
+ */
897
+ dispatchToAllPlugins(action) {
898
+ return this.coreStore.dispatch(action);
899
+ }
900
+ /**
901
+ * Dispatch an action
902
+ */
903
+ dispatch(action) {
904
+ return this.pluginStore.dispatch(action);
905
+ }
906
+ /**
907
+ * Dispatch an action with a cooldown to prevent rapid repeated calls
908
+ * This executes immediately if cooldown has expired, then blocks subsequent calls
909
+ * @param action The action to dispatch
910
+ * @param cooldownTime Time in ms for cooldown (default: 100ms)
911
+ * @returns boolean indicating whether the action was dispatched or blocked
912
+ */
913
+ cooldownDispatch(action, cooldownTime = 100) {
914
+ const now = Date.now();
915
+ const lastActionTime = this.cooldownActions[action.type] || 0;
916
+ if (now - lastActionTime >= cooldownTime) {
917
+ this.cooldownActions[action.type] = now;
918
+ this.dispatch(action);
919
+ return true;
920
+ }
921
+ return false;
922
+ }
923
+ /**
924
+ * Dispatch an action with true debouncing - waits for the delay after the last call
925
+ * Each new call resets the timer. Action only executes after no calls for the specified time.
926
+ * @param action The action to dispatch
927
+ * @param debounceTime Time in ms to wait after the last call
928
+ */
929
+ debouncedDispatch(action, debounceTime = 100) {
930
+ const actionKey = action.type;
931
+ if (this.debouncedTimeouts[actionKey]) {
932
+ clearTimeout(this.debouncedTimeouts[actionKey]);
933
+ }
934
+ this.debouncedTimeouts[actionKey] = setTimeout(() => {
935
+ this.dispatch(action);
936
+ delete this.debouncedTimeouts[actionKey];
937
+ }, debounceTime);
938
+ }
939
+ /**
940
+ * Cancel a pending debounced action
941
+ * @param actionType The action type to cancel
942
+ */
943
+ cancelDebouncedDispatch(actionType) {
944
+ if (this.debouncedTimeouts[actionType]) {
945
+ clearTimeout(this.debouncedTimeouts[actionType]);
946
+ delete this.debouncedTimeouts[actionType];
947
+ }
948
+ }
949
+ /**
950
+ * Subscribe to state changes
951
+ */
952
+ subscribe(listener) {
953
+ return this.pluginStore.subscribeToState(listener);
954
+ }
955
+ /**
956
+ * Subscribe to core store changes
957
+ */
958
+ subscribeToCoreStore(listener) {
959
+ return this.coreStore.subscribe(listener);
960
+ }
961
+ /**
962
+ * Called when the plugin store state is updated
963
+ * @param oldState Previous state
964
+ * @param newState New state
965
+ */
966
+ onStoreUpdated(oldState, newState) {
967
+ }
968
+ /**
969
+ * Called when the core store state is updated
970
+ * @param oldState Previous state
971
+ * @param newState New state
972
+ */
973
+ onCoreStoreUpdated(oldState, newState) {
974
+ }
975
+ /**
976
+ * Called when a document is opened
977
+ * Override to initialize per-document state
978
+ * @param documentId The ID of the document that was opened
979
+ */
980
+ onDocumentLoadingStarted(documentId) {
981
+ }
982
+ /**
983
+ * Called when a document is loaded
984
+ * @param documentId The ID of the document that is loaded
985
+ */
986
+ onDocumentLoaded(documentId) {
987
+ }
988
+ /**
989
+ * Called when a document is closed
990
+ * Override to cleanup per-document state
991
+ * @param documentId The ID of the document that was closed
992
+ */
993
+ onDocumentClosed(documentId) {
994
+ }
995
+ /**
996
+ * Called when the active document changes
997
+ * @param previousId The ID of the previous active document
998
+ * @param currentId The ID of the new active document
999
+ */
1000
+ onActiveDocumentChanged(previousId, currentId) {
1001
+ }
1002
+ onScaleChanged(documentId, scale) {
1003
+ }
1004
+ onRotationChanged(documentId, rotation) {
1005
+ }
1006
+ /**
1007
+ * Cleanup method to be called when plugin is being destroyed
1008
+ */
1009
+ destroy() {
1010
+ Object.values(this.debouncedTimeouts).forEach((timeout) => {
1011
+ clearTimeout(timeout);
1012
+ });
1013
+ this.debouncedTimeouts = {};
1014
+ if (this.unsubscribeFromState) {
1015
+ this.unsubscribeFromState();
1016
+ this.unsubscribeFromState = null;
1017
+ }
1018
+ if (this.unsubscribeFromCoreStore) {
1019
+ this.unsubscribeFromCoreStore();
1020
+ this.unsubscribeFromCoreStore = null;
1021
+ }
1022
+ if (this.unsubscribeFromStartLoadingDocument) {
1023
+ this.unsubscribeFromStartLoadingDocument();
1024
+ this.unsubscribeFromStartLoadingDocument = null;
1025
+ }
1026
+ if (this.unsubscribeFromSetDocumentLoaded) {
1027
+ this.unsubscribeFromSetDocumentLoaded();
1028
+ this.unsubscribeFromSetDocumentLoaded = null;
1029
+ }
1030
+ if (this.unsubscribeFromCloseDocument) {
1031
+ this.unsubscribeFromCloseDocument();
1032
+ this.unsubscribeFromCloseDocument = null;
1033
+ }
1034
+ if (this.unsubscribeFromSetScale) {
1035
+ this.unsubscribeFromSetScale();
1036
+ this.unsubscribeFromSetScale = null;
1037
+ }
1038
+ if (this.unsubscribeFromSetRotation) {
1039
+ this.unsubscribeFromSetRotation();
1040
+ this.unsubscribeFromSetRotation = null;
1041
+ }
1042
+ }
1043
+ /**
1044
+ * Returns a promise that resolves when the plugin is ready
1045
+ */
1046
+ ready() {
1047
+ return this.readyPromise;
1048
+ }
1049
+ /**
1050
+ * Mark the plugin as ready
1051
+ */
1052
+ markReady() {
1053
+ this.readyResolve();
1054
+ }
1055
+ /**
1056
+ * Reset the ready state (useful for plugins that need to reinitialize)
1057
+ */
1058
+ resetReady() {
1059
+ this.readyPromise = new Promise((resolve) => {
1060
+ this.readyResolve = resolve;
1061
+ });
1062
+ }
1063
+ /**
1064
+ * Get the active document ID
1065
+ * @throws Error if no active document exists
1066
+ */
1067
+ getActiveDocumentId() {
1068
+ const id = this.coreState.core.activeDocumentId;
1069
+ if (!id) {
1070
+ throw new Error("No active document");
1071
+ }
1072
+ return id;
1073
+ }
1074
+ /**
1075
+ * Get the active document ID or null if none exists
1076
+ */
1077
+ getActiveDocumentIdOrNull() {
1078
+ return this.coreState.core.activeDocumentId;
1079
+ }
1080
+ /**
1081
+ * Get core document state for a specific document
1082
+ * @param documentId Document ID (optional, defaults to active document)
1083
+ * @returns Document state or null if not found
1084
+ */
1085
+ getCoreDocument(documentId) {
1086
+ const id = documentId ?? this.getActiveDocumentIdOrNull();
1087
+ if (!id) return null;
1088
+ return this.coreState.core.documents[id] ?? null;
1089
+ }
1090
+ /**
1091
+ * Get core document state for a specific document
1092
+ * @param documentId Document ID (optional, defaults to active document)
1093
+ * @throws Error if document not found
1094
+ */
1095
+ getCoreDocumentOrThrow(documentId) {
1096
+ const doc = this.getCoreDocument(documentId);
1097
+ if (!doc) {
1098
+ throw new Error(`Document not found: ${documentId ?? "active"}`);
1099
+ }
1100
+ return doc;
1101
+ }
1102
+ // ─────────────────────────────────────────────────────────
1103
+ // Permission Helpers
1104
+ // ─────────────────────────────────────────────────────────
1105
+ /**
1106
+ * Get the effective permission flags for a document.
1107
+ * Applies layered resolution: per-document override → global override → PDF permission.
1108
+ * Returns AllowAll if document not found.
1109
+ * @param documentId Document ID (optional, defaults to active document)
1110
+ */
1111
+ getDocumentPermissions(documentId) {
1112
+ const docId = documentId ?? this.coreState.core.activeDocumentId;
1113
+ if (!docId) return PdfPermissionFlag.AllowAll;
1114
+ return getEffectivePermissions(this.coreState.core, docId);
1115
+ }
1116
+ /**
1117
+ * Check if a document has the required permissions (returns boolean).
1118
+ * Applies layered resolution: per-document override → global override → PDF permission.
1119
+ * Useful for conditional UI logic.
1120
+ * @param documentId Document ID (optional, defaults to active document)
1121
+ * @param flags Permission flags to check
1122
+ */
1123
+ checkPermission(documentId, ...flags) {
1124
+ const docId = documentId ?? this.coreState.core.activeDocumentId;
1125
+ if (!docId) return true;
1126
+ return flags.every((flag) => getEffectivePermission(this.coreState.core, docId, flag));
1127
+ }
1128
+ /**
1129
+ * Assert that a document has the required permissions.
1130
+ * Applies layered resolution: per-document override → global override → PDF permission.
1131
+ * Throws PermissionDeniedError if any flag is missing.
1132
+ * @param documentId Document ID (optional, defaults to active document)
1133
+ * @param flags Permission flags to require
1134
+ */
1135
+ requirePermission(documentId, ...flags) {
1136
+ const docId = documentId ?? this.coreState.core.activeDocumentId;
1137
+ if (!docId) return;
1138
+ const missingFlags = [];
1139
+ for (const flag of flags) {
1140
+ if (!getEffectivePermission(this.coreState.core, docId, flag)) {
1141
+ missingFlags.push(flag);
1142
+ }
1143
+ }
1144
+ if (missingFlags.length > 0) {
1145
+ const effectivePermissions = getEffectivePermissions(this.coreState.core, docId);
1146
+ throw new PermissionDeniedError(missingFlags, effectivePermissions);
1147
+ }
1148
+ }
1149
+ }
1150
+ class TaskAbortedError extends Error {
1151
+ constructor(reason) {
1152
+ super(`Task aborted: ${JSON.stringify(reason)}`);
1153
+ this.name = "TaskAbortedError";
1154
+ this.reason = reason;
1155
+ }
1156
+ }
1157
+ class TaskRejectedError extends Error {
1158
+ constructor(reason) {
1159
+ super(`Task rejected: ${JSON.stringify(reason)}`);
1160
+ this.name = "TaskRejectedError";
1161
+ this.reason = reason;
1162
+ }
1163
+ }
1164
+ class Task {
1165
+ constructor() {
1166
+ this.state = {
1167
+ stage: 0
1168
+ /* Pending */
1169
+ };
1170
+ this.resolvedCallbacks = [];
1171
+ this.rejectedCallbacks = [];
1172
+ this._promise = null;
1173
+ this.progressCbs = [];
1174
+ }
1175
+ /**
1176
+ * Convert task to promise
1177
+ * @returns promise that will be resolved when task is settled
1178
+ */
1179
+ toPromise() {
1180
+ if (!this._promise) {
1181
+ this._promise = new Promise((resolve, reject) => {
1182
+ this.wait(
1183
+ (result) => resolve(result),
1184
+ (error) => {
1185
+ if (error.type === "abort") {
1186
+ reject(new TaskAbortedError(error.reason));
1187
+ } else {
1188
+ reject(new TaskRejectedError(error.reason));
1189
+ }
1190
+ }
1191
+ );
1192
+ });
1193
+ }
1194
+ return this._promise;
1195
+ }
1196
+ /**
1197
+ * wait for task to be settled
1198
+ * @param resolvedCallback - callback for resolved value
1199
+ * @param rejectedCallback - callback for rejected value
1200
+ */
1201
+ wait(resolvedCallback, rejectedCallback) {
1202
+ switch (this.state.stage) {
1203
+ case 0:
1204
+ this.resolvedCallbacks.push(resolvedCallback);
1205
+ this.rejectedCallbacks.push(rejectedCallback);
1206
+ break;
1207
+ case 1:
1208
+ resolvedCallback(this.state.result);
1209
+ break;
1210
+ case 2:
1211
+ rejectedCallback({
1212
+ type: "reject",
1213
+ reason: this.state.reason
1214
+ });
1215
+ break;
1216
+ case 3:
1217
+ rejectedCallback({
1218
+ type: "abort",
1219
+ reason: this.state.reason
1220
+ });
1221
+ break;
1222
+ }
1223
+ }
1224
+ /**
1225
+ * resolve task with specific result
1226
+ * @param result - result value
1227
+ */
1228
+ resolve(result) {
1229
+ if (this.state.stage === 0) {
1230
+ this.state = {
1231
+ stage: 1,
1232
+ result
1233
+ };
1234
+ for (const resolvedCallback of this.resolvedCallbacks) {
1235
+ try {
1236
+ resolvedCallback(result);
1237
+ } catch (e) {
1238
+ }
1239
+ }
1240
+ this.resolvedCallbacks = [];
1241
+ this.rejectedCallbacks = [];
1242
+ }
1243
+ }
1244
+ /**
1245
+ * reject task with specific reason
1246
+ * @param reason - abort reason
1247
+ *
1248
+ */
1249
+ reject(reason) {
1250
+ if (this.state.stage === 0) {
1251
+ this.state = {
1252
+ stage: 2,
1253
+ reason
1254
+ };
1255
+ for (const rejectedCallback of this.rejectedCallbacks) {
1256
+ try {
1257
+ rejectedCallback({
1258
+ type: "reject",
1259
+ reason
1260
+ });
1261
+ } catch (e) {
1262
+ }
1263
+ }
1264
+ this.resolvedCallbacks = [];
1265
+ this.rejectedCallbacks = [];
1266
+ }
1267
+ }
1268
+ /**
1269
+ * abort task with specific reason
1270
+ * @param reason - abort reason
1271
+ */
1272
+ abort(reason) {
1273
+ if (this.state.stage === 0) {
1274
+ this.state = {
1275
+ stage: 3,
1276
+ reason
1277
+ };
1278
+ for (const rejectedCallback of this.rejectedCallbacks) {
1279
+ try {
1280
+ rejectedCallback({
1281
+ type: "abort",
1282
+ reason
1283
+ });
1284
+ } catch (e) {
1285
+ }
1286
+ }
1287
+ this.resolvedCallbacks = [];
1288
+ this.rejectedCallbacks = [];
1289
+ }
1290
+ }
1291
+ /**
1292
+ * fail task with a TaskError from another task
1293
+ * This is a convenience method for error propagation between tasks
1294
+ * @param error - TaskError from another task
1295
+ */
1296
+ fail(error) {
1297
+ if (error.type === "abort") {
1298
+ this.abort(error.reason);
1299
+ } else {
1300
+ this.reject(error.reason);
1301
+ }
1302
+ }
1303
+ /**
1304
+ * Transform the result of this task using a mapping function.
1305
+ * Returns a new Task that resolves with the mapped value.
1306
+ *
1307
+ * Aborting the derived task also aborts the source task, and source errors
1308
+ * are forwarded to the derived task directly (bypassing `errMap`).
1309
+ *
1310
+ * Note: progress events from the source task are **not** forwarded
1311
+ * to the derived task.
1312
+ *
1313
+ * @param fn - mapping function that transforms the source result
1314
+ * @param errMap - maps errors from `fn` (sync throws or rejected promises)
1315
+ * into the error type `D`. Source task errors are forwarded as-is.
1316
+ * @returns a new Task that resolves with the mapped result
1317
+ */
1318
+ map(fn, errMap) {
1319
+ const derived = new Task();
1320
+ const origAbort = derived.abort.bind(derived);
1321
+ derived.abort = (reason) => {
1322
+ this.abort(reason);
1323
+ origAbort(reason);
1324
+ };
1325
+ this.wait(
1326
+ (result) => {
1327
+ if (derived.state.stage !== 0) return;
1328
+ try {
1329
+ const mapped = fn(result);
1330
+ if (mapped instanceof Promise) {
1331
+ mapped.then(
1332
+ (value) => {
1333
+ if (derived.state.stage === 0) {
1334
+ derived.resolve(value);
1335
+ }
1336
+ },
1337
+ (err) => {
1338
+ if (derived.state.stage === 0) {
1339
+ derived.reject(errMap(err));
1340
+ }
1341
+ }
1342
+ );
1343
+ } else {
1344
+ derived.resolve(mapped);
1345
+ }
1346
+ } catch (err) {
1347
+ if (derived.state.stage === 0) {
1348
+ derived.reject(errMap(err));
1349
+ }
1350
+ }
1351
+ },
1352
+ (error) => {
1353
+ if (derived.state.stage === 0) {
1354
+ derived.fail(error);
1355
+ }
1356
+ }
1357
+ );
1358
+ return derived;
1359
+ }
1360
+ /**
1361
+ * add a progress callback
1362
+ * @param cb - progress callback
1363
+ */
1364
+ onProgress(cb) {
1365
+ this.progressCbs.push(cb);
1366
+ }
1367
+ /**
1368
+ * call progress callback
1369
+ * @param p - progress value
1370
+ */
1371
+ progress(p) {
1372
+ for (const cb of this.progressCbs) cb(p);
1373
+ }
1374
+ /**
1375
+ * Static method to wait for all tasks to resolve
1376
+ * Returns a new task that resolves with an array of all results
1377
+ * Rejects immediately if any task fails
1378
+ *
1379
+ * @param tasks - array of tasks to wait for
1380
+ * @returns new task that resolves when all input tasks resolve
1381
+ * @public
1382
+ */
1383
+ static all(tasks) {
1384
+ const combinedTask = new Task();
1385
+ if (tasks.length === 0) {
1386
+ combinedTask.resolve([]);
1387
+ return combinedTask;
1388
+ }
1389
+ const results = new Array(tasks.length);
1390
+ let resolvedCount = 0;
1391
+ let isSettled = false;
1392
+ tasks.forEach((task, index) => {
1393
+ task.wait(
1394
+ (result) => {
1395
+ if (isSettled) return;
1396
+ results[index] = result;
1397
+ resolvedCount++;
1398
+ if (resolvedCount === tasks.length) {
1399
+ isSettled = true;
1400
+ combinedTask.resolve(results);
1401
+ }
1402
+ },
1403
+ (error) => {
1404
+ if (isSettled) return;
1405
+ isSettled = true;
1406
+ if (error.type === "abort") {
1407
+ combinedTask.abort(error.reason);
1408
+ } else {
1409
+ combinedTask.reject(error.reason);
1410
+ }
1411
+ }
1412
+ );
1413
+ });
1414
+ return combinedTask;
1415
+ }
1416
+ /**
1417
+ * Static method to wait for all tasks to settle (resolve, reject, or abort)
1418
+ * Always resolves with an array of settlement results
1419
+ *
1420
+ * @param tasks - array of tasks to wait for
1421
+ * @returns new task that resolves when all input tasks settle
1422
+ * @public
1423
+ */
1424
+ static allSettled(tasks) {
1425
+ const combinedTask = new Task();
1426
+ if (tasks.length === 0) {
1427
+ combinedTask.resolve([]);
1428
+ return combinedTask;
1429
+ }
1430
+ const results = new Array(tasks.length);
1431
+ let settledCount = 0;
1432
+ tasks.forEach((task, index) => {
1433
+ task.wait(
1434
+ (result) => {
1435
+ results[index] = { status: "resolved", value: result };
1436
+ settledCount++;
1437
+ if (settledCount === tasks.length) {
1438
+ combinedTask.resolve(results);
1439
+ }
1440
+ },
1441
+ (error) => {
1442
+ results[index] = {
1443
+ status: error.type === "abort" ? "aborted" : "rejected",
1444
+ reason: error.reason
1445
+ };
1446
+ settledCount++;
1447
+ if (settledCount === tasks.length) {
1448
+ combinedTask.resolve(results);
1449
+ }
1450
+ }
1451
+ );
1452
+ });
1453
+ return combinedTask;
1454
+ }
1455
+ /**
1456
+ * Static method that resolves/rejects with the first task that settles
1457
+ *
1458
+ * @param tasks - array of tasks to race
1459
+ * @returns new task that settles with the first input task that settles
1460
+ * @public
1461
+ */
1462
+ static race(tasks) {
1463
+ const combinedTask = new Task();
1464
+ if (tasks.length === 0) {
1465
+ combinedTask.reject("No tasks provided");
1466
+ return combinedTask;
1467
+ }
1468
+ let isSettled = false;
1469
+ tasks.forEach((task) => {
1470
+ task.wait(
1471
+ (result) => {
1472
+ if (isSettled) return;
1473
+ isSettled = true;
1474
+ combinedTask.resolve(result);
1475
+ },
1476
+ (error) => {
1477
+ if (isSettled) return;
1478
+ isSettled = true;
1479
+ if (error.type === "abort") {
1480
+ combinedTask.abort(error.reason);
1481
+ } else {
1482
+ combinedTask.reject(error.reason);
1483
+ }
1484
+ }
1485
+ );
1486
+ });
1487
+ return combinedTask;
1488
+ }
1489
+ /**
1490
+ * Utility to track progress of multiple tasks
1491
+ *
1492
+ * @param tasks - array of tasks to track
1493
+ * @param onProgress - callback called when any task completes
1494
+ * @returns new task that resolves when all input tasks resolve
1495
+ * @public
1496
+ */
1497
+ static withProgress(tasks, onProgress) {
1498
+ const combinedTask = Task.all(tasks);
1499
+ if (onProgress) {
1500
+ let completedCount = 0;
1501
+ tasks.forEach((task) => {
1502
+ task.wait(
1503
+ () => {
1504
+ completedCount++;
1505
+ onProgress(completedCount, tasks.length);
1506
+ },
1507
+ () => {
1508
+ completedCount++;
1509
+ onProgress(completedCount, tasks.length);
1510
+ }
1511
+ );
1512
+ });
1513
+ }
1514
+ return combinedTask;
1515
+ }
1516
+ }
1517
+ const PdfSoftHyphenMarker = "­";
1518
+ const PdfZeroWidthSpace = "​";
1519
+ const PdfWordJoiner = "⁠";
1520
+ const PdfBomOrZwnbsp = "\uFEFF";
1521
+ const PdfNonCharacterFFFE = "￾";
1522
+ const PdfNonCharacterFFFF = "￿";
1523
+ const PdfUnwantedTextMarkers = Object.freeze([
1524
+ PdfSoftHyphenMarker,
1525
+ PdfZeroWidthSpace,
1526
+ PdfWordJoiner,
1527
+ PdfBomOrZwnbsp,
1528
+ PdfNonCharacterFFFE,
1529
+ PdfNonCharacterFFFF
1530
+ ]);
1531
+ new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
1532
+ var PdfStandardFont = /* @__PURE__ */ ((PdfStandardFont2) => {
1533
+ PdfStandardFont2[PdfStandardFont2["Unknown"] = -1] = "Unknown";
1534
+ PdfStandardFont2[PdfStandardFont2["Courier"] = 0] = "Courier";
1535
+ PdfStandardFont2[PdfStandardFont2["Courier_Bold"] = 1] = "Courier_Bold";
1536
+ PdfStandardFont2[PdfStandardFont2["Courier_BoldOblique"] = 2] = "Courier_BoldOblique";
1537
+ PdfStandardFont2[PdfStandardFont2["Courier_Oblique"] = 3] = "Courier_Oblique";
1538
+ PdfStandardFont2[PdfStandardFont2["Helvetica"] = 4] = "Helvetica";
1539
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Bold"] = 5] = "Helvetica_Bold";
1540
+ PdfStandardFont2[PdfStandardFont2["Helvetica_BoldOblique"] = 6] = "Helvetica_BoldOblique";
1541
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Oblique"] = 7] = "Helvetica_Oblique";
1542
+ PdfStandardFont2[PdfStandardFont2["Times_Roman"] = 8] = "Times_Roman";
1543
+ PdfStandardFont2[PdfStandardFont2["Times_Bold"] = 9] = "Times_Bold";
1544
+ PdfStandardFont2[PdfStandardFont2["Times_BoldItalic"] = 10] = "Times_BoldItalic";
1545
+ PdfStandardFont2[PdfStandardFont2["Times_Italic"] = 11] = "Times_Italic";
1546
+ PdfStandardFont2[PdfStandardFont2["Symbol"] = 12] = "Symbol";
1547
+ PdfStandardFont2[PdfStandardFont2["ZapfDingbats"] = 13] = "ZapfDingbats";
1548
+ return PdfStandardFont2;
1549
+ })(PdfStandardFont || {});
1550
+ var PdfTextAlignment = /* @__PURE__ */ ((PdfTextAlignment2) => {
1551
+ PdfTextAlignment2[PdfTextAlignment2["Left"] = 0] = "Left";
1552
+ PdfTextAlignment2[PdfTextAlignment2["Center"] = 1] = "Center";
1553
+ PdfTextAlignment2[PdfTextAlignment2["Right"] = 2] = "Right";
1554
+ return PdfTextAlignment2;
1555
+ })(PdfTextAlignment || {});
1556
+ var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
1557
+ PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
1558
+ PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
1559
+ PdfBlendMode2[PdfBlendMode2["Screen"] = 2] = "Screen";
1560
+ PdfBlendMode2[PdfBlendMode2["Overlay"] = 3] = "Overlay";
1561
+ PdfBlendMode2[PdfBlendMode2["Darken"] = 4] = "Darken";
1562
+ PdfBlendMode2[PdfBlendMode2["Lighten"] = 5] = "Lighten";
1563
+ PdfBlendMode2[PdfBlendMode2["ColorDodge"] = 6] = "ColorDodge";
1564
+ PdfBlendMode2[PdfBlendMode2["ColorBurn"] = 7] = "ColorBurn";
1565
+ PdfBlendMode2[PdfBlendMode2["HardLight"] = 8] = "HardLight";
1566
+ PdfBlendMode2[PdfBlendMode2["SoftLight"] = 9] = "SoftLight";
1567
+ PdfBlendMode2[PdfBlendMode2["Difference"] = 10] = "Difference";
1568
+ PdfBlendMode2[PdfBlendMode2["Exclusion"] = 11] = "Exclusion";
1569
+ PdfBlendMode2[PdfBlendMode2["Hue"] = 12] = "Hue";
1570
+ PdfBlendMode2[PdfBlendMode2["Saturation"] = 13] = "Saturation";
1571
+ PdfBlendMode2[PdfBlendMode2["Color"] = 14] = "Color";
1572
+ PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
1573
+ return PdfBlendMode2;
1574
+ })(PdfBlendMode || {});
1575
+ const PdfAnnotationFlagName = Object.freeze({
1576
+ [
1577
+ 1
1578
+ /* INVISIBLE */
1579
+ ]: "invisible",
1580
+ [
1581
+ 2
1582
+ /* HIDDEN */
1583
+ ]: "hidden",
1584
+ [
1585
+ 4
1586
+ /* PRINT */
1587
+ ]: "print",
1588
+ [
1589
+ 8
1590
+ /* NO_ZOOM */
1591
+ ]: "noZoom",
1592
+ [
1593
+ 16
1594
+ /* NO_ROTATE */
1595
+ ]: "noRotate",
1596
+ [
1597
+ 32
1598
+ /* NO_VIEW */
1599
+ ]: "noView",
1600
+ [
1601
+ 64
1602
+ /* READ_ONLY */
1603
+ ]: "readOnly",
1604
+ [
1605
+ 128
1606
+ /* LOCKED */
1607
+ ]: "locked",
1608
+ [
1609
+ 256
1610
+ /* TOGGLE_NOVIEW */
1611
+ ]: "toggleNoView"
1612
+ });
1613
+ Object.entries(
1614
+ PdfAnnotationFlagName
1615
+ ).reduce(
1616
+ (acc, [bit, name]) => {
1617
+ acc[name] = Number(bit);
1618
+ return acc;
1619
+ },
1620
+ {}
1621
+ );
1622
+ var PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {
1623
+ PdfErrorCode2[PdfErrorCode2["Ok"] = 0] = "Ok";
1624
+ PdfErrorCode2[PdfErrorCode2["Unknown"] = 1] = "Unknown";
1625
+ PdfErrorCode2[PdfErrorCode2["NotFound"] = 2] = "NotFound";
1626
+ PdfErrorCode2[PdfErrorCode2["WrongFormat"] = 3] = "WrongFormat";
1627
+ PdfErrorCode2[PdfErrorCode2["Password"] = 4] = "Password";
1628
+ PdfErrorCode2[PdfErrorCode2["Security"] = 5] = "Security";
1629
+ PdfErrorCode2[PdfErrorCode2["PageError"] = 6] = "PageError";
1630
+ PdfErrorCode2[PdfErrorCode2["XFALoad"] = 7] = "XFALoad";
1631
+ PdfErrorCode2[PdfErrorCode2["XFALayout"] = 8] = "XFALayout";
1632
+ PdfErrorCode2[PdfErrorCode2["Cancelled"] = 9] = "Cancelled";
1633
+ PdfErrorCode2[PdfErrorCode2["Initialization"] = 10] = "Initialization";
1634
+ PdfErrorCode2[PdfErrorCode2["NotReady"] = 11] = "NotReady";
1635
+ PdfErrorCode2[PdfErrorCode2["NotSupport"] = 12] = "NotSupport";
1636
+ PdfErrorCode2[PdfErrorCode2["LoadDoc"] = 13] = "LoadDoc";
1637
+ PdfErrorCode2[PdfErrorCode2["DocNotOpen"] = 14] = "DocNotOpen";
1638
+ PdfErrorCode2[PdfErrorCode2["CantCloseDoc"] = 15] = "CantCloseDoc";
1639
+ PdfErrorCode2[PdfErrorCode2["CantCreateNewDoc"] = 16] = "CantCreateNewDoc";
1640
+ PdfErrorCode2[PdfErrorCode2["CantImportPages"] = 17] = "CantImportPages";
1641
+ PdfErrorCode2[PdfErrorCode2["CantCreateAnnot"] = 18] = "CantCreateAnnot";
1642
+ PdfErrorCode2[PdfErrorCode2["CantSetAnnotRect"] = 19] = "CantSetAnnotRect";
1643
+ PdfErrorCode2[PdfErrorCode2["CantSetAnnotContent"] = 20] = "CantSetAnnotContent";
1644
+ PdfErrorCode2[PdfErrorCode2["CantRemoveInkList"] = 21] = "CantRemoveInkList";
1645
+ PdfErrorCode2[PdfErrorCode2["CantAddInkStoke"] = 22] = "CantAddInkStoke";
1646
+ PdfErrorCode2[PdfErrorCode2["CantReadAttachmentSize"] = 23] = "CantReadAttachmentSize";
1647
+ PdfErrorCode2[PdfErrorCode2["CantReadAttachmentContent"] = 24] = "CantReadAttachmentContent";
1648
+ PdfErrorCode2[PdfErrorCode2["CantFocusAnnot"] = 25] = "CantFocusAnnot";
1649
+ PdfErrorCode2[PdfErrorCode2["CantSelectText"] = 26] = "CantSelectText";
1650
+ PdfErrorCode2[PdfErrorCode2["CantSelectOption"] = 27] = "CantSelectOption";
1651
+ PdfErrorCode2[PdfErrorCode2["CantCheckField"] = 28] = "CantCheckField";
1652
+ PdfErrorCode2[PdfErrorCode2["CantSetAnnotString"] = 29] = "CantSetAnnotString";
1653
+ return PdfErrorCode2;
1654
+ })(PdfErrorCode || {});
1655
+ class PdfTaskHelper {
1656
+ /**
1657
+ * Create a task
1658
+ * @returns new task
1659
+ */
1660
+ static create() {
1661
+ return new Task();
1662
+ }
1663
+ /**
1664
+ * Create a task that has been resolved with value
1665
+ * @param result - resolved value
1666
+ * @returns resolved task
1667
+ */
1668
+ static resolve(result) {
1669
+ const task = new Task();
1670
+ task.resolve(result);
1671
+ return task;
1672
+ }
1673
+ /**
1674
+ * Create a task that has been rejected with error
1675
+ * @param reason - rejected error
1676
+ * @returns rejected task
1677
+ */
1678
+ static reject(reason) {
1679
+ const task = new Task();
1680
+ task.reject(reason);
1681
+ return task;
1682
+ }
1683
+ /**
1684
+ * Create a task that has been aborted with error
1685
+ * @param reason - aborted error
1686
+ * @returns aborted task
1687
+ */
1688
+ static abort(reason) {
1689
+ const task = new Task();
1690
+ task.reject(reason);
1691
+ return task;
1692
+ }
1693
+ }
1694
+ const TEXT_ALIGNMENT_INFOS = Object.freeze([
1695
+ { id: PdfTextAlignment.Left, label: "Left", css: "left" },
1696
+ { id: PdfTextAlignment.Center, label: "Center", css: "center" },
1697
+ { id: PdfTextAlignment.Right, label: "Right", css: "right" }
1698
+ ]);
1699
+ TEXT_ALIGNMENT_INFOS.reduce(
1700
+ (m, info) => {
1701
+ m[info.id] = info;
1702
+ return m;
1703
+ },
1704
+ {}
1705
+ );
1706
+ TEXT_ALIGNMENT_INFOS.reduce(
1707
+ (m, info) => {
1708
+ m[info.css] = info.id;
1709
+ return m;
1710
+ },
1711
+ {}
1712
+ );
1713
+ TEXT_ALIGNMENT_INFOS.map((info) => ({
1714
+ value: info.id,
1715
+ label: info.label
1716
+ }));
1717
+ var PdfStandardFontFamily = /* @__PURE__ */ ((PdfStandardFontFamily2) => {
1718
+ PdfStandardFontFamily2["Courier"] = "Courier";
1719
+ PdfStandardFontFamily2["Helvetica"] = "Helvetica";
1720
+ PdfStandardFontFamily2["Times"] = "Times";
1721
+ PdfStandardFontFamily2["Symbol"] = "Symbol";
1722
+ PdfStandardFontFamily2["ZapfDingbats"] = "ZapfDingbats";
1723
+ PdfStandardFontFamily2["Unknown"] = "Unknown";
1724
+ return PdfStandardFontFamily2;
1725
+ })(PdfStandardFontFamily || {});
1726
+ PdfStandardFont.Helvetica;
1727
+ const HELVETICA_DESC = {
1728
+ id: PdfStandardFont.Helvetica,
1729
+ family: "Helvetica",
1730
+ bold: false,
1731
+ italic: false,
1732
+ label: "Helvetica",
1733
+ css: "Helvetica, Arial, sans-serif"
1734
+ };
1735
+ const STANDARD_FONT_DESCRIPTORS = Object.freeze([
1736
+ {
1737
+ id: PdfStandardFont.Courier,
1738
+ family: "Courier",
1739
+ bold: false,
1740
+ italic: false,
1741
+ label: "Courier",
1742
+ css: "Courier, monospace"
1743
+ },
1744
+ {
1745
+ id: PdfStandardFont.Courier_Bold,
1746
+ family: "Courier",
1747
+ bold: true,
1748
+ italic: false,
1749
+ label: "Courier Bold",
1750
+ css: "Courier, monospace"
1751
+ },
1752
+ {
1753
+ id: PdfStandardFont.Courier_BoldOblique,
1754
+ family: "Courier",
1755
+ bold: true,
1756
+ italic: true,
1757
+ label: "Courier Bold Oblique",
1758
+ css: "Courier, monospace"
1759
+ },
1760
+ {
1761
+ id: PdfStandardFont.Courier_Oblique,
1762
+ family: "Courier",
1763
+ bold: false,
1764
+ italic: true,
1765
+ label: "Courier Oblique",
1766
+ css: "Courier, monospace"
1767
+ },
1768
+ HELVETICA_DESC,
1769
+ {
1770
+ id: PdfStandardFont.Helvetica_Bold,
1771
+ family: "Helvetica",
1772
+ bold: true,
1773
+ italic: false,
1774
+ label: "Helvetica Bold",
1775
+ css: "Helvetica, Arial, sans-serif"
1776
+ },
1777
+ {
1778
+ id: PdfStandardFont.Helvetica_BoldOblique,
1779
+ family: "Helvetica",
1780
+ bold: true,
1781
+ italic: true,
1782
+ label: "Helvetica Bold Oblique",
1783
+ css: "Helvetica, Arial, sans-serif"
1784
+ },
1785
+ {
1786
+ id: PdfStandardFont.Helvetica_Oblique,
1787
+ family: "Helvetica",
1788
+ bold: false,
1789
+ italic: true,
1790
+ label: "Helvetica Oblique",
1791
+ css: "Helvetica, Arial, sans-serif"
1792
+ },
1793
+ {
1794
+ id: PdfStandardFont.Times_Roman,
1795
+ family: "Times",
1796
+ bold: false,
1797
+ italic: false,
1798
+ label: "Times Roman",
1799
+ css: '"Times New Roman", Times, serif'
1800
+ },
1801
+ {
1802
+ id: PdfStandardFont.Times_Bold,
1803
+ family: "Times",
1804
+ bold: true,
1805
+ italic: false,
1806
+ label: "Times Bold",
1807
+ css: '"Times New Roman", Times, serif'
1808
+ },
1809
+ {
1810
+ id: PdfStandardFont.Times_BoldItalic,
1811
+ family: "Times",
1812
+ bold: true,
1813
+ italic: true,
1814
+ label: "Times Bold Italic",
1815
+ css: '"Times New Roman", Times, serif'
1816
+ },
1817
+ {
1818
+ id: PdfStandardFont.Times_Italic,
1819
+ family: "Times",
1820
+ bold: false,
1821
+ italic: true,
1822
+ label: "Times Italic",
1823
+ css: '"Times New Roman", Times, serif'
1824
+ },
1825
+ {
1826
+ id: PdfStandardFont.Symbol,
1827
+ family: "Symbol",
1828
+ bold: false,
1829
+ italic: false,
1830
+ label: "Symbol",
1831
+ css: "Symbol, serif"
1832
+ },
1833
+ {
1834
+ id: PdfStandardFont.ZapfDingbats,
1835
+ family: "ZapfDingbats",
1836
+ bold: false,
1837
+ italic: false,
1838
+ label: "Zapf Dingbats",
1839
+ css: "ZapfDingbats, serif"
1840
+ }
1841
+ ]);
1842
+ STANDARD_FONT_DESCRIPTORS.reduce((m, d) => (m[d.id] = d, m), {});
1843
+ const familyStyleToId = /* @__PURE__ */ new Map();
1844
+ for (const d of STANDARD_FONT_DESCRIPTORS) {
1845
+ familyStyleToId.set(`${d.family}_${d.bold}_${d.italic}`, d.id);
1846
+ }
1847
+ Object.values(PdfStandardFontFamily).filter(
1848
+ (f) => f !== "Unknown"
1849
+ /* Unknown */
1850
+ ).map((family) => ({ value: family, label: family }));
1851
+ [
1852
+ ...new Set(STANDARD_FONT_DESCRIPTORS.map((d) => d.family))
1853
+ ];
1854
+ const BLEND_MODE_INFOS = Object.freeze([
1855
+ { id: PdfBlendMode.Normal, label: "Normal", css: "normal" },
1856
+ { id: PdfBlendMode.Multiply, label: "Multiply", css: "multiply" },
1857
+ { id: PdfBlendMode.Screen, label: "Screen", css: "screen" },
1858
+ { id: PdfBlendMode.Overlay, label: "Overlay", css: "overlay" },
1859
+ { id: PdfBlendMode.Darken, label: "Darken", css: "darken" },
1860
+ { id: PdfBlendMode.Lighten, label: "Lighten", css: "lighten" },
1861
+ { id: PdfBlendMode.ColorDodge, label: "Color Dodge", css: "color-dodge" },
1862
+ { id: PdfBlendMode.ColorBurn, label: "Color Burn", css: "color-burn" },
1863
+ { id: PdfBlendMode.HardLight, label: "Hard Light", css: "hard-light" },
1864
+ { id: PdfBlendMode.SoftLight, label: "Soft Light", css: "soft-light" },
1865
+ { id: PdfBlendMode.Difference, label: "Difference", css: "difference" },
1866
+ { id: PdfBlendMode.Exclusion, label: "Exclusion", css: "exclusion" },
1867
+ { id: PdfBlendMode.Hue, label: "Hue", css: "hue" },
1868
+ { id: PdfBlendMode.Saturation, label: "Saturation", css: "saturation" },
1869
+ { id: PdfBlendMode.Color, label: "Color", css: "color" },
1870
+ { id: PdfBlendMode.Luminosity, label: "Luminosity", css: "luminosity" }
1871
+ ]);
1872
+ BLEND_MODE_INFOS.reduce(
1873
+ (m, info) => {
1874
+ m[info.id] = info;
1875
+ return m;
1876
+ },
1877
+ {}
1878
+ );
1879
+ BLEND_MODE_INFOS.reduce(
1880
+ (m, info) => {
1881
+ m[info.css] = info.id;
1882
+ return m;
1883
+ },
1884
+ {}
1885
+ );
1886
+ BLEND_MODE_INFOS.map((info) => ({
1887
+ value: info.id,
1888
+ label: info.label
1889
+ }));
1890
+ BLEND_MODE_INFOS.map((info) => info.id);
1891
+ const _AttachmentPlugin = class _AttachmentPlugin extends BasePlugin {
1892
+ constructor(id, registry) {
1893
+ super(id, registry);
1894
+ }
1895
+ async initialize(_) {
1896
+ }
1897
+ // ─────────────────────────────────────────────────────────
1898
+ // Capability
1899
+ // ─────────────────────────────────────────────────────────
1900
+ buildCapability() {
1901
+ return {
1902
+ // Active document operations
1903
+ getAttachments: () => this.getAttachments(),
1904
+ downloadAttachment: (attachment) => this.downloadAttachment(attachment),
1905
+ // Document-scoped operations
1906
+ forDocument: (documentId) => this.createAttachmentScope(documentId)
1907
+ };
1908
+ }
1909
+ // ─────────────────────────────────────────────────────────
1910
+ // Document Scoping
1911
+ // ─────────────────────────────────────────────────────────
1912
+ createAttachmentScope(documentId) {
1913
+ return {
1914
+ getAttachments: () => this.getAttachments(documentId),
1915
+ downloadAttachment: (attachment) => this.downloadAttachment(attachment, documentId)
1916
+ };
1917
+ }
1918
+ // ─────────────────────────────────────────────────────────
1919
+ // Core Operations
1920
+ // ─────────────────────────────────────────────────────────
1921
+ downloadAttachment(attachment, documentId) {
1922
+ const id = documentId ?? this.getActiveDocumentId();
1923
+ const coreDoc = this.coreState.core.documents[id];
1924
+ if (!(coreDoc == null ? void 0 : coreDoc.document)) {
1925
+ return PdfTaskHelper.reject({
1926
+ code: PdfErrorCode.NotFound,
1927
+ message: `Document ${id} not found`
1928
+ });
1929
+ }
1930
+ return this.engine.readAttachmentContent(coreDoc.document, attachment);
1931
+ }
1932
+ getAttachments(documentId) {
1933
+ const id = documentId ?? this.getActiveDocumentId();
1934
+ const coreDoc = this.coreState.core.documents[id];
1935
+ if (!(coreDoc == null ? void 0 : coreDoc.document)) {
1936
+ return PdfTaskHelper.reject({
1937
+ code: PdfErrorCode.NotFound,
1938
+ message: `Document ${id} not found`
1939
+ });
1940
+ }
1941
+ return this.engine.getAttachments(coreDoc.document);
1942
+ }
1943
+ };
1944
+ _AttachmentPlugin.id = "attachment";
1945
+ let AttachmentPlugin = _AttachmentPlugin;
1946
+ const useAttachmentPlugin = () => usePlugin(AttachmentPlugin.id);
1947
+ const useAttachmentCapability = () => useCapability(AttachmentPlugin.id);
1948
+ export {
1949
+ useAttachmentCapability,
1950
+ useAttachmentPlugin
1951
+ };
1952
+ //# sourceMappingURL=index.js.map