@mrakomor/core 0.0.10 → 0.0.12

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 (116) hide show
  1. package/dist/blockChrome.mjs +2 -2
  2. package/dist/blockInsertMenu.mjs +1 -1
  3. package/dist/chunk-2C6UDFD4.mjs +1 -0
  4. package/dist/chunk-5HWTMPF4.mjs +2 -0
  5. package/dist/chunk-6CG6EGQM.mjs +2 -0
  6. package/dist/{chunk-K2DMHAUD.mjs → chunk-7CJLTNHZ.mjs} +1 -1
  7. package/dist/chunk-ERNLRJPB.mjs +1 -0
  8. package/dist/chunk-EXDY5TZH.mjs +1 -0
  9. package/dist/chunk-FAXIFXQK.mjs +4 -0
  10. package/dist/chunk-GDDVUIEH.mjs +1 -0
  11. package/dist/{chunk-GDID5DFL.mjs → chunk-JVQ2YGII.mjs} +1 -1
  12. package/dist/chunk-P7TUN2KD.mjs +1 -0
  13. package/dist/chunk-S2W6LYHT.mjs +1 -0
  14. package/dist/chunk-TL5BHWDU.mjs +2 -0
  15. package/dist/chunk-ZHOZPQZH.mjs +1 -0
  16. package/dist/clipboard.cjs +4 -4
  17. package/dist/clipboard.mjs +3 -3
  18. package/dist/footer.cjs +4 -1
  19. package/dist/footer.mjs +2 -2
  20. package/dist/headline.cjs +3 -2
  21. package/dist/headline.mjs +1 -1
  22. package/dist/help.mjs +2 -2
  23. package/dist/index.cjs +6 -5
  24. package/dist/index.mjs +4 -4
  25. package/dist/link.cjs +3 -3
  26. package/dist/link.mjs +2 -2
  27. package/dist/list.cjs +3 -3
  28. package/dist/list.mjs +1 -1
  29. package/dist/paragraph.cjs +3 -2
  30. package/dist/paragraph.mjs +1 -1
  31. package/dist/slashCommand.cjs +2 -2
  32. package/dist/slashCommand.mjs +1 -1
  33. package/dist/tooltip.cjs +1 -1
  34. package/dist/tooltip.mjs +2 -2
  35. package/dist/tts.cjs +8 -8
  36. package/dist/tts.mjs +3 -3
  37. package/dist/types/Mrakomor.d.mts +230 -0
  38. package/dist/types/component/AbstractComponent.d.mts +69 -0
  39. package/dist/types/component/Editor.d.mts +8 -0
  40. package/dist/types/component/block/BlockComponent.d.mts +105 -0
  41. package/dist/types/component/block/BlockRegister.d.mts +29 -0
  42. package/dist/types/component/block/ExternalComponent.d.mts +42 -0
  43. package/dist/types/component/block/UnknownComponent.d.mts +3 -0
  44. package/dist/types/component/block/blockItemEquals.d.mts +6 -0
  45. package/dist/types/component/block/helpers.d.mts +319 -0
  46. package/dist/types/component/editorContext.d.mts +4 -0
  47. package/dist/types/component/entityRange/EntityRangeElement.d.mts +15 -0
  48. package/dist/types/component/inlineStyle/Bold.d.mts +4 -0
  49. package/dist/types/component/inlineStyle/InlineElement.d.mts +10 -0
  50. package/dist/types/component/inlineStyle/Italic.d.mts +4 -0
  51. package/dist/types/component/inlineStyle/Subscript.d.mts +4 -0
  52. package/dist/types/component/inlineStyle/Superscript.d.mts +4 -0
  53. package/dist/types/component/inlineStyle/Underline.d.mts +4 -0
  54. package/dist/types/component/inlineStyle/index.d.mts +5 -0
  55. package/dist/types/component/overlayMount.d.mts +46 -0
  56. package/dist/types/dom.d.mts +161 -0
  57. package/dist/types/emitter.d.mts +38 -0
  58. package/dist/types/index.d.mts +7 -0
  59. package/dist/types/namespaces.d.mts +17 -0
  60. package/dist/types/plugin/blockChrome/BlockChrome.d.mts +11 -0
  61. package/dist/types/plugin/blockChrome/index.d.mts +1 -0
  62. package/dist/types/plugin/blockInsertMenu/BlockInsertMenu.d.mts +6 -0
  63. package/dist/types/plugin/blockInsertMenu/index.d.mts +1 -0
  64. package/dist/types/plugin/clipboard/clipboardHelpers.d.mts +151 -0
  65. package/dist/types/plugin/clipboard/clipboardPlugin.d.mts +6 -0
  66. package/dist/types/plugin/clipboard/index.d.mts +1 -0
  67. package/dist/types/plugin/default/defaultMrakomorPlugin.d.mts +21 -0
  68. package/dist/types/plugin/dialog/Dialog.d.mts +23 -0
  69. package/dist/types/plugin/footer/footerPlugin.d.mts +7 -0
  70. package/dist/types/plugin/footer/index.d.mts +1 -0
  71. package/dist/types/plugin/headline/Headline.d.mts +29 -0
  72. package/dist/types/plugin/headline/index.d.mts +1 -0
  73. package/dist/types/plugin/help/HelpRegister.d.mts +15 -0
  74. package/dist/types/plugin/help/helpPlugin.d.mts +26 -0
  75. package/dist/types/plugin/help/helpSchema.d.mts +11 -0
  76. package/dist/types/plugin/help/index.d.mts +1 -0
  77. package/dist/types/plugin/linkEntity/LinkEntity.d.mts +37 -0
  78. package/dist/types/plugin/linkEntity/index.d.mts +1 -0
  79. package/dist/types/plugin/list/List.d.mts +61 -0
  80. package/dist/types/plugin/list/index.d.mts +1 -0
  81. package/dist/types/plugin/list/listHelpers.d.mts +166 -0
  82. package/dist/types/plugin/menu/Menu.d.mts +22 -0
  83. package/dist/types/plugin/menu/menuPlugin.d.mts +6 -0
  84. package/dist/types/plugin/paragraph/Paragraph.d.mts +16 -0
  85. package/dist/types/plugin/paragraph/index.d.mts +1 -0
  86. package/dist/types/plugin/slashCommand/SlashActionRegister.d.mts +12 -0
  87. package/dist/types/plugin/slashCommand/index.d.mts +1 -0
  88. package/dist/types/plugin/slashCommand/slashActionSchema.d.mts +29 -0
  89. package/dist/types/plugin/slashCommand/slashCommandHelpers.d.mts +77 -0
  90. package/dist/types/plugin/slashCommand/slashCommandPlugin.d.mts +11 -0
  91. package/dist/types/plugin/slashCommand/slashHelp.d.mts +12 -0
  92. package/dist/types/plugin/tooltip/Tooltip.d.mts +16 -0
  93. package/dist/types/plugin/tooltip/index.d.mts +1 -0
  94. package/dist/types/plugin/tts/TtsHeadline.d.mts +27 -0
  95. package/dist/types/plugin/tts/TtsList.d.mts +19 -0
  96. package/dist/types/plugin/tts/TtsParagraph.d.mts +9 -0
  97. package/dist/types/plugin/tts/TtsVoice.d.mts +52 -0
  98. package/dist/types/plugin/tts/index.d.mts +4 -0
  99. package/dist/types/register/Register.d.mts +50 -0
  100. package/dist/types/register/sortRegisterEntries.d.mts +7 -0
  101. package/dist/types/schema/blockContent.d.mts +34 -0
  102. package/dist/types/schema/blockRegister.d.mts +14 -0
  103. package/dist/types/schema/config.d.mts +6 -0
  104. package/dist/types/types.d.mts +636 -0
  105. package/package.json +35 -23
  106. package/dist/chunk-5VPYPKGA.mjs +0 -1
  107. package/dist/chunk-G2QV4GOO.mjs +0 -1
  108. package/dist/chunk-N4I2WZWF.mjs +0 -1
  109. package/dist/chunk-Q7RMVYZR.mjs +0 -1
  110. package/dist/chunk-T7OO472O.mjs +0 -1
  111. package/dist/chunk-TX4RCFPO.mjs +0 -3
  112. package/dist/chunk-U3MSKB3R.mjs +0 -2
  113. package/dist/chunk-UC7W4JIH.mjs +0 -2
  114. package/dist/chunk-WBTDWVEC.mjs +0 -3
  115. package/dist/chunk-WQWE5UCN.mjs +0 -1
  116. package/dist/chunk-YHWQV2DB.mjs +0 -1
package/dist/footer.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {r,o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/footer/footer.css",o=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!o){var t=document.createElement("style");t.setAttribute("data-mrakomor-css",""),t.setAttribute("data-mrakomor-css-path",e),t.textContent=`.mrakomor-footer-plugin-container{display:contents}.mrakomor-footer-container{position:relative;flex:0 0 auto;display:flex;align-items:stretch;justify-content:space-between;gap:0;height:22px;min-height:22px;padding:0;border-top:1px solid #e4e7ec;background:#f3f4f6;color:#5b6472;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:11px;line-height:22px;user-select:none;pointer-events:none}.mrakomor-footer-start,.mrakomor-footer-end{display:flex;align-items:stretch;min-width:0}.mrakomor-footer-end{margin-left:auto;flex-shrink:0}.mrakomor-footer-item{display:inline-flex;align-items:center;max-width:100%;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#5b6472}.mrakomor-footer-item+.mrakomor-footer-item{border-left:1px solid #e0e4ea}.mrakomor-footer-action{display:inline-flex;align-items:center;gap:4px;height:100%;margin:0;padding:0 10px;border:none;border-left:1px solid #e0e4ea;background:transparent;color:inherit;font:inherit;line-height:inherit;cursor:pointer;pointer-events:all}.mrakomor-footer-action:hover{background:#e9edf2;color:#1f2937}.mrakomor-footer-action:focus-visible{outline:1px solid #94a3b8;outline-offset:-1px}.mrakomor-footer-action__icon{font-size:12px;font-weight:700;line-height:1}
2
- `,document.head.appendChild(t);}}})();function l(e,o){let t=0;for(let r of o){let s=e.register.blocks.getByNamespace(r?.component)?.toExchangeState(r)?.properties?.text;t+=(s??"").length;}return t}function i(e){return e.toLocaleString()}function m({mrakomor:e}){let o$1=e.get();return o("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[o("div",{className:"mrakomor-footer-start"},[o("span",{className:"mrakomor-footer-item"},()=>{let t=o$1._getContentState().length;return `${i(t)} ${t===1?"block":"blocks"}`}),o("span",{className:"mrakomor-footer-item"},()=>{let t=l(o$1,o$1._getContentState());return `${i(t)} ${t===1?"character":"characters"}`})]),o("div",{className:"mrakomor-footer-end"})])}function c(e){let o=e.getRoot();return o?o.classList?.contains("mrakomor-editor")?o:o.querySelector(".mrakomor-editor"):null}function f({mrakomor:e}){let o$1=null,t=null;return {onMount(){let r$1=c(e);r$1&&(o$1=document.createElement("div"),o$1.className="mrakomor-footer-plugin-container",r$1.append(o$1),t=r(o$1,o(m,{mrakomor:e})));},onUnmount(){t?.(),o$1?.remove(),t=null,o$1=null;}}}export{f as footerPlugin};
1
+ import {l as l$1}from'./chunk-FAXIFXQK.mjs';import'./chunk-P7TUN2KD.mjs';import {s as s$1,p}from'./chunk-7CJLTNHZ.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/footer/footer.css",o=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===t});if(!o){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",t),e.textContent=`.mrakomor-footer-plugin-container{display:contents}.mrakomor-footer-container{position:relative;flex:0 0 auto;display:flex;align-items:stretch;justify-content:space-between;gap:0;height:22px;min-height:22px;padding:0;border-top:1px solid #e4e7ec;background:#f3f4f6;color:#5b6472;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:11px;line-height:22px;user-select:none;pointer-events:none}.mrakomor-footer-start,.mrakomor-footer-end{display:flex;align-items:stretch;min-width:0}.mrakomor-footer-end{margin-left:auto;flex-shrink:0}.mrakomor-footer-item{display:inline-flex;align-items:center;max-width:100%;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#5b6472}.mrakomor-footer-item+.mrakomor-footer-item{border-left:1px solid #e0e4ea}.mrakomor-footer-action{display:inline-flex;align-items:center;gap:4px;height:100%;margin:0;padding:0 10px;border:none;border-left:1px solid #e0e4ea;background:transparent;color:inherit;font:inherit;line-height:inherit;cursor:pointer;pointer-events:all}.mrakomor-footer-action:hover{background:#e9edf2;color:#1f2937}.mrakomor-footer-action:focus-visible{outline:1px solid #94a3b8;outline-offset:-1px}.mrakomor-footer-action__icon{font-size:12px;font-weight:700;line-height:1}
2
+ `,document.head.appendChild(e);}}})();function l(t,o){let e=0;for(let r of o){let m=t.register.blocks.getByNamespace(r?.component)?.toExchangeState(r)?.properties?.items;e+=l$1(m).text.length;}return e}function s(t){return t.toLocaleString()}function c({mrakomor:t}){let o=t.get();return p("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[p("div",{className:"mrakomor-footer-start"},[p("span",{className:"mrakomor-footer-item"},()=>{let e=o._getContentState().length;return `${s(e)} ${e===1?"block":"blocks"}`}),p("span",{className:"mrakomor-footer-item"},()=>{let e=l(o,o._getContentState());return `${s(e)} ${e===1?"character":"characters"}`})]),p("div",{className:"mrakomor-footer-end"})])}function f(t){let o=t.getRoot();return o?o.classList?.contains("mrakomor-editor")?o:o.querySelector(".mrakomor-editor"):null}function u({mrakomor:t}){let o=null,e=null;return {onMount(){let r=f(t);r&&(o=document.createElement("div"),o.className="mrakomor-footer-plugin-container",r.append(o),e=s$1(o,p(c,{mrakomor:t})));},onUnmount(){e?.(),o?.remove(),e=null,o=null;}}}export{u as footerPlugin};
package/dist/headline.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/headline/Headline.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}
2
- `,document.head.appendChild(n);}}})();var Qe=class{next(...e){}error(...e){}complete(...e){}},ye=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var te=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var S=null,Se=false,be=[];function v(e){let t=S;S=null;let n=e();return S=t,n}function ln(){Se=false;let e=nt();for(let n of e)n.get();let t=be;be=[];for(let n of t)n();}function Ze(){Se||(Se=true,queueMicrotask(ln));}function xe(e){be.push(e),Ze();}var et=Symbol("@esmj/signals:internal observable"),R=Symbol("@esmj/signals:original function"),fn=class extends ye{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>v(()=>{this.#e.add(e),this.#r();}),e.next[R]=void 0),e instanceof st&&e.next[R]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#r();}),e.next[R]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[R]){let n=t.get,r=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),r())),t.get[R]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[R]?e.next[R]:e.next,e.get=e.get[R]?e.get[R]:e.get,this.#e.delete(e),this.unsubscribe(e)}},ne=null;function tt(e){ne=new fn(e);}tt(()=>{Ze();});function nt(){return ne.getPending()}function rt(e){return ne.watch(e)}function ot(e){return ne.unwatch(e)}var k=Symbol("@esmj/signals:no error"),st=class it extends Qe{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#u=null;#i=0;#s=new Map;#t=k;constructor(t,n){super(),this.#c=t,this.#u=n,this.debug=n?.debug,this[te]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#l(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[q],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof it&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==k)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==k)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=k,this.#l(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#c();}catch(r){this.#t=r;}return S=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=k,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===k&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#l(),this.#s.clear(),this.#e=true,this.#t=k;}};function B(e,t){return new st(e,t)}function _(e,t){let n,{debug:r,...o}={},i=B(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),rt(i);let s=()=>{n?.(),i.destroy(),ot(i);};return s[Symbol.dispose]=s,s[te]="effect",s[q]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new ye;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(l,r)),e}function s(){return e}function a(c){if(!n(e,c)){e=c,r++,o.next();}return e}function u(){return r}let l={get:i,set:a,peek:s,getRevision:u,[et]:o,[te]:"signal",[q]:t?.debug??null};return l}function re(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var dt=Symbol("node-component"),oe=Symbol("node-internal"),pn=Symbol("keep-literal"),ue=Symbol("raw-props");var gt=null;function D(){return gt}function se(e){gt=e;}function Me(e){return e?.[dt]||null}function at(e,t){e[dt]=t;}function ie(e,t={disposers:[],id:re()}){return e?.[oe]?e[oe]:(e&&(e[oe]=t),t)}function dn(e){return e[oe]}function L(e,t){let n=dn(e);n||(n=ie(e)),n.disposers.push(t);}function _e(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function T(e,t){let n=D();se(e);try{return t()}finally{se(n);}}var Ne=new Map,ae=new Map,ut=new Map;function Et(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[pn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=B(i):r[o]=I(i);}return r}function we(e){return {id:Symbol("context-id"),defaultValue:e}}function Le(e){let t=D();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function U(e){xe(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ne.get(t);if(n){Ne.delete(t);for(let r of n){let o=r();typeof o=="function"&&_e(ae,t,o);}}}function gn(e){let t=ae.get(e);if(t){ae.delete(e);for(let n of t)n();}}function En(e){let t=ut.get(e);if(t){ut.delete(e);for(let n of t)n();}}function Te(e){if(!e)return;let t=ie(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=Me(e);if(n&&(gn(n.componentId),En(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Te(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ct(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function yn(e,t,n){let r=re(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=ct(e)?void 0:e[ue],s={...Et(t??{},i),children:n},a=D(),u={disposers:[],id:r,contexts:new Map(a?.contexts)};se(u);let l;if(ct(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&_e(Ne,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&_e(ae,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);se(a);let c=Sn(l);if(o.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)ie(f,u),at(f,o);else ie(c,u),c instanceof Node&&at(c,o);return c}};return o}function yt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function Sn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var lt={className:"class",htmlFor:"for"},ft=new Set(["value","defaultValue","checked","selected","indeterminate"]),bn=new Set(["srcdoc"]),xn=new Set(["href","src","action","formaction","xlink:href"]),Cn=new Set(["securitypolicyviolation"]),_n=new Set(["contenteditable","draggable","spellcheck"]);function G(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var St=Symbol("Fragment");function le(e,t,n){if(e===St){let o=document.createDocumentFragment();return Ae(o,mt(n)),o}if(typeof e=="function")return yn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),fe(r,t),Ae(r,mt(n)),r}function Ce(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Nn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function An(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return bn.has(n)?true:xn.has(n)&&t!==null&&t!==void 0&&Nn(String(t))}function bt(e){return typeof e!="string"?e:lt[e]?lt[e]:e}function Rn(e,t){let n=bt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return _n.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function pt(e,t,n){let r=Rn(t,n);if(r===null){e.removeAttribute(t);return}if(An(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function fe(e,t){let n=D();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=bt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(G(o)){let i=_(()=>{T(n,()=>{Ce(e,o.get());});});L(e,i);}else if(typeof o=="function"){let i=_(()=>{T(n,()=>{Ce(e,o());});});L(e,i);}else Ce(e,o);continue}if(r==="style"){if(G(o)){let i=_(()=>{T(n,()=>{Object.assign(e.style,o.get());});});L(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Cn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(G(o)||typeof o=="function"){let i=r,s=_(()=>{T(n,()=>{let a=typeof o=="function"?o():o.get();ft.has(i)?e[i]=a??"":pt(e,i,a);});});L(e,s);continue}ft.has(r)||typeof r=="symbol"?e[r]=o??"":pt(e,r,o);}}function mt(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Ae(e,t){for(let n of t)xt(e,n);}function xt(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){ht(e,t);return}if(j(t)){yt(e,t);return}if(G(t)){ht(e,()=>t.get());return}if(Array.isArray(t)){Ae(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function H(e){let t=null,n=e;return j(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function pe(e,t=true){for(let n of e)t&&Te(n),n.remove();}function ht(e,t){let n=D(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{T(n,()=>{let s=t(),{nodes:a,instance:u}=H(s);pe(o),a.length&&r.after(...a),u&&queueMicrotask(()=>Y(u)),o=a;});});L(e,i);}var Nt=class{constructor(e){this.props=e;}};var Mn={abortEarly:true};function De(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function wn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(De(e.errors[r],n));}function kt(e,t,n,r){if(n!==false){let o=De(e.error,t);return {success:false,error:o,errors:[o]}}wn(e,r,t);}function me(e){return e?.abortEarly!==void 0?e:Mn}function Oe(e,t){g(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Pe=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ie=e=>e===true||e===false,Ln=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Tn=e=>typeof e=="function",On=e=>Array.isArray(e),Be=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function vt(e,t){let n=b(Be,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return g(this,"_parse",(s,a,u)=>{let l=s(a,u);if(!l.success)return l;let c=o(l.data,{context:u?.context});if(!Be(c)){let f={message:`derive() callback must return a plain object of overrides, got ${c===null?"null":typeof c}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let p in c)f[p]===void 0&&(f[p]=c[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...c}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:u}=me(s);if(a.success===false)return a;let l={},c=[];for(let f in e){let p=e[f]._parse(a.data[f],s);if(p.success)l[f]=p.data;else {let m=kt(p,f,u,c);if(m)return m}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),r}function $e(e){return b(W,{...e,type:"string"})}function je(e){return b(Pe,{...e,type:"number"})}function He(e){return b(Ie,{...e,type:"boolean"})}function Fe(e){return b(Ln,{...e,type:"date"})}function Mt(e){return b(Tn,{...e,type:"function"})}function wt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=b(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Lt(e,t){let n=b(On,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,g(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=me(i);if(s.success===false)return s;let u=[],l=[],c=i;for(let f=0;f<s.data.length;f++){let p={...c,context:{...c?.context,index:f}},m=e._parse(s.data[f],p);if(m.success)u.push(m.data);else {let E=kt(m,f,a,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:u}}),n}function Tt(){return b(()=>true)}function F(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Ot(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${Be(o)?JSON.stringify(o):`"${o}"`}`,r=b(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,g(r,"_parse",(o,i,s)=>{let a=s,u=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(i,a);if(m.success)return m;u.push(m);}let{abortEarly:l}=me(a),c={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:c,errors:[c]};let f=[];for(let p=0;p<u.length;p++){let m=u[p].errors;if(m?.length)for(let E=0;E<m.length;E++)m[E].cause?.key&&f.push(De(m[E],`branch ${p}`));}return f.length===0&&f.push(c),{success:false,error:f[0],errors:f}}),r}function Pt(e,t){let n=b(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function It(e){let t=b(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,g(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Bt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Dt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return F(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},He({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return F(n=>{if(Ie(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},je({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ie(n)||Pe(n)&&Number.isFinite(n)?String(n):n,$e({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return W(n)&&(r=n.trim()),Pe(n)&&Number.isFinite(n)||r?new Date(r??n):n},Fe({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return g(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},$t={},d={object:vt,string:$e,number:je,boolean:He,date:Fe,function:Mt,enum:wt,array:Lt,any:Tt,preprocess:F,union:Ot,literal:Pt,contextRef:It,withContext:Bt,coerce:$t,cast:Dt};function At(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function g(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function b(e,{type:t="any",name:n,message:r}={}){r=r||At(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let u=this._parse(s,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success&&(c.data=s(c.data)),c}),this},optional(){return Oe(this,s=>s===void 0),this},nullable(){return Oe(this,s=>s===null),this},nullish(){return Oe(this,s=>s==null),this},default(s){return g(this,"_parse",(a,u,l)=>(u===void 0&&(u=typeof s=="function"?s({context:l?.context}):s),a(u,l))),this},catch(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?c:{success:true,data:typeof s=="function"?s({input:u,error:c.error}):s}}),this},pipe(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?s._parse(c.data,l):c}),this},refine(s,{message:a,type:u,jsonSchema:l}={}){if(u&&(a=a||At(u),t=u),l){let c=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>c;}return g(this,"_parse",(c,f,p)=>{let m=c(f,p),{abortEarly:E}=me(p);if(!m.success)return m;let N=s(m.data);if(N===true||typeof N=="object"&&N?.success===true)return m;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return Rt.length>0?Rt.reduce((s,a)=>a(s,e,o)??s,i):i}var Rt=[];var Ke=Ve(),qe=Ve(),jt=Ve(),Pn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ve(){return Math.floor(Math.random()*16777215)}function In(){return qe=(qe+1)%16777215,qe}function he(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=In(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Ke>>16&255,Ke>>8&255,Ke&255,jt>>8&255,jt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Pn[n.charCodeAt(o)];return r}var Ht=Symbol("block-element"),Bn=Symbol("block-element-body"),Ge=Symbol("selectable-element");function Ue(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function Dn(e){return e?Ue(e.startContainer,Ht):null}function Ft(e){return Ue(e,Ht)}function $n(e){return e?Ue(e.startContainer,Ge):null}function Kt(){return window.getSelection()}function X(){let e=Kt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function qt(){let e=X();if(!e)return 0;e.collapse(true);let t=$n(e),n=Dn(e),r=t??Ye(n);return Vt(r,e.startContainer,e.startOffset)}function Vt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,u=Math.min(n,a.length);for(let l=0;l<u;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function jn(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let i=o.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(r+s>=t)return n.setEnd(i,t-r),n.setStart(i,t-r),n;r+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)o.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function de(e,t){let n=jn(e,t),r=Kt();r.removeAllRanges(),r.addRange(n);}function Ye(e){if(!e)return null;let t=Hn(e);return t?.firstElementChild??t?.firstChild}function Hn(e){if(!e)return null;for(let t of e.children)if(t[Bn])return t;return null}var Gt={INPUT:"mrakomor:input"};var Ut=we();var ge=class extends Nt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Le(Ut),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(Gt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var We="molecule.paragraph.Paragraph";var Yt="molecule.headline.H1",Wt="molecule.headline.H2",Xt="molecule.headline.H3",zt="molecule.headline.H4",Jt="molecule.headline.H5";function M(e){return e===`
2
+ `,document.head.appendChild(n);}}})();var Qe=class{next(...e){}error(...e){}complete(...e){}},Se=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var ne=Symbol("@esmj/signals:type"),V=Symbol("@esmj/signals:name");var S=null,be=false,xe=[];function M(e){let t=S;S=null;let n=e();return S=t,n}function pn(){be=false;let e=nt();for(let n of e)n.get();let t=xe;xe=[];for(let n of t)n();}function Ze(){be||(be=true,queueMicrotask(pn));}function Ce(e){xe.push(e),Ze();}var et=Symbol("@esmj/signals:internal observable"),k=Symbol("@esmj/signals:original function"),hn=class extends Se{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>M(()=>{this.#e.add(e),this.#r();}),e.next[k]=void 0),e instanceof st&&e.next[k]===void 0){let t=e.next.bind(e);e.next=()=>M(()=>{this.#e.add(e),t(),this.#r();}),e.next[k]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[k]){let n=t.get,r=n.bind(t);t.get=()=>M(()=>(this.#e.delete(t),r())),t.get[k]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[k]?e.next[k]:e.next,e.get=e.get[k]?e.get[k]:e.get,this.#e.delete(e),this.unsubscribe(e)}},re=null;function tt(e){re=new hn(e);}tt(()=>{Ze();});function nt(){return re.getPending()}function rt(e){return re.watch(e)}function ot(e){return re.unwatch(e)}var v=Symbol("@esmj/signals:no error"),st=class it extends Qe{#e=true;#r=false;#n=null;#o=this.#p();#u=null;#c=null;#i=0;#s=new Map;#t=v;constructor(t,n){super(),this.#u=t,this.#c=n,this.debug=n?.debug,this[ne]="computed",this[V]=n?.debug??null,this.get=this.get.bind(this);}#l(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[V],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof it&&M(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=P(this.#a(),this.#c)),(this.#e||this.#t!==v)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==v)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=P(this.#a(),this.#c)),(this.#e||this.#t!==v)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==v)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=v,this.#l(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#u();}catch(r){this.#t=r;}return S=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=v,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===v&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#l(),this.#s.clear(),this.#e=true,this.#t=v;}};function B(e,t){return new st(e,t)}function _(e,t){let n,{debug:r,...o}={},i=B(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),rt(i);let s=()=>{n?.(),i.destroy(),ot(i);};return s[Symbol.dispose]=s,s[ne]="effect",s[V]=r??null,s.__RX_COMPUTED__=i,s}function P(e,t={}){let n=t?.equals??Object.is,r=0,o=new Se;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(l,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function c(){return r}let l={get:i,set:a,peek:s,getRevision:c,[et]:o,[ne]:"signal",[V]:t?.debug??null};return l}function oe(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var dt=Symbol("node-component"),se=Symbol("node-internal"),mn=Symbol("keep-literal"),ue=Symbol("raw-props");var gt=null;function D(){return gt}function ie(e){gt=e;}function we(e){return e?.[dt]||null}function at(e,t){e[dt]=t;}function ae(e,t={disposers:[],id:oe()}){return e?.[se]?e[se]:(e&&(e[se]=t),t)}function En(e){return e[se]}function L(e,t){let n=En(e);n||(n=ae(e)),n.disposers.push(t);}function Ne(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function T(e,t){let n=D();ie(e);try{return t()}finally{ie(n);}}var Ae=new Map,ce=new Map,ct=new Map;function Et(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[mn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=B(i):r[o]=P(i);}return r}function Le(e){return {id:Symbol("context-id"),defaultValue:e}}function Te(e){let t=D();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function $(e){Ce(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ae.get(t);if(n){Ae.delete(t);for(let r of n){let o=r();typeof o=="function"&&Ne(ce,t,o);}}}function yn(e){let t=ce.get(e);if(t){ce.delete(e);for(let n of t)n();}}function Sn(e){let t=ct.get(e);if(t){ct.delete(e);for(let n of t)n();}}function Oe(e){if(!e)return;let t=ae(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=we(e);if(n&&(yn(n.componentId),Sn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Oe(r),r=o;}}}function H(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ut(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function bn(e,t,n){let r=oe(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=ut(e)?void 0:e[ue],s={...Et(t??{},i),children:n},a=D(),c={disposers:[],id:r,contexts:new Map(a?.contexts)};ie(c);let l;if(ut(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&Ne(Ae,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Ne(ce,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);ie(a);let u=xn(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ae(f,c),at(f,o);else ae(u,c),u instanceof Node&&at(u,o);return u}};return o}function yt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function xn(e){return e instanceof Node?e:H(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var lt={className:"class",htmlFor:"for"},ft=new Set(["value","defaultValue","checked","selected","indeterminate"]),Cn=new Set(["srcdoc"]),_n=new Set(["href","src","action","formaction","xlink:href"]),Nn=new Set(["securitypolicyviolation"]),An=new Set(["contenteditable","draggable","spellcheck"]);function U(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var St=Symbol("Fragment");function fe(e,t,n){if(e===St){let o=document.createDocumentFragment();return Re(o,ht(n)),o}if(typeof e=="function")return bn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),pe(r,t),Re(r,ht(n)),r}function _e(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Rn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function kn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Cn.has(n)?true:_n.has(n)&&t!==null&&t!==void 0&&Rn(String(t))}function bt(e){return typeof e!="string"?e:lt[e]?lt[e]:e}function vn(e,t){let n=bt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return An.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function pt(e,t,n){let r=vn(t,n);if(r===null){e.removeAttribute(t);return}if(kn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function pe(e,t){let n=D();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=bt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(U(o)){let i=_(()=>{T(n,()=>{_e(e,o.get());});});L(e,i);}else if(typeof o=="function"){let i=_(()=>{T(n,()=>{_e(e,o());});});L(e,i);}else _e(e,o);continue}if(r==="style"){if(U(o)){let i=_(()=>{T(n,()=>{Object.assign(e.style,o.get());});});L(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Nn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(U(o)||typeof o=="function"){let i=r,s=_(()=>{T(n,()=>{let a=typeof o=="function"?o():o.get();ft.has(i)?e[i]=a??"":pt(e,i,a);});});L(e,s);continue}ft.has(r)||typeof r=="symbol"?e[r]=o??"":pt(e,r,o);}}function ht(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Re(e,t){for(let n of t)xt(e,n);}function xt(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){mt(e,t);return}if(H(t)){yt(e,t);return}if(U(t)){mt(e,()=>t.get());return}if(Array.isArray(t)){Re(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(e){let t=null,n=e;return H(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function he(e,t=true){for(let n of e)t&&Oe(n),n.remove();}function mt(e,t){let n=D(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{T(n,()=>{let s=t(),{nodes:a,instance:c}=F(s);he(o),a.length&&r.after(...a),c&&queueMicrotask(()=>Y(c)),o=a;});});L(e,i);}var Nt=class{constructor(e){this.props=e;}};var Ln={abortEarly:true};function je(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function Tn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(je(e.errors[r],n));}function kt(e,t,n,r){if(n!==false){let o=je(e.error,t);return {success:false,error:o,errors:[o]}}Tn(e,r,t);}function me(e){return e?.abortEarly!==void 0?e:Ln}function Ie(e,t){g(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Pe=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Be=e=>e===true||e===false,On=e=>e instanceof Date&&!Number.isNaN(e.getTime()),In=e=>typeof e=="function",Pn=e=>Array.isArray(e),De=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function vt(e,t){let n=b(De,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return g(this,"_parse",(s,a,c)=>{let l=s(a,c);if(!l.success)return l;let u=o(l.data,{context:c?.context});if(!De(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:c}=me(s);if(a.success===false)return a;let l={},u=[];for(let f in e){let p=e[f]._parse(a.data[f],s);if(p.success)l[f]=p.data;else {let h=kt(p,f,c,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function $e(e){return b(W,{...e,type:"string"})}function He(e){return b(Pe,{...e,type:"number"})}function Fe(e){return b(Be,{...e,type:"boolean"})}function Ke(e){return b(On,{...e,type:"date"})}function Mt(e){return b(In,{...e,type:"function"})}function wt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=b(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Lt(e,t){let n=b(Pn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,g(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=me(i);if(s.success===false)return s;let c=[],l=[],u=i;for(let f=0;f<s.data.length;f++){let p={...u,context:{...u?.context,index:f}},h=e._parse(s.data[f],p);if(h.success)c.push(h.data);else {let E=kt(h,f,a,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function Tt(){return b(()=>true)}function K(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Ot(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${De(o)?JSON.stringify(o):`"${o}"`}`,r=b(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,g(r,"_parse",(o,i,s)=>{let a=s,c=[];for(let p=0;p<e.length;p++){let h=e[p]._parse(i,a);if(h.success)return h;c.push(h);}let{abortEarly:l}=me(a),u={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<c.length;p++){let h=c[p].errors;if(h?.length)for(let E=0;E<h.length;E++)h[E].cause?.key&&f.push(je(h[E],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function It(e,t){let n=b(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function Pt(e){let t=b(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,g(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Bt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Dt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return K(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},Fe({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return K(n=>{if(Be(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},He({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return K(n=>Be(n)||Pe(n)&&Number.isFinite(n)?String(n):n,$e({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return K(n=>{let r;return W(n)&&(r=n.trim()),Pe(n)&&Number.isFinite(n)||r?new Date(r??n):n},Ke({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return g(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},jt={},d={object:vt,string:$e,number:He,boolean:Fe,date:Ke,function:Mt,enum:wt,array:Lt,any:Tt,preprocess:K,union:Ot,literal:It,contextRef:Pt,withContext:Bt,coerce:jt,cast:Dt};function At(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function g(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function b(e,{type:t="any",name:n,message:r}={}){r=r||At(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let c=e(s);if(c===true)return {success:true,data:s};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let c=this._parse(s,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=s(u.data)),u}),this},optional(){return Ie(this,s=>s===void 0),this},nullable(){return Ie(this,s=>s===null),this},nullish(){return Ie(this,s=>s==null),this},default(s){return g(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof s=="function"?s({context:l?.context}):s),a(c,l))),this},catch(s){return g(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof s=="function"?s({input:c,error:u.error}):s}}),this},pipe(s){return g(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?s._parse(u.data,l):u}),this},refine(s,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||At(c),t=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return g(this,"_parse",(u,f,p)=>{let h=u(f,p),{abortEarly:E}=me(p);if(!h.success)return h;let A=s(h.data);if(A===true||typeof A=="object"&&A?.success===true)return h;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return Rt.length>0?Rt.reduce((s,a)=>a(s,e,o)??s,i):i}var Rt=[];var qe=Ge(),Ve=Ge(),$t=Ge(),Bn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ge(){return Math.floor(Math.random()*16777215)}function Dn(){return Ve=(Ve+1)%16777215,Ve}function de(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Dn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,qe>>16&255,qe>>8&255,qe&255,$t>>8&255,$t&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Bn[n.charCodeAt(o)];return r}var Ht=Symbol("block-element"),jn=Symbol("block-element-body"),Ue=Symbol("selectable-element");function Ye(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function $n(e){return e?Ye(e.startContainer,Ht):null}function Ft(e){return Ye(e,Ht)}function Hn(e){return e?Ye(e.startContainer,Ue):null}function Kt(){return window.getSelection()}function X(){let e=Kt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function qt(){let e=X();if(!e)return 0;e.collapse(true);let t=Hn(e),n=$n(e),r=t??ge(n);return Vt(r,e.startContainer,e.startOffset)}function Vt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function Fn(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let i=o.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(r+s>=t)return n.setEnd(i,t-r),n.setStart(i,t-r),n;r+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)o.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function z(e,t){let n=Fn(e,t),r=Kt();r.removeAllRanges(),r.addRange(n);}function ge(e){if(!e)return null;let t=Kn(e);return t?.firstElementChild??t?.firstChild}function Kn(e){if(!e)return null;for(let t of e.children)if(t[jn])return t;return null}var Gt={INPUT:"mrakomor:input"};var Ut=Le();var Ee=class extends Nt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Te(Ut),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(Gt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var We="molecule.paragraph.Paragraph";var Yt="molecule.headline.H1",Wt="molecule.headline.H2",Xt="molecule.headline.H3",zt="molecule.headline.H4",Jt="molecule.headline.H5";function N(e){return e===`
3
3
  `||e===`\r
4
- `?"":e??""}function en({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...o,text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]},...r?{settings:r}:{}}}function tn(e,t){let n=M(e.properties.text),r=M(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function Qt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Zt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function Fn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=Qt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Zt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Qt(e.properties.entityRanges,t),r.properties.entityRanges=Zt(e.properties.entityRanges,t),r.componentId=he(),{originalLineState:n,newLineState:r}}function nn(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Fn(e.getState(),qt(e.element));return e.mrakomor.command.insertBlockElement({range:X(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}var Ee=class extends ge{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:M(this.getState()?.properties?.text).length;de(this.element,r);};n(),U(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return en({originComponent:this.NAMESPACE,properties:{...t?.properties,text:M(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return tn(t,n)}};function rn(e,{component:t,properties:n,settings:r=d.object({}).default({})}){return d.object({component:d.string().default(t),componentId:d.string().default(e?.getAttribute("data-componentid")||he()),properties:d.object(n).default({}),settings:r}).default({})}var O=class extends Ee{constructor(t){super(t),this._level=1;}static getStateSchema(t){return rn(t,{component:this.NAMESPACE,properties:{text:d.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse());return n.properties.text=M(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return le(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Ge]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return M(r)?v(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}nn(this,t,{namespace:We});}#e(t){if(!X()?.collapsed)return;let r=Ft(this.element);if(r?.previousElementSibling||M(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:We});let o=()=>{let i=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),s=Ye(i);s?.isConnected&&de(s,0);};o(),U(o);}},z=class extends O{static get NAMESPACE(){return Yt}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},J=class extends O{static get NAMESPACE(){return Wt}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},Q=class extends O{static get NAMESPACE(){return Xt}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},Z=class extends O{static get NAMESPACE(){return zt}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},ee=class extends O{static get NAMESPACE(){return Jt}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function Kn(){return {resolveConfig:e=>(e.blockComponents.push(z,J,Q,Z,ee),e),resolveComponent:e=>{if(e===z.NAMESPACE)return z;if(e===J.NAMESPACE)return J;if(e===Q.NAMESPACE)return Q;if(e===Z.NAMESPACE)return Z;if(e===ee.NAMESPACE)return ee}}}exports.HeadlineComponent=O;exports.headlinePlugin=Kn;
4
+ `?"":e??""}function en({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},i=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:i},...r?{settings:r}:{}}}function tn(e){let t="",n=[],r=[];return (e??[]).forEach((o,i)=>{i>0&&(t+=`
5
+ `);let s=t.length;t+=N(o?.text);for(let a of o?.inlineStyleRanges??[])n.push({...a,offset:a.offset+s});for(let a of o?.entityRanges??[])r.push({...a,offset:a.offset+s});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function nn(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function rn(e,t){let n=N(e.properties.text),r=N(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function Qt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Zt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function qn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=Qt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Zt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Qt(e.properties.entityRanges,t),r.properties.entityRanges=Zt(e.properties.entityRanges,t),r.componentId=de(),{originalLineState:n,newLineState:r}}function on(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=qn(e.getState(),qt(e.element));return e.mrakomor.command.insertBlockElement({range:X(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}var ye=class extends Ee{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:N(this.getState()?.properties?.text).length;z(this.element,r);};n(),$(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:N(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),en({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=tn(n?.properties?.items);return rn(t,nn(r))}};function sn(e,{component:t,properties:n,settings:r=d.object({}).default({})}){return d.object({component:d.string().default(t),componentId:d.string().default(e?.getAttribute("data-componentid")||de()),properties:d.object(n).default({}),settings:r}).default({})}var O=class extends ye{constructor(t){super(t),this._level=1;}static getStateSchema(t){return sn(t,{component:this.NAMESPACE,properties:{text:d.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse());return n.properties.text=N(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return fe(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Ue]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return N(r)?M(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}on(this,t,{namespace:We});}#e(t){if(!X()?.collapsed)return;let r=Ft(this.element);if(r?.previousElementSibling||N(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:We});let o=()=>{let i=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),s=ge(i);s?.isConnected&&z(s,0);};o(),$(o);}},J=class extends O{static get NAMESPACE(){return Yt}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},Q=class extends O{static get NAMESPACE(){return Wt}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},Z=class extends O{static get NAMESPACE(){return Xt}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},ee=class extends O{static get NAMESPACE(){return zt}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},te=class extends O{static get NAMESPACE(){return Jt}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function Vn(){return {resolveConfig:e=>(e.blockComponents.push(J,Q,Z,ee,te),e),resolveComponent:e=>{if(e===J.NAMESPACE)return J;if(e===Q.NAMESPACE)return Q;if(e===Z.NAMESPACE)return Z;if(e===ee.NAMESPACE)return ee;if(e===te.NAMESPACE)return te}}}exports.HeadlineComponent=O;exports.headlinePlugin=Vn;
package/dist/headline.mjs CHANGED
@@ -1 +1 @@
1
- export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-UC7W4JIH.mjs';import'./chunk-G2QV4GOO.mjs';import'./chunk-GDID5DFL.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-TX4RCFPO.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';
1
+ export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-TL5BHWDU.mjs';import'./chunk-GDDVUIEH.mjs';import'./chunk-JVQ2YGII.mjs';import'./chunk-ZHOZPQZH.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-FAXIFXQK.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-P7TUN2KD.mjs';import'./chunk-7CJLTNHZ.mjs';
package/dist/help.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {b}from'./chunk-5VPYPKGA.mjs';import {o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/help/help.css",a=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(t){return t.getAttribute("data-mrakomor-css-path")===e});if(!a){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent=`.mrakomor-help-plugin-container{display:contents}.mrakomor-help{width:420px;max-width:calc(100vw - 32px);max-height:70vh;overflow:auto;border:1px solid #e2e8f0;border-radius:12px;background:#fff;box-shadow:0 18px 40px #0f172a29,0 2px 8px #0f172a14;color:#0f172a;font-size:13px;line-height:1.45}.mrakomor-help__header{padding:16px 18px 12px;border-bottom:1px solid #eef2f6;background:linear-gradient(180deg,#fafbfc,#fff)}.mrakomor-help__title{margin:0;font-size:16px;font-weight:650;letter-spacing:-.01em}.mrakomor-help__subtitle{margin:4px 0 0;font-size:12px;color:#64748b}.mrakomor-help__body{padding:8px 10px 12px}.mrakomor-help__section+.mrakomor-help__section{margin-top:10px}.mrakomor-help__group{margin:0 0 6px;padding:0 8px;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#64748b}.mrakomor-help__list{margin:0;padding:0;list-style:none}.mrakomor-help__item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:start;padding:10px 8px;border-radius:8px}.mrakomor-help__item+.mrakomor-help__item{border-top:1px solid #f1f5f9}.mrakomor-help__description{color:#334155}.mrakomor-help__keys{display:flex;flex-wrap:wrap;gap:4px;justify-content:flex-end}.mrakomor-help__kbd{display:inline-flex;align-items:center;min-height:22px;padding:2px 7px;border:1px solid #dbe2ea;border-bottom-width:2px;border-radius:6px;background:#f8fafc;color:#0f172a;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;white-space:nowrap}
2
- `,document.head.appendChild(r);}}})();var p={id:"help",label:"Help",keywords:["help","shortcuts"],group:"help",order:1e4,description:"Show keyboard shortcuts and slash commands",handler:e=>{e.mrakomor.command.openHelp?.();}},c=[{id:"block.split",group:"blocks",description:"Split the current block or insert a new line",commands:[],shortcuts:["Enter"]},{id:"block.merge",group:"blocks",description:"Merge with the previous block or outdent a list item",commands:[],shortcuts:["Backspace"]},{id:"overlay.dismiss",group:"navigation",description:"Close the open dialog, menu, or slash palette",commands:[],shortcuts:["Escape"]}];function h(e){return e?e.charAt(0).toUpperCase()+e.slice(1):"General"}function m(e){let a=new Map;for(let r of e){let t=r.group||"general",n=a.get(t)??[];n.push(r),a.set(t,n);}return a}function d(e){let a=m(e),r=[];for(let[t,n]of a)r.push(o("section",{className:"mrakomor-help__section","data-group":t},[o("h3",{className:"mrakomor-help__group"},h(t)),o("ul",{className:"mrakomor-help__list"},n.map(s=>o("li",{className:"mrakomor-help__item","data-help-id":s.id},[o("div",{className:"mrakomor-help__description"},s.description),o("div",{className:"mrakomor-help__keys"},[...(s.commands??[]).map(l=>o("kbd",{className:"mrakomor-help__kbd"},l)),...(s.shortcuts??[]).map(l=>o("kbd",{className:"mrakomor-help__kbd"},l))])])))]));return o("div",{className:"mrakomor-help",role:"document","aria-label":"Editor help"},[o("header",{className:"mrakomor-help__header"},[o("h2",{className:"mrakomor-help__title"},"Help"),o("p",{className:"mrakomor-help__subtitle"},"Keyboard shortcuts and slash commands")]),o("div",{className:"mrakomor-help__body"},r)])}function u({mrakomor:e}){let a=null;function r(t={}){e.command.openDialog?.({element:t.element??null,children:d(e.register.help.list())},{placement:"center"});}return {registerCommands(t){t.command.openHelp=r;let n=e.register.slashActions;n&&!n.has(p.id)&&n.add(p);for(let s of c)e.register.help.add(s);e.register.help.add({id:p.id,group:p.group,description:p.description,commands:["/help"],shortcuts:[]});},onMount(){let{dispose:t}=b(e,"mrakomor-help-plugin-container",o("button",{type:"button",className:"mrakomor-footer-action mrakomor-help-trigger","aria-label":"Open help",title:"Keyboard shortcuts and commands",onClick:n=>{r({element:n.currentTarget});}},[o("span",{className:"mrakomor-footer-action__icon","aria-hidden":"true"},"?"),"Help"]));a=t;},onUnmount(){a?.(),a=null;}}}export{p as HELP_SLASH_ACTION,d as buildHelpDialogContent,m as groupHelpEntries,u as helpPlugin};
1
+ import {b}from'./chunk-ERNLRJPB.mjs';import {p as p$1}from'./chunk-7CJLTNHZ.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/help/help.css",a=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(t){return t.getAttribute("data-mrakomor-css-path")===e});if(!a){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent=`.mrakomor-help-plugin-container{display:contents}.mrakomor-help{width:420px;max-width:calc(100vw - 32px);max-height:70vh;overflow:auto;border:1px solid #e2e8f0;border-radius:12px;background:#fff;box-shadow:0 18px 40px #0f172a29,0 2px 8px #0f172a14;color:#0f172a;font-size:13px;line-height:1.45}.mrakomor-help__header{padding:16px 18px 12px;border-bottom:1px solid #eef2f6;background:linear-gradient(180deg,#fafbfc,#fff)}.mrakomor-help__title{margin:0;font-size:16px;font-weight:650;letter-spacing:-.01em}.mrakomor-help__subtitle{margin:4px 0 0;font-size:12px;color:#64748b}.mrakomor-help__body{padding:8px 10px 12px}.mrakomor-help__section+.mrakomor-help__section{margin-top:10px}.mrakomor-help__group{margin:0 0 6px;padding:0 8px;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#64748b}.mrakomor-help__list{margin:0;padding:0;list-style:none}.mrakomor-help__item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:start;padding:10px 8px;border-radius:8px}.mrakomor-help__item+.mrakomor-help__item{border-top:1px solid #f1f5f9}.mrakomor-help__description{color:#334155}.mrakomor-help__keys{display:flex;flex-wrap:wrap;gap:4px;justify-content:flex-end}.mrakomor-help__kbd{display:inline-flex;align-items:center;min-height:22px;padding:2px 7px;border:1px solid #dbe2ea;border-bottom-width:2px;border-radius:6px;background:#f8fafc;color:#0f172a;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;white-space:nowrap}
2
+ `,document.head.appendChild(r);}}})();var p={id:"help",label:"Help",keywords:["help","shortcuts"],group:"help",order:1e4,description:"Show keyboard shortcuts and slash commands",handler:e=>{e.mrakomor.command.openHelp?.();}},c=[{id:"block.split",group:"blocks",description:"Split the current block or insert a new line",commands:[],shortcuts:["Enter"]},{id:"block.merge",group:"blocks",description:"Merge with the previous block or outdent a list item",commands:[],shortcuts:["Backspace"]},{id:"overlay.dismiss",group:"navigation",description:"Close the open dialog, menu, or slash palette",commands:[],shortcuts:["Escape"]}];function h(e){return e?e.charAt(0).toUpperCase()+e.slice(1):"General"}function m(e){let a=new Map;for(let r of e){let t=r.group||"general",n=a.get(t)??[];n.push(r),a.set(t,n);}return a}function d(e){let a=m(e),r=[];for(let[t,n]of a)r.push(p$1("section",{className:"mrakomor-help__section","data-group":t},[p$1("h3",{className:"mrakomor-help__group"},h(t)),p$1("ul",{className:"mrakomor-help__list"},n.map(s=>p$1("li",{className:"mrakomor-help__item","data-help-id":s.id},[p$1("div",{className:"mrakomor-help__description"},s.description),p$1("div",{className:"mrakomor-help__keys"},[...(s.commands??[]).map(l=>p$1("kbd",{className:"mrakomor-help__kbd"},l)),...(s.shortcuts??[]).map(l=>p$1("kbd",{className:"mrakomor-help__kbd"},l))])])))]));return p$1("div",{className:"mrakomor-help",role:"document","aria-label":"Editor help"},[p$1("header",{className:"mrakomor-help__header"},[p$1("h2",{className:"mrakomor-help__title"},"Help"),p$1("p",{className:"mrakomor-help__subtitle"},"Keyboard shortcuts and slash commands")]),p$1("div",{className:"mrakomor-help__body"},r)])}function u({mrakomor:e}){let a=null;function r(t={}){e.command.openDialog?.({element:t.element??null,children:d(e.register.help.list())},{placement:"center"});}return {registerCommands(t){t.command.openHelp=r;let n=e.register.slashActions;n&&!n.has(p.id)&&n.add(p);for(let s of c)e.register.help.add(s);e.register.help.add({id:p.id,group:p.group,description:p.description,commands:["/help"],shortcuts:[]});},onMount(){let{dispose:t}=b(e,"mrakomor-help-plugin-container",p$1("button",{type:"button",className:"mrakomor-footer-action mrakomor-help-trigger","aria-label":"Open help",title:"Keyboard shortcuts and commands",onClick:n=>{r({element:n.currentTarget});}},[p$1("span",{className:"mrakomor-footer-action__icon","aria-hidden":"true"},"?"),"Help"]));a=t;},onUnmount(){a?.(),a=null;}}}export{p as HELP_SLASH_ACTION,d as buildHelpDialogContent,m as groupHelpEntries,u as helpPlugin};
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
- 'use strict';(function(){if(!(typeof document>"u")){var t="mrakomor/core/style/core.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.mrakomor-editor:focus-visible{outline:none}.mrakomor-editor{display:flex;flex-direction:column;min-height:0}.mrakomor-editor-surface{position:relative;flex:1 1 auto;min-height:0}.mrakomor-tools-container{position:absolute;inset:0;pointer-events:none;z-index:4}.mrakomor-content{position:relative;min-height:0}.mrakomor-content:focus-visible{outline:none}
2
- `,document.head.appendChild(n);}}})();var Ft=class{next(...t){}error(...t){}complete(...t){}},ct=class{#e=new Set;pipe(...t){return t.reduce((e,n)=>n(e),this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t);});}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e);});}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e);});}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#e.delete(t);}};var ve=Symbol("@esmj/signals:type"),ye=Symbol("@esmj/signals:name");var w=null,lt=false,ut=[];function H(t){let e=w;w=null;let n=t();return w=e,n}function co(){lt=false;let t=zt();for(let n of t)n.get();let e=ut;ut=[];for(let n of e)n();}function Ht(){lt||(lt=true,queueMicrotask(co));}function ft(t){ut.push(t),Ht();}var qt=Symbol("@esmj/signals:internal observable"),K=Symbol("@esmj/signals:original function"),lo=class extends ct{#e=new Set;#o=null;constructor(t){super(),this.#o=t,this.pipe(e=>{let n=e.subscribe.bind(e),o=e.unsubscribe.bind(e);return e.subscribe=r=>{n(r),this.#e.add(r);},e.unsubscribe=r=>{o(r),this.#e.delete(r);},e});}watch(t){if(typeof t.next!="function"&&(t.next=()=>H(()=>{this.#e.add(t),this.#o();}),t.next[K]=void 0),t instanceof Wt&&t.next[K]===void 0){let e=t.next.bind(t);t.next=()=>H(()=>{this.#e.add(t),e(),this.#o();}),t.next[K]=e;}return this.subscribe(t)}getPending(){let t=[];for(let e of this.#e){if(!e.get[K]){let n=e.get,o=n.bind(e);e.get=()=>H(()=>(this.#e.delete(e),o())),e.get[K]=n;}t.push(e);}return t}unwatch(t){return t.next=t.next[K]?t.next[K]:t.next,t.get=t.get[K]?t.get[K]:t.get,this.#e.delete(t),this.unsubscribe(t)}},Ie=null;function Gt(t){Ie=new lo(t);}Gt(()=>{Ht();});function zt(){return Ie.getPending()}function Vt(t){return Ie.watch(t)}function Yt(t){return Ie.unwatch(t)}var F=Symbol("@esmj/signals:no error"),Wt=class Xt extends Ft{#e=true;#o=false;#t=null;#n=this.#u();#r=null;#i=null;#c=0;#a=new Map;#s=F;constructor(e,n){super(),this.#r=e,this.#i=n,this.debug=n?.debug,this[ve]="computed",this[ye]=n?.debug??null,this.get=this.get.bind(this);}#l(){for(let{unsubscribe:e}of this.#n.dependencies.values())e();this.#n.dependencies.clear();}#u(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#c}getDebugInfo(){return {name:this[ye],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#a.keys()]}}#m(){for(let[e,n]of this.#a)if(e instanceof Xt&&H(()=>e.get()),e.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[qt].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=C(this.#f(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#m()?this.#f():this.#e=false),w&&w.sourceRevisions.set(this,this.#c),this.#s!==F)throw this.#s;return this.#t.get()}peek(){if(this.#t||(this.#t=C(this.#f(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#m()?this.#f():this.#e=false),this.#s!==F)throw this.#s;return this.#t.peek()}#f(){this.#o=true,this.#e=false,this.#s=F,this.#l(),this.#n.sourceRevisions.clear();let e=w;w=this.#n;let n;try{n=this.#r();}catch(o){this.#s=o;}return w=e,this.#a=this.#n.sourceRevisions,this.#n.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#s=F,this.#t.set(o);}).catch(o=>{this.#s=o;})),this.#s===F&&this.#t&&this.#t.set(n),this.#c++,n}destroy(){this.#l(),this.#a.clear(),this.#e=true,this.#s=F;}};function B(t,e){return new Wt(t,e)}function D(t,e){let n,{debug:o,...r}={},s=B(()=>{n?.(),n=t();},{equals:()=>false,...r});s.get(),Vt(s);let i=()=>{n?.(),s.destroy(),Yt(s);};return i[Symbol.dispose]=i,i[ve]="effect",i[ye]=o??null,i.__RX_COMPUTED__=s,i}function C(t,e={}){let n=e?.equals??Object.is,o=0,r=new ct;function s(){return w&&(w.dependencies.set(r,r.subscribe(w.observer)),w.sourceRevisions.set(l,o)),t}function i(){return t}function a(u){if(!n(t,u)){t=u,o++,r.next();}return t}function c(){return o}let l={get:s,set:a,peek:i,getRevision:c,[qt]:r,[ve]:"signal",[ye]:e?.debug??null};return l}function Be(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var sn=Symbol("node-component"),Me=Symbol("node-internal"),uo=Symbol("keep-literal"),Oe=Symbol("raw-props");function dt(t){return typeof t=="function"?t:t!=null&&typeof t.get=="function"?()=>t.get():()=>t}function gt(t,e){let n=t.children!==void 0?t.children:e;return Array.isArray(n)?n[0]:n}var fo=new Set(["template","script"]);function mo(t,e){let n=(t==null?"span":String(t)).trim(),o=n;fo.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${t}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),o="span");let r=document.createElement(o);return o==="span"&&(r.style.display="contents"),r.setAttribute(e,Be()),r}function ht(t,e,n){let o=mo(t,e);return n?.id&&o.setAttribute("id",n.id),o}function oe(t){let e=null,n=()=>e,o=s=>(e=s??null,e),r={get:n,set:o,[Symbol.toPrimitive](){return e?String(e):""}};return Object.defineProperty(r,"current",{get(){return e},set(s){o(s);},enumerable:true,configurable:false}),new Proxy(r,{get(s,i,a){if(Reflect.has(s,i))return Reflect.get(s,i,a);if(!e)return;let c=e[i];return typeof c=="function"?c.bind(e):c},set(s,i,a,c){return Reflect.has(s,i)||!e?Reflect.set(s,i,a,c):(e[i]=a,true)},has(s,i){return Reflect.has(s,i)||!!e&&i in e}})}var an=null;function $(){return an}function we(t){an=t;}function re(t){return t?.[sn]||null}function Jt(t,e){t[sn]=e;}function Le(t,e={disposers:[],id:Be()}){return t?.[Me]?t[Me]:(t&&(t[Me]=e),e)}function po(t){return t[Me]}function q(t,e){let n=po(t);n||(n=Le(t)),n.disposers.push(e);}function Se(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n);}function G(t,e){let n=$();we(t);try{return e()}finally{we(n);}}var Te=new Map,Ce=new Map,Qt=new Map;function cn(t,e){let n=typeof e=="function"?e:r=>!!e?.includes(r),o=Object.create(null);for(let r of Object.keys(t)){let s=t[r];r==="children"||n(r)?o[r]=s:s?.[uo]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=B(s):o[r]=C(s);}return o}function se(t,e){if(t===e)return true;if(t==null||e==null||typeof t!="object"||typeof e!="object")return false;let n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?false:n.every(r=>{let s=Object.getOwnPropertyDescriptor(t,r),i=Object.getOwnPropertyDescriptor(e,r);if(!s||!i)return false;let a="value"in s?s.value:s.get?.call(t),c="value"in i?i.value:i.get?.call(e);return se(a,c)})}function Et(t){return {id:Symbol("context-id"),defaultValue:t}}function yt(t,e){let n=$();n&&n.contexts.set(t.id,e);}function bt(t){let e=$();return e?.contexts?.has(t.id)?e.contexts.get(t.id):t.defaultValue}function De(t){let e=$();if(!e){console.warn("onMount called outside of a component context");return}Se(Te,e.id,t);}function Pe(t){let e=$();if(!e){console.warn("onUnmount called outside of a component context");return}Se(Ce,e.id,t);}function R(t){ft(()=>{setTimeout(t,0);});}function ie(t){let e=t.componentId,n=Te.get(e);if(n){Te.delete(e);for(let o of n){let r=o();typeof r=="function"&&Se(Ce,e,r);}}}function go(t){let e=Ce.get(t);if(e){Ce.delete(t);for(let n of e)n();}}function ho(t){let e=Qt.get(t);if(e){Qt.delete(t);for(let n of e)n();}}function ke(t){if(!t)return;let e=Le(t);if(e?.disposers?.length){for(let o of e.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}e.disposers=[];}let n=re(t);if(n&&(go(n.componentId),ho(n.componentId)),t.childNodes){let o=t.firstChild;for(;o;){let r=o.nextSibling;ke(o),o=r;}}}function z(t){return t!=null&&typeof t=="object"&&typeof t.$constructor=="function"}function Zt(t){return typeof t=="function"&&typeof t.prototype?.render=="function"}function Eo(t,e,n){let o=Be(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=Zt(t)?void 0:t[Oe],i={...cn(e??{},s),children:n},a=$(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};we(c);let l;if(Zt(t)){r.ClassConstructor=t;let f=new t(i);r.classInstance=f,typeof f.onMount=="function"&&Se(Te,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Se(Ce,o,()=>{f.onUnmount?.();}),l=f.render();}else l=t(i);we(a);let u=yo(l);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)Le(f,c),Jt(f,r);else Le(u,c),u instanceof Node&&Jt(u,r);return u}};return r}function xt(t,e){let n=e.$constructor();n instanceof Node&&t.appendChild(n),queueMicrotask(()=>{ie(e);});}function yo(t){return t instanceof Node?t:z(t)?t.$constructor():typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):document.createTextNode("")}var en={className:"class",htmlFor:"for"},tn=new Set(["value","defaultValue","checked","selected","indeterminate"]),bo=new Set(["srcdoc"]),xo=new Set(["href","src","action","formaction","xlink:href"]),So=new Set(["securitypolicyviolation"]),Co=new Set(["contenteditable","draggable","spellcheck"]);function xe(t){return t!=null&&typeof t=="object"&&typeof t.get=="function"&&!(t instanceof Node)}var ln=Symbol("Fragment");function E(t,e,n){if(t===ln){let r=document.createDocumentFragment();return pt(r,on(n)),r}if(typeof t=="function")return Eo(t,e||{},n);typeof t!="string"&&(n=e,e=t,t="div"),e=e||{};let o=document.createElement(t);return e.id&&o.setAttribute("id",e.id),$e(o,e),pt(o,on(n)),o}function mt(t,e){e instanceof DocumentFragment?t.replaceChildren(e):t.innerHTML=e??"";}function ko(t){return typeof t!="string"?false:t.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function _o(t,e){if(typeof t!="string")return false;let n=t.toLowerCase();return bo.has(n)?true:xo.has(n)&&e!==null&&e!==void 0&&ko(String(e))}function un(t){return typeof t!="string"?t:en[t]?en[t]:t}function No(t,e){let n=un(t),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Co.has(o)&&(e===true||e===false||e==="true"||e==="false")?String(e):e==null||e===false?null:e}function nn(t,e,n){let o=No(e,n);if(o===null){t.removeAttribute(e);return}if(_o(e,o)){t.removeAttribute(e),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(e)}" on <${t.tagName.toLowerCase()}>`);return}t.setAttribute(e,o);}function $e(t,e){let n=$();for(let[o,r]of Reflect.ownKeys(e).map(s=>[s,e[s]]))if(o!=="id"){if(o=un(o),o==="$ref"){typeof r=="function"?r(t):typeof r=="object"&&r!==null&&(r.current=t);continue}if(o==="$dangerouslySetInnerHTML"){if(xe(r)){let s=D(()=>{G(n,()=>{mt(t,r.get());});});q(t,s);}else if(typeof r=="function"){let s=D(()=>{G(n,()=>{mt(t,r());});});q(t,s);}else mt(t,r);continue}if(o==="style"){if(xe(r)){let s=D(()=>{G(n,()=>{Object.assign(t.style,r.get());});});q(t,s);}else typeof r=="object"&&r!==null?Object.assign(t.style,r):t.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(So.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${t.tagName.toLowerCase()}>`);continue}t.addEventListener(s,r);continue}if(xe(r)||typeof r=="function"){let s=o,i=D(()=>{G(n,()=>{let a=typeof r=="function"?r():r.get();tn.has(s)?t[s]=a??"":nn(t,s,a);});});q(t,i);continue}tn.has(o)||typeof o=="symbol"?t[o]=r??"":nn(t,o,r);}}function on(t){return t==null?[]:Array.isArray(t)?t.flat(Number.POSITIVE_INFINITY):[t]}function pt(t,e){for(let n of e)fn(t,n);}function fn(t,e){if(!(e==null||e===false||e===true)){if(e instanceof Node){t.appendChild(e);return}if(typeof e=="string"||typeof e=="number"){t.appendChild(document.createTextNode(String(e)));return}if(typeof e=="function"){rn(t,e);return}if(z(e)){xt(t,e);return}if(xe(e)){rn(t,()=>e.get());return}if(Array.isArray(e)){pt(t,e);return}t.appendChild(document.createTextNode(String(e)));}}function ae(t){let e=null,n=t;return z(t)&&(e=t,n=t.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:e}:n instanceof Node?{nodes:[n],instance:e}:n==null||n===false||n===true?{nodes:[],instance:e}:{nodes:[document.createTextNode(String(n))],instance:e}}function je(t,e=true){for(let n of t)e&&ke(n),n.remove();}function rn(t,e){let n=$(),o=document.createComment("");t.appendChild(o);let r=[],s=D(()=>{G(n,()=>{let i=e(),{nodes:a,instance:c}=ae(i);je(r),a.length&&o.after(...a),c&&queueMicrotask(()=>ie(c)),r=a;});});q(t,s);}var Ue=class{constructor(t){this.props=t;}};function mn(t,e,n,o){let{equals:r=se,tagName:s="span",...i}=o??{},a=ht(s,"data-for",i);$e(a,i);let c=$(),l=[],u=new Map,f=B(()=>t()),d=D(()=>{let h=f.get(),x=Array.isArray(h)?h:[],_=[],N=[],g=new Set;for(let b=0;b<x.length;b++){let A=x[b],v=e(A,b);if(g.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${b}`);continue}g.add(v),_.push(A),N.push(v);}let y=new Map(l.map(b=>[b.key,b])),k=[];for(let b=0;b<_.length;b++){let A=N[b],v=_[b],U=y.get(A);if(U)u.get(A).set(v),k.push(U),y.delete(A);else {let Ee=C(v,{equals:r});u.set(A,Ee);let at={...Ee,set(){}},X={key:A,nodes:[]};G(c,()=>{let ro=n(at,b),{nodes:so,instance:Kt}=ae(ro);X.nodes=so,Kt&&queueMicrotask(()=>ie(Kt));}),k.push(X);}}for(let[b,A]of y)je(A.nodes),u.delete(b);let S=null;for(let b=k.length-1;b>=0;b--){let A=k[b].nodes;for(let v=A.length-1;v>=0;v--){let U=A[v];(U.parentNode!==a||U.nextSibling!==S)&&a.insertBefore(U,S),S=U;}}l=k;});return q(a,d),a}function St(t,e,n,o){if(typeof t=="function")return mn(t,e,n,o);let{each:r,keyFn:s,equals:i,tagName:a,children:c,...l}=t??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=dt(r),f=gt(t??{},e);return mn(u,s,f,{...l,equals:i,tagName:a})}St[Oe]=t=>t!=="each";function J(t,e){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("mount: container not found");t instanceof DocumentFragment||(ke(t),t.innerHTML=""),z(e)?xt(t,e):e instanceof Node?t.appendChild(e):t.appendChild(document.createTextNode(String(e)));}function dn(t){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("unmount: container not found");ke(t),t.innerHTML="";}function _e(t,e){let n=null;if(z(e)?(n=e.$constructor(),queueMicrotask(()=>ie(e))):e instanceof Node?n=e:n=document.createTextNode(String(e)),n instanceof HTMLElement){let o=B(()=>!!t()),r=D(()=>{n.style.display=o.get()?"":"none";});q(n,r);}return n}var L=class extends Ue{static get nodeName(){return "span"}static get style(){return "SPAN"}static match(e){return e.nodeName===this.nodeName.toUpperCase()||e.style===this.style}getState(){return {style:this.constructor.style}}render(){return E(this.constructor.nodeName,{},this.props.children)}};var ce=class extends L{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return E("b",{},"B")}static match(e){return e.nodeName==="strong"?true:super.match(e)}};var le=class extends L{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return E("i",{},"I")}};var ue=class extends L{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return E("sub",{},"Sub")}};var fe=class extends L{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return E("sup",{},"Sup")}};var me=class extends L{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return E("u",{},"U")}};var j=Symbol("result-key"),Ke=Symbol("stopped-event");function gn(t,e){let n=!!e.name,o=e[j]||"result",r=o.includes("."),s={error:null,context:{},[j]:o,...e,[o]:n?void 0:Q(e,o),name:t,[Ke]:false,defaultPrevented:false};return r&&(Ro(s,o),s[o]=n?void 0:Q(e,o)),s.stopPropagation=()=>{s[Ke]=true;},s.preventDefault=()=>{s.defaultPrevented=true;},s}function Q(t,e){return e===""?t:e.split(".").reduce((o,r)=>o?.[r]??void 0,t)}function Ct(t,e,n){let o=e.split("."),r=o.pop(),s=Q(t,o.join("."));return s[r]=n}function Ro(t,e){let n=e.split(".");n.pop(),n.reduce((o,r)=>o[r]=o[r]??{},t);}var Fe=class{constructor({logger:e,debug:n}={}){this._logger=e??console,this._debug=n??false,this._events=new Map,this.addListener=this.on,this.removeListener=this.off;}emit(e,n={}){let o=this.listeners(e),r=gn(e,n),s=null,i=null;this._debug&&(typeof this._debug=="function"?this._debug(e,r):this._logger.debug(`Event name: ${e}, event: ${r}`));for(let a of o){if(s&&(s=s.then(c=>(Ct(r,r[j],c??Q(r,r[j])),r[Ke]?Q(r,r[j]):a(r)))),!s){if(r[Ke])return r;i=a(r);}i instanceof Promise&&!s?s=i:Ct(r,r[j],i??Q(r,r[j]));}return s?s.then(a=>(Ct(r,r[j],a??Q(r,r[j])),r)):r}emitParallel(e,n={}){let o=this.listeners(e),r=gn(e,n);return Promise.all(o.map(async s=>await s(r))).then(s=>(r[r[j]]=s,r)).catch(s=>{throw r.error=s,s})}listeners(e){return this._events.has(e)?[...this._events.get(e)]:[]}removeAllListeners(e){return e?this.listeners(e).forEach(n=>this.off(e,n)):Array.from(this._events.keys()).forEach(n=>this.removeAllListeners(n))}_addListener(e,n,o){return this._events.has(e)||this._events.set(e,[]),this._events.get(e)[o](n),()=>{this.off(e,n);}}on(e,n){if(typeof n!="function")throw new TypeError("The listener must be a function");return this._addListener(e,n,"push")}prependListener(e,n){return this._addListener(e,n,"unshift")}_addListenerOnce(e,n,o){let r=this[o](e,s=>(r(),n(s)));}once(e,n){return this._addListenerOnce(e,n,"on")}prependOnceListener(e,n){return this._addListenerOnce(e,n,"prependListener")}off(e,n){if(this._events.has(e)){let o=this._events.get(e),r=o.indexOf(n);o.splice(r,1);}}};var m={INSERT_BLOCK_ELEMENT:"mrakomor:insert-block-component",REPLACE_BLOCK_ELEMENT:"mrakomor:replace-block-component",REMOVE_BLOCK_ELEMENT:"mrakomor:remove-block-component",MERGE_BLOCK_ELEMENT:"mrakomor:merge-block-component",INSERT_ENTITY_RANGE:"mrakomor:insert-entity-range",REMOVE_ENTITY_RANGE:"mrakomor:remove-entity-range",INSERT_INLINE_STYLE_RANGE:"mrakomor:insert-inline-style-range",KEYDOWN:"mrakomor:keydown",BEFORE_INPUT:"mrakomor:beforeinput",INPUT:"mrakomor:input",CLICK:"mrakomor:click",FOCUSIN:"mrakomor:focusin",FOCUSOUT:"mrakomor:focusout",SELECTION_CHANGE:"mrakomor:selection-change",CONTENT_CHANGE:"mrakomor:content-change",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element",MOVE_BLOCK_ELEMENT:"mrakomor:move-block-element"};function T(t){return e=>{if(!e.defaultPrevented)return t(e)}}function hn({mrakomor:t}={}){let e=t?.emitter??new Fe;function n(o,r={}){return typeof t?.emit=="function"?t.emit(o,r):e.emit(o,{...r,mrakomor:t})}return {emitter:e,command:{insertBlockElement(o,r){n(m.INSERT_BLOCK_ELEMENT,{...o,options:r});},replaceBlockElement(o,r){n(m.REPLACE_BLOCK_ELEMENT,{...o,options:r});},removeBlockElement(o,r){n(m.REMOVE_BLOCK_ELEMENT,{...o,options:r});},mergeBlockElement(o,r){n(m.MERGE_BLOCK_ELEMENT,{...o,options:r});},insertEntityRange(o,r){n(m.INSERT_ENTITY_RANGE,{...o,options:r});},removeEntityRange(o,r){n(m.REMOVE_ENTITY_RANGE,{...o,options:r});},insertInlineStyleRange(o,r){n(m.INSERT_INLINE_STYLE_RANGE,{...o,options:r});},transformBlockElement(o,r){n(m.TRANSFORM_BLOCK_ELEMENT,{...o,options:r});},moveBlockElement(o,r){n(m.MOVE_BLOCK_ELEMENT,{...o,options:r});}}}}var En=class{#e=new Set;pipe(...t){return vo(...t)(this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t);});}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e);});}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e);});}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#e.delete(t);}};function vo(...t){return e=>Array.from(t).reduce((n,o)=>o(n),e)}function yn(t){return t.map((e,n)=>({entry:e,index:n})).sort((e,n)=>{let o=e.entry.order??e.index,r=n.entry.order??n.index;return o!==r?o-r:e.index-n.index}).map(({entry:e})=>e)}var pe=class extends En{mrakomor;#e=new Map;#o=null;#t=0;#n;constructor(e,n={}){super(),this.mrakomor=e,this.#n=n.sort??yn;}normalize(e,n){throw new Error("Register subclass must implement normalize")}#r(){this.#o=null,this.next(this.list());}#i(e,n=this.#t++){let o=this.normalize(e,n);return o?(this.#e.set(o.id,o),o):null}add(e){if(Array.isArray(e)){let o=[];for(let r of e){let s=this.#i(r,this.#t++);s&&o.push(s);}return o.length&&this.#r(),o}let n=this.#i(e);return n&&this.#r(),n}get(e){return this.#e.get(e)}has(e){return this.#e.has(e)}remove(e){let n=this.#e.delete(e);return n&&this.#r(),n}list(){return this.#o??=this.#n([...this.#e.values()]),this.#o}};var Io={abortEarly:true};function Rt(t,e){if(e===void 0)return t;let n=t?.cause?.key?`${e}.${t.cause.key}`:`${e}`;return {message:`Error parsing key "${n}": ${t.message}`,cause:{key:n}}}function Bo(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(Rt(t.errors[o],n));}function Sn(t,e,n,o){if(n!==false){let r=Rt(t.error,e);return {success:false,error:r,errors:[r]}}Bo(t,o,e);}function He(t){return t?.abortEarly!==void 0?t:Io}function kt(t,e){I(t,"_parse",(n,o,r)=>{let s=n(o,r);return !s.success&&e(o)?{success:true,data:o}:s});}var Ne=t=>typeof t=="string"||t instanceof String,_t=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),Nt=t=>t===true||t===false,Mo=t=>t instanceof Date&&!Number.isNaN(t.getTime()),wo=t=>typeof t=="function",Lo=t=>Array.isArray(t),At=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Cn(t,e){let n=O(At,{...e,type:"object"});n._getDescription=()=>`object({ ${Object.entries(t).map(([r,s])=>`${r}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>t;let o=n;return o.derive=function(r,{when:s="always"}={}){return I(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=r(l.data,{context:c?.context});if(!At(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(s==="missing"){let f={...l.data};for(let d in u)f[d]===void 0&&(f[d]=u[d]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},I(n,"_parse",(r,s,i)=>{let a=r(s,i),{abortEarly:c}=He(i);if(a.success===false)return a;let l={},u=[];for(let f in t){let d=t[f]._parse(a.data[f],i);if(d.success)l[f]=d.data;else {let h=Sn(d,f,c,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),o}function vt(t){return O(Ne,{...t,type:"string"})}function It(t){return O(_t,{...t,type:"number"})}function Bt(t){return O(Nt,{...t,type:"boolean"})}function Mt(t){return O(Mo,{...t,type:"date"})}function kn(t){return O(wo,{...t,type:"function"})}function _n(t,e){let n=i=>t.includes(i),o=i=>`Invalid ${r} value. Expected ${t.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,r="enum",s=O(n,{message:o,...e,type:r});return s._getDescription=()=>`enum(${t.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>t,s}function Nn(t,e){let n=O(Lo,{...e,type:"array"});return n._getDescription=()=>`array(${t._getDescription()})`,n._getDefinition=()=>t,I(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:a}=He(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let f=0;f<i.data.length;f++){let d={...u,context:{...u?.context,index:f}},h=t._parse(i.data[f],d);if(h.success)c.push(h.data);else {let x=Sn(h,f,a,l);if(x)return x}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function An(){return O(()=>true)}function de(t,e){return I(e,"_parse",(n,o,r)=>(o=t(o),n(o,r))),e}function Rn(t,e){let n=r=>`Invalid union value. Expected the value to match one of the schemas:${t.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof r}" with value: ${At(r)?JSON.stringify(r):`"${r}"`}`,o=O(()=>false,{message:n,...e,type:"union"});return o._getDefinition=()=>t,I(o,"_parse",(r,s,i)=>{let a=i,c=[];for(let d=0;d<t.length;d++){let h=t[d]._parse(s,a);if(h.success)return h;c.push(h);}let{abortEarly:l}=He(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let d=0;d<c.length;d++){let h=c[d].errors;if(h?.length)for(let x=0;x<h.length;x++)h[x].cause?.key&&f.push(Rt(h[x],`branch ${d}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),o}function vn(t,e){let n=O(o=>o===t,{message:o=>e?.message?typeof e.message=="function"?e.message(o):e.message:`Expected literal value "${t}", received "${o}"`,name:e?.name,type:"literal"});return n._getDescription=()=>`literal("${t}")`,n._getDefinition=()=>t,n}function In(t){let e=O(()=>true,{type:"contextRef"});return e._getDescription=()=>`contextRef("${t}")`,I(e,"_parse",(n,o,r)=>({success:true,data:r?.context?.[t]})),e}function Bn(t,e){return {parse(n,o){let r=t.parse(o?.context??{},o);return e(r).parse(n,o)},safeParse(n,o){let r=t.safeParse(o?.context??{},o);return r.success?e(r.data).safeParse(n,o):r}}}var Mn={boolean(t){let e=t?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return de(n=>{let o;return Ne(n)&&(o=n.toLowerCase()),o==="true"||o==="yes"||o==="on"||o==="1"||n===1?true:o==="false"||o==="no"||o==="off"||o==="0"||n===0?false:n},Bt({...t,message:e}))},number(t){let e=t?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return de(n=>{if(Nt(n))return Number(n);if(Ne(n)){let o=n.trim();if(o==="")return n;let r=Number(o);if(Number.isFinite(r))return r}return n},It({...t,message:e}))},string(t){let e=t?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return de(n=>Nt(n)||_t(n)&&Number.isFinite(n)?String(n):n,vt({...t,message:e}))},date(t){let e=t?.message??(n=>`Cannot cast "${n}" to a valid date.`);return de(n=>{let o;return Ne(n)&&(o=n.trim()),_t(n)&&Number.isFinite(n)||o?new Date(o??n):n},Mt({...t,message:e}))},json(t,e){let n=e?.message??(o=>`Cannot parse "${o}" as JSON.`);return I(t,"_parse",(o,r,s)=>{if(Ne(r))try{r=JSON.parse(r);}catch{let i={message:typeof n=="function"?n(r):n};return {success:false,error:i,errors:[i]}}return o(r,s)}),t}},wn={},p={object:Cn,string:vt,number:It,boolean:Bt,date:Mt,function:kn,enum:_n,array:Nn,any:An,preprocess:de,union:Rn,literal:vn,contextRef:In,withContext:Bn,coerce:wn,cast:Mn};function bn(t){return e=>`The value "${e}" must be type of ${t} but is type of "${typeof e}".`}function I(t,e,n){let o=t[e];t[e]=(...r)=>n(o,...r);}function O(t,{type:e="any",name:n,message:o}={}){o=o||bn(e);let r={name:n,message:o,type:e},s={_getName(){return n},_getType(){return e},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=t(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof o=="function"?o(i):o};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return kt(this,i=>i===void 0),this},nullable(){return kt(this,i=>i===null),this},nullish(){return kt(this,i=>i==null),this},default(i){return I(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||bn(c),e=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return I(this,"_parse",(u,f,d)=>{let h=u(f,d),{abortEarly:x}=He(d);if(!h.success)return h;let _=i(h.data);if(_===true||typeof _=="object"&&_?.success===true)return h;let N={message:typeof a=="function"?a(f):a};return {success:false,error:N,errors:[N]}}),this},clone(){return {...this}}};return xn.length>0?xn.reduce((i,a)=>a(i,t,r)??i,s):s}var xn=[];var To=p.object({component:p.function(),id:p.string(),label:p.string(),keywords:p.array(p.string()),group:p.string(),order:p.number().default(({context:t})=>t?.index??0),settings:p.any().optional()});function Oo(t,e){let n=`block:${t}`;return e?.style==="UNORDERED"?`${n}:ul`:e?.style==="ORDERED"?`${n}:ol`:n}function Ln(t,e=0){let n=typeof t=="function",o=n?t:t?.component,r=n?{}:t,s=o.NAMESPACE??"",i=s.split(".").pop()||s,a=r.label||o.LABEL||i||s,c=Array.isArray(o.KEYWORDS)?o.KEYWORDS:[],l=r.keywords?.length?r.keywords.map(String):c.length?c.map(String):[a,i].filter(Boolean).map(String),u=r.settings;return To.parse({component:o,id:r.id||Oo(s,u),label:String(a),keywords:l,group:String(r.group||o.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...u?{settings:u}:{}},{context:{index:e}})}var qe=class t extends pe{#e=null;constructor(e){super(e),this.subscribe(()=>{this.#e=null;});}normalize(e,n){if(e==null)return null;try{return Ln(e,n)}catch{return null}}getByNamespace(e){return this.#o().get(e)}#o(){return this.#e??=t.buildNamespaceMap(this.list()),this.#e}static buildNamespaceMap(e){let n=new Map;for(let o of e){let r=o.component?.NAMESPACE;r&&!n.has(r)&&n.set(r,o.component);}return n}};var wt="molecule.paragraph.Paragraph";var Tn="molecule.external.ExternalComponent",On="namespace.unknown.UnknownComponent";var Dn="molecule.headline.";var Lt=Dt(),Tt=Dt(),Pn=Dt(),Do=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function Dt(){return Math.floor(Math.random()*16777215)}function Po(){return Tt=(Tt+1)%16777215,Tt}function V(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Po(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Lt>>16&255,Lt>>8&255,Lt&255,Pn>>8&255,Pn&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=Do[n.charCodeAt(r)];return o}var Ae=Symbol("block-element"),$o=Symbol("block-element-body"),Ge=Symbol("selectable-element");function ze(t,e){let n=t;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[e]===void 0;)n=n.parentElement;return n??null}function Y(t){return t?ze(t.startContainer,Ae):null}function $n(t){return ze(t,Ae)}function jo(t){return t?ze(t.startContainer,Ge):null}function jn(t){return ze(t,Ge)}function Pt(){return window.getSelection()}function W(){let t=Pt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function $t(){let t=W();if(!t)return 0;t.collapse(true);let e=jo(t),n=Y(t),o=e??M(n);return ge(o,t.startContainer,t.startOffset)}function ge(t,e,n){if(!t)return 0;if(e===t){if(e.nodeType===Node.TEXT_NODE)return n;let i=0,a=t.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].textContent.length;return i}if(e.nodeType===Node.ELEMENT_NODE&&!t.contains(e))return 0;let o=0,r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),s=r.nextNode();for(;s;){if(s===e)return o+n;o+=s.textContent.length,s=r.nextNode();}return o}function Kn(t=W()){if(!t||t.collapsed)return null;let e=$n(t.startContainer),n=$n(t.endContainer);if(!e||!n)return null;let o=jn(t.startContainer)??M(e),r=jn(t.endContainer)??M(n);return {startBlock:e,endBlock:n,startOffset:ge(o,t.startContainer,t.startOffset),endOffset:ge(r,t.endContainer,t.endOffset)}}function Ot(t,e){let n=document.createRange();if(!t)return n;if(e<=0)return n.setStart(t,0),n.collapse(true),n;let o=0,r=[t];for(;r.length>0;){let s=r.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(o+i>=e)return n.setEnd(s,e-o),n.setStart(s,e-o),n;o+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)r.push(s.childNodes[i]);}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function ee(t,e){let n=Ot(t,e),o=Pt();o.removeAllRanges(),o.addRange(n);}function M(t){if(!t)return null;let e=Ve(t);return e?.firstElementChild??e?.firstChild}function P(t){if(!t?.[Ae])return null;let e=M(t);return e?re(e)?.classInstance:null}function Ve(t){if(!t)return null;for(let e of t.children)if(e[$o])return e;return null}function Ye(t,e,n,o=12){let r=t.getBoundingClientRect(),s=typeof e?.getBoundingClientRect=="function"?e.getBoundingClientRect():e??{left:0,top:0},i=n?.offsetHeight??40;return {x:s.left-r.left,y:s.top-r.top-i-o}}function Fn(t,e){let n=t.getBoundingClientRect(),o=e?.offsetWidth??420,r=e?.offsetHeight??320,s=16;return {x:Math.max(s,(n.width-o)/2),y:Math.max(s,(n.height-r)/2)}}var We=Et();var Xe=class extends Ue{state;element;mrakomor;constructor(e){super(e);let{state:n,observeDOMChanges:o=true}=e??{};this.state=n,this.element=null,this.mrakomor=bt(We),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=o;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return p.object({component:p.string().default(this.NAMESPACE),properties:p.object().default({}),settings:p.object().default({})}).default({})}static getPropsSchema(){return p.object({state:this.getStateSchema(),observeDOMChanges:p.boolean().default(true)}).default({})}parseFromHTML(e){return this.constructor.getStateSchema(e).parse()}getState(){if(this._stale){let e=this.element;return this.parseFromHTML(e)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=e=>{let n=e.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(m.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};function te(t){return t===`
1
+ 'use strict';(function(){if(!(typeof document>"u")){var t="mrakomor/core/style/core.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.mrakomor-editor:focus-visible{outline:none}.mrakomor-editor{display:flex;flex-direction:column;height:100%;min-height:0}.mrakomor-editor-surface{position:relative;flex:1 1 auto;min-height:0}.mrakomor-tools-container{position:absolute;inset:0;pointer-events:none;z-index:4}.mrakomor-content{position:relative;height:100%;min-height:0;overflow-y:auto}.mrakomor-content:focus-visible{outline:none}
2
+ `,document.head.appendChild(n);}}})();var zt=class{next(...t){}error(...t){}complete(...t){}},be=class{#e=new Set;pipe(...t){return t.reduce((e,n)=>n(e),this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t);});}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e);});}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e);});}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#e.delete(t);}};var Be=Symbol("@esmj/signals:type"),Se=Symbol("@esmj/signals:name");var L=null,lt=false,ut=[];function H(t){let e=L;L=null;let n=t();return L=e,n}function po(){lt=false;let t=Vt();for(let n of t)n.get();let e=ut;ut=[];for(let n of e)n();}function Gt(){lt||(lt=true,queueMicrotask(po));}function ft(t){ut.push(t),Gt();}var qt=Symbol("@esmj/signals:internal observable"),K=Symbol("@esmj/signals:original function"),go=class extends be{#e=new Set;#n=null;constructor(t){super(),this.#n=t,this.pipe(e=>{let n=e.subscribe.bind(e),o=e.unsubscribe.bind(e);return e.subscribe=r=>{n(r),this.#e.add(r);},e.unsubscribe=r=>{o(r),this.#e.delete(r);},e});}watch(t){if(typeof t.next!="function"&&(t.next=()=>H(()=>{this.#e.add(t),this.#n();}),t.next[K]=void 0),t instanceof Jt&&t.next[K]===void 0){let e=t.next.bind(t);t.next=()=>H(()=>{this.#e.add(t),e(),this.#n();}),t.next[K]=e;}return this.subscribe(t)}getPending(){let t=[];for(let e of this.#e){if(!e.get[K]){let n=e.get,o=n.bind(e);e.get=()=>H(()=>(this.#e.delete(e),o())),e.get[K]=n;}t.push(e);}return t}unwatch(t){return t.next=t.next[K]?t.next[K]:t.next,t.get=t.get[K]?t.get[K]:t.get,this.#e.delete(t),this.unsubscribe(t)}},Me=null;function Yt(t){Me=new go(t);}Yt(()=>{Gt();});function Vt(){return Me.getPending()}function Wt(t){return Me.watch(t)}function Xt(t){return Me.unwatch(t)}var F=Symbol("@esmj/signals:no error"),Jt=class Qt extends zt{#e=true;#n=false;#r=null;#t=this.#f();#o=null;#i=null;#c=0;#a=new Map;#s=F;constructor(e,n){super(),this.#o=e,this.#i=n,this.debug=n?.debug,this[Be]="computed",this[Se]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:e}of this.#t.dependencies.values())e();this.#t.dependencies.clear();}#f(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#c}getDebugInfo(){return {name:this[Se],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#a.keys()]}}#l(){for(let[e,n]of this.#a)if(e instanceof Qt&&H(()=>e.get()),e.getRevision()!==n)return true;return false}next(){this.#e=true,this.#r[qt].next();}get(){if(this.#n)throw new Error("Cycle detected in computed signal");if(this.#r||(this.#r=S(this.#m(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#l()?this.#m():this.#e=false),L&&L.sourceRevisions.set(this,this.#c),this.#s!==F)throw this.#s;return this.#r.get()}peek(){if(this.#r||(this.#r=S(this.#m(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#l()?this.#m():this.#e=false),this.#s!==F)throw this.#s;return this.#r.peek()}#m(){this.#n=true,this.#e=false,this.#s=F,this.#u(),this.#t.sourceRevisions.clear();let e=L;L=this.#t;let n;try{n=this.#o();}catch(o){this.#s=o;}return L=e,this.#a=this.#t.sourceRevisions,this.#t.sourceRevisions=new Map,this.#n=false,n instanceof Promise&&(n=n.then(o=>{this.#s=F,this.#r.set(o);}).catch(o=>{this.#s=o;})),this.#s===F&&this.#r&&this.#r.set(n),this.#c++,n}destroy(){this.#u(),this.#a.clear(),this.#e=true,this.#s=F;}};function M(t,e){return new Jt(t,e)}function P(t,e){let n,{debug:o,...r}={},s=M(()=>{n?.(),n=t();},{equals:()=>false,...r});s.get(),Wt(s);let i=()=>{n?.(),s.destroy(),Xt(s);};return i[Symbol.dispose]=i,i[Be]="effect",i[Se]=o??null,i.__RX_COMPUTED__=s,i}function S(t,e={}){let n=e?.equals??Object.is,o=0,r=new be;function s(){return L&&(L.dependencies.set(r,r.subscribe(L.observer)),L.sourceRevisions.set(l,o)),t}function i(){return t}function a(u){if(!n(t,u)){t=u,o++,r.next();}return t}function c(){return o}let l={get:s,set:a,peek:i,getRevision:c,[qt]:r,[Be]:"signal",[Se]:e?.debug??null};return l}function we(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var cn=Symbol("node-component"),Le=Symbol("node-internal"),ho=Symbol("keep-literal"),Pe=Symbol("raw-props");function dt(t){return typeof t=="function"?t:t!=null&&typeof t.get=="function"?()=>t.get():()=>t}function gt(t,e){let n=t.children!==void 0?t.children:e;return Array.isArray(n)?n[0]:n}var Eo=new Set(["template","script"]);function yo(t,e){let n=(t==null?"span":String(t)).trim(),o=n;Eo.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${t}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),o="span");let r=document.createElement(o);return o==="span"&&(r.style.display="contents"),r.setAttribute(e,we()),r}function ht(t,e,n){let o=yo(t,e);return n?.id&&o.setAttribute("id",n.id),o}function W(t){let e=null,n=()=>e,o=s=>(e=s??null,typeof t=="function"&&t(e),e),r={get:n,set:o,[Symbol.toPrimitive](){return e?String(e):""}};return Object.defineProperty(r,"current",{get(){return e},set(s){o(s);},enumerable:true,configurable:false}),new Proxy(r,{get(s,i,a){if(Reflect.has(s,i))return Reflect.get(s,i,a);if(!e)return;let c=e[i];return typeof c=="function"?c.bind(e):c},set(s,i,a,c){return Reflect.has(s,i)||!e?Reflect.set(s,i,a,c):(e[i]=a,true)},has(s,i){return Reflect.has(s,i)||!!e&&i in e}})}var ln=null;function $(){return ln}function Te(t){ln=t;}function se(t){return t?.[cn]||null}function Zt(t,e){t[cn]=e;}function Oe(t,e={disposers:[],id:we()}){return t?.[Le]?t[Le]:(t&&(t[Le]=e),e)}function xo(t){return t[Le]}function z(t,e){let n=xo(t);n||(n=Oe(t)),n.disposers.push(e);}function _e(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n);}function V(t,e){let n=$();Te(t);try{return e()}finally{Te(n);}}var De=new Map,Ne=new Map,en=new Map;function un(t,e){let n=typeof e=="function"?e:r=>!!e?.includes(r),o=Object.create(null);for(let r of Object.keys(t)){let s=t[r];r==="children"||n(r)?o[r]=s:s?.[ho]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=M(s):o[r]=S(s);}return o}function ie(t,e){if(t===e)return true;if(t==null||e==null||typeof t!="object"||typeof e!="object")return false;let n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?false:n.every(r=>{let s=Object.getOwnPropertyDescriptor(t,r),i=Object.getOwnPropertyDescriptor(e,r);if(!s||!i)return false;let a="value"in s?s.value:s.get?.call(t),c="value"in i?i.value:i.get?.call(e);return ie(a,c)})}function Et(t){return {id:Symbol("context-id"),defaultValue:t}}function yt(t,e){let n=$();n&&n.contexts.set(t.id,e);}function xt(t){let e=$();return e?.contexts?.has(t.id)?e.contexts.get(t.id):t.defaultValue}function $e(t){let e=$();if(!e){console.warn("onMount called outside of a component context");return}_e(De,e.id,t);}function je(t){let e=$();if(!e){console.warn("onUnmount called outside of a component context");return}_e(Ne,e.id,t);}function A(t){ft(()=>{setTimeout(t,0);});}function ae(t){let e=t.componentId,n=De.get(e);if(n){De.delete(e);for(let o of n){let r=o();typeof r=="function"&&_e(Ne,e,r);}}}function bo(t){let e=Ne.get(t);if(e){Ne.delete(t);for(let n of e)n();}}function So(t){let e=en.get(t);if(e){en.delete(t);for(let n of e)n();}}function Re(t){if(!t)return;let e=Oe(t);if(e?.disposers?.length){for(let o of e.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}e.disposers=[];}let n=se(t);if(n&&(bo(n.componentId),So(n.componentId)),t.childNodes){let o=t.firstChild;for(;o;){let r=o.nextSibling;Re(o),o=r;}}}function X(t){return t!=null&&typeof t=="object"&&typeof t.$constructor=="function"}function tn(t){return typeof t=="function"&&typeof t.prototype?.render=="function"}function Co(t,e,n){let o=we(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=tn(t)?void 0:t[Pe],i={...un(e??{},s),children:n},a=$(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};Te(c);let l;if(tn(t)){r.ClassConstructor=t;let f=new t(i);r.classInstance=f,typeof f.onMount=="function"&&_e(De,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&_e(Ne,o,()=>{f.onUnmount?.();}),l=f.render();}else l=t(i);Te(a);let u=ko(l);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)Oe(f,c),Zt(f,r);else Oe(u,c),u instanceof Node&&Zt(u,r);return u}};return r}function bt(t,e){let n=e.$constructor();n instanceof Node&&t.appendChild(n),queueMicrotask(()=>{ae(e);});}function ko(t){return t instanceof Node?t:X(t)?t.$constructor():typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):document.createTextNode("")}var nn={className:"class",htmlFor:"for"},on=new Set(["value","defaultValue","checked","selected","indeterminate"]),_o=new Set(["srcdoc"]),No=new Set(["href","src","action","formaction","xlink:href"]),Ro=new Set(["securitypolicyviolation"]),Ao=new Set(["contenteditable","draggable","spellcheck"]);function ke(t){return t!=null&&typeof t=="object"&&typeof t.get=="function"&&!(t instanceof Node)}var fn=Symbol("Fragment");function E(t,e,n){if(t===fn){let r=document.createDocumentFragment();return pt(r,sn(n)),r}if(typeof t=="function")return Co(t,e||{},n);typeof t!="string"&&(n=e,e=t,t="div"),e=e||{};let o=document.createElement(t);return e.id&&o.setAttribute("id",e.id),Ue(o,e),pt(o,sn(n)),o}function mt(t,e){e instanceof DocumentFragment?t.replaceChildren(e):t.innerHTML=e??"";}function Io(t){return typeof t!="string"?false:t.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function vo(t,e){if(typeof t!="string")return false;let n=t.toLowerCase();return _o.has(n)?true:No.has(n)&&e!==null&&e!==void 0&&Io(String(e))}function mn(t){return typeof t!="string"?t:nn[t]?nn[t]:t}function Bo(t,e){let n=mn(t),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Ao.has(o)&&(e===true||e===false||e==="true"||e==="false")?String(e):e==null||e===false?null:e}function rn(t,e,n){let o=Bo(e,n);if(o===null){t.removeAttribute(e);return}if(vo(e,o)){t.removeAttribute(e),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(e)}" on <${t.tagName.toLowerCase()}>`);return}t.setAttribute(e,o);}function Ue(t,e){let n=$();for(let[o,r]of Reflect.ownKeys(e).map(s=>[s,e[s]]))if(o!=="id"){if(o=mn(o),o==="$ref"){typeof r=="function"?r(t):typeof r=="object"&&r!==null&&(r.current=t);continue}if(o==="$dangerouslySetInnerHTML"){if(ke(r)){let s=P(()=>{V(n,()=>{mt(t,r.get());});});z(t,s);}else if(typeof r=="function"){let s=P(()=>{V(n,()=>{mt(t,r());});});z(t,s);}else mt(t,r);continue}if(o==="style"){if(ke(r)){let s=P(()=>{V(n,()=>{Object.assign(t.style,r.get());});});z(t,s);}else typeof r=="object"&&r!==null?Object.assign(t.style,r):t.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(Ro.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${t.tagName.toLowerCase()}>`);continue}t.addEventListener(s,r);continue}if(ke(r)||typeof r=="function"){let s=o,i=P(()=>{V(n,()=>{let a=typeof r=="function"?r():r.get();on.has(s)?t[s]=a??"":rn(t,s,a);});});z(t,i);continue}on.has(o)||typeof o=="symbol"?t[o]=r??"":rn(t,o,r);}}function sn(t){return t==null?[]:Array.isArray(t)?t.flat(Number.POSITIVE_INFINITY):[t]}function pt(t,e){for(let n of e)pn(t,n);}function pn(t,e){if(!(e==null||e===false||e===true)){if(e instanceof Node){t.appendChild(e);return}if(typeof e=="string"||typeof e=="number"){t.appendChild(document.createTextNode(String(e)));return}if(typeof e=="function"){an(t,e);return}if(X(e)){bt(t,e);return}if(ke(e)){an(t,()=>e.get());return}if(Array.isArray(e)){pt(t,e);return}t.appendChild(document.createTextNode(String(e)));}}function ce(t){let e=null,n=t;return X(t)&&(e=t,n=t.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:e}:n instanceof Node?{nodes:[n],instance:e}:n==null||n===false||n===true?{nodes:[],instance:e}:{nodes:[document.createTextNode(String(n))],instance:e}}function Ke(t,e=true){for(let n of t)e&&Re(n),n.remove();}function an(t,e){let n=$(),o=document.createComment("");t.appendChild(o);let r=[],s=P(()=>{V(n,()=>{let i=e(),{nodes:a,instance:c}=ce(i);Ke(r),a.length&&o.after(...a),c&&queueMicrotask(()=>ae(c)),r=a;});});z(t,s);}var Fe=class{constructor(t){this.props=t;}};function dn(t,e,n,o){let{equals:r=ie,tagName:s="span",...i}=o??{},a=ht(s,"data-for",i);Ue(a,i);let c=$(),l=[],u=new Map,f=M(()=>t()),p=P(()=>{let h=f.get(),b=Array.isArray(h)?h:[],R=[],N=[],g=new Set;for(let x=0;x<b.length;x++){let _=b[x],v=e(_,x);if(g.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${x}`);continue}g.add(v),R.push(_),N.push(v);}let y=new Map(l.map(x=>[x.key,x])),k=[];for(let x=0;x<R.length;x++){let _=N[x],v=R[x],U=y.get(_);if(U)u.get(_).set(v),k.push(U),y.delete(_);else {let xe=S(v,{equals:r});u.set(_,xe);let ct={...xe,set(){}},Z={key:_,nodes:[]};V(c,()=>{let lo=n(ct,x),{nodes:uo,instance:Ht}=ce(lo);Z.nodes=uo,Ht&&queueMicrotask(()=>ae(Ht));}),k.push(Z);}}for(let[x,_]of y)Ke(_.nodes),u.delete(x);let C=null;for(let x=k.length-1;x>=0;x--){let _=k[x].nodes;for(let v=_.length-1;v>=0;v--){let U=_[v];(U.parentNode!==a||U.nextSibling!==C)&&a.insertBefore(U,C),C=U;}}l=k;});return z(a,p),a}function St(t,e,n,o){if(typeof t=="function")return dn(t,e,n,o);let{each:r,keyFn:s,equals:i,tagName:a,children:c,...l}=t??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=dt(r),f=gt(t??{},e);return dn(u,s,f,{...l,equals:i,tagName:a})}St[Pe]=t=>t!=="each";function ee(t,e){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("mount: container not found");t instanceof DocumentFragment||(Re(t),t.innerHTML=""),X(e)?bt(t,e):e instanceof Node?t.appendChild(e):t.appendChild(document.createTextNode(String(e)));}function hn(t){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("unmount: container not found");Re(t),t.innerHTML="";}function Ae(t,e){let n=null;if(X(e)?(n=e.$constructor(),queueMicrotask(()=>ae(e))):e instanceof Node?n=e:n=document.createTextNode(String(e)),n instanceof HTMLElement){let o=M(()=>!!t()),r=P(()=>{n.style.display=o.get()?"":"none";});z(n,r);}return n}var T=class extends Fe{static get nodeName(){return "span"}static get style(){return "SPAN"}static match(e){return e.nodeName===this.nodeName.toUpperCase()||e.style===this.style}getState(){return {style:this.constructor.style}}render(){return E(this.constructor.nodeName,{},this.props.children)}};var le=class extends T{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return E("b",{},"B")}static match(e){return e.nodeName==="strong"?true:super.match(e)}};var ue=class extends T{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return E("i",{},"I")}};var fe=class extends T{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return E("sub",{},"Sub")}};var me=class extends T{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return E("sup",{},"Sup")}};var pe=class extends T{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return E("u",{},"U")}};var j=Symbol("result-key"),He=Symbol("stopped-event");function En(t,e){let n=!!e.name,o=e[j]||"result",r=o.includes("."),s={error:null,context:{},[j]:o,...e,[o]:n?void 0:te(e,o),name:t,[He]:false,defaultPrevented:false};return r&&(wo(s,o),s[o]=n?void 0:te(e,o)),s.stopPropagation=()=>{s[He]=true;},s.preventDefault=()=>{s.defaultPrevented=true;},s}function te(t,e){return e===""?t:e.split(".").reduce((o,r)=>o?.[r]??void 0,t)}function Ct(t,e,n){let o=e.split("."),r=o.pop(),s=te(t,o.join("."));return s[r]=n}function wo(t,e){let n=e.split(".");n.pop(),n.reduce((o,r)=>o[r]=o[r]??{},t);}var ze=class{constructor({logger:e,debug:n}={}){this._logger=e??console,this._debug=n??false,this._events=new Map,this.addListener=this.on,this.removeListener=this.off;}emit(e,n={}){let o=this.listeners(e),r=En(e,n),s=null,i=null;this._debug&&(typeof this._debug=="function"?this._debug(e,r):this._logger.debug(`Event name: ${e}, event: ${r}`));for(let a of o){if(s&&(s=s.then(c=>(Ct(r,r[j],c??te(r,r[j])),r[He]?te(r,r[j]):a(r)))),!s){if(r[He])return r;i=a(r);}i instanceof Promise&&!s?s=i:Ct(r,r[j],i??te(r,r[j]));}return s?s.then(a=>(Ct(r,r[j],a??te(r,r[j])),r)):r}emitParallel(e,n={}){let o=this.listeners(e),r=En(e,n);return Promise.all(o.map(async s=>await s(r))).then(s=>(r[r[j]]=s,r)).catch(s=>{throw r.error=s,s})}listeners(e){return this._events.has(e)?[...this._events.get(e)]:[]}removeAllListeners(e){return e?this.listeners(e).forEach(n=>this.off(e,n)):Array.from(this._events.keys()).forEach(n=>this.removeAllListeners(n))}_addListener(e,n,o){return this._events.has(e)||this._events.set(e,[]),this._events.get(e)[o](n),()=>{this.off(e,n);}}on(e,n){if(typeof n!="function")throw new TypeError("The listener must be a function");return this._addListener(e,n,"push")}prependListener(e,n){return this._addListener(e,n,"unshift")}_addListenerOnce(e,n,o){let r=this[o](e,s=>(r(),n(s)));}once(e,n){return this._addListenerOnce(e,n,"on")}prependOnceListener(e,n){return this._addListenerOnce(e,n,"prependListener")}off(e,n){if(this._events.has(e)){let o=this._events.get(e),r=o.indexOf(n);o.splice(r,1);}}};var m={INSERT_BLOCK_ELEMENT:"mrakomor:insert-block-component",REPLACE_BLOCK_ELEMENT:"mrakomor:replace-block-component",REMOVE_BLOCK_ELEMENT:"mrakomor:remove-block-component",MERGE_BLOCK_ELEMENT:"mrakomor:merge-block-component",INSERT_ENTITY_RANGE:"mrakomor:insert-entity-range",REMOVE_ENTITY_RANGE:"mrakomor:remove-entity-range",INSERT_INLINE_STYLE_RANGE:"mrakomor:insert-inline-style-range",KEYDOWN:"mrakomor:keydown",BEFORE_INPUT:"mrakomor:beforeinput",INPUT:"mrakomor:input",CLICK:"mrakomor:click",FOCUSIN:"mrakomor:focusin",FOCUSOUT:"mrakomor:focusout",SELECTION_CHANGE:"mrakomor:selection-change",CONTENT_CHANGE:"mrakomor:content-change",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element",MOVE_BLOCK_ELEMENT:"mrakomor:move-block-element"};function w(t){return e=>{if(!e.defaultPrevented)return t(e)}}function yn({mrakomor:t}={}){let e=t?.emitter??new ze;function n(o,r={}){return typeof t?.emit=="function"?t.emit(o,r):e.emit(o,{...r,mrakomor:t})}return {emitter:e,command:{insertBlockElement(o,r){n(m.INSERT_BLOCK_ELEMENT,{...o,options:r});},replaceBlockElement(o,r){n(m.REPLACE_BLOCK_ELEMENT,{...o,options:r});},removeBlockElement(o,r){n(m.REMOVE_BLOCK_ELEMENT,{...o,options:r});},mergeBlockElement(o,r){n(m.MERGE_BLOCK_ELEMENT,{...o,options:r});},insertEntityRange(o,r){n(m.INSERT_ENTITY_RANGE,{...o,options:r});},removeEntityRange(o,r){n(m.REMOVE_ENTITY_RANGE,{...o,options:r});},insertInlineStyleRange(o,r){n(m.INSERT_INLINE_STYLE_RANGE,{...o,options:r});},transformBlockElement(o,r){n(m.TRANSFORM_BLOCK_ELEMENT,{...o,options:r});},moveBlockElement(o,r){n(m.MOVE_BLOCK_ELEMENT,{...o,options:r});}}}}function xn(t){return t.map((e,n)=>({entry:e,index:n})).sort((e,n)=>{let o=e.entry.order??e.index,r=n.entry.order??n.index;return o!==r?o-r:e.index-n.index}).map(({entry:e})=>e)}var de=class extends be{mrakomor;#e=new Map;#n=null;#r=0;#t;constructor(e,n={}){super(),this.mrakomor=e,this.#t=n.sort??xn;}normalize(e,n){throw new Error("Register subclass must implement normalize")}#o(){this.#n=null,this.next(this.list());}#i(e,n=this.#r++){let o=this.normalize(e,n);return o?(this.#e.set(o.id,o),o):null}add(e){if(Array.isArray(e)){let o=[];for(let r of e){let s=this.#i(r,this.#r++);s&&o.push(s);}return o.length&&this.#o(),o}let n=this.#i(e);return n&&this.#o(),n}get(e){return this.#e.get(e)}has(e){return this.#e.has(e)}remove(e){let n=this.#e.delete(e);return n&&this.#o(),n}list(){return this.#n??=this.#t([...this.#e.values()]),this.#n}};var Lo={abortEarly:true};function At(t,e){if(e===void 0)return t;let n=t?.cause?.key?`${e}.${t.cause.key}`:`${e}`;return {message:`Error parsing key "${n}": ${t.message}`,cause:{key:n}}}function To(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(At(t.errors[o],n));}function Cn(t,e,n,o){if(n!==false){let r=At(t.error,e);return {success:false,error:r,errors:[r]}}To(t,o,e);}function Ge(t){return t?.abortEarly!==void 0?t:Lo}function kt(t,e){B(t,"_parse",(n,o,r)=>{let s=n(o,r);return !s.success&&e(o)?{success:true,data:o}:s});}var Ie=t=>typeof t=="string"||t instanceof String,_t=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),Nt=t=>t===true||t===false,Oo=t=>t instanceof Date&&!Number.isNaN(t.getTime()),Do=t=>typeof t=="function",Po=t=>Array.isArray(t),Rt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function kn(t,e){let n=O(Rt,{...e,type:"object"});n._getDescription=()=>`object({ ${Object.entries(t).map(([r,s])=>`${r}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>t;let o=n;return o.derive=function(r,{when:s="always"}={}){return B(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=r(l.data,{context:c?.context});if(!Rt(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(s==="missing"){let f={...l.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},B(n,"_parse",(r,s,i)=>{let a=r(s,i),{abortEarly:c}=Ge(i);if(a.success===false)return a;let l={},u=[];for(let f in t){let p=t[f]._parse(a.data[f],i);if(p.success)l[f]=p.data;else {let h=Cn(p,f,c,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),o}function It(t){return O(Ie,{...t,type:"string"})}function vt(t){return O(_t,{...t,type:"number"})}function Bt(t){return O(Nt,{...t,type:"boolean"})}function Mt(t){return O(Oo,{...t,type:"date"})}function _n(t){return O(Do,{...t,type:"function"})}function Nn(t,e){let n=i=>t.includes(i),o=i=>`Invalid ${r} value. Expected ${t.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,r="enum",s=O(n,{message:o,...e,type:r});return s._getDescription=()=>`enum(${t.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>t,s}function Rn(t,e){let n=O(Po,{...e,type:"array"});return n._getDescription=()=>`array(${t._getDescription()})`,n._getDefinition=()=>t,B(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:a}=Ge(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},h=t._parse(i.data[f],p);if(h.success)c.push(h.data);else {let b=Cn(h,f,a,l);if(b)return b}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function An(){return O(()=>true)}function ge(t,e){return B(e,"_parse",(n,o,r)=>(o=t(o),n(o,r))),e}function In(t,e){let n=r=>`Invalid union value. Expected the value to match one of the schemas:${t.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof r}" with value: ${Rt(r)?JSON.stringify(r):`"${r}"`}`,o=O(()=>false,{message:n,...e,type:"union"});return o._getDefinition=()=>t,B(o,"_parse",(r,s,i)=>{let a=i,c=[];for(let p=0;p<t.length;p++){let h=t[p]._parse(s,a);if(h.success)return h;c.push(h);}let{abortEarly:l}=Ge(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<c.length;p++){let h=c[p].errors;if(h?.length)for(let b=0;b<h.length;b++)h[b].cause?.key&&f.push(At(h[b],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),o}function vn(t,e){let n=O(o=>o===t,{message:o=>e?.message?typeof e.message=="function"?e.message(o):e.message:`Expected literal value "${t}", received "${o}"`,name:e?.name,type:"literal"});return n._getDescription=()=>`literal("${t}")`,n._getDefinition=()=>t,n}function Bn(t){let e=O(()=>true,{type:"contextRef"});return e._getDescription=()=>`contextRef("${t}")`,B(e,"_parse",(n,o,r)=>({success:true,data:r?.context?.[t]})),e}function Mn(t,e){return {parse(n,o){let r=t.parse(o?.context??{},o);return e(r).parse(n,o)},safeParse(n,o){let r=t.safeParse(o?.context??{},o);return r.success?e(r.data).safeParse(n,o):r}}}var wn={boolean(t){let e=t?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return ge(n=>{let o;return Ie(n)&&(o=n.toLowerCase()),o==="true"||o==="yes"||o==="on"||o==="1"||n===1?true:o==="false"||o==="no"||o==="off"||o==="0"||n===0?false:n},Bt({...t,message:e}))},number(t){let e=t?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return ge(n=>{if(Nt(n))return Number(n);if(Ie(n)){let o=n.trim();if(o==="")return n;let r=Number(o);if(Number.isFinite(r))return r}return n},vt({...t,message:e}))},string(t){let e=t?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return ge(n=>Nt(n)||_t(n)&&Number.isFinite(n)?String(n):n,It({...t,message:e}))},date(t){let e=t?.message??(n=>`Cannot cast "${n}" to a valid date.`);return ge(n=>{let o;return Ie(n)&&(o=n.trim()),_t(n)&&Number.isFinite(n)||o?new Date(o??n):n},Mt({...t,message:e}))},json(t,e){let n=e?.message??(o=>`Cannot parse "${o}" as JSON.`);return B(t,"_parse",(o,r,s)=>{if(Ie(r))try{r=JSON.parse(r);}catch{let i={message:typeof n=="function"?n(r):n};return {success:false,error:i,errors:[i]}}return o(r,s)}),t}},Ln={},d={object:kn,string:It,number:vt,boolean:Bt,date:Mt,function:_n,enum:Nn,array:Rn,any:An,preprocess:ge,union:In,literal:vn,contextRef:Bn,withContext:Mn,coerce:Ln,cast:wn};function bn(t){return e=>`The value "${e}" must be type of ${t} but is type of "${typeof e}".`}function B(t,e,n){let o=t[e];t[e]=(...r)=>n(o,...r);}function O(t,{type:e="any",name:n,message:o}={}){o=o||bn(e);let r={name:n,message:o,type:e},s={_getName(){return n},_getType(){return e},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=t(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof o=="function"?o(i):o};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return B(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return kt(this,i=>i===void 0),this},nullable(){return kt(this,i=>i===null),this},nullish(){return kt(this,i=>i==null),this},default(i){return B(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return B(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return B(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||bn(c),e=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return B(this,"_parse",(u,f,p)=>{let h=u(f,p),{abortEarly:b}=Ge(p);if(!h.success)return h;let R=i(h.data);if(R===true||typeof R=="object"&&R?.success===true)return h;let N={message:typeof a=="function"?a(f):a};return {success:false,error:N,errors:[N]}}),this},clone(){return {...this}}};return Sn.length>0?Sn.reduce((i,a)=>a(i,t,r)??i,s):s}var Sn=[];var $o=d.object({component:d.function(),id:d.string(),label:d.string(),keywords:d.array(d.string()),group:d.string(),order:d.number().default(({context:t})=>t?.index??0),settings:d.any().optional()});function jo(t,e){let n=`block:${t}`;return e?.style==="UNORDERED"?`${n}:ul`:e?.style==="ORDERED"?`${n}:ol`:n}function Tn(t,e=0){let n=typeof t=="function",o=n?t:t?.component,r=n?{}:t,s=o.NAMESPACE??"",i=s.split(".").pop()||s,a=r.label||o.LABEL||i||s,c=Array.isArray(o.KEYWORDS)?o.KEYWORDS:[],l=r.keywords?.length?r.keywords.map(String):c.length?c.map(String):[a,i].filter(Boolean).map(String),u=r.settings;return $o.parse({component:o,id:r.id||jo(s,u),label:String(a),keywords:l,group:String(r.group||o.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...u?{settings:u}:{}},{context:{index:e}})}var qe=class t extends de{#e=null;constructor(e){super(e),this.subscribe(()=>{this.#e=null;});}normalize(e,n){if(e==null)return null;try{return Tn(e,n)}catch{return null}}getByNamespace(e){return this.#n().get(e)}#n(){return this.#e??=t.buildNamespaceMap(this.list()),this.#e}static buildNamespaceMap(e){let n=new Map;for(let o of e){let r=o.component?.NAMESPACE;r&&!n.has(r)&&n.set(r,o.component);}return n}};var wt="molecule.paragraph.Paragraph";var On="molecule.external.ExternalComponent",Dn="namespace.unknown.UnknownComponent";var Pn="molecule.headline.";var Lt=Dt(),Tt=Dt(),$n=Dt(),Uo=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function Dt(){return Math.floor(Math.random()*16777215)}function Ko(){return Tt=(Tt+1)%16777215,Tt}function J(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Ko(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Lt>>16&255,Lt>>8&255,Lt&255,$n>>8&255,$n&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=Uo[n.charCodeAt(r)];return o}var ve=Symbol("block-element"),Fo=Symbol("block-element-body"),he=Symbol("selectable-element");function Ye(t,e){let n=t;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[e]===void 0;)n=n.parentElement;return n??null}function G(t){return t?Ye(t.startContainer,ve):null}function jn(t){return Ye(t,ve)}function Kn(t){return t?Ye(t.startContainer,he):null}function Un(t){return Ye(t,he)}function Ho(t){return t?t[he]!==void 0?[t]:[...t.children].filter(e=>e[he]!==void 0):[]}function zo(t,e){return e?Ho(t).indexOf(e):-1}function Fn(t,e){let n=Kn(e);return !n||!t?.contains(n)?null:{element:n,index:zo(t,n)}}function Pt(){return window.getSelection()}function q(){let t=Pt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function $t(){let t=q();if(!t)return 0;t.collapse(true);let e=Kn(t),n=G(t),o=e??I(n);return Ee(o,t.startContainer,t.startOffset)}function Ee(t,e,n){if(!t)return 0;if(e===t){if(e.nodeType===Node.TEXT_NODE)return n;let i=0,a=t.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].textContent.length;return i}if(e.nodeType===Node.ELEMENT_NODE&&!t.contains(e))return 0;let o=0,r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),s=r.nextNode();for(;s;){if(s===e)return o+n;o+=s.textContent.length,s=r.nextNode();}return o}function zn(t=q()){if(!t||t.collapsed)return null;let e=jn(t.startContainer),n=jn(t.endContainer);if(!e||!n)return null;let o=Un(t.startContainer)??I(e),r=Un(t.endContainer)??I(n);return {startBlock:e,endBlock:n,startOffset:Ee(o,t.startContainer,t.startOffset),endOffset:Ee(r,t.endContainer,t.endOffset)}}function Ot(t,e){let n=document.createRange();if(!t)return n;if(e<=0)return n.setStart(t,0),n.collapse(true),n;let o=0,r=[t];for(;r.length>0;){let s=r.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(o+i>=e)return n.setEnd(s,e-o),n.setStart(s,e-o),n;o+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)r.push(s.childNodes[i]);}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function Y(t,e){let n=Ot(t,e),o=Pt();o.removeAllRanges(),o.addRange(n);}function I(t){if(!t)return null;let e=Ve(t);return e?.firstElementChild??e?.firstChild}function D(t){if(!t?.[ve])return null;let e=I(t);return e?se(e)?.classInstance:null}function Ve(t){if(!t)return null;for(let e of t.children)if(e[Fo])return e;return null}function We(t,e,n,o=12){let r=t.getBoundingClientRect(),s=typeof e?.getBoundingClientRect=="function"?e.getBoundingClientRect():e??{left:0,top:0},i=n?.offsetHeight??40;return {x:s.left-r.left,y:s.top-r.top-i-o}}function Gn(t,e){let n=t.getBoundingClientRect(),o=e?.offsetWidth??420,r=e?.offsetHeight??320,s=16;return {x:Math.max(s,(n.width-o)/2),y:Math.max(s,(n.height-r)/2)}}var Xe=Et();var Je=class extends Fe{state;element;mrakomor;constructor(e){super(e);let{state:n,observeDOMChanges:o=true}=e??{};this.state=n,this.element=null,this.mrakomor=xt(Xe),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=o;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(e){return this.constructor.getStateSchema(e).parse()}getState(){if(this._stale){let e=this.element;return this.parseFromHTML(e)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=e=>{let n=e.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(m.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};function Q(t){return t===`
3
3
  `||t===`\r
4
- `?"":t??""}function Re({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{};return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{...r,text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]},...o?{settings:o}:{}}}function Je(t){let e=t?.component??"";return e===wt||e.startsWith(Dn)}function jt(t,e){let n=te(t.properties.text),o=te(e.properties.text);return {state:{...t,properties:{...e.properties,...t.properties,text:n+o,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(r=>({...r,offset:r.offset+n.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(r=>({...r,offset:r.offset+n.length}))]},settings:{...e.settings,...t.settings}},cursor:n.length}}function zn(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],a=s[n],{originalLineState:c}=Gn(i,o),{newLineState:l}=Gn(a,r),{state:u,cursor:f}=jt(c,l);return s.splice(e,n-e+1,u),{content:s,cursor:f,resultIndex:e}}function Hn(t,e){return (t??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)}))}function qn(t,e){return (t??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)}))}function Gn(t,e){let n=structuredClone(t),o=structuredClone(t);return n.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),n.properties.inlineStyleRanges=Hn(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=qn(t.properties.inlineStyleRanges,e),n.properties.entityRanges=Hn(t.properties.entityRanges,e),o.properties.entityRanges=qn(t.properties.entityRanges,e),o.componentId=V(),{originalLineState:n,newLineState:o}}function Vn(t,e){if(e.key!=="Enter")return false;e.preventDefault();let n=wt,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:W(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:n}),true}function Yn(t,e){let n=ge(t,e.startContainer,e.startOffset),o=ge(t,e.endContainer,e.endOffset);return {offset:n,length:Math.max(0,o-n)}}function Fo(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(a=>a.style===e&&a.offset<=n&&a.offset+a.length>=s);return i?r.filter(a=>a!==i):[...r,{style:e,offset:n,length:o}]}function Ho(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function qo(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!Ho(r,e)){o.push(r);continue}r.offset<e.offset&&o.push({...r,length:e.offset-r.offset});let s=r.offset+r.length;s>n&&o.push({...r,offset:n,length:s-n});}return o}function Go(t,e){let n=t??[],o=e?.length??0;if(o===0)return null;let r=e.offset??0,s=e.entity?.type,i=n.find(a=>a.offset===r&&a.length===o&&a.entity?.type===s);return i?n.filter(a=>a!==i):[...qo(n,e),e]}function Wn(t,e,{style:n,range:o}){if(!t||!e?.element||!o)return null;let r=e.read(t);if(r?.inlineStyleRanges===void 0)return null;let{offset:s,length:i}=Yn(e.element,o);return i===0?null:(e.write(t,{inlineStyleRanges:Fo(r.inlineStyleRanges??[],{style:n,offset:s,length:i})}),t)}function Xn(t,e,{state:n,namespace:o,range:r}){if(!t||!e?.element||!r)return null;let s=e.read(t);if(s?.entityRanges===void 0)return null;let i={...n,entity:{type:o,...n?.entity},...Yn(e.element,r)},a=Go(s.entityRanges??[],i);return a===null?null:(e.write(t,{entityRanges:a}),t)}var Qe=class extends Xe{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(e){let n=()=>{if(!this.element?.isConnected)return;let o=typeof e=="number"?e:te(this.getState()?.properties?.text).length;ee(this.element,o);};n(),R(n);}onKeydown(e){}getFormattingTarget(e){return null}static toExchangeState(e){return Re({originComponent:this.NAMESPACE,properties:{...e?.properties,text:te(e?.properties?.text)},settings:e?.settings})}static fromExchangeState(e){return {properties:e?.properties,settings:e?.settings}}static appendExchangeState(e,n){return jt(e,n)}};var ne=class t extends Qe{static get NAMESPACE(){return Tn}static getStateSchema(e){return p.object({component:p.string().default(t.NAMESPACE),componentId:p.string().default(e?.getAttribute("data-componentid")||V()),properties:p.object({}).default({}),settings:p.object({}).default({})}).default({})}constructor(e){super(e),this.root=null;}getState(){return this.state.peek()}isAtomic(){return true}static appendExchangeState(){return null}onMount(){}onUnmount(){}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E("div",{className:e,contentEditable:false,style:"position: relative;",$ref:o=>{this.element=o;},"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[E("div",{$ref:o=>{this.root=o;},style:"display: block;",contentEditable:false}),E("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:true,[Ge]:true},document.createTextNode("\xA0"))])}onKeydown(e){e.key!=="Backspace"&&e.key!=="ArrowUp"&&e.key!=="ArrowDown"&&e.preventDefault(),Vn(this,e);}};var he=class extends ne{static get NAMESPACE(){return On}onMount(){let e=E("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);J(this.root,e);}onUnmount(){this.root.innerHTML="";}};function zo(t,e){let n=t._getBlockElementByComponentId(e);return P(n)?.isStale?.()??false}function Jn(t){return (e,n)=>{if(!se(e,n))return false;let o=n?.componentId??e?.componentId;return !(o&&zo(t,o))}}function Qn({mrakomor:t}){let e=t.get(),n=Jn(e);return yt(We,e),De(()=>{e._onMount();}),Pe(()=>{e._onUnmount();}),E("div",{id:e._id,className:"mrakomor-editor"},[E("div",{className:"mrakomor-editor-surface"},[E("div",{className:"mrakomor-tools-container"}),E("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"}},[St(()=>e._getContentState(),o=>o.componentId,(o,r)=>E(()=>{let s;De(()=>{s.getNodeComponent=()=>{let c=M(s);return c?re(c):null},e._setBlockElement(s,r);}),Pe(()=>{e._removeBlockElement(s);});let i=e.resolveComponent(o.get().component,o),a=e.wrapBlockElement(i);return E("div",{className:"mrakomor-block-element",[Ae]:true,$ref:c=>{s=c;}},a)}),{equals:n})])])])}function Ze(t,e,n){let o=t._getBlockElementIndex(e);if(o===-1)return false;let r=t.getContent();return r.splice(o,1,t.normalizeComponentState(n)),t._setContentState(r),true}function Zn(t,{customHook:e,applyFn:n,applyArgs:o,resolveRange:r=true}){let{mrakomor:s}=t,{blockElement:i,range:a}=t;r&&(a=a??W(),i=i??Y(a));let c=P(i),l=c?.[e]?.(t);if(t.defaultPrevented){l&&Ze(s,i,l);return}let u=c?.getFormattingTarget?.(a);if(!u)return;let f=s._getBlockElementState(i);if(!f)return;let d=n(structuredClone(f),u,{...o,range:a});d&&Ze(s,i,d);}function Vo(t){let{mrakomor:e}=t,{blockElement:n,range:o,newLineState:r,originalLineState:s,namespace:i,position:a,cursor:c}=t,l,u;if(a||(n?l=e._getBlockElementIndex(n):o&&(l=e._getBlockElementIndex(Y(o))),l===void 0||l===-1))return;u=l+1;let f=e.getContent();s&&f.splice(l,1,e.normalizeComponentState(s)),r&&(r.component=i,f.splice(u,0,e.normalizeComponentState(r))),e._setContentState(f),R(()=>{typeof c=="number"&&P(e._getBlockElements()[u])?.setCursor?.(c);});}function Yo(t){let{mrakomor:e}=t,{blockElement:n,range:o,blocks:r,cursor:s,cursorBlockIndex:i=0}=t;if(!Array.isArray(r)||r.length===0)return;let a=n??(o?Y(o):null),c=e._getBlockElementIndex(a);if(c===-1)return;let l=[...e._getContentState()];l.splice(c,1,...r.map(u=>e.normalizeComponentState(u))),e._setContentState(l),R(()=>{if(typeof s!="number")return;e._syncBlockElementsFromDom();let u=M(e._getBlockElements()[c+i]);u?.isConnected&&ee(u,s);});}function Wo(t){let{mrakomor:e,blockElement:n,namespace:o}=t,r=e._getBlockElementState(n);if(!r)return;let s=e.register.blocks.getByNamespace(r.component),i=e.register.blocks.getByNamespace(o),a=t.exchangeState??s?.toExchangeState?.(r)??Re({properties:r.properties,settings:r.settings}),c=i?.fromExchangeState?.(a)??a;Ze(e,n,{...c,component:o,componentId:V()});}function Xo(t){let{mrakomor:e,blockElement:n,targetIndex:o}=t,r=e._getBlockElementIndex(n);if(r===-1||typeof o!="number")return;let s=o>r?o-1:o;if(s===r)return;let i=[...e._getContentState()],[a]=i.splice(r,1);i.splice(s,0,a),e._setContentState(i);}function Jo(t){let{mrakomor:e,blockElement:n,range:o}=t,r=e._getBlockElementIndex(n);if(r!==-1){let s=e.getContent();s.splice(r,1),e._setContentState(s);}R(()=>{let s=Y(o);ee(M(s),0);});}function Qo(t){let{mrakomor:e,state:n,blockElement:o}=t,r=e._getBlockElementState(o);if(!r)return;let s=structuredClone(r),i=n?.offset,a=n?.length,c=n?.entity?.type;s.properties.entityRanges=(s.properties.entityRanges??[]).filter(l=>!(l?.offset===i&&l?.length===a&&l?.entity?.type===c)),Ze(e,o,s),e.command.closeDialog?.();}function Zo(t){Zn(t,{customHook:"insertEntityRange",applyFn:Xn,applyArgs:{state:t.state,namespace:t.namespace}});}function er(t){Zn(t,{customHook:"insertInlineStyleRange",applyFn:Wn,applyArgs:{style:t.style}});}function tr(t){let{mrakomor:e,blockElement:n,previousBlockElement:o}=t,r=e._getBlockElementIndex(o),s=e._getBlockElementIndex(n);if(r===-1||s===-1)return;let i=e.getContent(),a=i[s],c=i[r],l=e.register.blocks.getByNamespace(c.component),u=e.register.blocks.getByNamespace(a.component),f=t.exchangeState??u?.toExchangeState?.(a)??Re({properties:a.properties,settings:a.settings}),d=l?.appendExchangeState?.(c,f);if(!d)return;i.splice(s,1),i.splice(r,1,e.normalizeComponentState(d.state)),e._setContentState(i);let h=()=>{if(typeof d.cursor!="number")return;let x=e._getBlockElements()[r]??o,_=M(x);_?.isConnected&&ee(_,d.cursor);};h(),R(h);}function nr(t){let{mrakomor:e}=t,n=e.getRoot();if(t.relatedTarget instanceof Node&&n.contains(t.relatedTarget))return;let[r,s]=H(()=>[e.getContent(),e._getContentState()]);r.length===s.length&&r.every((a,c)=>a===s[c])||e.setContent(r);}function or(t){let e=W();return Y(e)?.getNodeComponent?.()?.classInstance?.onKeydown?.(t)}function rr(t){P(t)?.setCursor?.();}function sr(t){if(t.key!=="Backspace")return;let{mrakomor:e}=t,n=W();if(!n)return;let o=Y(n);if(!o)return;let r=Ve(o),s=o?.previousSibling,a=Ve(s)?.childNodes?.[0]?.contentEditable==="true",c=r?.childNodes?.[0]?.contentEditable==="true",l=M(o),u=!te(l?.textContent),f=n.collapsed&&(n.startOffset===0||$t()===0||u);if(!n.collapsed){let g=Kn(n);if(g&&g.startBlock!==g.endBlock){let y=e._getBlockElementIndex(g.startBlock),k=e._getBlockElementIndex(g.endBlock),S=e.getContent(),b=y>=0?S[y]:void 0,A=k>=0?S[k]:void 0;if(y>=0&&k>y&&typeof b?.properties?.text=="string"&&typeof A?.properties?.text=="string"){t.preventDefault();let{content:U,cursor:Ee,resultIndex:at}=zn(S,{startIndex:y,endIndex:k,startOffset:g.startOffset,endOffset:g.endOffset});e._setContentState(U.map(X=>e.normalizeComponentState(X))),R(()=>{let X=e._getBlockElements()[at];X&&typeof Ee=="number"&&ee(M(X),Ee);});}}return}if(!f)return;let d=e._getBlockElementIndex(o),h=s?e._getBlockElementIndex(s):-1,x=e._getBlockElementState(o),_=e._getBlockElementState(s),N=s?P(s):null;if(!s||h<0){t.preventDefault();return}if(_&&x&&Je(x)&&N&&!N.isAtomic?.()){if(u&&!Je(_)){t.preventDefault();let g=e.getContent();g.splice(d,1),e._setContentState(g),rr(s);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:n});return}N?.isAtomic?.()&&(!a&&n.startOffset===0||o?.textContent==="\xA0"&&!c)&&(t.preventDefault(),e.command.removeBlockElement({blockElement:s,range:n})),x&&!Je(x)&&t.preventDefault();}function et(t){return {resolveComponent:e=>e===ne.NAMESPACE?ne:he,registerCommands(e){e.emitter.on(m.INSERT_BLOCK_ELEMENT,T(Vo)),e.emitter.on(m.REPLACE_BLOCK_ELEMENT,T(Yo)),e.emitter.on(m.TRANSFORM_BLOCK_ELEMENT,T(Wo)),e.emitter.on(m.MOVE_BLOCK_ELEMENT,T(Xo)),e.emitter.on(m.REMOVE_BLOCK_ELEMENT,T(Jo)),e.emitter.on(m.REMOVE_ENTITY_RANGE,T(Qo)),e.emitter.on(m.INSERT_ENTITY_RANGE,T(Zo)),e.emitter.on(m.INSERT_INLINE_STYLE_RANGE,T(er)),e.emitter.on(m.MERGE_BLOCK_ELEMENT,T(tr));},registerHandlers(e){e.emitter.on(m.FOCUSOUT,nr),e.emitter.on(m.KEYDOWN,T(or)),e.emitter.on(m.KEYDOWN,T(sr));},registerListeners(e){let n=e.getRoot(),{signal:o}=e.listenerAbortController;n.addEventListener("keydown",r=>e.emitDomEvent(m.KEYDOWN,r),{signal:o}),n.addEventListener("beforeinput",r=>e.emitDomEvent(m.BEFORE_INPUT,r),{signal:o}),n.addEventListener("input",r=>e.emitDomEvent(m.INPUT,r),{signal:o}),n.addEventListener("focusin",r=>e.emitDomEvent(m.FOCUSIN,r),{signal:o}),n.addEventListener("focusout",r=>e.emitDomEvent(m.FOCUSOUT,r),{signal:o}),n.addEventListener("click",r=>e.emitDomEvent(m.CLICK,r),{signal:o}),document.addEventListener("selectionchange",r=>e.emitDomEvent(m.SELECTION_CHANGE,r),{signal:o});}}}(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/dialog/Dialog.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-dialog-container,.mrakomor-dialog-backdrop{pointer-events:all}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between}.dialog[open] .dialog-controls{text-align:right;width:100%}.dialog[open] .dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}.dialog[open] .dialog-container{width:100%}
5
- `,document.head.appendChild(n);}}})();function ir(t,e,n,o){let r=t.getRoot()?.querySelector(e);if(!r)return {container:null,dispose:null};let s=document.createElement("div");s.className=n,r.append(s);let i=J(s,o);return {container:s,dispose:i??null}}function tt(t,e,n){return ir(t,".mrakomor-tools-container",e,n)}var eo="mrakomor.dialog.Dialog";function nt({open:t,placement:e,positionX:n,positionY:o,block:r,dialogRef:s}){let i=B(()=>{let c=e.get()==="center";return {position:"absolute",zIndex:c?"9100":"9000",top:`${o.get()}px`,left:`${n.get()}px`,...c?{padding:0,background:"transparent",border:"none",boxShadow:"none",minWidth:0}:{background:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px 10px",boxShadow:"0 2px 8px rgba(0,0,0,.15)",minWidth:"220px"}}}),a=B(()=>({position:"absolute",inset:"0",zIndex:"9050",background:"rgba(15, 23, 42, 0.28)",pointerEvents:"all"}));return E("span",{style:{display:"contents"}},[_e(()=>t.get()&&e.get()==="center",E("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:a})),_e(()=>t.get(),E("div",{className:"mrakomor-dialog-container",contenteditable:false,style:i,$ref:s},()=>r.get()))])}nt.NAMESPACE=eo;function ot({mrakomor:t}){let e=null,n=C(false),o=C(false),r=C("anchor"),s=C(0),i=C(0),a=C(null),c=oe(),l=oe();function u(){o.set(false),r.set("anchor"),c.set(null),R(()=>{n.set(false);});}return {resolveComponent(f){if(f===eo)return nt},registerEvents(){m.OPEN_DIALOG="mrakomor:open-dialog",m.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(d,h)=>{f.emit(m.OPEN_DIALOG,{...d,options:h});},f.command.closeDialog=()=>{f.emit(m.CLOSE_DIALOG);};},registerHandlers(){t.emitter.on(m.OPEN_DIALOG,({children:f,element:d,options:h={}})=>{a.set(f??E("div",{},"Empty dialog")),o.set(true),c.set(d??null),r.set(h.placement??"anchor"),R(()=>{let x=t.getRoot(),{x:_,y:N}=h.placement==="center"?Fn(x,l):Ye(x,d??{left:0,top:0},l);s.set(_),i.set(N),n.set(true);});}),t.emitter.on(m.CLOSE_DIALOG,u),t.emitter.on(m.KEYDOWN,f=>{f.key==="Escape"&&o.peek()===true&&t.command.closeDialog();}),t.emitter.on(m.CLICK,f=>{if(o.peek()!==true||n.peek()!==true)return;let d=f.target,h=l&&typeof l.contains=="function"&&l.contains(d),x=c&&typeof c.contains=="function"&&c.contains(d);!h&&!x&&t.command.closeDialog();});},onMount(){let{dispose:f}=tt(t,"mrakomor-dialog-plugin-container",E(nt,{open:o,placement:r,positionX:s,positionY:i,block:a,dialogRef:l}));e=f;},onUnmount(){e?.(),e=null;}}}function ar(){return p.object({id:p.string(),group:p.string().default("general"),description:p.string().default(""),commands:p.array(p.string()).default([]),shortcuts:p.array(p.string()).default([])}).default({})}function to(t){try{return ar().parse(t)}catch{return null}}var rt=class extends pe{constructor(e){super(e,{sort:n=>n});}normalize(e){return to(e)}};(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/menu/Menu.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-menu{position:absolute;z-index:9300;display:flex;flex-direction:column;gap:2px;min-width:160px;max-height:240px;overflow-y:auto;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-menu__item:hover,.mrakomor-menu__item--active{background:#ffffff26}
6
- `,document.head.appendChild(n);}}})();function cr(t,e=-1){if(!t.length)return null;let n=t.map((o,r)=>E("button",{type:"button",role:"option",id:`mrakomor-menu-option-${o.id}`,className:["mrakomor-menu__item",r===e?"mrakomor-menu__item--active":""].filter(Boolean).join(" "),title:o.label,"data-id":o.id,"aria-selected":r===e?"true":"false",onMouseDown:s=>{s.preventDefault();}},o.label));return E("span",{style:"display: contents"},n)}function Ut({open:t,positionX:e,positionY:n,entries:o,highlightIndex:r,ariaLabel:s,menuRef:i}){let a=B(()=>({left:`${e.get()}px`,top:`${n.get()}px`}));return _e(()=>t.get(),E("div",{className:"mrakomor-menu",role:"listbox","aria-label":()=>s.get(),contenteditable:false,style:a,$ref:i},()=>cr(o.get(),r.get())))}function st({mrakomor:t}){let e=null,n=null,o=oe(),r=null,s=C(false),i=C(false),a=C(0),c=C(0),l=C([]),u=C(-1),f=C("Menu");function d(g){R(()=>{let y=t.getRoot();if(!y||!g)return;let k=o?.offsetHeight??200,S=y.getBoundingClientRect();if(g.top-S.top>k+8){let{x:A,y:v}=Ye(y,g,{offsetHeight:k},4);a.set(A),c.set(v);}else a.set(g.left-S.left),c.set(g.bottom-S.top+4);s.set(true);});}function h(){i.set(false),r=null,u.set(-1),l.set([]),R(()=>{s.set(false);});}function x(g){!g||!r||r(g);}function _(g){if(i.peek()!==true)return;let y=g.target?.closest?.(".mrakomor-menu__item");if(!y||!n?.contains(y))return;g.preventDefault(),g.stopPropagation();let k=y.getAttribute("data-id"),S=l.peek().find(b=>b.id===k);S&&x(S);}function N(g={}){let{entries:y=[],anchorRect:k,highlightIndex:S=-1,ariaLabel:b="Menu",onSelect:A=null}=g;l.set(y),u.set(S),f.set(b),A!==void 0&&(r=A),i.set(true),k?d(k):s.set(true);}return {registerEvents(){m.OPEN_MENU="mrakomor:open-menu",m.CLOSE_MENU="mrakomor:close-menu",m.UPDATE_MENU="mrakomor:update-menu";},registerCommands(g){g.command.openMenu=y=>{g.emit(m.OPEN_MENU,y);},g.command.updateMenu=y=>{g.emit(m.UPDATE_MENU,y);},g.command.closeMenu=()=>{g.emit(m.CLOSE_MENU);};},registerHandlers(){t.emitter.on(m.OPEN_MENU,N),t.emitter.on(m.UPDATE_MENU,N),t.emitter.on(m.CLOSE_MENU,h),t.emitter.on(m.CLICK,g=>{let y=o?.current??o;i.peek()===true&&s.peek()===true&&y&&typeof y.contains=="function"&&!y.contains(g.target)&&h();}),t.emitter.on(m.KEYDOWN,g=>{g.key==="Escape"&&i.peek()===true&&h();});},onMount(){let{container:g,dispose:y}=tt(t,"mrakomor-menu-plugin-container",E(Ut,{open:i,positionX:a,positionY:c,entries:l,highlightIndex:u,ariaLabel:f,menuRef:o}));n=g,n?.addEventListener("click",_),e=y;},onUnmount(){n?.removeEventListener("click",_),e?.(),e=null,n=null,o.current=null,r=null;}}}function lr(t){return t!=null&&typeof t=="object"&&(typeof Element>"u"?t.nodeType===1:t instanceof Element)}function no(){return p.object({root:p.any().refine(lr,{message:"root must be a DOM Element"}),id:p.string().optional(),debug:p.boolean().optional(),content:p.array(p.any()).optional(),plugins:p.array(p.function()).optional(),blockComponents:p.array(p.any().refine(t=>typeof t=="function"||t!=null&&typeof t=="object"&&typeof t.component=="function",{message:"blockComponents entry must be a constructor or registration"})).optional(),slashActions:p.array(p.any().refine(t=>t!=null&&typeof t=="object"&&typeof t.handler=="function",{message:"slashActions entry must include a handler function"})).optional(),inlineStyles:p.array(p.function()).optional(),entityRanges:p.array(p.function()).optional(),tooltip:p.any().optional()})}function oo(t){return [...t.filter(e=>e!==ot&&e!==st&&e!==et),ot,st,et]}function ur(t){no().parse(t);let e={debug:false,content:[],plugins:[],blockComponents:[],slashActions:[],inlineStyles:[ce,le,me,ue,fe],entityRanges:[],tooltip:{}},n={...e,...t,plugins:oo(t.plugins??e.plugins)},o=new it(n);return o._init(),o}var it=class{#e=V();#o;#t=[];#n=[];#r;#i=false;listenerAbortController=new AbortController;#c=C([],{debug:"content"});#a=[];command;emitter;register;constructor(e){let{root:n,id:o,content:r}=e;this.#e=o||this.#e,this.#o=n,this.#a=r,this.#n=[],this.#r={...e,plugins:oo(e.plugins??[])},this.register={blocks:new qe(this),help:new rt(this)};let{emitter:s,command:i}=hn({mrakomor:this});this.command=i,this.emitter=s;}_init(){this.#s(),this.#c=C(this._normalizeContentState(this.#a),{debug:"content"});}#s(){this.#t=this.#r.plugins.map(e=>e?.({config:this.#r,root:this.#o,mrakomor:this}))??[],this.#r=this.#t.reduce((e,n)=>n?.resolveConfig?.(e)??e,this.#r),this.register.blocks.add(this.#r.blockComponents??[]),this.#t.forEach(e=>{e?.registerEvents?.(this);}),this.#t.forEach(e=>{e?.registerCommands?.(this);}),this.#t.forEach(e=>{this.emitter.on(m.KEYDOWN,n=>e?.onKeyDown?.(n));}),this.#t.forEach(e=>{e?.registerHandlers?.(this);}),this.#t.forEach(e=>{e?.registerListeners?.(this);});}emit(e,n={}){return this.emitter.emit(e,{...n,mrakomor:this})}on(e,n){return this.emitter.on(e,n)}onChangeContent(e){return this.on(m.CONTENT_CHANGE,e)}emitDomEvent(e,n){let{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:d,which:h,detail:x,isTrusted:_,target:N,relatedTarget:g,data:y,inputType:k}=n??{},{defaultPrevented:S}=this.emit(e,{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:d,which:h,detail:x,isTrusted:_,target:N,relatedTarget:g,data:y,inputType:k});return S&&n?.preventDefault?.(),S}getConfig(){return {...this.#r,blockComponents:this.register.blocks.list(),slashActions:this.register.slashActions?.list()??[]}}wrapBlockElement(e){for(let n of this.#t){let o=n.wrapBlockElement?.(e);if(o)return o}return e}getRoot(){return this.#o}get _id(){return this.#e}getContent(){return this.#n.map(n=>P(n)?.getState())}setContent(e=[]){this._setContentState(this._normalizeContentState(e));}_syncBlockElementsFromDom(){let e=this.#o?.querySelector?.(".mrakomor-content");e&&(this.#n=[...e.querySelectorAll(".mrakomor-block-element")]);}_getBlockElements(){return this.#n}_getContentState(){return this.#c.get()}_setContentState(e=[]){this.#c.set(e),this.emit(m.CONTENT_CHANGE,{content:e}),R(()=>{this._syncBlockElementsFromDom();});}_normalizeContentState(e=[]){return e.map(n=>structuredClone(this.normalizeComponentState(n)))??[]}_setBlockElement(e,n=this.#n.length){this.#n.splice(n,0,e);}_removeBlockElement(e){this.#n=this.#n.filter(n=>n!==e);}#l(e){return P(e)?.state?.peek()?.componentId}#u(e){return e?this.#n.findIndex(n=>this.#l(n)===e):-1}_getBlockElementIndex(e){if(!e)return -1;let n=this.#n.indexOf(e);return n!==-1?n:this.#u(this.#l(e))}_getBlockElementByComponentId(e){let n=this.#u(e);return n===-1?null:this.#n[n]}_getBlockElementState(e){let n=this._getBlockElementIndex(e);if(n!==-1)return P(this.#n[n])?.getState()}mount(){let e=J(this.#o,E(Qn,{mrakomor:this}));return this.#i=true,e}unmount(){this.#i&&(this.#i=false,dn(this.#o));}_onUnmount(){this.listenerAbortController.abort(),this.#t.forEach(e=>{e?.onUnmount?.(this);}),this.emitter.removeAllListeners();}_onMount(){this.#t.forEach(e=>{e?.onMount?.(this);}),R(()=>{this._syncBlockElementsFromDom();});}resolveComponent(e,n){let o=this.resolveComponentConstructor(e);return o?E(o,{state:n}):E(he,{state:n})}resolveComponentConstructor(e){let n=this.register.blocks.getByNamespace(e);if(!n){for(let o of this.#t)if(n=o?.resolveComponent?.(e),n)break}return n}normalizeComponentState(e){let n="component"in e?e.component:e.entity.type;return this.resolveComponentConstructor(n)?.getStateSchema()?.parse(e)}};exports.Bold=ce;exports.Dialog=nt;exports.EVENT=m;exports.Italic=le;exports.Menu=Ut;exports.Mrakomor=it;exports.Subscript=ue;exports.Superscript=fe;exports.Underline=me;exports.createMrakomor=ur;exports.defaultMrakomorPlugin=et;exports.dialogPlugin=ot;exports.menuPlugin=st;
4
+ `?"":t??""}function oe({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{},s=Array.isArray(r.items)?r.items:[{text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]}];return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{items:s},...o?{settings:o}:{}}}function Wn(t){let e="",n=[],o=[];return (t??[]).forEach((r,s)=>{s>0&&(e+=`
5
+ `);let i=e.length;e+=Q(r?.text);for(let a of r?.inlineStyleRanges??[])n.push({...a,offset:a.offset+i});for(let a of r?.entityRanges??[])o.push({...a,offset:a.offset+i});}),{text:e,inlineStyleRanges:n,entityRanges:o}}function Xn(t){return {properties:{text:t?.text??"",inlineStyleRanges:t?.inlineStyleRanges??[],entityRanges:t?.entityRanges??[]}}}function jt(t,e,n,o){let r=t.toExchangeState(e),s=[...r.properties?.items??[]];if(!s[n])return e;s[n]={...s[n],...o};let i=t.fromExchangeState({...r,properties:{...r.properties,items:s}});return {...e,properties:i?.properties??e.properties,settings:i?.settings??e.settings}}function Ut(t,e,n){let o=t._getBlockElementState(e);if(!o)return null;let r=t.register.blocks.getByNamespace(o.component);if(!r)return null;let s=r.toExchangeState(o)?.properties?.items??[];if(!s.length)return null;let i=I(e),a=Fn(i,n),c=a?.element??i??e,l=a?.index??0,u=s[l];return u?{Constructor:r,current:o,element:c,itemIndex:l,item:u}:null}function Jn({mrakomor:t,resultIndex:e,cursor:n,fallbackBlockElement:o,itemIndex:r}){let s=()=>{if(typeof n!="number")return;let i=t._getBlockElements()[e]??o,a=D(i);if(a?.setCursor){a.setCursor({cursor:n,itemIndex:r});return}let c=I(i);c?.isConnected&&Y(c,n);};s(),A(s);}function Qe(t){let e=t?.component??"";return e===wt||e.startsWith(Pn)}function Kt(t,e){let n=Q(t.properties.text),o=Q(e.properties.text);return {state:{...t,properties:{...e.properties,...t.properties,text:n+o,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(r=>({...r,offset:r.offset+n.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(r=>({...r,offset:r.offset+n.length}))]},settings:{...e.settings,...t.settings}},cursor:n.length}}function Qn(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],a=s[n],{originalLineState:c}=Vn(i,o),{newLineState:l}=Vn(a,r),{state:u,cursor:f}=Kt(c,l);return s.splice(e,n-e+1,u),{content:s,cursor:f,resultIndex:e}}function qn(t,e){return (t??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)}))}function Yn(t,e){return (t??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)}))}function Vn(t,e){let n=structuredClone(t),o=structuredClone(t);return n.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),n.properties.inlineStyleRanges=qn(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=Yn(t.properties.inlineStyleRanges,e),n.properties.entityRanges=qn(t.properties.entityRanges,e),o.properties.entityRanges=Yn(t.properties.entityRanges,e),o.componentId=J(),{originalLineState:n,newLineState:o}}function Zn(t,e){if(e.key!=="Enter")return false;e.preventDefault();let n=wt,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:q(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:n}),true}function eo(t,e){let n=Ee(t,e.startContainer,e.startOffset),o=Ee(t,e.endContainer,e.endOffset);return {offset:n,length:Math.max(0,o-n)}}function Yo(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(a=>a.style===e&&a.offset<=n&&a.offset+a.length>=s);return i?r.filter(a=>a!==i):[...r,{style:e,offset:n,length:o}]}function Vo(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function Wo(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!Vo(r,e)){o.push(r);continue}r.offset<e.offset&&o.push({...r,length:e.offset-r.offset});let s=r.offset+r.length;s>n&&o.push({...r,offset:n,length:s-n});}return o}function Xo(t,e){let n=t??[],o=e?.length??0;if(o===0)return null;let r=e.offset??0,s=e.entity?.type,i=n.find(a=>a.offset===r&&a.length===o&&a.entity?.type===s);return i?n.filter(a=>a!==i):[...Wo(n,e),e]}function to(t,e,n,o){if(!e||!n)return null;let{offset:r,length:s}=eo(e,n);return s===0?null:Yo(t??[],{style:o,offset:r,length:s})}function no(t,e,n,{namespace:o,entityData:r}){if(!e||!n)return null;let s={...r,entity:{type:o,...r?.entity},...eo(e,n)};return Xo(t??[],s)}var Ze=class extends Je{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:e}={}){let n=()=>{if(!this.element?.isConnected)return;let o=typeof e=="number"?e:Q(this.getState()?.properties?.text).length;Y(this.element,o);};n(),A(n);}onKeydown(e){}static toExchangeState(e){let n=e?.properties,o={text:Q(n?.text)};return n?.inlineStyleRanges!==void 0&&(o.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(o.entityRanges=n.entityRanges),oe({originComponent:this.NAMESPACE,properties:{items:[o]},settings:e?.settings})}static fromExchangeState(e){let n=e?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:e?.settings}}static appendExchangeState(e,n){let o=Wn(n?.properties?.items);return Kt(e,Xn(o))}};var re=class t extends Ze{static get NAMESPACE(){return On}static getStateSchema(e){return d.object({component:d.string().default(t.NAMESPACE),componentId:d.string().default(e?.getAttribute("data-componentid")||J()),properties:d.object({}).default({}),settings:d.object({}).default({})}).default({})}constructor(e){super(e),this.root=null;}getState(){return this.state.peek()}isAtomic(){return true}static appendExchangeState(){return null}onMount(){}onUnmount(){}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E("div",{className:e,contentEditable:false,style:"position: relative;",$ref:o=>{this.element=o;},"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[E("div",{$ref:o=>{this.root=o;},style:"display: block;",contentEditable:false}),E("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:true,[he]:true},document.createTextNode("\xA0"))])}onKeydown(e){e.key!=="Backspace"&&e.key!=="ArrowUp"&&e.key!=="ArrowDown"&&e.preventDefault(),Zn(this,e);}};var ye=class extends re{static get NAMESPACE(){return Dn}onMount(){let e=E("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);ee(this.root,e);}onUnmount(){this.root.innerHTML="";}};function Jo(t,e){let n=t._getBlockElementByComponentId(e);return D(n)?.isStale?.()??false}function oo(t){return (e,n)=>{if(!ie(e,n))return false;let o=n?.componentId??e?.componentId;return !(o&&Jo(t,o))}}function ro({mrakomor:t}){let e=t.get(),n=oo(e);yt(Xe,e);let o=W(r=>{e._setContentRoot(r??null);});return $e(()=>{e._onMount();}),je(()=>{e._onUnmount();}),E("div",{id:e._id,className:"mrakomor-editor"},[E("div",{className:"mrakomor-editor-surface"},[E("div",{className:"mrakomor-tools-container"}),E("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"},$ref:o},[St(()=>e._getContentState(),r=>r.componentId,(r,s)=>E(()=>{let i;$e(()=>{i.getNodeComponent=()=>{let l=I(i);return l?se(l):null},e._setBlockElement(i,s);}),je(()=>{e._removeBlockElement(i);});let a=e.resolveComponent(r.get().component,r),c=e.wrapBlockElement(a);return E("div",{className:"mrakomor-block-element",[ve]:true,$ref:l=>{i=l;}},c)}),{equals:n})])])])}function et(t,e,n){let o=t._getBlockElementIndex(e);if(o===-1)return false;let r=t.getContent();return r.splice(o,1,t.normalizeComponentState(n)),t._setContentState(r),true}function Qo(t){let{mrakomor:e}=t,{blockElement:n,range:o,newLineState:r,originalLineState:s,namespace:i,position:a,cursor:c}=t,l,u;if(a||(n?l=e._getBlockElementIndex(n):o&&(l=e._getBlockElementIndex(G(o))),l===void 0||l===-1))return;u=l+1;let f=e.getContent();s&&f.splice(l,1,e.normalizeComponentState(s)),r&&(r.component=i,f.splice(u,0,e.normalizeComponentState(r))),e._setContentState(f),A(()=>{typeof c=="number"&&D(e._getBlockElements()[u])?.setCursor?.({cursor:c});});}function Zo(t){let{mrakomor:e}=t,{blockElement:n,range:o,blocks:r,cursor:s,cursorBlockIndex:i=0}=t;if(!Array.isArray(r)||r.length===0)return;let a=n??(o?G(o):null),c=e._getBlockElementIndex(a);if(c===-1)return;let l=[...e._getContentState()];l.splice(c,1,...r.map(u=>e.normalizeComponentState(u))),e._setContentState(l),A(()=>{if(typeof s!="number")return;e._syncBlockElementsFromDom();let u=I(e._getBlockElements()[c+i]);u?.isConnected&&Y(u,s);});}function er(t){let{mrakomor:e,blockElement:n,namespace:o}=t,r=e._getBlockElementState(n);if(!r)return;let s=e.register.blocks.getByNamespace(r.component),i=e.register.blocks.getByNamespace(o),a=(t.exchangeState&&oe(t.exchangeState))??s?.toExchangeState?.(r)??oe({properties:r.properties,settings:r.settings}),c=i?.fromExchangeState?.(a)??a;et(e,n,{...c,component:o,componentId:J()});}function tr(t){let{mrakomor:e,blockElement:n,targetIndex:o}=t,r=e._getBlockElementIndex(n);if(r===-1||typeof o!="number")return;let s=o>r?o-1:o;if(s===r)return;let i=[...e._getContentState()],[a]=i.splice(r,1);i.splice(s,0,a),e._setContentState(i);}function nr(t){let{mrakomor:e,blockElement:n,range:o}=t,r=e._getBlockElementIndex(n);if(r!==-1){let s=e.getContent();s.splice(r,1),e._setContentState(s);}A(()=>{let s=G(o);Y(I(s),0);});}function or(t){let{mrakomor:e,state:n,blockElement:o}=t,r=e._getBlockElementState(o);if(!r)return;let s=structuredClone(r),i=n?.offset,a=n?.length,c=n?.entity?.type;s.properties.entityRanges=(s.properties.entityRanges??[]).filter(l=>!(l?.offset===i&&l?.length===a&&l?.entity?.type===c)),et(e,o,s),e.command.closeDialog?.();}function rr(t){let{mrakomor:e,namespace:n,state:o}=t,r=t.range??q(),s=t.blockElement??G(r),i=Ut(e,s,r);if(!i||i.item.entityRanges===void 0)return;let{Constructor:a,current:c,element:l,itemIndex:u,item:f}=i,p=no(f.entityRanges,l,r,{namespace:n,entityData:o});if(p===null)return;let h=jt(a,c,u,{entityRanges:p});et(e,s,h);}function sr(t){let{mrakomor:e,style:n}=t,o=t.range??q(),r=t.blockElement??G(o),s=Ut(e,r,o);if(!s||s.item.inlineStyleRanges===void 0)return;let{Constructor:i,current:a,element:c,itemIndex:l,item:u}=s,f=to(u.inlineStyleRanges,c,o,n);if(f===null)return;let p=jt(i,a,l,{inlineStyleRanges:f});et(e,r,p);}function ir(t){let{mrakomor:e,blockElement:n,previousBlockElement:o}=t,r=e._getBlockElementIndex(o),s=e._getBlockElementIndex(n);if(r===-1||s===-1)return;let i=e.getContent(),a=i[s],c=i[r],l=e.register.blocks.getByNamespace(c.component),u=e.register.blocks.getByNamespace(a.component),f=(t.exchangeState&&oe(t.exchangeState))??u?.toExchangeState?.(a)??oe({properties:a.properties,settings:a.settings}),p=l?.appendExchangeState?.(c,f);p&&(i.splice(s,1),i.splice(r,1,e.normalizeComponentState(p.state)),e._setContentState(i),Jn({mrakomor:e,resultIndex:r,cursor:p.cursor,fallbackBlockElement:o,itemIndex:p.itemIndex}));}function ar(t){let{mrakomor:e}=t,n=e.getRoot(),o=t.relatedTarget instanceof Node&&n.contains(t.relatedTarget),r=n?.contains(document.activeElement)??false;if(o||r)return;let[i,a]=H(()=>[e.getContent(),e._getContentState()]);i.length===a.length&&i.every((l,u)=>l===a[u])||e.setContent(i);}function cr(t){let{mrakomor:e,clientX:n,clientY:o}=t;if(typeof o!="number")return;let r=e._getContentRoot(),s=e._getBlockElements(),i=s[0],a=s[s.length-1];if(!r||!i||!a)return;let c=o<i.getBoundingClientRect().top,l=o>a.getBoundingClientRect().bottom;if(!c&&!l)return;if(typeof n=="number"){let f=r.getBoundingClientRect();if(n<f.left||n>f.right)return}let u=I(c?i:a);u?.isConnected&&Y(u,c?0:u.textContent.length);}function lr(t){let e=q();return G(e)?.getNodeComponent?.()?.classInstance?.onKeydown?.(t)}function ur(t){D(t)?.setCursor?.();}function fr(t){if(t.key!=="Backspace")return;let{mrakomor:e}=t,n=q();if(!n)return;let o=G(n);if(!o)return;let r=Ve(o),s=o?.previousSibling,a=Ve(s)?.childNodes?.[0]?.contentEditable==="true",c=r?.childNodes?.[0]?.contentEditable==="true",l=I(o),u=!Q(l?.textContent),f=n.collapsed&&(n.startOffset===0||$t()===0||u);if(!n.collapsed){let g=zn(n);if(g&&g.startBlock!==g.endBlock){let y=e._getBlockElementIndex(g.startBlock),k=e._getBlockElementIndex(g.endBlock),C=e.getContent(),x=y>=0?C[y]:void 0,_=k>=0?C[k]:void 0;if(y>=0&&k>y&&typeof x?.properties?.text=="string"&&typeof _?.properties?.text=="string"){t.preventDefault();let{content:U,cursor:xe,resultIndex:ct}=Qn(C,{startIndex:y,endIndex:k,startOffset:g.startOffset,endOffset:g.endOffset});e._setContentState(U.map(Z=>e.normalizeComponentState(Z))),A(()=>{let Z=e._getBlockElements()[ct];Z&&typeof xe=="number"&&Y(I(Z),xe);});}}return}if(!f)return;let p=e._getBlockElementIndex(o),h=s?e._getBlockElementIndex(s):-1,b=e._getBlockElementState(o),R=e._getBlockElementState(s),N=s?D(s):null;if(!s||h<0){t.preventDefault();return}if(R&&b&&Qe(b)&&N&&!N.isAtomic?.()){if(u&&!Qe(R)){t.preventDefault();let g=e.getContent();g.splice(p,1),e._setContentState(g),ur(s);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:n});return}N?.isAtomic?.()&&(!a&&n.startOffset===0||o?.textContent==="\xA0"&&!c)&&(t.preventDefault(),e.command.removeBlockElement({blockElement:s,range:n})),b&&!Qe(b)&&t.preventDefault();}function tt(t){return {resolveComponent:e=>e===re.NAMESPACE?re:ye,registerCommands(e){e.emitter.on(m.INSERT_BLOCK_ELEMENT,w(Qo)),e.emitter.on(m.REPLACE_BLOCK_ELEMENT,w(Zo)),e.emitter.on(m.TRANSFORM_BLOCK_ELEMENT,w(er)),e.emitter.on(m.MOVE_BLOCK_ELEMENT,w(tr)),e.emitter.on(m.REMOVE_BLOCK_ELEMENT,w(nr)),e.emitter.on(m.REMOVE_ENTITY_RANGE,w(or)),e.emitter.on(m.INSERT_ENTITY_RANGE,w(rr)),e.emitter.on(m.INSERT_INLINE_STYLE_RANGE,w(sr)),e.emitter.on(m.MERGE_BLOCK_ELEMENT,w(ir));},registerHandlers(e){e.emitter.on(m.FOCUSOUT,ar),e.emitter.on(m.KEYDOWN,w(lr)),e.emitter.on(m.KEYDOWN,w(fr)),e.emitter.on(m.CLICK,w(cr));},registerListeners(e){let n=e.getRoot(),{signal:o}=e.listenerAbortController;n.addEventListener("keydown",r=>e.emitDomEvent(m.KEYDOWN,r),{signal:o}),n.addEventListener("beforeinput",r=>e.emitDomEvent(m.BEFORE_INPUT,r),{signal:o}),n.addEventListener("input",r=>e.emitDomEvent(m.INPUT,r),{signal:o}),n.addEventListener("focusin",r=>e.emitDomEvent(m.FOCUSIN,r),{signal:o}),n.addEventListener("focusout",r=>e.emitDomEvent(m.FOCUSOUT,r),{signal:o}),n.addEventListener("click",r=>e.emitDomEvent(m.CLICK,r),{signal:o}),document.addEventListener("selectionchange",r=>e.emitDomEvent(m.SELECTION_CHANGE,r),{signal:o});}}}(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/dialog/Dialog.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-dialog-container,.mrakomor-dialog-backdrop{pointer-events:all}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between}.dialog[open] .dialog-controls{text-align:right;width:100%}.dialog[open] .dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}.dialog[open] .dialog-container{width:100%}
6
+ `,document.head.appendChild(n);}}})();function mr(t,e,n,o){let r=t.getRoot()?.querySelector(e);if(!r)return {container:null,dispose:null};let s=document.createElement("div");s.className=n,r.append(s);let i=ee(s,o);return {container:s,dispose:i??null}}function nt(t,e,n){return mr(t,".mrakomor-tools-container",e,n)}var so="mrakomor.dialog.Dialog";function ot({open:t,placement:e,positionX:n,positionY:o,block:r,dialogRef:s}){let i=M(()=>{let c=e.get()==="center";return {position:"absolute",zIndex:c?"9100":"9000",top:`${o.get()}px`,left:`${n.get()}px`,...c?{padding:0,background:"transparent",border:"none",boxShadow:"none",minWidth:0}:{background:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px 10px",boxShadow:"0 2px 8px rgba(0,0,0,.15)",minWidth:"220px"}}}),a=M(()=>({position:"absolute",inset:"0",zIndex:"9050",background:"rgba(15, 23, 42, 0.28)",pointerEvents:"all"}));return E("span",{style:{display:"contents"}},[Ae(()=>t.get()&&e.get()==="center",E("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:a})),Ae(()=>t.get(),E("div",{className:"mrakomor-dialog-container",contenteditable:false,style:i,$ref:s},()=>r.get()))])}ot.NAMESPACE=so;function rt({mrakomor:t}){let e=null,n=S(false),o=S(false),r=S("anchor"),s=S(0),i=S(0),a=S(null),c=W(null),l=W(null);function u(){o.set(false),r.set("anchor"),c.set(null),A(()=>{n.set(false);});}return {resolveComponent(f){if(f===so)return ot},registerEvents(){m.OPEN_DIALOG="mrakomor:open-dialog",m.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(p,h)=>{f.emit(m.OPEN_DIALOG,{...p,options:h});},f.command.closeDialog=()=>{f.emit(m.CLOSE_DIALOG);};},registerHandlers(){t.emitter.on(m.OPEN_DIALOG,({children:f,element:p,options:h={}})=>{a.set(f??E("div",{},"Empty dialog")),o.set(true),c.set(p??null),r.set(h.placement??"anchor"),A(()=>{let b=t.getRoot(),{x:R,y:N}=h.placement==="center"?Gn(b,l):We(b,p??{left:0,top:0},l);s.set(R),i.set(N),n.set(true);});}),t.emitter.on(m.CLOSE_DIALOG,u),t.emitter.on(m.KEYDOWN,f=>{f.key==="Escape"&&o.peek()===true&&t.command.closeDialog();}),t.emitter.on(m.CLICK,f=>{if(o.peek()!==true||n.peek()!==true)return;let p=f.target,h=l&&typeof l.contains=="function"&&l.contains(p),b=c&&typeof c.contains=="function"&&c.contains(p);!h&&!b&&t.command.closeDialog();});},onMount(){let{dispose:f}=nt(t,"mrakomor-dialog-plugin-container",E(ot,{open:o,placement:r,positionX:s,positionY:i,block:a,dialogRef:l}));e=f;},onUnmount(){e?.(),e=null;}}}function pr(){return d.object({id:d.string(),group:d.string().default("general"),description:d.string().default(""),commands:d.array(d.string()).default([]),shortcuts:d.array(d.string()).default([])}).default({})}function io(t){try{return pr().parse(t)}catch{return null}}var st=class extends de{constructor(e){super(e,{sort:n=>n});}normalize(e){return io(e)}};(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/menu/Menu.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-menu{position:absolute;z-index:9300;display:flex;flex-direction:column;gap:2px;min-width:160px;max-height:240px;overflow-y:auto;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-menu__item:hover,.mrakomor-menu__item--active{background:#ffffff26}.mrakomor-menu__empty{padding:6px 10px;font-size:13px;font-weight:600;color:#ffffff80}
7
+ `,document.head.appendChild(n);}}})();function dr(t,e=-1){if(!t.length)return E("div",{className:"mrakomor-menu__empty",role:"presentation"},"No results");let n=t.map((o,r)=>E("button",{type:"button",role:"option",id:`mrakomor-menu-option-${o.id}`,className:["mrakomor-menu__item",r===e?"mrakomor-menu__item--active":""].filter(Boolean).join(" "),title:o.label,"data-id":o.id,"aria-selected":r===e?"true":"false",onMouseDown:s=>{s.preventDefault();}},o.label));return E("span",{style:"display: contents"},n)}function Ft({open:t,positionX:e,positionY:n,entries:o,highlightIndex:r,ariaLabel:s,menuRef:i}){let a=M(()=>({left:`${e.get()}px`,top:`${n.get()}px`}));return Ae(()=>t.get(),E("div",{className:"mrakomor-menu",role:"listbox","aria-label":()=>s.get(),contenteditable:false,style:a,$ref:i},()=>dr(o.get(),r.get())))}function it({mrakomor:t}){let e=null,n=null,o=W(null),r=null,s=S(false),i=S(false),a=S(0),c=S(0),l=S([]),u=S(-1),f=S("Menu");function p(g){A(()=>{let y=t.getRoot();if(!y||!g)return;let k=o?.offsetHeight??200,C=y.getBoundingClientRect();if(g.top-C.top>k+8){let{x:_,y:v}=We(y,g,{offsetHeight:k},4);a.set(_),c.set(v);}else a.set(g.left-C.left),c.set(g.bottom-C.top+4);s.set(true);});}function h(){i.set(false),r=null,u.set(-1),l.set([]),A(()=>{s.set(false);});}function b(g){!g||!r||r(g);}function R(g){if(i.peek()!==true)return;let y=g.target?.closest?.(".mrakomor-menu__item");if(!y||!n?.contains(y))return;g.preventDefault(),g.stopPropagation();let k=y.getAttribute("data-id"),C=l.peek().find(x=>x.id===k);C&&b(C);}function N(g={}){let{entries:y=[],anchorRect:k,highlightIndex:C=-1,ariaLabel:x="Menu",onSelect:_=null}=g;l.set(y),u.set(C),f.set(x),_!==void 0&&(r=_),i.set(true),k?p(k):s.set(true);}return {registerEvents(){m.OPEN_MENU="mrakomor:open-menu",m.CLOSE_MENU="mrakomor:close-menu",m.UPDATE_MENU="mrakomor:update-menu";},registerCommands(g){g.command.openMenu=y=>{g.emit(m.OPEN_MENU,y);},g.command.updateMenu=y=>{g.emit(m.UPDATE_MENU,y);},g.command.closeMenu=()=>{g.emit(m.CLOSE_MENU);};},registerHandlers(){t.emitter.on(m.OPEN_MENU,N),t.emitter.on(m.UPDATE_MENU,N),t.emitter.on(m.CLOSE_MENU,h),t.emitter.on(m.CLICK,g=>{let y=o?.current??o;i.peek()===true&&s.peek()===true&&y&&typeof y.contains=="function"&&!y.contains(g.target)&&h();}),t.emitter.on(m.KEYDOWN,g=>{g.key==="Escape"&&i.peek()===true&&h();});},onMount(){let{container:g,dispose:y}=nt(t,"mrakomor-menu-plugin-container",E(Ft,{open:i,positionX:a,positionY:c,entries:l,highlightIndex:u,ariaLabel:f,menuRef:o}));n=g,n?.addEventListener("click",R),e=y;},onUnmount(){n?.removeEventListener("click",R),e?.(),e=null,n=null,o.current=null,r=null;}}}function gr(t){return t!=null&&typeof t=="object"&&(typeof Element>"u"?t.nodeType===1:t instanceof Element)}function ao(){return d.object({root:d.any().refine(gr,{message:"root must be a DOM Element"}),id:d.string().optional(),debug:d.boolean().optional(),content:d.array(d.any()).optional(),plugins:d.array(d.function()).optional(),blockComponents:d.array(d.any().refine(t=>typeof t=="function"||t!=null&&typeof t=="object"&&typeof t.component=="function",{message:"blockComponents entry must be a constructor or registration"})).optional(),slashActions:d.array(d.any().refine(t=>t!=null&&typeof t=="object"&&typeof t.handler=="function",{message:"slashActions entry must include a handler function"})).optional(),inlineStyles:d.array(d.function()).optional(),entityRanges:d.array(d.function()).optional(),tooltip:d.any().optional()})}function co(t){return [...t.filter(e=>e!==rt&&e!==it&&e!==tt),rt,it,tt]}function hr(t){ao().parse(t);let e={debug:false,content:[],plugins:[],blockComponents:[],slashActions:[],inlineStyles:[le,ue,pe,fe,me],entityRanges:[],tooltip:{}},n={...e,...t,plugins:co(t.plugins??e.plugins)},o=new at(n);return o._init(),o}var at=class{#e=J();#n;#r=null;#t=[];#o=[];#i;#c=false;listenerAbortController=new AbortController;#a=S([],{debug:"content"});#s=[];command;emitter;register;constructor(e){let{root:n,id:o,content:r}=e;this.#e=o||this.#e,this.#n=n,this.#s=r,this.#o=[],this.#i={...e,plugins:co(e.plugins??[])},this.register={blocks:new qe(this),help:new st(this)};let{emitter:s,command:i}=yn({mrakomor:this});this.command=i,this.emitter=s;}_init(){this.#u(),this.#a=S(this._normalizeContentState(this.#s),{debug:"content"});}#u(){this.#t=this.#i.plugins.map(e=>e?.({config:this.#i,root:this.#n,mrakomor:this}))??[],this.#i=this.#t.reduce((e,n)=>n?.resolveConfig?.(e)??e,this.#i),this.register.blocks.add(this.#i.blockComponents??[]),this.#t.forEach(e=>{e?.registerEvents?.(this);}),this.#t.forEach(e=>{e?.registerCommands?.(this);}),this.#t.forEach(e=>{this.emitter.on(m.KEYDOWN,n=>e?.onKeyDown?.(n));}),this.#t.forEach(e=>{e?.registerHandlers?.(this);}),this.#t.forEach(e=>{e?.registerListeners?.(this);});}emit(e,n={}){return this.emitter.emit(e,{...n,mrakomor:this})}on(e,n){return this.emitter.on(e,n)}onChangeContent(e){return this.on(m.CONTENT_CHANGE,e)}emitDomEvent(e,n){let{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:p,which:h,detail:b,isTrusted:R,target:N,relatedTarget:g,data:y,inputType:k,clientX:C,clientY:x}=n??{},{defaultPrevented:_}=this.emit(e,{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:p,which:h,detail:b,isTrusted:R,target:N,relatedTarget:g,data:y,inputType:k,clientX:C,clientY:x});return _&&n?.preventDefault?.(),_}getConfig(){return {...this.#i,blockComponents:this.register.blocks.list(),slashActions:this.register.slashActions?.list()??[]}}wrapBlockElement(e){for(let n of this.#t){let o=n.wrapBlockElement?.(e);if(o)return o}return e}getRoot(){return this.#n}_getContentRoot(){return this.#r}_setContentRoot(e){this.#r=e;}get _id(){return this.#e}getContent(){return this.#o.map(n=>D(n)?.getState())}setContent(e=[]){this._setContentState(this._normalizeContentState(e));}_syncBlockElementsFromDom(){let e=this.#r;e&&(this.#o=[...e.querySelectorAll(".mrakomor-block-element")]);}_getBlockElements(){return this.#o}_getContentState(){return this.#a.get()}_setContentState(e=[]){this.#a.set(e),this.emit(m.CONTENT_CHANGE,{content:e}),A(()=>{this._syncBlockElementsFromDom();});}_normalizeContentState(e=[]){return e.map(n=>{let o=this.normalizeComponentState(n);return o===void 0?void 0:structuredClone(o)}).filter(n=>n!==void 0)??[]}_setBlockElement(e,n=this.#o.length){this.#o.splice(n,0,e);}_removeBlockElement(e){this.#o=this.#o.filter(n=>n!==e);}#f(e){return D(e)?.state?.peek()?.componentId}#l(e){return e?this.#o.findIndex(n=>this.#f(n)===e):-1}_getBlockElementIndex(e){if(!e)return -1;let n=this.#o.indexOf(e);return n!==-1?n:this.#l(this.#f(e))}_getBlockElementByComponentId(e){let n=this.#l(e);return n===-1?null:this.#o[n]}_getBlockElementState(e){let n=this._getBlockElementIndex(e);if(n!==-1)return D(this.#o[n])?.getState()}mount(){let e=ee(this.#n,E(ro,{mrakomor:this}));return this.#c=true,e}unmount(){this.#c&&(this.#c=false,hn(this.#n));}_onUnmount(){this.listenerAbortController.abort(),this.#t.forEach(e=>{e?.onUnmount?.(this);}),this.emitter.removeAllListeners();}_onMount(){this.#t.forEach(e=>{e?.onMount?.(this);}),A(()=>{this._syncBlockElementsFromDom();});}resolveComponent(e,n){let o=this.resolveComponentConstructor(e);return o?E(o,{state:n}):E(ye,{state:n})}resolveComponentConstructor(e){let n=this.register.blocks.getByNamespace(e);if(!n){for(let o of this.#t)if(n=o?.resolveComponent?.(e),n)break}return n}normalizeComponentState(e){if(e==null){console.warn("normalizeComponentState() received a nullish state; dropping it.");return}let n="component"in e?e.component:e.entity.type;return this.resolveComponentConstructor(n)?.getStateSchema()?.parse(e)}};exports.Bold=le;exports.Dialog=ot;exports.EVENT=m;exports.Italic=ue;exports.Menu=Ft;exports.Mrakomor=at;exports.Subscript=fe;exports.Superscript=me;exports.Underline=pe;exports.createMrakomor=hr;exports.defaultMrakomorPlugin=tt;exports.dialogPlugin=rt;exports.menuPlugin=it;