@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 @@
1
+ {"version":3,"file":"index.js","sources":["../../../core/dist/svelte/index.js","../../../core/dist/index.js","../../../models/dist/index.js","../../src/lib/attachment-plugin.ts","../../src/svelte/hooks/use-attachment.ts"],"sourcesContent":["import * as $ from \"svelte/internal/client\";\nimport \"svelte/internal/disclose-version\";\nconst pdfContext = $.proxy({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: []\n});\nconst useRegistry = () => pdfContext;\nfunction usePlugin(pluginId) {\n const { registry } = pdfContext;\n const state = $.proxy({ plugin: null, isLoading: true, ready: new Promise(() => {\n }) });\n if (registry === null) {\n return state;\n }\n const plugin = registry.getPlugin(pluginId);\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n return state;\n}\nfunction useCapability(pluginId) {\n const p = usePlugin(pluginId);\n const state = $.proxy({\n provides: null,\n isLoading: true,\n ready: new Promise(() => {\n })\n });\n $.user_effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n state.provides = p.plugin.provides();\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n return state;\n}\nfunction useCoreState() {\n const context = useRegistry();\n return {\n get current() {\n return context.coreState;\n }\n };\n}\nfunction useDocumentState(getDocumentId) {\n const coreStateRef = useCoreState();\n const documentId = $.derived(getDocumentId);\n const documentState = $.derived(() => coreStateRef.current && $.get(documentId) ? coreStateRef.current.documents[$.get(documentId)] ?? null : null);\n return {\n get current() {\n return $.get(documentState);\n }\n };\n}\nvar Rotation = /* @__PURE__ */ ((Rotation2) => {\n Rotation2[Rotation2[\"Degree0\"] = 0] = \"Degree0\";\n Rotation2[Rotation2[\"Degree90\"] = 1] = \"Degree90\";\n Rotation2[Rotation2[\"Degree180\"] = 2] = \"Degree180\";\n Rotation2[Rotation2[\"Degree270\"] = 3] = \"Degree270\";\n return Rotation2;\n})(Rotation || {});\nclass NoopLogger {\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled() {\n return false;\n }\n /** {@inheritDoc Logger.debug} */\n debug() {\n }\n /** {@inheritDoc Logger.info} */\n info() {\n }\n /** {@inheritDoc Logger.warn} */\n warn() {\n }\n /** {@inheritDoc Logger.error} */\n error() {\n }\n /** {@inheritDoc Logger.perf} */\n perf() {\n }\n}\nconst PdfSoftHyphenMarker = \"­\";\nconst PdfZeroWidthSpace = \"​\";\nconst PdfWordJoiner = \"⁠\";\nconst PdfBomOrZwnbsp = \"\\uFEFF\";\nconst PdfNonCharacterFFFE = \"￾\";\nconst PdfNonCharacterFFFF = \"￿\";\nconst PdfUnwantedTextMarkers = Object.freeze([\n PdfSoftHyphenMarker,\n PdfZeroWidthSpace,\n PdfWordJoiner,\n PdfBomOrZwnbsp,\n PdfNonCharacterFFFE,\n PdfNonCharacterFFFF\n]);\nnew RegExp(`[${PdfUnwantedTextMarkers.join(\"\")}]`, \"g\");\nvar PdfStandardFont = /* @__PURE__ */ ((PdfStandardFont2) => {\n PdfStandardFont2[PdfStandardFont2[\"Unknown\"] = -1] = \"Unknown\";\n PdfStandardFont2[PdfStandardFont2[\"Courier\"] = 0] = \"Courier\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Bold\"] = 1] = \"Courier_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_BoldOblique\"] = 2] = \"Courier_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Oblique\"] = 3] = \"Courier_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica\"] = 4] = \"Helvetica\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Bold\"] = 5] = \"Helvetica_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_BoldOblique\"] = 6] = \"Helvetica_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Oblique\"] = 7] = \"Helvetica_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Roman\"] = 8] = \"Times_Roman\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Bold\"] = 9] = \"Times_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Times_BoldItalic\"] = 10] = \"Times_BoldItalic\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Italic\"] = 11] = \"Times_Italic\";\n PdfStandardFont2[PdfStandardFont2[\"Symbol\"] = 12] = \"Symbol\";\n PdfStandardFont2[PdfStandardFont2[\"ZapfDingbats\"] = 13] = \"ZapfDingbats\";\n return PdfStandardFont2;\n})(PdfStandardFont || {});\nvar PdfTextAlignment = /* @__PURE__ */ ((PdfTextAlignment2) => {\n PdfTextAlignment2[PdfTextAlignment2[\"Left\"] = 0] = \"Left\";\n PdfTextAlignment2[PdfTextAlignment2[\"Center\"] = 1] = \"Center\";\n PdfTextAlignment2[PdfTextAlignment2[\"Right\"] = 2] = \"Right\";\n return PdfTextAlignment2;\n})(PdfTextAlignment || {});\nvar PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {\n PdfBlendMode2[PdfBlendMode2[\"Normal\"] = 0] = \"Normal\";\n PdfBlendMode2[PdfBlendMode2[\"Multiply\"] = 1] = \"Multiply\";\n PdfBlendMode2[PdfBlendMode2[\"Screen\"] = 2] = \"Screen\";\n PdfBlendMode2[PdfBlendMode2[\"Overlay\"] = 3] = \"Overlay\";\n PdfBlendMode2[PdfBlendMode2[\"Darken\"] = 4] = \"Darken\";\n PdfBlendMode2[PdfBlendMode2[\"Lighten\"] = 5] = \"Lighten\";\n PdfBlendMode2[PdfBlendMode2[\"ColorDodge\"] = 6] = \"ColorDodge\";\n PdfBlendMode2[PdfBlendMode2[\"ColorBurn\"] = 7] = \"ColorBurn\";\n PdfBlendMode2[PdfBlendMode2[\"HardLight\"] = 8] = \"HardLight\";\n PdfBlendMode2[PdfBlendMode2[\"SoftLight\"] = 9] = \"SoftLight\";\n PdfBlendMode2[PdfBlendMode2[\"Difference\"] = 10] = \"Difference\";\n PdfBlendMode2[PdfBlendMode2[\"Exclusion\"] = 11] = \"Exclusion\";\n PdfBlendMode2[PdfBlendMode2[\"Hue\"] = 12] = \"Hue\";\n PdfBlendMode2[PdfBlendMode2[\"Saturation\"] = 13] = \"Saturation\";\n PdfBlendMode2[PdfBlendMode2[\"Color\"] = 14] = \"Color\";\n PdfBlendMode2[PdfBlendMode2[\"Luminosity\"] = 15] = \"Luminosity\";\n return PdfBlendMode2;\n})(PdfBlendMode || {});\nconst PdfAnnotationFlagName = Object.freeze({\n [\n 1\n /* INVISIBLE */\n ]: \"invisible\",\n [\n 2\n /* HIDDEN */\n ]: \"hidden\",\n [\n 4\n /* PRINT */\n ]: \"print\",\n [\n 8\n /* NO_ZOOM */\n ]: \"noZoom\",\n [\n 16\n /* NO_ROTATE */\n ]: \"noRotate\",\n [\n 32\n /* NO_VIEW */\n ]: \"noView\",\n [\n 64\n /* READ_ONLY */\n ]: \"readOnly\",\n [\n 128\n /* LOCKED */\n ]: \"locked\",\n [\n 256\n /* TOGGLE_NOVIEW */\n ]: \"toggleNoView\"\n});\nObject.entries(\n PdfAnnotationFlagName\n).reduce(\n (acc, [bit, name]) => {\n acc[name] = Number(bit);\n return acc;\n },\n {}\n);\nvar PdfPermissionFlag = /* @__PURE__ */ ((PdfPermissionFlag2) => {\n PdfPermissionFlag2[PdfPermissionFlag2[\"Print\"] = 4] = \"Print\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyContents\"] = 8] = \"ModifyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"CopyContents\"] = 16] = \"CopyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyAnnotations\"] = 32] = \"ModifyAnnotations\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"FillForms\"] = 256] = \"FillForms\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ExtractForAccessibility\"] = 512] = \"ExtractForAccessibility\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AssembleDocument\"] = 1024] = \"AssembleDocument\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"PrintHighQuality\"] = 2048] = \"PrintHighQuality\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AllowAll\"] = 3900] = \"AllowAll\";\n return PdfPermissionFlag2;\n})(PdfPermissionFlag || {});\nconst TEXT_ALIGNMENT_INFOS = Object.freeze([\n { id: PdfTextAlignment.Left, label: \"Left\", css: \"left\" },\n { id: PdfTextAlignment.Center, label: \"Center\", css: \"center\" },\n { id: PdfTextAlignment.Right, label: \"Right\", css: \"right\" }\n]);\nTEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nTEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nTEXT_ALIGNMENT_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nvar PdfStandardFontFamily = /* @__PURE__ */ ((PdfStandardFontFamily2) => {\n PdfStandardFontFamily2[\"Courier\"] = \"Courier\";\n PdfStandardFontFamily2[\"Helvetica\"] = \"Helvetica\";\n PdfStandardFontFamily2[\"Times\"] = \"Times\";\n PdfStandardFontFamily2[\"Symbol\"] = \"Symbol\";\n PdfStandardFontFamily2[\"ZapfDingbats\"] = \"ZapfDingbats\";\n PdfStandardFontFamily2[\"Unknown\"] = \"Unknown\";\n return PdfStandardFontFamily2;\n})(PdfStandardFontFamily || {});\nPdfStandardFont.Helvetica;\nconst HELVETICA_DESC = {\n id: PdfStandardFont.Helvetica,\n family: \"Helvetica\",\n bold: false,\n italic: false,\n label: \"Helvetica\",\n css: \"Helvetica, Arial, sans-serif\"\n};\nconst STANDARD_FONT_DESCRIPTORS = Object.freeze([\n {\n id: PdfStandardFont.Courier,\n family: \"Courier\",\n bold: false,\n italic: false,\n label: \"Courier\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Bold,\n family: \"Courier\",\n bold: true,\n italic: false,\n label: \"Courier Bold\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_BoldOblique,\n family: \"Courier\",\n bold: true,\n italic: true,\n label: \"Courier Bold Oblique\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Oblique,\n family: \"Courier\",\n bold: false,\n italic: true,\n label: \"Courier Oblique\",\n css: \"Courier, monospace\"\n },\n HELVETICA_DESC,\n {\n id: PdfStandardFont.Helvetica_Bold,\n family: \"Helvetica\",\n bold: true,\n italic: false,\n label: \"Helvetica Bold\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_BoldOblique,\n family: \"Helvetica\",\n bold: true,\n italic: true,\n label: \"Helvetica Bold Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_Oblique,\n family: \"Helvetica\",\n bold: false,\n italic: true,\n label: \"Helvetica Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Times_Roman,\n family: \"Times\",\n bold: false,\n italic: false,\n label: \"Times Roman\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Bold,\n family: \"Times\",\n bold: true,\n italic: false,\n label: \"Times Bold\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_BoldItalic,\n family: \"Times\",\n bold: true,\n italic: true,\n label: \"Times Bold Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Italic,\n family: \"Times\",\n bold: false,\n italic: true,\n label: \"Times Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Symbol,\n family: \"Symbol\",\n bold: false,\n italic: false,\n label: \"Symbol\",\n css: \"Symbol, serif\"\n },\n {\n id: PdfStandardFont.ZapfDingbats,\n family: \"ZapfDingbats\",\n bold: false,\n italic: false,\n label: \"Zapf Dingbats\",\n css: \"ZapfDingbats, serif\"\n }\n]);\nSTANDARD_FONT_DESCRIPTORS.reduce((m, d) => (m[d.id] = d, m), {});\nconst familyStyleToId = /* @__PURE__ */ new Map();\nfor (const d of STANDARD_FONT_DESCRIPTORS) {\n familyStyleToId.set(`${d.family}_${d.bold}_${d.italic}`, d.id);\n}\nObject.values(PdfStandardFontFamily).filter(\n (f) => f !== \"Unknown\"\n /* Unknown */\n).map((family) => ({ value: family, label: family }));\n[\n ...new Set(STANDARD_FONT_DESCRIPTORS.map((d) => d.family))\n];\nconst BLEND_MODE_INFOS = Object.freeze([\n { id: PdfBlendMode.Normal, label: \"Normal\", css: \"normal\" },\n { id: PdfBlendMode.Multiply, label: \"Multiply\", css: \"multiply\" },\n { id: PdfBlendMode.Screen, label: \"Screen\", css: \"screen\" },\n { id: PdfBlendMode.Overlay, label: \"Overlay\", css: \"overlay\" },\n { id: PdfBlendMode.Darken, label: \"Darken\", css: \"darken\" },\n { id: PdfBlendMode.Lighten, label: \"Lighten\", css: \"lighten\" },\n { id: PdfBlendMode.ColorDodge, label: \"Color Dodge\", css: \"color-dodge\" },\n { id: PdfBlendMode.ColorBurn, label: \"Color Burn\", css: \"color-burn\" },\n { id: PdfBlendMode.HardLight, label: \"Hard Light\", css: \"hard-light\" },\n { id: PdfBlendMode.SoftLight, label: \"Soft Light\", css: \"soft-light\" },\n { id: PdfBlendMode.Difference, label: \"Difference\", css: \"difference\" },\n { id: PdfBlendMode.Exclusion, label: \"Exclusion\", css: \"exclusion\" },\n { id: PdfBlendMode.Hue, label: \"Hue\", css: \"hue\" },\n { id: PdfBlendMode.Saturation, label: \"Saturation\", css: \"saturation\" },\n { id: PdfBlendMode.Color, label: \"Color\", css: \"color\" },\n { id: PdfBlendMode.Luminosity, label: \"Luminosity\", css: \"luminosity\" }\n]);\nBLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nBLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nBLEND_MODE_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nBLEND_MODE_INFOS.map((info) => info.id);\n({\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality\n});\nconst ALL_PERMISSION_FLAGS = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality\n];\nconst PERMISSION_FLAG_TO_NAME = {\n [PdfPermissionFlag.Print]: \"print\",\n [PdfPermissionFlag.ModifyContents]: \"modifyContents\",\n [PdfPermissionFlag.CopyContents]: \"copyContents\",\n [PdfPermissionFlag.ModifyAnnotations]: \"modifyAnnotations\",\n [PdfPermissionFlag.FillForms]: \"fillForms\",\n [PdfPermissionFlag.ExtractForAccessibility]: \"extractForAccessibility\",\n [PdfPermissionFlag.AssembleDocument]: \"assembleDocument\",\n [PdfPermissionFlag.PrintHighQuality]: \"printHighQuality\"\n};\nfunction getPermissionOverride(overrides, flag) {\n if (!overrides) return void 0;\n if (flag in overrides) {\n return overrides[flag];\n }\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return overrides[name];\n }\n return void 0;\n}\nfunction getEffectivePermission(state, documentId, flag) {\n var _a;\n const docState = state.documents[documentId];\n const docConfig = docState == null ? void 0 : docState.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = ((_a = docState == null ? void 0 : docState.document) == null ? void 0 : _a.permissions) ?? PdfPermissionFlag.AllowAll;\n const docOverride = getPermissionOverride(docConfig == null ? void 0 : docConfig.overrides, flag);\n if (docOverride !== void 0) {\n return docOverride;\n }\n const globalOverride = getPermissionOverride(globalConfig == null ? void 0 : globalConfig.overrides, flag);\n if (globalOverride !== void 0) {\n return globalOverride;\n }\n const enforce = (docConfig == null ? void 0 : docConfig.enforceDocumentPermissions) ?? (globalConfig == null ? void 0 : globalConfig.enforceDocumentPermissions) ?? true;\n if (!enforce) return true;\n return (pdfPermissions & flag) !== 0;\n}\nfunction getEffectivePermissions(state, documentId) {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\nfunction useDocumentPermissions(getDocumentId) {\n const coreStateRef = useCoreState();\n const documentId = $.derived(getDocumentId);\n const coreState = $.derived(() => coreStateRef.current);\n const effectivePermissions = $.derived(() => $.get(coreState) ? getEffectivePermissions($.get(coreState), $.get(documentId)) : PdfPermissionFlag.AllowAll);\n const pdfPermissions = $.derived(() => {\n var _a, _b, _c;\n return ((_c = (_b = (_a = $.get(coreState)) == null ? void 0 : _a.documents[$.get(documentId)]) == null ? void 0 : _b.document) == null ? void 0 : _c.permissions) ?? PdfPermissionFlag.AllowAll;\n });\n const hasPermission = (flag) => $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), flag) : true;\n const hasAllPermissions = (...flags) => flags.every((flag) => $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), flag) : true);\n return {\n get permissions() {\n return $.get(effectivePermissions);\n },\n get pdfPermissions() {\n return $.get(pdfPermissions);\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.Print) : true;\n },\n get canModifyContents() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ModifyContents) : true;\n },\n get canCopyContents() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.CopyContents) : true;\n },\n get canModifyAnnotations() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ModifyAnnotations) : true;\n },\n get canFillForms() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.FillForms) : true;\n },\n get canExtractForAccessibility() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ExtractForAccessibility) : true;\n },\n get canAssembleDocument() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.AssembleDocument) : true;\n },\n get canPrintHighQuality() {\n return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.PrintHighQuality) : true;\n }\n };\n}\nclass DependencyResolver {\n constructor() {\n this.dependencyGraph = /* @__PURE__ */ new Map();\n }\n addNode(id, dependencies = []) {\n this.dependencyGraph.set(id, new Set(dependencies));\n }\n hasCircularDependencies() {\n const visited = /* @__PURE__ */ new Set();\n const recursionStack = /* @__PURE__ */ new Set();\n const dfs = (id) => {\n visited.add(id);\n recursionStack.add(id);\n const dependencies = this.dependencyGraph.get(id) || /* @__PURE__ */ new Set();\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n if (dfs(dep)) return true;\n } else if (recursionStack.has(dep)) {\n return true;\n }\n }\n recursionStack.delete(id);\n return false;\n };\n for (const id of this.dependencyGraph.keys()) {\n if (!visited.has(id)) {\n if (dfs(id)) return true;\n }\n }\n return false;\n }\n resolveLoadOrder() {\n if (this.hasCircularDependencies()) {\n throw new Error(\"Circular dependencies detected\");\n }\n const result = [];\n const visited = /* @__PURE__ */ new Set();\n const temp = /* @__PURE__ */ new Set();\n const visit = (id) => {\n if (temp.has(id)) throw new Error(\"Circular dependency\");\n if (visited.has(id)) return;\n temp.add(id);\n const dependencies = this.dependencyGraph.get(id) || /* @__PURE__ */ new Set();\n for (const dep of dependencies) {\n visit(dep);\n }\n temp.delete(id);\n visited.add(id);\n result.push(id);\n };\n for (const id of this.dependencyGraph.keys()) {\n if (!visited.has(id)) {\n visit(id);\n }\n }\n return result;\n }\n}\nclass PluginRegistrationError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginRegistrationError\";\n }\n}\nclass PluginNotFoundError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginNotFoundError\";\n }\n}\nclass CircularDependencyError extends Error {\n constructor(message) {\n super(message);\n this.name = \"CircularDependencyError\";\n }\n}\nclass PluginConfigurationError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginConfigurationError\";\n }\n}\nclass PluginStore {\n /**\n * Initializes the PluginStore with the main store and plugin ID.\n * @param store The main store instance.\n * @param pluginId The unique identifier for the plugin.\n */\n constructor(store, pluginId) {\n this.store = store;\n this.pluginId = pluginId;\n }\n /**\n * Gets the current state of the plugin.\n * @returns The plugin's state.\n */\n getState() {\n return this.store.getState().plugins[this.pluginId];\n }\n /**\n * Dispatches an action for the plugin and returns the *new* global state.\n * If you only need the plugin’s updated state, call `getState()` afterward.\n * @param action The action to dispatch.\n * @returns The updated global store state (after plugin reducer).\n */\n dispatch(action) {\n return this.store.dispatchToPlugin(this.pluginId, action);\n }\n /**\n * Subscribes to state changes only for this specific plugin.\n * You now receive (action, newPluginState, oldPluginState) in the callback.\n *\n * @param listener The callback to invoke when plugin state changes.\n * @returns A function to unsubscribe the listener.\n */\n subscribeToState(listener) {\n return this.store.subscribeToPlugin(this.pluginId, (action, newPluginState, oldPluginState) => {\n listener(\n action,\n newPluginState,\n oldPluginState\n );\n });\n }\n /**\n * Subscribes to a specific action type for the plugin.\n * This still uses the main store's `onAction`, so you get the *global*\n * old/new store states there. If you specifically want old/new plugin state,\n * use `subscribeToState` instead.\n *\n * @param type The action type to listen for.\n * @param handler The callback to invoke when the action occurs.\n * @returns A function to unsubscribe the handler.\n */\n onAction(type, handler) {\n return this.store.onAction(type, (action, state, oldState) => {\n handler(\n action,\n state.plugins[this.pluginId],\n oldState.plugins[this.pluginId]\n );\n });\n }\n}\nconst START_LOADING_DOCUMENT = \"START_LOADING_DOCUMENT\";\nconst UPDATE_DOCUMENT_LOADING_PROGRESS = \"UPDATE_DOCUMENT_LOADING_PROGRESS\";\nconst SET_DOCUMENT_LOADED = \"SET_DOCUMENT_LOADED\";\nconst SET_DOCUMENT_ERROR = \"SET_DOCUMENT_ERROR\";\nconst RETRY_LOADING_DOCUMENT = \"RETRY_LOADING_DOCUMENT\";\nconst CLOSE_DOCUMENT = \"CLOSE_DOCUMENT\";\nconst SET_ACTIVE_DOCUMENT = \"SET_ACTIVE_DOCUMENT\";\nconst REORDER_DOCUMENTS = \"REORDER_DOCUMENTS\";\nconst MOVE_DOCUMENT = \"MOVE_DOCUMENT\";\nconst UPDATE_DOCUMENT_SECURITY = \"UPDATE_DOCUMENT_SECURITY\";\nconst REFRESH_DOCUMENT = \"REFRESH_DOCUMENT\";\nconst REFRESH_PAGES = \"REFRESH_PAGES\";\nconst SET_PAGES = \"SET_PAGES\";\nconst SET_SCALE = \"SET_SCALE\";\nconst SET_ROTATION = \"SET_ROTATION\";\nconst SET_DEFAULT_SCALE = \"SET_DEFAULT_SCALE\";\nconst SET_DEFAULT_ROTATION = \"SET_DEFAULT_ROTATION\";\nconst CORE_ACTION_TYPES = [\n START_LOADING_DOCUMENT,\n UPDATE_DOCUMENT_LOADING_PROGRESS,\n SET_DOCUMENT_LOADED,\n CLOSE_DOCUMENT,\n SET_ACTIVE_DOCUMENT,\n SET_DOCUMENT_ERROR,\n RETRY_LOADING_DOCUMENT,\n REFRESH_DOCUMENT,\n REFRESH_PAGES,\n SET_PAGES,\n SET_SCALE,\n SET_ROTATION,\n SET_DEFAULT_SCALE,\n SET_DEFAULT_ROTATION,\n REORDER_DOCUMENTS,\n MOVE_DOCUMENT,\n UPDATE_DOCUMENT_SECURITY\n];\nclass Store {\n /**\n * Initializes the store with the provided core state.\n * @param reducer The core reducer function\n * @param initialCoreState The initial core state\n */\n constructor(reducer, initialCoreState2) {\n this.initialCoreState = initialCoreState2;\n this.pluginReducers = {};\n this.listeners = [];\n this.pluginListeners = {};\n this.isDispatching = false;\n this.state = { core: initialCoreState2, plugins: {} };\n this.coreReducer = reducer;\n }\n /**\n * Adds a reducer for a plugin-specific state.\n * @param pluginId The unique identifier for the plugin.\n * @param reducer The reducer function for the plugin state.\n * @param initialState The initial state for the plugin.\n */\n addPluginReducer(pluginId, reducer, initialState) {\n this.state.plugins[pluginId] = initialState;\n this.pluginReducers[pluginId] = reducer;\n }\n /**\n * Dispatches an action *only* to the core reducer.\n * Notifies the global store listeners with (action, newState, oldState).\n *\n * @param action The action to dispatch, typed as CoreAction\n * @returns The updated *global* store state\n */\n dispatchToCore(action) {\n if (!this.coreReducer) {\n return this.getState();\n }\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldState = this.getState();\n try {\n this.isDispatching = true;\n this.state.core = this.coreReducer(this.state.core, action);\n } finally {\n this.isDispatching = false;\n }\n this.listeners.forEach((listener) => {\n const currentState = this.getState();\n listener(action, currentState, oldState);\n });\n return this.getState();\n }\n /**\n * Dispatches an action *only* to a specific plugin.\n * Optionally notifies global store listeners if `notifyGlobal` is true.\n * Always notifies plugin-specific listeners with (action, newPluginState, oldPluginState).\n *\n * @param pluginId The plugin identifier\n * @param action The plugin action to dispatch\n * @param notifyGlobal Whether to also notify global store listeners\n * @returns The updated plugin state\n */\n dispatchToPlugin(pluginId, action, notifyGlobal = true) {\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldGlobalState = this.getState();\n const reducer = this.pluginReducers[pluginId];\n if (!reducer) {\n return oldGlobalState.plugins[pluginId];\n }\n const oldPluginState = oldGlobalState.plugins[pluginId];\n try {\n this.isDispatching = true;\n const newPluginState = reducer(oldPluginState, action);\n this.state.plugins[pluginId] = newPluginState;\n } finally {\n this.isDispatching = false;\n }\n if (notifyGlobal) {\n this.listeners.forEach((listener) => {\n const currentGlobalState = this.getState();\n listener(action, currentGlobalState, oldGlobalState);\n });\n }\n if (this.pluginListeners[pluginId]) {\n this.pluginListeners[pluginId].forEach((listener) => {\n const currentPluginState = this.getState().plugins[pluginId];\n listener(action, currentPluginState, oldPluginState);\n });\n }\n return this.getState().plugins[pluginId];\n }\n /**\n * Dispatches an action to update the state using:\n * - the core reducer (if it's a CoreAction)\n * - *all* plugin reducers (regardless of action type), with no global notify for each plugin\n *\n * Returns the new *global* store state after all reducers have processed the action.\n *\n * @param action The action to dispatch (can be CoreAction or any Action).\n */\n dispatch(action) {\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldState = this.getState();\n try {\n this.isDispatching = true;\n if (this.isCoreAction(action)) {\n this.state.core = this.coreReducer(this.state.core, action);\n }\n for (const pluginId in this.pluginReducers) {\n const reducer = this.pluginReducers[pluginId];\n const oldPluginState = oldState.plugins[pluginId];\n if (reducer) {\n this.state.plugins[pluginId] = reducer(oldPluginState, action);\n }\n }\n } finally {\n this.isDispatching = false;\n }\n this.listeners.forEach((listener) => {\n const currentState = this.getState();\n listener(action, currentState, oldState);\n });\n return this.getState();\n }\n /**\n * Returns a shallow copy of the current state.\n * @returns The current store state.\n */\n getState() {\n if (this.isDispatching) {\n throw new Error(\n \"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.\"\n );\n }\n return {\n core: { ...this.state.core },\n plugins: { ...this.state.plugins }\n };\n }\n /**\n * Subscribes a listener to *global* state changes.\n * The callback signature is now (action, newState, oldState).\n *\n * @param listener The callback to invoke on state changes\n * @returns A function to unsubscribe the listener\n */\n subscribe(listener) {\n if (this.isDispatching) {\n throw new Error(\n \"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state.\"\n );\n }\n this.listeners.push(listener);\n return () => {\n if (this.isDispatching) {\n throw new Error(\n \"You may not unsubscribe from a store listener while the reducer is executing.\"\n );\n }\n this.listeners = this.listeners.filter((l) => l !== listener);\n };\n }\n /**\n * Subscribes a listener to *plugin-specific* state changes.\n * The callback signature is now (action, newPluginState, oldPluginState).\n *\n * @param pluginId The unique identifier for the plugin.\n * @param listener The callback to invoke on plugin state changes.\n * @returns A function to unsubscribe the listener.\n */\n subscribeToPlugin(pluginId, listener) {\n if (!(pluginId in this.state.plugins)) {\n throw new Error(\n `Plugin state not found for plugin \"${pluginId}\". Did you forget to call addPluginReducer?`\n );\n }\n if (this.isDispatching) {\n throw new Error(\"You may not call store.subscribeToPlugin() while the reducer is executing.\");\n }\n if (!this.pluginListeners[pluginId]) {\n this.pluginListeners[pluginId] = [];\n }\n this.pluginListeners[pluginId].push(listener);\n return () => {\n if (this.isDispatching) {\n throw new Error(\n \"You may not unsubscribe from a store listener while the reducer is executing.\"\n );\n }\n this.pluginListeners[pluginId] = this.pluginListeners[pluginId].filter((l) => l !== listener);\n if (this.pluginListeners[pluginId].length === 0) {\n delete this.pluginListeners[pluginId];\n }\n };\n }\n /**\n * Subscribes to a specific action type (only from the core's action union).\n * The callback signature is (action, newState, oldState).\n *\n * @param type The action type to listen for.\n * @param handler The callback to invoke when the action occurs.\n * @returns A function to unsubscribe the handler.\n */\n onAction(type, handler) {\n return this.subscribe((action, newState, oldState) => {\n if (action.type === type) {\n handler(action, newState, oldState);\n }\n });\n }\n /**\n * Gets a PluginStore handle for a specific plugin.\n * @param pluginId The unique identifier for the plugin.\n * @returns A PluginStore instance for the plugin.\n */\n getPluginStore(pluginId) {\n if (!(pluginId in this.state.plugins)) {\n throw new Error(\n `Plugin state not found for plugin \"${pluginId}\". Did you forget to call addPluginReducer?`\n );\n }\n return new PluginStore(this, pluginId);\n }\n /**\n * Helper method to check if an action is a CoreAction.\n * Adjust if you have a more refined way to differentiate CoreAction vs. any other Action.\n */\n isCoreAction(action) {\n return CORE_ACTION_TYPES.includes(action.type);\n }\n /**\n * Destroy the store: drop every listener and plugin reducer\n */\n destroy() {\n var _a, _b;\n this.listeners.length = 0;\n for (const id in this.pluginListeners) {\n (_b = (_a = this.pluginListeners[id]) == null ? void 0 : _a.splice) == null ? void 0 : _b.call(_a, 0);\n }\n this.pluginListeners = {};\n this.pluginReducers = {};\n this.state.plugins = {};\n this.state.core = { ...this.initialCoreState };\n }\n}\nconst initialCoreState = (config) => ({\n documents: {},\n documentOrder: [],\n activeDocumentId: null,\n defaultScale: (config == null ? void 0 : config.defaultScale) ?? 1,\n defaultRotation: (config == null ? void 0 : config.defaultRotation) ?? Rotation.Degree0,\n globalPermissions: config == null ? void 0 : config.permissions\n});\nfunction calculateNextActiveDocument(state, closingDocumentId, explicitNext) {\n const currentActiveId = state.activeDocumentId;\n if (currentActiveId !== closingDocumentId) {\n return currentActiveId;\n }\n if (explicitNext !== void 0) {\n return explicitNext && state.documents[explicitNext] ? explicitNext : null;\n }\n const closingIndex = state.documentOrder.indexOf(closingDocumentId);\n if (closingIndex === -1) {\n return null;\n }\n if (closingIndex > 0) {\n return state.documentOrder[closingIndex - 1];\n }\n if (closingIndex < state.documentOrder.length - 1) {\n return state.documentOrder[closingIndex + 1];\n }\n return null;\n}\nfunction moveDocumentInOrder(currentOrder, documentId, toIndex) {\n const fromIndex = currentOrder.indexOf(documentId);\n if (fromIndex === -1) return null;\n if (toIndex < 0 || toIndex >= currentOrder.length) return null;\n if (fromIndex === toIndex) return null;\n const newOrder = [...currentOrder];\n newOrder.splice(fromIndex, 1);\n newOrder.splice(toIndex, 0, documentId);\n return newOrder;\n}\nconst coreReducer = (state, action) => {\n switch (action.type) {\n case START_LOADING_DOCUMENT: {\n const {\n documentId,\n name,\n scale,\n rotation,\n passwordProvided,\n autoActivate = true,\n permissions\n } = action.payload;\n const newDocState = {\n id: documentId,\n name,\n status: \"loading\",\n loadingProgress: 0,\n error: null,\n document: null,\n scale: scale ?? state.defaultScale,\n rotation: rotation ?? state.defaultRotation,\n passwordProvided: passwordProvided ?? false,\n pageRefreshVersions: {},\n permissions,\n loadStartedAt: Date.now()\n };\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: newDocState\n },\n documentOrder: [...state.documentOrder, documentId],\n // Only activate if autoActivate is true (default), or if no document is currently active\n activeDocumentId: autoActivate || !state.activeDocumentId ? documentId : state.activeDocumentId\n };\n }\n case UPDATE_DOCUMENT_LOADING_PROGRESS: {\n const { documentId, progress } = action.payload;\n const docState = state.documents[documentId];\n if (!docState || docState.status !== \"loading\") return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n loadingProgress: progress\n }\n }\n };\n }\n case SET_DOCUMENT_LOADED: {\n const { documentId, document } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"loaded\",\n document,\n error: null,\n errorCode: void 0,\n errorDetails: void 0,\n passwordProvided: void 0,\n loadedAt: Date.now()\n }\n }\n };\n }\n case SET_DOCUMENT_ERROR: {\n const { documentId, error, errorCode, errorDetails } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"error\",\n error,\n errorCode,\n errorDetails\n }\n }\n };\n }\n case RETRY_LOADING_DOCUMENT: {\n const { documentId, passwordProvided } = action.payload;\n const docState = state.documents[documentId];\n if (!docState || docState.status !== \"error\") return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"loading\",\n loadingProgress: 0,\n error: null,\n errorCode: void 0,\n errorDetails: void 0,\n passwordProvided: passwordProvided ?? false,\n loadStartedAt: Date.now()\n }\n }\n };\n }\n case CLOSE_DOCUMENT: {\n const { documentId, nextActiveDocumentId } = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n documentOrder: state.documentOrder.filter((id) => id !== documentId),\n activeDocumentId: calculateNextActiveDocument(state, documentId, nextActiveDocumentId)\n };\n }\n case MOVE_DOCUMENT: {\n const { documentId, toIndex } = action.payload;\n const newOrder = moveDocumentInOrder(state.documentOrder, documentId, toIndex);\n if (!newOrder) return state;\n return {\n ...state,\n documentOrder: newOrder\n };\n }\n case REORDER_DOCUMENTS: {\n return {\n ...state,\n documentOrder: action.payload\n };\n }\n case SET_ACTIVE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload\n };\n }\n case SET_SCALE: {\n const { scale, documentId } = action.payload;\n const targetId = documentId ?? state.activeDocumentId;\n if (!targetId) return state;\n const docState = state.documents[targetId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [targetId]: {\n ...docState,\n scale\n }\n }\n };\n }\n case SET_ROTATION: {\n const { rotation, documentId } = action.payload;\n const targetId = documentId ?? state.activeDocumentId;\n if (!targetId) return state;\n const docState = state.documents[targetId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [targetId]: {\n ...docState,\n rotation\n }\n }\n };\n }\n case REFRESH_PAGES: {\n const { documentId, pageIndexes } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n const newVersions = { ...docState.pageRefreshVersions };\n for (const pageIndex of pageIndexes) {\n newVersions[pageIndex] = (newVersions[pageIndex] || 0) + 1;\n }\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pageRefreshVersions: newVersions\n }\n }\n };\n }\n case UPDATE_DOCUMENT_SECURITY: {\n const { documentId, permissions, isOwnerUnlocked } = action.payload;\n const docState = state.documents[documentId];\n if (!(docState == null ? void 0 : docState.document)) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n document: {\n ...docState.document,\n permissions,\n isOwnerUnlocked\n }\n }\n }\n };\n }\n default:\n return state;\n }\n};\nclass PluginRegistry {\n constructor(engine, config) {\n this.plugins = /* @__PURE__ */ new Map();\n this.manifests = /* @__PURE__ */ new Map();\n this.capabilities = /* @__PURE__ */ new Map();\n this.status = /* @__PURE__ */ new Map();\n this.configurations = /* @__PURE__ */ new Map();\n this.initPromise = null;\n this.pendingRegistrations = [];\n this.processingRegistrations = [];\n this.initialized = false;\n this.isInitializing = false;\n this.pluginsReadyPromise = null;\n this.destroyed = false;\n this.resolver = new DependencyResolver();\n this.engine = engine;\n this.initialCoreState = initialCoreState(config);\n this.store = new Store(coreReducer, this.initialCoreState);\n this.logger = (config == null ? void 0 : config.logger) ?? new NoopLogger();\n }\n /**\n * Get the logger instance\n */\n getLogger() {\n return this.logger;\n }\n /**\n * Register a plugin without initializing it\n */\n registerPlugin(pluginPackage, config) {\n if (this.initialized && !this.isInitializing) {\n throw new PluginRegistrationError(\"Cannot register plugins after initialization\");\n }\n this.validateManifest(pluginPackage.manifest);\n this.store.addPluginReducer(\n pluginPackage.manifest.id,\n // We need one type assertion here since we can't fully reconcile TAction with Action\n // due to TypeScript's type system limitations with generic variance\n pluginPackage.reducer,\n \"function\" === typeof pluginPackage.initialState ? pluginPackage.initialState(\n this.initialCoreState,\n {\n ...pluginPackage.manifest.defaultConfig,\n ...config\n }\n ) : pluginPackage.initialState\n );\n this.pendingRegistrations.push({\n package: pluginPackage,\n config\n });\n }\n /**\n * Get the central store instance\n */\n getStore() {\n return this.store;\n }\n /**\n * Get the engine instance\n */\n getEngine() {\n return this.engine;\n }\n /**\n * Get a promise that resolves when all plugins are ready\n */\n pluginsReady() {\n if (this.pluginsReadyPromise) {\n return this.pluginsReadyPromise;\n }\n this.pluginsReadyPromise = (async () => {\n if (!this.initialized) {\n await this.initialize();\n }\n const readyPromises = Array.from(this.plugins.values()).map(\n (p) => typeof p.ready === \"function\" ? p.ready() : Promise.resolve()\n );\n await Promise.all(readyPromises);\n })();\n return this.pluginsReadyPromise;\n }\n /**\n * INITIALISE THE REGISTRY – runs once no-matter-how-many calls *\n */\n async initialize() {\n if (this.destroyed) {\n throw new PluginRegistrationError(\"Registry has been destroyed\");\n }\n if (this.initPromise) {\n return this.initPromise;\n }\n this.initPromise = (async () => {\n if (this.initialized) {\n throw new PluginRegistrationError(\"Registry is already initialized\");\n }\n this.isInitializing = true;\n try {\n if (this.destroyed) return;\n while (this.pendingRegistrations.length > 0) {\n if (this.destroyed) return;\n this.processingRegistrations = [...this.pendingRegistrations];\n this.pendingRegistrations = [];\n for (const reg of this.processingRegistrations) {\n const dependsOn = /* @__PURE__ */ new Set();\n const allDeps = [...reg.package.manifest.requires, ...reg.package.manifest.optional];\n for (const cap of allDeps) {\n const provider = this.processingRegistrations.find(\n (r) => r.package.manifest.provides.includes(cap)\n );\n if (provider) {\n dependsOn.add(provider.package.manifest.id);\n }\n }\n this.resolver.addNode(reg.package.manifest.id, [...dependsOn]);\n }\n const loadOrder = this.resolver.resolveLoadOrder();\n for (const id of loadOrder) {\n const reg = this.processingRegistrations.find((r) => r.package.manifest.id === id);\n this.instantiatePlugin(reg.package.manifest, reg.package.create, reg.config);\n }\n for (const id of loadOrder) {\n await this.runPluginInitialization(id);\n }\n this.processingRegistrations = [];\n this.resolver = new DependencyResolver();\n }\n this.initialized = true;\n } catch (err) {\n if (err instanceof Error) {\n throw new CircularDependencyError(\n `Failed to resolve plugin dependencies: ${err.message}`\n );\n }\n throw err;\n } finally {\n this.isInitializing = false;\n }\n })();\n return this.initPromise;\n }\n /**\n * Phase 2: Create instance and register capabilities\n */\n instantiatePlugin(manifest, packageCreator, config) {\n const finalConfig = {\n ...manifest.defaultConfig,\n ...config\n };\n this.validateConfig(manifest.id, finalConfig, manifest.defaultConfig);\n const plugin = packageCreator(this, finalConfig);\n this.validatePlugin(plugin);\n for (const capability of manifest.provides) {\n if (this.capabilities.has(capability)) {\n throw new PluginRegistrationError(\n `Capability ${capability} is already provided by plugin ${this.capabilities.get(capability)}`\n );\n }\n this.capabilities.set(capability, manifest.id);\n }\n this.plugins.set(manifest.id, plugin);\n this.manifests.set(manifest.id, manifest);\n this.status.set(manifest.id, \"registered\");\n this.configurations.set(manifest.id, finalConfig);\n }\n /**\n * Phase 3: Run the initialize method\n */\n async runPluginInitialization(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) return;\n const manifest = this.manifests.get(pluginId);\n const config = this.configurations.get(pluginId);\n for (const capability of manifest.requires) {\n if (!this.capabilities.has(capability)) {\n throw new PluginRegistrationError(\n `Missing required capability: ${capability} for plugin ${pluginId}`\n );\n }\n }\n this.logger.debug(\"PluginRegistry\", \"InitializePlugin\", `Initializing plugin ${pluginId}`);\n try {\n if (plugin.initialize) {\n await plugin.initialize(config);\n }\n this.status.set(pluginId, \"active\");\n this.logger.info(\n \"PluginRegistry\",\n \"PluginInitialized\",\n `Plugin ${pluginId} initialized successfully`\n );\n } catch (error) {\n this.status.set(pluginId, \"error\");\n this.logger.error(\n \"PluginRegistry\",\n \"InitializationFailed\",\n `Plugin ${pluginId} initialization failed`,\n { error }\n );\n throw error;\n }\n }\n getPluginConfig(pluginId) {\n const config = this.configurations.get(pluginId);\n if (!config) {\n throw new PluginNotFoundError(`Configuration for plugin ${pluginId} not found`);\n }\n return config;\n }\n validateConfig(pluginId, config, defaultConfig) {\n const requiredKeys = Object.keys(defaultConfig);\n const missingKeys = requiredKeys.filter((key) => !config.hasOwnProperty(key));\n if (missingKeys.length > 0) {\n throw new PluginConfigurationError(\n `Missing required configuration keys for plugin ${pluginId}: ${missingKeys.join(\", \")}`\n );\n }\n }\n async updatePluginConfig(pluginId, config) {\n const plugin = this.getPlugin(pluginId);\n if (!plugin) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n const manifest = this.manifests.get(pluginId);\n const currentConfig = this.configurations.get(pluginId);\n if (!manifest || !currentConfig) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n const newConfig = {\n ...currentConfig,\n ...config\n };\n this.validateConfig(pluginId, newConfig, manifest.defaultConfig);\n this.configurations.set(pluginId, newConfig);\n if (plugin.initialize) {\n await plugin.initialize(newConfig);\n }\n }\n /**\n * Register multiple plugins at once\n */\n registerPluginBatch(registrations) {\n for (const reg of registrations) {\n this.registerPlugin(reg.package, reg.config);\n }\n }\n /**\n * Unregister a plugin\n */\n async unregisterPlugin(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) {\n throw new PluginNotFoundError(`Plugin ${pluginId} is not registered`);\n }\n const manifest = this.manifests.get(pluginId);\n if (!manifest) {\n throw new PluginNotFoundError(`Manifest for plugin ${pluginId} not found`);\n }\n for (const [otherId, otherManifest] of this.manifests.entries()) {\n if (otherId === pluginId) continue;\n const dependsOnThis = [...otherManifest.requires, ...otherManifest.optional].some(\n (cap) => manifest.provides.includes(cap)\n );\n if (dependsOnThis) {\n throw new PluginRegistrationError(\n `Cannot unregister plugin ${pluginId}: plugin ${otherId} depends on it`\n );\n }\n }\n try {\n if (plugin.destroy) {\n await plugin.destroy();\n }\n for (const capability of manifest.provides) {\n this.capabilities.delete(capability);\n }\n this.plugins.delete(pluginId);\n this.manifests.delete(pluginId);\n this.status.delete(pluginId);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to unregister plugin ${pluginId}: ${error.message}`);\n }\n throw error;\n }\n }\n /**\n * Get a plugin instance\n * @param pluginId The ID of the plugin to get\n * @returns The plugin instance or null if not found\n */\n getPlugin(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) {\n return null;\n }\n return plugin;\n }\n /**\n * Get a plugin that provides a specific capability\n * @param capability The capability to get a provider for\n * @returns The plugin providing the capability or null if not found\n */\n getCapabilityProvider(capability) {\n const pluginId = this.capabilities.get(capability);\n if (!pluginId) {\n return null;\n }\n return this.getPlugin(pluginId);\n }\n /**\n * Check if a capability is available\n */\n hasCapability(capability) {\n return this.capabilities.has(capability);\n }\n /**\n * Get all registered plugins\n */\n getAllPlugins() {\n return Array.from(this.plugins.values());\n }\n /**\n * Get plugin status\n */\n getPluginStatus(pluginId) {\n const status = this.status.get(pluginId);\n if (!status) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n return status;\n }\n /**\n * Validate plugin object\n */\n validatePlugin(plugin) {\n if (!plugin.id) {\n throw new PluginRegistrationError(\"Plugin must have an id\");\n }\n }\n /**\n * Validate plugin manifest\n */\n validateManifest(manifest) {\n if (!manifest.id) {\n throw new PluginRegistrationError(\"Manifest must have an id\");\n }\n if (!manifest.name) {\n throw new PluginRegistrationError(\"Manifest must have a name\");\n }\n if (!manifest.version) {\n throw new PluginRegistrationError(\"Manifest must have a version\");\n }\n if (!Array.isArray(manifest.provides)) {\n throw new PluginRegistrationError(\"Manifest must have a provides array\");\n }\n if (!Array.isArray(manifest.requires)) {\n throw new PluginRegistrationError(\"Manifest must have a requires array\");\n }\n if (!Array.isArray(manifest.optional)) {\n throw new PluginRegistrationError(\"Manifest must have an optional array\");\n }\n }\n isDestroyed() {\n return this.destroyed;\n }\n /**\n * DESTROY EVERYTHING – waits for any ongoing initialise(), once *\n */\n async destroy() {\n var _a;\n if (this.destroyed) throw new PluginRegistrationError(\"Registry has already been destroyed\");\n this.destroyed = true;\n try {\n await this.initPromise;\n } catch {\n }\n for (const plugin of Array.from(this.plugins.values()).reverse()) {\n await ((_a = plugin.destroy) == null ? void 0 : _a.call(plugin));\n }\n this.store.destroy();\n this.plugins.clear();\n this.manifests.clear();\n this.capabilities.clear();\n this.status.clear();\n this.pendingRegistrations.length = 0;\n this.processingRegistrations.length = 0;\n }\n}\nfunction hasAutoMountElements(pkg) {\n return \"autoMountElements\" in pkg && typeof pkg.autoMountElements === \"function\";\n}\nvar root_5 = $.from_html(`<!> <!>`, 1);\nfunction NestedWrapper_1($$anchor, $$props) {\n $.push($$props, true);\n let utilities = $.prop($$props, \"utilities\", 19, () => []);\n var fragment = $.comment();\n var node = $.first_child(fragment);\n {\n var consequent = ($$anchor2) => {\n const Wrapper = $.derived(() => $$props.wrappers[0]);\n var fragment_1 = $.comment();\n var node_1 = $.first_child(fragment_1);\n $.component(node_1, () => $.get(Wrapper), ($$anchor3, Wrapper_1) => {\n Wrapper_1($$anchor3, {\n children: ($$anchor4, $$slotProps) => {\n {\n let $0 = $.derived(() => $$props.wrappers.slice(1));\n NestedWrapper_1($$anchor4, {\n get wrappers() {\n return $.get($0);\n },\n get utilities() {\n return utilities();\n },\n children: ($$anchor5, $$slotProps2) => {\n var fragment_3 = $.comment();\n var node_2 = $.first_child(fragment_3);\n $.snippet(node_2, () => $$props.children ?? $.noop);\n $.append($$anchor5, fragment_3);\n },\n $$slots: { default: true }\n });\n }\n },\n $$slots: { default: true }\n });\n });\n $.append($$anchor2, fragment_1);\n };\n var alternate = ($$anchor2) => {\n const Wrapper = $.derived(() => $$props.wrappers[0]);\n var fragment_4 = $.comment();\n var node_3 = $.first_child(fragment_4);\n $.component(node_3, () => $.get(Wrapper), ($$anchor3, Wrapper_2) => {\n Wrapper_2($$anchor3, {\n children: ($$anchor4, $$slotProps) => {\n var fragment_5 = root_5();\n var node_4 = $.first_child(fragment_5);\n $.snippet(node_4, () => $$props.children ?? $.noop);\n var node_5 = $.sibling(node_4, 2);\n $.each(node_5, 19, utilities, (Utility, i) => `utility-${i}`, ($$anchor5, Utility) => {\n var fragment_6 = $.comment();\n var node_6 = $.first_child(fragment_6);\n $.component(node_6, () => $.get(Utility), ($$anchor6, Utility_1) => {\n Utility_1($$anchor6, {});\n });\n $.append($$anchor5, fragment_6);\n });\n $.append($$anchor4, fragment_5);\n },\n $$slots: { default: true }\n });\n });\n $.append($$anchor2, fragment_4);\n };\n $.if(node, ($$render) => {\n if ($$props.wrappers.length > 1) $$render(consequent);\n else $$render(alternate, false);\n });\n }\n $.append($$anchor, fragment);\n $.pop();\n}\nvar root_2 = $.from_html(`<!> <!>`, 1);\nfunction AutoMount($$anchor, $$props) {\n $.push($$props, true);\n let utilities = $.state($.proxy([]));\n let wrappers = $.state($.proxy([]));\n $.user_effect(() => {\n var _a;\n const nextUtilities = [];\n const nextWrappers = [];\n for (const reg of $$props.plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = ((_a = pkg.autoMountElements) == null ? void 0 : _a.call(pkg)) ?? [];\n for (const element of elements) {\n if (element.type === \"utility\") {\n nextUtilities.push(element.component);\n } else if (element.type === \"wrapper\") {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n $.set(utilities, nextUtilities, true);\n $.set(wrappers, nextWrappers, true);\n });\n var fragment = $.comment();\n var node = $.first_child(fragment);\n {\n var consequent = ($$anchor2) => {\n NestedWrapper_1($$anchor2, {\n get wrappers() {\n return $.get(wrappers);\n },\n get utilities() {\n return $.get(utilities);\n },\n get children() {\n return $$props.children;\n }\n });\n };\n var alternate = ($$anchor2) => {\n var fragment_2 = root_2();\n var node_1 = $.first_child(fragment_2);\n $.snippet(node_1, () => $$props.children ?? $.noop);\n var node_2 = $.sibling(node_1, 2);\n $.each(node_2, 19, () => $.get(utilities), (Utility, i) => `utility-${i}`, ($$anchor3, Utility) => {\n var fragment_3 = $.comment();\n var node_3 = $.first_child(fragment_3);\n $.component(node_3, () => $.get(Utility), ($$anchor4, Utility_1) => {\n Utility_1($$anchor4, {});\n });\n $.append($$anchor3, fragment_3);\n });\n $.append($$anchor2, fragment_2);\n };\n $.if(node, ($$render) => {\n if ($.get(wrappers).length > 0) $$render(consequent);\n else $$render(alternate, false);\n });\n }\n $.append($$anchor, fragment);\n $.pop();\n}\nfunction EmbedPDF($$anchor, $$props) {\n $.push($$props, true);\n let autoMountDomElements = $.prop($$props, \"autoMountDomElements\", 3, true);\n let latestInit = $$props.onInitialized;\n $.user_effect(() => {\n if ($$props.onInitialized) {\n latestInit = $$props.onInitialized;\n }\n });\n $.user_effect(() => {\n var _a;\n if ($$props.engine || $$props.engine && $$props.plugins) {\n const finalConfig = {\n ...$$props.config,\n logger: ((_a = $$props.config) == null ? void 0 : _a.logger) ?? $$props.logger\n };\n const reg = new PluginRegistry($$props.engine, finalConfig);\n reg.registerPluginBatch($$props.plugins);\n const initialize = async () => {\n await reg.initialize();\n if (reg.isDestroyed()) {\n return;\n }\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument = activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder.map((docId) => documents[docId]).filter((doc) => doc !== null && doc !== void 0);\n }\n });\n await (latestInit == null ? void 0 : latestInit(reg));\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n return unsubscribe;\n };\n let cleanup;\n initialize().then((unsub) => {\n cleanup = unsub;\n }).catch(console.error);\n return () => {\n cleanup == null ? void 0 : cleanup();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n var fragment = $.comment();\n var node = $.first_child(fragment);\n {\n var consequent = ($$anchor2) => {\n AutoMount($$anchor2, {\n get plugins() {\n return $$props.plugins;\n },\n children: ($$anchor3, $$slotProps) => {\n var fragment_2 = $.comment();\n var node_1 = $.first_child(fragment_2);\n $.snippet(node_1, () => $$props.children, () => pdfContext);\n $.append($$anchor3, fragment_2);\n },\n $$slots: { default: true }\n });\n };\n var alternate = ($$anchor2) => {\n var fragment_3 = $.comment();\n var node_2 = $.first_child(fragment_3);\n $.snippet(node_2, () => $$props.children, () => pdfContext);\n $.append($$anchor2, fragment_3);\n };\n $.if(node, ($$render) => {\n if (pdfContext.pluginsReady && autoMountDomElements()) $$render(consequent);\n else $$render(alternate, false);\n });\n }\n $.append($$anchor, fragment);\n $.pop();\n}\nexport {\n EmbedPDF,\n pdfContext,\n useCapability,\n useCoreState,\n useDocumentPermissions,\n useDocumentState,\n usePlugin,\n useRegistry\n};\n//# sourceMappingURL=index.js.map\n","class DependencyResolver {\n constructor() {\n this.dependencyGraph = /* @__PURE__ */ new Map();\n }\n addNode(id, dependencies = []) {\n this.dependencyGraph.set(id, new Set(dependencies));\n }\n hasCircularDependencies() {\n const visited = /* @__PURE__ */ new Set();\n const recursionStack = /* @__PURE__ */ new Set();\n const dfs = (id) => {\n visited.add(id);\n recursionStack.add(id);\n const dependencies = this.dependencyGraph.get(id) || /* @__PURE__ */ new Set();\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n if (dfs(dep)) return true;\n } else if (recursionStack.has(dep)) {\n return true;\n }\n }\n recursionStack.delete(id);\n return false;\n };\n for (const id of this.dependencyGraph.keys()) {\n if (!visited.has(id)) {\n if (dfs(id)) return true;\n }\n }\n return false;\n }\n resolveLoadOrder() {\n if (this.hasCircularDependencies()) {\n throw new Error(\"Circular dependencies detected\");\n }\n const result = [];\n const visited = /* @__PURE__ */ new Set();\n const temp = /* @__PURE__ */ new Set();\n const visit = (id) => {\n if (temp.has(id)) throw new Error(\"Circular dependency\");\n if (visited.has(id)) return;\n temp.add(id);\n const dependencies = this.dependencyGraph.get(id) || /* @__PURE__ */ new Set();\n for (const dep of dependencies) {\n visit(dep);\n }\n temp.delete(id);\n visited.add(id);\n result.push(id);\n };\n for (const id of this.dependencyGraph.keys()) {\n if (!visited.has(id)) {\n visit(id);\n }\n }\n return result;\n }\n}\nclass PluginRegistrationError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginRegistrationError\";\n }\n}\nclass PluginNotFoundError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginNotFoundError\";\n }\n}\nclass CircularDependencyError extends Error {\n constructor(message) {\n super(message);\n this.name = \"CircularDependencyError\";\n }\n}\nclass CapabilityNotFoundError extends Error {\n constructor(message) {\n super(message);\n this.name = \"CapabilityNotFoundError\";\n }\n}\nclass CapabilityConflictError extends Error {\n constructor(message) {\n super(message);\n this.name = \"CapabilityConflictError\";\n }\n}\nclass PluginInitializationError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginInitializationError\";\n }\n}\nclass PluginConfigurationError extends Error {\n constructor(message) {\n super(message);\n this.name = \"PluginConfigurationError\";\n }\n}\nvar Rotation = /* @__PURE__ */ ((Rotation2) => {\n Rotation2[Rotation2[\"Degree0\"] = 0] = \"Degree0\";\n Rotation2[Rotation2[\"Degree90\"] = 1] = \"Degree90\";\n Rotation2[Rotation2[\"Degree180\"] = 2] = \"Degree180\";\n Rotation2[Rotation2[\"Degree270\"] = 3] = \"Degree270\";\n return Rotation2;\n})(Rotation || {});\nclass NoopLogger {\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled() {\n return false;\n }\n /** {@inheritDoc Logger.debug} */\n debug() {\n }\n /** {@inheritDoc Logger.info} */\n info() {\n }\n /** {@inheritDoc Logger.warn} */\n warn() {\n }\n /** {@inheritDoc Logger.error} */\n error() {\n }\n /** {@inheritDoc Logger.perf} */\n perf() {\n }\n}\nconst PdfSoftHyphenMarker = \"­\";\nconst PdfZeroWidthSpace = \"​\";\nconst PdfWordJoiner = \"⁠\";\nconst PdfBomOrZwnbsp = \"\\uFEFF\";\nconst PdfNonCharacterFFFE = \"￾\";\nconst PdfNonCharacterFFFF = \"￿\";\nconst PdfUnwantedTextMarkers = Object.freeze([\n PdfSoftHyphenMarker,\n PdfZeroWidthSpace,\n PdfWordJoiner,\n PdfBomOrZwnbsp,\n PdfNonCharacterFFFE,\n PdfNonCharacterFFFF\n]);\nnew RegExp(`[${PdfUnwantedTextMarkers.join(\"\")}]`, \"g\");\nvar PdfStandardFont = /* @__PURE__ */ ((PdfStandardFont2) => {\n PdfStandardFont2[PdfStandardFont2[\"Unknown\"] = -1] = \"Unknown\";\n PdfStandardFont2[PdfStandardFont2[\"Courier\"] = 0] = \"Courier\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Bold\"] = 1] = \"Courier_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_BoldOblique\"] = 2] = \"Courier_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Oblique\"] = 3] = \"Courier_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica\"] = 4] = \"Helvetica\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Bold\"] = 5] = \"Helvetica_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_BoldOblique\"] = 6] = \"Helvetica_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Oblique\"] = 7] = \"Helvetica_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Roman\"] = 8] = \"Times_Roman\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Bold\"] = 9] = \"Times_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Times_BoldItalic\"] = 10] = \"Times_BoldItalic\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Italic\"] = 11] = \"Times_Italic\";\n PdfStandardFont2[PdfStandardFont2[\"Symbol\"] = 12] = \"Symbol\";\n PdfStandardFont2[PdfStandardFont2[\"ZapfDingbats\"] = 13] = \"ZapfDingbats\";\n return PdfStandardFont2;\n})(PdfStandardFont || {});\nvar PdfTextAlignment = /* @__PURE__ */ ((PdfTextAlignment2) => {\n PdfTextAlignment2[PdfTextAlignment2[\"Left\"] = 0] = \"Left\";\n PdfTextAlignment2[PdfTextAlignment2[\"Center\"] = 1] = \"Center\";\n PdfTextAlignment2[PdfTextAlignment2[\"Right\"] = 2] = \"Right\";\n return PdfTextAlignment2;\n})(PdfTextAlignment || {});\nvar PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {\n PdfBlendMode2[PdfBlendMode2[\"Normal\"] = 0] = \"Normal\";\n PdfBlendMode2[PdfBlendMode2[\"Multiply\"] = 1] = \"Multiply\";\n PdfBlendMode2[PdfBlendMode2[\"Screen\"] = 2] = \"Screen\";\n PdfBlendMode2[PdfBlendMode2[\"Overlay\"] = 3] = \"Overlay\";\n PdfBlendMode2[PdfBlendMode2[\"Darken\"] = 4] = \"Darken\";\n PdfBlendMode2[PdfBlendMode2[\"Lighten\"] = 5] = \"Lighten\";\n PdfBlendMode2[PdfBlendMode2[\"ColorDodge\"] = 6] = \"ColorDodge\";\n PdfBlendMode2[PdfBlendMode2[\"ColorBurn\"] = 7] = \"ColorBurn\";\n PdfBlendMode2[PdfBlendMode2[\"HardLight\"] = 8] = \"HardLight\";\n PdfBlendMode2[PdfBlendMode2[\"SoftLight\"] = 9] = \"SoftLight\";\n PdfBlendMode2[PdfBlendMode2[\"Difference\"] = 10] = \"Difference\";\n PdfBlendMode2[PdfBlendMode2[\"Exclusion\"] = 11] = \"Exclusion\";\n PdfBlendMode2[PdfBlendMode2[\"Hue\"] = 12] = \"Hue\";\n PdfBlendMode2[PdfBlendMode2[\"Saturation\"] = 13] = \"Saturation\";\n PdfBlendMode2[PdfBlendMode2[\"Color\"] = 14] = \"Color\";\n PdfBlendMode2[PdfBlendMode2[\"Luminosity\"] = 15] = \"Luminosity\";\n return PdfBlendMode2;\n})(PdfBlendMode || {});\nconst PdfAnnotationFlagName = Object.freeze({\n [\n 1\n /* INVISIBLE */\n ]: \"invisible\",\n [\n 2\n /* HIDDEN */\n ]: \"hidden\",\n [\n 4\n /* PRINT */\n ]: \"print\",\n [\n 8\n /* NO_ZOOM */\n ]: \"noZoom\",\n [\n 16\n /* NO_ROTATE */\n ]: \"noRotate\",\n [\n 32\n /* NO_VIEW */\n ]: \"noView\",\n [\n 64\n /* READ_ONLY */\n ]: \"readOnly\",\n [\n 128\n /* LOCKED */\n ]: \"locked\",\n [\n 256\n /* TOGGLE_NOVIEW */\n ]: \"toggleNoView\"\n});\nObject.entries(\n PdfAnnotationFlagName\n).reduce(\n (acc, [bit, name]) => {\n acc[name] = Number(bit);\n return acc;\n },\n {}\n);\nvar PdfPermissionFlag = /* @__PURE__ */ ((PdfPermissionFlag2) => {\n PdfPermissionFlag2[PdfPermissionFlag2[\"Print\"] = 4] = \"Print\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyContents\"] = 8] = \"ModifyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"CopyContents\"] = 16] = \"CopyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyAnnotations\"] = 32] = \"ModifyAnnotations\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"FillForms\"] = 256] = \"FillForms\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ExtractForAccessibility\"] = 512] = \"ExtractForAccessibility\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AssembleDocument\"] = 1024] = \"AssembleDocument\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"PrintHighQuality\"] = 2048] = \"PrintHighQuality\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AllowAll\"] = 3900] = \"AllowAll\";\n return PdfPermissionFlag2;\n})(PdfPermissionFlag || {});\nclass PermissionDeniedError extends Error {\n constructor(requiredFlags, currentPermissions) {\n const flagNames = requiredFlags.map((f) => PdfPermissionFlag[f]).join(\", \");\n super(`Permission denied. Required: ${flagNames}`);\n this.requiredFlags = requiredFlags;\n this.currentPermissions = currentPermissions;\n this.name = \"PermissionDeniedError\";\n }\n}\nconst TEXT_ALIGNMENT_INFOS = Object.freeze([\n { id: PdfTextAlignment.Left, label: \"Left\", css: \"left\" },\n { id: PdfTextAlignment.Center, label: \"Center\", css: \"center\" },\n { id: PdfTextAlignment.Right, label: \"Right\", css: \"right\" }\n]);\nTEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nTEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nTEXT_ALIGNMENT_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nvar PdfStandardFontFamily = /* @__PURE__ */ ((PdfStandardFontFamily2) => {\n PdfStandardFontFamily2[\"Courier\"] = \"Courier\";\n PdfStandardFontFamily2[\"Helvetica\"] = \"Helvetica\";\n PdfStandardFontFamily2[\"Times\"] = \"Times\";\n PdfStandardFontFamily2[\"Symbol\"] = \"Symbol\";\n PdfStandardFontFamily2[\"ZapfDingbats\"] = \"ZapfDingbats\";\n PdfStandardFontFamily2[\"Unknown\"] = \"Unknown\";\n return PdfStandardFontFamily2;\n})(PdfStandardFontFamily || {});\nPdfStandardFont.Helvetica;\nconst HELVETICA_DESC = {\n id: PdfStandardFont.Helvetica,\n family: \"Helvetica\",\n bold: false,\n italic: false,\n label: \"Helvetica\",\n css: \"Helvetica, Arial, sans-serif\"\n};\nconst STANDARD_FONT_DESCRIPTORS = Object.freeze([\n {\n id: PdfStandardFont.Courier,\n family: \"Courier\",\n bold: false,\n italic: false,\n label: \"Courier\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Bold,\n family: \"Courier\",\n bold: true,\n italic: false,\n label: \"Courier Bold\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_BoldOblique,\n family: \"Courier\",\n bold: true,\n italic: true,\n label: \"Courier Bold Oblique\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Oblique,\n family: \"Courier\",\n bold: false,\n italic: true,\n label: \"Courier Oblique\",\n css: \"Courier, monospace\"\n },\n HELVETICA_DESC,\n {\n id: PdfStandardFont.Helvetica_Bold,\n family: \"Helvetica\",\n bold: true,\n italic: false,\n label: \"Helvetica Bold\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_BoldOblique,\n family: \"Helvetica\",\n bold: true,\n italic: true,\n label: \"Helvetica Bold Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_Oblique,\n family: \"Helvetica\",\n bold: false,\n italic: true,\n label: \"Helvetica Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Times_Roman,\n family: \"Times\",\n bold: false,\n italic: false,\n label: \"Times Roman\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Bold,\n family: \"Times\",\n bold: true,\n italic: false,\n label: \"Times Bold\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_BoldItalic,\n family: \"Times\",\n bold: true,\n italic: true,\n label: \"Times Bold Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Italic,\n family: \"Times\",\n bold: false,\n italic: true,\n label: \"Times Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Symbol,\n family: \"Symbol\",\n bold: false,\n italic: false,\n label: \"Symbol\",\n css: \"Symbol, serif\"\n },\n {\n id: PdfStandardFont.ZapfDingbats,\n family: \"ZapfDingbats\",\n bold: false,\n italic: false,\n label: \"Zapf Dingbats\",\n css: \"ZapfDingbats, serif\"\n }\n]);\nSTANDARD_FONT_DESCRIPTORS.reduce((m, d) => (m[d.id] = d, m), {});\nconst familyStyleToId = /* @__PURE__ */ new Map();\nfor (const d of STANDARD_FONT_DESCRIPTORS) {\n familyStyleToId.set(`${d.family}_${d.bold}_${d.italic}`, d.id);\n}\nObject.values(PdfStandardFontFamily).filter(\n (f) => f !== \"Unknown\"\n /* Unknown */\n).map((family) => ({ value: family, label: family }));\n[\n ...new Set(STANDARD_FONT_DESCRIPTORS.map((d) => d.family))\n];\nconst BLEND_MODE_INFOS = Object.freeze([\n { id: PdfBlendMode.Normal, label: \"Normal\", css: \"normal\" },\n { id: PdfBlendMode.Multiply, label: \"Multiply\", css: \"multiply\" },\n { id: PdfBlendMode.Screen, label: \"Screen\", css: \"screen\" },\n { id: PdfBlendMode.Overlay, label: \"Overlay\", css: \"overlay\" },\n { id: PdfBlendMode.Darken, label: \"Darken\", css: \"darken\" },\n { id: PdfBlendMode.Lighten, label: \"Lighten\", css: \"lighten\" },\n { id: PdfBlendMode.ColorDodge, label: \"Color Dodge\", css: \"color-dodge\" },\n { id: PdfBlendMode.ColorBurn, label: \"Color Burn\", css: \"color-burn\" },\n { id: PdfBlendMode.HardLight, label: \"Hard Light\", css: \"hard-light\" },\n { id: PdfBlendMode.SoftLight, label: \"Soft Light\", css: \"soft-light\" },\n { id: PdfBlendMode.Difference, label: \"Difference\", css: \"difference\" },\n { id: PdfBlendMode.Exclusion, label: \"Exclusion\", css: \"exclusion\" },\n { id: PdfBlendMode.Hue, label: \"Hue\", css: \"hue\" },\n { id: PdfBlendMode.Saturation, label: \"Saturation\", css: \"saturation\" },\n { id: PdfBlendMode.Color, label: \"Color\", css: \"color\" },\n { id: PdfBlendMode.Luminosity, label: \"Luminosity\", css: \"luminosity\" }\n]);\nBLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nBLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nBLEND_MODE_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nBLEND_MODE_INFOS.map((info) => info.id);\nclass PluginStore {\n /**\n * Initializes the PluginStore with the main store and plugin ID.\n * @param store The main store instance.\n * @param pluginId The unique identifier for the plugin.\n */\n constructor(store, pluginId) {\n this.store = store;\n this.pluginId = pluginId;\n }\n /**\n * Gets the current state of the plugin.\n * @returns The plugin's state.\n */\n getState() {\n return this.store.getState().plugins[this.pluginId];\n }\n /**\n * Dispatches an action for the plugin and returns the *new* global state.\n * If you only need the plugin’s updated state, call `getState()` afterward.\n * @param action The action to dispatch.\n * @returns The updated global store state (after plugin reducer).\n */\n dispatch(action) {\n return this.store.dispatchToPlugin(this.pluginId, action);\n }\n /**\n * Subscribes to state changes only for this specific plugin.\n * You now receive (action, newPluginState, oldPluginState) in the callback.\n *\n * @param listener The callback to invoke when plugin state changes.\n * @returns A function to unsubscribe the listener.\n */\n subscribeToState(listener) {\n return this.store.subscribeToPlugin(this.pluginId, (action, newPluginState, oldPluginState) => {\n listener(\n action,\n newPluginState,\n oldPluginState\n );\n });\n }\n /**\n * Subscribes to a specific action type for the plugin.\n * This still uses the main store's `onAction`, so you get the *global*\n * old/new store states there. If you specifically want old/new plugin state,\n * use `subscribeToState` instead.\n *\n * @param type The action type to listen for.\n * @param handler The callback to invoke when the action occurs.\n * @returns A function to unsubscribe the handler.\n */\n onAction(type, handler) {\n return this.store.onAction(type, (action, state, oldState) => {\n handler(\n action,\n state.plugins[this.pluginId],\n oldState.plugins[this.pluginId]\n );\n });\n }\n}\nconst START_LOADING_DOCUMENT = \"START_LOADING_DOCUMENT\";\nconst UPDATE_DOCUMENT_LOADING_PROGRESS = \"UPDATE_DOCUMENT_LOADING_PROGRESS\";\nconst SET_DOCUMENT_LOADED = \"SET_DOCUMENT_LOADED\";\nconst SET_DOCUMENT_ERROR = \"SET_DOCUMENT_ERROR\";\nconst RETRY_LOADING_DOCUMENT = \"RETRY_LOADING_DOCUMENT\";\nconst CLOSE_DOCUMENT = \"CLOSE_DOCUMENT\";\nconst SET_ACTIVE_DOCUMENT = \"SET_ACTIVE_DOCUMENT\";\nconst REORDER_DOCUMENTS = \"REORDER_DOCUMENTS\";\nconst MOVE_DOCUMENT = \"MOVE_DOCUMENT\";\nconst UPDATE_DOCUMENT_SECURITY = \"UPDATE_DOCUMENT_SECURITY\";\nconst REFRESH_DOCUMENT = \"REFRESH_DOCUMENT\";\nconst REFRESH_PAGES = \"REFRESH_PAGES\";\nconst SET_PAGES = \"SET_PAGES\";\nconst SET_SCALE = \"SET_SCALE\";\nconst SET_ROTATION = \"SET_ROTATION\";\nconst SET_DEFAULT_SCALE = \"SET_DEFAULT_SCALE\";\nconst SET_DEFAULT_ROTATION = \"SET_DEFAULT_ROTATION\";\nconst CORE_ACTION_TYPES = [\n START_LOADING_DOCUMENT,\n UPDATE_DOCUMENT_LOADING_PROGRESS,\n SET_DOCUMENT_LOADED,\n CLOSE_DOCUMENT,\n SET_ACTIVE_DOCUMENT,\n SET_DOCUMENT_ERROR,\n RETRY_LOADING_DOCUMENT,\n REFRESH_DOCUMENT,\n REFRESH_PAGES,\n SET_PAGES,\n SET_SCALE,\n SET_ROTATION,\n SET_DEFAULT_SCALE,\n SET_DEFAULT_ROTATION,\n REORDER_DOCUMENTS,\n MOVE_DOCUMENT,\n UPDATE_DOCUMENT_SECURITY\n];\nconst startLoadingDocument = (documentId, name, scale, rotation, passwordProvided, autoActivate, permissions) => ({\n type: START_LOADING_DOCUMENT,\n payload: { documentId, name, scale, rotation, passwordProvided, autoActivate, permissions }\n});\nconst updateDocumentLoadingProgress = (documentId, progress) => ({\n type: UPDATE_DOCUMENT_LOADING_PROGRESS,\n payload: { documentId, progress }\n});\nconst setDocumentLoaded = (documentId, document) => ({\n type: SET_DOCUMENT_LOADED,\n payload: { documentId, document }\n});\nconst setDocumentError = (documentId, error, errorCode, errorDetails) => ({\n type: SET_DOCUMENT_ERROR,\n payload: { documentId, error, errorCode, errorDetails }\n});\nconst retryLoadingDocument = (documentId, passwordProvided) => ({\n type: RETRY_LOADING_DOCUMENT,\n payload: { documentId, passwordProvided }\n});\nconst closeDocument = (documentId, nextActiveDocumentId) => ({\n type: CLOSE_DOCUMENT,\n payload: { documentId, nextActiveDocumentId }\n});\nconst setActiveDocument = (documentId) => ({\n type: SET_ACTIVE_DOCUMENT,\n payload: documentId\n});\nconst refreshDocument = (documentId, document) => ({\n type: REFRESH_DOCUMENT,\n payload: { documentId, document }\n});\nconst refreshPages = (documentId, pageIndexes) => ({\n type: REFRESH_PAGES,\n payload: { documentId, pageIndexes }\n});\nconst setPages = (documentId, pages) => ({\n type: SET_PAGES,\n payload: { documentId, pages }\n});\nconst setScale = (scale, documentId) => ({\n type: SET_SCALE,\n payload: { scale, documentId }\n});\nconst setRotation = (rotation, documentId) => ({\n type: SET_ROTATION,\n payload: { rotation, documentId }\n});\nconst setDefaultScale = (scale) => ({\n type: SET_DEFAULT_SCALE,\n payload: scale\n});\nconst setDefaultRotation = (rotation) => ({\n type: SET_DEFAULT_ROTATION,\n payload: rotation\n});\nconst reorderDocuments = (order) => ({\n type: REORDER_DOCUMENTS,\n payload: order\n});\nconst moveDocument = (documentId, toIndex) => ({\n type: MOVE_DOCUMENT,\n payload: { documentId, toIndex }\n});\nconst updateDocumentSecurity = (documentId, permissions, isOwnerUnlocked) => ({\n type: UPDATE_DOCUMENT_SECURITY,\n payload: { documentId, permissions, isOwnerUnlocked }\n});\nclass Store {\n /**\n * Initializes the store with the provided core state.\n * @param reducer The core reducer function\n * @param initialCoreState The initial core state\n */\n constructor(reducer, initialCoreState2) {\n this.initialCoreState = initialCoreState2;\n this.pluginReducers = {};\n this.listeners = [];\n this.pluginListeners = {};\n this.isDispatching = false;\n this.state = { core: initialCoreState2, plugins: {} };\n this.coreReducer = reducer;\n }\n /**\n * Adds a reducer for a plugin-specific state.\n * @param pluginId The unique identifier for the plugin.\n * @param reducer The reducer function for the plugin state.\n * @param initialState The initial state for the plugin.\n */\n addPluginReducer(pluginId, reducer, initialState) {\n this.state.plugins[pluginId] = initialState;\n this.pluginReducers[pluginId] = reducer;\n }\n /**\n * Dispatches an action *only* to the core reducer.\n * Notifies the global store listeners with (action, newState, oldState).\n *\n * @param action The action to dispatch, typed as CoreAction\n * @returns The updated *global* store state\n */\n dispatchToCore(action) {\n if (!this.coreReducer) {\n return this.getState();\n }\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldState = this.getState();\n try {\n this.isDispatching = true;\n this.state.core = this.coreReducer(this.state.core, action);\n } finally {\n this.isDispatching = false;\n }\n this.listeners.forEach((listener) => {\n const currentState = this.getState();\n listener(action, currentState, oldState);\n });\n return this.getState();\n }\n /**\n * Dispatches an action *only* to a specific plugin.\n * Optionally notifies global store listeners if `notifyGlobal` is true.\n * Always notifies plugin-specific listeners with (action, newPluginState, oldPluginState).\n *\n * @param pluginId The plugin identifier\n * @param action The plugin action to dispatch\n * @param notifyGlobal Whether to also notify global store listeners\n * @returns The updated plugin state\n */\n dispatchToPlugin(pluginId, action, notifyGlobal = true) {\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldGlobalState = this.getState();\n const reducer = this.pluginReducers[pluginId];\n if (!reducer) {\n return oldGlobalState.plugins[pluginId];\n }\n const oldPluginState = oldGlobalState.plugins[pluginId];\n try {\n this.isDispatching = true;\n const newPluginState = reducer(oldPluginState, action);\n this.state.plugins[pluginId] = newPluginState;\n } finally {\n this.isDispatching = false;\n }\n if (notifyGlobal) {\n this.listeners.forEach((listener) => {\n const currentGlobalState = this.getState();\n listener(action, currentGlobalState, oldGlobalState);\n });\n }\n if (this.pluginListeners[pluginId]) {\n this.pluginListeners[pluginId].forEach((listener) => {\n const currentPluginState = this.getState().plugins[pluginId];\n listener(action, currentPluginState, oldPluginState);\n });\n }\n return this.getState().plugins[pluginId];\n }\n /**\n * Dispatches an action to update the state using:\n * - the core reducer (if it's a CoreAction)\n * - *all* plugin reducers (regardless of action type), with no global notify for each plugin\n *\n * Returns the new *global* store state after all reducers have processed the action.\n *\n * @param action The action to dispatch (can be CoreAction or any Action).\n */\n dispatch(action) {\n if (this.isDispatching) {\n throw new Error(\n \"Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.\"\n );\n }\n const oldState = this.getState();\n try {\n this.isDispatching = true;\n if (this.isCoreAction(action)) {\n this.state.core = this.coreReducer(this.state.core, action);\n }\n for (const pluginId in this.pluginReducers) {\n const reducer = this.pluginReducers[pluginId];\n const oldPluginState = oldState.plugins[pluginId];\n if (reducer) {\n this.state.plugins[pluginId] = reducer(oldPluginState, action);\n }\n }\n } finally {\n this.isDispatching = false;\n }\n this.listeners.forEach((listener) => {\n const currentState = this.getState();\n listener(action, currentState, oldState);\n });\n return this.getState();\n }\n /**\n * Returns a shallow copy of the current state.\n * @returns The current store state.\n */\n getState() {\n if (this.isDispatching) {\n throw new Error(\n \"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.\"\n );\n }\n return {\n core: { ...this.state.core },\n plugins: { ...this.state.plugins }\n };\n }\n /**\n * Subscribes a listener to *global* state changes.\n * The callback signature is now (action, newState, oldState).\n *\n * @param listener The callback to invoke on state changes\n * @returns A function to unsubscribe the listener\n */\n subscribe(listener) {\n if (this.isDispatching) {\n throw new Error(\n \"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state.\"\n );\n }\n this.listeners.push(listener);\n return () => {\n if (this.isDispatching) {\n throw new Error(\n \"You may not unsubscribe from a store listener while the reducer is executing.\"\n );\n }\n this.listeners = this.listeners.filter((l) => l !== listener);\n };\n }\n /**\n * Subscribes a listener to *plugin-specific* state changes.\n * The callback signature is now (action, newPluginState, oldPluginState).\n *\n * @param pluginId The unique identifier for the plugin.\n * @param listener The callback to invoke on plugin state changes.\n * @returns A function to unsubscribe the listener.\n */\n subscribeToPlugin(pluginId, listener) {\n if (!(pluginId in this.state.plugins)) {\n throw new Error(\n `Plugin state not found for plugin \"${pluginId}\". Did you forget to call addPluginReducer?`\n );\n }\n if (this.isDispatching) {\n throw new Error(\"You may not call store.subscribeToPlugin() while the reducer is executing.\");\n }\n if (!this.pluginListeners[pluginId]) {\n this.pluginListeners[pluginId] = [];\n }\n this.pluginListeners[pluginId].push(listener);\n return () => {\n if (this.isDispatching) {\n throw new Error(\n \"You may not unsubscribe from a store listener while the reducer is executing.\"\n );\n }\n this.pluginListeners[pluginId] = this.pluginListeners[pluginId].filter((l) => l !== listener);\n if (this.pluginListeners[pluginId].length === 0) {\n delete this.pluginListeners[pluginId];\n }\n };\n }\n /**\n * Subscribes to a specific action type (only from the core's action union).\n * The callback signature is (action, newState, oldState).\n *\n * @param type The action type to listen for.\n * @param handler The callback to invoke when the action occurs.\n * @returns A function to unsubscribe the handler.\n */\n onAction(type, handler) {\n return this.subscribe((action, newState, oldState) => {\n if (action.type === type) {\n handler(action, newState, oldState);\n }\n });\n }\n /**\n * Gets a PluginStore handle for a specific plugin.\n * @param pluginId The unique identifier for the plugin.\n * @returns A PluginStore instance for the plugin.\n */\n getPluginStore(pluginId) {\n if (!(pluginId in this.state.plugins)) {\n throw new Error(\n `Plugin state not found for plugin \"${pluginId}\". Did you forget to call addPluginReducer?`\n );\n }\n return new PluginStore(this, pluginId);\n }\n /**\n * Helper method to check if an action is a CoreAction.\n * Adjust if you have a more refined way to differentiate CoreAction vs. any other Action.\n */\n isCoreAction(action) {\n return CORE_ACTION_TYPES.includes(action.type);\n }\n /**\n * Destroy the store: drop every listener and plugin reducer\n */\n destroy() {\n var _a, _b;\n this.listeners.length = 0;\n for (const id in this.pluginListeners) {\n (_b = (_a = this.pluginListeners[id]) == null ? void 0 : _a.splice) == null ? void 0 : _b.call(_a, 0);\n }\n this.pluginListeners = {};\n this.pluginReducers = {};\n this.state.plugins = {};\n this.state.core = { ...this.initialCoreState };\n }\n}\nconst initialCoreState = (config) => ({\n documents: {},\n documentOrder: [],\n activeDocumentId: null,\n defaultScale: (config == null ? void 0 : config.defaultScale) ?? 1,\n defaultRotation: (config == null ? void 0 : config.defaultRotation) ?? Rotation.Degree0,\n globalPermissions: config == null ? void 0 : config.permissions\n});\nconst PERMISSION_NAME_TO_FLAG = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality\n};\nconst ALL_PERMISSION_FLAGS = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality\n];\nconst ALL_PERMISSION_NAMES = [\n \"print\",\n \"modifyContents\",\n \"copyContents\",\n \"modifyAnnotations\",\n \"fillForms\",\n \"extractForAccessibility\",\n \"assembleDocument\",\n \"printHighQuality\"\n];\nconst PERMISSION_FLAG_TO_NAME = {\n [PdfPermissionFlag.Print]: \"print\",\n [PdfPermissionFlag.ModifyContents]: \"modifyContents\",\n [PdfPermissionFlag.CopyContents]: \"copyContents\",\n [PdfPermissionFlag.ModifyAnnotations]: \"modifyAnnotations\",\n [PdfPermissionFlag.FillForms]: \"fillForms\",\n [PdfPermissionFlag.ExtractForAccessibility]: \"extractForAccessibility\",\n [PdfPermissionFlag.AssembleDocument]: \"assembleDocument\",\n [PdfPermissionFlag.PrintHighQuality]: \"printHighQuality\"\n};\nfunction getPermissionOverride(overrides, flag) {\n if (!overrides) return void 0;\n if (flag in overrides) {\n return overrides[flag];\n }\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return overrides[name];\n }\n return void 0;\n}\nconst getActiveDocumentState = (state) => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\nconst getDocumentState = (state, documentId) => {\n return state.documents[documentId] ?? null;\n};\nconst getDocumentIds = (state) => {\n return Object.keys(state.documents);\n};\nconst isDocumentLoaded = (state, documentId) => {\n return !!state.documents[documentId];\n};\nconst getDocumentCount = (state) => {\n return Object.keys(state.documents).length;\n};\nfunction getEffectivePermission(state, documentId, flag) {\n var _a;\n const docState = state.documents[documentId];\n const docConfig = docState == null ? void 0 : docState.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = ((_a = docState == null ? void 0 : docState.document) == null ? void 0 : _a.permissions) ?? PdfPermissionFlag.AllowAll;\n const docOverride = getPermissionOverride(docConfig == null ? void 0 : docConfig.overrides, flag);\n if (docOverride !== void 0) {\n return docOverride;\n }\n const globalOverride = getPermissionOverride(globalConfig == null ? void 0 : globalConfig.overrides, flag);\n if (globalOverride !== void 0) {\n return globalOverride;\n }\n const enforce = (docConfig == null ? void 0 : docConfig.enforceDocumentPermissions) ?? (globalConfig == null ? void 0 : globalConfig.enforceDocumentPermissions) ?? true;\n if (!enforce) return true;\n return (pdfPermissions & flag) !== 0;\n}\nfunction getEffectivePermissions(state, documentId) {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\nfunction calculateNextActiveDocument(state, closingDocumentId, explicitNext) {\n const currentActiveId = state.activeDocumentId;\n if (currentActiveId !== closingDocumentId) {\n return currentActiveId;\n }\n if (explicitNext !== void 0) {\n return explicitNext && state.documents[explicitNext] ? explicitNext : null;\n }\n const closingIndex = state.documentOrder.indexOf(closingDocumentId);\n if (closingIndex === -1) {\n return null;\n }\n if (closingIndex > 0) {\n return state.documentOrder[closingIndex - 1];\n }\n if (closingIndex < state.documentOrder.length - 1) {\n return state.documentOrder[closingIndex + 1];\n }\n return null;\n}\nfunction moveDocumentInOrder(currentOrder, documentId, toIndex) {\n const fromIndex = currentOrder.indexOf(documentId);\n if (fromIndex === -1) return null;\n if (toIndex < 0 || toIndex >= currentOrder.length) return null;\n if (fromIndex === toIndex) return null;\n const newOrder = [...currentOrder];\n newOrder.splice(fromIndex, 1);\n newOrder.splice(toIndex, 0, documentId);\n return newOrder;\n}\nconst coreReducer = (state, action) => {\n switch (action.type) {\n case START_LOADING_DOCUMENT: {\n const {\n documentId,\n name,\n scale,\n rotation,\n passwordProvided,\n autoActivate = true,\n permissions\n } = action.payload;\n const newDocState = {\n id: documentId,\n name,\n status: \"loading\",\n loadingProgress: 0,\n error: null,\n document: null,\n scale: scale ?? state.defaultScale,\n rotation: rotation ?? state.defaultRotation,\n passwordProvided: passwordProvided ?? false,\n pageRefreshVersions: {},\n permissions,\n loadStartedAt: Date.now()\n };\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: newDocState\n },\n documentOrder: [...state.documentOrder, documentId],\n // Only activate if autoActivate is true (default), or if no document is currently active\n activeDocumentId: autoActivate || !state.activeDocumentId ? documentId : state.activeDocumentId\n };\n }\n case UPDATE_DOCUMENT_LOADING_PROGRESS: {\n const { documentId, progress } = action.payload;\n const docState = state.documents[documentId];\n if (!docState || docState.status !== \"loading\") return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n loadingProgress: progress\n }\n }\n };\n }\n case SET_DOCUMENT_LOADED: {\n const { documentId, document } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"loaded\",\n document,\n error: null,\n errorCode: void 0,\n errorDetails: void 0,\n passwordProvided: void 0,\n loadedAt: Date.now()\n }\n }\n };\n }\n case SET_DOCUMENT_ERROR: {\n const { documentId, error, errorCode, errorDetails } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"error\",\n error,\n errorCode,\n errorDetails\n }\n }\n };\n }\n case RETRY_LOADING_DOCUMENT: {\n const { documentId, passwordProvided } = action.payload;\n const docState = state.documents[documentId];\n if (!docState || docState.status !== \"error\") return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n status: \"loading\",\n loadingProgress: 0,\n error: null,\n errorCode: void 0,\n errorDetails: void 0,\n passwordProvided: passwordProvided ?? false,\n loadStartedAt: Date.now()\n }\n }\n };\n }\n case CLOSE_DOCUMENT: {\n const { documentId, nextActiveDocumentId } = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n documentOrder: state.documentOrder.filter((id) => id !== documentId),\n activeDocumentId: calculateNextActiveDocument(state, documentId, nextActiveDocumentId)\n };\n }\n case MOVE_DOCUMENT: {\n const { documentId, toIndex } = action.payload;\n const newOrder = moveDocumentInOrder(state.documentOrder, documentId, toIndex);\n if (!newOrder) return state;\n return {\n ...state,\n documentOrder: newOrder\n };\n }\n case REORDER_DOCUMENTS: {\n return {\n ...state,\n documentOrder: action.payload\n };\n }\n case SET_ACTIVE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload\n };\n }\n case SET_SCALE: {\n const { scale, documentId } = action.payload;\n const targetId = documentId ?? state.activeDocumentId;\n if (!targetId) return state;\n const docState = state.documents[targetId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [targetId]: {\n ...docState,\n scale\n }\n }\n };\n }\n case SET_ROTATION: {\n const { rotation, documentId } = action.payload;\n const targetId = documentId ?? state.activeDocumentId;\n if (!targetId) return state;\n const docState = state.documents[targetId];\n if (!docState) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [targetId]: {\n ...docState,\n rotation\n }\n }\n };\n }\n case REFRESH_PAGES: {\n const { documentId, pageIndexes } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n const newVersions = { ...docState.pageRefreshVersions };\n for (const pageIndex of pageIndexes) {\n newVersions[pageIndex] = (newVersions[pageIndex] || 0) + 1;\n }\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pageRefreshVersions: newVersions\n }\n }\n };\n }\n case UPDATE_DOCUMENT_SECURITY: {\n const { documentId, permissions, isOwnerUnlocked } = action.payload;\n const docState = state.documents[documentId];\n if (!(docState == null ? void 0 : docState.document)) return state;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n document: {\n ...docState.document,\n permissions,\n isOwnerUnlocked\n }\n }\n }\n };\n }\n default:\n return state;\n }\n};\nclass PluginRegistry {\n constructor(engine, config) {\n this.plugins = /* @__PURE__ */ new Map();\n this.manifests = /* @__PURE__ */ new Map();\n this.capabilities = /* @__PURE__ */ new Map();\n this.status = /* @__PURE__ */ new Map();\n this.configurations = /* @__PURE__ */ new Map();\n this.initPromise = null;\n this.pendingRegistrations = [];\n this.processingRegistrations = [];\n this.initialized = false;\n this.isInitializing = false;\n this.pluginsReadyPromise = null;\n this.destroyed = false;\n this.resolver = new DependencyResolver();\n this.engine = engine;\n this.initialCoreState = initialCoreState(config);\n this.store = new Store(coreReducer, this.initialCoreState);\n this.logger = (config == null ? void 0 : config.logger) ?? new NoopLogger();\n }\n /**\n * Get the logger instance\n */\n getLogger() {\n return this.logger;\n }\n /**\n * Register a plugin without initializing it\n */\n registerPlugin(pluginPackage, config) {\n if (this.initialized && !this.isInitializing) {\n throw new PluginRegistrationError(\"Cannot register plugins after initialization\");\n }\n this.validateManifest(pluginPackage.manifest);\n this.store.addPluginReducer(\n pluginPackage.manifest.id,\n // We need one type assertion here since we can't fully reconcile TAction with Action\n // due to TypeScript's type system limitations with generic variance\n pluginPackage.reducer,\n \"function\" === typeof pluginPackage.initialState ? pluginPackage.initialState(\n this.initialCoreState,\n {\n ...pluginPackage.manifest.defaultConfig,\n ...config\n }\n ) : pluginPackage.initialState\n );\n this.pendingRegistrations.push({\n package: pluginPackage,\n config\n });\n }\n /**\n * Get the central store instance\n */\n getStore() {\n return this.store;\n }\n /**\n * Get the engine instance\n */\n getEngine() {\n return this.engine;\n }\n /**\n * Get a promise that resolves when all plugins are ready\n */\n pluginsReady() {\n if (this.pluginsReadyPromise) {\n return this.pluginsReadyPromise;\n }\n this.pluginsReadyPromise = (async () => {\n if (!this.initialized) {\n await this.initialize();\n }\n const readyPromises = Array.from(this.plugins.values()).map(\n (p) => typeof p.ready === \"function\" ? p.ready() : Promise.resolve()\n );\n await Promise.all(readyPromises);\n })();\n return this.pluginsReadyPromise;\n }\n /**\n * INITIALISE THE REGISTRY – runs once no-matter-how-many calls *\n */\n async initialize() {\n if (this.destroyed) {\n throw new PluginRegistrationError(\"Registry has been destroyed\");\n }\n if (this.initPromise) {\n return this.initPromise;\n }\n this.initPromise = (async () => {\n if (this.initialized) {\n throw new PluginRegistrationError(\"Registry is already initialized\");\n }\n this.isInitializing = true;\n try {\n if (this.destroyed) return;\n while (this.pendingRegistrations.length > 0) {\n if (this.destroyed) return;\n this.processingRegistrations = [...this.pendingRegistrations];\n this.pendingRegistrations = [];\n for (const reg of this.processingRegistrations) {\n const dependsOn = /* @__PURE__ */ new Set();\n const allDeps = [...reg.package.manifest.requires, ...reg.package.manifest.optional];\n for (const cap of allDeps) {\n const provider = this.processingRegistrations.find(\n (r) => r.package.manifest.provides.includes(cap)\n );\n if (provider) {\n dependsOn.add(provider.package.manifest.id);\n }\n }\n this.resolver.addNode(reg.package.manifest.id, [...dependsOn]);\n }\n const loadOrder = this.resolver.resolveLoadOrder();\n for (const id of loadOrder) {\n const reg = this.processingRegistrations.find((r) => r.package.manifest.id === id);\n this.instantiatePlugin(reg.package.manifest, reg.package.create, reg.config);\n }\n for (const id of loadOrder) {\n await this.runPluginInitialization(id);\n }\n this.processingRegistrations = [];\n this.resolver = new DependencyResolver();\n }\n this.initialized = true;\n } catch (err) {\n if (err instanceof Error) {\n throw new CircularDependencyError(\n `Failed to resolve plugin dependencies: ${err.message}`\n );\n }\n throw err;\n } finally {\n this.isInitializing = false;\n }\n })();\n return this.initPromise;\n }\n /**\n * Phase 2: Create instance and register capabilities\n */\n instantiatePlugin(manifest, packageCreator, config) {\n const finalConfig = {\n ...manifest.defaultConfig,\n ...config\n };\n this.validateConfig(manifest.id, finalConfig, manifest.defaultConfig);\n const plugin = packageCreator(this, finalConfig);\n this.validatePlugin(plugin);\n for (const capability of manifest.provides) {\n if (this.capabilities.has(capability)) {\n throw new PluginRegistrationError(\n `Capability ${capability} is already provided by plugin ${this.capabilities.get(capability)}`\n );\n }\n this.capabilities.set(capability, manifest.id);\n }\n this.plugins.set(manifest.id, plugin);\n this.manifests.set(manifest.id, manifest);\n this.status.set(manifest.id, \"registered\");\n this.configurations.set(manifest.id, finalConfig);\n }\n /**\n * Phase 3: Run the initialize method\n */\n async runPluginInitialization(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) return;\n const manifest = this.manifests.get(pluginId);\n const config = this.configurations.get(pluginId);\n for (const capability of manifest.requires) {\n if (!this.capabilities.has(capability)) {\n throw new PluginRegistrationError(\n `Missing required capability: ${capability} for plugin ${pluginId}`\n );\n }\n }\n this.logger.debug(\"PluginRegistry\", \"InitializePlugin\", `Initializing plugin ${pluginId}`);\n try {\n if (plugin.initialize) {\n await plugin.initialize(config);\n }\n this.status.set(pluginId, \"active\");\n this.logger.info(\n \"PluginRegistry\",\n \"PluginInitialized\",\n `Plugin ${pluginId} initialized successfully`\n );\n } catch (error) {\n this.status.set(pluginId, \"error\");\n this.logger.error(\n \"PluginRegistry\",\n \"InitializationFailed\",\n `Plugin ${pluginId} initialization failed`,\n { error }\n );\n throw error;\n }\n }\n getPluginConfig(pluginId) {\n const config = this.configurations.get(pluginId);\n if (!config) {\n throw new PluginNotFoundError(`Configuration for plugin ${pluginId} not found`);\n }\n return config;\n }\n validateConfig(pluginId, config, defaultConfig) {\n const requiredKeys = Object.keys(defaultConfig);\n const missingKeys = requiredKeys.filter((key) => !config.hasOwnProperty(key));\n if (missingKeys.length > 0) {\n throw new PluginConfigurationError(\n `Missing required configuration keys for plugin ${pluginId}: ${missingKeys.join(\", \")}`\n );\n }\n }\n async updatePluginConfig(pluginId, config) {\n const plugin = this.getPlugin(pluginId);\n if (!plugin) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n const manifest = this.manifests.get(pluginId);\n const currentConfig = this.configurations.get(pluginId);\n if (!manifest || !currentConfig) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n const newConfig = {\n ...currentConfig,\n ...config\n };\n this.validateConfig(pluginId, newConfig, manifest.defaultConfig);\n this.configurations.set(pluginId, newConfig);\n if (plugin.initialize) {\n await plugin.initialize(newConfig);\n }\n }\n /**\n * Register multiple plugins at once\n */\n registerPluginBatch(registrations) {\n for (const reg of registrations) {\n this.registerPlugin(reg.package, reg.config);\n }\n }\n /**\n * Unregister a plugin\n */\n async unregisterPlugin(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) {\n throw new PluginNotFoundError(`Plugin ${pluginId} is not registered`);\n }\n const manifest = this.manifests.get(pluginId);\n if (!manifest) {\n throw new PluginNotFoundError(`Manifest for plugin ${pluginId} not found`);\n }\n for (const [otherId, otherManifest] of this.manifests.entries()) {\n if (otherId === pluginId) continue;\n const dependsOnThis = [...otherManifest.requires, ...otherManifest.optional].some(\n (cap) => manifest.provides.includes(cap)\n );\n if (dependsOnThis) {\n throw new PluginRegistrationError(\n `Cannot unregister plugin ${pluginId}: plugin ${otherId} depends on it`\n );\n }\n }\n try {\n if (plugin.destroy) {\n await plugin.destroy();\n }\n for (const capability of manifest.provides) {\n this.capabilities.delete(capability);\n }\n this.plugins.delete(pluginId);\n this.manifests.delete(pluginId);\n this.status.delete(pluginId);\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to unregister plugin ${pluginId}: ${error.message}`);\n }\n throw error;\n }\n }\n /**\n * Get a plugin instance\n * @param pluginId The ID of the plugin to get\n * @returns The plugin instance or null if not found\n */\n getPlugin(pluginId) {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) {\n return null;\n }\n return plugin;\n }\n /**\n * Get a plugin that provides a specific capability\n * @param capability The capability to get a provider for\n * @returns The plugin providing the capability or null if not found\n */\n getCapabilityProvider(capability) {\n const pluginId = this.capabilities.get(capability);\n if (!pluginId) {\n return null;\n }\n return this.getPlugin(pluginId);\n }\n /**\n * Check if a capability is available\n */\n hasCapability(capability) {\n return this.capabilities.has(capability);\n }\n /**\n * Get all registered plugins\n */\n getAllPlugins() {\n return Array.from(this.plugins.values());\n }\n /**\n * Get plugin status\n */\n getPluginStatus(pluginId) {\n const status = this.status.get(pluginId);\n if (!status) {\n throw new PluginNotFoundError(`Plugin ${pluginId} not found`);\n }\n return status;\n }\n /**\n * Validate plugin object\n */\n validatePlugin(plugin) {\n if (!plugin.id) {\n throw new PluginRegistrationError(\"Plugin must have an id\");\n }\n }\n /**\n * Validate plugin manifest\n */\n validateManifest(manifest) {\n if (!manifest.id) {\n throw new PluginRegistrationError(\"Manifest must have an id\");\n }\n if (!manifest.name) {\n throw new PluginRegistrationError(\"Manifest must have a name\");\n }\n if (!manifest.version) {\n throw new PluginRegistrationError(\"Manifest must have a version\");\n }\n if (!Array.isArray(manifest.provides)) {\n throw new PluginRegistrationError(\"Manifest must have a provides array\");\n }\n if (!Array.isArray(manifest.requires)) {\n throw new PluginRegistrationError(\"Manifest must have a requires array\");\n }\n if (!Array.isArray(manifest.optional)) {\n throw new PluginRegistrationError(\"Manifest must have an optional array\");\n }\n }\n isDestroyed() {\n return this.destroyed;\n }\n /**\n * DESTROY EVERYTHING – waits for any ongoing initialise(), once *\n */\n async destroy() {\n var _a;\n if (this.destroyed) throw new PluginRegistrationError(\"Registry has already been destroyed\");\n this.destroyed = true;\n try {\n await this.initPromise;\n } catch {\n }\n for (const plugin of Array.from(this.plugins.values()).reverse()) {\n await ((_a = plugin.destroy) == null ? void 0 : _a.call(plugin));\n }\n this.store.destroy();\n this.plugins.clear();\n this.manifests.clear();\n this.capabilities.clear();\n this.status.clear();\n this.pendingRegistrations.length = 0;\n this.processingRegistrations.length = 0;\n }\n}\nfunction createPluginRegistration(pluginPackage, config) {\n return {\n package: pluginPackage,\n config\n };\n}\nfunction hasAutoMountElements(pkg) {\n return \"autoMountElements\" in pkg && typeof pkg.autoMountElements === \"function\";\n}\nclass BasePlugin {\n constructor(id, registry) {\n this.id = id;\n this.registry = registry;\n this.cooldownActions = {};\n this.debouncedTimeouts = {};\n this.unsubscribeFromState = null;\n this.unsubscribeFromCoreStore = null;\n this.unsubscribeFromStartLoadingDocument = null;\n this.unsubscribeFromSetDocumentLoaded = null;\n this.unsubscribeFromCloseDocument = null;\n this.unsubscribeFromSetScale = null;\n this.unsubscribeFromSetRotation = null;\n if (id !== this.constructor.id) {\n throw new Error(\n `Plugin ID mismatch: ${id} !== ${this.constructor.id}`\n );\n }\n this.engine = this.registry.getEngine();\n this.logger = this.registry.getLogger();\n this.coreStore = this.registry.getStore();\n this.pluginStore = this.coreStore.getPluginStore(this.id);\n this.unsubscribeFromState = this.pluginStore.subscribeToState((action, newState, oldState) => {\n this.onStoreUpdated(oldState, newState);\n });\n this.unsubscribeFromCoreStore = this.coreStore.subscribe((action, newState, oldState) => {\n this.onCoreStoreUpdated(oldState, newState);\n if (newState.core.activeDocumentId !== oldState.core.activeDocumentId) {\n this.onActiveDocumentChanged(\n oldState.core.activeDocumentId,\n newState.core.activeDocumentId\n );\n }\n });\n this.unsubscribeFromStartLoadingDocument = this.coreStore.onAction(\n START_LOADING_DOCUMENT,\n (action) => {\n this.onDocumentLoadingStarted(action.payload.documentId);\n }\n );\n this.unsubscribeFromSetDocumentLoaded = this.coreStore.onAction(\n SET_DOCUMENT_LOADED,\n (action) => {\n this.onDocumentLoaded(action.payload.documentId);\n }\n );\n this.unsubscribeFromCloseDocument = this.coreStore.onAction(CLOSE_DOCUMENT, (action) => {\n this.onDocumentClosed(action.payload.documentId);\n });\n this.unsubscribeFromSetScale = this.coreStore.onAction(SET_SCALE, (action, state) => {\n const targetId = action.payload.documentId ?? state.core.activeDocumentId;\n if (targetId) {\n this.onScaleChanged(targetId, action.payload.scale);\n }\n });\n this.unsubscribeFromSetRotation = this.coreStore.onAction(SET_ROTATION, (action, state) => {\n const targetId = action.payload.documentId ?? state.core.activeDocumentId;\n if (targetId) {\n this.onRotationChanged(targetId, action.payload.rotation);\n }\n });\n this.readyPromise = new Promise((resolve) => {\n this.readyResolve = resolve;\n });\n this.readyResolve();\n }\n provides() {\n if (!this._capability) {\n const cap = this.buildCapability();\n this._capability = Object.freeze(cap);\n }\n return this._capability;\n }\n /**\n * Get a copy of the current state\n */\n get state() {\n return this.pluginStore.getState();\n }\n /**\n * Get a copy of the current core state\n */\n get coreState() {\n return this.coreStore.getState();\n }\n /**\n * @deprecated use `this.state` Get a copy of the current state\n */\n getState() {\n return this.pluginStore.getState();\n }\n /**\n * @deprecated use `this.coreState` Get a copy of the current core state\n */\n getCoreState() {\n return this.coreStore.getState();\n }\n /**\n * Core Dispatch\n */\n dispatchCoreAction(action) {\n return this.coreStore.dispatchToCore(action);\n }\n /**\n * Dispatch an action to all plugins\n */\n dispatchToAllPlugins(action) {\n return this.coreStore.dispatch(action);\n }\n /**\n * Dispatch an action\n */\n dispatch(action) {\n return this.pluginStore.dispatch(action);\n }\n /**\n * Dispatch an action with a cooldown to prevent rapid repeated calls\n * This executes immediately if cooldown has expired, then blocks subsequent calls\n * @param action The action to dispatch\n * @param cooldownTime Time in ms for cooldown (default: 100ms)\n * @returns boolean indicating whether the action was dispatched or blocked\n */\n cooldownDispatch(action, cooldownTime = 100) {\n const now = Date.now();\n const lastActionTime = this.cooldownActions[action.type] || 0;\n if (now - lastActionTime >= cooldownTime) {\n this.cooldownActions[action.type] = now;\n this.dispatch(action);\n return true;\n }\n return false;\n }\n /**\n * Dispatch an action with true debouncing - waits for the delay after the last call\n * Each new call resets the timer. Action only executes after no calls for the specified time.\n * @param action The action to dispatch\n * @param debounceTime Time in ms to wait after the last call\n */\n debouncedDispatch(action, debounceTime = 100) {\n const actionKey = action.type;\n if (this.debouncedTimeouts[actionKey]) {\n clearTimeout(this.debouncedTimeouts[actionKey]);\n }\n this.debouncedTimeouts[actionKey] = setTimeout(() => {\n this.dispatch(action);\n delete this.debouncedTimeouts[actionKey];\n }, debounceTime);\n }\n /**\n * Cancel a pending debounced action\n * @param actionType The action type to cancel\n */\n cancelDebouncedDispatch(actionType) {\n if (this.debouncedTimeouts[actionType]) {\n clearTimeout(this.debouncedTimeouts[actionType]);\n delete this.debouncedTimeouts[actionType];\n }\n }\n /**\n * Subscribe to state changes\n */\n subscribe(listener) {\n return this.pluginStore.subscribeToState(listener);\n }\n /**\n * Subscribe to core store changes\n */\n subscribeToCoreStore(listener) {\n return this.coreStore.subscribe(listener);\n }\n /**\n * Called when the plugin store state is updated\n * @param oldState Previous state\n * @param newState New state\n */\n onStoreUpdated(oldState, newState) {\n }\n /**\n * Called when the core store state is updated\n * @param oldState Previous state\n * @param newState New state\n */\n onCoreStoreUpdated(oldState, newState) {\n }\n /**\n * Called when a document is opened\n * Override to initialize per-document state\n * @param documentId The ID of the document that was opened\n */\n onDocumentLoadingStarted(documentId) {\n }\n /**\n * Called when a document is loaded\n * @param documentId The ID of the document that is loaded\n */\n onDocumentLoaded(documentId) {\n }\n /**\n * Called when a document is closed\n * Override to cleanup per-document state\n * @param documentId The ID of the document that was closed\n */\n onDocumentClosed(documentId) {\n }\n /**\n * Called when the active document changes\n * @param previousId The ID of the previous active document\n * @param currentId The ID of the new active document\n */\n onActiveDocumentChanged(previousId, currentId) {\n }\n onScaleChanged(documentId, scale) {\n }\n onRotationChanged(documentId, rotation) {\n }\n /**\n * Cleanup method to be called when plugin is being destroyed\n */\n destroy() {\n Object.values(this.debouncedTimeouts).forEach((timeout) => {\n clearTimeout(timeout);\n });\n this.debouncedTimeouts = {};\n if (this.unsubscribeFromState) {\n this.unsubscribeFromState();\n this.unsubscribeFromState = null;\n }\n if (this.unsubscribeFromCoreStore) {\n this.unsubscribeFromCoreStore();\n this.unsubscribeFromCoreStore = null;\n }\n if (this.unsubscribeFromStartLoadingDocument) {\n this.unsubscribeFromStartLoadingDocument();\n this.unsubscribeFromStartLoadingDocument = null;\n }\n if (this.unsubscribeFromSetDocumentLoaded) {\n this.unsubscribeFromSetDocumentLoaded();\n this.unsubscribeFromSetDocumentLoaded = null;\n }\n if (this.unsubscribeFromCloseDocument) {\n this.unsubscribeFromCloseDocument();\n this.unsubscribeFromCloseDocument = null;\n }\n if (this.unsubscribeFromSetScale) {\n this.unsubscribeFromSetScale();\n this.unsubscribeFromSetScale = null;\n }\n if (this.unsubscribeFromSetRotation) {\n this.unsubscribeFromSetRotation();\n this.unsubscribeFromSetRotation = null;\n }\n }\n /**\n * Returns a promise that resolves when the plugin is ready\n */\n ready() {\n return this.readyPromise;\n }\n /**\n * Mark the plugin as ready\n */\n markReady() {\n this.readyResolve();\n }\n /**\n * Reset the ready state (useful for plugins that need to reinitialize)\n */\n resetReady() {\n this.readyPromise = new Promise((resolve) => {\n this.readyResolve = resolve;\n });\n }\n /**\n * Get the active document ID\n * @throws Error if no active document exists\n */\n getActiveDocumentId() {\n const id = this.coreState.core.activeDocumentId;\n if (!id) {\n throw new Error(\"No active document\");\n }\n return id;\n }\n /**\n * Get the active document ID or null if none exists\n */\n getActiveDocumentIdOrNull() {\n return this.coreState.core.activeDocumentId;\n }\n /**\n * Get core document state for a specific document\n * @param documentId Document ID (optional, defaults to active document)\n * @returns Document state or null if not found\n */\n getCoreDocument(documentId) {\n const id = documentId ?? this.getActiveDocumentIdOrNull();\n if (!id) return null;\n return this.coreState.core.documents[id] ?? null;\n }\n /**\n * Get core document state for a specific document\n * @param documentId Document ID (optional, defaults to active document)\n * @throws Error if document not found\n */\n getCoreDocumentOrThrow(documentId) {\n const doc = this.getCoreDocument(documentId);\n if (!doc) {\n throw new Error(`Document not found: ${documentId ?? \"active\"}`);\n }\n return doc;\n }\n // ─────────────────────────────────────────────────────────\n // Permission Helpers\n // ─────────────────────────────────────────────────────────\n /**\n * Get the effective permission flags for a document.\n * Applies layered resolution: per-document override → global override → PDF permission.\n * Returns AllowAll if document not found.\n * @param documentId Document ID (optional, defaults to active document)\n */\n getDocumentPermissions(documentId) {\n const docId = documentId ?? this.coreState.core.activeDocumentId;\n if (!docId) return PdfPermissionFlag.AllowAll;\n return getEffectivePermissions(this.coreState.core, docId);\n }\n /**\n * Check if a document has the required permissions (returns boolean).\n * Applies layered resolution: per-document override → global override → PDF permission.\n * Useful for conditional UI logic.\n * @param documentId Document ID (optional, defaults to active document)\n * @param flags Permission flags to check\n */\n checkPermission(documentId, ...flags) {\n const docId = documentId ?? this.coreState.core.activeDocumentId;\n if (!docId) return true;\n return flags.every((flag) => getEffectivePermission(this.coreState.core, docId, flag));\n }\n /**\n * Assert that a document has the required permissions.\n * Applies layered resolution: per-document override → global override → PDF permission.\n * Throws PermissionDeniedError if any flag is missing.\n * @param documentId Document ID (optional, defaults to active document)\n * @param flags Permission flags to require\n */\n requirePermission(documentId, ...flags) {\n const docId = documentId ?? this.coreState.core.activeDocumentId;\n if (!docId) return;\n const missingFlags = [];\n for (const flag of flags) {\n if (!getEffectivePermission(this.coreState.core, docId, flag)) {\n missingFlags.push(flag);\n }\n }\n if (missingFlags.length > 0) {\n const effectivePermissions = getEffectivePermissions(this.coreState.core, docId);\n throw new PermissionDeniedError(missingFlags, effectivePermissions);\n }\n }\n}\nclass EventControl {\n constructor(handler, options) {\n this.handler = handler;\n this.options = options;\n this.lastRun = 0;\n this.handle = (data) => {\n if (this.options.mode === \"debounce\") {\n this.debounce(data);\n } else {\n this.throttle(data);\n }\n };\n }\n debounce(data) {\n if (this.timeoutId) {\n window.clearTimeout(this.timeoutId);\n }\n this.timeoutId = window.setTimeout(() => {\n this.handler(data);\n this.timeoutId = void 0;\n }, this.options.wait);\n }\n throttle(data) {\n if (this.options.mode === \"debounce\") return;\n const now = Date.now();\n const throttleMode = this.options.throttleMode || \"leading-trailing\";\n if (now - this.lastRun >= this.options.wait) {\n if (throttleMode === \"leading-trailing\") {\n this.handler(data);\n }\n this.lastRun = now;\n }\n if (this.timeoutId) {\n window.clearTimeout(this.timeoutId);\n }\n this.timeoutId = window.setTimeout(\n () => {\n this.handler(data);\n this.lastRun = Date.now();\n this.timeoutId = void 0;\n },\n this.options.wait - (now - this.lastRun)\n );\n }\n destroy() {\n if (this.timeoutId) {\n window.clearTimeout(this.timeoutId);\n }\n }\n}\nclass KeyedEventControl {\n constructor(handler, options) {\n this.handler = handler;\n this.options = options;\n this.controls = /* @__PURE__ */ new Map();\n this.handle = (data) => {\n const key = String(this.options.keyExtractor(data));\n let control = this.controls.get(key);\n if (!control) {\n control = new EventControl(this.handler, this.baseOptions);\n this.controls.set(key, control);\n }\n control.handle(data);\n };\n this.baseOptions = {\n mode: options.mode,\n wait: options.wait,\n ...options.mode === \"throttle\" && \"throttleMode\" in options ? { throttleMode: options.throttleMode } : {}\n };\n }\n destroy() {\n for (const control of this.controls.values()) {\n control.destroy();\n }\n this.controls.clear();\n }\n}\nfunction isKeyedOptions(options) {\n return \"keyExtractor\" in options;\n}\nfunction clamp(value, min, max) {\n return value < min ? min : value > max ? max : value;\n}\nfunction arePropsEqual(a, b, visited) {\n if (a === b) {\n return true;\n }\n if (a == null || b == null) {\n return a === b;\n }\n const aType = typeof a;\n const bType = typeof b;\n if (aType !== bType) return false;\n if (aType === \"object\") {\n if (!visited) visited = /* @__PURE__ */ new Set();\n const pairId = getPairId(a, b);\n if (visited.has(pairId)) {\n return true;\n }\n visited.add(pairId);\n const aIsArray = Array.isArray(a);\n const bIsArray = Array.isArray(b);\n if (aIsArray && bIsArray) {\n return arraysEqualUnordered(a, b, visited);\n } else if (!aIsArray && !bIsArray) {\n return objectsEqual(a, b, visited);\n } else {\n return false;\n }\n }\n return false;\n}\nfunction getPairId(a, b) {\n return `${objectId(a)}__${objectId(b)}`;\n}\nlet objectIdCounter = 0;\nconst objectIds = /* @__PURE__ */ new WeakMap();\nfunction objectId(obj) {\n if (!objectIds.has(obj)) {\n objectIds.set(obj, ++objectIdCounter);\n }\n return objectIds.get(obj);\n}\nfunction arraysEqualUnordered(a, b, visited) {\n if (a.length !== b.length) return false;\n const used = new Array(b.length).fill(false);\n outer: for (let i = 0; i < a.length; i++) {\n const elemA = a[i];\n for (let j = 0; j < b.length; j++) {\n if (used[j]) continue;\n if (arePropsEqual(elemA, b[j], visited)) {\n used[j] = true;\n continue outer;\n }\n }\n return false;\n }\n return true;\n}\nfunction objectsEqual(a, b, visited) {\n const aKeys = Object.keys(a).sort();\n const bKeys = Object.keys(b).sort();\n if (aKeys.length !== bKeys.length) return false;\n for (let i = 0; i < aKeys.length; i++) {\n if (aKeys[i] !== bKeys[i]) return false;\n }\n for (const key of aKeys) {\n const valA = a[key];\n const valB = b[key];\n if (!arePropsEqual(valA, valB, visited)) {\n return false;\n }\n }\n return true;\n}\nfunction createEmitter() {\n const listeners = /* @__PURE__ */ new Set();\n const on = (l) => {\n listeners.add(l);\n return () => listeners.delete(l);\n };\n return {\n emit: (v = void 0) => listeners.forEach((l) => l(v)),\n on,\n off: (l) => listeners.delete(l),\n clear: () => listeners.clear()\n };\n}\nfunction createBehaviorEmitter(initial, equality = arePropsEqual) {\n const listeners = /* @__PURE__ */ new Set();\n const proxyMap = /* @__PURE__ */ new Map();\n let _value = initial;\n const notify = (v) => listeners.forEach((l) => l(v));\n const baseOn = (listener, options) => {\n let realListener = listener;\n let destroy = () => {\n };\n if (options) {\n if (isKeyedOptions(options)) {\n const ctl = new KeyedEventControl(listener, options);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n } else {\n const ctl = new EventControl(listener, options);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n }\n proxyMap.set(listener, { wrapped: realListener, destroy });\n }\n if (_value !== void 0) realListener(_value);\n listeners.add(realListener);\n return () => {\n listeners.delete(realListener);\n destroy();\n proxyMap.delete(listener);\n };\n };\n return {\n /* emitter behaviour ---------------------------------------- */\n get value() {\n return _value;\n },\n emit(v = void 0) {\n if (_value === void 0 || !equality(_value, v)) {\n _value = v;\n notify(v);\n }\n },\n on: baseOn,\n off(listener) {\n const proxy = proxyMap.get(listener);\n if (proxy) {\n listeners.delete(proxy.wrapped);\n proxy.destroy();\n proxyMap.delete(listener);\n } else {\n listeners.delete(listener);\n }\n },\n clear() {\n listeners.clear();\n proxyMap.forEach((p) => p.destroy());\n proxyMap.clear();\n },\n /* derived hook --------------------------------------------- */\n select(selector, eq = arePropsEqual) {\n return (listener, options) => {\n let prev;\n if (_value !== void 0) {\n const mapped = selector(_value);\n prev = mapped;\n listener(mapped);\n }\n return baseOn(\n (next) => {\n const mapped = selector(next);\n if (prev === void 0 || !eq(prev, mapped)) {\n prev = mapped;\n listener(mapped);\n }\n },\n options\n );\n };\n }\n };\n}\nfunction createScopedEmitter(toGlobalEvent, options) {\n const shouldCache = (options == null ? void 0 : options.cache) ?? true;\n const equality = (options == null ? void 0 : options.equality) ?? arePropsEqual;\n const scopeCaches = /* @__PURE__ */ new Map();\n const scopeListeners = /* @__PURE__ */ new Map();\n const scopeProxyMaps = /* @__PURE__ */ new Map();\n const globalListeners = /* @__PURE__ */ new Set();\n const globalProxyMap = /* @__PURE__ */ new Map();\n const normalizeKey = (key) => String(key);\n const getOrCreateListeners = (key) => {\n let listeners = scopeListeners.get(key);\n if (!listeners) {\n listeners = /* @__PURE__ */ new Set();\n scopeListeners.set(key, listeners);\n }\n return listeners;\n };\n const getOrCreateProxyMap = (key) => {\n let proxyMap = scopeProxyMaps.get(key);\n if (!proxyMap) {\n proxyMap = /* @__PURE__ */ new Map();\n scopeProxyMaps.set(key, proxyMap);\n }\n return proxyMap;\n };\n const onGlobal = (listener, options2) => {\n let realListener = listener;\n let destroy = () => {\n };\n if (options2) {\n if (isKeyedOptions(options2)) {\n const ctl = new KeyedEventControl(listener, options2);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n } else {\n const ctl = new EventControl(listener, options2);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n }\n globalProxyMap.set(listener, { wrapped: realListener, destroy });\n }\n globalListeners.add(realListener);\n return () => {\n globalListeners.delete(realListener);\n destroy();\n globalProxyMap.delete(listener);\n };\n };\n return {\n emit(key, data) {\n const normalizedKey = normalizeKey(key);\n if (shouldCache) {\n const cached = scopeCaches.get(normalizedKey);\n if (cached !== void 0 && equality(cached, data)) {\n return;\n }\n scopeCaches.set(normalizedKey, data);\n }\n const listeners = scopeListeners.get(normalizedKey);\n if (listeners) {\n listeners.forEach((l) => l(data));\n }\n const globalEvent = toGlobalEvent(key, data);\n globalListeners.forEach((l) => l(globalEvent));\n },\n forScope(key) {\n const normalizedKey = normalizeKey(key);\n return (listener, options2) => {\n const listeners = getOrCreateListeners(normalizedKey);\n const proxyMap = getOrCreateProxyMap(normalizedKey);\n let realListener = listener;\n let destroy = () => {\n };\n if (options2) {\n if (isKeyedOptions(options2)) {\n const ctl = new KeyedEventControl(listener, options2);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n } else {\n const ctl = new EventControl(listener, options2);\n realListener = ctl.handle;\n destroy = () => ctl.destroy();\n }\n proxyMap.set(listener, { wrapped: realListener, destroy });\n }\n if (shouldCache) {\n const cached = scopeCaches.get(normalizedKey);\n if (cached !== void 0) {\n realListener(cached);\n }\n }\n listeners.add(realListener);\n return () => {\n listeners.delete(realListener);\n destroy();\n proxyMap.delete(listener);\n if (listeners.size === 0) {\n scopeListeners.delete(normalizedKey);\n }\n if (proxyMap.size === 0) {\n scopeProxyMaps.delete(normalizedKey);\n }\n };\n };\n },\n onGlobal,\n getValue(key) {\n return shouldCache ? scopeCaches.get(normalizeKey(key)) : void 0;\n },\n getScopes() {\n if (shouldCache) {\n return Array.from(scopeCaches.keys());\n }\n return Array.from(scopeListeners.keys());\n },\n clearScope(key) {\n const normalizedKey = normalizeKey(key);\n if (shouldCache) {\n scopeCaches.delete(normalizedKey);\n }\n const listeners = scopeListeners.get(normalizedKey);\n if (listeners) {\n listeners.clear();\n scopeListeners.delete(normalizedKey);\n }\n const proxyMap = scopeProxyMaps.get(normalizedKey);\n if (proxyMap) {\n proxyMap.forEach((p) => p.destroy());\n proxyMap.clear();\n scopeProxyMaps.delete(normalizedKey);\n }\n },\n clear() {\n if (shouldCache) {\n scopeCaches.clear();\n }\n scopeListeners.forEach((set) => set.clear());\n scopeListeners.clear();\n scopeProxyMaps.forEach((map) => {\n map.forEach((p) => p.destroy());\n map.clear();\n });\n scopeProxyMaps.clear();\n globalListeners.clear();\n globalProxyMap.forEach((p) => p.destroy());\n globalProxyMap.clear();\n }\n };\n}\nfunction enumEntries(record) {\n return Object.entries(record).map(([k, v]) => {\n const maybeNum = Number(k);\n const typedKey = Number.isFinite(maybeNum) && k.trim() !== \"\" ? maybeNum : k;\n return [typedKey, v];\n });\n}\nclass PluginPackageBuilder {\n constructor(basePackage) {\n this.autoMountElements = [];\n this.package = basePackage;\n }\n addUtility(component) {\n this.autoMountElements.push({ component, type: \"utility\" });\n return this;\n }\n addWrapper(component) {\n this.autoMountElements.push({ component, type: \"wrapper\" });\n return this;\n }\n build() {\n return {\n ...this.package,\n autoMountElements: () => this.autoMountElements\n };\n }\n}\nfunction createPluginPackage(basePackage) {\n return new PluginPackageBuilder(basePackage);\n}\nexport {\n ALL_PERMISSION_FLAGS,\n ALL_PERMISSION_NAMES,\n BasePlugin,\n CLOSE_DOCUMENT,\n CORE_ACTION_TYPES,\n CapabilityConflictError,\n CapabilityNotFoundError,\n CircularDependencyError,\n DependencyResolver,\n EventControl,\n KeyedEventControl,\n MOVE_DOCUMENT,\n PERMISSION_FLAG_TO_NAME,\n PERMISSION_NAME_TO_FLAG,\n PluginConfigurationError,\n PluginInitializationError,\n PluginNotFoundError,\n PluginPackageBuilder,\n PluginRegistrationError,\n PluginRegistry,\n REFRESH_DOCUMENT,\n REFRESH_PAGES,\n REORDER_DOCUMENTS,\n RETRY_LOADING_DOCUMENT,\n SET_ACTIVE_DOCUMENT,\n SET_DEFAULT_ROTATION,\n SET_DEFAULT_SCALE,\n SET_DOCUMENT_ERROR,\n SET_DOCUMENT_LOADED,\n SET_PAGES,\n SET_ROTATION,\n SET_SCALE,\n START_LOADING_DOCUMENT,\n UPDATE_DOCUMENT_LOADING_PROGRESS,\n UPDATE_DOCUMENT_SECURITY,\n arePropsEqual,\n clamp,\n closeDocument,\n createBehaviorEmitter,\n createEmitter,\n createPluginPackage,\n createPluginRegistration,\n createScopedEmitter,\n enumEntries,\n getActiveDocumentState,\n getDocumentCount,\n getDocumentIds,\n getDocumentState,\n getEffectivePermission,\n getEffectivePermissions,\n getPermissionOverride,\n hasAutoMountElements,\n initialCoreState,\n isDocumentLoaded,\n isKeyedOptions,\n moveDocument,\n refreshDocument,\n refreshPages,\n reorderDocuments,\n retryLoadingDocument,\n setActiveDocument,\n setDefaultRotation,\n setDefaultScale,\n setDocumentError,\n setDocumentLoaded,\n setPages,\n setRotation,\n setScale,\n startLoadingDocument,\n updateDocumentLoadingProgress,\n updateDocumentSecurity\n};\n//# sourceMappingURL=index.js.map\n","var Rotation = /* @__PURE__ */ ((Rotation2) => {\n Rotation2[Rotation2[\"Degree0\"] = 0] = \"Degree0\";\n Rotation2[Rotation2[\"Degree90\"] = 1] = \"Degree90\";\n Rotation2[Rotation2[\"Degree180\"] = 2] = \"Degree180\";\n Rotation2[Rotation2[\"Degree270\"] = 3] = \"Degree270\";\n return Rotation2;\n})(Rotation || {});\nfunction toIntPos(p) {\n return { x: Math.floor(p.x), y: Math.floor(p.y) };\n}\nfunction toIntSize(s) {\n return { width: Math.ceil(s.width), height: Math.ceil(s.height) };\n}\nfunction toIntRect(r) {\n return {\n origin: toIntPos(r.origin),\n size: toIntSize(r.size)\n };\n}\nfunction calculateDegree(rotation) {\n switch (rotation) {\n case 0:\n return 0;\n case 1:\n return 90;\n case 2:\n return 180;\n case 3:\n return 270;\n }\n}\nfunction calculateAngle(rotation) {\n return calculateDegree(rotation) * Math.PI / 180;\n}\nfunction swap(size) {\n const { width, height } = size;\n return {\n width: height,\n height: width\n };\n}\nfunction transformSize(size, rotation, scaleFactor) {\n size = rotation % 2 === 0 ? size : swap(size);\n return {\n width: size.width * scaleFactor,\n height: size.height * scaleFactor\n };\n}\nfunction quadToRect(q) {\n const xs = [q.p1.x, q.p2.x, q.p3.x, q.p4.x];\n const ys = [q.p1.y, q.p2.y, q.p3.y, q.p4.y];\n return {\n origin: { x: Math.min(...xs), y: Math.min(...ys) },\n size: {\n width: Math.max(...xs) - Math.min(...xs),\n height: Math.max(...ys) - Math.min(...ys)\n }\n };\n}\nfunction rectToQuad(r) {\n return {\n p1: { x: r.origin.x, y: r.origin.y },\n p2: { x: r.origin.x + r.size.width, y: r.origin.y },\n p3: { x: r.origin.x + r.size.width, y: r.origin.y + r.size.height },\n p4: { x: r.origin.x, y: r.origin.y + r.size.height }\n };\n}\nfunction rotatePosition(containerSize, position, rotation) {\n let x = position.x;\n let y = position.y;\n switch (rotation) {\n case 0:\n x = position.x;\n y = position.y;\n break;\n case 1:\n x = containerSize.height - position.y;\n y = position.x;\n break;\n case 2:\n x = containerSize.width - position.x;\n y = containerSize.height - position.y;\n break;\n case 3:\n x = position.y;\n y = containerSize.width - position.x;\n break;\n }\n return {\n x,\n y\n };\n}\nfunction scalePosition(position, scaleFactor) {\n return {\n x: position.x * scaleFactor,\n y: position.y * scaleFactor\n };\n}\nfunction transformPosition(containerSize, position, rotation, scaleFactor) {\n return scalePosition(rotatePosition(containerSize, position, rotation), scaleFactor);\n}\nfunction restorePosition(containerSize, position, rotation, scaleFactor) {\n return scalePosition(\n rotatePosition(containerSize, position, (4 - rotation) % 4),\n 1 / scaleFactor\n );\n}\nfunction rectEquals(a, b) {\n return a.origin.x === b.origin.x && a.origin.y === b.origin.y && a.size.width === b.size.width && a.size.height === b.size.height;\n}\nfunction rectFromPoints(positions) {\n if (positions.length === 0) {\n return { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };\n }\n const xs = positions.map((p) => p.x);\n const ys = positions.map((p) => p.y);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n return {\n origin: { x: minX, y: minY },\n size: {\n width: Math.max(...xs) - minX,\n height: Math.max(...ys) - minY\n }\n };\n}\nfunction rotateAndTranslatePoint(pos, angleRad, translate) {\n const cos = Math.cos(angleRad);\n const sin = Math.sin(angleRad);\n const newX = pos.x * cos - pos.y * sin;\n const newY = pos.x * sin + pos.y * cos;\n return {\n x: newX + translate.x,\n y: newY + translate.y\n };\n}\nfunction expandRect(rect, padding) {\n return {\n origin: { x: rect.origin.x - padding, y: rect.origin.y - padding },\n size: { width: rect.size.width + padding * 2, height: rect.size.height + padding * 2 }\n };\n}\nfunction rotateRect(containerSize, rect, rotation) {\n let x = rect.origin.x;\n let y = rect.origin.y;\n let size = rect.size;\n switch (rotation) {\n case 0:\n break;\n case 1:\n x = containerSize.height - rect.origin.y - rect.size.height;\n y = rect.origin.x;\n size = swap(rect.size);\n break;\n case 2:\n x = containerSize.width - rect.origin.x - rect.size.width;\n y = containerSize.height - rect.origin.y - rect.size.height;\n break;\n case 3:\n x = rect.origin.y;\n y = containerSize.width - rect.origin.x - rect.size.width;\n size = swap(rect.size);\n break;\n }\n return {\n origin: {\n x,\n y\n },\n size: {\n width: size.width,\n height: size.height\n }\n };\n}\nfunction scaleRect(rect, scaleFactor) {\n return {\n origin: {\n x: rect.origin.x * scaleFactor,\n y: rect.origin.y * scaleFactor\n },\n size: {\n width: rect.size.width * scaleFactor,\n height: rect.size.height * scaleFactor\n }\n };\n}\nfunction transformRect(containerSize, rect, rotation, scaleFactor) {\n return scaleRect(rotateRect(containerSize, rect, rotation), scaleFactor);\n}\nfunction restoreRect(containerSize, rect, rotation, scaleFactor) {\n return scaleRect(rotateRect(containerSize, rect, (4 - rotation) % 4), 1 / scaleFactor);\n}\nfunction restoreOffset(offset, rotation, scaleFactor) {\n let offsetX = offset.x;\n let offsetY = offset.y;\n switch (rotation) {\n case 0:\n offsetX = offset.x / scaleFactor;\n offsetY = offset.y / scaleFactor;\n break;\n case 1:\n offsetX = offset.y / scaleFactor;\n offsetY = -offset.x / scaleFactor;\n break;\n case 2:\n offsetX = -offset.x / scaleFactor;\n offsetY = -offset.y / scaleFactor;\n break;\n case 3:\n offsetX = -offset.y / scaleFactor;\n offsetY = offset.x / scaleFactor;\n break;\n }\n return {\n x: offsetX,\n y: offsetY\n };\n}\nconst EMPTY_RECT = { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };\nfunction boundingRect(rects) {\n if (rects.length === 0) return null;\n let minX = rects[0].origin.x, minY = rects[0].origin.y, maxX = rects[0].origin.x + rects[0].size.width, maxY = rects[0].origin.y + rects[0].size.height;\n for (const r of rects) {\n minX = Math.min(minX, r.origin.x);\n minY = Math.min(minY, r.origin.y);\n maxX = Math.max(maxX, r.origin.x + r.size.width);\n maxY = Math.max(maxY, r.origin.y + r.size.height);\n }\n return {\n origin: {\n x: minX,\n y: minY\n },\n size: {\n width: maxX - minX,\n height: maxY - minY\n }\n };\n}\nfunction boundingRectOrEmpty(rects) {\n return boundingRect(rects) ?? EMPTY_RECT;\n}\nfunction normalizeAngle(degrees) {\n const normalized = degrees % 360;\n return normalized < 0 ? normalized + 360 : normalized;\n}\nfunction getRectCenter(rect) {\n return {\n x: rect.origin.x + rect.size.width / 2,\n y: rect.origin.y + rect.size.height / 2\n };\n}\nfunction rotatePointAround(point, center, angleDegrees) {\n const angleRad = angleDegrees * Math.PI / 180;\n const cos = Math.cos(angleRad);\n const sin = Math.sin(angleRad);\n const dx = point.x - center.x;\n const dy = point.y - center.y;\n return {\n x: center.x + dx * cos - dy * sin,\n y: center.y + dx * sin + dy * cos\n };\n}\nfunction rotateVertices(points, center, angleDegrees) {\n return points.map((v) => rotatePointAround(v, center, angleDegrees));\n}\nfunction calculateRotatedRectAABBAroundPoint(rect, angleDegrees, center) {\n const corners = [\n { x: rect.origin.x, y: rect.origin.y },\n { x: rect.origin.x + rect.size.width, y: rect.origin.y },\n { x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height },\n { x: rect.origin.x, y: rect.origin.y + rect.size.height }\n ];\n const rotated = rotateVertices(corners, center, angleDegrees);\n return rectFromPoints(rotated);\n}\nfunction calculateRotatedRectAABB(unrotatedRect, angleDegrees) {\n return calculateRotatedRectAABBAroundPoint(\n unrotatedRect,\n angleDegrees,\n getRectCenter(unrotatedRect)\n );\n}\nfunction inferRotationCenterFromRects(unrotatedRect, rotatedAabb, angleDegrees) {\n const angleRad = angleDegrees * Math.PI / 180;\n const cos = Math.cos(angleRad);\n const sin = Math.sin(angleRad);\n const m00 = 1 - cos;\n const m01 = sin;\n const m10 = -sin;\n const m11 = 1 - cos;\n const det = m00 * m11 - m01 * m10;\n const unrotatedCenter = getRectCenter(unrotatedRect);\n if (Math.abs(det) < 1e-10) return unrotatedCenter;\n const rotatedCenter = getRectCenter(rotatedAabb);\n const rhsX = rotatedCenter.x - (cos * unrotatedCenter.x - sin * unrotatedCenter.y);\n const rhsY = rotatedCenter.y - (sin * unrotatedCenter.x + cos * unrotatedCenter.y);\n return {\n x: (m11 * rhsX - m01 * rhsY) / det,\n y: (-m10 * rhsX + m00 * rhsY) / det\n };\n}\nfunction buildUserToDeviceMatrix(rect, rotation, outW, outH) {\n const L = rect.origin.x;\n const B = rect.origin.y;\n const W = rect.size.width;\n const H = rect.size.height;\n const sx0 = outW / W;\n const sy0 = outH / H;\n const sx90 = outW / H;\n const sy90 = outH / W;\n switch (rotation) {\n case 0:\n return { a: sx0, b: 0, c: 0, d: sy0, e: -sx0 * L, f: -sy0 * B };\n case 3:\n return { a: 0, b: -sy90, c: sx90, d: 0, e: -sx90 * B, f: sy90 * (L + W) };\n case 2:\n return { a: -sx0, b: 0, c: 0, d: -sy0, e: sx0 * (L + W), f: sy0 * (B + H) };\n case 1:\n return { a: 0, b: sy90, c: -sx90, d: 0, e: sx90 * (B + H), f: -sy90 * L };\n }\n}\nclass NoopLogger {\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled() {\n return false;\n }\n /** {@inheritDoc Logger.debug} */\n debug() {\n }\n /** {@inheritDoc Logger.info} */\n info() {\n }\n /** {@inheritDoc Logger.warn} */\n warn() {\n }\n /** {@inheritDoc Logger.error} */\n error() {\n }\n /** {@inheritDoc Logger.perf} */\n perf() {\n }\n}\nclass ConsoleLogger {\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled() {\n return true;\n }\n /** {@inheritDoc Logger.debug} */\n debug(source, category, ...args) {\n console.debug(`${source}.${category}`, ...args);\n }\n /** {@inheritDoc Logger.info} */\n info(source, category, ...args) {\n console.info(`${source}.${category}`, ...args);\n }\n /** {@inheritDoc Logger.warn} */\n warn(source, category, ...args) {\n console.warn(`${source}.${category}`, ...args);\n }\n /** {@inheritDoc Logger.error} */\n error(source, category, ...args) {\n console.error(`${source}.${category}`, ...args);\n }\n /** {@inheritDoc Logger.perf} */\n perf(source, category, event, phase, ...args) {\n console.info(`${source}.${category}.${event}.${phase}`, ...args);\n }\n}\nvar LogLevel = /* @__PURE__ */ ((LogLevel2) => {\n LogLevel2[LogLevel2[\"Debug\"] = 0] = \"Debug\";\n LogLevel2[LogLevel2[\"Info\"] = 1] = \"Info\";\n LogLevel2[LogLevel2[\"Warn\"] = 2] = \"Warn\";\n LogLevel2[LogLevel2[\"Error\"] = 3] = \"Error\";\n return LogLevel2;\n})(LogLevel || {});\nclass LevelLogger {\n /**\n * create new LevelLogger\n * @param logger - the original logger\n * @param level - log level that used for filtering, all logs lower than this level will be filtered out\n */\n constructor(logger, level) {\n this.logger = logger;\n this.level = level;\n }\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled(level) {\n const levelMap = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3\n /* Error */\n };\n return this.level <= levelMap[level];\n }\n /** {@inheritDoc Logger.debug} */\n debug(source, category, ...args) {\n if (this.level <= 0) {\n this.logger.debug(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.info} */\n info(source, category, ...args) {\n if (this.level <= 1) {\n this.logger.info(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.warn} */\n warn(source, category, ...args) {\n if (this.level <= 2) {\n this.logger.warn(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.error} */\n error(source, category, ...args) {\n if (this.level <= 3) {\n this.logger.error(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.perf} */\n perf(source, category, event, phase, ...args) {\n this.logger.perf(source, category, event, phase, ...args);\n }\n}\nclass PerfLogger {\n /**\n * create new PerfLogger\n */\n constructor() {\n this.marks = /* @__PURE__ */ new Map();\n }\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled() {\n return false;\n }\n /** {@inheritDoc Logger.debug} */\n debug(source, category, ...args) {\n }\n /** {@inheritDoc Logger.info} */\n info(source, category, ...args) {\n }\n /** {@inheritDoc Logger.warn} */\n warn(source, category, ...args) {\n }\n /** {@inheritDoc Logger.error} */\n error(source, category, ...args) {\n }\n /** {@inheritDoc Logger.perf} */\n perf(source, category, event, phase, identifier, ...args) {\n const markName = `${source}.${category}.${event}.${phase}.${identifier}`;\n switch (phase) {\n case \"Begin\":\n globalThis.performance.mark(markName, { detail: args });\n this.marks.set(`${source}.${category}.${event}.${identifier}`, Date.now());\n break;\n case \"End\":\n globalThis.performance.mark(markName, { detail: args });\n const measureName = `${source}.${category}.${event}.Measure.${identifier}`;\n const beginMark = `${source}.${category}.${event}.Begin.${identifier}`;\n globalThis.performance.measure(measureName, beginMark, markName);\n const startTime = this.marks.get(`${source}.${category}.${event}.${identifier}`);\n if (startTime) {\n const duration = Date.now() - startTime;\n console.info(`⏱️ ${source}.${category}.${event}.${identifier}: ${duration}ms`);\n this.marks.delete(`${source}.${category}.${event}.${identifier}`);\n }\n break;\n }\n }\n}\nclass AllLogger {\n /**\n * create new PerfLogger\n */\n constructor(loggers) {\n this.loggers = loggers;\n }\n /** {@inheritDoc Logger.isEnabled} */\n isEnabled(level) {\n return this.loggers.some((logger) => logger.isEnabled(level));\n }\n /** {@inheritDoc Logger.debug} */\n debug(source, category, ...args) {\n for (const logger of this.loggers) {\n logger.debug(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.info} */\n info(source, category, ...args) {\n for (const logger of this.loggers) {\n logger.info(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.warn} */\n warn(source, category, ...args) {\n for (const logger of this.loggers) {\n logger.warn(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.error} */\n error(source, category, ...args) {\n for (const logger of this.loggers) {\n logger.error(source, category, ...args);\n }\n }\n /** {@inheritDoc Logger.perf} */\n perf(source, category, event, phase, ...args) {\n for (const logger of this.loggers) {\n logger.perf(source, category, event, phase, ...args);\n }\n }\n}\nvar TaskStage = /* @__PURE__ */ ((TaskStage2) => {\n TaskStage2[TaskStage2[\"Pending\"] = 0] = \"Pending\";\n TaskStage2[TaskStage2[\"Resolved\"] = 1] = \"Resolved\";\n TaskStage2[TaskStage2[\"Rejected\"] = 2] = \"Rejected\";\n TaskStage2[TaskStage2[\"Aborted\"] = 3] = \"Aborted\";\n return TaskStage2;\n})(TaskStage || {});\nclass TaskAbortedError extends Error {\n constructor(reason) {\n super(`Task aborted: ${JSON.stringify(reason)}`);\n this.name = \"TaskAbortedError\";\n this.reason = reason;\n }\n}\nclass TaskRejectedError extends Error {\n constructor(reason) {\n super(`Task rejected: ${JSON.stringify(reason)}`);\n this.name = \"TaskRejectedError\";\n this.reason = reason;\n }\n}\nclass Task {\n constructor() {\n this.state = {\n stage: 0\n /* Pending */\n };\n this.resolvedCallbacks = [];\n this.rejectedCallbacks = [];\n this._promise = null;\n this.progressCbs = [];\n }\n /**\n * Convert task to promise\n * @returns promise that will be resolved when task is settled\n */\n toPromise() {\n if (!this._promise) {\n this._promise = new Promise((resolve, reject) => {\n this.wait(\n (result) => resolve(result),\n (error) => {\n if (error.type === \"abort\") {\n reject(new TaskAbortedError(error.reason));\n } else {\n reject(new TaskRejectedError(error.reason));\n }\n }\n );\n });\n }\n return this._promise;\n }\n /**\n * wait for task to be settled\n * @param resolvedCallback - callback for resolved value\n * @param rejectedCallback - callback for rejected value\n */\n wait(resolvedCallback, rejectedCallback) {\n switch (this.state.stage) {\n case 0:\n this.resolvedCallbacks.push(resolvedCallback);\n this.rejectedCallbacks.push(rejectedCallback);\n break;\n case 1:\n resolvedCallback(this.state.result);\n break;\n case 2:\n rejectedCallback({\n type: \"reject\",\n reason: this.state.reason\n });\n break;\n case 3:\n rejectedCallback({\n type: \"abort\",\n reason: this.state.reason\n });\n break;\n }\n }\n /**\n * resolve task with specific result\n * @param result - result value\n */\n resolve(result) {\n if (this.state.stage === 0) {\n this.state = {\n stage: 1,\n result\n };\n for (const resolvedCallback of this.resolvedCallbacks) {\n try {\n resolvedCallback(result);\n } catch (e) {\n }\n }\n this.resolvedCallbacks = [];\n this.rejectedCallbacks = [];\n }\n }\n /**\n * reject task with specific reason\n * @param reason - abort reason\n *\n */\n reject(reason) {\n if (this.state.stage === 0) {\n this.state = {\n stage: 2,\n reason\n };\n for (const rejectedCallback of this.rejectedCallbacks) {\n try {\n rejectedCallback({\n type: \"reject\",\n reason\n });\n } catch (e) {\n }\n }\n this.resolvedCallbacks = [];\n this.rejectedCallbacks = [];\n }\n }\n /**\n * abort task with specific reason\n * @param reason - abort reason\n */\n abort(reason) {\n if (this.state.stage === 0) {\n this.state = {\n stage: 3,\n reason\n };\n for (const rejectedCallback of this.rejectedCallbacks) {\n try {\n rejectedCallback({\n type: \"abort\",\n reason\n });\n } catch (e) {\n }\n }\n this.resolvedCallbacks = [];\n this.rejectedCallbacks = [];\n }\n }\n /**\n * fail task with a TaskError from another task\n * This is a convenience method for error propagation between tasks\n * @param error - TaskError from another task\n */\n fail(error) {\n if (error.type === \"abort\") {\n this.abort(error.reason);\n } else {\n this.reject(error.reason);\n }\n }\n /**\n * Transform the result of this task using a mapping function.\n * Returns a new Task that resolves with the mapped value.\n *\n * Aborting the derived task also aborts the source task, and source errors\n * are forwarded to the derived task directly (bypassing `errMap`).\n *\n * Note: progress events from the source task are **not** forwarded\n * to the derived task.\n *\n * @param fn - mapping function that transforms the source result\n * @param errMap - maps errors from `fn` (sync throws or rejected promises)\n * into the error type `D`. Source task errors are forwarded as-is.\n * @returns a new Task that resolves with the mapped result\n */\n map(fn, errMap) {\n const derived = new Task();\n const origAbort = derived.abort.bind(derived);\n derived.abort = (reason) => {\n this.abort(reason);\n origAbort(reason);\n };\n this.wait(\n (result) => {\n if (derived.state.stage !== 0) return;\n try {\n const mapped = fn(result);\n if (mapped instanceof Promise) {\n mapped.then(\n (value) => {\n if (derived.state.stage === 0) {\n derived.resolve(value);\n }\n },\n (err) => {\n if (derived.state.stage === 0) {\n derived.reject(errMap(err));\n }\n }\n );\n } else {\n derived.resolve(mapped);\n }\n } catch (err) {\n if (derived.state.stage === 0) {\n derived.reject(errMap(err));\n }\n }\n },\n (error) => {\n if (derived.state.stage === 0) {\n derived.fail(error);\n }\n }\n );\n return derived;\n }\n /**\n * add a progress callback\n * @param cb - progress callback\n */\n onProgress(cb) {\n this.progressCbs.push(cb);\n }\n /**\n * call progress callback\n * @param p - progress value\n */\n progress(p) {\n for (const cb of this.progressCbs) cb(p);\n }\n /**\n * Static method to wait for all tasks to resolve\n * Returns a new task that resolves with an array of all results\n * Rejects immediately if any task fails\n *\n * @param tasks - array of tasks to wait for\n * @returns new task that resolves when all input tasks resolve\n * @public\n */\n static all(tasks) {\n const combinedTask = new Task();\n if (tasks.length === 0) {\n combinedTask.resolve([]);\n return combinedTask;\n }\n const results = new Array(tasks.length);\n let resolvedCount = 0;\n let isSettled = false;\n tasks.forEach((task, index) => {\n task.wait(\n (result) => {\n if (isSettled) return;\n results[index] = result;\n resolvedCount++;\n if (resolvedCount === tasks.length) {\n isSettled = true;\n combinedTask.resolve(results);\n }\n },\n (error) => {\n if (isSettled) return;\n isSettled = true;\n if (error.type === \"abort\") {\n combinedTask.abort(error.reason);\n } else {\n combinedTask.reject(error.reason);\n }\n }\n );\n });\n return combinedTask;\n }\n /**\n * Static method to wait for all tasks to settle (resolve, reject, or abort)\n * Always resolves with an array of settlement results\n *\n * @param tasks - array of tasks to wait for\n * @returns new task that resolves when all input tasks settle\n * @public\n */\n static allSettled(tasks) {\n const combinedTask = new Task();\n if (tasks.length === 0) {\n combinedTask.resolve([]);\n return combinedTask;\n }\n const results = new Array(tasks.length);\n let settledCount = 0;\n tasks.forEach((task, index) => {\n task.wait(\n (result) => {\n results[index] = { status: \"resolved\", value: result };\n settledCount++;\n if (settledCount === tasks.length) {\n combinedTask.resolve(results);\n }\n },\n (error) => {\n results[index] = {\n status: error.type === \"abort\" ? \"aborted\" : \"rejected\",\n reason: error.reason\n };\n settledCount++;\n if (settledCount === tasks.length) {\n combinedTask.resolve(results);\n }\n }\n );\n });\n return combinedTask;\n }\n /**\n * Static method that resolves/rejects with the first task that settles\n *\n * @param tasks - array of tasks to race\n * @returns new task that settles with the first input task that settles\n * @public\n */\n static race(tasks) {\n const combinedTask = new Task();\n if (tasks.length === 0) {\n combinedTask.reject(\"No tasks provided\");\n return combinedTask;\n }\n let isSettled = false;\n tasks.forEach((task) => {\n task.wait(\n (result) => {\n if (isSettled) return;\n isSettled = true;\n combinedTask.resolve(result);\n },\n (error) => {\n if (isSettled) return;\n isSettled = true;\n if (error.type === \"abort\") {\n combinedTask.abort(error.reason);\n } else {\n combinedTask.reject(error.reason);\n }\n }\n );\n });\n return combinedTask;\n }\n /**\n * Utility to track progress of multiple tasks\n *\n * @param tasks - array of tasks to track\n * @param onProgress - callback called when any task completes\n * @returns new task that resolves when all input tasks resolve\n * @public\n */\n static withProgress(tasks, onProgress) {\n const combinedTask = Task.all(tasks);\n if (onProgress) {\n let completedCount = 0;\n tasks.forEach((task) => {\n task.wait(\n () => {\n completedCount++;\n onProgress(completedCount, tasks.length);\n },\n () => {\n completedCount++;\n onProgress(completedCount, tasks.length);\n }\n );\n });\n }\n return combinedTask;\n }\n}\nconst PdfSoftHyphenMarker = \"­\";\nconst PdfZeroWidthSpace = \"​\";\nconst PdfWordJoiner = \"⁠\";\nconst PdfBomOrZwnbsp = \"\\uFEFF\";\nconst PdfNonCharacterFFFE = \"￾\";\nconst PdfNonCharacterFFFF = \"￿\";\nconst PdfUnwantedTextMarkers = Object.freeze([\n PdfSoftHyphenMarker,\n PdfZeroWidthSpace,\n PdfWordJoiner,\n PdfBomOrZwnbsp,\n PdfNonCharacterFFFE,\n PdfNonCharacterFFFF\n]);\nconst PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join(\"\")}]`, \"g\");\nfunction stripPdfUnwantedMarkers(text) {\n return text.replace(PdfUnwantedTextRegex, \"\");\n}\nvar PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {\n PdfZoomMode2[PdfZoomMode2[\"Unknown\"] = 0] = \"Unknown\";\n PdfZoomMode2[PdfZoomMode2[\"XYZ\"] = 1] = \"XYZ\";\n PdfZoomMode2[PdfZoomMode2[\"FitPage\"] = 2] = \"FitPage\";\n PdfZoomMode2[PdfZoomMode2[\"FitHorizontal\"] = 3] = \"FitHorizontal\";\n PdfZoomMode2[PdfZoomMode2[\"FitVertical\"] = 4] = \"FitVertical\";\n PdfZoomMode2[PdfZoomMode2[\"FitRectangle\"] = 5] = \"FitRectangle\";\n PdfZoomMode2[PdfZoomMode2[\"FitBoundingBox\"] = 6] = \"FitBoundingBox\";\n PdfZoomMode2[PdfZoomMode2[\"FitBoundingBoxHorizontal\"] = 7] = \"FitBoundingBoxHorizontal\";\n PdfZoomMode2[PdfZoomMode2[\"FitBoundingBoxVertical\"] = 8] = \"FitBoundingBoxVertical\";\n return PdfZoomMode2;\n})(PdfZoomMode || {});\nvar PdfTrappedStatus = /* @__PURE__ */ ((PdfTrappedStatus2) => {\n PdfTrappedStatus2[PdfTrappedStatus2[\"NotSet\"] = 0] = \"NotSet\";\n PdfTrappedStatus2[PdfTrappedStatus2[\"True\"] = 1] = \"True\";\n PdfTrappedStatus2[PdfTrappedStatus2[\"False\"] = 2] = \"False\";\n PdfTrappedStatus2[PdfTrappedStatus2[\"Unknown\"] = 3] = \"Unknown\";\n return PdfTrappedStatus2;\n})(PdfTrappedStatus || {});\nvar PdfStandardFont = /* @__PURE__ */ ((PdfStandardFont2) => {\n PdfStandardFont2[PdfStandardFont2[\"Unknown\"] = -1] = \"Unknown\";\n PdfStandardFont2[PdfStandardFont2[\"Courier\"] = 0] = \"Courier\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Bold\"] = 1] = \"Courier_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_BoldOblique\"] = 2] = \"Courier_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Courier_Oblique\"] = 3] = \"Courier_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica\"] = 4] = \"Helvetica\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Bold\"] = 5] = \"Helvetica_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_BoldOblique\"] = 6] = \"Helvetica_BoldOblique\";\n PdfStandardFont2[PdfStandardFont2[\"Helvetica_Oblique\"] = 7] = \"Helvetica_Oblique\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Roman\"] = 8] = \"Times_Roman\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Bold\"] = 9] = \"Times_Bold\";\n PdfStandardFont2[PdfStandardFont2[\"Times_BoldItalic\"] = 10] = \"Times_BoldItalic\";\n PdfStandardFont2[PdfStandardFont2[\"Times_Italic\"] = 11] = \"Times_Italic\";\n PdfStandardFont2[PdfStandardFont2[\"Symbol\"] = 12] = \"Symbol\";\n PdfStandardFont2[PdfStandardFont2[\"ZapfDingbats\"] = 13] = \"ZapfDingbats\";\n return PdfStandardFont2;\n})(PdfStandardFont || {});\nvar PdfTextAlignment = /* @__PURE__ */ ((PdfTextAlignment2) => {\n PdfTextAlignment2[PdfTextAlignment2[\"Left\"] = 0] = \"Left\";\n PdfTextAlignment2[PdfTextAlignment2[\"Center\"] = 1] = \"Center\";\n PdfTextAlignment2[PdfTextAlignment2[\"Right\"] = 2] = \"Right\";\n return PdfTextAlignment2;\n})(PdfTextAlignment || {});\nvar PdfVerticalAlignment = /* @__PURE__ */ ((PdfVerticalAlignment2) => {\n PdfVerticalAlignment2[PdfVerticalAlignment2[\"Top\"] = 0] = \"Top\";\n PdfVerticalAlignment2[PdfVerticalAlignment2[\"Middle\"] = 1] = \"Middle\";\n PdfVerticalAlignment2[PdfVerticalAlignment2[\"Bottom\"] = 2] = \"Bottom\";\n return PdfVerticalAlignment2;\n})(PdfVerticalAlignment || {});\nvar PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {\n PdfBlendMode2[PdfBlendMode2[\"Normal\"] = 0] = \"Normal\";\n PdfBlendMode2[PdfBlendMode2[\"Multiply\"] = 1] = \"Multiply\";\n PdfBlendMode2[PdfBlendMode2[\"Screen\"] = 2] = \"Screen\";\n PdfBlendMode2[PdfBlendMode2[\"Overlay\"] = 3] = \"Overlay\";\n PdfBlendMode2[PdfBlendMode2[\"Darken\"] = 4] = \"Darken\";\n PdfBlendMode2[PdfBlendMode2[\"Lighten\"] = 5] = \"Lighten\";\n PdfBlendMode2[PdfBlendMode2[\"ColorDodge\"] = 6] = \"ColorDodge\";\n PdfBlendMode2[PdfBlendMode2[\"ColorBurn\"] = 7] = \"ColorBurn\";\n PdfBlendMode2[PdfBlendMode2[\"HardLight\"] = 8] = \"HardLight\";\n PdfBlendMode2[PdfBlendMode2[\"SoftLight\"] = 9] = \"SoftLight\";\n PdfBlendMode2[PdfBlendMode2[\"Difference\"] = 10] = \"Difference\";\n PdfBlendMode2[PdfBlendMode2[\"Exclusion\"] = 11] = \"Exclusion\";\n PdfBlendMode2[PdfBlendMode2[\"Hue\"] = 12] = \"Hue\";\n PdfBlendMode2[PdfBlendMode2[\"Saturation\"] = 13] = \"Saturation\";\n PdfBlendMode2[PdfBlendMode2[\"Color\"] = 14] = \"Color\";\n PdfBlendMode2[PdfBlendMode2[\"Luminosity\"] = 15] = \"Luminosity\";\n return PdfBlendMode2;\n})(PdfBlendMode || {});\nvar PdfStampFit = /* @__PURE__ */ ((PdfStampFit2) => {\n PdfStampFit2[PdfStampFit2[\"Contain\"] = 0] = \"Contain\";\n PdfStampFit2[PdfStampFit2[\"Cover\"] = 1] = \"Cover\";\n PdfStampFit2[PdfStampFit2[\"Stretch\"] = 2] = \"Stretch\";\n return PdfStampFit2;\n})(PdfStampFit || {});\nvar PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {\n PdfActionType2[PdfActionType2[\"Unsupported\"] = 0] = \"Unsupported\";\n PdfActionType2[PdfActionType2[\"Goto\"] = 1] = \"Goto\";\n PdfActionType2[PdfActionType2[\"RemoteGoto\"] = 2] = \"RemoteGoto\";\n PdfActionType2[PdfActionType2[\"URI\"] = 3] = \"URI\";\n PdfActionType2[PdfActionType2[\"LaunchAppOrOpenFile\"] = 4] = \"LaunchAppOrOpenFile\";\n return PdfActionType2;\n})(PdfActionType || {});\nconst AP_MODE_NORMAL = 1;\nconst AP_MODE_ROLLOVER = 2;\nconst AP_MODE_DOWN = 4;\nvar PdfAnnotationSubtype = /* @__PURE__ */ ((PdfAnnotationSubtype2) => {\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"TEXT\"] = 1] = \"TEXT\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"LINK\"] = 2] = \"LINK\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"FREETEXT\"] = 3] = \"FREETEXT\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"LINE\"] = 4] = \"LINE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"SQUARE\"] = 5] = \"SQUARE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"CIRCLE\"] = 6] = \"CIRCLE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"POLYGON\"] = 7] = \"POLYGON\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"POLYLINE\"] = 8] = \"POLYLINE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"HIGHLIGHT\"] = 9] = \"HIGHLIGHT\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"UNDERLINE\"] = 10] = \"UNDERLINE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"SQUIGGLY\"] = 11] = \"SQUIGGLY\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"STRIKEOUT\"] = 12] = \"STRIKEOUT\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"STAMP\"] = 13] = \"STAMP\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"CARET\"] = 14] = \"CARET\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"INK\"] = 15] = \"INK\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"POPUP\"] = 16] = \"POPUP\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"FILEATTACHMENT\"] = 17] = \"FILEATTACHMENT\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"SOUND\"] = 18] = \"SOUND\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"MOVIE\"] = 19] = \"MOVIE\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"WIDGET\"] = 20] = \"WIDGET\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"SCREEN\"] = 21] = \"SCREEN\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"PRINTERMARK\"] = 22] = \"PRINTERMARK\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"TRAPNET\"] = 23] = \"TRAPNET\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"WATERMARK\"] = 24] = \"WATERMARK\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"THREED\"] = 25] = \"THREED\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"RICHMEDIA\"] = 26] = \"RICHMEDIA\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"XFAWIDGET\"] = 27] = \"XFAWIDGET\";\n PdfAnnotationSubtype2[PdfAnnotationSubtype2[\"REDACT\"] = 28] = \"REDACT\";\n return PdfAnnotationSubtype2;\n})(PdfAnnotationSubtype || {});\nconst PdfAnnotationSubtypeName = {\n [\n 0\n /* UNKNOWN */\n ]: \"unknow\",\n [\n 1\n /* TEXT */\n ]: \"text\",\n [\n 2\n /* LINK */\n ]: \"link\",\n [\n 3\n /* FREETEXT */\n ]: \"freetext\",\n [\n 4\n /* LINE */\n ]: \"line\",\n [\n 5\n /* SQUARE */\n ]: \"square\",\n [\n 6\n /* CIRCLE */\n ]: \"circle\",\n [\n 7\n /* POLYGON */\n ]: \"polygon\",\n [\n 8\n /* POLYLINE */\n ]: \"polyline\",\n [\n 9\n /* HIGHLIGHT */\n ]: \"highlight\",\n [\n 10\n /* UNDERLINE */\n ]: \"underline\",\n [\n 11\n /* SQUIGGLY */\n ]: \"squiggly\",\n [\n 12\n /* STRIKEOUT */\n ]: \"strikeout\",\n [\n 13\n /* STAMP */\n ]: \"stamp\",\n [\n 14\n /* CARET */\n ]: \"caret\",\n [\n 15\n /* INK */\n ]: \"ink\",\n [\n 16\n /* POPUP */\n ]: \"popup\",\n [\n 17\n /* FILEATTACHMENT */\n ]: \"fileattachment\",\n [\n 18\n /* SOUND */\n ]: \"sound\",\n [\n 19\n /* MOVIE */\n ]: \"movie\",\n [\n 20\n /* WIDGET */\n ]: \"widget\",\n [\n 21\n /* SCREEN */\n ]: \"screen\",\n [\n 22\n /* PRINTERMARK */\n ]: \"printermark\",\n [\n 23\n /* TRAPNET */\n ]: \"trapnet\",\n [\n 24\n /* WATERMARK */\n ]: \"watermark\",\n [\n 25\n /* THREED */\n ]: \"threed\",\n [\n 26\n /* RICHMEDIA */\n ]: \"richmedia\",\n [\n 27\n /* XFAWIDGET */\n ]: \"xfawidget\",\n [\n 28\n /* REDACT */\n ]: \"redact\"\n};\nvar PdfAnnotationObjectStatus = /* @__PURE__ */ ((PdfAnnotationObjectStatus2) => {\n PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2[\"Created\"] = 0] = \"Created\";\n PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2[\"Committed\"] = 1] = \"Committed\";\n return PdfAnnotationObjectStatus2;\n})(PdfAnnotationObjectStatus || {});\nvar AppearanceMode = /* @__PURE__ */ ((AppearanceMode2) => {\n AppearanceMode2[AppearanceMode2[\"Normal\"] = 0] = \"Normal\";\n AppearanceMode2[AppearanceMode2[\"Rollover\"] = 1] = \"Rollover\";\n AppearanceMode2[AppearanceMode2[\"Down\"] = 2] = \"Down\";\n return AppearanceMode2;\n})(AppearanceMode || {});\nvar PdfAnnotationState = /* @__PURE__ */ ((PdfAnnotationState2) => {\n PdfAnnotationState2[\"Marked\"] = \"Marked\";\n PdfAnnotationState2[\"Unmarked\"] = \"Unmarked\";\n PdfAnnotationState2[\"Accepted\"] = \"Accepted\";\n PdfAnnotationState2[\"Rejected\"] = \"Rejected\";\n PdfAnnotationState2[\"Completed\"] = \"Completed\";\n PdfAnnotationState2[\"Cancelled\"] = \"Cancelled\";\n PdfAnnotationState2[\"None\"] = \"None\";\n return PdfAnnotationState2;\n})(PdfAnnotationState || {});\nvar PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {\n PdfAnnotationStateModel2[\"Marked\"] = \"Marked\";\n PdfAnnotationStateModel2[\"Review\"] = \"Review\";\n return PdfAnnotationStateModel2;\n})(PdfAnnotationStateModel || {});\nvar PdfAnnotationIcon = /* @__PURE__ */ ((PdfAnnotationIcon2) => {\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Unknown\"] = -1] = \"Unknown\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Comment\"] = 0] = \"Comment\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Key\"] = 1] = \"Key\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Note\"] = 2] = \"Note\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Help\"] = 3] = \"Help\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"NewParagraph\"] = 4] = \"NewParagraph\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Paragraph\"] = 5] = \"Paragraph\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Insert\"] = 6] = \"Insert\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Graph\"] = 7] = \"Graph\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"PushPin\"] = 8] = \"PushPin\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Paperclip\"] = 9] = \"Paperclip\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Tag\"] = 10] = \"Tag\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Speaker\"] = 11] = \"Speaker\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Mic\"] = 12] = \"Mic\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Approved\"] = 13] = \"Approved\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Experimental\"] = 14] = \"Experimental\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"NotApproved\"] = 15] = \"NotApproved\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"AsIs\"] = 16] = \"AsIs\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Expired\"] = 17] = \"Expired\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"NotForPublicRelease\"] = 18] = \"NotForPublicRelease\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Confidential\"] = 19] = \"Confidential\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Final\"] = 20] = \"Final\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Sold\"] = 21] = \"Sold\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Departmental\"] = 22] = \"Departmental\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"ForComment\"] = 23] = \"ForComment\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"TopSecret\"] = 24] = \"TopSecret\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"Draft\"] = 25] = \"Draft\";\n PdfAnnotationIcon2[PdfAnnotationIcon2[\"ForPublicRelease\"] = 26] = \"ForPublicRelease\";\n return PdfAnnotationIcon2;\n})(PdfAnnotationIcon || {});\nvar PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"None\"] = 0] = \"None\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Square\"] = 1] = \"Square\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Circle\"] = 2] = \"Circle\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Diamond\"] = 3] = \"Diamond\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"OpenArrow\"] = 4] = \"OpenArrow\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"ClosedArrow\"] = 5] = \"ClosedArrow\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Butt\"] = 6] = \"Butt\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"ROpenArrow\"] = 7] = \"ROpenArrow\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"RClosedArrow\"] = 8] = \"RClosedArrow\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Slash\"] = 9] = \"Slash\";\n PdfAnnotationLineEnding2[PdfAnnotationLineEnding2[\"Unknown\"] = 10] = \"Unknown\";\n return PdfAnnotationLineEnding2;\n})(PdfAnnotationLineEnding || {});\nvar PdfAnnotationReplyType = /* @__PURE__ */ ((PdfAnnotationReplyType2) => {\n PdfAnnotationReplyType2[PdfAnnotationReplyType2[\"Unknown\"] = 0] = \"Unknown\";\n PdfAnnotationReplyType2[PdfAnnotationReplyType2[\"Reply\"] = 1] = \"Reply\";\n PdfAnnotationReplyType2[PdfAnnotationReplyType2[\"Group\"] = 2] = \"Group\";\n return PdfAnnotationReplyType2;\n})(PdfAnnotationReplyType || {});\nvar PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"PUSHBUTTON\"] = 1] = \"PUSHBUTTON\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"CHECKBOX\"] = 2] = \"CHECKBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"RADIOBUTTON\"] = 3] = \"RADIOBUTTON\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"COMBOBOX\"] = 4] = \"COMBOBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"LISTBOX\"] = 5] = \"LISTBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"TEXTFIELD\"] = 6] = \"TEXTFIELD\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"SIGNATURE\"] = 7] = \"SIGNATURE\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA\"] = 8] = \"XFA\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_CHECKBOX\"] = 9] = \"XFA_CHECKBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_COMBOBOX\"] = 10] = \"XFA_COMBOBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_IMAGEFIELD\"] = 11] = \"XFA_IMAGEFIELD\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_LISTBOX\"] = 12] = \"XFA_LISTBOX\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_PUSHBUTTON\"] = 13] = \"XFA_PUSHBUTTON\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_SIGNATURE\"] = 14] = \"XFA_SIGNATURE\";\n PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2[\"XFA_TEXTFIELD\"] = 15] = \"XFA_TEXTFIELD\";\n return PDF_FORM_FIELD_TYPE2;\n})(PDF_FORM_FIELD_TYPE || {});\nvar PdfAnnotationColorType = /* @__PURE__ */ ((PdfAnnotationColorType2) => {\n PdfAnnotationColorType2[PdfAnnotationColorType2[\"Color\"] = 0] = \"Color\";\n PdfAnnotationColorType2[PdfAnnotationColorType2[\"InteriorColor\"] = 1] = \"InteriorColor\";\n PdfAnnotationColorType2[PdfAnnotationColorType2[\"OverlayColor\"] = 2] = \"OverlayColor\";\n return PdfAnnotationColorType2;\n})(PdfAnnotationColorType || {});\nvar PdfAnnotationBorderStyle = /* @__PURE__ */ ((PdfAnnotationBorderStyle2) => {\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"SOLID\"] = 1] = \"SOLID\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"DASHED\"] = 2] = \"DASHED\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"BEVELED\"] = 3] = \"BEVELED\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"INSET\"] = 4] = \"INSET\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"UNDERLINE\"] = 5] = \"UNDERLINE\";\n PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2[\"CLOUDY\"] = 6] = \"CLOUDY\";\n return PdfAnnotationBorderStyle2;\n})(PdfAnnotationBorderStyle || {});\nvar PdfAnnotationFlags = /* @__PURE__ */ ((PdfAnnotationFlags2) => {\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"NONE\"] = 0] = \"NONE\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"INVISIBLE\"] = 1] = \"INVISIBLE\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"HIDDEN\"] = 2] = \"HIDDEN\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"PRINT\"] = 4] = \"PRINT\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"NO_ZOOM\"] = 8] = \"NO_ZOOM\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"NO_ROTATE\"] = 16] = \"NO_ROTATE\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"NO_VIEW\"] = 32] = \"NO_VIEW\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"READ_ONLY\"] = 64] = \"READ_ONLY\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"LOCKED\"] = 128] = \"LOCKED\";\n PdfAnnotationFlags2[PdfAnnotationFlags2[\"TOGGLE_NOVIEW\"] = 256] = \"TOGGLE_NOVIEW\";\n return PdfAnnotationFlags2;\n})(PdfAnnotationFlags || {});\nvar PDF_FORM_FIELD_FLAG = /* @__PURE__ */ ((PDF_FORM_FIELD_FLAG2) => {\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"NONE\"] = 0] = \"NONE\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"READONLY\"] = 1] = \"READONLY\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"REQUIRED\"] = 2] = \"REQUIRED\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"NOEXPORT\"] = 4] = \"NOEXPORT\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"TEXT_MULTIPLINE\"] = 4096] = \"TEXT_MULTIPLINE\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"TEXT_PASSWORD\"] = 8192] = \"TEXT_PASSWORD\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"CHOICE_COMBO\"] = 131072] = \"CHOICE_COMBO\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"CHOICE_EDIT\"] = 262144] = \"CHOICE_EDIT\";\n PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2[\"CHOICE_MULTL_SELECT\"] = 2097152] = \"CHOICE_MULTL_SELECT\";\n return PDF_FORM_FIELD_FLAG2;\n})(PDF_FORM_FIELD_FLAG || {});\nvar PdfPageObjectType = /* @__PURE__ */ ((PdfPageObjectType2) => {\n PdfPageObjectType2[PdfPageObjectType2[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n PdfPageObjectType2[PdfPageObjectType2[\"TEXT\"] = 1] = \"TEXT\";\n PdfPageObjectType2[PdfPageObjectType2[\"PATH\"] = 2] = \"PATH\";\n PdfPageObjectType2[PdfPageObjectType2[\"IMAGE\"] = 3] = \"IMAGE\";\n PdfPageObjectType2[PdfPageObjectType2[\"SHADING\"] = 4] = \"SHADING\";\n PdfPageObjectType2[PdfPageObjectType2[\"FORM\"] = 5] = \"FORM\";\n return PdfPageObjectType2;\n})(PdfPageObjectType || {});\nconst PdfAnnotationFlagName = Object.freeze({\n [\n 1\n /* INVISIBLE */\n ]: \"invisible\",\n [\n 2\n /* HIDDEN */\n ]: \"hidden\",\n [\n 4\n /* PRINT */\n ]: \"print\",\n [\n 8\n /* NO_ZOOM */\n ]: \"noZoom\",\n [\n 16\n /* NO_ROTATE */\n ]: \"noRotate\",\n [\n 32\n /* NO_VIEW */\n ]: \"noView\",\n [\n 64\n /* READ_ONLY */\n ]: \"readOnly\",\n [\n 128\n /* LOCKED */\n ]: \"locked\",\n [\n 256\n /* TOGGLE_NOVIEW */\n ]: \"toggleNoView\"\n});\nconst PdfAnnotationFlagValue = Object.entries(\n PdfAnnotationFlagName\n).reduce(\n (acc, [bit, name]) => {\n acc[name] = Number(bit);\n return acc;\n },\n {}\n);\nfunction flagsToNames(raw) {\n return Object.keys(PdfAnnotationFlagName).filter((flag) => (raw & flag) !== 0).map((flag) => PdfAnnotationFlagName[flag]);\n}\nfunction namesToFlags(names) {\n return names.reduce(\n (mask, name) => mask | PdfAnnotationFlagValue[name],\n 0\n /* NONE */\n );\n}\nvar PdfSegmentObjectType = /* @__PURE__ */ ((PdfSegmentObjectType2) => {\n PdfSegmentObjectType2[PdfSegmentObjectType2[\"UNKNOWN\"] = -1] = \"UNKNOWN\";\n PdfSegmentObjectType2[PdfSegmentObjectType2[\"LINETO\"] = 0] = \"LINETO\";\n PdfSegmentObjectType2[PdfSegmentObjectType2[\"BEZIERTO\"] = 1] = \"BEZIERTO\";\n PdfSegmentObjectType2[PdfSegmentObjectType2[\"MOVETO\"] = 2] = \"MOVETO\";\n return PdfSegmentObjectType2;\n})(PdfSegmentObjectType || {});\nvar FontCharset = /* @__PURE__ */ ((FontCharset2) => {\n FontCharset2[FontCharset2[\"ANSI\"] = 0] = \"ANSI\";\n FontCharset2[FontCharset2[\"DEFAULT\"] = 1] = \"DEFAULT\";\n FontCharset2[FontCharset2[\"SYMBOL\"] = 2] = \"SYMBOL\";\n FontCharset2[FontCharset2[\"SHIFTJIS\"] = 128] = \"SHIFTJIS\";\n FontCharset2[FontCharset2[\"HANGEUL\"] = 129] = \"HANGEUL\";\n FontCharset2[FontCharset2[\"GB2312\"] = 134] = \"GB2312\";\n FontCharset2[FontCharset2[\"CHINESEBIG5\"] = 136] = \"CHINESEBIG5\";\n FontCharset2[FontCharset2[\"GREEK\"] = 161] = \"GREEK\";\n FontCharset2[FontCharset2[\"VIETNAMESE\"] = 163] = \"VIETNAMESE\";\n FontCharset2[FontCharset2[\"HEBREW\"] = 177] = \"HEBREW\";\n FontCharset2[FontCharset2[\"ARABIC\"] = 178] = \"ARABIC\";\n FontCharset2[FontCharset2[\"CYRILLIC\"] = 204] = \"CYRILLIC\";\n FontCharset2[FontCharset2[\"THAI\"] = 222] = \"THAI\";\n FontCharset2[FontCharset2[\"EASTERNEUROPEAN\"] = 238] = \"EASTERNEUROPEAN\";\n return FontCharset2;\n})(FontCharset || {});\nvar PdfEngineFeature = /* @__PURE__ */ ((PdfEngineFeature2) => {\n PdfEngineFeature2[PdfEngineFeature2[\"RenderPage\"] = 0] = \"RenderPage\";\n PdfEngineFeature2[PdfEngineFeature2[\"RenderPageRect\"] = 1] = \"RenderPageRect\";\n PdfEngineFeature2[PdfEngineFeature2[\"Thumbnails\"] = 2] = \"Thumbnails\";\n PdfEngineFeature2[PdfEngineFeature2[\"Bookmarks\"] = 3] = \"Bookmarks\";\n PdfEngineFeature2[PdfEngineFeature2[\"Annotations\"] = 4] = \"Annotations\";\n return PdfEngineFeature2;\n})(PdfEngineFeature || {});\nvar PdfEngineOperation = /* @__PURE__ */ ((PdfEngineOperation2) => {\n PdfEngineOperation2[PdfEngineOperation2[\"Create\"] = 0] = \"Create\";\n PdfEngineOperation2[PdfEngineOperation2[\"Read\"] = 1] = \"Read\";\n PdfEngineOperation2[PdfEngineOperation2[\"Update\"] = 2] = \"Update\";\n PdfEngineOperation2[PdfEngineOperation2[\"Delete\"] = 3] = \"Delete\";\n return PdfEngineOperation2;\n})(PdfEngineOperation || {});\nvar MatchFlag = /* @__PURE__ */ ((MatchFlag2) => {\n MatchFlag2[MatchFlag2[\"None\"] = 0] = \"None\";\n MatchFlag2[MatchFlag2[\"MatchCase\"] = 1] = \"MatchCase\";\n MatchFlag2[MatchFlag2[\"MatchWholeWord\"] = 2] = \"MatchWholeWord\";\n MatchFlag2[MatchFlag2[\"MatchConsecutive\"] = 4] = \"MatchConsecutive\";\n return MatchFlag2;\n})(MatchFlag || {});\nfunction unionFlags(flags) {\n return flags.reduce(\n (flag, currFlag) => {\n return flag | currFlag;\n },\n 0\n /* None */\n );\n}\nfunction compareSearchTarget(targetA, targetB) {\n const flagA = unionFlags(targetA.flags);\n const flagB = unionFlags(targetB.flags);\n return flagA === flagB && targetA.keyword === targetB.keyword;\n}\nvar PdfPermissionFlag = /* @__PURE__ */ ((PdfPermissionFlag2) => {\n PdfPermissionFlag2[PdfPermissionFlag2[\"Print\"] = 4] = \"Print\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyContents\"] = 8] = \"ModifyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"CopyContents\"] = 16] = \"CopyContents\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ModifyAnnotations\"] = 32] = \"ModifyAnnotations\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"FillForms\"] = 256] = \"FillForms\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"ExtractForAccessibility\"] = 512] = \"ExtractForAccessibility\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AssembleDocument\"] = 1024] = \"AssembleDocument\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"PrintHighQuality\"] = 2048] = \"PrintHighQuality\";\n PdfPermissionFlag2[PdfPermissionFlag2[\"AllowAll\"] = 3900] = \"AllowAll\";\n return PdfPermissionFlag2;\n})(PdfPermissionFlag || {});\nfunction buildPermissions(...flags) {\n let result = flags.reduce((acc, flag) => acc | flag, 0);\n if (result & 2048) {\n result |= 4;\n }\n return result;\n}\nclass PermissionDeniedError extends Error {\n constructor(requiredFlags, currentPermissions) {\n const flagNames = requiredFlags.map((f) => PdfPermissionFlag[f]).join(\", \");\n super(`Permission denied. Required: ${flagNames}`);\n this.requiredFlags = requiredFlags;\n this.currentPermissions = currentPermissions;\n this.name = \"PermissionDeniedError\";\n }\n}\nvar PdfPageFlattenFlag = /* @__PURE__ */ ((PdfPageFlattenFlag2) => {\n PdfPageFlattenFlag2[PdfPageFlattenFlag2[\"Display\"] = 0] = \"Display\";\n PdfPageFlattenFlag2[PdfPageFlattenFlag2[\"Print\"] = 1] = \"Print\";\n return PdfPageFlattenFlag2;\n})(PdfPageFlattenFlag || {});\nvar PdfPageFlattenResult = /* @__PURE__ */ ((PdfPageFlattenResult2) => {\n PdfPageFlattenResult2[PdfPageFlattenResult2[\"Fail\"] = 0] = \"Fail\";\n PdfPageFlattenResult2[PdfPageFlattenResult2[\"Success\"] = 1] = \"Success\";\n PdfPageFlattenResult2[PdfPageFlattenResult2[\"NothingToDo\"] = 2] = \"NothingToDo\";\n return PdfPageFlattenResult2;\n})(PdfPageFlattenResult || {});\nvar PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {\n PdfErrorCode2[PdfErrorCode2[\"Ok\"] = 0] = \"Ok\";\n PdfErrorCode2[PdfErrorCode2[\"Unknown\"] = 1] = \"Unknown\";\n PdfErrorCode2[PdfErrorCode2[\"NotFound\"] = 2] = \"NotFound\";\n PdfErrorCode2[PdfErrorCode2[\"WrongFormat\"] = 3] = \"WrongFormat\";\n PdfErrorCode2[PdfErrorCode2[\"Password\"] = 4] = \"Password\";\n PdfErrorCode2[PdfErrorCode2[\"Security\"] = 5] = \"Security\";\n PdfErrorCode2[PdfErrorCode2[\"PageError\"] = 6] = \"PageError\";\n PdfErrorCode2[PdfErrorCode2[\"XFALoad\"] = 7] = \"XFALoad\";\n PdfErrorCode2[PdfErrorCode2[\"XFALayout\"] = 8] = \"XFALayout\";\n PdfErrorCode2[PdfErrorCode2[\"Cancelled\"] = 9] = \"Cancelled\";\n PdfErrorCode2[PdfErrorCode2[\"Initialization\"] = 10] = \"Initialization\";\n PdfErrorCode2[PdfErrorCode2[\"NotReady\"] = 11] = \"NotReady\";\n PdfErrorCode2[PdfErrorCode2[\"NotSupport\"] = 12] = \"NotSupport\";\n PdfErrorCode2[PdfErrorCode2[\"LoadDoc\"] = 13] = \"LoadDoc\";\n PdfErrorCode2[PdfErrorCode2[\"DocNotOpen\"] = 14] = \"DocNotOpen\";\n PdfErrorCode2[PdfErrorCode2[\"CantCloseDoc\"] = 15] = \"CantCloseDoc\";\n PdfErrorCode2[PdfErrorCode2[\"CantCreateNewDoc\"] = 16] = \"CantCreateNewDoc\";\n PdfErrorCode2[PdfErrorCode2[\"CantImportPages\"] = 17] = \"CantImportPages\";\n PdfErrorCode2[PdfErrorCode2[\"CantCreateAnnot\"] = 18] = \"CantCreateAnnot\";\n PdfErrorCode2[PdfErrorCode2[\"CantSetAnnotRect\"] = 19] = \"CantSetAnnotRect\";\n PdfErrorCode2[PdfErrorCode2[\"CantSetAnnotContent\"] = 20] = \"CantSetAnnotContent\";\n PdfErrorCode2[PdfErrorCode2[\"CantRemoveInkList\"] = 21] = \"CantRemoveInkList\";\n PdfErrorCode2[PdfErrorCode2[\"CantAddInkStoke\"] = 22] = \"CantAddInkStoke\";\n PdfErrorCode2[PdfErrorCode2[\"CantReadAttachmentSize\"] = 23] = \"CantReadAttachmentSize\";\n PdfErrorCode2[PdfErrorCode2[\"CantReadAttachmentContent\"] = 24] = \"CantReadAttachmentContent\";\n PdfErrorCode2[PdfErrorCode2[\"CantFocusAnnot\"] = 25] = \"CantFocusAnnot\";\n PdfErrorCode2[PdfErrorCode2[\"CantSelectText\"] = 26] = \"CantSelectText\";\n PdfErrorCode2[PdfErrorCode2[\"CantSelectOption\"] = 27] = \"CantSelectOption\";\n PdfErrorCode2[PdfErrorCode2[\"CantCheckField\"] = 28] = \"CantCheckField\";\n PdfErrorCode2[PdfErrorCode2[\"CantSetAnnotString\"] = 29] = \"CantSetAnnotString\";\n return PdfErrorCode2;\n})(PdfErrorCode || {});\nclass PdfTaskHelper {\n /**\n * Create a task\n * @returns new task\n */\n static create() {\n return new Task();\n }\n /**\n * Create a task that has been resolved with value\n * @param result - resolved value\n * @returns resolved task\n */\n static resolve(result) {\n const task = new Task();\n task.resolve(result);\n return task;\n }\n /**\n * Create a task that has been rejected with error\n * @param reason - rejected error\n * @returns rejected task\n */\n static reject(reason) {\n const task = new Task();\n task.reject(reason);\n return task;\n }\n /**\n * Create a task that has been aborted with error\n * @param reason - aborted error\n * @returns aborted task\n */\n static abort(reason) {\n const task = new Task();\n task.reject(reason);\n return task;\n }\n}\nvar RenderPriority = /* @__PURE__ */ ((RenderPriority2) => {\n RenderPriority2[RenderPriority2[\"LOW\"] = 0] = \"LOW\";\n RenderPriority2[RenderPriority2[\"MEDIUM\"] = 1] = \"MEDIUM\";\n RenderPriority2[RenderPriority2[\"HIGH\"] = 2] = \"HIGH\";\n RenderPriority2[RenderPriority2[\"CRITICAL\"] = 3] = \"CRITICAL\";\n return RenderPriority2;\n})(RenderPriority || {});\nfunction pdfColorToWebColor(c) {\n const clamp = (n) => Math.max(0, Math.min(255, n));\n const toHex = (n) => clamp(n).toString(16).padStart(2, \"0\");\n return `#${toHex(c.red)}${toHex(c.green)}${toHex(c.blue)}`;\n}\nfunction webColorToPdfColor(color) {\n if (/^#?[0-9a-f]{3}$/i.test(color)) {\n color = color.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, \"#$1$1$2$2$3$3\").toLowerCase();\n }\n const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {\n throw new Error(`Invalid hex colour: \"${color}\"`);\n })();\n return {\n red: parseInt(r, 16),\n green: parseInt(g, 16),\n blue: parseInt(b, 16)\n };\n}\nfunction pdfAlphaToWebOpacity(alpha) {\n const clamp = (n) => Math.max(0, Math.min(255, n));\n return clamp(alpha) / 255;\n}\nfunction webOpacityToPdfAlpha(opacity) {\n const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));\n return clamp(Math.round(opacity * 255));\n}\nfunction extractPdfColor(c) {\n return { red: c.red, green: c.green, blue: c.blue };\n}\nfunction extractWebOpacity(c) {\n return pdfAlphaToWebOpacity(c.alpha);\n}\nfunction combinePdfColorWithAlpha(color, alpha) {\n return { ...color, alpha };\n}\nfunction combineWebColorWithOpacity(color, opacity) {\n return { color, opacity };\n}\nfunction pdfAlphaColorToWebAlphaColor(c) {\n const color = pdfColorToWebColor(extractPdfColor(c));\n const opacity = extractWebOpacity(c);\n return { color, opacity };\n}\nfunction webAlphaColorToPdfAlphaColor({ color, opacity }) {\n const pdfColor = webColorToPdfColor(color);\n const alpha = webOpacityToPdfAlpha(opacity);\n return combinePdfColorWithAlpha(pdfColor, alpha);\n}\nfunction pdfDateToDate(pdf) {\n if (!(pdf == null ? void 0 : pdf.startsWith(\"D:\")) || pdf.length < 16) return;\n const y = +pdf.slice(2, 6);\n const mo = +pdf.slice(6, 8) - 1;\n const d = +pdf.slice(8, 10);\n const H = +pdf.slice(10, 12);\n const M = +pdf.slice(12, 14);\n const S = +pdf.slice(14, 16);\n return new Date(Date.UTC(y, mo, d, H, M, S));\n}\nfunction dateToPdfDate(date = /* @__PURE__ */ new Date()) {\n const z = (n, len = 2) => n.toString().padStart(len, \"0\");\n const YYYY = date.getUTCFullYear();\n const MM = z(date.getUTCMonth() + 1);\n const DD = z(date.getUTCDate());\n const HH = z(date.getUTCHours());\n const mm = z(date.getUTCMinutes());\n const SS = z(date.getUTCSeconds());\n return `D:${YYYY}${MM}${DD}${HH}${mm}${SS}`;\n}\nconst MixedTextAlignment = Symbol(\"mixed\");\nconst TEXT_ALIGNMENT_INFOS = Object.freeze([\n { id: PdfTextAlignment.Left, label: \"Left\", css: \"left\" },\n { id: PdfTextAlignment.Center, label: \"Center\", css: \"center\" },\n { id: PdfTextAlignment.Right, label: \"Right\", css: \"right\" }\n]);\nconst enumToTextInfo = TEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nconst cssToTextEnum = TEXT_ALIGNMENT_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nfunction getTextAlignmentInfo(alignment) {\n return enumToTextInfo[alignment] ?? enumToTextInfo[PdfTextAlignment.Left];\n}\nfunction textAlignmentToCss(alignment) {\n return getTextAlignmentInfo(alignment).css;\n}\nfunction cssToTextAlignment(value) {\n return cssToTextEnum[value];\n}\nfunction textAlignmentLabel(alignment) {\n return getTextAlignmentInfo(alignment).label;\n}\nfunction reduceTextAlignments(values) {\n if (!values.length) return PdfTextAlignment.Left;\n const first = values[0];\n return values.every((a) => a === first) ? first : MixedTextAlignment;\n}\nconst textAlignmentSelectOptions = TEXT_ALIGNMENT_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nvar PdfStandardFontFamily = /* @__PURE__ */ ((PdfStandardFontFamily2) => {\n PdfStandardFontFamily2[\"Courier\"] = \"Courier\";\n PdfStandardFontFamily2[\"Helvetica\"] = \"Helvetica\";\n PdfStandardFontFamily2[\"Times\"] = \"Times\";\n PdfStandardFontFamily2[\"Symbol\"] = \"Symbol\";\n PdfStandardFontFamily2[\"ZapfDingbats\"] = \"ZapfDingbats\";\n PdfStandardFontFamily2[\"Unknown\"] = \"Unknown\";\n return PdfStandardFontFamily2;\n})(PdfStandardFontFamily || {});\nconst DEFAULT_FALLBACK_FONT = PdfStandardFont.Helvetica;\nconst MixedStandardFont = Symbol(\"mixed\");\nconst HELVETICA_DESC = {\n id: PdfStandardFont.Helvetica,\n family: \"Helvetica\",\n bold: false,\n italic: false,\n label: \"Helvetica\",\n css: \"Helvetica, Arial, sans-serif\"\n};\nconst STANDARD_FONT_DESCRIPTORS = Object.freeze([\n {\n id: PdfStandardFont.Courier,\n family: \"Courier\",\n bold: false,\n italic: false,\n label: \"Courier\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Bold,\n family: \"Courier\",\n bold: true,\n italic: false,\n label: \"Courier Bold\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_BoldOblique,\n family: \"Courier\",\n bold: true,\n italic: true,\n label: \"Courier Bold Oblique\",\n css: \"Courier, monospace\"\n },\n {\n id: PdfStandardFont.Courier_Oblique,\n family: \"Courier\",\n bold: false,\n italic: true,\n label: \"Courier Oblique\",\n css: \"Courier, monospace\"\n },\n HELVETICA_DESC,\n {\n id: PdfStandardFont.Helvetica_Bold,\n family: \"Helvetica\",\n bold: true,\n italic: false,\n label: \"Helvetica Bold\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_BoldOblique,\n family: \"Helvetica\",\n bold: true,\n italic: true,\n label: \"Helvetica Bold Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Helvetica_Oblique,\n family: \"Helvetica\",\n bold: false,\n italic: true,\n label: \"Helvetica Oblique\",\n css: \"Helvetica, Arial, sans-serif\"\n },\n {\n id: PdfStandardFont.Times_Roman,\n family: \"Times\",\n bold: false,\n italic: false,\n label: \"Times Roman\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Bold,\n family: \"Times\",\n bold: true,\n italic: false,\n label: \"Times Bold\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_BoldItalic,\n family: \"Times\",\n bold: true,\n italic: true,\n label: \"Times Bold Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Times_Italic,\n family: \"Times\",\n bold: false,\n italic: true,\n label: \"Times Italic\",\n css: '\"Times New Roman\", Times, serif'\n },\n {\n id: PdfStandardFont.Symbol,\n family: \"Symbol\",\n bold: false,\n italic: false,\n label: \"Symbol\",\n css: \"Symbol, serif\"\n },\n {\n id: PdfStandardFont.ZapfDingbats,\n family: \"ZapfDingbats\",\n bold: false,\n italic: false,\n label: \"Zapf Dingbats\",\n css: \"ZapfDingbats, serif\"\n }\n]);\nconst idToDescriptor = STANDARD_FONT_DESCRIPTORS.reduce((m, d) => (m[d.id] = d, m), {});\nconst familyStyleToId = /* @__PURE__ */ new Map();\nfor (const d of STANDARD_FONT_DESCRIPTORS) {\n familyStyleToId.set(`${d.family}_${d.bold}_${d.italic}`, d.id);\n}\nfunction unknownDescriptor() {\n return HELVETICA_DESC;\n}\nfunction getStandardFontDescriptor(font) {\n return idToDescriptor[font] ?? unknownDescriptor();\n}\nfunction standardFontFamily(font) {\n return getStandardFontDescriptor(font).family;\n}\nfunction standardFontIsBold(font) {\n return getStandardFontDescriptor(font).bold;\n}\nfunction standardFontIsItalic(font) {\n return getStandardFontDescriptor(font).italic;\n}\nfunction makeStandardFont(family, { bold, italic }) {\n return familyStyleToId.get(`${family}_${bold}_${italic}`) ?? DEFAULT_FALLBACK_FONT;\n}\nfunction standardFontLabel(font) {\n return getStandardFontDescriptor(font).label;\n}\nfunction standardFontCss(font) {\n return getStandardFontDescriptor(font).css;\n}\nfunction standardFontCssProperties(font) {\n const desc = getStandardFontDescriptor(font);\n return {\n fontFamily: desc.css,\n fontWeight: desc.bold ? \"bold\" : \"normal\",\n fontStyle: desc.italic ? \"italic\" : \"normal\"\n };\n}\nconst standardFontFamilySelectOptions = Object.values(PdfStandardFontFamily).filter(\n (f) => f !== \"Unknown\"\n /* Unknown */\n).map((family) => ({ value: family, label: family }));\nfunction reduceStandardFonts(fonts) {\n if (!fonts.length) return PdfStandardFont.Unknown;\n const first = fonts[0];\n return fonts.every((f) => f === first) ? first : MixedStandardFont;\n}\nconst STANDARD_FONT_FAMILIES = [\n ...new Set(STANDARD_FONT_DESCRIPTORS.map((d) => d.family))\n];\nfunction standardFontFamilyLabel(fam) {\n switch (fam) {\n case \"Courier\":\n return \"Courier\";\n case \"Helvetica\":\n return \"Helvetica\";\n case \"Times\":\n return \"Times\";\n case \"Symbol\":\n return \"Symbol\";\n case \"ZapfDingbats\":\n return \"ZapfDingbats\";\n /* fallback */\n default:\n return \"Helvetica\";\n }\n}\nconst MixedBlendMode = Symbol(\"mixed\");\nconst BLEND_MODE_INFOS = Object.freeze([\n { id: PdfBlendMode.Normal, label: \"Normal\", css: \"normal\" },\n { id: PdfBlendMode.Multiply, label: \"Multiply\", css: \"multiply\" },\n { id: PdfBlendMode.Screen, label: \"Screen\", css: \"screen\" },\n { id: PdfBlendMode.Overlay, label: \"Overlay\", css: \"overlay\" },\n { id: PdfBlendMode.Darken, label: \"Darken\", css: \"darken\" },\n { id: PdfBlendMode.Lighten, label: \"Lighten\", css: \"lighten\" },\n { id: PdfBlendMode.ColorDodge, label: \"Color Dodge\", css: \"color-dodge\" },\n { id: PdfBlendMode.ColorBurn, label: \"Color Burn\", css: \"color-burn\" },\n { id: PdfBlendMode.HardLight, label: \"Hard Light\", css: \"hard-light\" },\n { id: PdfBlendMode.SoftLight, label: \"Soft Light\", css: \"soft-light\" },\n { id: PdfBlendMode.Difference, label: \"Difference\", css: \"difference\" },\n { id: PdfBlendMode.Exclusion, label: \"Exclusion\", css: \"exclusion\" },\n { id: PdfBlendMode.Hue, label: \"Hue\", css: \"hue\" },\n { id: PdfBlendMode.Saturation, label: \"Saturation\", css: \"saturation\" },\n { id: PdfBlendMode.Color, label: \"Color\", css: \"color\" },\n { id: PdfBlendMode.Luminosity, label: \"Luminosity\", css: \"luminosity\" }\n]);\nconst enumToInfo = BLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.id] = info;\n return m;\n },\n {}\n);\nconst cssToEnum = BLEND_MODE_INFOS.reduce(\n (m, info) => {\n m[info.css] = info.id;\n return m;\n },\n {}\n);\nfunction getBlendModeInfo(mode) {\n return enumToInfo[mode] ?? enumToInfo[PdfBlendMode.Normal];\n}\nfunction blendModeToCss(mode) {\n return getBlendModeInfo(mode).css;\n}\nfunction cssToBlendMode(value) {\n return cssToEnum[value];\n}\nfunction blendModeLabel(mode) {\n return getBlendModeInfo(mode).label;\n}\nfunction reduceBlendModes(modes) {\n if (!modes.length) return PdfBlendMode.Normal;\n const first = modes[0];\n return modes.every((m) => m === first) ? first : MixedBlendMode;\n}\nconst blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({\n value: info.id,\n label: info.label\n}));\nconst blendModeValues = BLEND_MODE_INFOS.map((info) => info.id);\nfunction uiBlendModeDisplay(value) {\n return value === MixedBlendMode ? \"(mixed)\" : blendModeLabel(value);\n}\nfunction serializeLogger(logger) {\n if (logger instanceof NoopLogger) {\n return { type: \"noop\" };\n }\n if (logger instanceof ConsoleLogger) {\n return { type: \"console\" };\n }\n if (logger instanceof PerfLogger) {\n return { type: \"perf\" };\n }\n if (logger instanceof LevelLogger) {\n const levelLogger = logger;\n return {\n type: \"level\",\n config: {\n level: levelLogger.level,\n logger: serializeLogger(levelLogger.logger)\n }\n };\n }\n if (logger instanceof AllLogger) {\n const allLogger = logger;\n return {\n type: \"all\",\n config: {\n loggers: allLogger.loggers.map(serializeLogger)\n }\n };\n }\n return { type: \"noop\" };\n}\nfunction deserializeLogger(serialized) {\n var _a, _b, _c;\n switch (serialized.type) {\n case \"noop\":\n return new NoopLogger();\n case \"console\":\n return new ConsoleLogger();\n case \"perf\":\n return new PerfLogger();\n case \"level\":\n if (!((_a = serialized.config) == null ? void 0 : _a.logger) || ((_b = serialized.config) == null ? void 0 : _b.level) === void 0) {\n throw new Error(\"LevelLogger requires logger and level in config\");\n }\n return new LevelLogger(deserializeLogger(serialized.config.logger), serialized.config.level);\n case \"all\":\n if (!((_c = serialized.config) == null ? void 0 : _c.loggers)) {\n throw new Error(\"AllLogger requires loggers array in config\");\n }\n return new AllLogger(serialized.config.loggers.map(deserializeLogger));\n default:\n return new NoopLogger();\n }\n}\nconst V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\nfunction isUuidV4(str) {\n return V4_REGEX.test(str);\n}\nfunction getRandomBytes(len) {\n var _a;\n if (typeof ((_a = globalThis.crypto) == null ? void 0 : _a.getRandomValues) === \"function\") {\n return globalThis.crypto.getRandomValues(new Uint8Array(len));\n }\n if (typeof require === \"function\") {\n try {\n const { randomBytes } = require(\"crypto\");\n return randomBytes(len);\n } catch {\n }\n }\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\nfunction uuidV4() {\n var _a;\n if (typeof ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n const bytes = getRandomBytes(16);\n bytes[6] = bytes[6] & 15 | 64;\n bytes[8] = bytes[8] & 63 | 128;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\nclass CompoundTask extends Task {\n constructor(config = {}) {\n super();\n this.children = /* @__PURE__ */ new Map();\n this.childResults = [];\n this.completedCount = 0;\n this.expectedCount = 0;\n this.isFinalized = false;\n this.config = {\n aggregate: config.aggregate ?? ((results) => results),\n onChildComplete: config.onChildComplete ?? (() => {\n }),\n failFast: config.failFast ?? true\n };\n }\n /**\n * Add a child task - automatically wires up completion handling\n */\n addChild(child, index) {\n if (this.state.stage !== TaskStage.Pending) {\n if (this.state.stage === TaskStage.Aborted) {\n child.abort(this.state.reason);\n }\n return this;\n }\n const childIndex = index ?? this.expectedCount;\n this.expectedCount = Math.max(this.expectedCount, childIndex + 1);\n this.children.set(child, childIndex);\n child.wait(\n (result) => this.handleChildSuccess(child, result, childIndex),\n (error) => this.handleChildError(child, error, childIndex)\n );\n return this;\n }\n /**\n * Finalize - signals that no more children will be added\n * If no children were added, resolves immediately\n */\n finalize() {\n if (this.isFinalized) return this;\n this.isFinalized = true;\n if (this.expectedCount === 0) {\n this.resolve(this.config.aggregate([]));\n }\n return this;\n }\n handleChildSuccess(child, result, index) {\n if (this.state.stage !== TaskStage.Pending) return;\n this.childResults[index] = result;\n this.completedCount++;\n this.children.delete(child);\n const progressValue = this.config.onChildComplete(\n this.completedCount,\n this.expectedCount,\n result,\n index\n );\n if (progressValue !== void 0) {\n this.progress(progressValue);\n }\n if (this.completedCount === this.expectedCount) {\n const finalResult = this.config.aggregate(this.childResults);\n this.resolve(finalResult);\n }\n }\n handleChildError(child, error, index) {\n if (this.state.stage !== TaskStage.Pending) return;\n this.children.delete(child);\n if (this.config.failFast) {\n for (const [otherChild] of this.children) {\n otherChild.abort(\"Sibling task failed\");\n }\n this.children.clear();\n this.fail(error);\n } else {\n this.childResults[index] = void 0;\n this.completedCount++;\n if (this.completedCount === this.expectedCount) {\n const finalResult = this.config.aggregate(this.childResults);\n this.resolve(finalResult);\n }\n }\n }\n /**\n * Override abort to propagate to all children\n */\n abort(reason) {\n for (const [child] of this.children) {\n child.abort(reason);\n }\n this.children.clear();\n super.abort(reason);\n }\n /**\n * Override reject to abort all children\n */\n reject(reason) {\n for (const [child] of this.children) {\n child.abort(reason);\n }\n this.children.clear();\n super.reject(reason);\n }\n /**\n * Get count of pending children\n */\n getPendingCount() {\n return this.children.size;\n }\n /**\n * Get count of completed children\n */\n getCompletedCount() {\n return this.completedCount;\n }\n // ============================================================================\n // Static Factory Methods\n // ============================================================================\n /**\n * Gather results from an array of tasks (progress-friendly).\n * (Formerly: all)\n */\n static gather(tasks) {\n const compound = new CompoundTask({\n aggregate: (results) => results,\n onChildComplete: (completed, total) => ({ completed, total })\n });\n tasks.forEach((task, index) => compound.addChild(task, index));\n compound.finalize();\n return compound;\n }\n /**\n * Gather into a Record indexed by number.\n * (Formerly: allIndexed)\n */\n static gatherIndexed(tasks) {\n const compound = new CompoundTask({\n aggregate: (results) => {\n const record = {};\n results.forEach((result, index) => {\n record[index] = result;\n });\n return record;\n },\n onChildComplete: (_completed, _total, result, index) => ({ page: index, result })\n });\n tasks.forEach((task, index) => compound.addChild(task, index));\n compound.finalize();\n return compound;\n }\n /**\n * Gather with custom aggregation config.\n * (Formerly: from)\n */\n static gatherFrom(tasks, config) {\n const compound = new CompoundTask(config);\n tasks.forEach((task, index) => compound.addChild(task, index));\n compound.finalize();\n return compound;\n }\n /**\n * Resolve with the first successful child; abort the rest.\n * (Formerly: race)\n */\n static first(tasks) {\n let resolved = false;\n const compound = new CompoundTask({\n aggregate: (results) => results[0],\n failFast: false\n });\n compound[\"handleChildSuccess\"] = (child, result) => {\n if (!resolved) {\n resolved = true;\n for (const [otherChild] of compound[\"children\"]) {\n if (otherChild !== child) otherChild.abort(\"Race won by sibling\");\n }\n compound.resolve(result);\n }\n };\n tasks.forEach((task, index) => compound.addChild(task, index));\n compound.finalize();\n return compound;\n }\n}\nclass TaskSequence {\n constructor(parentTask) {\n this.parentTask = parentTask;\n this.activeChild = null;\n this.disposed = false;\n const origAbort = parentTask.abort.bind(parentTask);\n parentTask.abort = (reason) => {\n var _a;\n this.disposed = true;\n (_a = this.activeChild) == null ? void 0 : _a.abort(reason);\n origAbort(reason);\n };\n }\n /**\n * Execute a child Task and return its result as a Promise.\n *\n * If the parent task has been aborted, throws `TaskAbortedError` immediately.\n * If the parent task is aborted while the child is running, the child is aborted too.\n */\n run(factory) {\n return new Promise((resolve, reject) => {\n if (this.disposed || this.parentTask.state.stage !== TaskStage.Pending) {\n reject(new TaskAbortedError(\"Sequence aborted\"));\n return;\n }\n const child = factory();\n this.activeChild = child;\n child.wait(\n (result) => {\n this.activeChild = null;\n resolve(result);\n },\n (error) => {\n this.activeChild = null;\n if (error.type === \"abort\") {\n reject(new TaskAbortedError(error.reason));\n } else {\n reject(new TaskRejectedError(error.reason));\n }\n }\n );\n });\n }\n /**\n * Execute a child Task and return its result as a Promise,\n * forwarding the child's progress events to the parent task\n * through the provided mapper function.\n *\n * If the parent task has been aborted, throws `TaskAbortedError` immediately.\n * If the parent task is aborted while the child is running, the child is aborted too.\n */\n runWithProgress(factory, mapProgress) {\n return new Promise((resolve, reject) => {\n if (this.disposed || this.parentTask.state.stage !== TaskStage.Pending) {\n reject(new TaskAbortedError(\"Sequence aborted\"));\n return;\n }\n const child = factory();\n this.activeChild = child;\n child.onProgress((p) => {\n this.parentTask.progress(mapProgress(p));\n });\n child.wait(\n (result) => {\n this.activeChild = null;\n resolve(result);\n },\n (error) => {\n this.activeChild = null;\n if (error.type === \"abort\") {\n reject(new TaskAbortedError(error.reason));\n } else {\n reject(new TaskRejectedError(error.reason));\n }\n }\n );\n });\n }\n /**\n * Execute an async function body that uses `run()` / `runWithProgress()`,\n * automatically handling abort and error routing to the parent task.\n *\n * - If the body throws `TaskAbortedError`, it is silently ignored\n * (the parent task was already aborted via the abort override).\n * - If the body throws `TaskRejectedError` (from a child task rejection\n * via `run()` / `runWithProgress()`), its `.reason` is forwarded directly\n * to the parent task, bypassing `mapError`.\n * - Any other thrown error is mapped through `mapError` and used to\n * reject the parent task. This handles unexpected runtime exceptions\n * in the async body itself.\n * - On success, the body is responsible for calling `parentTask.resolve()`.\n */\n execute(fn, mapError) {\n fn().catch((err) => {\n if (err instanceof TaskAbortedError) return;\n if (err instanceof TaskRejectedError) {\n this.parentTask.reject(err.reason);\n return;\n }\n this.parentTask.reject(mapError(err));\n });\n }\n}\nfunction ignore() {\n}\nexport {\n AP_MODE_DOWN,\n AP_MODE_NORMAL,\n AP_MODE_ROLLOVER,\n AllLogger,\n AppearanceMode,\n CompoundTask,\n ConsoleLogger,\n FontCharset,\n LevelLogger,\n LogLevel,\n MatchFlag,\n MixedBlendMode,\n MixedStandardFont,\n MixedTextAlignment,\n NoopLogger,\n PDF_FORM_FIELD_FLAG,\n PDF_FORM_FIELD_TYPE,\n PdfActionType,\n PdfAnnotationBorderStyle,\n PdfAnnotationColorType,\n PdfAnnotationFlagName,\n PdfAnnotationFlags,\n PdfAnnotationIcon,\n PdfAnnotationLineEnding,\n PdfAnnotationObjectStatus,\n PdfAnnotationReplyType,\n PdfAnnotationState,\n PdfAnnotationStateModel,\n PdfAnnotationSubtype,\n PdfAnnotationSubtypeName,\n PdfBlendMode,\n PdfBomOrZwnbsp,\n PdfEngineFeature,\n PdfEngineOperation,\n PdfErrorCode,\n PdfNonCharacterFFFE,\n PdfNonCharacterFFFF,\n PdfPageFlattenFlag,\n PdfPageFlattenResult,\n PdfPageObjectType,\n PdfPermissionFlag,\n PdfSegmentObjectType,\n PdfSoftHyphenMarker,\n PdfStampFit,\n PdfStandardFont,\n PdfStandardFontFamily,\n PdfTaskHelper,\n PdfTextAlignment,\n PdfTrappedStatus,\n PdfUnwantedTextMarkers,\n PdfUnwantedTextRegex,\n PdfVerticalAlignment,\n PdfWordJoiner,\n PdfZeroWidthSpace,\n PdfZoomMode,\n PerfLogger,\n PermissionDeniedError,\n RenderPriority,\n Rotation,\n STANDARD_FONT_FAMILIES,\n Task,\n TaskAbortedError,\n TaskRejectedError,\n TaskSequence,\n TaskStage,\n blendModeLabel,\n blendModeSelectOptions,\n blendModeToCss,\n blendModeValues,\n boundingRect,\n boundingRectOrEmpty,\n buildPermissions,\n buildUserToDeviceMatrix,\n calculateAngle,\n calculateDegree,\n calculateRotatedRectAABB,\n calculateRotatedRectAABBAroundPoint,\n combinePdfColorWithAlpha,\n combineWebColorWithOpacity,\n compareSearchTarget,\n cssToBlendMode,\n cssToTextAlignment,\n dateToPdfDate,\n deserializeLogger,\n expandRect,\n extractPdfColor,\n extractWebOpacity,\n flagsToNames,\n getBlendModeInfo,\n getRectCenter,\n getStandardFontDescriptor,\n getTextAlignmentInfo,\n ignore,\n inferRotationCenterFromRects,\n isUuidV4,\n makeStandardFont,\n namesToFlags,\n normalizeAngle,\n pdfAlphaColorToWebAlphaColor,\n pdfAlphaToWebOpacity,\n pdfColorToWebColor,\n pdfDateToDate,\n quadToRect,\n rectEquals,\n rectFromPoints,\n rectToQuad,\n reduceBlendModes,\n reduceStandardFonts,\n reduceTextAlignments,\n restoreOffset,\n restorePosition,\n restoreRect,\n rotateAndTranslatePoint,\n rotatePointAround,\n rotatePosition,\n rotateRect,\n rotateVertices,\n scalePosition,\n scaleRect,\n serializeLogger,\n standardFontCss,\n standardFontCssProperties,\n standardFontFamily,\n standardFontFamilyLabel,\n standardFontFamilySelectOptions,\n standardFontIsBold,\n standardFontIsItalic,\n standardFontLabel,\n stripPdfUnwantedMarkers,\n swap,\n textAlignmentLabel,\n textAlignmentSelectOptions,\n textAlignmentToCss,\n toIntPos,\n toIntRect,\n toIntSize,\n transformPosition,\n transformRect,\n transformSize,\n uiBlendModeDisplay,\n unionFlags,\n uuidV4,\n webAlphaColorToPdfAlphaColor,\n webColorToPdfColor,\n webOpacityToPdfAlpha\n};\n//# sourceMappingURL=index.js.map\n","import { BasePlugin, PluginRegistry } from '@pdfmergy-embedpdf/core';\n\nimport { AttachmentCapability, AttachmentPluginConfig, AttachmentScope } from './types';\nimport {\n PdfAttachmentObject,\n PdfErrorCode,\n PdfErrorReason,\n PdfTaskHelper,\n Task,\n} from '@pdfmergy-embedpdf/models';\n\nexport class AttachmentPlugin extends BasePlugin<AttachmentPluginConfig, AttachmentCapability> {\n static readonly id = 'attachment' as const;\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: AttachmentPluginConfig): Promise<void> {}\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): AttachmentCapability {\n return {\n // Active document operations\n getAttachments: () => this.getAttachments(),\n downloadAttachment: (attachment) => this.downloadAttachment(attachment),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createAttachmentScope(documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createAttachmentScope(documentId: string): AttachmentScope {\n return {\n getAttachments: () => this.getAttachments(documentId),\n downloadAttachment: (attachment) => this.downloadAttachment(attachment, documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private downloadAttachment(\n attachment: PdfAttachmentObject,\n documentId?: string,\n ): Task<ArrayBuffer, PdfErrorReason> {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: `Document ${id} not found`,\n });\n }\n\n return this.engine.readAttachmentContent(coreDoc.document, attachment);\n }\n\n private getAttachments(documentId?: string): Task<PdfAttachmentObject[], PdfErrorReason> {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: `Document ${id} not found`,\n });\n }\n\n return this.engine.getAttachments(coreDoc.document);\n }\n}\n","import { useCapability, usePlugin } from '@pdfmergy-embedpdf/core/svelte';\nimport { AttachmentPlugin } from '@pdfmergy-embedpdf/plugin-attachment';\n\nexport const useAttachmentPlugin = () => usePlugin<AttachmentPlugin>(AttachmentPlugin.id);\nexport const useAttachmentCapability = () => useCapability<AttachmentPlugin>(AttachmentPlugin.id);\n"],"names":["PdfSoftHyphenMarker","PdfZeroWidthSpace","PdfWordJoiner","PdfBomOrZwnbsp","PdfNonCharacterFFFE","PdfNonCharacterFFFF","PdfUnwantedTextMarkers","PdfStandardFont","PdfTextAlignment","PdfBlendMode","PdfAnnotationFlagName","PdfPermissionFlag","TEXT_ALIGNMENT_INFOS","PdfStandardFontFamily","HELVETICA_DESC","STANDARD_FONT_DESCRIPTORS","familyStyleToId","BLEND_MODE_INFOS"],"mappings":";;AAEA,MAAM,aAAa,EAAE,MAAM;AAAA,EACzB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,WAAW,CAAA;AAAA,EACX,gBAAgB,CAAA;AAClB,CAAC;AAED,SAAS,UAAU,UAAU;AAC3B,QAAM,EAAE,SAAQ,IAAK;AACrB,QAAM,QAAQ,EAAE,MAAM,EAAE,QAAQ,MAAM,WAAW,MAAM,OAAO,IAAI,QAAQ,MAAM;AAAA,EAChF,CAAC,EAAC,CAAE;AACJ,MAAI,aAAa,MAAM;AACrB,WAAO;AAAA,EACT;AACA,QAAM,SAAS,SAAS,UAAU,QAAQ;AAC1C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,UAAU,QAAQ,YAAY;AAAA,EAChD;AACA,QAAM,SAAS;AACf,QAAM,YAAY;AAClB,QAAM,QAAQ,OAAO,MAAK;AAC1B,SAAO;AACT;AACA,SAAS,cAAc,UAAU;AAC/B,QAAM,IAAI,UAAU,QAAQ;AAC5B,QAAM,QAAQ,EAAE,MAAM;AAAA,IACpB,UAAU;AAAA,IACV,WAAW;AAAA,IACX,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