ckeditor5-symfony 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/elements/editable.d.ts +3 -3
  2. package/dist/elements/editable.d.ts.map +1 -1
  3. package/dist/elements/editor/editor.d.ts +7 -3
  4. package/dist/elements/editor/editor.d.ts.map +1 -1
  5. package/dist/elements/editor/utils/cleanup-orphan-editor-elements.d.ts +8 -0
  6. package/dist/elements/editor/utils/cleanup-orphan-editor-elements.d.ts.map +1 -0
  7. package/dist/elements/editor/utils/create-editor-in-context.d.ts +6 -1
  8. package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -1
  9. package/dist/elements/editor/utils/index.d.ts +2 -0
  10. package/dist/elements/editor/utils/index.d.ts.map +1 -1
  11. package/dist/elements/editor/utils/is-multiroot-editor-instance.d.ts +6 -0
  12. package/dist/elements/editor/utils/is-multiroot-editor-instance.d.ts.map +1 -0
  13. package/dist/elements/editor/utils/wrap-with-watchdog.d.ts +7 -16
  14. package/dist/elements/editor/utils/wrap-with-watchdog.d.ts.map +1 -1
  15. package/dist/elements/ui-part.d.ts +3 -3
  16. package/dist/elements/ui-part.d.ts.map +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.mjs +376 -319
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/shared/are-maps-equal.d.ts +11 -0
  22. package/dist/shared/are-maps-equal.d.ts.map +1 -0
  23. package/dist/shared/async-registry.d.ts +44 -16
  24. package/dist/shared/async-registry.d.ts.map +1 -1
  25. package/dist/shared/index.d.ts +1 -0
  26. package/dist/shared/index.d.ts.map +1 -1
  27. package/package.json +3 -3
  28. package/src/elements/editable.ts +57 -44
  29. package/src/elements/editor/editor.ts +151 -140
  30. package/src/elements/editor/utils/cleanup-orphan-editor-elements.test.ts +285 -0
  31. package/src/elements/editor/utils/cleanup-orphan-editor-elements.ts +60 -0
  32. package/src/elements/editor/utils/create-editor-in-context.ts +7 -2
  33. package/src/elements/editor/utils/index.ts +2 -0
  34. package/src/elements/editor/utils/is-multiroot-editor-instance.ts +8 -0
  35. package/src/elements/editor/utils/wrap-with-watchdog.test.ts +34 -14
  36. package/src/elements/editor/utils/wrap-with-watchdog.ts +16 -26
  37. package/src/elements/ui-part.test.ts +1 -1
  38. package/src/elements/ui-part.ts +12 -10
  39. package/src/shared/are-maps-equal.test.ts +56 -0
  40. package/src/shared/are-maps-equal.ts +22 -0
  41. package/src/shared/async-registry.test.ts +190 -88
  42. package/src/shared/async-registry.ts +179 -107
  43. package/src/shared/index.ts +1 -0
@@ -3,9 +3,9 @@
3
3
  */
4
4
  export declare class EditableComponentElement extends HTMLElement {
5
5
  /**
6
- * The promise that resolves when the editable is mounted.
6
+ * Stops observing the editor registry and immediately runs any pending cleanup.
7
7
  */
8
- private editorPromise;
8
+ private unmountEffect;
9
9
  /**
10
10
  * Mounts the editable component.
11
11
  */
@@ -13,6 +13,6 @@ export declare class EditableComponentElement extends HTMLElement {
13
13
  /**
14
14
  * Destroys the editable component. Unmounts root from the editor.
15
15
  */
16
- disconnectedCallback(): Promise<void>;
16
+ disconnectedCallback(): void;
17
17
  }
18
18
  //# sourceMappingURL=editable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../../../src/elements/editable.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACvD;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgD;IAErE;;OAEG;IACG,iBAAiB;IA2EvB;;OAEG;IACG,oBAAoB;CA2B3B"}
1
+ {"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../../../src/elements/editable.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACvD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACG,iBAAiB;IA2GvB;;OAEG;IACH,oBAAoB;CAQrB"}
@@ -3,18 +3,22 @@
3
3
  */
4
4
  export declare class EditorComponentElement extends HTMLElement {
5
5
  /**
6
- * The promise that resolves to the editor instance.
6
+ * Stops observing the editor registry and immediately runs any pending cleanup.
7
7
  */
8
- private editorPromise;
8
+ private unmountEffect;
9
9
  /**
10
10
  * Mounts the editor component.
11
11
  */
12
12
  connectedCallback(): Promise<void>;
13
+ /**
14
+ * Initializes the editor instance.
15
+ */
16
+ private initializeEditor;
13
17
  /**
14
18
  * Destroys the editor instance when the component is destroyed.
15
19
  * This is important to prevent memory leaks and ensure that the editor is properly cleaned up.
16
20
  */
17
- disconnectedCallback(): Promise<void>;
21
+ disconnectedCallback(): void;
18
22
  /**
19
23
  * Creates the CKEditor instance.
20
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/editor.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgC;IAErD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiCxC;;;OAGG;IACG,oBAAoB;IAmC1B;;OAEG;YACW,YAAY;CA6I3B"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/editor.ts"],"names":[],"mappings":"AA4BA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxC;;OAEG;YACW,gBAAgB;IAwD9B;;;OAGG;IACH,oBAAoB;IASpB;;OAEG;YACW,YAAY;CAoJ3B"}
@@ -0,0 +1,8 @@
1
+ import { Editor } from 'ckeditor5';
2
+ /**
3
+ * Removes all DOM elements injected by a specific CKEditor instance.
4
+ * Call this before assigning a new instance (e.g. in the 'restart' watchdog handler),
5
+ * because the watchdog does not clean up the previous editor's DOM on its own.
6
+ */
7
+ export declare function cleanupOrphanEditorElements(editor: Editor): void;
8
+ //# sourceMappingURL=cleanup-orphan-editor-elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup-orphan-editor-elements.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/cleanup-orphan-editor-elements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAoDhE"}
@@ -1,5 +1,4 @@
1
1
  import { Context, ContextWatchdog, Editor, EditorConfig } from 'ckeditor5';
2
- import { EditorCreator } from './wrap-with-watchdog';
3
2
  /**
4
3
  * Creates a CKEditor 5 editor instance within a given context watchdog.
5
4
  *
@@ -40,5 +39,11 @@ type EditorContextDescriptor = {
40
39
  editorContextId: string;
41
40
  context: ContextWatchdog<Context>;
42
41
  };
42
+ /**
43
+ * Type representing an Editor creator with a create method.
44
+ */
45
+ type EditorCreator = {
46
+ create: (...args: any) => Promise<Editor>;
47
+ };
43
48
  export {};
44
49
  //# sourceMappingURL=create-editor-in-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-editor-in-context.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/create-editor-in-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAU1D;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK;;WAgE/E,WAAW,GAAG,aAAa;qBACjB,MAAM;aACd,eAAe,CAAC,OAAO,CAAC;GAhClC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAMlF;AAED;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,WAAW,GAAG,aAAa,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC"}
1
+ {"version":3,"file":"create-editor-in-context.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/create-editor-in-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUhF;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK;;WAgE/E,WAAW,GAAG,aAAa;qBACjB,MAAM;aACd,eAAe,CAAC,OAAO,CAAC;GAhClC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAMlF;AAED;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,WAAW,GAAG,aAAa,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC"}
@@ -1,5 +1,7 @@
1
+ export * from './cleanup-orphan-editor-elements';
1
2
  export * from './create-editor-in-context';
2
3
  export * from './get-editor-roots-values';
4
+ export * from './is-multiroot-editor-instance';
3
5
  export * from './is-single-root-editor';
4
6
  export * from './load-editor-constructor';
5
7
  export * from './load-editor-plugins';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Editor, MultiRootEditor } from 'ckeditor5';
2
+ /**
3
+ * Check if passed editor is multiroot editor.
4
+ */
5
+ export declare function isMultirootEditorInstance(editor: Editor): editor is MultiRootEditor;
6
+ //# sourceMappingURL=is-multiroot-editor-instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-multiroot-editor-instance.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/is-multiroot-editor-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEzD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,eAAe,CAEnF"}
@@ -1,24 +1,15 @@
1
- import { Editor, EditorWatchdog } from 'ckeditor5';
1
+ import { Editor, EditorWatchdog, WatchdogConfig } from 'ckeditor5';
2
2
  /**
3
- * Wraps an Editor creator with a watchdog for automatic recovery.
3
+ * Wraps an editor factory with a watchdog for automatic recovery.
4
+ * The factory is invoked on each (re)start, so configuration is rebuilt every time.
4
5
  *
5
- * @param Editor - The Editor creator to wrap.
6
- * @returns The Editor creator wrapped with a watchdog.
6
+ * @param factory Async function that creates and returns an Editor instance.
7
+ * @param watchdogConfig Configuration of the watchdog.
8
+ * @returns The watchdog instance.
7
9
  */
8
- export declare function wrapWithWatchdog(Editor: EditorCreator): Promise<{
9
- watchdog: EditorWatchdog<Editor>;
10
- Constructor: {
11
- create: (...args: Parameters<(typeof Editor)["create"]>) => Promise<Editor>;
12
- };
13
- }>;
10
+ export declare function wrapWithWatchdog(factory: () => Promise<Editor>, watchdogConfig?: WatchdogConfig | null): Promise<EditorWatchdog<Editor>>;
14
11
  /**
15
12
  * Unwraps the EditorWatchdog from the editor instance.
16
13
  */
17
14
  export declare function unwrapEditorWatchdog(editor: Editor): EditorWatchdog | null;
18
- /**
19
- * Type representing an Editor creator with a create method.
20
- */
21
- export type EditorCreator = {
22
- create: (...args: any) => Promise<Editor>;
23
- };
24
15
  //# sourceMappingURL=wrap-with-watchdog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-with-watchdog.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/wrap-with-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIxD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,aAAa;;;0BAe9B,UAAU,CAAC,CAAA,OAAO,MAAM,EAAC,QAAQ,CAAC,CAAC;;GAOhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM1E;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC"}
1
+ {"version":3,"file":"wrap-with-watchdog.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/wrap-with-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIxE;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,mCAiB5G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM1E"}
@@ -3,9 +3,9 @@
3
3
  */
4
4
  export declare class UIPartComponentElement extends HTMLElement {
5
5
  /**
6
- * The promise that resolves when the UI part is mounted.
6
+ * Stops observing the editor registry and immediately runs any pending cleanup.
7
7
  */
8
- private mountedPromise;
8
+ private unmountEffect;
9
9
  /**
10
10
  * Mounts the UI part component.
11
11
  */
@@ -13,6 +13,6 @@ export declare class UIPartComponentElement extends HTMLElement {
13
13
  /**
14
14
  * Destroys the UI part component. Unmounts UI parts from the editor.
15
15
  */
16
- disconnectedCallback(): Promise<void>;
16
+ disconnectedCallback(): void;
17
17
  }
18
18
  //# sourceMappingURL=ui-part.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui-part.d.ts","sourceRoot":"","sources":["../../../src/elements/ui-part.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,cAAc,CAA8B;IAEpD;;OAEG;IACG,iBAAiB;IAgCvB;;OAEG;IACG,oBAAoB;CAW3B"}
1
+ {"version":3,"file":"ui-part.d.ts","sourceRoot":"","sources":["../../../src/elements/ui-part.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACG,iBAAiB;IAqCvB;;OAEG;IACH,oBAAoB;CAQrB"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var Z=Object.create;var W=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var at=(i,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of et(t))!it.call(i,n)&&n!==r&&W(i,n,{get:()=>t[n],enumerable:!(a=tt(t,n))||a.enumerable});return i};var e=(i,t,r)=>(r=i!=null?Z(rt(i)):{},at(t||!i||!i.__esModule?W(r,"default",{value:i,enumerable:!0}):r,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class H{items=new Map;initializationErrors=new Map;pendingCallbacks=new Map;watchers=new Set;execute(t,r,a){const n=this.items.get(t),s=this.initializationErrors.get(t);return s?(a?.(s),Promise.reject(s)):n?Promise.resolve(r(n)):new Promise((o,c)=>{const u=this.getPendingCallbacks(t);u.success.push(async l=>{o(await r(l))}),a?u.error.push(a):u.error.push(c)})}register(t,r){if(this.items.has(t))throw new Error(`Item with ID "${t}" is already registered.`);this.resetErrors(t),this.items.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.success.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.registerAsDefault(t,r),this.notifyWatchers()}error(t,r){this.items.delete(t),this.initializationErrors.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.error.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.initializationErrors.size===1&&!this.items.size&&this.error(null,r),this.notifyWatchers()}resetErrors(t){const{initializationErrors:r}=this;r.has(null)&&r.get(null)===r.get(t)&&r.delete(null),r.delete(t)}unregister(t){if(!this.items.has(t))throw new Error(`Item with ID "${t}" is not registered.`);t&&this.items.get(null)===this.items.get(t)&&this.unregister(null),this.items.delete(t),this.pendingCallbacks.delete(t),this.notifyWatchers()}getItems(){return Array.from(this.items.values())}hasItem(t){return this.items.has(t)}waitFor(t,r){return new Promise((a,n)=>{let s=!1,o=null;this.execute(t,c=>{s||(o!==null&&clearTimeout(o),a(c))},c=>{s||(o!==null&&clearTimeout(o),n(c))}),r&&(o=setTimeout(()=>{s=!0,n(new Error(`Timeout waiting for item with ID "${t}" to be registered.`))},r))})}async destroyAll(){const t=Array.from(new Set(this.items.values())).map(r=>r.destroy());this.items.clear(),this.pendingCallbacks.clear(),await Promise.all(t),this.notifyWatchers()}watch(t){return this.watchers.add(t),t(new Map(this.items),new Map(this.initializationErrors)),this.unwatch.bind(this,t)}unwatch(t){this.watchers.delete(t)}reset(){this.items.clear(),this.initializationErrors.clear(),this.pendingCallbacks.clear(),this.notifyWatchers()}notifyWatchers(){this.watchers.forEach(t=>t(new Map(this.items),new Map(this.initializationErrors)))}getPendingCallbacks(t){let r=this.pendingCallbacks.get(t);return r||(r={success:[],error:[]},this.pendingCallbacks.set(t,r)),r}registerAsDefault(t,r){this.items.size===1&&t!==null&&this.register(null,r)}}function M(i,t){let r=null;return(...a)=>{r&&clearTimeout(r),r=setTimeout(()=>{t(...a)},i)}}function nt(i,t){const r=Object.entries(i).filter(([a,n])=>t(n,a));return Object.fromEntries(r)}function U(i){return Object.keys(i).length===0&&i.constructor===Object}function R(i,t){const r=Object.entries(i).map(([a,n])=>[a,t(n,a)]);return Object.fromEntries(r)}function st(){return Math.random().toString(36).substring(2)}function ot(i,{timeOutAfter:t=500,retryAfter:r=100}={}){return new Promise((a,n)=>{const s=Date.now();let o=null;const c=setTimeout(()=>{n(o??new Error("Timeout"))},t),u=async()=>{try{const l=await i();clearTimeout(c),a(l)}catch(l){o=l,Date.now()-s>t?n(l):setTimeout(u,r)}};u()})}function I(){return new Promise(i=>{switch(document.readyState){case"loading":document.addEventListener("DOMContentLoaded",()=>i(),{once:!0});break;case"interactive":case"complete":setTimeout(i,0);break;default:console.warn("Unexpected document.readyState:",document.readyState),setTimeout(i,0)}})}const D=Symbol.for("context-editor-watchdog");async function ct({element:i,context:t,creator:r,config:a}){const n=st();await t.add({creator:(u,l)=>r.create(u,l),id:n,sourceElementOrData:i,type:"editor",config:a});const s=t.getItem(n),o={state:"available",editorContextId:n,context:t};s[D]=o;const c=t.destroy.bind(t);return t.destroy=async()=>(o.state="unavailable",c()),{...o,editor:s}}function ut(i){return D in i?i[D]:null}function lt(i){return Array.from(i.model.document.getRoots()).reduce((t,r)=>(r.rootName==="$graveyard"||(t[r.rootName]=i.getData({rootName:r.rootName})),t),Object.create({}))}function v(i){return["inline","classic","balloon","decoupled"].includes(i)}class w extends Error{constructor(t){super(t),this.name="CKEditor5SymfonyError"}}async function mt(i){const t=await import("ckeditor5"),a={inline:t.InlineEditor,balloon:t.BalloonEditor,classic:t.ClassicEditor,decoupled:t.DecoupledEditor,multiroot:t.MultiRootEditor}[i];if(!a)throw new w(`Unsupported editor type: ${i}`);return a}class x{static the=new x;plugins=new Map;constructor(){}register(t,r){if(this.plugins.has(t))throw new w(`Plugin with name "${t}" is already registered.`);return this.plugins.set(t,r),this.unregister.bind(this,t)}unregister(t){if(!this.plugins.has(t))throw new w(`Plugin with name "${t}" is not registered.`);this.plugins.delete(t)}unregisterAll(){this.plugins.clear()}async get(t){return this.plugins.get(t)?.()}has(t){return this.plugins.has(t)}}async function V(i){const t=await import("ckeditor5");let r=null;const a=i.map(async n=>{const s=await x.the.get(n);if(s)return s;const{[n]:o}=t;if(o)return o;if(!r)try{r=await import("ckeditor5-premium-features")}catch(u){throw console.error(`Failed to load premium package: ${u}`),new w(`Plugin "${n}" not found in base package and failed to load premium package.`)}const{[n]:c}=r||{};if(c)return c;throw new w(`Plugin "${n}" not found in base or premium packages.`)});return{loadedPlugins:await Promise.all(a),hasPremium:!!r}}async function B(i,t){const r=[i.ui,i.content];return await Promise.all([q("ckeditor5",r),t&&q("ckeditor5-premium-features",r)].filter(n=>!!n)).then(n=>n.flat())}async function q(i,t){return await Promise.all(t.filter(r=>r!=="en").map(async r=>{const a=await dt(i,r);return a?.default??a}).filter(Boolean))}async function dt(i,t){try{if(i==="ckeditor5")switch(t){case"af":return await import("ckeditor5/translations/af.js");case"ar":return await import("ckeditor5/translations/ar.js");case"ast":return await import("ckeditor5/translations/ast.js");case"az":return await import("ckeditor5/translations/az.js");case"bg":return await import("ckeditor5/translations/bg.js");case"bn":return await import("ckeditor5/translations/bn.js");case"bs":return await import("ckeditor5/translations/bs.js");case"ca":return await import("ckeditor5/translations/ca.js");case"cs":return await import("ckeditor5/translations/cs.js");case"da":return await import("ckeditor5/translations/da.js");case"de":return await import("ckeditor5/translations/de.js");case"de-ch":return await import("ckeditor5/translations/de-ch.js");case"el":return await import("ckeditor5/translations/el.js");case"en":return await import("ckeditor5/translations/en.js");case"en-au":return await import("ckeditor5/translations/en-au.js");case"en-gb":return await import("ckeditor5/translations/en-gb.js");case"eo":return await import("ckeditor5/translations/eo.js");case"es":return await import("ckeditor5/translations/es.js");case"es-co":return await import("ckeditor5/translations/es-co.js");case"et":return await import("ckeditor5/translations/et.js");case"eu":return await import("ckeditor5/translations/eu.js");case"fa":return await import("ckeditor5/translations/fa.js");case"fi":return await import("ckeditor5/translations/fi.js");case"fr":return await import("ckeditor5/translations/fr.js");case"gl":return await import("ckeditor5/translations/gl.js");case"gu":return await import("ckeditor5/translations/gu.js");case"he":return await import("ckeditor5/translations/he.js");case"hi":return await import("ckeditor5/translations/hi.js");case"hr":return await import("ckeditor5/translations/hr.js");case"hu":return await import("ckeditor5/translations/hu.js");case"hy":return await import("ckeditor5/translations/hy.js");case"id":return await import("ckeditor5/translations/id.js");case"it":return await import("ckeditor5/translations/it.js");case"ja":return await import("ckeditor5/translations/ja.js");case"jv":return await import("ckeditor5/translations/jv.js");case"kk":return await import("ckeditor5/translations/kk.js");case"km":return await import("ckeditor5/translations/km.js");case"kn":return await import("ckeditor5/translations/kn.js");case"ko":return await import("ckeditor5/translations/ko.js");case"ku":return await import("ckeditor5/translations/ku.js");case"lt":return await import("ckeditor5/translations/lt.js");case"lv":return await import("ckeditor5/translations/lv.js");case"ms":return await import("ckeditor5/translations/ms.js");case"nb":return await import("ckeditor5/translations/nb.js");case"ne":return await import("ckeditor5/translations/ne.js");case"nl":return await import("ckeditor5/translations/nl.js");case"no":return await import("ckeditor5/translations/no.js");case"oc":return await import("ckeditor5/translations/oc.js");case"pl":return await import("ckeditor5/translations/pl.js");case"pt":return await import("ckeditor5/translations/pt.js");case"pt-br":return await import("ckeditor5/translations/pt-br.js");case"ro":return await import("ckeditor5/translations/ro.js");case"ru":return await import("ckeditor5/translations/ru.js");case"si":return await import("ckeditor5/translations/si.js");case"sk":return await import("ckeditor5/translations/sk.js");case"sl":return await import("ckeditor5/translations/sl.js");case"sq":return await import("ckeditor5/translations/sq.js");case"sr":return await import("ckeditor5/translations/sr.js");case"sr-latn":return await import("ckeditor5/translations/sr-latn.js");case"sv":return await import("ckeditor5/translations/sv.js");case"th":return await import("ckeditor5/translations/th.js");case"tk":return await import("ckeditor5/translations/tk.js");case"tr":return await import("ckeditor5/translations/tr.js");case"tt":return await import("ckeditor5/translations/tt.js");case"ug":return await import("ckeditor5/translations/ug.js");case"uk":return await import("ckeditor5/translations/uk.js");case"ur":return await import("ckeditor5/translations/ur.js");case"uz":return await import("ckeditor5/translations/uz.js");case"vi":return await import("ckeditor5/translations/vi.js");case"zh":return await import("ckeditor5/translations/zh.js");case"zh-cn":return await import("ckeditor5/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in ckeditor5 translations`),null}else switch(t){case"af":return await import("ckeditor5-premium-features/translations/af.js");case"ar":return await import("ckeditor5-premium-features/translations/ar.js");case"ast":return await import("ckeditor5-premium-features/translations/ast.js");case"az":return await import("ckeditor5-premium-features/translations/az.js");case"bg":return await import("ckeditor5-premium-features/translations/bg.js");case"bn":return await import("ckeditor5-premium-features/translations/bn.js");case"bs":return await import("ckeditor5-premium-features/translations/bs.js");case"ca":return await import("ckeditor5-premium-features/translations/ca.js");case"cs":return await import("ckeditor5-premium-features/translations/cs.js");case"da":return await import("ckeditor5-premium-features/translations/da.js");case"de":return await import("ckeditor5-premium-features/translations/de.js");case"de-ch":return await import("ckeditor5-premium-features/translations/de-ch.js");case"el":return await import("ckeditor5-premium-features/translations/el.js");case"en":return await import("ckeditor5-premium-features/translations/en.js");case"en-au":return await import("ckeditor5-premium-features/translations/en-au.js");case"en-gb":return await import("ckeditor5-premium-features/translations/en-gb.js");case"eo":return await import("ckeditor5-premium-features/translations/eo.js");case"es":return await import("ckeditor5-premium-features/translations/es.js");case"es-co":return await import("ckeditor5-premium-features/translations/es-co.js");case"et":return await import("ckeditor5-premium-features/translations/et.js");case"eu":return await import("ckeditor5-premium-features/translations/eu.js");case"fa":return await import("ckeditor5-premium-features/translations/fa.js");case"fi":return await import("ckeditor5-premium-features/translations/fi.js");case"fr":return await import("ckeditor5-premium-features/translations/fr.js");case"gl":return await import("ckeditor5-premium-features/translations/gl.js");case"gu":return await import("ckeditor5-premium-features/translations/gu.js");case"he":return await import("ckeditor5-premium-features/translations/he.js");case"hi":return await import("ckeditor5-premium-features/translations/hi.js");case"hr":return await import("ckeditor5-premium-features/translations/hr.js");case"hu":return await import("ckeditor5-premium-features/translations/hu.js");case"hy":return await import("ckeditor5-premium-features/translations/hy.js");case"id":return await import("ckeditor5-premium-features/translations/id.js");case"it":return await import("ckeditor5-premium-features/translations/it.js");case"ja":return await import("ckeditor5-premium-features/translations/ja.js");case"jv":return await import("ckeditor5-premium-features/translations/jv.js");case"kk":return await import("ckeditor5-premium-features/translations/kk.js");case"km":return await import("ckeditor5-premium-features/translations/km.js");case"kn":return await import("ckeditor5-premium-features/translations/kn.js");case"ko":return await import("ckeditor5-premium-features/translations/ko.js");case"ku":return await import("ckeditor5-premium-features/translations/ku.js");case"lt":return await import("ckeditor5-premium-features/translations/lt.js");case"lv":return await import("ckeditor5-premium-features/translations/lv.js");case"ms":return await import("ckeditor5-premium-features/translations/ms.js");case"nb":return await import("ckeditor5-premium-features/translations/nb.js");case"ne":return await import("ckeditor5-premium-features/translations/ne.js");case"nl":return await import("ckeditor5-premium-features/translations/nl.js");case"no":return await import("ckeditor5-premium-features/translations/no.js");case"oc":return await import("ckeditor5-premium-features/translations/oc.js");case"pl":return await import("ckeditor5-premium-features/translations/pl.js");case"pt":return await import("ckeditor5-premium-features/translations/pt.js");case"pt-br":return await import("ckeditor5-premium-features/translations/pt-br.js");case"ro":return await import("ckeditor5-premium-features/translations/ro.js");case"ru":return await import("ckeditor5-premium-features/translations/ru.js");case"si":return await import("ckeditor5-premium-features/translations/si.js");case"sk":return await import("ckeditor5-premium-features/translations/sk.js");case"sl":return await import("ckeditor5-premium-features/translations/sl.js");case"sq":return await import("ckeditor5-premium-features/translations/sq.js");case"sr":return await import("ckeditor5-premium-features/translations/sr.js");case"sr-latn":return await import("ckeditor5-premium-features/translations/sr-latn.js");case"sv":return await import("ckeditor5-premium-features/translations/sv.js");case"th":return await import("ckeditor5-premium-features/translations/th.js");case"tk":return await import("ckeditor5-premium-features/translations/tk.js");case"tr":return await import("ckeditor5-premium-features/translations/tr.js");case"tt":return await import("ckeditor5-premium-features/translations/tt.js");case"ug":return await import("ckeditor5-premium-features/translations/ug.js");case"uk":return await import("ckeditor5-premium-features/translations/uk.js");case"ur":return await import("ckeditor5-premium-features/translations/ur.js");case"uz":return await import("ckeditor5-premium-features/translations/uz.js");case"vi":return await import("ckeditor5-premium-features/translations/vi.js");case"zh":return await import("ckeditor5-premium-features/translations/zh.js");case"zh-cn":return await import("ckeditor5-premium-features/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in premium translations`),await import("ckeditor5-premium-features/translations/en.js")}}catch(r){return console.error(`Failed to load translation for ${i}/${t}:`,r),null}}function F(i){return R(i,t=>({dictionary:t}))}function J(){return Array.from(document.querySelectorAll("cke5-editor")).map(i=>i.getAttribute("data-cke-editor-id")).filter(i=>i!==null)}function K(i){const t=_(i);return R(t,({element:r})=>r)}function j(i){const t=_(i),r=R(t,({content:a})=>a);return nt(r,a=>typeof a=="string")}function _(i){const t=Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${i}"]`)).reduce((o,c)=>{const u=c.getAttribute("data-cke-root-name"),l=c.getAttribute("data-cke-content");return o[u]={element:c.querySelector("[data-cke-editable-content]"),content:l},o},Object.create({})),r=document.querySelector(`cke5-editor[data-cke-editor-id="${i}"]`);if(!r)return t;const a=t.main,n=JSON.parse(r.getAttribute("data-cke-content")),s=document.querySelector(`#${i}_editor `);return a&&n?.main?{...t,main:{...a,content:a.content||n.main}}:s?{...t,main:{element:s,content:n?.main||null}}:t}function A(i){if(!i||typeof i!="object")return i;if(Array.isArray(i))return i.map(a=>A(a));const t=i;if(t.$element&&typeof t.$element=="string"){const a=document.querySelector(t.$element);return a||console.warn(`Element not found for selector: ${t.$element}`),a||null}const r=Object.create(null);for(const[a,n]of Object.entries(i))r[a]=A(n);return r}function T(i,t,r){if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(s=>T(i,t,s));const a=r;if(a.$translation&&typeof a.$translation=="string"){const s=a.$translation,o=pt(i,s,t);return o===void 0&&console.warn(`Translation not found for key: ${s}`),o!==void 0?o:null}const n=Object.create(null);for(const[s,o]of Object.entries(r))n[s]=T(i,t,o);return n}function pt(i,t,r){for(const a of i){const n=a[r];if(n?.dictionary&&t in n.dictionary)return n.dictionary[t]}}function ht(i,t){const{editing:r}=i;r.view.change(a=>{a.setStyle("height",`${t}px`,r.view.document.getRoot())})}const $=Symbol.for("elixir-editor-watchdog");async function wt(i){const{EditorWatchdog:t}=await import("ckeditor5"),r=new t(i);return r.setCreator(async(...a)=>{const n=await i.create(...a);return n[$]=r,n}),{watchdog:r,Constructor:{create:async(...a)=>(await r.create(...a),r.editor)}}}function ft(i){return $ in i?i[$]:null}class b extends H{static the=new b}class gt extends HTMLElement{contextPromise=null;async connectedCallback(){await I();const t=this.getAttribute("data-cke-context-id"),r=JSON.parse(this.getAttribute("data-cke-language")),a=JSON.parse(this.getAttribute("data-cke-context")),{customTranslations:n,watchdogConfig:s,config:{plugins:o,...c}}=a,{loadedPlugins:u,hasPremium:l}=await V(o??[]),f=[...await B(r,l),F(n||{})].filter(d=>!U(d));this.contextPromise=(async()=>{const{ContextWatchdog:d,Context:k}=await import("ckeditor5"),g=new d(k,{crashNumberLimit:10,...s});let y=A(c);return y=T([...f].reverse(),r.ui,y),await g.create({...y,language:r,plugins:u,...f.length&&{translations:f}}),g.on("itemError",(...O)=>{console.error("Context item error:",...O)}),g})();const E=await this.contextPromise;this.isConnected&&b.the.register(t,E)}async disconnectedCallback(){const t=this.getAttribute("data-cke-context-id");this.style.display="none";try{await(await this.contextPromise)?.destroy()}finally{this.contextPromise=null,t&&b.the.hasItem(t)&&b.the.unregister(t)}}}class p extends H{static the=new p}class G extends HTMLElement{editorPromise=null;async connectedCallback(){await I(),this.hasAttribute("data-cke-editor-id")||this.setAttribute("data-cke-editor-id",J()[0]);const t=this.getAttribute("data-cke-editor-id"),r=this.getAttribute("data-cke-root-name"),a=this.getAttribute("data-cke-content"),n=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10);if(!t||!r)throw new w("Editor ID or Root Name is missing.");this.style.display="block",this.editorPromise=p.the.execute(t,async s=>{if(!this.isConnected)return null;const o=this.querySelector("input"),{ui:c,editing:u,model:l}=s;if(l.document.getRoot(r)){if(a!==null){const d=s.getData({rootName:r});d&&d!==a&&s.setData({[r]:a})}return s}s.addRoot(r,{isUndoable:!1,...a!==null&&{data:a}});const h=this.querySelector("[data-cke-editable-content]"),f=c.view.createEditable(r,h);c.addEditable(f),u.view.forceRender();const E=()=>{const d=s.getData({rootName:r});o&&(o.value=d,o.dispatchEvent(new Event("input"))),this.dispatchEvent(new CustomEvent("change",{detail:{value:d}}))};return s.model.document.on("change:data",M(n,E)),E(),s})}async disconnectedCallback(){const t=this.getAttribute("data-cke-root-name");this.style.display="none";const r=await this.editorPromise;if(this.editorPromise=null,r&&r.state!=="destroyed"&&t){const a=r.model.document.getRoot(t);if(a&&"detachEditable"in r){try{r.detachEditable(a)}catch(n){console.error("Unable unmount editable from root:",n)}r.detachRoot(t,!1)}}}}async function yt({saveDebounceMs:i,editorId:t,targetElement:r}){const{Plugin:a}=await import("ckeditor5");return class extends a{static get pluginName(){return"DispatchEditorRootsChangeEvent"}afterInit(){const s=M(i,this.dispatch);this.editor.model.document.on("change:data",s),this.editor.once("ready",this.dispatch)}dispatch=()=>{r.dispatchEvent(new CustomEvent("ckeditor5:change:data",{detail:{editorId:t,editor:this.editor,roots:lt(this.editor)},bubbles:!0}))}}}async function bt(i){const{Plugin:t}=await import("ckeditor5");return class extends t{input=null;form=null;static get pluginName(){return"SyncEditorWithInput"}afterInit(){const{editor:a}=this,s=a.sourceElement.id.replace(/_editor$/,"");this.input=document.getElementById(`${s}_input`),this.input&&(a.model.document.on("change:data",M(i,()=>this.sync())),a.once("ready",this.sync),this.form=this.input.closest("form"),this.form?.addEventListener("submit",this.sync))}sync=()=>{if(this.input){const a=this.editor.getData();this.input.value=a,this.input.dispatchEvent(new Event("input",{bubbles:!0}))}};destroy(){this.form&&this.form.removeEventListener("submit",this.sync),this.input=null,this.form=null}}}class Y extends HTMLElement{editorPromise=null;async connectedCallback(){await I();const t=this.getAttribute("data-cke-editor-id");p.the.resetErrors(t);try{this.style.display="block",this.editorPromise=this.createEditor();const r=await this.editorPromise;this.isConnected&&(p.the.register(t,r),r.once("destroy",()=>{p.the.hasItem(t)&&p.the.unregister(t)}))}catch(r){console.error(`Error initializing CKEditor5 instance with ID "${t}":`,r),this.editorPromise=null,p.the.error(t,r)}}async disconnectedCallback(){this.style.display="none";try{const t=await this.editorPromise;if(!t)return;const r=ut(t),a=ft(t);r?r.state!=="unavailable"&&await r.context.remove(r.editorContextId):a?await a.destroy():await t.destroy()}finally{this.editorPromise=null}}async createEditor(){const t=this.getAttribute("data-cke-editor-id"),r=JSON.parse(this.getAttribute("data-cke-preset")),a=this.getAttribute("data-cke-context-id"),n=this.getAttribute("data-cke-editable-height")?Number.parseInt(this.getAttribute("data-cke-editable-height"),10):null,s=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10),o=JSON.parse(this.getAttribute("data-cke-language")),c=this.hasAttribute("data-cke-watchdog"),u=JSON.parse(this.getAttribute("data-cke-content")),{customTranslations:l,editorType:h,licenseKey:f,config:{plugins:E,...d}}=r;let k=await mt(h);const g=await(a?b.the.waitFor(a):null);if(c&&!g){const m=await wt(k);({Constructor:k}=m),m.watchdog.on("restart",()=>{const C=m.watchdog.editor;this.editorPromise=Promise.resolve(C),p.the.register(t,C)})}const{loadedPlugins:y,hasPremium:O}=await V(E);y.push(await yt({saveDebounceMs:s,editorId:t,targetElement:this})),v(h)&&y.push(await bt(s));const S=[...await B(o,O),F(l||{})].filter(m=>!U(m));let P={...u,...j(t)};v(h)&&(P=P.main||"");const z=await(async()=>{let m=K(t);if(!m.main){const L=v(h)?["main"]:Object.keys(P);X(m,L)||(m=await Et(t,L),P={...u,...j(t)})}v(h)&&"main"in m&&(m=m.main);let C=A(d);C=T([...S].reverse(),o.ui,C);const N={...C,initialData:P,licenseKey:f,plugins:y,language:o,...S.length&&{translations:S}};return!g||!(m instanceof HTMLElement)?k.create(m,N):(await ct({context:g,element:m,creator:k,config:N})).editor})();return v(h)&&n&&ht(z,n),z}}function X(i,t){return t.every(r=>i[r])}async function Et(i,t){return ot(()=>{const r=K(i);if(!X(r,t))throw new Error(`It looks like not all required root elements are present yet.
1
+ "use strict";var rt=Object.create;var W=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var ot=(i,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of at(t))!st.call(i,n)&&n!==r&&W(i,n,{get:()=>t[n],enumerable:!(a=it(t,n))||a.enumerable});return i};var e=(i,t,r)=>(r=i!=null?rt(nt(i)):{},ot(t||!i||!i.__esModule?W(r,"default",{value:i,enumerable:!0}):r,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(i,t){if(!i||i.size!==t.size)return!1;for(const[r,a]of i)if(!t.has(r)||t.get(r)!==a)return!1;return!0}class B{items=new Map;initializationErrors=new Map;pendingCallbacks=new Map;watchers=new Set;batchDepth=0;lastNotifiedItems=null;lastNotifiedErrors=null;execute(t,r,a){const n=this.items.get(t),s=this.initializationErrors.get(t);return s?(a?.(s),Promise.reject(s)):n?Promise.resolve(r(n)):new Promise((o,l)=>{const u=this.getPendingCallbacks(t);u.success.push(async c=>{o(await r(c))}),a?u.error.push(a):u.error.push(l)})}mountEffect(t,r){let a,n,s=!1;const o=this.watch(l=>{const u=l.get(t);if(u!==n&&(a?.(),a=void 0,n=u,!!u))try{const c=r(u);s?(c?.(),o()):a=c}catch(c){throw console.error(c),c}});return()=>{s=!0,n&&(o(),a?.(),a=void 0)}}register(t,r){this.batch(()=>{if(this.items.has(t))throw new Error(`Item with ID "${t}" is already registered.`);this.resetErrors(t),this.items.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.success.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.items.size===1&&t!==null&&this.register(null,r)})}error(t,r){this.batch(()=>{this.items.delete(t),this.initializationErrors.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.error.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.initializationErrors.size===1&&!this.items.size&&this.error(null,r)})}resetErrors(t){const{initializationErrors:r}=this;r.has(null)&&r.get(null)===r.get(t)&&r.delete(null),r.delete(t)}unregister(t,r=!0){this.batch(()=>{t&&this.items.get(null)===this.items.get(t)&&this.unregister(null,!1),this.items.delete(t),r&&this.pendingCallbacks.delete(t),this.resetErrors(t)})}getItems(){return Array.from(this.items.values())}getItem(t){return this.items.get(t)}hasItem(t){return this.items.has(t)}waitFor(t){return new Promise((r,a)=>{this.execute(t,r,a)})}async destroyAll(){const t=Array.from(new Set(this.items.values())).map(r=>r.destroy());this.items.clear(),this.pendingCallbacks.clear(),await Promise.all(t),this.flushWatchers()}async reset(){await this.destroyAll(),this.watchers.clear()}batch(t){this.batchDepth++;try{return t()}finally{this.batchDepth--,this.batchDepth===0&&this.flushWatchers()}}watch(t){return this.watchers.add(t),t(new Map(this.items),new Map(this.initializationErrors)),this.unwatch.bind(this,t)}unwatch(t){this.watchers.delete(t)}flushWatchers(){j(this.lastNotifiedItems,this.items)&&j(this.lastNotifiedErrors,this.initializationErrors)||(this.lastNotifiedItems=new Map(this.items),this.lastNotifiedErrors=new Map(this.initializationErrors),this.watchers.forEach(t=>t(new Map(this.items),new Map(this.initializationErrors))))}getPendingCallbacks(t){let r=this.pendingCallbacks.get(t);return r||(r={success:[],error:[]},this.pendingCallbacks.set(t,r)),r}}function $(i,t){let r=null;return(...a)=>{r&&clearTimeout(r),r=setTimeout(()=>{t(...a)},i)}}function ct(i,t){const r=Object.entries(i).filter(([a,n])=>t(n,a));return Object.fromEntries(r)}function F(i){return Object.keys(i).length===0&&i.constructor===Object}function z(i,t){const r=Object.entries(i).map(([a,n])=>[a,t(n,a)]);return Object.fromEntries(r)}function ut(){return Math.random().toString(36).substring(2)}function lt(i,{timeOutAfter:t=500,retryAfter:r=100}={}){return new Promise((a,n)=>{const s=Date.now();let o=null;const l=setTimeout(()=>{n(o??new Error("Timeout"))},t),u=async()=>{try{const c=await i();clearTimeout(l),a(c)}catch(c){o=c,Date.now()-s>t?n(c):setTimeout(u,r)}};u()})}function T(){return new Promise(i=>{switch(document.readyState){case"loading":document.addEventListener("DOMContentLoaded",()=>i(),{once:!0});break;case"interactive":case"complete":setTimeout(i,0);break;default:console.warn("Unexpected document.readyState:",document.readyState),setTimeout(i,0)}})}const M=Symbol.for("context-editor-watchdog");async function mt({element:i,context:t,creator:r,config:a}){const n=ut();await t.add({creator:(u,c)=>r.create(u,c),id:n,sourceElementOrData:i,type:"editor",config:a});const s=t.getItem(n),o={state:"available",editorContextId:n,context:t};s[M]=o;const l=t.destroy.bind(t);return t.destroy=async()=>(o.state="unavailable",l()),{...o,editor:s}}function dt(i){return M in i?i[M]:null}function ht(i){return Array.from(i.model.document.getRoots()).reduce((t,r)=>(r.rootName==="$graveyard"||(t[r.rootName]=i.getData({rootName:r.rootName})),t),Object.create({}))}function H(i){return"addEditable"in i.ui}function v(i){return["inline","classic","balloon","decoupled"].includes(i)}class w extends Error{constructor(t){super(t),this.name="CKEditor5SymfonyError"}}async function pt(i){const t=await import("ckeditor5"),a={inline:t.InlineEditor,balloon:t.BalloonEditor,classic:t.ClassicEditor,decoupled:t.DecoupledEditor,multiroot:t.MultiRootEditor}[i];if(!a)throw new w(`Unsupported editor type: ${i}`);return a}class x{static the=new x;plugins=new Map;constructor(){}register(t,r){if(this.plugins.has(t))throw new w(`Plugin with name "${t}" is already registered.`);return this.plugins.set(t,r),this.unregister.bind(this,t)}unregister(t){if(!this.plugins.has(t))throw new w(`Plugin with name "${t}" is not registered.`);this.plugins.delete(t)}unregisterAll(){this.plugins.clear()}async get(t){return this.plugins.get(t)?.()}has(t){return this.plugins.has(t)}}async function J(i){const t=await import("ckeditor5");let r=null;const a=i.map(async n=>{const s=await x.the.get(n);if(s)return s;const{[n]:o}=t;if(o)return o;if(!r)try{r=await import("ckeditor5-premium-features")}catch(u){throw console.error(`Failed to load premium package: ${u}`),new w(`Plugin "${n}" not found in base package and failed to load premium package.`)}const{[n]:l}=r||{};if(l)return l;throw new w(`Plugin "${n}" not found in base or premium packages.`)});return{loadedPlugins:await Promise.all(a),hasPremium:!!r}}async function K(i,t){const r=[i.ui,i.content];return await Promise.all([U("ckeditor5",r),t&&U("ckeditor5-premium-features",r)].filter(n=>!!n)).then(n=>n.flat())}async function U(i,t){return await Promise.all(t.filter(r=>r!=="en").map(async r=>{const a=await wt(i,r);return a?.default??a}).filter(Boolean))}async function wt(i,t){try{if(i==="ckeditor5")switch(t){case"af":return await import("ckeditor5/translations/af.js");case"ar":return await import("ckeditor5/translations/ar.js");case"ast":return await import("ckeditor5/translations/ast.js");case"az":return await import("ckeditor5/translations/az.js");case"bg":return await import("ckeditor5/translations/bg.js");case"bn":return await import("ckeditor5/translations/bn.js");case"bs":return await import("ckeditor5/translations/bs.js");case"ca":return await import("ckeditor5/translations/ca.js");case"cs":return await import("ckeditor5/translations/cs.js");case"da":return await import("ckeditor5/translations/da.js");case"de":return await import("ckeditor5/translations/de.js");case"de-ch":return await import("ckeditor5/translations/de-ch.js");case"el":return await import("ckeditor5/translations/el.js");case"en":return await import("ckeditor5/translations/en.js");case"en-au":return await import("ckeditor5/translations/en-au.js");case"en-gb":return await import("ckeditor5/translations/en-gb.js");case"eo":return await import("ckeditor5/translations/eo.js");case"es":return await import("ckeditor5/translations/es.js");case"es-co":return await import("ckeditor5/translations/es-co.js");case"et":return await import("ckeditor5/translations/et.js");case"eu":return await import("ckeditor5/translations/eu.js");case"fa":return await import("ckeditor5/translations/fa.js");case"fi":return await import("ckeditor5/translations/fi.js");case"fr":return await import("ckeditor5/translations/fr.js");case"gl":return await import("ckeditor5/translations/gl.js");case"gu":return await import("ckeditor5/translations/gu.js");case"he":return await import("ckeditor5/translations/he.js");case"hi":return await import("ckeditor5/translations/hi.js");case"hr":return await import("ckeditor5/translations/hr.js");case"hu":return await import("ckeditor5/translations/hu.js");case"hy":return await import("ckeditor5/translations/hy.js");case"id":return await import("ckeditor5/translations/id.js");case"it":return await import("ckeditor5/translations/it.js");case"ja":return await import("ckeditor5/translations/ja.js");case"jv":return await import("ckeditor5/translations/jv.js");case"kk":return await import("ckeditor5/translations/kk.js");case"km":return await import("ckeditor5/translations/km.js");case"kn":return await import("ckeditor5/translations/kn.js");case"ko":return await import("ckeditor5/translations/ko.js");case"ku":return await import("ckeditor5/translations/ku.js");case"lt":return await import("ckeditor5/translations/lt.js");case"lv":return await import("ckeditor5/translations/lv.js");case"ms":return await import("ckeditor5/translations/ms.js");case"nb":return await import("ckeditor5/translations/nb.js");case"ne":return await import("ckeditor5/translations/ne.js");case"nl":return await import("ckeditor5/translations/nl.js");case"no":return await import("ckeditor5/translations/no.js");case"oc":return await import("ckeditor5/translations/oc.js");case"pl":return await import("ckeditor5/translations/pl.js");case"pt":return await import("ckeditor5/translations/pt.js");case"pt-br":return await import("ckeditor5/translations/pt-br.js");case"ro":return await import("ckeditor5/translations/ro.js");case"ru":return await import("ckeditor5/translations/ru.js");case"si":return await import("ckeditor5/translations/si.js");case"sk":return await import("ckeditor5/translations/sk.js");case"sl":return await import("ckeditor5/translations/sl.js");case"sq":return await import("ckeditor5/translations/sq.js");case"sr":return await import("ckeditor5/translations/sr.js");case"sr-latn":return await import("ckeditor5/translations/sr-latn.js");case"sv":return await import("ckeditor5/translations/sv.js");case"th":return await import("ckeditor5/translations/th.js");case"tk":return await import("ckeditor5/translations/tk.js");case"tr":return await import("ckeditor5/translations/tr.js");case"tt":return await import("ckeditor5/translations/tt.js");case"ug":return await import("ckeditor5/translations/ug.js");case"uk":return await import("ckeditor5/translations/uk.js");case"ur":return await import("ckeditor5/translations/ur.js");case"uz":return await import("ckeditor5/translations/uz.js");case"vi":return await import("ckeditor5/translations/vi.js");case"zh":return await import("ckeditor5/translations/zh.js");case"zh-cn":return await import("ckeditor5/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in ckeditor5 translations`),null}else switch(t){case"af":return await import("ckeditor5-premium-features/translations/af.js");case"ar":return await import("ckeditor5-premium-features/translations/ar.js");case"ast":return await import("ckeditor5-premium-features/translations/ast.js");case"az":return await import("ckeditor5-premium-features/translations/az.js");case"bg":return await import("ckeditor5-premium-features/translations/bg.js");case"bn":return await import("ckeditor5-premium-features/translations/bn.js");case"bs":return await import("ckeditor5-premium-features/translations/bs.js");case"ca":return await import("ckeditor5-premium-features/translations/ca.js");case"cs":return await import("ckeditor5-premium-features/translations/cs.js");case"da":return await import("ckeditor5-premium-features/translations/da.js");case"de":return await import("ckeditor5-premium-features/translations/de.js");case"de-ch":return await import("ckeditor5-premium-features/translations/de-ch.js");case"el":return await import("ckeditor5-premium-features/translations/el.js");case"en":return await import("ckeditor5-premium-features/translations/en.js");case"en-au":return await import("ckeditor5-premium-features/translations/en-au.js");case"en-gb":return await import("ckeditor5-premium-features/translations/en-gb.js");case"eo":return await import("ckeditor5-premium-features/translations/eo.js");case"es":return await import("ckeditor5-premium-features/translations/es.js");case"es-co":return await import("ckeditor5-premium-features/translations/es-co.js");case"et":return await import("ckeditor5-premium-features/translations/et.js");case"eu":return await import("ckeditor5-premium-features/translations/eu.js");case"fa":return await import("ckeditor5-premium-features/translations/fa.js");case"fi":return await import("ckeditor5-premium-features/translations/fi.js");case"fr":return await import("ckeditor5-premium-features/translations/fr.js");case"gl":return await import("ckeditor5-premium-features/translations/gl.js");case"gu":return await import("ckeditor5-premium-features/translations/gu.js");case"he":return await import("ckeditor5-premium-features/translations/he.js");case"hi":return await import("ckeditor5-premium-features/translations/hi.js");case"hr":return await import("ckeditor5-premium-features/translations/hr.js");case"hu":return await import("ckeditor5-premium-features/translations/hu.js");case"hy":return await import("ckeditor5-premium-features/translations/hy.js");case"id":return await import("ckeditor5-premium-features/translations/id.js");case"it":return await import("ckeditor5-premium-features/translations/it.js");case"ja":return await import("ckeditor5-premium-features/translations/ja.js");case"jv":return await import("ckeditor5-premium-features/translations/jv.js");case"kk":return await import("ckeditor5-premium-features/translations/kk.js");case"km":return await import("ckeditor5-premium-features/translations/km.js");case"kn":return await import("ckeditor5-premium-features/translations/kn.js");case"ko":return await import("ckeditor5-premium-features/translations/ko.js");case"ku":return await import("ckeditor5-premium-features/translations/ku.js");case"lt":return await import("ckeditor5-premium-features/translations/lt.js");case"lv":return await import("ckeditor5-premium-features/translations/lv.js");case"ms":return await import("ckeditor5-premium-features/translations/ms.js");case"nb":return await import("ckeditor5-premium-features/translations/nb.js");case"ne":return await import("ckeditor5-premium-features/translations/ne.js");case"nl":return await import("ckeditor5-premium-features/translations/nl.js");case"no":return await import("ckeditor5-premium-features/translations/no.js");case"oc":return await import("ckeditor5-premium-features/translations/oc.js");case"pl":return await import("ckeditor5-premium-features/translations/pl.js");case"pt":return await import("ckeditor5-premium-features/translations/pt.js");case"pt-br":return await import("ckeditor5-premium-features/translations/pt-br.js");case"ro":return await import("ckeditor5-premium-features/translations/ro.js");case"ru":return await import("ckeditor5-premium-features/translations/ru.js");case"si":return await import("ckeditor5-premium-features/translations/si.js");case"sk":return await import("ckeditor5-premium-features/translations/sk.js");case"sl":return await import("ckeditor5-premium-features/translations/sl.js");case"sq":return await import("ckeditor5-premium-features/translations/sq.js");case"sr":return await import("ckeditor5-premium-features/translations/sr.js");case"sr-latn":return await import("ckeditor5-premium-features/translations/sr-latn.js");case"sv":return await import("ckeditor5-premium-features/translations/sv.js");case"th":return await import("ckeditor5-premium-features/translations/th.js");case"tk":return await import("ckeditor5-premium-features/translations/tk.js");case"tr":return await import("ckeditor5-premium-features/translations/tr.js");case"tt":return await import("ckeditor5-premium-features/translations/tt.js");case"ug":return await import("ckeditor5-premium-features/translations/ug.js");case"uk":return await import("ckeditor5-premium-features/translations/uk.js");case"ur":return await import("ckeditor5-premium-features/translations/ur.js");case"uz":return await import("ckeditor5-premium-features/translations/uz.js");case"vi":return await import("ckeditor5-premium-features/translations/vi.js");case"zh":return await import("ckeditor5-premium-features/translations/zh.js");case"zh-cn":return await import("ckeditor5-premium-features/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in premium translations`),await import("ckeditor5-premium-features/translations/en.js")}}catch(r){return console.error(`Failed to load translation for ${i}/${t}:`,r),null}}function _(i){return z(i,t=>({dictionary:t}))}function G(){return Array.from(document.querySelectorAll("cke5-editor")).map(i=>i.getAttribute("data-cke-editor-id")).filter(i=>i!==null)}function Y(i){const t=X(i);return z(t,({element:r})=>r)}function V(i){const t=X(i),r=z(t,({content:a})=>a);return ct(r,a=>typeof a=="string")}function X(i){const t=Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${i}"]`)).reduce((o,l)=>{const u=l.getAttribute("data-cke-root-name"),c=l.getAttribute("data-cke-content");return o[u]={element:l.querySelector("[data-cke-editable-content]"),content:c},o},Object.create({})),r=document.querySelector(`cke5-editor[data-cke-editor-id="${i}"]`);if(!r)return t;const a=t.main,n=JSON.parse(r.getAttribute("data-cke-content")),s=document.querySelector(`#${i}_editor `);return a&&n?.main?{...t,main:{...a,content:a.content||n.main}}:s?{...t,main:{element:s,content:n?.main||null}}:t}function I(i){if(!i||typeof i!="object")return i;if(Array.isArray(i))return i.map(a=>I(a));const t=i;if(t.$element&&typeof t.$element=="string"){const a=document.querySelector(t.$element);return a||console.warn(`Element not found for selector: ${t.$element}`),a||null}const r=Object.create(null);for(const[a,n]of Object.entries(i))r[a]=I(n);return r}function P(i,t,r){if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(s=>P(i,t,s));const a=r;if(a.$translation&&typeof a.$translation=="string"){const s=a.$translation,o=ft(i,s,t);return o===void 0&&console.warn(`Translation not found for key: ${s}`),o!==void 0?o:null}const n=Object.create(null);for(const[s,o]of Object.entries(r))n[s]=P(i,t,o);return n}function ft(i,t,r){for(const a of i){const n=a[r];if(n?.dictionary&&t in n.dictionary)return n.dictionary[t]}}function gt(i,t){const{editing:r}=i;r.view.change(a=>{a.setStyle("height",`${t}px`,r.view.document.getRoot())})}const N=Symbol.for("symfony-editor-watchdog");async function yt(i,t){const{EditorWatchdog:r}=await import("ckeditor5"),a=new r(null,{crashNumberLimit:10,minimumNonErrorTimePeriod:5e3});return a.setCreator(async()=>{const n=await i();return n[N]=a,n}),a}function Et(i){return N in i?i[N]:null}class y extends B{static the=new y}class bt extends HTMLElement{contextPromise=null;async connectedCallback(){await T();const t=this.getAttribute("data-cke-context-id"),r=JSON.parse(this.getAttribute("data-cke-language")),a=JSON.parse(this.getAttribute("data-cke-context")),{customTranslations:n,watchdogConfig:s,config:{plugins:o,...l}}=a,{loadedPlugins:u,hasPremium:c}=await J(o??[]),f=[...await K(r,c),_(n||{})].filter(k=>!F(k));this.contextPromise=(async()=>{const{ContextWatchdog:k,Context:A}=await import("ckeditor5"),g=new k(A,{crashNumberLimit:10,...s});let E=I(l);return E=P([...f].reverse(),r.ui,E),await g.create({...E,language:r,plugins:u,...f.length&&{translations:f}}),g.on("itemError",(...p)=>{console.error("Context item error:",...p)}),g})();const b=await this.contextPromise;this.isConnected&&y.the.register(t,b)}async disconnectedCallback(){const t=this.getAttribute("data-cke-context-id");this.style.display="none";try{await(await this.contextPromise)?.destroy()}finally{this.contextPromise=null,t&&y.the.hasItem(t)&&y.the.unregister(t)}}}class m extends B{static the=new m}class Q extends HTMLElement{unmountEffect=null;async connectedCallback(){await T(),this.hasAttribute("data-cke-editor-id")||this.setAttribute("data-cke-editor-id",G()[0]);const t=this.getAttribute("data-cke-editor-id"),r=this.getAttribute("data-cke-root-name"),a=this.getAttribute("data-cke-content"),n=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10);if(!t||!r)throw new w("Editor ID or Root Name is missing.");this.style.display="block",this.unmountEffect=m.the.mountEffect(t,s=>{if(!this.isConnected)return;const o=this.querySelector("input");if(s.model.document.getRoot(r)){if(a!==null){const c=s.getData({rootName:r});c&&c!==a&&s.setData({[r]:a})}return}if(H(s)){const{ui:c,editing:d}=s;s.addRoot(r,{isUndoable:!1,...a!==null&&{data:a}});const f=this.querySelector("[data-cke-editable-content]"),b=c.view.createEditable(r,f);c.addEditable(b),d.view.forceRender()}const l=()=>{const c=s.getData({rootName:r});o&&(o.value=c,o.dispatchEvent(new Event("input"))),this.dispatchEvent(new CustomEvent("change",{detail:{value:c}}))},u=$(n,l);return s.model.document.on("change:data",u),l(),()=>{if(s.model.document.off("change:data",u),s.state!=="destroyed"&&r){const c=s.model.document.getRoot(r);if(c&&H(s)){try{s.ui.view.editables[r]&&s.detachEditable(c)}catch(d){console.error("Unable unmount editable from root:",d)}c.isAttached()&&s.detachRoot(r,!1)}}}})}disconnectedCallback(){this.style.display="none",this.unmountEffect?.(),this.unmountEffect=null}}async function kt({saveDebounceMs:i,editorId:t,targetElement:r}){const{Plugin:a}=await import("ckeditor5");return class extends a{static get pluginName(){return"DispatchEditorRootsChangeEvent"}afterInit(){const s=$(i,this.dispatch);this.editor.model.document.on("change:data",s),this.editor.once("ready",this.dispatch)}dispatch=()=>{r.dispatchEvent(new CustomEvent("ckeditor5:change:data",{detail:{editorId:t,editor:this.editor,roots:ht(this.editor)},bubbles:!0}))}}}async function Ct(i){const{Plugin:t}=await import("ckeditor5");return class extends t{input=null;form=null;static get pluginName(){return"SyncEditorWithInput"}afterInit(){const{editor:a}=this,s=a.sourceElement.id.replace(/_editor$/,"");this.input=document.getElementById(`${s}_input`),this.input&&(a.model.document.on("change:data",$(i,()=>this.sync())),a.once("ready",this.sync),this.form=this.input.closest("form"),this.form?.addEventListener("submit",this.sync))}sync=()=>{if(this.input){const a=this.editor.getData();this.input.value=a,this.input.dispatchEvent(new Event("input",{bubbles:!0}))}};destroy(){this.form&&this.form.removeEventListener("submit",this.sync),this.input=null,this.form=null}}}class Z extends HTMLElement{unmountEffect=null;async connectedCallback(){await T(),await this.initializeEditor()}async initializeEditor(){const t=this.getAttribute("data-cke-editor-id");m.the.resetErrors(t);try{this.style.display="block";const r=await this.createEditor(),a=dt(r),n=Et(r);if(this.isConnected){const s=m.the.mountEffect(t,o=>{o.once("destroy",()=>{m.the.unregister(t,!1)},{priority:"highest"})});this.unmountEffect=async()=>{m.the.unregister(t),s(),a?a.state!=="unavailable"&&await a.context.remove(a.editorContextId):n?await n.destroy():await r.destroy()},m.the.register(t,r)}}catch(r){console.error(`Error initializing CKEditor5 instance with ID "${t}":`,r),this.unmountEffect=null,m.the.error(t,r)}}disconnectedCallback(){this.style.display="none",this.unmountEffect?.(),this.unmountEffect=null}async createEditor(){const t=this.getAttribute("data-cke-editor-id"),r=JSON.parse(this.getAttribute("data-cke-preset")),a=this.getAttribute("data-cke-context-id"),n=this.getAttribute("data-cke-editable-height")?Number.parseInt(this.getAttribute("data-cke-editable-height"),10):null,s=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10),o=JSON.parse(this.getAttribute("data-cke-language")),l=this.hasAttribute("data-cke-watchdog"),u=JSON.parse(this.getAttribute("data-cke-content")),{customTranslations:c,editorType:d,licenseKey:f,config:{plugins:b,...k}}=r,A=await pt(d),g=await(a?y.the.waitFor(a):null),E=async()=>{const{loadedPlugins:p,hasPremium:O}=await J(b);p.push(await kt({saveDebounceMs:s,editorId:t,targetElement:this})),v(d)&&p.push(await Ct(s));const S=[...await K(o,O),_(c||{})].filter(h=>!F(h));let C={...u,...V(t)};v(d)&&(C=C.main||"");const R=await(async()=>{let h=Y(t);if(!h.main){const q=v(d)?["main"]:Object.keys(C);tt(h,q)||(h=await vt(t,q),C={...u,...V(t)})}v(d)&&"main"in h&&(h=h.main);let D=I(k);D=P([...S].reverse(),o.ui,D);const L={...D,initialData:C,licenseKey:f,plugins:p,language:o,...S.length&&{translations:S}};return!g||!(h instanceof HTMLElement)?A.create(h,L):(await mt({context:g,element:h,creator:A,config:L})).editor})();return v(d)&&n&&gt(R,n),R};if(l&&!g){const p=await yt(E);return p.on("restart",()=>{const O=p.editor;m.the.register(t,O)}),await p.create({}),p.editor}return E()}}function tt(i,t){return t.every(r=>i[r])}async function vt(i,t){return lt(()=>{const r=Y(i);if(!tt(r,t))throw new Error(`It looks like not all required root elements are present yet.
2
2
  * If you want to wait for them, ensure they are registered before editor initialization.
3
3
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
4
- Missing roots: ${t.filter(a=>!r[a]).join(", ")}.`);return r},{timeOutAfter:2e3,retryAfter:100})}class Q extends HTMLElement{mountedPromise=null;async connectedCallback(){await I();const t=this.getAttribute("data-cke-editor-id")||J()[0],r=this.getAttribute("data-cke-name");!t||!r||(this.style.display="block",this.mountedPromise=p.the.execute(t,a=>{if(!this.isConnected)return;const{ui:n}=a,s=kt(r),o=n.view[s];if(!o)throw new w(`Unknown UI part name: "${r}". Supported names are "toolbar" and "menubar".`);this.appendChild(o.element)}))}async disconnectedCallback(){this.style.display="none",await this.mountedPromise,this.mountedPromise=null,this.innerHTML=""}}function kt(i){switch(i){case"toolbar":return"toolbar";case"menubar":return"menuBarView";default:return null}}const Ct={"cke5-editor":Y,"cke5-context":gt,"cke5-ui-part":Q,"cke5-editable":G};function Pt(){for(const[i,t]of Object.entries(Ct))window.customElements.get(i)||window.customElements.define(i,t)}Pt();exports.CKEditor5SymfonyError=w;exports.ContextsRegistry=b;exports.CustomEditorPluginsRegistry=x;exports.EditableComponentElement=G;exports.EditorComponentElement=Y;exports.EditorsRegistry=p;exports.UIPartComponentElement=Q;
4
+ Missing roots: ${t.filter(a=>!r[a]).join(", ")}.`);return r},{timeOutAfter:2e3,retryAfter:100})}class et extends HTMLElement{unmountEffect=null;async connectedCallback(){await T();const t=this.getAttribute("data-cke-editor-id")||G()[0],r=this.getAttribute("data-cke-name");!t||!r||(this.style.display="block",this.unmountEffect=m.the.mountEffect(t,a=>{if(!this.isConnected)return;const{ui:n}=a,s=At(r),o=n.view[s];if(!o)throw new w(`Unknown UI part name: "${r}". Supported names are "toolbar" and "menubar".`);return this.appendChild(o.element),()=>{this.innerHTML=""}}))}disconnectedCallback(){this.style.display="none",this.unmountEffect?.(),this.unmountEffect=null}}function At(i){switch(i){case"toolbar":return"toolbar";case"menubar":return"menuBarView";default:return null}}const It={"cke5-editor":Z,"cke5-context":bt,"cke5-ui-part":et,"cke5-editable":Q};function Pt(){for(const[i,t]of Object.entries(It))window.customElements.get(i)||window.customElements.define(i,t)}Pt();exports.CKEditor5SymfonyError=w;exports.ContextsRegistry=y;exports.CustomEditorPluginsRegistry=x;exports.EditableComponentElement=Q;exports.EditorComponentElement=Z;exports.EditorsRegistry=m;exports.UIPartComponentElement=et;
5
5
  //# sourceMappingURL=index.cjs.map