import*as e from"django-prose-editor/editor";let t="data-django-prose-editor-configurable",r={...e},o=new Map;async function n(e){if(!e||!e.length)return;let t=e.map(e=>{if(o.has(e))return o.get(e);let t=import(e).then(e=>{Object.assign(r,e)}).catch(t=>{console.error(`Error loading extension module from ${e}:`,t),o.delete(e)});return o.set(e,t),t});await Promise.all(t)}async function i(o){var i;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(o.closest(".prose-editor"))return null;(null==(i=(l=l||JSON.parse(o.getAttribute(t)||"{}")).js_modules)?void 0:i.length)&&await n(l.js_modules);let a=[];for(let[e,t]of Object.entries(l.extensions)){let o=r[e];o&&("object"==typeof t?a.push(o.configure(t)):a.push(o))}return(0,e.createTextareaEditor)(o,a)}let l=new WeakMap;function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(l.has(e))return l.get(e);let r=i(e,t).then(t=>{if(t){let r=new CustomEvent("prose-editor:ready",{detail:{editor:t,textarea:e},bubbles:!0});e.dispatchEvent(r)}return l.delete(e),t}).catch(t=>(console.error("Error initializing prose editor:",t),l.delete(e),null));return l.set(e,r),r}(0,e.initializeEditors)(a,`[${t}]`);export{a as createEditor};
//# sourceMappingURL=configurable.js.map