@mrakomor/core 0.0.11 → 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 (111) 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-NR2BAMSW.mjs → chunk-6CG6EGQM.mjs} +2 -2
  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-2VURZA2E.mjs → chunk-GDDVUIEH.mjs} +1 -1
  11. package/dist/{chunk-VYTSZ4S6.mjs → chunk-JVQ2YGII.mjs} +1 -1
  12. package/dist/{chunk-SCFD3XBH.mjs → chunk-P7TUN2KD.mjs} +1 -1
  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 +3 -3
  17. package/dist/clipboard.mjs +3 -3
  18. package/dist/footer.cjs +2 -2
  19. package/dist/footer.mjs +2 -2
  20. package/dist/headline.cjs +2 -2
  21. package/dist/headline.mjs +1 -1
  22. package/dist/help.mjs +2 -2
  23. package/dist/index.cjs +6 -6
  24. package/dist/index.mjs +4 -4
  25. package/dist/link.mjs +2 -2
  26. package/dist/list.cjs +3 -3
  27. package/dist/list.mjs +1 -1
  28. package/dist/paragraph.cjs +2 -2
  29. package/dist/paragraph.mjs +1 -1
  30. package/dist/slashCommand.cjs +2 -2
  31. package/dist/slashCommand.mjs +1 -1
  32. package/dist/tooltip.cjs +1 -1
  33. package/dist/tooltip.mjs +2 -2
  34. package/dist/tts.cjs +8 -8
  35. package/dist/tts.mjs +3 -3
  36. package/dist/types/Mrakomor.d.mts +230 -0
  37. package/dist/types/component/AbstractComponent.d.mts +69 -0
  38. package/dist/types/component/Editor.d.mts +8 -0
  39. package/dist/types/component/block/BlockComponent.d.mts +105 -0
  40. package/dist/types/component/block/BlockRegister.d.mts +29 -0
  41. package/dist/types/component/block/ExternalComponent.d.mts +42 -0
  42. package/dist/types/component/block/UnknownComponent.d.mts +3 -0
  43. package/dist/types/component/block/blockItemEquals.d.mts +6 -0
  44. package/dist/types/component/block/helpers.d.mts +319 -0
  45. package/dist/types/component/editorContext.d.mts +4 -0
  46. package/dist/types/component/entityRange/EntityRangeElement.d.mts +15 -0
  47. package/dist/types/component/inlineStyle/Bold.d.mts +4 -0
  48. package/dist/types/component/inlineStyle/InlineElement.d.mts +10 -0
  49. package/dist/types/component/inlineStyle/Italic.d.mts +4 -0
  50. package/dist/types/component/inlineStyle/Subscript.d.mts +4 -0
  51. package/dist/types/component/inlineStyle/Superscript.d.mts +4 -0
  52. package/dist/types/component/inlineStyle/Underline.d.mts +4 -0
  53. package/dist/types/component/inlineStyle/index.d.mts +5 -0
  54. package/dist/types/component/overlayMount.d.mts +46 -0
  55. package/dist/types/dom.d.mts +161 -0
  56. package/dist/types/emitter.d.mts +38 -0
  57. package/dist/types/index.d.mts +7 -0
  58. package/dist/types/namespaces.d.mts +17 -0
  59. package/dist/types/plugin/blockChrome/BlockChrome.d.mts +11 -0
  60. package/dist/types/plugin/blockChrome/index.d.mts +1 -0
  61. package/dist/types/plugin/blockInsertMenu/BlockInsertMenu.d.mts +6 -0
  62. package/dist/types/plugin/blockInsertMenu/index.d.mts +1 -0
  63. package/dist/types/plugin/clipboard/clipboardHelpers.d.mts +151 -0
  64. package/dist/types/plugin/clipboard/clipboardPlugin.d.mts +6 -0
  65. package/dist/types/plugin/clipboard/index.d.mts +1 -0
  66. package/dist/types/plugin/default/defaultMrakomorPlugin.d.mts +21 -0
  67. package/dist/types/plugin/dialog/Dialog.d.mts +23 -0
  68. package/dist/types/plugin/footer/footerPlugin.d.mts +7 -0
  69. package/dist/types/plugin/footer/index.d.mts +1 -0
  70. package/dist/types/plugin/headline/Headline.d.mts +29 -0
  71. package/dist/types/plugin/headline/index.d.mts +1 -0
  72. package/dist/types/plugin/help/HelpRegister.d.mts +15 -0
  73. package/dist/types/plugin/help/helpPlugin.d.mts +26 -0
  74. package/dist/types/plugin/help/helpSchema.d.mts +11 -0
  75. package/dist/types/plugin/help/index.d.mts +1 -0
  76. package/dist/types/plugin/linkEntity/LinkEntity.d.mts +37 -0
  77. package/dist/types/plugin/linkEntity/index.d.mts +1 -0
  78. package/dist/types/plugin/list/List.d.mts +61 -0
  79. package/dist/types/plugin/list/index.d.mts +1 -0
  80. package/dist/types/plugin/list/listHelpers.d.mts +166 -0
  81. package/dist/types/plugin/menu/Menu.d.mts +22 -0
  82. package/dist/types/plugin/menu/menuPlugin.d.mts +6 -0
  83. package/dist/types/plugin/paragraph/Paragraph.d.mts +16 -0
  84. package/dist/types/plugin/paragraph/index.d.mts +1 -0
  85. package/dist/types/plugin/slashCommand/SlashActionRegister.d.mts +12 -0
  86. package/dist/types/plugin/slashCommand/index.d.mts +1 -0
  87. package/dist/types/plugin/slashCommand/slashActionSchema.d.mts +29 -0
  88. package/dist/types/plugin/slashCommand/slashCommandHelpers.d.mts +77 -0
  89. package/dist/types/plugin/slashCommand/slashCommandPlugin.d.mts +11 -0
  90. package/dist/types/plugin/slashCommand/slashHelp.d.mts +12 -0
  91. package/dist/types/plugin/tooltip/Tooltip.d.mts +16 -0
  92. package/dist/types/plugin/tooltip/index.d.mts +1 -0
  93. package/dist/types/plugin/tts/TtsHeadline.d.mts +27 -0
  94. package/dist/types/plugin/tts/TtsList.d.mts +19 -0
  95. package/dist/types/plugin/tts/TtsParagraph.d.mts +9 -0
  96. package/dist/types/plugin/tts/TtsVoice.d.mts +52 -0
  97. package/dist/types/plugin/tts/index.d.mts +4 -0
  98. package/dist/types/register/Register.d.mts +50 -0
  99. package/dist/types/register/sortRegisterEntries.d.mts +7 -0
  100. package/dist/types/schema/blockContent.d.mts +34 -0
  101. package/dist/types/schema/blockRegister.d.mts +14 -0
  102. package/dist/types/schema/config.d.mts +6 -0
  103. package/dist/types/types.d.mts +636 -0
  104. package/package.json +35 -22
  105. package/dist/chunk-5VPYPKGA.mjs +0 -1
  106. package/dist/chunk-BCE45I7Q.mjs +0 -2
  107. package/dist/chunk-N4I2WZWF.mjs +0 -1
  108. package/dist/chunk-T7OO472O.mjs +0 -1
  109. package/dist/chunk-WQWE5UCN.mjs +0 -1
  110. package/dist/chunk-YO4ZA6PJ.mjs +0 -2
  111. package/dist/chunk-ZDMD7SRT.mjs +0 -4
package/dist/headline.cjs CHANGED
@@ -1,5 +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){}},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 te=Symbol("@esmj/signals:type"),q=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)}},ne=null;function tt(e){ne=new hn(e);}tt(()=>{Ze();});function nt(){return ne.getPending()}function rt(e){return ne.watch(e)}function ot(e){return ne.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[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&&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[te]="effect",s[q]=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,[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"),mn=Symbol("keep-literal"),ce=Symbol("raw-props");var gt=null;function D(){return gt}function se(e){gt=e;}function we(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 En(e){return e[oe]}function L(e,t){let n=En(e);n||(n=ie(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();se(e);try{return t()}finally{se(n);}}var Ae=new Map,ae=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 U(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(ae,t,o);}}}function yn(e){let t=ae.get(e);if(t){ae.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=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=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 $(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=re(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=ut(e)?void 0:e[ce],s={...Et(t??{},i),children:n},a=D(),c={disposers:[],id:r,contexts:new Map(a?.contexts)};se(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(ae,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);se(a);let u=xn(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ie(f,c),at(f,o);else ie(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:$(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 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 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),fe(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 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,()=>{_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(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(Nn.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 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($(t)){yt(e,t);return}if(G(t)){mt(e,()=>t.get());return}if(Array.isArray(t)){Re(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function H(e){let t=null,n=e;return $(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&&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}=H(s);pe(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 he(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}=he(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}=he(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 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: ${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}=he(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 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},Fe({...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(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 F(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 F(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:F,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}=he(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 me(){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 de(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===`
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
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=me(),{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(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:N(this.getState()?.properties?.text).length;de(this.element,r);};n(),U(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")||me()),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 le(`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&&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 Vn(){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=Vn;
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-YO4ZA6PJ.mjs';import'./chunk-2VURZA2E.mjs';import'./chunk-VYTSZ4S6.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-ZDMD7SRT.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-SCFD3XBH.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,7 +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 Gt=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"),be=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 po(){lt=false;let t=Yt();for(let n of t)n.get();let e=ut;ut=[];for(let n of e)n();}function qt(){lt||(lt=true,queueMicrotask(po));}function ft(t){ut.push(t),qt();}var zt=Symbol("@esmj/signals:internal observable"),K=Symbol("@esmj/signals:original function"),go=class extends ct{#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)}},Be=null;function Vt(t){Be=new go(t);}Vt(()=>{qt();});function Yt(){return Be.getPending()}function Wt(t){return Be.watch(t)}function Xt(t){return Be.unwatch(t)}var F=Symbol("@esmj/signals:no error"),Jt=class Qt extends Gt{#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[ve]="computed",this[be]=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[be],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[zt].next();}get(){if(this.#n)throw new Error("Cycle detected in computed signal");if(this.#r||(this.#r=C(this.#m(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#l()?this.#m():this.#e=false),w&&w.sourceRevisions.set(this,this.#c),this.#s!==F)throw this.#s;return this.#r.get()}peek(){if(this.#r||(this.#r=C(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=w;w=this.#t;let n;try{n=this.#o();}catch(o){this.#s=o;}return w=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 D(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[ve]="effect",i[be]=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,[zt]:r,[ve]:"signal",[be]:e?.debug??null};return l}function Me(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var cn=Symbol("node-component"),we=Symbol("node-internal"),ho=Symbol("keep-literal"),De=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,Me()),r}function ht(t,e,n){let o=yo(t,e);return n?.id&&o.setAttribute("id",n.id),o}function Y(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 Le(t){ln=t;}function se(t){return t?.[cn]||null}function Zt(t,e){t[cn]=e;}function Te(t,e={disposers:[],id:Me()}){return t?.[we]?t[we]:(t&&(t[we]=e),e)}function xo(t){return t[we]}function G(t,e){let n=xo(t);n||(n=Te(t)),n.disposers.push(e);}function ke(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n);}function V(t,e){let n=$();Le(t);try{return e()}finally{Le(n);}}var Oe=new Map,_e=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]=C(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 Pe(t){let e=$();if(!e){console.warn("onMount called outside of a component context");return}ke(Oe,e.id,t);}function $e(t){let e=$();if(!e){console.warn("onUnmount called outside of a component context");return}ke(_e,e.id,t);}function A(t){ft(()=>{setTimeout(t,0);});}function ae(t){let e=t.componentId,n=Oe.get(e);if(n){Oe.delete(e);for(let o of n){let r=o();typeof r=="function"&&ke(_e,e,r);}}}function bo(t){let e=_e.get(t);if(e){_e.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 Ne(t){if(!t)return;let e=Te(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;Ne(o),o=r;}}}function W(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=Me(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=tn(t)?void 0:t[De],i={...un(e??{},s),children:n},a=$(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};Le(c);let l;if(tn(t)){r.ClassConstructor=t;let f=new t(i);r.classInstance=f,typeof f.onMount=="function"&&ke(Oe,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&ke(_e,o,()=>{f.onUnmount?.();}),l=f.render();}else l=t(i);Le(a);let u=ko(l);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)Te(f,c),Zt(f,r);else Te(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:W(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 Ce(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),je(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 je(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(Ce(r)){let s=D(()=>{V(n,()=>{mt(t,r.get());});});G(t,s);}else if(typeof r=="function"){let s=D(()=>{V(n,()=>{mt(t,r());});});G(t,s);}else mt(t,r);continue}if(o==="style"){if(Ce(r)){let s=D(()=>{V(n,()=>{Object.assign(t.style,r.get());});});G(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(Ce(r)||typeof r=="function"){let s=o,i=D(()=>{V(n,()=>{let a=typeof r=="function"?r():r.get();on.has(s)?t[s]=a??"":rn(t,s,a);});});G(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(W(e)){bt(t,e);return}if(Ce(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 W(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 Ue(t,e=true){for(let n of t)e&&Ne(n),n.remove();}function an(t,e){let n=$(),o=document.createComment("");t.appendChild(o);let r=[],s=D(()=>{V(n,()=>{let i=e(),{nodes:a,instance:c}=ce(i);Ue(r),a.length&&o.after(...a),c&&queueMicrotask(()=>ae(c)),r=a;});});G(t,s);}var Ke=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);je(a,i);let c=$(),l=[],u=new Map,f=M(()=>t()),p=D(()=>{let g=f.get(),b=Array.isArray(g)?g:[],N=[],k=[],h=new Set;for(let x=0;x<b.length;x++){let R=b[x],v=e(R,x);if(h.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${x}`);continue}h.add(v),N.push(R),k.push(v);}let y=new Map(l.map(x=>[x.key,x])),_=[];for(let x=0;x<N.length;x++){let R=k[x],v=N[x],U=y.get(R);if(U)u.get(R).set(v),_.push(U),y.delete(R);else {let xe=C(v,{equals:r});u.set(R,xe);let at={...xe,set(){}},Q={key:R,nodes:[]};V(c,()=>{let lo=n(at,x),{nodes:uo,instance:Ht}=ce(lo);Q.nodes=uo,Ht&&queueMicrotask(()=>ae(Ht));}),_.push(Q);}}for(let[x,R]of y)Ue(R.nodes),u.delete(x);let S=null;for(let x=_.length-1;x>=0;x--){let R=_[x].nodes;for(let v=R.length-1;v>=0;v--){let U=R[v];(U.parentNode!==a||U.nextSibling!==S)&&a.insertBefore(U,S),S=U;}}l=_;});return G(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[De]=t=>t!=="each";function Z(t,e){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("mount: container not found");t instanceof DocumentFragment||(Ne(t),t.innerHTML=""),W(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");Ne(t),t.innerHTML="";}function Re(t,e){let n=null;if(W(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=D(()=>{n.style.display=o.get()?"":"none";});G(n,r);}return n}var L=class extends Ke{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 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 ue=class extends L{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return E("i",{},"I")}};var fe=class extends L{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return E("sub",{},"Sub")}};var me=class extends L{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return E("sup",{},"Sup")}};var pe=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"),Fe=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:ee(e,o),name:t,[Fe]:false,defaultPrevented:false};return r&&(wo(s,o),s[o]=n?void 0:ee(e,o)),s.stopPropagation=()=>{s[Fe]=true;},s.preventDefault=()=>{s.defaultPrevented=true;},s}function ee(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=ee(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 He=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??ee(r,r[j])),r[Fe]?ee(r,r[j]):a(r)))),!s){if(r[Fe])return r;i=a(r);}i instanceof Promise&&!s?s=i:Ct(r,r[j],i??ee(r,r[j]));}return s?s.then(a=>(Ct(r,r[j],a??ee(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 T(t){return e=>{if(!e.defaultPrevented)return t(e)}}function yn({mrakomor:t}={}){let e=t?.emitter??new He;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 xn=class{#e=new Set;pipe(...t){return Lo(...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 Lo(...t){return e=>Array.from(t).reduce((n,o)=>o(n),e)}function bn(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 xn{mrakomor;#e=new Map;#n=null;#r=0;#t;constructor(e,n={}){super(),this.mrakomor=e,this.#t=n.sort??bn;}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 To={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 Oo(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(At(t.errors[o],n));}function kn(t,e,n,o){if(n!==false){let r=At(t.error,e);return {success:false,error:r,errors:[r]}}Oo(t,o,e);}function Ge(t){return t?.abortEarly!==void 0?t:To}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 Ae=t=>typeof t=="string"||t instanceof String,_t=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),Nt=t=>t===true||t===false,Do=t=>t instanceof Date&&!Number.isNaN(t.getTime()),Po=t=>typeof t=="function",$o=t=>Array.isArray(t),Rt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function _n(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 g=kn(p,f,c,u);if(g)return g}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),o}function It(t){return O(Ae,{...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(Do,{...t,type:"date"})}function Nn(t){return O(Po,{...t,type:"function"})}function Rn(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 An(t,e){let n=O($o,{...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}},g=t._parse(i.data[f],p);if(g.success)c.push(g.data);else {let b=kn(g,f,a,l);if(b)return b}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function In(){return O(()=>true)}function ge(t,e){return B(e,"_parse",(n,o,r)=>(o=t(o),n(o,r))),e}function vn(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 g=t[p]._parse(s,a);if(g.success)return g;c.push(g);}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 g=c[p].errors;if(g?.length)for(let b=0;b<g.length;b++)g[b].cause?.key&&f.push(At(g[b],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),o}function Bn(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 Mn(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 wn(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 Ln={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 Ae(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(Ae(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 Ae(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(Ae(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}},Tn={},d={object:_n,string:It,number:vt,boolean:Bt,date:Mt,function:Nn,enum:Rn,array:An,any:In,preprocess:ge,union:vn,literal:Bn,contextRef:Mn,withContext:wn,coerce:Tn,cast:Ln};function Sn(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||Sn(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||Sn(c),e=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return B(this,"_parse",(u,f,p)=>{let g=u(f,p),{abortEarly:b}=Ge(p);if(!g.success)return g;let N=i(g.data);if(N===true||typeof N=="object"&&N?.success===true)return g;let k={message:typeof a=="function"?a(f):a};return {success:false,error:k,errors:[k]}}),this},clone(){return {...this}}};return Cn.length>0?Cn.reduce((i,a)=>a(i,t,r)??i,s):s}var Cn=[];var jo=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 Uo(t,e){let n=`block:${t}`;return e?.style==="UNORDERED"?`${n}:ul`:e?.style==="ORDERED"?`${n}:ol`:n}function On(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 jo.parse({component:o,id:r.id||Uo(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 On(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 Dn="molecule.external.ExternalComponent",Pn="namespace.unknown.UnknownComponent";var $n="molecule.headline.";var Lt=Dt(),Tt=Dt(),jn=Dt(),Ko=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function Dt(){return Math.floor(Math.random()*16777215)}function Fo(){return Tt=(Tt+1)%16777215,Tt}function X(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Fo(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Lt>>16&255,Lt>>8&255,Lt&255,jn>>8&255,jn&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=Ko[n.charCodeAt(r)];return o}var Ie=Symbol("block-element"),Ho=Symbol("block-element-body"),he=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 q(t){return t?ze(t.startContainer,Ie):null}function Un(t){return ze(t,Ie)}function Fn(t){return t?ze(t.startContainer,he):null}function Kn(t){return ze(t,he)}function Go(t){return t?t[he]!==void 0?[t]:[...t.children].filter(e=>e[he]!==void 0):[]}function qo(t,e){return e?Go(t).indexOf(e):-1}function Hn(t,e){let n=Fn(e);return !n||!t?.contains(n)?null:{element:n,index:qo(t,n)}}function Pt(){return window.getSelection()}function z(){let t=Pt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function $t(){let t=z();if(!t)return 0;t.collapse(true);let e=Fn(t),n=q(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 qn(t=z()){if(!t||t.collapsed)return null;let e=Un(t.startContainer),n=Un(t.endContainer);if(!e||!n)return null;let o=Kn(t.startContainer)??I(e),r=Kn(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 ne(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 P(t){if(!t?.[Ie])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[Ho])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 zn(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 Ke{state;element;mrakomor;constructor(e){super(e);let{state:n,observeDOMChanges:o=true}=e??{};this.state=n,this.element=null,this.mrakomor=xt(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 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 J(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 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 Xn(t){let e="",n=[],o=[];return (t??[]).forEach((r,s)=>{s>0&&(e+=`
5
- `);let i=e.length;e+=J(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 Jn(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=Hn(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 Je(t){let e=t?.component??"";return e===wt||e.startsWith($n)}function Kt(t,e){let n=J(t.properties.text),o=J(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}=Wn(i,o),{newLineState:l}=Wn(a,r),{state:u,cursor:f}=Kt(c,l);return s.splice(e,n-e+1,u),{content:s,cursor:f,resultIndex:e}}function Vn(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 Wn(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=Vn(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=Yn(t.properties.inlineStyleRanges,e),n.properties.entityRanges=Vn(t.properties.entityRanges,e),o.properties.entityRanges=Yn(t.properties.entityRanges,e),o.componentId=X(),{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:z(),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 Wo(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function Xo(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!Wo(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 Jo(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):[...Xo(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 Jo(t??[],s)}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:J(this.getState()?.properties?.text).length;ne(this.element,o);};n(),A(n);}onKeydown(e){}static toExchangeState(e){let n=e?.properties,o={text:J(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=Xn(n?.properties?.items);return Kt(e,Jn(o))}};var re=class t extends Qe{static get NAMESPACE(){return Dn}static getStateSchema(e){return d.object({component:d.string().default(t.NAMESPACE),componentId:d.string().default(e?.getAttribute("data-componentid")||X()),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 Pn}onMount(){let e=E("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);Z(this.root,e);}onUnmount(){this.root.innerHTML="";}};function Qo(t,e){let n=t._getBlockElementByComponentId(e);return P(n)?.isStale?.()??false}function oo(t){return (e,n)=>{if(!ie(e,n))return false;let o=n?.componentId??e?.componentId;return !(o&&Qo(t,o))}}function ro({mrakomor:t}){let e=t.get(),n=oo(e);yt(We,e);let o=Y(r=>{e._setContentRoot(r??null);});return Pe(()=>{e._onMount();}),$e(()=>{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;Pe(()=>{i.getNodeComponent=()=>{let l=I(i);return l?se(l):null},e._setBlockElement(i,s);}),$e(()=>{e._removeBlockElement(i);});let a=e.resolveComponent(r.get().component,r),c=e.wrapBlockElement(a);return E("div",{className:"mrakomor-block-element",[Ie]:true,$ref:l=>{i=l;}},c)}),{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 Zo(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(q(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"&&P(e._getBlockElements()[u])?.setCursor?.(c);});}function er(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?q(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&&ne(u,s);});}function tr(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;Ze(e,n,{...c,component:o,componentId:X()});}function nr(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 or(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=q(o);ne(I(s),0);});}function rr(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 sr(t){let{mrakomor:e,namespace:n,state:o}=t,r=t.range??z(),s=t.blockElement??q(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 g=jt(a,c,u,{entityRanges:p});Ze(e,s,g);}function ir(t){let{mrakomor:e,style:n}=t,o=t.range??z(),r=t.blockElement??q(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});Ze(e,r,p);}function ar(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);if(!p)return;i.splice(s,1),i.splice(r,1,e.normalizeComponentState(p.state)),e._setContentState(i);let g=()=>{if(typeof p.cursor!="number")return;let b=e._getBlockElements()[r]??o,N=P(b);if(N?.setCursor){N.setCursor(p.cursor);return}let k=I(b);k?.isConnected&&ne(k,p.cursor);};g(),A(g);}function cr(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 lr(t){let e=z();return q(e)?.getNodeComponent?.()?.classInstance?.onKeydown?.(t)}function ur(t){P(t)?.setCursor?.();}function fr(t){if(t.key!=="Backspace")return;let{mrakomor:e}=t,n=z();if(!n)return;let o=q(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=!J(l?.textContent),f=n.collapsed&&(n.startOffset===0||$t()===0||u);if(!n.collapsed){let h=qn(n);if(h&&h.startBlock!==h.endBlock){let y=e._getBlockElementIndex(h.startBlock),_=e._getBlockElementIndex(h.endBlock),S=e.getContent(),x=y>=0?S[y]:void 0,R=_>=0?S[_]:void 0;if(y>=0&&_>y&&typeof x?.properties?.text=="string"&&typeof R?.properties?.text=="string"){t.preventDefault();let{content:U,cursor:xe,resultIndex:at}=Qn(S,{startIndex:y,endIndex:_,startOffset:h.startOffset,endOffset:h.endOffset});e._setContentState(U.map(Q=>e.normalizeComponentState(Q))),A(()=>{let Q=e._getBlockElements()[at];Q&&typeof xe=="number"&&ne(I(Q),xe);});}}return}if(!f)return;let p=e._getBlockElementIndex(o),g=s?e._getBlockElementIndex(s):-1,b=e._getBlockElementState(o),N=e._getBlockElementState(s),k=s?P(s):null;if(!s||g<0){t.preventDefault();return}if(N&&b&&Je(b)&&k&&!k.isAtomic?.()){if(u&&!Je(N)){t.preventDefault();let h=e.getContent();h.splice(p,1),e._setContentState(h),ur(s);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:n});return}k?.isAtomic?.()&&(!a&&n.startOffset===0||o?.textContent==="\xA0"&&!c)&&(t.preventDefault(),e.command.removeBlockElement({blockElement:s,range:n})),b&&!Je(b)&&t.preventDefault();}function et(t){return {resolveComponent:e=>e===re.NAMESPACE?re:ye,registerCommands(e){e.emitter.on(m.INSERT_BLOCK_ELEMENT,T(Zo)),e.emitter.on(m.REPLACE_BLOCK_ELEMENT,T(er)),e.emitter.on(m.TRANSFORM_BLOCK_ELEMENT,T(tr)),e.emitter.on(m.MOVE_BLOCK_ELEMENT,T(nr)),e.emitter.on(m.REMOVE_BLOCK_ELEMENT,T(or)),e.emitter.on(m.REMOVE_ENTITY_RANGE,T(rr)),e.emitter.on(m.INSERT_ENTITY_RANGE,T(sr)),e.emitter.on(m.INSERT_INLINE_STYLE_RANGE,T(ir)),e.emitter.on(m.MERGE_BLOCK_ELEMENT,T(ar));},registerHandlers(e){e.emitter.on(m.FOCUSOUT,cr),e.emitter.on(m.KEYDOWN,T(lr)),e.emitter.on(m.KEYDOWN,T(fr));},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=Z(s,o);return {container:s,dispose:i??null}}function tt(t,e,n){return mr(t,".mrakomor-tools-container",e,n)}var so="mrakomor.dialog.Dialog";function nt({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"}},[Re(()=>t.get()&&e.get()==="center",E("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:a})),Re(()=>t.get(),E("div",{className:"mrakomor-dialog-container",contenteditable:false,style:i,$ref:s},()=>r.get()))])}nt.NAMESPACE=so;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=Y(null),l=Y(null);function u(){o.set(false),r.set("anchor"),c.set(null),A(()=>{n.set(false);});}return {resolveComponent(f){if(f===so)return nt},registerEvents(){m.OPEN_DIALOG="mrakomor:open-dialog",m.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(p,g)=>{f.emit(m.OPEN_DIALOG,{...p,options:g});},f.command.closeDialog=()=>{f.emit(m.CLOSE_DIALOG);};},registerHandlers(){t.emitter.on(m.OPEN_DIALOG,({children:f,element:p,options:g={}})=>{a.set(f??E("div",{},"Empty dialog")),o.set(true),c.set(p??null),r.set(g.placement??"anchor"),A(()=>{let b=t.getRoot(),{x:N,y:k}=g.placement==="center"?zn(b,l):Ye(b,p??{left:0,top:0},l);s.set(N),i.set(k),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,g=l&&typeof l.contains=="function"&&l.contains(p),b=c&&typeof c.contains=="function"&&c.contains(p);!g&&!b&&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 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 rt=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 Re(()=>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 st({mrakomor:t}){let e=null,n=null,o=Y(null),r=null,s=C(false),i=C(false),a=C(0),c=C(0),l=C([]),u=C(-1),f=C("Menu");function p(h){A(()=>{let y=t.getRoot();if(!y||!h)return;let _=o?.offsetHeight??200,S=y.getBoundingClientRect();if(h.top-S.top>_+8){let{x:R,y:v}=Ye(y,h,{offsetHeight:_},4);a.set(R),c.set(v);}else a.set(h.left-S.left),c.set(h.bottom-S.top+4);s.set(true);});}function g(){i.set(false),r=null,u.set(-1),l.set([]),A(()=>{s.set(false);});}function b(h){!h||!r||r(h);}function N(h){if(i.peek()!==true)return;let y=h.target?.closest?.(".mrakomor-menu__item");if(!y||!n?.contains(y))return;h.preventDefault(),h.stopPropagation();let _=y.getAttribute("data-id"),S=l.peek().find(x=>x.id===_);S&&b(S);}function k(h={}){let{entries:y=[],anchorRect:_,highlightIndex:S=-1,ariaLabel:x="Menu",onSelect:R=null}=h;l.set(y),u.set(S),f.set(x),R!==void 0&&(r=R),i.set(true),_?p(_):s.set(true);}return {registerEvents(){m.OPEN_MENU="mrakomor:open-menu",m.CLOSE_MENU="mrakomor:close-menu",m.UPDATE_MENU="mrakomor:update-menu";},registerCommands(h){h.command.openMenu=y=>{h.emit(m.OPEN_MENU,y);},h.command.updateMenu=y=>{h.emit(m.UPDATE_MENU,y);},h.command.closeMenu=()=>{h.emit(m.CLOSE_MENU);};},registerHandlers(){t.emitter.on(m.OPEN_MENU,k),t.emitter.on(m.UPDATE_MENU,k),t.emitter.on(m.CLOSE_MENU,g),t.emitter.on(m.CLICK,h=>{let y=o?.current??o;i.peek()===true&&s.peek()===true&&y&&typeof y.contains=="function"&&!y.contains(h.target)&&g();}),t.emitter.on(m.KEYDOWN,h=>{h.key==="Escape"&&i.peek()===true&&g();});},onMount(){let{container:h,dispose:y}=tt(t,"mrakomor-menu-plugin-container",E(Ft,{open:i,positionX:a,positionY:c,entries:l,highlightIndex:u,ariaLabel:f,menuRef:o}));n=h,n?.addEventListener("click",N),e=y;},onUnmount(){n?.removeEventListener("click",N),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!==ot&&e!==st&&e!==et),ot,st,et]}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 it(n);return o._init(),o}var it=class{#e=X();#n;#r=null;#t=[];#o=[];#i;#c=false;listenerAbortController=new AbortController;#a=C([],{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 rt(this)};let{emitter:s,command:i}=yn({mrakomor:this});this.command=i,this.emitter=s;}_init(){this.#u(),this.#a=C(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:g,detail:b,isTrusted:N,target:k,relatedTarget:h,data:y,inputType:_}=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:p,which:g,detail:b,isTrusted:N,target:k,relatedTarget:h,data:y,inputType:_});return S&&n?.preventDefault?.(),S}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=>P(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=>structuredClone(this.normalizeComponentState(n)))??[]}_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 P(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 P(this.#o[n])?.getState()}mount(){let e=Z(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){let n="component"in e?e.component:e.entity.type;return this.resolveComponentConstructor(n)?.getStateSchema()?.parse(e)}};exports.Bold=le;exports.Dialog=nt;exports.EVENT=m;exports.Italic=ue;exports.Menu=Ft;exports.Mrakomor=it;exports.Subscript=fe;exports.Superscript=me;exports.Underline=pe;exports.createMrakomor=hr;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;