@pdfmergy-embedpdf/plugin-ai-manager 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 (49) 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 +897 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions.d.ts +33 -0
  7. package/dist/lib/ai-manager-plugin.d.ts +18 -0
  8. package/dist/lib/index.d.ts +8 -0
  9. package/dist/lib/manifest.d.ts +4 -0
  10. package/dist/lib/reducer.d.ts +5 -0
  11. package/dist/lib/types.d.ts +50 -0
  12. package/dist/preact/adapter.d.ts +1 -0
  13. package/dist/preact/core.d.ts +1 -0
  14. package/dist/preact/index.cjs +2 -0
  15. package/dist/preact/index.cjs.map +1 -0
  16. package/dist/preact/index.d.ts +1 -0
  17. package/dist/preact/index.js +1310 -0
  18. package/dist/preact/index.js.map +1 -0
  19. package/dist/react/adapter.d.ts +1 -0
  20. package/dist/react/core.d.ts +1 -0
  21. package/dist/react/index.cjs +2 -0
  22. package/dist/react/index.cjs.map +1 -0
  23. package/dist/react/index.d.ts +1 -0
  24. package/dist/react/index.js +1309 -0
  25. package/dist/react/index.js.map +1 -0
  26. package/dist/shared/hooks/index.d.ts +1 -0
  27. package/dist/shared/hooks/use-ai-manager.d.ts +11 -0
  28. package/dist/shared/index.d.ts +2 -0
  29. package/dist/shared-preact/hooks/index.d.ts +1 -0
  30. package/dist/shared-preact/hooks/use-ai-manager.d.ts +11 -0
  31. package/dist/shared-preact/index.d.ts +2 -0
  32. package/dist/shared-react/hooks/index.d.ts +1 -0
  33. package/dist/shared-react/hooks/use-ai-manager.d.ts +11 -0
  34. package/dist/shared-react/index.d.ts +2 -0
  35. package/dist/svelte/hooks/index.d.ts +1 -0
  36. package/dist/svelte/hooks/use-ai-manager.svelte.d.ts +11 -0
  37. package/dist/svelte/index.cjs +2 -0
  38. package/dist/svelte/index.cjs.map +1 -0
  39. package/dist/svelte/index.d.ts +2 -0
  40. package/dist/svelte/index.js +1299 -0
  41. package/dist/svelte/index.js.map +1 -0
  42. package/dist/vue/hooks/index.d.ts +1 -0
  43. package/dist/vue/hooks/use-ai-manager.d.ts +3 -0
  44. package/dist/vue/index.cjs +2 -0
  45. package/dist/vue/index.cjs.map +1 -0
  46. package/dist/vue/index.d.ts +2 -0
  47. package/dist/vue/index.js +1282 -0
  48. package/dist/vue/index.js.map +1 -0
  49. package/package.json +81 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../core/dist/svelte/index.js","../../../core/dist/index.js","../../src/lib/actions.ts","../../src/lib/ai-manager-plugin.ts","../../src/lib/manifest.ts","../../src/lib/reducer.ts","../../src/lib/index.ts","../../src/svelte/hooks/use-ai-manager.svelte.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","import { Action } from '@pdfmergy-embedpdf/core';\nimport { AiBackend } from '@pdfmergy-embedpdf/ai';\n\nexport const SET_BACKEND = 'AI_MANAGER/SET_BACKEND';\nexport const SET_MODEL_LOADED = 'AI_MANAGER/SET_MODEL_LOADED';\nexport const SET_MODEL_UNLOADED = 'AI_MANAGER/SET_MODEL_UNLOADED';\nexport const SET_MODEL_LOADING = 'AI_MANAGER/SET_MODEL_LOADING';\nexport const SET_MODEL_LOADING_DONE = 'AI_MANAGER/SET_MODEL_LOADING_DONE';\n\nexport interface SetBackendAction extends Action {\n type: typeof SET_BACKEND;\n payload: AiBackend | null;\n}\n\nexport interface SetModelLoadedAction extends Action {\n type: typeof SET_MODEL_LOADED;\n payload: string;\n}\n\nexport interface SetModelUnloadedAction extends Action {\n type: typeof SET_MODEL_UNLOADED;\n payload: string;\n}\n\nexport interface SetModelLoadingAction extends Action {\n type: typeof SET_MODEL_LOADING;\n payload: string;\n}\n\nexport interface SetModelLoadingDoneAction extends Action {\n type: typeof SET_MODEL_LOADING_DONE;\n payload: string;\n}\n\nexport type AiManagerAction =\n | SetBackendAction\n | SetModelLoadedAction\n | SetModelUnloadedAction\n | SetModelLoadingAction\n | SetModelLoadingDoneAction;\n\nexport function setBackend(backend: AiBackend | null): SetBackendAction {\n return { type: SET_BACKEND, payload: backend };\n}\n\nexport function setModelLoaded(modelId: string): SetModelLoadedAction {\n return { type: SET_MODEL_LOADED, payload: modelId };\n}\n\nexport function setModelUnloaded(modelId: string): SetModelUnloadedAction {\n return { type: SET_MODEL_UNLOADED, payload: modelId };\n}\n\nexport function setModelLoading(modelId: string): SetModelLoadingAction {\n return { type: SET_MODEL_LOADING, payload: modelId };\n}\n\nexport function setModelLoadingDone(modelId: string): SetModelLoadingDoneAction {\n return { type: SET_MODEL_LOADING_DONE, payload: modelId };\n}\n","import { BasePlugin, PluginRegistry } from '@pdfmergy-embedpdf/core';\nimport {\n AiRuntime,\n AiPipeline,\n AiTask,\n AiBackend,\n ModelLoadProgress,\n PipelineProgress,\n} from '@pdfmergy-embedpdf/ai';\nimport { AiManagerPluginConfig, AiManagerCapability, AiManagerState } from './types';\nimport {\n AiManagerAction,\n setBackend,\n setModelLoaded,\n setModelUnloaded,\n setModelLoading,\n setModelLoadingDone,\n} from './actions';\n\n/**\n * Service plugin that wraps the AiRuntime and exposes it\n * as an 'ai-manager' capability for other plugins to consume.\n *\n * Follows the same pattern as plugin-interaction-manager.\n */\nexport class AiManagerPlugin extends BasePlugin<\n AiManagerPluginConfig,\n AiManagerCapability,\n AiManagerState,\n AiManagerAction\n> {\n static readonly id = 'ai-manager' as const;\n\n private runtime!: AiRuntime;\n\n constructor(\n id: string,\n registry: PluginRegistry,\n private config: AiManagerPluginConfig,\n ) {\n super(id, registry);\n }\n\n async initialize(config: AiManagerPluginConfig): Promise<void> {\n this.runtime = config.runtime;\n if (!this.runtime) {\n throw new Error(\n '[AiManagerPlugin] A runtime instance is required. ' +\n 'Pass it via config: createPluginRegistration(AiManagerPluginPackage, { runtime: aiRuntime })',\n );\n }\n }\n\n protected buildCapability(): AiManagerCapability {\n return {\n run: <TInput, TOutput>(\n pipeline: AiPipeline<TInput, TOutput>,\n input: TInput,\n ): AiTask<TOutput, PipelineProgress> => {\n const task = this.runtime.run(pipeline, input);\n // Track loading state\n if (!this.runtime.isModelLoaded(pipeline.modelId)) {\n this.dispatch(setModelLoading(pipeline.modelId));\n task.wait(\n () => {\n this.dispatch(setModelLoaded(pipeline.modelId));\n this.dispatch(setBackend(this.runtime.getBackend()));\n },\n () => {\n this.dispatch(setModelLoadingDone(pipeline.modelId));\n },\n );\n }\n return task;\n },\n\n loadModel: (modelId: string): AiTask<void, ModelLoadProgress> => {\n this.dispatch(setModelLoading(modelId));\n const task = this.runtime.loadModel(modelId);\n task.wait(\n () => {\n this.dispatch(setModelLoaded(modelId));\n this.dispatch(setBackend(this.runtime.getBackend()));\n },\n () => {\n this.dispatch(setModelLoadingDone(modelId));\n },\n );\n return task;\n },\n\n unloadModel: (modelId: string): void => {\n this.runtime.unloadModel(modelId);\n this.dispatch(setModelUnloaded(modelId));\n },\n\n isModelLoaded: (modelId: string): boolean => {\n return this.runtime.isModelLoaded(modelId);\n },\n\n getBackend: (): AiBackend | null => {\n return this.runtime.getBackend();\n },\n\n getRuntime: (): AiRuntime => {\n return this.runtime;\n },\n };\n }\n\n async destroy(): Promise<void> {\n await this.runtime.destroy();\n }\n}\n","import { PluginManifest } from '@pdfmergy-embedpdf/core';\nimport { AiManagerPluginConfig } from './types';\nimport { AiRuntime } from '@pdfmergy-embedpdf/ai';\n\nexport const AI_MANAGER_PLUGIN_ID = 'ai-manager';\n\nexport const manifest: PluginManifest<AiManagerPluginConfig> = {\n id: AI_MANAGER_PLUGIN_ID,\n name: 'AI Manager Plugin',\n version: '1.0.0',\n provides: ['ai-manager'],\n requires: [],\n optional: [],\n defaultConfig: {\n // runtime must be provided by the user\n runtime: null as unknown as AiRuntime,\n },\n};\n","import { Reducer } from '@pdfmergy-embedpdf/core';\nimport { AiManagerState } from './types';\nimport {\n AiManagerAction,\n SET_BACKEND,\n SET_MODEL_LOADED,\n SET_MODEL_UNLOADED,\n SET_MODEL_LOADING,\n SET_MODEL_LOADING_DONE,\n} from './actions';\n\nexport const initialState: AiManagerState = {\n backend: null,\n loadedModels: [],\n loadingModels: [],\n};\n\nexport const reducer: Reducer<AiManagerState, AiManagerAction> = (state = initialState, action) => {\n switch (action.type) {\n case SET_BACKEND:\n return { ...state, backend: action.payload };\n\n case SET_MODEL_LOADING:\n return {\n ...state,\n loadingModels: state.loadingModels.includes(action.payload)\n ? state.loadingModels\n : [...state.loadingModels, action.payload],\n };\n\n case SET_MODEL_LOADING_DONE:\n return {\n ...state,\n loadingModels: state.loadingModels.filter((id) => id !== action.payload),\n };\n\n case SET_MODEL_LOADED:\n return {\n ...state,\n loadedModels: state.loadedModels.includes(action.payload)\n ? state.loadedModels\n : [...state.loadedModels, action.payload],\n loadingModels: state.loadingModels.filter((id) => id !== action.payload),\n };\n\n case SET_MODEL_UNLOADED:\n return {\n ...state,\n loadedModels: state.loadedModels.filter((id) => id !== action.payload),\n };\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@pdfmergy-embedpdf/core';\n\nimport { AiManagerPlugin } from './ai-manager-plugin';\nimport { manifest, AI_MANAGER_PLUGIN_ID } from './manifest';\nimport { AiManagerPluginConfig, AiManagerState } from './types';\nimport { reducer, initialState } from './reducer';\nimport { AiManagerAction } from './actions';\n\nexport const AiManagerPluginPackage: PluginPackage<\n AiManagerPlugin,\n AiManagerPluginConfig,\n AiManagerState,\n AiManagerAction\n> = {\n manifest,\n create: (registry, config) => new AiManagerPlugin(AI_MANAGER_PLUGIN_ID, registry, config),\n reducer,\n initialState,\n};\n\nexport * from './ai-manager-plugin';\nexport * from './types';\nexport * from './manifest';\n","import { useCapability, usePlugin } from '@pdfmergy-embedpdf/core/svelte';\nimport { AiManagerPlugin } from '@pdfmergy-embedpdf/plugin-ai-manager';\n\nexport const useAiManagerPlugin = () => usePlugin<AiManagerPlugin>(AiManagerPlugin.id);\nexport const useAiManagerCapability = () => useCapability<AiManagerPlugin>(AiManagerPlugin.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,OAAO,IAAI,QAAQ,MAAM;AAAA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,QAAQ,cAAc,WAAW;AACjG,UAAQ,OAAO,MAAA;AAAA,IACb,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,SAAS,OAAO,QAAA;AAAA,IAErC,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,MAAM,cAAc,SAAS,OAAO,OAAO,IACtD,MAAM,gBACN,CAAC,GAAG,MAAM,eAAe,OAAO,OAAO;AAAA,MAAA;AAAA,IAG/C,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,MAAM,cAAc,OAAO,CAAC,OAAO,OAAO,OAAO,OAAO;AAAA,MAAA;AAAA,IAG3E,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,cAAc,MAAM,aAAa,SAAS,OAAO,OAAO,IACpD,MAAM,eACN,CAAC,GAAG,MAAM,cAAc,OAAO,OAAO;AAAA,QAC1C,eAAe,MAAM,cAAc,OAAO,CAAC,OAAO,OAAO,OAAO,OAAO;AAAA,MAAA;AAAA,IAG3E,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,cAAc,MAAM,aAAa,OAAO,CAAC,OAAO,OAAO,OAAO,OAAO;AAAA,MAAA;AAAA,IAGzE;AACE,aAAO;AAAA,EAAA;AAEb;AC9CO,MAAM,yBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,gBAAgB,sBAAsB,UAAU,MAAM;AAAA,EACxF;AAAA,EACA;AACF;ACfa,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;AACxE,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;"}
@@ -0,0 +1 @@
1
+ export * from './use-ai-manager';
@@ -0,0 +1,3 @@
1
+ import { AiManagerPlugin } from '../../lib/index.ts';
2
+ export declare const useAiManagerPlugin: () => import('@pdfmergy-embedpdf/core/vue').PluginState<AiManagerPlugin>;
3
+ export declare const useAiManagerCapability: () => import('@pdfmergy-embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').AiManagerCapability>>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),i=Symbol("pdfKey");const t=Object.freeze(["­","​","⁠","\ufeff","￾","￿"]);new RegExp(`[${t.join("")}]`,"g");var o=(e=>(e[e.Unknown=-1]="Unknown",e[e.Courier=0]="Courier",e[e.Courier_Bold=1]="Courier_Bold",e[e.Courier_BoldOblique=2]="Courier_BoldOblique",e[e.Courier_Oblique=3]="Courier_Oblique",e[e.Helvetica=4]="Helvetica",e[e.Helvetica_Bold=5]="Helvetica_Bold",e[e.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",e[e.Helvetica_Oblique=7]="Helvetica_Oblique",e[e.Times_Roman=8]="Times_Roman",e[e.Times_Bold=9]="Times_Bold",e[e.Times_BoldItalic=10]="Times_BoldItalic",e[e.Times_Italic=11]="Times_Italic",e[e.Symbol=12]="Symbol",e[e.ZapfDingbats=13]="ZapfDingbats",e))(o||{}),l=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(l||{}),s=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(s||{});const r=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(r).reduce((e,[i,t])=>(e[t]=Number(i),e),{});var n=(e=>(e[e.Print=4]="Print",e[e.ModifyContents=8]="ModifyContents",e[e.CopyContents=16]="CopyContents",e[e.ModifyAnnotations=32]="ModifyAnnotations",e[e.FillForms=256]="FillForms",e[e.ExtractForAccessibility=512]="ExtractForAccessibility",e[e.AssembleDocument=1024]="AssembleDocument",e[e.PrintHighQuality=2048]="PrintHighQuality",e[e.AllowAll=3900]="AllowAll",e))(n||{});const a=Object.freeze([{id:l.Left,label:"Left",css:"left"},{id:l.Center,label:"Center",css:"center"},{id:l.Right,label:"Right",css:"right"}]);a.reduce((e,i)=>(e[i.id]=i,e),{}),a.reduce((e,i)=>(e[i.css]=i.id,e),{}),a.map(e=>({value:e.id,label:e.label}));var c=(e=>(e.Courier="Courier",e.Helvetica="Helvetica",e.Times="Times",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats",e.Unknown="Unknown",e))(c||{});o.Helvetica;const u={id:o.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},d=Object.freeze([{id:o.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:o.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:o.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:o.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},u,{id:o.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:o.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:o.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:o.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:o.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:o.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:o.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:o.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:o.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]);d.reduce((e,i)=>(e[i.id]=i,e),{});const m=new Map;for(const K of d)m.set(`${K.family}_${K.bold}_${K.italic}`,K.id);Object.values(c).filter(e=>"Unknown"!==e).map(e=>({value:e,label:e})),new Set(d.map(e=>e.family));const b=Object.freeze([{id:s.Normal,label:"Normal",css:"normal"},{id:s.Multiply,label:"Multiply",css:"multiply"},{id:s.Screen,label:"Screen",css:"screen"},{id:s.Overlay,label:"Overlay",css:"overlay"},{id:s.Darken,label:"Darken",css:"darken"},{id:s.Lighten,label:"Lighten",css:"lighten"},{id:s.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:s.ColorBurn,label:"Color Burn",css:"color-burn"},{id:s.HardLight,label:"Hard Light",css:"hard-light"},{id:s.SoftLight,label:"Soft Light",css:"soft-light"},{id:s.Difference,label:"Difference",css:"difference"},{id:s.Exclusion,label:"Exclusion",css:"exclusion"},{id:s.Hue,label:"Hue",css:"hue"},{id:s.Saturation,label:"Saturation",css:"saturation"},{id:s.Color,label:"Color",css:"color"},{id:s.Luminosity,label:"Luminosity",css:"luminosity"}]);function h(t){const{registry:o}=function(){const t=e.inject(i);if(!t)throw new Error("useRegistry must be used inside <EmbedPDF>");return t}(),l=e.shallowRef(null),s=e.ref(!0),r=e.ref(new Promise(()=>{})),n=()=>{var e;if(!o.value)return;const i=o.value.getPlugin(t);if(!i)throw new Error(`Plugin ${t} not found`);l.value=i,s.value=!1,r.value=(null==(e=i.ready)?void 0:e.call(i))??Promise.resolve()};return e.onMounted(n),e.watch(o,n),{plugin:l,isLoading:s,ready:r}}b.reduce((e,i)=>(e[i.id]=i,e),{}),b.reduce((e,i)=>(e[i.css]=i.id,e),{}),b.map(e=>({value:e.id,label:e.label})),b.map(e=>e.id),n.Print,n.ModifyContents,n.CopyContents,n.ModifyAnnotations,n.FillForms,n.ExtractForAccessibility,n.AssembleDocument,n.PrintHighQuality,n.Print,n.ModifyContents,n.CopyContents,n.ModifyAnnotations,n.FillForms,n.ExtractForAccessibility,n.AssembleDocument,n.PrintHighQuality,n.Print,n.ModifyContents,n.CopyContents,n.ModifyAnnotations,n.FillForms,n.ExtractForAccessibility,n.AssembleDocument,n.PrintHighQuality;const f=Object.freeze(["­","​","⁠","\ufeff","￾","￿"]);new RegExp(`[${f.join("")}]`,"g");var y=(e=>(e[e.Unknown=-1]="Unknown",e[e.Courier=0]="Courier",e[e.Courier_Bold=1]="Courier_Bold",e[e.Courier_BoldOblique=2]="Courier_BoldOblique",e[e.Courier_Oblique=3]="Courier_Oblique",e[e.Helvetica=4]="Helvetica",e[e.Helvetica_Bold=5]="Helvetica_Bold",e[e.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",e[e.Helvetica_Oblique=7]="Helvetica_Oblique",e[e.Times_Roman=8]="Times_Roman",e[e.Times_Bold=9]="Times_Bold",e[e.Times_BoldItalic=10]="Times_BoldItalic",e[e.Times_Italic=11]="Times_Italic",e[e.Symbol=12]="Symbol",e[e.ZapfDingbats=13]="ZapfDingbats",e))(y||{}),g=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(g||{}),p=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(p||{});const C=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(C).reduce((e,[i,t])=>(e[t]=Number(i),e),{});var S=(e=>(e[e.Print=4]="Print",e[e.ModifyContents=8]="ModifyContents",e[e.CopyContents=16]="CopyContents",e[e.ModifyAnnotations=32]="ModifyAnnotations",e[e.FillForms=256]="FillForms",e[e.ExtractForAccessibility=512]="ExtractForAccessibility",e[e.AssembleDocument=1024]="AssembleDocument",e[e.PrintHighQuality=2048]="PrintHighQuality",e[e.AllowAll=3900]="AllowAll",e))(S||{});class v extends Error{constructor(e,i){super(`Permission denied. Required: ${e.map(e=>S[e]).join(", ")}`),this.requiredFlags=e,this.currentPermissions=i,this.name="PermissionDeniedError"}}const D=Object.freeze([{id:g.Left,label:"Left",css:"left"},{id:g.Center,label:"Center",css:"center"},{id:g.Right,label:"Right",css:"right"}]);D.reduce((e,i)=>(e[i.id]=i,e),{}),D.reduce((e,i)=>(e[i.css]=i.id,e),{}),D.map(e=>({value:e.id,label:e.label}));var A=(e=>(e.Courier="Courier",e.Helvetica="Helvetica",e.Times="Times",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats",e.Unknown="Unknown",e))(A||{});y.Helvetica;const T={id:y.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},_=Object.freeze([{id:y.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:y.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:y.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:y.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},T,{id:y.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:y.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:y.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:y.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:y.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:y.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:y.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:y.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:y.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]);_.reduce((e,i)=>(e[i.id]=i,e),{});const H=new Map;for(const K of _)H.set(`${K.family}_${K.bold}_${K.italic}`,K.id);Object.values(A).filter(e=>"Unknown"!==e).map(e=>({value:e,label:e})),new Set(_.map(e=>e.family));const O=Object.freeze([{id:p.Normal,label:"Normal",css:"normal"},{id:p.Multiply,label:"Multiply",css:"multiply"},{id:p.Screen,label:"Screen",css:"screen"},{id:p.Overlay,label:"Overlay",css:"overlay"},{id:p.Darken,label:"Darken",css:"darken"},{id:p.Lighten,label:"Lighten",css:"lighten"},{id:p.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:p.ColorBurn,label:"Color Burn",css:"color-burn"},{id:p.HardLight,label:"Hard Light",css:"hard-light"},{id:p.SoftLight,label:"Soft Light",css:"soft-light"},{id:p.Difference,label:"Difference",css:"difference"},{id:p.Exclusion,label:"Exclusion",css:"exclusion"},{id:p.Hue,label:"Hue",css:"hue"},{id:p.Saturation,label:"Saturation",css:"saturation"},{id:p.Color,label:"Color",css:"color"},{id:p.Luminosity,label:"Luminosity",css:"luminosity"}]);O.reduce((e,i)=>(e[i.id]=i,e),{}),O.reduce((e,i)=>(e[i.css]=i.id,e),{}),O.map(e=>({value:e.id,label:e.label})),O.map(e=>e.id);S.Print,S.ModifyContents,S.CopyContents,S.ModifyAnnotations,S.FillForms,S.ExtractForAccessibility,S.AssembleDocument,S.PrintHighQuality;const M=[S.Print,S.ModifyContents,S.CopyContents,S.ModifyAnnotations,S.FillForms,S.ExtractForAccessibility,S.AssembleDocument,S.PrintHighQuality],L={[S.Print]:"print",[S.ModifyContents]:"modifyContents",[S.CopyContents]:"copyContents",[S.ModifyAnnotations]:"modifyAnnotations",[S.FillForms]:"fillForms",[S.ExtractForAccessibility]:"extractForAccessibility",[S.AssembleDocument]:"assembleDocument",[S.PrintHighQuality]:"printHighQuality"};function F(e,i){if(!e)return;if(i in e)return e[i];const t=L[i];return t&&t in e?e[t]:void 0}function w(e,i,t){var o;const l=e.documents[i],s=null==l?void 0:l.permissions,r=e.globalPermissions,n=(null==(o=null==l?void 0:l.document)?void 0:o.permissions)??S.AllowAll,a=F(null==s?void 0:s.overrides,t);if(void 0!==a)return a;const c=F(null==r?void 0:r.overrides,t);if(void 0!==c)return c;return!((null==s?void 0:s.enforceDocumentPermissions)??(null==r?void 0:r.enforceDocumentPermissions)??!0)||0!==(n&t)}function B(e,i){return M.reduce((t,o)=>w(e,i,o)?t|o:t,0)}class E{constructor(e,i){if(this.id=e,this.registry=i,this.cooldownActions={},this.debouncedTimeouts={},this.unsubscribeFromState=null,this.unsubscribeFromCoreStore=null,this.unsubscribeFromStartLoadingDocument=null,this.unsubscribeFromSetDocumentLoaded=null,this.unsubscribeFromCloseDocument=null,this.unsubscribeFromSetScale=null,this.unsubscribeFromSetRotation=null,e!==this.constructor.id)throw new Error(`Plugin ID mismatch: ${e} !== ${this.constructor.id}`);this.engine=this.registry.getEngine(),this.logger=this.registry.getLogger(),this.coreStore=this.registry.getStore(),this.pluginStore=this.coreStore.getPluginStore(this.id),this.unsubscribeFromState=this.pluginStore.subscribeToState((e,i,t)=>{this.onStoreUpdated(t,i)}),this.unsubscribeFromCoreStore=this.coreStore.subscribe((e,i,t)=>{this.onCoreStoreUpdated(t,i),i.core.activeDocumentId!==t.core.activeDocumentId&&this.onActiveDocumentChanged(t.core.activeDocumentId,i.core.activeDocumentId)}),this.unsubscribeFromStartLoadingDocument=this.coreStore.onAction("START_LOADING_DOCUMENT",e=>{this.onDocumentLoadingStarted(e.payload.documentId)}),this.unsubscribeFromSetDocumentLoaded=this.coreStore.onAction("SET_DOCUMENT_LOADED",e=>{this.onDocumentLoaded(e.payload.documentId)}),this.unsubscribeFromCloseDocument=this.coreStore.onAction("CLOSE_DOCUMENT",e=>{this.onDocumentClosed(e.payload.documentId)}),this.unsubscribeFromSetScale=this.coreStore.onAction("SET_SCALE",(e,i)=>{const t=e.payload.documentId??i.core.activeDocumentId;t&&this.onScaleChanged(t,e.payload.scale)}),this.unsubscribeFromSetRotation=this.coreStore.onAction("SET_ROTATION",(e,i)=>{const t=e.payload.documentId??i.core.activeDocumentId;t&&this.onRotationChanged(t,e.payload.rotation)}),this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.readyResolve()}provides(){if(!this._capability){const e=this.buildCapability();this._capability=Object.freeze(e)}return this._capability}get state(){return this.pluginStore.getState()}get coreState(){return this.coreStore.getState()}getState(){return this.pluginStore.getState()}getCoreState(){return this.coreStore.getState()}dispatchCoreAction(e){return this.coreStore.dispatchToCore(e)}dispatchToAllPlugins(e){return this.coreStore.dispatch(e)}dispatch(e){return this.pluginStore.dispatch(e)}cooldownDispatch(e,i=100){const t=Date.now();return t-(this.cooldownActions[e.type]||0)>=i&&(this.cooldownActions[e.type]=t,this.dispatch(e),!0)}debouncedDispatch(e,i=100){const t=e.type;this.debouncedTimeouts[t]&&clearTimeout(this.debouncedTimeouts[t]),this.debouncedTimeouts[t]=setTimeout(()=>{this.dispatch(e),delete this.debouncedTimeouts[t]},i)}cancelDebouncedDispatch(e){this.debouncedTimeouts[e]&&(clearTimeout(this.debouncedTimeouts[e]),delete this.debouncedTimeouts[e])}subscribe(e){return this.pluginStore.subscribeToState(e)}subscribeToCoreStore(e){return this.coreStore.subscribe(e)}onStoreUpdated(e,i){}onCoreStoreUpdated(e,i){}onDocumentLoadingStarted(e){}onDocumentLoaded(e){}onDocumentClosed(e){}onActiveDocumentChanged(e,i){}onScaleChanged(e,i){}onRotationChanged(e,i){}destroy(){Object.values(this.debouncedTimeouts).forEach(e=>{clearTimeout(e)}),this.debouncedTimeouts={},this.unsubscribeFromState&&(this.unsubscribeFromState(),this.unsubscribeFromState=null),this.unsubscribeFromCoreStore&&(this.unsubscribeFromCoreStore(),this.unsubscribeFromCoreStore=null),this.unsubscribeFromStartLoadingDocument&&(this.unsubscribeFromStartLoadingDocument(),this.unsubscribeFromStartLoadingDocument=null),this.unsubscribeFromSetDocumentLoaded&&(this.unsubscribeFromSetDocumentLoaded(),this.unsubscribeFromSetDocumentLoaded=null),this.unsubscribeFromCloseDocument&&(this.unsubscribeFromCloseDocument(),this.unsubscribeFromCloseDocument=null),this.unsubscribeFromSetScale&&(this.unsubscribeFromSetScale(),this.unsubscribeFromSetScale=null),this.unsubscribeFromSetRotation&&(this.unsubscribeFromSetRotation(),this.unsubscribeFromSetRotation=null)}ready(){return this.readyPromise}markReady(){this.readyResolve()}resetReady(){this.readyPromise=new Promise(e=>{this.readyResolve=e})}getActiveDocumentId(){const e=this.coreState.core.activeDocumentId;if(!e)throw new Error("No active document");return e}getActiveDocumentIdOrNull(){return this.coreState.core.activeDocumentId}getCoreDocument(e){const i=e??this.getActiveDocumentIdOrNull();return i?this.coreState.core.documents[i]??null:null}getCoreDocumentOrThrow(e){const i=this.getCoreDocument(e);if(!i)throw new Error(`Document not found: ${e??"active"}`);return i}getDocumentPermissions(e){const i=e??this.coreState.core.activeDocumentId;return i?B(this.coreState.core,i):S.AllowAll}checkPermission(e,...i){const t=e??this.coreState.core.activeDocumentId;return!t||i.every(e=>w(this.coreState.core,t,e))}requirePermission(e,...i){const t=e??this.coreState.core.activeDocumentId;if(!t)return;const o=[];for(const l of i)w(this.coreState.core,t,l)||o.push(l);if(o.length>0){const e=B(this.coreState.core,t);throw new v(o,e)}}}const P="AI_MANAGER/SET_BACKEND",R="AI_MANAGER/SET_MODEL_LOADED",I="AI_MANAGER/SET_MODEL_UNLOADED",N="AI_MANAGER/SET_MODEL_LOADING",q="AI_MANAGER/SET_MODEL_LOADING_DONE";function k(e){return{type:P,payload:e}}function x(e){return{type:R,payload:e}}function j(e){return{type:N,payload:e}}function U(e){return{type:q,payload:e}}const Z=class extends E{constructor(e,i,t){super(e,i),this.config=t}async initialize(e){if(this.runtime=e.runtime,!this.runtime)throw new Error("[AiManagerPlugin] A runtime instance is required. Pass it via config: createPluginRegistration(AiManagerPluginPackage, { runtime: aiRuntime })")}buildCapability(){return{run:(e,i)=>{const t=this.runtime.run(e,i);return this.runtime.isModelLoaded(e.modelId)||(this.dispatch(j(e.modelId)),t.wait(()=>{this.dispatch(x(e.modelId)),this.dispatch(k(this.runtime.getBackend()))},()=>{this.dispatch(U(e.modelId))})),t},loadModel:e=>{this.dispatch(j(e));const i=this.runtime.loadModel(e);return i.wait(()=>{this.dispatch(x(e)),this.dispatch(k(this.runtime.getBackend()))},()=>{this.dispatch(U(e))}),i},unloadModel:e=>{this.runtime.unloadModel(e),this.dispatch(function(e){return{type:I,payload:e}}(e))},isModelLoaded:e=>this.runtime.isModelLoaded(e),getBackend:()=>this.runtime.getBackend(),getRuntime:()=>this.runtime}}async destroy(){await this.runtime.destroy()}};Z.id="ai-manager";let $=Z;const z="ai-manager",Q={id:z,name:"AI Manager Plugin",version:"1.0.0",provides:["ai-manager"],requires:[],optional:[],defaultConfig:{runtime:null}},G={backend:null,loadedModels:[],loadingModels:[]},V={manifest:Q,create:(e,i)=>new $(z,e,i),reducer:(e=G,i)=>{switch(i.type){case P:return{...e,backend:i.payload};case N:return{...e,loadingModels:e.loadingModels.includes(i.payload)?e.loadingModels:[...e.loadingModels,i.payload]};case q:return{...e,loadingModels:e.loadingModels.filter(e=>e!==i.payload)};case R:return{...e,loadedModels:e.loadedModels.includes(i.payload)?e.loadedModels:[...e.loadedModels,i.payload],loadingModels:e.loadingModels.filter(e=>e!==i.payload)};case I:return{...e,loadedModels:e.loadedModels.filter(e=>e!==i.payload)};default:return e}},initialState:G};exports.AI_MANAGER_PLUGIN_ID=z,exports.AiManagerPlugin=$,exports.AiManagerPluginPackage=V,exports.manifest=Q,exports.useAiManagerCapability=()=>function(i){const{plugin:t,isLoading:o,ready:l}=h(i);return{provides:e.computed(()=>{if(!t.value)return null;if(!t.value.provides)throw new Error(`Plugin ${i} does not implement provides()`);return t.value.provides()}),isLoading:o,ready:l}}($.id),exports.useAiManagerPlugin=()=>h($.id);
2
+ //# sourceMappingURL=index.cjs.map