{"version":3,"file":"index.mjs","sources":["../src/ckeditor5-blazor-error.ts","../src/shared/are-maps-equal.ts","../src/shared/async-registry.ts","../src/shared/debounce.ts","../src/shared/is-empty-object.ts","../src/shared/once.ts","../src/shared/make-destroy-idempotent.ts","../src/shared/map-object-values.ts","../src/shared/shallow-equal.ts","../src/shared/wait-for.ts","../src/shared/wait-for-dom-ready.ts","../src/shared/wait-for-interactive-attribute.ts","../src/elements/editor/utils/assign-editor-roots-to-config.ts","../src/elements/editor/utils/get-editor-roots-values.ts","../src/elements/editor/utils/is-single-root-editor.ts","../src/elements/editor/utils/load-editor-constructor.ts","../src/elements/editor/custom-editor-plugins.ts","../src/elements/editor/utils/load-editor-plugins.ts","../src/elements/editor/utils/load-editor-translations.ts","../src/elements/editor/utils/normalize-custom-translations.ts","../src/elements/editor/utils/normalize-editor-language.ts","../src/elements/editor/utils/query-all-editor-editables.ts","../src/elements/editor/utils/query-all-editor-ids.ts","../src/elements/editor/utils/resolve-editor-config-elements-references.ts","../src/elements/editor/utils/resolve-editor-config-translations.ts","../src/elements/editor/utils/set-editor-editable-height.ts","../src/elements/context/contexts-registry.ts","../src/elements/context/context.ts","../src/elements/editor/editors-registry.ts","../src/elements/editable.ts","../src/elements/editor/plugins/dispatch-editor-roots-change-event.ts","../src/elements/editor/plugins/sync-editor-with-input.ts","../src/elements/editor/editor.ts","../src/elements/ui-part.ts","../src/elements/ensure-editor-elements-registered.ts","../src/interop/create-context-blazor-interop.ts","../src/interop/utils/create-editor-value-sync.ts","../src/interop/utils/sync-root-attributes.ts","../src/interop/create-editable-blazor-interop.ts","../src/interop/create-editor-blazor-interop.ts","../src/interop/create-ui-part-blazor-interop.ts"],"sourcesContent":["/**\n * Custom error class for CKEditor5 Blazor-related errors.\n */\nexport class CKEditor5BlazorError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CKEditor5BlazorError';\n }\n}\n","/**\n * Compares two Map structures for equality based on their contents.\n * The function checks if the maps have the same size, contain the exact same keys,\n * and have strictly equal values (using shallow comparison).\n *\n * @param map1 - The first map to compare (can be null).\n * @param map2 - The second map to compare.\n * @returns Returns `true` if the maps are identical in terms of keys and values, otherwise `false`.\n */\nexport function areMapsEqual(map1: Map | null, map2: Map): boolean {\n if (!map1 || map1.size !== map2.size) {\n return false;\n }\n\n for (const [key, value] of map1) {\n if (!map2.has(key) || map2.get(key) !== value) {\n return false;\n }\n }\n\n return true;\n}\n","import { areMapsEqual } from './are-maps-equal';\n\n/**\n * Generic async registry for objects with an async destroy method.\n * Provides a way to register, unregister, and execute callbacks on objects by ID.\n */\nexport class AsyncRegistry {\n /**\n * Map of registered items.\n */\n private readonly items = new Map();\n\n /**\n * Map of initialization errors for items that failed to register.\n */\n private readonly initializationErrors = new Map();\n\n /**\n * Map of pending callbacks waiting for items to be registered or fail.\n */\n private readonly pendingCallbacks = new Map>();\n\n /**\n * Set of watchers that observe changes to the registry.\n */\n private readonly watchers = new Set>();\n\n /**\n * Batch nesting depth. When > 0, watcher notifications are deferred.\n */\n private batchDepth = 0;\n\n /**\n * Snapshot of the last state dispatched to watchers, used for change detection.\n */\n private lastNotifiedItems: Map | null = null;\n\n private lastNotifiedErrors: Map | null = null;\n\n /**\n * Executes a function on an item.\n * If the item is not yet registered, it will wait for it to be registered.\n *\n * @param id The ID of the item.\n * @param onSuccess The function to execute.\n * @param onError Optional error callback.\n * @returns A promise that resolves with the result of the function.\n */\n execute(\n id: RegistryId | null,\n onSuccess: (item: E) => R,\n onError?: (error: any) => void,\n ): Promise> {\n const item = this.items.get(id);\n const error = this.initializationErrors.get(id);\n\n // If error exists and callback provided, invoke it immediately.\n if (error) {\n onError?.(error);\n return Promise.reject(error);\n }\n\n // If item exists, invoke callback immediately (synchronously via Promise.resolve).\n if (item) {\n return Promise.resolve(onSuccess(item as E));\n }\n\n // Item not ready yet - queue the callbacks.\n return new Promise((resolve, reject) => {\n const pending = this.getPendingCallbacks(id);\n\n pending.success.push(async (item: T) => {\n resolve(await onSuccess(item as E));\n });\n\n if (onError) {\n pending.error.push(onError);\n }\n else {\n pending.error.push(reject);\n }\n });\n }\n\n /**\n * Reactively binds a mount/unmount lifecycle to a single registry item.\n *\n * @param id The ID of the item to observe.\n * @param onMount Function executed when the item mounts.\n * @returns A function that stops observing and immediately runs any pending cleanup.\n */\n mountEffect(\n id: RegistryId | null,\n onMount: (item: E) => (() => void) | void,\n ): () => void {\n let cleanup: VoidFunction | void;\n let mountedItem: T | undefined;\n let unmounted = false;\n\n const unwatch = this.watch((items) => {\n const item = items.get(id);\n\n if (item === mountedItem) {\n return;\n }\n\n cleanup?.();\n cleanup = undefined;\n mountedItem = item;\n\n if (!item) {\n return;\n }\n\n try {\n const newCleanup = onMount(item as E);\n\n if (unmounted) {\n newCleanup?.();\n unwatch();\n }\n else {\n cleanup = newCleanup;\n }\n }\n catch (err) {\n /* v8 ignore start -- @preserve */\n console.error(err);\n throw err;\n /* v8 ignore end */\n }\n });\n\n return () => {\n unmounted = true;\n\n if (mountedItem) {\n unwatch();\n cleanup?.();\n cleanup = undefined;\n }\n };\n }\n\n /**\n * Registers an item.\n *\n * @param id The ID of the item.\n * @param item The item instance.\n */\n register(id: RegistryId | null, item: T): void {\n this.batch(() => {\n if (this.items.has(id)) {\n throw new Error(`Item with ID \"${id}\" is already registered.`);\n }\n\n this.resetErrors(id);\n this.items.set(id, item);\n\n // Execute all pending callbacks for this item (synchronously).\n const pending = this.pendingCallbacks.get(id);\n\n if (pending) {\n pending.success.forEach(callback => callback(item));\n this.pendingCallbacks.delete(id);\n }\n\n // Register the first item as the default item (null ID).\n if (this.items.size === 1 && id !== null) {\n this.register(null, item);\n }\n });\n }\n\n /**\n * Registers an error for an item.\n *\n * @param id The ID of the item.\n * @param error The error to register.\n */\n error(id: RegistryId | null, error: any): void {\n this.batch(() => {\n this.items.delete(id);\n this.initializationErrors.set(id, error);\n\n // Execute all pending error callbacks for this item.\n const pending = this.pendingCallbacks.get(id);\n\n if (pending) {\n pending.error.forEach(callback => callback(error));\n this.pendingCallbacks.delete(id);\n }\n\n // Set as default error if this is the first error and no items exist.\n if (this.initializationErrors.size === 1 && !this.items.size) {\n this.error(null, error);\n }\n });\n }\n\n /**\n * Resets errors for an item.\n *\n * @param id The ID of the item.\n */\n resetErrors(id: RegistryId | null): void {\n const { initializationErrors } = this;\n\n // Clear default error if it's the same as the specific error.\n if (initializationErrors.has(null) && initializationErrors.get(null) === initializationErrors.get(id)) {\n initializationErrors.delete(null);\n }\n\n initializationErrors.delete(id);\n }\n\n /**\n * Un-registers an item.\n *\n * @param id The ID of the item.\n * @param resetPendingCallbacks If true resets pending callbacks.\n */\n unregister(id: RegistryId | null, resetPendingCallbacks: boolean = true): void {\n this.batch(() => {\n // If unregistering the default item, clear it.\n if (id && this.items.get(null) === this.items.get(id)) {\n this.unregister(null, false);\n }\n\n this.items.delete(id);\n\n if (resetPendingCallbacks) {\n this.pendingCallbacks.delete(id);\n }\n\n this.resetErrors(id);\n });\n }\n\n /**\n * Gets all registered items.\n *\n * @returns An array of all registered items.\n */\n getItems(): T[] {\n return Array.from(this.items.values());\n }\n\n /**\n * Returns single registered item.\n *\n * @returns Registered item.\n */\n getItem(id: RegistryId | null): T | undefined {\n return this.items.get(id);\n }\n\n /**\n * Checks if an item with the given ID is registered.\n *\n * @param id The ID of the item.\n * @returns `true` if the item is registered, `false` otherwise.\n */\n hasItem(id: RegistryId | null): boolean {\n return this.items.has(id);\n }\n\n /**\n * Gets a promise that resolves with the item instance for the given ID.\n * If the item is not registered yet, it will wait for it to be registered.\n *\n * @param id The ID of the item.\n * @returns A promise that resolves with the item instance.\n */\n waitFor(id: RegistryId | null): Promise {\n return new Promise((resolve, reject) => {\n // `execute()` passes an already registered error to `reject` and also returns it as a rejected promise.\n // That promise is handled here, otherwise it'd be reported as an unhandled rejection.\n this.execute(id, resolve as (value: E) => void, reject).catch(() => {});\n });\n }\n\n /**\n * Destroys all registered items and clears the registry.\n * This will call the `destroy` method on each item.\n */\n async destroyAll() {\n const promises = (\n Array\n .from(new Set(this.items.values()))\n .map(item => item.destroy())\n );\n\n this.items.clear();\n this.pendingCallbacks.clear();\n\n await Promise.all(promises);\n\n this.flushWatchers();\n }\n\n /**\n * Destroys all registered items, removes all watchers and clears initialization errors.\n */\n async reset() {\n await this.destroyAll();\n this.watchers.clear();\n this.initializationErrors.clear();\n }\n\n /**\n * Executes a callback while deferring all watcher notifications.\n * A single notification is fired synchronously after the callback returns,\n * but only if the registry actually changed.\n *\n * Batches can be nested — watchers are notified only when the outermost\n * batch completes.\n *\n * @param fn The callback to execute.\n * @returns The return value of the callback.\n */\n batch(fn: () => R): R {\n this.batchDepth++;\n\n try {\n return fn();\n }\n finally {\n this.batchDepth--;\n\n if (this.batchDepth === 0) {\n this.flushWatchers();\n }\n }\n }\n\n /**\n * Registers a watcher that will be called whenever the registry changes.\n *\n * @param watcher The watcher function to register.\n * @returns A function to unregister the watcher.\n */\n watch(watcher: RegistryWatcher): () => void {\n this.watchers.add(watcher);\n\n // Call the watcher immediately with the current state.\n watcher(\n new Map(this.items),\n new Map(this.initializationErrors),\n );\n\n return this.unwatch.bind(this, watcher);\n }\n\n /**\n * Un-registers a watcher.\n *\n * @param watcher The watcher function to unregister.\n */\n unwatch(watcher: RegistryWatcher): void {\n this.watchers.delete(watcher);\n }\n\n /**\n * Immediately dispatches the current state to all watchers if it changed.\n */\n private flushWatchers(): void {\n if (\n areMapsEqual(this.lastNotifiedItems, this.items)\n && areMapsEqual(this.lastNotifiedErrors, this.initializationErrors)\n ) {\n return;\n }\n\n this.lastNotifiedItems = new Map(this.items);\n this.lastNotifiedErrors = new Map(this.initializationErrors);\n\n this.watchers.forEach(watcher => watcher(\n new Map(this.items),\n new Map(this.initializationErrors),\n ));\n }\n\n /**\n * Gets or creates pending callbacks for a specific ID.\n *\n * @param id The ID of the item.\n * @returns The pending callbacks structure.\n */\n private getPendingCallbacks(id: RegistryId | null): PendingCallbacks {\n let pending = this.pendingCallbacks.get(id);\n\n if (!pending) {\n pending = { success: [], error: [] };\n this.pendingCallbacks.set(id, pending);\n }\n\n return pending;\n }\n}\n\n/**\n * Interface for objects that can be destroyed.\n */\nexport type Destructible = {\n destroy: () => Promise;\n};\n\n/**\n * Identifier of the registry item.\n */\ntype RegistryId = string;\n\n/**\n * Structure holding pending success and error callbacks for an item.\n */\ntype PendingCallbacks = {\n success: Array<(item: T) => void>;\n error: Array<(error: Error) => void>;\n};\n\n/**\n * Callback type for watching registry changes.\n */\ntype RegistryWatcher = (\n items: Map,\n errors: Map,\n) => void;\n","export function debounce any>(\n delay: number,\n callback: T,\n): (...args: Parameters) => void {\n let timeoutId: ReturnType | null = null;\n\n return (...args: Parameters): void => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n callback(...args);\n }, delay);\n };\n}\n","export function isEmptyObject(obj: Record): boolean {\n return Object.keys(obj).length === 0 && obj.constructor === Object;\n}\n","export function once any>(fn: T): T {\n let called = false;\n let result: ReturnType;\n\n return function (this: any, ...args: Parameters): ReturnType {\n if (!called) {\n called = true;\n result = fn.apply(this, args);\n }\n return result;\n } as T;\n}\n","import type { Destructible } from './async-registry';\n\nimport { once } from './once';\n\n/**\n * Makes `destroy()` of the instance idempotent: the first call destroys the instance,\n * subsequent calls return the same promise.\n *\n * Neither `Editor#destroy()` nor `Context#destroy()` guard against being called twice, and it happens\n * when a context and its editors are being disconnected in the same DOM update. Depending on the order of\n * elements, the editor component and the context (which destroys all its editors) both destroy the editor.\n *\n * @param instance The instance to patch.\n * @returns The same instance.\n */\nexport function makeDestroyIdempotent(instance: T): T {\n instance.destroy = once(instance.destroy.bind(instance));\n\n return instance;\n}\n","/**\n * Maps the values of an object using a provided mapper function.\n *\n * @param obj The object whose values will be mapped.\n * @param mapper A function that takes a value and its key, and returns a new value.\n * @template T The type of the original values in the object.\n * @template U The type of the new values in the object.\n * @returns A new object with the same keys as the original, but with values transformed by\n */\nexport function mapObjectValues(\n obj: Record,\n mapper: (value: T, key: string) => U,\n): Record {\n const mappedEntries = Object\n .entries(obj)\n .map(([key, value]) => [key, mapper(value, key)] as const);\n\n return Object.fromEntries(mappedEntries);\n}\n","/**\n * Performs a shallow comparison of two objects.\n *\n * @param objA - The first object to compare.\n * @param objB - The second object to compare.\n * @returns True if the objects are shallowly equal, false otherwise.\n */\nexport function shallowEqual>(\n objA: T,\n objB: T,\n): boolean {\n if (objA === objB) {\n return true;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n for (const key of keysA) {\n if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {\n return false;\n }\n }\n\n return true;\n}\n","import type { CanBePromise } from '../types';\n\n/**\n * Waits for the provided callback to succeed. The callback is executed multiple times until it succeeds or the timeout is reached.\n * It's executed immediately and then with a delay defined by the `retry` option.\n *\n * @param callback The callback to execute.\n * @param config Configuration for the function.\n * @param config.timeOutAfter The maximum time to wait for the callback to succeed, in milliseconds. Default is 500ms.\n * @param config.retryAfter The time to wait between retries, in milliseconds. Default is 100ms.\n * @returns A promise that resolves when the callback succeeds.\n */\nexport function waitFor(\n callback: () => CanBePromise,\n {\n timeOutAfter = 500,\n retryAfter = 100,\n }: WaitForConfig = {},\n): Promise {\n return new Promise((resolve, reject) => {\n const startTime = Date.now();\n let lastError: Error | null = null;\n\n const timeoutTimerId = setTimeout(() => {\n reject(lastError ?? new Error('Timeout'));\n }, timeOutAfter);\n\n const tick = async () => {\n try {\n const result = await callback();\n clearTimeout(timeoutTimerId);\n resolve(result);\n }\n catch (err: any) {\n lastError = err;\n\n if (Date.now() - startTime > timeOutAfter) {\n reject(err);\n }\n else {\n setTimeout(tick, retryAfter);\n }\n }\n };\n\n void tick();\n });\n}\n\n/**\n * Configuration for the `waitFor` function.\n */\nexport type WaitForConfig = {\n timeOutAfter?: number;\n retryAfter?: number;\n};\n","/**\n * Returns a promise that resolves when the DOM is fully loaded and ready.\n */\nexport function waitForDOMReady(): Promise {\n return new Promise((resolve) => {\n switch (document.readyState) {\n case 'loading':\n document.addEventListener('DOMContentLoaded', () => resolve(), { once: true });\n break;\n\n case 'interactive':\n case 'complete':\n setTimeout(resolve, 0);\n break;\n\n default:\n console.warn('Unexpected document.readyState:', document.readyState);\n setTimeout(resolve, 0);\n }\n });\n}\n","/**\n * Waits for the 'data-cke-interactive' attribute to be added to the element.\n */\nexport function waitForInteractiveAttribute(element: HTMLElement): WaitForInteractiveResult {\n if (element.hasAttribute('data-cke-interactive')) {\n return { promise: Promise.resolve(), disconnect: () => {} };\n }\n\n let observer: MutationObserver;\n\n const promise = new Promise((resolve) => {\n observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (\n mutation.type === 'attributes'\n && mutation.attributeName === 'data-cke-interactive'\n && element.hasAttribute('data-cke-interactive')\n ) {\n observer.disconnect();\n resolve();\n break;\n }\n }\n });\n\n observer.observe(element, { attributes: true });\n });\n\n return {\n promise,\n disconnect: () => observer?.disconnect(),\n };\n}\n\n/**\n * Marks the given element as interactive by adding the 'data-cke-interactive' attribute.\n *\n * @param element - The HTML element to mark as interactive.\n */\nexport function markElementAsInteractive(element: HTMLElement) {\n element.setAttribute('data-cke-interactive', 'true');\n}\n\n/**\n * Result of waiting for the interactive attribute.\n */\nexport type WaitForInteractiveResult = {\n promise: Promise;\n disconnect: () => void;\n};\n","import type { EditorRelaxedConstructor } from '../types/editor-relaxed-constructor.type';\nimport type { EditableItem } from './query-all-editor-editables';\nimport type { EditorConfig } from 'ckeditor5';\n\n/**\n * Assigns DOM elements and initial data to the editor configuration in a way that is compatible\n * with the specific editor type.\n *\n * Roots with `element: null` (pending roots not yet in the DOM) contribute only `initialData`\n * and are skipped for element assignment.\n *\n * @param Editor Constructor of the editor used to determine the location of element config entry.\n * @param editables Map of editable items (element + content) keyed by root name.\n * @param config Config of the editor.\n * @returns The updated configuration object.\n */\nexport function assignEditorRootsToConfig(\n Editor: EditorRelaxedConstructor,\n editables: Record,\n config: C,\n): C {\n const isClassicEditor = !Editor.editorName || Editor.editorName === 'ClassicEditor';\n const allRootsKeys = new Set([\n ...Object.keys(editables),\n ...Object.keys(config.roots ?? {}),\n ]);\n\n const rootsConfig = Array.from(allRootsKeys).reduce((acc, rootKey) => ({\n ...acc,\n [rootKey]: {\n /* v8 ignore next 1 */\n ...config.roots?.[rootKey],\n ...rootKey === 'main' ? config.root : {},\n\n /* v8 ignore next 12 */\n ...rootKey in editables\n ? {\n ...editables[rootKey]!.content !== null && {\n initialData: editables[rootKey]!.content,\n },\n modelElement: editables[rootKey]!.modelElement || '$root',\n ...!isClassicEditor && editables[rootKey]!.element !== null && {\n element: editables[rootKey]!.element,\n },\n }\n : {},\n },\n }), { ...config.roots || {} });\n\n const mappedConfig: C = {\n ...config,\n roots: rootsConfig,\n ...isClassicEditor && editables['main']?.element && {\n attachTo: editables['main'].element,\n },\n };\n\n delete mappedConfig.root;\n\n return mappedConfig;\n}\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Gets values of all editor roots.\n *\n * @param editor The editor instance.\n * @returns A record where keys are root names and values are root HTML strings.\n */\nexport function getEditorRootsValues(editor: Editor): Record {\n return Array\n .from(editor.model.document.getRoots())\n .reduce>((acc, root) => {\n if (root.rootName === '$graveyard') {\n return acc;\n }\n\n acc[root.rootName] = editor.getData({ rootName: root.rootName });\n\n return acc;\n }, Object.create(null));\n}\n","import type { EditorType } from '../typings';\n\n/**\n * Checks if the given editor type is one of the single editing-like editors.\n *\n * @param editorType - The type of the editor to check.\n * @returns `true` if the editor type is 'inline', 'classic', or 'balloon', otherwise `false`.\n */\nexport function isSingleRootEditor(editorType: EditorType): boolean {\n return ['inline', 'classic', 'balloon', 'decoupled'].includes(editorType);\n}\n","import type { EditorType } from '../typings';\n\nimport { CKEditor5BlazorError } from '../../../ckeditor5-blazor-error';\n\n/**\n * Returns the constructor for the specified CKEditor5 editor type.\n *\n * @param type - The type of the editor to load.\n * @returns A promise that resolves to the editor constructor.\n */\nexport async function loadEditorConstructor(type: EditorType) {\n const PKG = await import('ckeditor5');\n\n const editorMap = {\n inline: PKG.InlineEditor,\n balloon: PKG.BalloonEditor,\n classic: PKG.ClassicEditor,\n decoupled: PKG.DecoupledEditor,\n multiroot: PKG.MultiRootEditor,\n } as const;\n\n const EditorConstructor = editorMap[type];\n\n if (!EditorConstructor) {\n throw new CKEditor5BlazorError(`Unsupported editor type: ${type}`);\n }\n\n return EditorConstructor;\n}\n","import type { CanBePromise } from '../../types';\nimport type { PluginConstructor } from 'ckeditor5';\n\nimport { CKEditor5BlazorError } from '../../ckeditor5-blazor-error';\n\ntype PluginReader = () => CanBePromise;\n\n/**\n * Registry for custom CKEditor plugins.\n * Allows registration and retrieval of custom plugins that can be used alongside built-in plugins.\n */\nexport class CustomEditorPluginsRegistry {\n static readonly the = new CustomEditorPluginsRegistry();\n\n /**\n * Map of registered custom plugins.\n */\n private readonly plugins = new Map();\n\n /**\n * Private constructor to enforce singleton pattern.\n */\n private constructor() {}\n\n /**\n * Registers a custom plugin for the CKEditor.\n *\n * @param name The name of the plugin.\n * @param reader The plugin reader function that returns the plugin constructor.\n * @returns A function to unregister the plugin.\n */\n register(name: string, reader: PluginReader): () => void {\n if (this.plugins.has(name)) {\n throw new CKEditor5BlazorError(`Plugin with name \"${name}\" is already registered.`);\n }\n\n this.plugins.set(name, reader);\n\n return this.unregister.bind(this, name);\n }\n\n /**\n * Removes a custom plugin by its name.\n *\n * @param name The name of the plugin to unregister.\n * @throws Will throw an error if the plugin is not registered.\n */\n unregister(name: string): void {\n if (!this.plugins.has(name)) {\n throw new CKEditor5BlazorError(`Plugin with name \"${name}\" is not registered.`);\n }\n\n this.plugins.delete(name);\n }\n\n /**\n * Removes all custom editor plugins.\n * This is useful for cleanup in tests or when reloading plugins.\n */\n unregisterAll(): void {\n this.plugins.clear();\n }\n\n /**\n * Retrieves a custom plugin by its name.\n *\n * @param name The name of the plugin.\n * @returns The plugin constructor or undefined if not found.\n */\n async get(name: string): Promise {\n const reader = this.plugins.get(name);\n\n return reader?.();\n }\n\n /**\n * Checks if a plugin with the given name is registered.\n *\n * @param name The name of the plugin.\n * @returns `true` if the plugin is registered, `false` otherwise.\n */\n has(name: string): boolean {\n return this.plugins.has(name);\n }\n}\n","import type { EditorPlugin, EditorPluginImport } from '../typings';\nimport type { PluginConstructor } from 'ckeditor5';\n\nimport { CKEditor5BlazorError } from '../../../ckeditor5-blazor-error';\nimport { CustomEditorPluginsRegistry } from '../custom-editor-plugins';\n\n/**\n * Loads CKEditor plugins from base and premium packages.\n * First tries to load from the base 'ckeditor5' package, then falls back to 'ckeditor5-premium-features'.\n * Supports custom import descriptors ({ $import: { name, path } }) for plugins loaded from custom modules.\n *\n * @param plugins - Array of plugin names or import descriptors to load\n * @returns Promise that resolves to an array of loaded Plugin instances\n * @throws Error if a plugin is not found in either package\n */\nexport async function loadEditorPlugins(plugins: EditorPlugin[]): Promise {\n const basePackage = await import('ckeditor5');\n let premiumPackage: Record | null = null;\n\n const loaders = plugins.map(async (plugin) => {\n // Handle custom import descriptor: { $import: { name, path } }\n if (isPluginImport(plugin)) {\n const { name, path } = plugin.$import;\n\n const mod = await import(/* @vite-ignore */ path);\n const typedMod = mod as Record;\n const ctor = (Object.prototype.hasOwnProperty.call(typedMod, name) ? typedMod[name] : undefined)\n ?? (Object.prototype.hasOwnProperty.call(typedMod, 'default') ? typedMod['default'] : undefined);\n\n if (!ctor) {\n throw new CKEditor5BlazorError(`Plugin \"${name}\" not found in module \"${path}\".`);\n }\n\n return ctor as PluginConstructor;\n }\n\n // If the plugin is not found in the base package, try custom plugins.\n const customPlugin = await CustomEditorPluginsRegistry.the.get(plugin);\n\n if (customPlugin) {\n return customPlugin;\n }\n\n // If not found, try to load from the base package.\n const { [plugin]: basePkgImport } = basePackage as Record;\n\n if (basePkgImport) {\n return basePkgImport as PluginConstructor;\n }\n\n // Plugin not found in base package, try premium package.\n /* v8 ignore start -- @preserve */\n if (!premiumPackage) {\n try {\n premiumPackage = await import('ckeditor5-premium-features');\n }\n catch (error) {\n console.error(`Failed to load premium package: ${error}`);\n throw new CKEditor5BlazorError(`Plugin \"${plugin}\" not found in base package and failed to load premium package.`);\n }\n }\n /* v8 ignore end */\n\n const { [plugin]: premiumPkgImport } = premiumPackage || {};\n\n if (premiumPkgImport) {\n return premiumPkgImport as PluginConstructor;\n }\n\n // Plugin not found in either package, throw an error.\n throw new CKEditor5BlazorError(`Plugin \"${plugin}\" not found in base or premium packages.`);\n });\n\n return {\n loadedPlugins: await Promise.all(loaders),\n hasPremium: !!premiumPackage,\n };\n}\n\n/**\n * Returns `true` when the plugin entry is an import descriptor (`{ $import: ... }`).\n */\nfunction isPluginImport(plugin: EditorPlugin): plugin is EditorPluginImport {\n return typeof plugin === 'object' && plugin !== null && '$import' in plugin;\n}\n\n/**\n * Type representing the loaded plugins and whether premium features are available.\n */\ntype LoadedPlugins = {\n loadedPlugins: PluginConstructor[];\n hasPremium: boolean;\n};\n","/**\n * Loads all required translations for the editor based on the language configuration.\n *\n * @param language - The language configuration object containing UI and content language codes.\n * @param language.ui - The UI language code.\n * @param language.content - The content language code.\n * @param hasPremium - Whether premium features are enabled and premium translations should be loaded.\n * @returns A promise that resolves to an array of loaded translation objects.\n */\nexport async function loadAllEditorTranslations(\n language: { ui: string; content: string; },\n hasPremium: boolean,\n) {\n const translations = [language.ui, language.content];\n const loadedTranslations = await Promise.all(\n [\n loadEditorPkgTranslations('ckeditor5', translations),\n\n /* v8 ignore next -- @preserve */\n hasPremium && loadEditorPkgTranslations('ckeditor5-premium-features', translations),\n ].filter(pkg => !!pkg),\n )\n .then(translations => translations.flat());\n\n return loadedTranslations;\n}\n\n/**\n * Loads the editor translations for the given languages.\n *\n * Make sure this function is properly compiled and bundled in self hosted environments!\n *\n * @param pkg - The package to load translations from ('ckeditor5' or 'ckeditor5-premium-features').\n * @param translations - The list of language codes to load translations for.\n * @returns A promise that resolves to an array of loaded translation packs.\n */\nasync function loadEditorPkgTranslations(\n pkg: EditorPkgName,\n translations: string[],\n) {\n return await Promise.all(\n translations\n .filter(lang => lang !== 'en') // 'en' is the default language, no need to load it.\n .map(async (lang) => {\n const pack = await loadEditorTranslation(pkg, lang);\n\n /* v8 ignore next -- @preserve */\n return pack?.default ?? pack;\n })\n .filter(Boolean),\n );\n}\n\n/**\n * Type representing the package name for CKEditor 5.\n */\ntype EditorPkgName = 'ckeditor5' | 'ckeditor5-premium-features';\n\n/**\n * Load translation for CKEditor 5\n * @param pkg - Package type: 'ckeditor5' or 'premium'\n * @param lang - Language code (e.g., 'pl', 'en', 'de')\n * @returns Translation object or null if failed\n */\nasync function loadEditorTranslation(pkg: EditorPkgName, lang: string): Promise {\n try {\n /* v8 ignore next if -- @preserve */\n if (pkg === 'ckeditor5') {\n switch (lang) {\n case 'af': return await import('ckeditor5/translations/af.js');\n case 'ar': return await import('ckeditor5/translations/ar.js');\n case 'ast': return await import('ckeditor5/translations/ast.js');\n case 'az': return await import('ckeditor5/translations/az.js');\n case 'bg': return await import('ckeditor5/translations/bg.js');\n case 'bn': return await import('ckeditor5/translations/bn.js');\n case 'bs': return await import('ckeditor5/translations/bs.js');\n case 'ca': return await import('ckeditor5/translations/ca.js');\n case 'cs': return await import('ckeditor5/translations/cs.js');\n case 'da': return await import('ckeditor5/translations/da.js');\n case 'de': return await import('ckeditor5/translations/de.js');\n case 'de-ch': return await import('ckeditor5/translations/de-ch.js');\n case 'el': return await import('ckeditor5/translations/el.js');\n case 'en': return await import('ckeditor5/translations/en.js');\n case 'en-au': return await import('ckeditor5/translations/en-au.js');\n case 'en-gb': return await import('ckeditor5/translations/en-gb.js');\n case 'eo': return await import('ckeditor5/translations/eo.js');\n case 'es': return await import('ckeditor5/translations/es.js');\n case 'es-co': return await import('ckeditor5/translations/es-co.js');\n case 'et': return await import('ckeditor5/translations/et.js');\n case 'eu': return await import('ckeditor5/translations/eu.js');\n case 'fa': return await import('ckeditor5/translations/fa.js');\n case 'fi': return await import('ckeditor5/translations/fi.js');\n case 'fr': return await import('ckeditor5/translations/fr.js');\n case 'gl': return await import('ckeditor5/translations/gl.js');\n case 'gu': return await import('ckeditor5/translations/gu.js');\n case 'he': return await import('ckeditor5/translations/he.js');\n case 'hi': return await import('ckeditor5/translations/hi.js');\n case 'hr': return await import('ckeditor5/translations/hr.js');\n case 'hu': return await import('ckeditor5/translations/hu.js');\n case 'hy': return await import('ckeditor5/translations/hy.js');\n case 'id': return await import('ckeditor5/translations/id.js');\n case 'it': return await import('ckeditor5/translations/it.js');\n case 'ja': return await import('ckeditor5/translations/ja.js');\n case 'jv': return await import('ckeditor5/translations/jv.js');\n case 'kk': return await import('ckeditor5/translations/kk.js');\n case 'km': return await import('ckeditor5/translations/km.js');\n case 'kn': return await import('ckeditor5/translations/kn.js');\n case 'ko': return await import('ckeditor5/translations/ko.js');\n case 'ku': return await import('ckeditor5/translations/ku.js');\n case 'lt': return await import('ckeditor5/translations/lt.js');\n case 'lv': return await import('ckeditor5/translations/lv.js');\n case 'ms': return await import('ckeditor5/translations/ms.js');\n case 'nb': return await import('ckeditor5/translations/nb.js');\n case 'ne': return await import('ckeditor5/translations/ne.js');\n case 'nl': return await import('ckeditor5/translations/nl.js');\n case 'no': return await import('ckeditor5/translations/no.js');\n case 'oc': return await import('ckeditor5/translations/oc.js');\n case 'pl': return await import('ckeditor5/translations/pl.js');\n case 'pt': return await import('ckeditor5/translations/pt.js');\n case 'pt-br': return await import('ckeditor5/translations/pt-br.js');\n case 'ro': return await import('ckeditor5/translations/ro.js');\n case 'ru': return await import('ckeditor5/translations/ru.js');\n case 'si': return await import('ckeditor5/translations/si.js');\n case 'sk': return await import('ckeditor5/translations/sk.js');\n case 'sl': return await import('ckeditor5/translations/sl.js');\n case 'sq': return await import('ckeditor5/translations/sq.js');\n case 'sr': return await import('ckeditor5/translations/sr.js');\n case 'sr-latn': return await import('ckeditor5/translations/sr-latn.js');\n case 'sv': return await import('ckeditor5/translations/sv.js');\n case 'th': return await import('ckeditor5/translations/th.js');\n case 'tk': return await import('ckeditor5/translations/tk.js');\n case 'tr': return await import('ckeditor5/translations/tr.js');\n case 'tt': return await import('ckeditor5/translations/tt.js');\n case 'ug': return await import('ckeditor5/translations/ug.js');\n case 'uk': return await import('ckeditor5/translations/uk.js');\n case 'ur': return await import('ckeditor5/translations/ur.js');\n case 'uz': return await import('ckeditor5/translations/uz.js');\n case 'vi': return await import('ckeditor5/translations/vi.js');\n case 'zh': return await import('ckeditor5/translations/zh.js');\n case 'zh-cn': return await import('ckeditor5/translations/zh-cn.js');\n default:\n console.warn(`Language ${lang} not found in ckeditor5 translations`);\n return null;\n }\n }\n else {\n // Premium features translations\n switch (lang) {\n case 'af': return await import('ckeditor5-premium-features/translations/af.js');\n case 'ar': return await import('ckeditor5-premium-features/translations/ar.js');\n case 'ast': return await import('ckeditor5-premium-features/translations/ast.js');\n case 'az': return await import('ckeditor5-premium-features/translations/az.js');\n case 'bg': return await import('ckeditor5-premium-features/translations/bg.js');\n case 'bn': return await import('ckeditor5-premium-features/translations/bn.js');\n case 'bs': return await import('ckeditor5-premium-features/translations/bs.js');\n case 'ca': return await import('ckeditor5-premium-features/translations/ca.js');\n case 'cs': return await import('ckeditor5-premium-features/translations/cs.js');\n case 'da': return await import('ckeditor5-premium-features/translations/da.js');\n case 'de': return await import('ckeditor5-premium-features/translations/de.js');\n case 'de-ch': return await import('ckeditor5-premium-features/translations/de-ch.js');\n case 'el': return await import('ckeditor5-premium-features/translations/el.js');\n case 'en': return await import('ckeditor5-premium-features/translations/en.js');\n case 'en-au': return await import('ckeditor5-premium-features/translations/en-au.js');\n case 'en-gb': return await import('ckeditor5-premium-features/translations/en-gb.js');\n case 'eo': return await import('ckeditor5-premium-features/translations/eo.js');\n case 'es': return await import('ckeditor5-premium-features/translations/es.js');\n case 'es-co': return await import('ckeditor5-premium-features/translations/es-co.js');\n case 'et': return await import('ckeditor5-premium-features/translations/et.js');\n case 'eu': return await import('ckeditor5-premium-features/translations/eu.js');\n case 'fa': return await import('ckeditor5-premium-features/translations/fa.js');\n case 'fi': return await import('ckeditor5-premium-features/translations/fi.js');\n case 'fr': return await import('ckeditor5-premium-features/translations/fr.js');\n case 'gl': return await import('ckeditor5-premium-features/translations/gl.js');\n case 'gu': return await import('ckeditor5-premium-features/translations/gu.js');\n case 'he': return await import('ckeditor5-premium-features/translations/he.js');\n case 'hi': return await import('ckeditor5-premium-features/translations/hi.js');\n case 'hr': return await import('ckeditor5-premium-features/translations/hr.js');\n case 'hu': return await import('ckeditor5-premium-features/translations/hu.js');\n case 'hy': return await import('ckeditor5-premium-features/translations/hy.js');\n case 'id': return await import('ckeditor5-premium-features/translations/id.js');\n case 'it': return await import('ckeditor5-premium-features/translations/it.js');\n case 'ja': return await import('ckeditor5-premium-features/translations/ja.js');\n case 'jv': return await import('ckeditor5-premium-features/translations/jv.js');\n case 'kk': return await import('ckeditor5-premium-features/translations/kk.js');\n case 'km': return await import('ckeditor5-premium-features/translations/km.js');\n case 'kn': return await import('ckeditor5-premium-features/translations/kn.js');\n case 'ko': return await import('ckeditor5-premium-features/translations/ko.js');\n case 'ku': return await import('ckeditor5-premium-features/translations/ku.js');\n case 'lt': return await import('ckeditor5-premium-features/translations/lt.js');\n case 'lv': return await import('ckeditor5-premium-features/translations/lv.js');\n case 'ms': return await import('ckeditor5-premium-features/translations/ms.js');\n case 'nb': return await import('ckeditor5-premium-features/translations/nb.js');\n case 'ne': return await import('ckeditor5-premium-features/translations/ne.js');\n case 'nl': return await import('ckeditor5-premium-features/translations/nl.js');\n case 'no': return await import('ckeditor5-premium-features/translations/no.js');\n case 'oc': return await import('ckeditor5-premium-features/translations/oc.js');\n case 'pl': return await import('ckeditor5-premium-features/translations/pl.js');\n case 'pt': return await import('ckeditor5-premium-features/translations/pt.js');\n case 'pt-br': return await import('ckeditor5-premium-features/translations/pt-br.js');\n case 'ro': return await import('ckeditor5-premium-features/translations/ro.js');\n case 'ru': return await import('ckeditor5-premium-features/translations/ru.js');\n case 'si': return await import('ckeditor5-premium-features/translations/si.js');\n case 'sk': return await import('ckeditor5-premium-features/translations/sk.js');\n case 'sl': return await import('ckeditor5-premium-features/translations/sl.js');\n case 'sq': return await import('ckeditor5-premium-features/translations/sq.js');\n case 'sr': return await import('ckeditor5-premium-features/translations/sr.js');\n case 'sr-latn': return await import('ckeditor5-premium-features/translations/sr-latn.js');\n case 'sv': return await import('ckeditor5-premium-features/translations/sv.js');\n case 'th': return await import('ckeditor5-premium-features/translations/th.js');\n case 'tk': return await import('ckeditor5-premium-features/translations/tk.js');\n case 'tr': return await import('ckeditor5-premium-features/translations/tr.js');\n case 'tt': return await import('ckeditor5-premium-features/translations/tt.js');\n case 'ug': return await import('ckeditor5-premium-features/translations/ug.js');\n case 'uk': return await import('ckeditor5-premium-features/translations/uk.js');\n case 'ur': return await import('ckeditor5-premium-features/translations/ur.js');\n case 'uz': return await import('ckeditor5-premium-features/translations/uz.js');\n case 'vi': return await import('ckeditor5-premium-features/translations/vi.js');\n case 'zh': return await import('ckeditor5-premium-features/translations/zh.js');\n case 'zh-cn': return await import('ckeditor5-premium-features/translations/zh-cn.js');\n default:\n console.warn(`Language ${lang} not found in premium translations`);\n return await import('ckeditor5-premium-features/translations/en.js'); // fallback to English\n }\n }\n }\n /* v8 ignore start -- @preserve */\n catch (error) {\n console.error(`Failed to load translation for ${pkg}/${lang}:`, error);\n return null;\n }\n /* v8 ignore stop -- @preserve */\n}\n","import type { EditorCustomTranslationsDictionary } from '../typings';\nimport type { Translations } from 'ckeditor5';\n\nimport { mapObjectValues } from '../../../shared';\n\n/**\n * This function takes a custom translations object and maps it to the format expected by CKEditor5.\n * Each translation dictionary is wrapped in an object with a `dictionary` key.\n *\n * @param translations - The custom translations to normalize.\n * @returns A normalized translations object suitable for CKEditor5.\n */\nexport function normalizeCustomTranslations(translations: EditorCustomTranslationsDictionary): Translations {\n return mapObjectValues(translations, dictionary => ({\n dictionary,\n }));\n}\n","import type { EditorLanguage } from '../typings';\n\n/**\n * Normalize editor language into object.\n *\n * @param lang Editor language.\n * @returns Language object.\n */\nexport function normalizeEditorLanguage(lang: EditorLanguage | string): EditorLanguage {\n if (!lang) {\n return {\n ui: 'en',\n content: 'en',\n };\n }\n\n if (typeof lang === 'string') {\n return {\n ui: lang,\n content: lang,\n };\n }\n\n return lang;\n}\n","import type { EditorId } from '../typings';\n\n/**\n * Queries all editable elements within a specific editor instance. It picks\n * initial values from actually rendered elements or from the editor container's\n * `data-cke-content` attribute, whichever is available.\n *\n * Roots present in the editor container's content but without a matching\n * `cke5-editable` element yet are included with `element: null` — these are\n * \"pending\" roots that haven't been attached to the DOM yet.\n *\n * @param editorId The ID of the editor to query.\n * @returns An object mapping root names to their corresponding elements and content.\n */\nexport function queryAllEditorEditables(editorId: EditorId): Record {\n const acc = Array\n .from(document.querySelectorAll(`cke5-editable[data-cke-editor-id=\"${editorId}\"]`))\n .reduce>((acc, element) => {\n const rootName = element.getAttribute('data-cke-root-name')!;\n const modelElement = element.getAttribute('data-cke-root-model-element-name') || null;\n\n acc[rootName] = {\n element: element.querySelector('[data-cke-editable-content]'),\n content: element.getAttribute('data-cke-content'),\n modelElement,\n };\n\n return acc;\n }, Object.create(null));\n\n const rootEditorElement = document.querySelector(`cke5-editor[data-cke-editor-id=\"${editorId}\"]`);\n\n /* v8 ignore next -- @preserve */\n if (!rootEditorElement) {\n return acc;\n }\n\n // v8 ignore next -- @preserve\n const editorContent: Record = JSON.parse(rootEditorElement.getAttribute('data-cke-content')!) ?? {};\n const classicMainElement = document.querySelector(`#${editorId}_editor`);\n const rootEditorModelElement = rootEditorElement.getAttribute('data-cke-root-model-element-name');\n\n if ('main' in acc) {\n acc['main'].modelElement ??= rootEditorModelElement;\n }\n else if (classicMainElement) {\n acc['main'] = {\n element: classicMainElement,\n content: editorContent['main'] || '',\n modelElement: rootEditorModelElement,\n };\n }\n\n for (const [rootName, rootContent] of Object.entries(editorContent)) {\n if (acc[rootName]) {\n // Editable element is already present — fill content from editor level if the editable didn't provide its own.\n acc[rootName] = {\n ...acc[rootName],\n content: acc[rootName].content ?? rootContent,\n modelElement: acc[rootName].modelElement ?? rootEditorModelElement,\n };\n }\n else {\n // Root has server-provided content but its editable element hasn't been attached to the DOM yet.\n acc[rootName] = {\n element: null,\n content: rootContent,\n modelElement: rootEditorModelElement,\n };\n }\n }\n\n return acc;\n}\n\n/**\n * Type representing an editable item within an editor.\n * `element` is null when the root's DOM element hasn't appeared yet (pending root).\n */\nexport type EditableItem = {\n element: HTMLElement | null;\n content: string | null;\n modelElement: string | null;\n};\n","/**\n * Queries all CKEditor 5 editor IDs present in the document.\n */\nexport function queryAllEditorIds(): string[] {\n return Array\n .from(document.querySelectorAll('cke5-editor'))\n .map(element => element.getAttribute('data-cke-editor-id'))\n .filter((id): id is string => id !== null);\n}\n","/**\n * Resolves element references in configuration object.\n * Looks for objects with { $element: \"selector\" } format and replaces them with actual DOM elements.\n *\n * @param obj - Configuration object to process\n * @returns Processed configuration object with resolved element references\n */\nexport function resolveEditorConfigElementReferences(obj: T): T {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveEditorConfigElementReferences(item)) as T;\n }\n\n const anyObj = obj as any;\n\n if (anyObj.$element && typeof anyObj.$element === 'string') {\n const element = document.querySelector(anyObj.$element);\n\n if (!element) {\n console.warn(`Element not found for selector: ${anyObj.$element}`);\n }\n\n return (element || null) as T;\n }\n\n const result = Object.create(null);\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveEditorConfigElementReferences(value);\n }\n\n return result as T;\n}\n","import type { Translations } from 'ckeditor5';\n\n/**\n * Resolves translation references in a configuration object.\n *\n * The configuration may contain objects with the form `{ $translation: \"some.key\" }`.\n * These are replaced with the actual string from the provided translations map.\n *\n * The function will walk the provided object recursively, handling arrays and\n * nested objects. Primitive values are returned as-is. If a translation key is\n * not present in the map, a warning is logged and `null` is returned for that\n * value.\n *\n * @param translations - An array of CKEditor `Translations` objects. Each translation\n * pack will be searched in order for the requested key, and the\n * first matching value will be returned. This mirrors the format\n * returned by `loadAllEditorTranslations` and simplifies the\n * caller's API.\n * @param language - Language identifier to look up in the packs. Only this locale\n * will be consulted, ensuring that keys from other languages are\n * ignored even if they appear earlier in the array.\n * @param obj - Configuration object to process\n * @returns Processed configuration object with resolved translations.\n */\nexport function resolveEditorConfigTranslations(\n translations: Translations[],\n language: string,\n obj: T,\n): T {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveEditorConfigTranslations(translations, language, item)) as T;\n }\n\n const anyObj = obj as any;\n\n if (anyObj.$translation && typeof anyObj.$translation === 'string') {\n const key: string = anyObj.$translation;\n const value = getTranslationValue(translations, key, language);\n\n if (value === undefined) {\n console.warn(`Translation not found for key: ${key}`);\n }\n\n return (value !== undefined ? value : null) as T;\n }\n\n const result = Object.create(null);\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveEditorConfigTranslations(translations, language, value);\n }\n\n return result as T;\n}\n\n/**\n * Look up a translation value inside the provided map or array of CKEditor packs.\n */\nfunction getTranslationValue(\n translations: Translations[],\n key: string,\n language: string,\n): string | ReadonlyArray | undefined {\n for (const pack of translations) {\n const langData = pack[language];\n\n if (langData?.dictionary && key in langData.dictionary) {\n return langData.dictionary[key] as string | ReadonlyArray;\n }\n }\n\n return undefined;\n}\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Sets the height of the editable area in the CKEditor instance.\n *\n * @param instance - The CKEditor instance to modify.\n * @param height - The height in pixels to set for the editable area.\n */\nexport function setEditorEditableHeight(instance: Editor, height: number): void {\n const { editing } = instance;\n\n editing.view.change((writer) => {\n writer.setStyle('height', `${height}px`, editing.view.document.getRoot()!);\n });\n}\n","import type { Context } from 'ckeditor5';\n\nimport { AsyncRegistry } from '../../shared';\n\n/**\n * It provides a way to register contexts and execute callbacks on them when they are available.\n */\nexport class ContextsRegistry extends AsyncRegistry {\n static readonly the = new ContextsRegistry();\n}\n","import type { WaitForInteractiveResult } from '../../shared';\nimport type { EditorLanguage } from '../editor';\nimport type { ContextConfig } from './typings';\nimport type { Context } from 'ckeditor5';\n\nimport { isEmptyObject, makeDestroyIdempotent, waitForDOMReady, waitForInteractiveAttribute } from '../../shared';\nimport {\n loadAllEditorTranslations,\n loadEditorPlugins,\n normalizeCustomTranslations,\n normalizeEditorLanguage,\n resolveEditorConfigElementReferences,\n resolveEditorConfigTranslations,\n} from '../editor/utils';\nimport { ContextsRegistry } from './contexts-registry';\n\n/**\n * The Blazor hook that mounts CKEditor context instances.\n */\nexport class ContextComponentElement extends HTMLElement {\n /**\n * The promise that resolves to the context instance created for the current connection.\n */\n private contextPromise: Promise | null = null;\n\n /**\n * Wait result for the interactive attribute.\n */\n private interactiveWait?: WaitForInteractiveResult;\n\n /**\n * Unregisters the error callback of the current context instance.\n */\n private offEditorError: VoidFunction | null = null;\n\n /**\n * Mounts the context component.\n */\n async connectedCallback() {\n await waitForDOMReady();\n\n // Removed while waiting for the DOM.\n if (!this.isConnected) {\n return;\n }\n\n // By default, components do not bootstrap from web components.\n // They bootstrap only when they receive the data-cke-interactive flag, which the interop sets.\n // This is a fallback for situations where CKEditor 5 is rendered on a non-interactive page.\n this.interactiveWait = waitForInteractiveAttribute(this);\n\n await this.interactiveWait.promise;\n await this.initializeContext();\n }\n\n /**\n * Initializes the context component.\n */\n private async initializeContext(): Promise {\n const contextId = this.getAttribute('data-cke-context-id')!;\n\n ContextsRegistry.the.resetErrors(contextId);\n\n // Assigned synchronously, so `disconnectedCallback()` always has something to destroy,\n // even if the element is disconnected while plugins or translations are still loading.\n const contextPromise = this.createContext();\n\n this.contextPromise = contextPromise;\n\n try {\n const context = await contextPromise;\n const { onEditorError } = await import('ckeditor5');\n\n // Removed in the meantime. `disconnectedCallback()` awaits `contextPromise` and destroys the context.\n if (!this.isConnected) {\n return;\n }\n\n // Nothing restarts the context after a crash anymore. Its state may be inconsistent, so lock\n // its editors in read-only mode. Errors attributed to editors are handled by editor components.\n this.offEditorError = onEditorError(({ error, source }) => {\n if (source !== context) {\n return;\n }\n\n console.error(`CKEditor5 context with ID \"${contextId}\" failed.`, error);\n\n for (const editor of context.editors) {\n editor.enableReadOnlyMode('error-handling');\n }\n });\n\n ContextsRegistry.the.register(contextId, context);\n }\n catch (error: any) {\n // Without this, editors waiting for this context would hang forever.\n console.error(`Error initializing CKEditor5 context with ID \"${contextId}\":`, error);\n ContextsRegistry.the.error(contextId, error);\n }\n }\n\n /**\n * Destroys the context component. Destroying the context destroys all its editors too.\n */\n async disconnectedCallback() {\n // Disconnect the observer if present.\n this.interactiveWait?.disconnect();\n\n // Let's hide the element during destruction to prevent flickering.\n this.style.display = 'none';\n\n this.offEditorError?.();\n this.offEditorError = null;\n\n const { contextPromise } = this;\n\n this.contextPromise = null;\n\n if (!contextPromise) {\n return;\n }\n\n // Creation errors are already reported in `initializeContext()`.\n const context = await contextPromise.catch(() => null);\n\n if (!context) {\n return;\n }\n\n // Unregister before destroying, so newly mounted editors don't pick up a context that is going down.\n // Don't touch the registry if another element with the same ID has already registered its own context.\n const contextId = this.getAttribute('data-cke-context-id');\n\n if (contextId && ContextsRegistry.the.getItem(contextId) === context) {\n ContextsRegistry.the.unregister(contextId);\n }\n\n try {\n await context.destroy();\n }\n catch (error) {\n console.error(`Failed to destroy CKEditor5 context with ID \"${contextId}\".`, error);\n }\n }\n\n /**\n * Loads plugins and translations and creates the context instance.\n */\n private async createContext(): Promise {\n const contextConfig = JSON.parse(this.getAttribute('data-cke-context')!) as ContextConfig;\n const { customTranslations, config: { plugins, ...config } } = contextConfig;\n\n const language = (\n this.getAttribute('data-cke-language')\n ? JSON.parse(this.getAttribute('data-cke-language')!)\n : normalizeEditorLanguage(config['language'])\n ) as EditorLanguage;\n\n const { loadedPlugins, hasPremium } = await loadEditorPlugins(plugins ?? []);\n\n // Mix custom translations with loaded translations.\n const loadedTranslations = await loadAllEditorTranslations(language, hasPremium);\n const mixedTranslations = [\n ...loadedTranslations,\n normalizeCustomTranslations(customTranslations || {}),\n ]\n .filter(translations => !isEmptyObject(translations));\n\n // Construct parsed config. First resolve DOM element references in the provided configuration.\n let resolvedConfig = resolveEditorConfigElementReferences(config);\n\n // Then resolve translation references in the provided configuration, using the mixed translations.\n resolvedConfig = resolveEditorConfigTranslations([...mixedTranslations].reverse(), language.ui, resolvedConfig);\n\n const { Context } = await import('ckeditor5');\n\n const context = await Context.create({\n ...resolvedConfig,\n language,\n plugins: loadedPlugins,\n ...mixedTranslations.length && {\n translations: mixedTranslations,\n },\n });\n\n // The context may be destroyed both by this component and by `ContextsRegistry#destroyAll()`.\n return makeDestroyIdempotent(context);\n }\n}\n","import type { Editor } from 'ckeditor5';\n\nimport { AsyncRegistry } from '../../shared/async-registry';\n\n/**\n * It provides a way to register editors and execute callbacks on them when they are available.\n */\nexport class EditorsRegistry extends AsyncRegistry {\n static readonly the = new EditorsRegistry();\n}\n","import type { WaitForInteractiveResult } from '../shared';\nimport type { MultiRootEditor } from 'ckeditor5';\n\nimport { CKEditor5BlazorError } from '../ckeditor5-blazor-error';\nimport { debounce, isEmptyObject, waitForDOMReady, waitForInteractiveAttribute } from '../shared';\nimport { EditorsRegistry } from './editor/editors-registry';\nimport { queryAllEditorIds } from './editor/utils';\n\n/**\n * Editable hook for Blazor. It allows you to create editables for multi-root editors.\n */\nexport class EditableComponentElement extends HTMLElement {\n /**\n * Stops observing the editor registry and immediately runs any pending cleanup.\n */\n private unmountEffect: VoidFunction | null = null;\n\n /**\n * Wait result for the interactive attribute.\n */\n private interactiveWait?: WaitForInteractiveResult;\n\n /**\n * Mounts the editable component.\n */\n async connectedCallback() {\n await waitForDOMReady();\n\n this.interactiveWait = waitForInteractiveAttribute(this);\n await this.interactiveWait.promise;\n await this.initializeEditable();\n }\n\n /**\n * Initializes the editable instance.\n */\n private async initializeEditable(): Promise {\n if (!this.hasAttribute('data-cke-editor-id')) {\n this.setAttribute('data-cke-editor-id', queryAllEditorIds()[0]!);\n }\n\n const editorId = this.getAttribute('data-cke-editor-id');\n const rootName = this.getAttribute('data-cke-root-name');\n const rootAttributes = JSON.parse(this.getAttribute('data-cke-root-attributes') || '{}');\n const rootModelElement = this.getAttribute('data-cke-root-model-element-name') || '$root';\n const content = this.getAttribute('data-cke-content');\n const saveDebounceMs = Number.parseInt(this.getAttribute('data-cke-save-debounce-ms')!, 10);\n\n /* v8 ignore next if -- @preserve */\n if (!editorId || !rootName) {\n throw new CKEditor5BlazorError('Editor ID or Root Name is missing.');\n }\n\n this.style.display = 'block';\n\n this.unmountEffect = EditorsRegistry.the.mountEffect(editorId, (editor: MultiRootEditor) => {\n if (!this.isConnected) {\n return;\n }\n\n const { ui, editing, model } = editor;\n\n const input = this.querySelector('input') as HTMLInputElement | null;\n const root = model.document.getRoot(rootName);\n\n if (root?.isAttached()) {\n // If the newly added root already exists, but the newly added editable has content,\n // we need to update the root data with the editable content.\n if (content !== null) {\n const data = editor.getData({ rootName });\n\n if (data && data !== content) {\n editor.setData({\n [rootName]: content,\n });\n }\n }\n\n // Assign attributes to the root if they are not empty.\n // This allows users to add custom attributes to the root element of the editable.\n if (!isEmptyObject(rootAttributes)) {\n editor.model.change((writer) => {\n writer.setAttributes(rootAttributes, root);\n });\n }\n\n return;\n }\n\n editor.addRoot(rootName, {\n isUndoable: false,\n modelAttributes: { ...rootAttributes },\n modelElement: rootModelElement,\n ...content !== null && {\n initialData: content,\n },\n });\n\n const contentElement = this.querySelector('[data-cke-editable-content]') as HTMLElement | null;\n const editable = ui.view.createEditable(rootName, contentElement!);\n\n ui.addEditable(editable);\n editing.view.forceRender();\n\n // Sync data with socket and input element.\n const sync = () => {\n if (!model.document.getRoot(rootName)?.isAttached()) {\n return;\n }\n\n const html = editor.getData({ rootName });\n\n if (input) {\n input.value = html;\n input.dispatchEvent(new Event('input'));\n }\n\n this.dispatchEvent(new CustomEvent('change', {\n detail: {\n value: html,\n },\n }));\n };\n\n const debouncedSync = debounce(saveDebounceMs, sync);\n\n editor.model.document.on('change:data', debouncedSync);\n sync();\n\n return () => {\n editor.model.document.off('change:data', debouncedSync);\n\n /* v8 ignore else -- @preserve */\n if (editor.state !== 'destroyed' && rootName) {\n const root = editor.model.document.getRoot(rootName);\n\n /* v8 ignore else -- @preserve */\n if (root && 'detachEditable' in editor) {\n // Detaching editables seem to be buggy when something removed DOM element of the editable (e.g. Blazor re-render) before\n // the editable is unmounted. To prevent errors in such cases, we will try to detach the editable if it exists, but ignore errors.\n try {\n /* v8 ignore else -- @preserve */\n if (editor.ui.view.editables[rootName]) {\n editor.detachEditable(root);\n }\n }\n catch (err) {\n // Ignore errors when detaching editable.\n /* v8 ignore next -- @preserve */\n console.error('Unable unmount editable from root:', err);\n }\n\n if (root.isAttached()) {\n editor.detachRoot(rootName, false);\n }\n }\n }\n };\n });\n }\n\n /**\n * Destroys the editable component. Unmounts root from the editor.\n */\n disconnectedCallback() {\n // Disconnect the observer if present.\n this.interactiveWait?.disconnect();\n\n // Let's hide the element during destruction to prevent flickering.\n this.style.display = 'none';\n\n // Stop observing the registry and run cleanup immediately.\n this.unmountEffect?.();\n this.unmountEffect = null;\n }\n}\n","import type { Editor, PluginConstructor } from 'ckeditor5';\n\nimport { debounce } from '../../../shared';\nimport { getEditorRootsValues } from '../utils';\n\n/**\n * Creates a DispatchEditorRootsChangeEvent plugin class.\n */\nexport async function createDispatchEditorRootsChangeEventPlugin(\n {\n saveDebounceMs,\n editorId,\n targetElement,\n }: {\n saveDebounceMs: number;\n editorId: string;\n targetElement: HTMLElement;\n },\n): Promise {\n const { Plugin } = await import('ckeditor5');\n\n return class DispatchEditorRootsChangeEvent extends Plugin {\n /**\n * The name of the plugin.\n */\n static get pluginName() {\n return 'DispatchEditorRootsChangeEvent' as const;\n }\n\n /**\n * Initializes the plugin.\n */\n public afterInit(): void {\n const { editor } = this;\n const sync = debounce(saveDebounceMs, this.dispatch);\n\n editor.model.document.on('change:data', sync);\n editor.once('ready', this.dispatch);\n }\n\n /**\n * Dispatches a custom event with all roots data.\n */\n private dispatch = (): void => {\n const { editor } = this;\n\n targetElement.dispatchEvent(\n new CKEditor5ChangeDataEvent({\n editorId,\n editor,\n roots: getEditorRootsValues(editor),\n }),\n );\n };\n };\n}\n\n/**\n * A custom event dispatched by the DispatchEditorRootsChangeEvent plugin, containing all editor roots data.\n */\nexport class CKEditor5ChangeDataEvent extends CustomEvent {\n static readonly EVENT_NAME = 'ckeditor5:change:data';\n\n constructor(detail: CKEditor5ChangeDataEventPayload) {\n super(CKEditor5ChangeDataEvent.EVENT_NAME, {\n detail,\n bubbles: true,\n });\n }\n}\n\ntype CKEditor5ChangeDataEventPayload = {\n editorId: string;\n editor: Editor;\n roots: Record;\n};\n","import type { ClassicEditor, PluginConstructor } from 'ckeditor5';\n\nimport { debounce } from '../../../shared';\n\n/**\n * Creates a SyncEditorWithInput plugin class.\n */\nexport async function createSyncEditorWithInputPlugin(saveDebounceMs: number): Promise {\n const { Plugin } = await import('ckeditor5');\n\n return class SyncEditorWithInput extends Plugin {\n /**\n * The input element to synchronize with.\n */\n private input: HTMLInputElement | null = null;\n\n /**\n * The form element reference for cleanup.\n */\n private form: HTMLFormElement | null = null;\n\n /**\n * The name of the plugin.\n */\n static get pluginName() {\n return 'SyncEditorWithInput' as const;\n }\n\n /**\n * Initializes the plugin.\n */\n public afterInit(): void {\n const { editor } = this;\n const editorElement = (editor as ClassicEditor).sourceElement as HTMLElement;\n\n // Try to find the associated input field.\n const editorId = editorElement.id.replace(/_editor$/, '');\n\n this.input = document.getElementById(`${editorId}_input`) as HTMLInputElement | null;\n\n if (!this.input) {\n return;\n }\n\n // Setup handlers.\n editor.model.document.on('change:data', debounce(saveDebounceMs, () => this.sync()));\n editor.once('ready', this.sync);\n\n // Setup form integration.\n this.form = this.input.closest('form');\n this.form?.addEventListener('submit', this.sync);\n }\n\n /**\n * Synchronizes the editor's content with the input field.\n */\n private sync = (): void => {\n /* v8 ignore else -- @preserve */\n if (this.input) {\n const newValue = this.editor.getData();\n\n this.input.value = newValue;\n this.input.dispatchEvent(new Event('input', { bubbles: true }));\n }\n };\n\n /**\n * Destroys the plugin.\n */\n public override destroy(): void {\n if (this.form) {\n this.form.removeEventListener('submit', this.sync);\n }\n\n this.input = null;\n this.form = null;\n }\n };\n}\n","import type { WaitForInteractiveResult } from '../../shared';\nimport type { EditorId, EditorLanguage, EditorPreset } from './typings';\nimport type { EditableItem } from './utils';\nimport type { Context, Editor } from 'ckeditor5';\n\nimport {\n isEmptyObject,\n makeDestroyIdempotent,\n waitFor,\n waitForDOMReady,\n waitForInteractiveAttribute,\n} from '../../shared';\nimport { ContextsRegistry } from '../context';\nimport { EditorsRegistry } from './editors-registry';\nimport {\n createDispatchEditorRootsChangeEventPlugin,\n createSyncEditorWithInputPlugin,\n} from './plugins';\nimport {\n assignEditorRootsToConfig,\n isSingleRootEditor,\n loadAllEditorTranslations,\n loadEditorConstructor,\n loadEditorPlugins,\n normalizeCustomTranslations,\n normalizeEditorLanguage,\n queryAllEditorEditables,\n resolveEditorConfigElementReferences,\n resolveEditorConfigTranslations,\n setEditorEditableHeight,\n} from './utils';\n\n/**\n * The Blazor hook that manages the lifecycle of CKEditor5 instances.\n */\nexport class EditorComponentElement extends HTMLElement {\n /**\n * Stops observing the editor registry and immediately runs any pending cleanup.\n */\n private unmountEffect: VoidFunction | null = null;\n\n /**\n * Wait result for the interactive attribute.\n */\n private interactiveWait?: WaitForInteractiveResult;\n\n /**\n * Mounts the editor component.\n */\n async connectedCallback(): Promise {\n await waitForDOMReady();\n\n // Removed while waiting for the DOM.\n if (!this.isConnected) {\n return;\n }\n\n // By default, components do not bootstrap from web components.\n // They bootstrap only when they receive the data-cke-interactive flag, which the interop sets.\n // This is a fallback for situations where CKEditor 5 is rendered on a non-interactive page.\n this.interactiveWait = waitForInteractiveAttribute(this);\n\n // Let's start preloading the editor constructor. We are still waiting for the interactive attribute, but\n // at least we will have the constructor ready when it arrives. It makes no difference which editor type is being\n // preloaded as they are loaded from the same package, so let's just preload the classic editor constructor.\n void loadEditorConstructor('classic');\n\n await this.interactiveWait.promise;\n await this.initializeEditor();\n }\n\n /**\n * Initializes the editor instance.\n */\n private async initializeEditor(): Promise {\n const editorId = this.getAttribute('data-cke-editor-id')!;\n\n EditorsRegistry.the.resetErrors(editorId);\n\n try {\n this.style.display = 'block';\n\n const [editor, { onEditorError }] = await Promise.all([\n this.createEditor(),\n import('ckeditor5'),\n ]);\n\n // Removed while the editor was being created. Nobody else will destroy it.\n if (!this.isConnected) {\n await destroyEditorSafely(editorId, editor);\n return;\n }\n\n // Nothing restarts the editor after a crash anymore and its state may be inconsistent,\n // so lock it in read-only mode to avoid syncing broken data with Blazor.\n // Errors of the context are handled by the context component.\n const offEditorError = onEditorError(({ error, source }) => {\n if (source !== editor) {\n return;\n }\n\n console.error(`CKEditor5 instance with ID \"${editorId}\" failed.`, error);\n editor.enableReadOnlyMode('error-handling');\n });\n\n // Bind lifecycle of the integration to the registered editor instance.\n const unmountDestroyWatchers = EditorsRegistry.the.mountEffect(editorId, (editor) => {\n // Enforce deregistration of the editor when it's destroyed externally (for example by its context\n // or manually using `.destroy()`). Keep pending callbacks though.\n editor.once('destroy', () => {\n EditorsRegistry.the.unregister(editorId, false);\n }, { priority: 'highest' });\n });\n\n this.unmountEffect = () => {\n // If for some reason editor not fired `destroy`, enforce deregistration.\n EditorsRegistry.the.unregister(editorId);\n unmountDestroyWatchers();\n offEditorError();\n\n void destroyEditorSafely(editorId, editor);\n };\n\n EditorsRegistry.the.register(editorId, editor);\n }\n catch (error: any) {\n console.error(`Error initializing CKEditor5 instance with ID \"${editorId}\":`, error);\n this.unmountEffect = null;\n EditorsRegistry.the.error(editorId, error);\n }\n }\n\n /**\n * Destroys the editor instance when the component is destroyed.\n * This is important to prevent memory leaks and ensure that the editor is properly cleaned up.\n */\n disconnectedCallback() {\n this.interactiveWait?.disconnect();\n\n // Let's hide the element during destruction to prevent flickering.\n this.style.display = 'none';\n\n // Stop observing the registry and run cleanup immediately.\n this.unmountEffect?.();\n this.unmountEffect = null;\n }\n\n /**\n * Creates the CKEditor instance.\n */\n private async createEditor(): Promise {\n const preset = JSON.parse(this.getAttribute('data-cke-preset')!) as EditorPreset;\n const {\n customTranslations,\n editorType,\n licenseKey,\n config: { plugins, ...config },\n } = preset;\n\n const editorId = this.getAttribute('data-cke-editor-id')!;\n const contextId = this.getAttribute('data-cke-context-id');\n const rootAttributes = JSON.parse(this.getAttribute('data-cke-root-attributes') || '{}');\n const editableHeight = this.getAttribute('data-cke-editable-height') ? Number.parseInt(this.getAttribute('data-cke-editable-height')!, 10) : null;\n const saveDebounceMs = Number.parseInt(this.getAttribute('data-cke-save-debounce-ms')!, 10);\n const language = (\n this.getAttribute('data-cke-language')\n ? JSON.parse(this.getAttribute('data-cke-language')!)\n : normalizeEditorLanguage(preset.config['language'])\n ) as EditorLanguage;\n\n const Constructor = await loadEditorConstructor(editorType);\n const context: Context | null = await (\n contextId\n ? ContextsRegistry.the.waitFor(contextId)\n : null\n );\n\n const { loadedPlugins, hasPremium } = await loadEditorPlugins(plugins);\n\n loadedPlugins.push(\n await createDispatchEditorRootsChangeEventPlugin({\n saveDebounceMs,\n editorId,\n targetElement: this,\n }),\n );\n\n if (isSingleRootEditor(editorType)) {\n loadedPlugins.push(\n await createSyncEditorWithInputPlugin(saveDebounceMs),\n );\n }\n\n // Mix custom translations with loaded translations.\n const loadedTranslations = await loadAllEditorTranslations(language, hasPremium);\n const mixedTranslations = [\n ...loadedTranslations,\n normalizeCustomTranslations(customTranslations || {}),\n ]\n .filter(translations => !isEmptyObject(translations));\n\n // Query all editable elements along with their content in one pass.\n // Roots present in the editor container's data-cke-content but not yet in the DOM\n // are included with element: null so we know which roots to wait for.\n let editables = queryAllEditorEditables(editorId);\n const requiredRoots = Object.keys(editables);\n\n if (isSingleRootEditor(editorType)) {\n requiredRoots.push('main');\n }\n\n if (!checkIfAllRootsArePresent(editables, requiredRoots)) {\n editables = await waitForAllRootsToBePresent(editorId, requiredRoots);\n }\n\n // Do some postprocessing on received configuration.\n let resolvedConfig = {\n ...config,\n licenseKey,\n plugins: loadedPlugins,\n language,\n ...mixedTranslations.length && {\n translations: mixedTranslations,\n },\n };\n\n resolvedConfig = resolveEditorConfigElementReferences(resolvedConfig);\n resolvedConfig = resolveEditorConfigTranslations([...mixedTranslations].reverse(), language.ui, resolvedConfig);\n resolvedConfig = assignEditorRootsToConfig(Constructor, editables, resolvedConfig);\n\n const editor = await Constructor.create(\n context\n ? { ...resolvedConfig, context }\n : resolvedConfig,\n );\n\n // Assign root attributes if they are not empty. This is needed to support custom attributes on the root element of the editor.\n if (!isEmptyObject(rootAttributes)) {\n editor.model.change((writer) => {\n writer.setAttributes(rootAttributes, editor.model.document.getRoot()!);\n });\n }\n\n if (isSingleRootEditor(editorType) && editableHeight) {\n setEditorEditableHeight(editor, editableHeight);\n }\n\n // The editor may be destroyed both by this component and by its context (when they're disconnected\n // in the same DOM update, in any order), or by `EditorsRegistry#destroyAll()`.\n return makeDestroyIdempotent(editor);\n }\n}\n\n/**\n * Destroys the editor. Never rejects, because callers (like `disconnectedCallback()`) are not awaited.\n *\n * @param editorId The editor's ID (used for logging).\n * @param editor The editor instance.\n */\nasync function destroyEditorSafely(editorId: EditorId, editor: Editor): Promise {\n try {\n await editor.destroy();\n }\n catch (error) {\n console.error(`Failed to destroy CKEditor5 instance with ID \"${editorId}\".`, error);\n }\n}\n\n/**\n * Checks if all required root elements are present (i.e. have a non-null element) in the editables map.\n *\n * @param editables The editables map keyed by root name.\n * @param requiredRoots The list of required root names.\n * @returns True if all required roots have a DOM element attached, false otherwise.\n */\nfunction checkIfAllRootsArePresent(editables: Record, requiredRoots: string[]): boolean {\n return requiredRoots.every(rootId => editables[rootId]?.element);\n}\n\n/**\n * Waits for all required root elements to be present in the DOM.\n *\n * @param editorId The editor's ID.\n * @param requiredRoots The list of required root names.\n * @returns A promise that resolves to the updated editables map once all elements are attached.\n */\nasync function waitForAllRootsToBePresent(\n editorId: EditorId,\n requiredRoots: string[],\n): Promise> {\n return waitFor(\n () => {\n const editables = queryAllEditorEditables(editorId);\n\n if (!checkIfAllRootsArePresent(editables, requiredRoots)) {\n throw new Error(\n 'It looks like not all required root elements are present yet.\\n'\n + '* If you want to wait for them, ensure they are registered before editor initialization.\\n'\n + '* If you want lazy initialize roots, consider removing root values from the `initialData` config '\n + 'and assign initial data in editable components.\\n'\n + `Missing roots: ${requiredRoots.filter(rootId => !editables[rootId]?.element).join(', ')}.`,\n );\n }\n\n return editables;\n },\n { timeOutAfter: 2000, retryAfter: 100 },\n );\n}\n","import { CKEditor5BlazorError } from '../ckeditor5-blazor-error';\nimport { waitForDOMReady } from '../shared';\nimport { EditorsRegistry } from './editor/editors-registry';\nimport { queryAllEditorIds } from './editor/utils';\n\n/**\n * UI Part hook for Blazor. It allows you to create UI parts for multi-root editors.\n */\nexport class UIPartComponentElement extends HTMLElement {\n /**\n * Stops observing the editor registry and immediately runs any pending cleanup.\n */\n private unmountEffect: VoidFunction | null = null;\n\n /**\n * Mounts the UI part component.\n */\n async connectedCallback() {\n await waitForDOMReady();\n\n const editorId = this.getAttribute('data-cke-editor-id') || queryAllEditorIds()[0]!;\n const name = this.getAttribute('data-cke-name');\n\n /* v8 ignore next if -- @preserve */\n if (!editorId || !name) {\n return;\n }\n\n this.style.display = 'block';\n\n this.unmountEffect = EditorsRegistry.the.mountEffect(editorId, (editor) => {\n if (!this.isConnected) {\n return;\n }\n\n const { ui } = editor;\n\n const uiViewName = mapUIPartView(name);\n const uiPart = (ui.view as any)[uiViewName!];\n\n /* v8 ignore next if -- @preserve */\n if (!uiPart) {\n throw new CKEditor5BlazorError(`Unknown UI part name: \"${name}\". Supported names are \"toolbar\" and \"menubar\".`);\n }\n\n this.appendChild(uiPart.element);\n\n return () => {\n this.innerHTML = '';\n };\n });\n }\n\n /**\n * Destroys the UI part component. Unmounts UI parts from the editor.\n */\n disconnectedCallback() {\n // Let's hide the element during destruction to prevent flickering.\n this.style.display = 'none';\n\n // Stop observing the registry and run cleanup immediately.\n this.unmountEffect?.();\n this.unmountEffect = null;\n }\n}\n\n/**\n * Maps the UI part name to the corresponding view in the editor.\n *\n * @param name The name of the UI part.\n * @returns The name of the view in the editor.\n */\nfunction mapUIPartView(name: string): string | null {\n switch (name) {\n case 'toolbar':\n return 'toolbar';\n\n case 'menubar':\n return 'menuBarView';\n\n /* v8 ignore next -- @preserve */\n default:\n return null;\n }\n}\n","import { ContextComponentElement } from './context';\nimport { EditableComponentElement } from './editable';\nimport { EditorComponentElement } from './editor';\nimport { UIPartComponentElement } from './ui-part';\n\nconst CUSTOM_ELEMENTS = {\n 'cke5-editor': EditorComponentElement,\n 'cke5-context': ContextComponentElement,\n 'cke5-ui-part': UIPartComponentElement,\n 'cke5-editable': EditableComponentElement,\n};\n\n/**\n * Registers all available Blazor component hooks.\n */\nexport function ensureEditorElementsRegistered() {\n for (const [name, CustomElement] of Object.entries(CUSTOM_ELEMENTS)) {\n if (window.customElements.get(name)) {\n continue;\n }\n\n window.customElements.define(name, CustomElement);\n }\n}\n","import { markElementAsInteractive } from '../shared';\n\n/**\n * Creates a simple interop layer for CKEditor 5 context to set the interactive attribute.\n *\n * @param element - The root HTML element of the context component, used to identify\n * the context instance and attach necessary attributes.\n */\nexport function createContextBlazorInterop(element: HTMLElement) {\n markElementAsInteractive(element);\n\n return {\n unmount() {},\n };\n}\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Creates a focus-aware value synchronization layer for a CKEditor 5 instance.\n *\n * Handles the shared mechanics present in both the Editor and Editable Blazor interops:\n * - Tracking `lastSyncedValue` to prevent circular Blazor ↔ JS updates.\n * - Storing a `pendingValue` when a Blazor update arrives while the editor is focused,\n * and applying it safely once the user blurs.\n * - Registering and cleaning up the `change:data` and `change:isFocused` editor listeners.\n *\n * @param editor - The CKEditor 5 editor instance to synchronize with.\n * @param options - Callbacks and equality check specific to the consumer (editor vs editable).\n * @param options.getCurrentValue - Returns the current value of the tracked root(s) from the editor.\n * @param options.applyValue - Applies the given value to the editor (e.g. via `editor.setData`).\n * @param options.isEqual - Returns true if two values are considered equal, used to avoid redundant updates.\n * @returns An object with `setValue`, `shouldNotify`, and `unmount`.\n */\nexport function createEditorValueSync(\n editor: Editor,\n options: {\n\n /**\n * Returns the current value of the tracked root(s) from the editor.\n * Called to compare against the pending value before applying it.\n */\n getCurrentValue: () => T;\n\n /**\n * Applies the given value to the editor (e.g. via `editor.setData`).\n */\n applyValue: (value: T) => void;\n\n /**\n * Returns true if two values are considered equal, used to avoid redundant\n * updates in both directions.\n */\n isEqual: (a: T, b: T) => boolean;\n },\n): EditorValueSync {\n const state = {\n /** Value received from Blazor while the editor was focused, pending application on blur. */\n pendingValue: null as T | null,\n\n /** The last value sent to or received from Blazor to prevent circular updates. */\n lastSyncedValue: null as T | null,\n };\n\n /**\n * Any internal model change means the pending external value is stale — discard it.\n */\n const onChangeData = () => {\n state.pendingValue = null;\n };\n\n /**\n * When the editor loses focus, apply any value that Blazor sent while the user was typing.\n */\n const onFocusChange = (_evt: unknown, _name: unknown, isFocused: boolean) => {\n if (isFocused || state.pendingValue === null) {\n return;\n }\n\n const current = options.getCurrentValue();\n\n if (!options.isEqual(current, state.pendingValue)) {\n options.applyValue(state.pendingValue);\n }\n\n state.pendingValue = null;\n };\n\n editor.model.document.on('change:data', onChangeData);\n editor.ui.focusTracker.on('change:isFocused', onFocusChange);\n\n return {\n /**\n * Removes all editor listeners registered by this sync instance.\n * Call this when the Blazor component is disposed.\n */\n unmount() {\n editor.model.document.off('change:data', onChangeData);\n editor.ui.focusTracker.off('change:isFocused', onFocusChange);\n },\n\n /**\n * Checks whether the given value differs from the last synced value and, if so,\n * updates `lastSyncedValue` and returns `true` to signal that Blazor should be notified.\n *\n * Call this from the `CKEditor5ChangeDataEvent` handler to conditionally invoke\n * the .NET interop method.\n */\n shouldNotify(value: T): boolean {\n if (state.lastSyncedValue !== null && options.isEqual(state.lastSyncedValue, value)) {\n return false;\n }\n\n state.lastSyncedValue = value;\n return true;\n },\n\n /**\n * Pushes a new value from Blazor into the editor.\n * If the editor is currently focused, the update is deferred until blur.\n * If the value matches the last synced state, the update is skipped entirely.\n */\n setValue(value: T) {\n if (editor.ui.focusTracker.isFocused) {\n state.pendingValue = value;\n return;\n }\n\n if (state.lastSyncedValue !== null && options.isEqual(state.lastSyncedValue, value)) {\n return;\n }\n\n state.lastSyncedValue = value;\n options.applyValue(value);\n },\n };\n}\n\n/**\n * Returns a no-op {@link EditorValueSync} used as a placeholder before the real editor\n * instance is available, so callers never have to null-check `sync`.\n */\nexport function createNoopSync(): EditorValueSync {\n return {\n unmount() {},\n shouldNotify(_value: T): boolean { return false; },\n setValue(_value: T) {},\n };\n}\n\n/**\n * The public interface returned by {@link createEditorValueSync} and {@link createNoopSync}.\n * Typed over the value shape `T` so consumers can declare `sync` variables without\n * repeating the full return type.\n */\nexport type EditorValueSync = {\n /** Removes all editor listeners registered by this sync instance. */\n unmount: () => void;\n\n /**\n * Checks whether the given value differs from the last synced value and, if so,\n * updates `lastSyncedValue` and returns `true` to signal that Blazor should be notified.\n */\n /**\n * Called by the consumer to determine if a value change should trigger a\n * notification. Returns `true` when the value differs from the last one that\n * was synced and updates internal tracking.\n */\n shouldNotify: (value: T) => boolean;\n\n /**\n * Pushes a new value from Blazor into the editor.\n * Deferred until blur when the editor is focused; skipped when value is unchanged.\n */\n setValue: (value: T) => void;\n};\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Creates a function that synchronizes root attributes on the given editor root.\n *\n * The returned function tracks which attributes were set by itself and will only\n * remove attributes it previously managed. This avoids interfering with other\n * consumers that may also change attributes on the same root.\n *\n * @param editor The editor instance containing the root to manage.\n * @param rootName The name of the root to manage attributes on.\n * @returns A function that can be called with the desired set of attributes to apply them to the root.\n * Calling the function with `null` or an empty object will clear all attributes previously set by it.\n */\nexport function createRootAttributesUpdater(editor: Editor, rootName: string): RootAttributesUpdater {\n const managedAttrs = new Set();\n\n return (rootAttributes?: Record | null) => {\n editor.model.enqueueChange({ isUndoable: false }, (writer) => {\n const root = editor.model.document.getRoot(rootName);\n\n /* v8 ignore next if -- @preserve */\n if (!root) {\n return;\n }\n\n // Remove previously managed attributes that are no longer requested.\n for (const key of managedAttrs) {\n if (rootAttributes && (key in rootAttributes)) {\n continue;\n }\n\n writer.removeAttribute(key, root);\n managedAttrs.delete(key);\n }\n\n // Apply or overwrite requested attributes.\n for (const [key, value] of Object.entries(rootAttributes ?? {})) {\n writer.setAttribute(key, value, root);\n managedAttrs.add(key);\n }\n });\n };\n}\n\nexport type RootAttributesUpdater = (rootAttributes?: Record | null) => void;\n","import type { DotNetInterop } from '../types';\nimport type { RootAttributesUpdater } from './utils';\n\nimport { EditorsRegistry } from '../elements/editor/editors-registry';\nimport { CKEditor5ChangeDataEvent } from '../elements/editor/plugins/dispatch-editor-roots-change-event';\nimport { queryAllEditorIds } from '../elements/editor/utils';\nimport { markElementAsInteractive } from '../shared';\nimport { createEditorValueSync, createNoopSync, createRootAttributesUpdater } from './utils';\n\n/**\n * Creates an interop layer to synchronize a single CKEditor 5 editable root with a Blazor component.\n *\n * @param element - The root HTML element of the editable component, used to identify\n * the editable instance and attach necessary attributes.\n * @param interop - The .NET object reference to trigger Blazor methods.\n * @returns An object containing lifecycle and synchronization methods.\n */\nexport function createEditableBlazorInterop(element: HTMLElement, interop: DotNetInterop) {\n const editorId = element.getAttribute('data-cke-editor-id') ?? queryAllEditorIds()[0]!;\n const rootName = element.getAttribute('data-cke-root-name') ?? 'main';\n\n let unmounted = false;\n let stopEffect: VoidFunction | null = null;\n\n let editorRef: unknown | null = null;\n\n let sync = createNoopSync();\n let syncRootAttributes: RootAttributesUpdater | null = null;\n\n /**\n * Handles data change events dispatched by the CKEditor plugin.\n * Filters by both editorId and rootName, then notifies Blazor if the root value changed.\n * The callback now includes a JS object reference to the underlying editor instance.\n */\n const onDataChange = (event: Event) => {\n if (!(event instanceof CKEditor5ChangeDataEvent) || event.detail.editorId !== editorId) {\n return;\n }\n\n const newValue = event.detail.roots[rootName];\n\n if (newValue === undefined) {\n return;\n }\n\n if (sync.shouldNotify(newValue)) {\n void interop.invokeMethodAsync('OnChangeEditableData', editorRef, newValue);\n }\n };\n\n stopEffect = EditorsRegistry.the.mountEffect(editorId, (editor) => {\n editorRef = globalThis.DotNet.createJSObjectReference(editor);\n\n sync = createEditorValueSync(editor, {\n getCurrentValue: () => editor.getData({ rootName }) ?? '',\n applyValue: value => editor.setData({ [rootName]: value }),\n isEqual: (a, b) => a === b,\n });\n\n syncRootAttributes = createRootAttributesUpdater(editor, rootName);\n\n return () => {\n sync.unmount();\n\n /* v8 ignore else -- @preserve */\n if (editorRef) {\n globalThis.DotNet?.disposeJSObjectReference(editorRef);\n editorRef = null;\n }\n\n syncRootAttributes = null;\n };\n });\n\n document.body.addEventListener(CKEditor5ChangeDataEvent.EVENT_NAME, onDataChange);\n markElementAsInteractive(element);\n\n return {\n /**\n * Cleans up all event listeners when the Blazor component is disposed.\n */\n unmount() {\n if (unmounted) {\n return;\n }\n\n document.body.removeEventListener(CKEditor5ChangeDataEvent.EVENT_NAME, onDataChange);\n\n stopEffect?.();\n stopEffect = null;\n\n unmounted = true;\n },\n\n /**\n * Updates this editable root's data from Blazor.\n * If the editor is focused, the update is deferred until blur to avoid interrupting the user.\n */\n setValue: async (value: string) => {\n if (unmounted) {\n return;\n }\n\n await EditorsRegistry.the.waitFor(editorId);\n sync.setValue(value);\n },\n\n /**\n * Updates the root attributes on the editor. This is useful when the Blazor component\n * re-renders with new root attributes.\n */\n setRootAttributes: async (rootAttributes?: Record | null) => {\n if (unmounted) {\n return;\n }\n\n await EditorsRegistry.the.waitFor(editorId);\n\n syncRootAttributes?.(rootAttributes);\n },\n };\n}\n","import type { DotNetInterop } from '../types';\nimport type { RootAttributesUpdater } from './utils';\nimport type { Editor, FileRepository } from 'ckeditor5';\n\nimport { ensureEditorElementsRegistered } from '../elements';\nimport { EditorsRegistry } from '../elements/editor/editors-registry';\nimport { CKEditor5ChangeDataEvent } from '../elements/editor/plugins/dispatch-editor-roots-change-event';\nimport { getEditorRootsValues } from '../elements/editor/utils';\nimport { markElementAsInteractive, shallowEqual } from '../shared';\nimport { createEditorValueSync, createNoopSync, createRootAttributesUpdater } from './utils';\n\n/**\n * Creates an interop layer to synchronize a CKEditor 5 instance with a Blazor component.\n *\n * @param element - The root HTML element of the editor component, used to identify the editor instance and attach necessary attributes.\n * @param interop - The .NET object reference to trigger Blazor methods.\n * @returns An object containing lifecycle and synchronization methods.\n */\nexport function createEditorBlazorInterop(element: HTMLElement, interop: DotNetInterop) {\n const editorId = element.getAttribute('data-cke-editor-id');\n\n let unmounted = false;\n let stopEffect: VoidFunction | null = null;\n\n let sync = createNoopSync>();\n let syncRootAttributes: RootAttributesUpdater | null = null;\n\n let editorRef: unknown | null = null;\n\n // Handles data change events dispatched by the CKEditor plugin.\n // Dispatches updates back to Blazor if the data has changed.\n const onDataChange = (event: Event) => {\n if (!(event instanceof CKEditor5ChangeDataEvent) || event.detail.editorId !== editorId) {\n return;\n }\n\n if (sync.shouldNotify(event.detail.roots)) {\n void interop.invokeMethodAsync('OnChangeEditorData', editorRef!, event.detail.roots);\n }\n };\n\n stopEffect = EditorsRegistry.the.mountEffect(editorId, (editor) => {\n editorRef = globalThis.DotNet.createJSObjectReference(editor);\n sync = createEditorValueSync(editor, {\n getCurrentValue: () => getEditorRootsValues(editor),\n applyValue: value => editor.setData(value),\n isEqual: shallowEqual,\n });\n\n syncRootAttributes = createRootAttributesUpdater(editor, 'main');\n\n // Notify Blazor of focus changes so it can trigger the appropriate callbacks.\n const onFocusChange = (_evt: unknown, _name: unknown, isFocused: boolean) => {\n const method = isFocused ? 'OnEditorFocus' : 'OnEditorBlur';\n\n void interop.invokeMethodAsync(method, editorRef);\n };\n\n editor.ui.focusTracker.on('change:isFocused', onFocusChange);\n\n // Notify Blazor that the editor instance is ready so the consumer can\n // retain an IJSObjectReference or perform additional JS calls directly.\n // This mirrors the `OnChangeEditorData` (which now also drives the public\n // `OnChange` event) as well as `OnEditorFocus` and `OnEditorBlur` callbacks\n // that already exist on the .NET side.\n void interop.invokeMethodAsync('OnEditorReady', editorRef);\n\n return () => {\n editor.ui.focusTracker.off('change:isFocused', onFocusChange);\n sync.unmount();\n\n /* v8 ignore else -- @preserve */\n if (editorRef) {\n globalThis.DotNet?.disposeJSObjectReference(editorRef);\n editorRef = null;\n }\n\n syncRootAttributes = null;\n };\n });\n\n document.body.addEventListener(CKEditor5ChangeDataEvent.EVENT_NAME, onDataChange);\n\n ensureEditorElementsRegistered();\n markElementAsInteractive(element);\n\n return {\n /**\n * Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.\n */\n setValue: async (value: Record) => {\n if (unmounted) {\n return;\n }\n\n await EditorsRegistry.the.waitFor(editorId);\n sync.setValue(value);\n },\n\n /**\n * Updates the root attributes on the editor instance.\n */\n setRootAttributes: async (rootAttributes?: Record | null) => {\n if (unmounted) {\n return;\n }\n\n await EditorsRegistry.the.waitFor(editorId);\n\n syncRootAttributes?.(rootAttributes);\n },\n\n /**\n * Cleans up all event listeners when the Blazor component is disposed.\n */\n unmount() {\n if (unmounted) {\n return;\n }\n\n document.body.removeEventListener(CKEditor5ChangeDataEvent.EVENT_NAME, onDataChange);\n\n stopEffect?.();\n stopEffect = null;\n\n unmounted = true;\n },\n\n /**\n * Installs the custom image upload adapter that delegates uploads to Blazor.\n * This is called lazily from Blazor when the consumer sets the `OnImageUpload` callback\n * to avoid unnecessary overhead for consumers that don't use this feature.\n */\n attachImageUploadAdapter: async () => {\n if (unmounted) {\n return;\n }\n\n EditorsRegistry.the.mountEffect(editorId, (editor) => {\n installImageUploadAdapter(editor, interop);\n });\n },\n };\n}\n\n/**\n * Installs a custom CKEditor 5 upload adapter that delegates image uploads to Blazor.\n * When the user inserts an image the adapter encodes the file as Base64 and calls\n * `OnEditorImageUpload` on the .NET interop object, which returns the public URL to embed.\n */\nfunction installImageUploadAdapter(editor: Editor, interop: DotNetInterop) {\n if (!editor.plugins.has('FileRepository')) {\n return;\n }\n\n const fileRepository = editor.plugins.get('FileRepository') as FileRepository;\n\n fileRepository.createUploadAdapter = (loader: any) => {\n let aborted = false;\n\n return {\n async upload() {\n const file: File = await loader.file;\n\n if (aborted) {\n throw new Error('Upload aborted.');\n }\n\n const payload = await fileToBase64(file);\n const url = await interop.invokeMethodAsync('OnEditorImageUpload', {\n fileName: file.name,\n mimeType: file.type,\n payload,\n });\n\n if (!url) {\n throw new Error(\n 'OnImageUpload handler returned null. '\n + 'Make sure the OnImageUpload parameter is set on the component.',\n );\n }\n\n return { default: url };\n },\n\n abort() {\n aborted = true;\n },\n };\n };\n}\n\n/**\n * Converts a File object to a Base64-encoded string (data-URL prefix stripped).\n */\nfunction fileToBase64(file: File): Promise {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n\n reader.onload = () => {\n const result = reader.result as string;\n\n /* v8 ignore next -- @preserve */\n const base64 = result.split(',')[1] ?? result;\n\n resolve(base64);\n };\n\n /* v8 ignore next -- @preserve */\n reader.onerror = () => reject(reader.error);\n reader.readAsDataURL(file);\n });\n}\n","import { markElementAsInteractive } from '../shared';\n\n/**\n * Creates a simple interop layer for CKEditor 5 UI part to set the interactive attribute.\n *\n * @param element - The root HTML element of the UI part component, used to identify\n * the UI part instance and attach necessary attributes.\n */\nexport function createUIPartBlazorInterop(element: HTMLElement) {\n markElementAsInteractive(element);\n\n return {\n unmount() {},\n };\n}\n"],"names":["CKEditor5BlazorError","message","areMapsEqual","map1","map2","key","value","AsyncRegistry","id","onSuccess","onError","item","error","resolve","reject","pending","onMount","cleanup","mountedItem","unmounted","unwatch","items","newCleanup","err","callback","initializationErrors","resetPendingCallbacks","promises","fn","watcher","debounce","delay","timeoutId","args","isEmptyObject","obj","once","called","result","makeDestroyIdempotent","instance","mapObjectValues","mapper","mappedEntries","shallowEqual","objA","objB","keysA","keysB","waitFor","timeOutAfter","retryAfter","startTime","lastError","timeoutTimerId","tick","waitForDOMReady","waitForInteractiveAttribute","element","observer","mutations","mutation","markElementAsInteractive","assignEditorRootsToConfig","Editor","editables","config","isClassicEditor","allRootsKeys","rootsConfig","acc","rootKey","mappedConfig","getEditorRootsValues","editor","root","isSingleRootEditor","editorType","loadEditorConstructor","type","PKG","EditorConstructor","CustomEditorPluginsRegistry","name","reader","loadEditorPlugins","plugins","basePackage","premiumPackage","loaders","plugin","isPluginImport","path","typedMod","ctor","customPlugin","basePkgImport","premiumPkgImport","loadAllEditorTranslations","language","hasPremium","translations","loadEditorPkgTranslations","pkg","lang","pack","loadEditorTranslation","normalizeCustomTranslations","dictionary","normalizeEditorLanguage","queryAllEditorEditables","editorId","rootName","modelElement","rootEditorElement","editorContent","classicMainElement","rootEditorModelElement","rootContent","queryAllEditorIds","resolveEditorConfigElementReferences","anyObj","resolveEditorConfigTranslations","getTranslationValue","langData","setEditorEditableHeight","height","editing","writer","ContextsRegistry","ContextComponentElement","contextId","contextPromise","context","onEditorError","source","contextConfig","customTranslations","loadedPlugins","mixedTranslations","resolvedConfig","Context","EditorsRegistry","EditableComponentElement","rootAttributes","rootModelElement","content","saveDebounceMs","ui","model","input","data","contentElement","editable","sync","html","debouncedSync","createDispatchEditorRootsChangeEventPlugin","targetElement","Plugin","CKEditor5ChangeDataEvent","detail","createSyncEditorWithInputPlugin","newValue","EditorComponentElement","destroyEditorSafely","offEditorError","unmountDestroyWatchers","preset","licenseKey","editableHeight","Constructor","requiredRoots","checkIfAllRootsArePresent","waitForAllRootsToBePresent","rootId","UIPartComponentElement","uiViewName","mapUIPartView","uiPart","CUSTOM_ELEMENTS","ensureEditorElementsRegistered","CustomElement","createContextBlazorInterop","createEditorValueSync","options","state","onChangeData","onFocusChange","_evt","_name","isFocused","current","createNoopSync","_value","createRootAttributesUpdater","managedAttrs","createEditableBlazorInterop","interop","stopEffect","editorRef","syncRootAttributes","onDataChange","event","a","b","createEditorBlazorInterop","method","installImageUploadAdapter","fileRepository","loader","aborted","file","payload","fileToBase64","url","base64","createUIPartBlazorInterop"],"mappings":"AAGO,MAAMA,UAA6B,MAAM;AAAA,EAC9C,YAAYC,GAAiB;AAC3B,UAAMA,CAAO,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