@mrakomor/core 0.0.11 → 0.0.13

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 (113) 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-4WTPDNPA.mjs +1 -0
  5. package/dist/chunk-5AD5MQXI.mjs +1 -0
  6. package/dist/{chunk-K2DMHAUD.mjs → chunk-7CJLTNHZ.mjs} +1 -1
  7. package/dist/{chunk-VYTSZ4S6.mjs → chunk-B2UFH244.mjs} +1 -1
  8. package/dist/chunk-BWK2S4UI.mjs +2 -0
  9. package/dist/chunk-D6K2L5O3.mjs +4 -0
  10. package/dist/{chunk-NR2BAMSW.mjs → chunk-DHFIX7FW.mjs} +2 -2
  11. package/dist/chunk-ERNLRJPB.mjs +1 -0
  12. package/dist/chunk-EXDY5TZH.mjs +1 -0
  13. package/dist/chunk-J4TTWQ6J.mjs +2 -0
  14. package/dist/{chunk-2VURZA2E.mjs → chunk-SG5PCGIV.mjs} +1 -1
  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 +3 -3
  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.cjs +1 -1
  23. package/dist/help.mjs +2 -2
  24. package/dist/index.cjs +6 -6
  25. package/dist/index.mjs +4 -4
  26. package/dist/link.mjs +2 -2
  27. package/dist/list.cjs +3 -3
  28. package/dist/list.mjs +1 -1
  29. package/dist/paragraph.cjs +2 -2
  30. package/dist/paragraph.mjs +1 -1
  31. package/dist/slashCommand.cjs +2 -2
  32. package/dist/slashCommand.mjs +1 -1
  33. package/dist/tooltip.cjs +1 -1
  34. package/dist/tooltip.mjs +2 -2
  35. package/dist/tts.cjs +8 -8
  36. package/dist/tts.mjs +3 -3
  37. package/dist/types/Mrakomor.d.mts +230 -0
  38. package/dist/types/component/AbstractComponent.d.mts +69 -0
  39. package/dist/types/component/Editor.d.mts +8 -0
  40. package/dist/types/component/block/BlockComponent.d.mts +105 -0
  41. package/dist/types/component/block/BlockRegister.d.mts +29 -0
  42. package/dist/types/component/block/ExternalComponent.d.mts +42 -0
  43. package/dist/types/component/block/UnknownComponent.d.mts +3 -0
  44. package/dist/types/component/block/blockItemEquals.d.mts +6 -0
  45. package/dist/types/component/block/helpers.d.mts +319 -0
  46. package/dist/types/component/editorContext.d.mts +4 -0
  47. package/dist/types/component/entityRange/EntityRangeElement.d.mts +15 -0
  48. package/dist/types/component/inlineStyle/Bold.d.mts +4 -0
  49. package/dist/types/component/inlineStyle/InlineElement.d.mts +10 -0
  50. package/dist/types/component/inlineStyle/Italic.d.mts +4 -0
  51. package/dist/types/component/inlineStyle/Subscript.d.mts +4 -0
  52. package/dist/types/component/inlineStyle/Superscript.d.mts +4 -0
  53. package/dist/types/component/inlineStyle/Underline.d.mts +4 -0
  54. package/dist/types/component/inlineStyle/index.d.mts +5 -0
  55. package/dist/types/component/overlayMount.d.mts +46 -0
  56. package/dist/types/dom.d.mts +169 -0
  57. package/dist/types/emitter.d.mts +38 -0
  58. package/dist/types/index.d.mts +7 -0
  59. package/dist/types/namespaces.d.mts +17 -0
  60. package/dist/types/plugin/blockChrome/BlockChrome.d.mts +11 -0
  61. package/dist/types/plugin/blockChrome/index.d.mts +1 -0
  62. package/dist/types/plugin/blockInsertMenu/BlockInsertMenu.d.mts +6 -0
  63. package/dist/types/plugin/blockInsertMenu/index.d.mts +1 -0
  64. package/dist/types/plugin/clipboard/clipboardHelpers.d.mts +151 -0
  65. package/dist/types/plugin/clipboard/clipboardPlugin.d.mts +6 -0
  66. package/dist/types/plugin/clipboard/index.d.mts +1 -0
  67. package/dist/types/plugin/default/defaultMrakomorPlugin.d.mts +21 -0
  68. package/dist/types/plugin/dialog/Dialog.d.mts +23 -0
  69. package/dist/types/plugin/footer/footerPlugin.d.mts +7 -0
  70. package/dist/types/plugin/footer/index.d.mts +1 -0
  71. package/dist/types/plugin/headline/Headline.d.mts +29 -0
  72. package/dist/types/plugin/headline/index.d.mts +1 -0
  73. package/dist/types/plugin/help/HelpRegister.d.mts +15 -0
  74. package/dist/types/plugin/help/helpPlugin.d.mts +26 -0
  75. package/dist/types/plugin/help/helpSchema.d.mts +11 -0
  76. package/dist/types/plugin/help/index.d.mts +1 -0
  77. package/dist/types/plugin/linkEntity/LinkEntity.d.mts +37 -0
  78. package/dist/types/plugin/linkEntity/index.d.mts +1 -0
  79. package/dist/types/plugin/list/List.d.mts +61 -0
  80. package/dist/types/plugin/list/index.d.mts +1 -0
  81. package/dist/types/plugin/list/listHelpers.d.mts +166 -0
  82. package/dist/types/plugin/menu/Menu.d.mts +22 -0
  83. package/dist/types/plugin/menu/menuPlugin.d.mts +6 -0
  84. package/dist/types/plugin/paragraph/Paragraph.d.mts +16 -0
  85. package/dist/types/plugin/paragraph/index.d.mts +1 -0
  86. package/dist/types/plugin/slashCommand/SlashActionRegister.d.mts +12 -0
  87. package/dist/types/plugin/slashCommand/index.d.mts +1 -0
  88. package/dist/types/plugin/slashCommand/slashActionSchema.d.mts +29 -0
  89. package/dist/types/plugin/slashCommand/slashCommandHelpers.d.mts +77 -0
  90. package/dist/types/plugin/slashCommand/slashCommandPlugin.d.mts +11 -0
  91. package/dist/types/plugin/slashCommand/slashHelp.d.mts +12 -0
  92. package/dist/types/plugin/tooltip/Tooltip.d.mts +16 -0
  93. package/dist/types/plugin/tooltip/index.d.mts +1 -0
  94. package/dist/types/plugin/tts/TtsHeadline.d.mts +27 -0
  95. package/dist/types/plugin/tts/TtsList.d.mts +19 -0
  96. package/dist/types/plugin/tts/TtsParagraph.d.mts +9 -0
  97. package/dist/types/plugin/tts/TtsVoice.d.mts +52 -0
  98. package/dist/types/plugin/tts/index.d.mts +4 -0
  99. package/dist/types/register/Register.d.mts +50 -0
  100. package/dist/types/register/sortRegisterEntries.d.mts +7 -0
  101. package/dist/types/schema/blockContent.d.mts +34 -0
  102. package/dist/types/schema/blockRegister.d.mts +14 -0
  103. package/dist/types/schema/config.d.mts +6 -0
  104. package/dist/types/types.d.mts +636 -0
  105. package/package.json +36 -22
  106. package/dist/chunk-5VPYPKGA.mjs +0 -1
  107. package/dist/chunk-BCE45I7Q.mjs +0 -2
  108. package/dist/chunk-N4I2WZWF.mjs +0 -1
  109. package/dist/chunk-SCFD3XBH.mjs +0 -1
  110. package/dist/chunk-T7OO472O.mjs +0 -1
  111. package/dist/chunk-WQWE5UCN.mjs +0 -1
  112. package/dist/chunk-YO4ZA6PJ.mjs +0 -2
  113. 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-J4TTWQ6J.mjs';import'./chunk-SG5PCGIV.mjs';import'./chunk-B2UFH244.mjs';import'./chunk-ZHOZPQZH.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-D6K2L5O3.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-4WTPDNPA.mjs';import'./chunk-7CJLTNHZ.mjs';
package/dist/help.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/help/help.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.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-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}
1
+ 'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/help/help.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.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-help-plugin-container{display:contents}.mrakomor-help{width:420px;max-width:calc(100vw - 32px);max-height:70vh;overflow:auto;border:1px solid #e4e7ec;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 #edf0f3;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 #edf0f3}.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 #e0e4ea;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
2
  `,document.head.appendChild(n);}}})();var me=class{next(...e){}error(...e){}complete(...e){}},te=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 U=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var h=null,ne=false,he=[];function C(e){let t=h;h=null;let n=e();return h=t,n}function Xe(){ne=false;let e=ye();for(let n of e)n.get();let t=he;he=[];for(let n of t)n();}function Ye(){ne||(ne=true,queueMicrotask(Xe));}var ge=Symbol("@esmj/signals:internal observable"),x=Symbol("@esmj/signals:original function"),Je=class extends te{#e=new Set;#o=null;constructor(e){super(),this.#o=e,this.pipe(t=>{let n=t.subscribe.bind(t),o=t.unsubscribe.bind(t);return t.subscribe=r=>{n(r),this.#e.add(r);},t.unsubscribe=r=>{o(r),this.#e.delete(r);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>C(()=>{this.#e.add(e),this.#o();}),e.next[x]=void 0),e instanceof we&&e.next[x]===void 0){let t=e.next.bind(e);e.next=()=>C(()=>{this.#e.add(e),t(),this.#o();}),e.next[x]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[x]){let n=t.get,o=n.bind(t);t.get=()=>C(()=>(this.#e.delete(t),o())),t.get[x]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[x]?e.next[x]:e.next,e.get=e.get[x]?e.get[x]:e.get,this.#e.delete(e),this.unsubscribe(e)}},B=null;function be(e){B=new Je(e);}be(()=>{Ye();});function ye(){return B.getPending()}function xe(e){return B.watch(e)}function ke(e){return B.unwatch(e)}var k=Symbol("@esmj/signals:no error"),we=class _e extends me{#e=true;#o=false;#n=null;#r=this.#p();#u=null;#l=null;#i=0;#s=new Map;#t=k;constructor(t,n){super(),this.#u=t,this.#l=n,this.debug=n?.debug,this[U]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#c(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.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 _e&&C(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[ge].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=E(this.#a(),this.#l)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),h&&h.sourceRevisions.set(this,this.#i),this.#t!==k)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=E(this.#a(),this.#l)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==k)throw this.#t;return this.#n.peek()}#a(){this.#o=true,this.#e=false,this.#t=k,this.#c(),this.#r.sourceRevisions.clear();let t=h;h=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return h=t,this.#s=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=k,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===k&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=k;}};function A(e,t){return new we(e,t)}function b(e,t){let n,{debug:o,...r}={},s=A(()=>{n?.(),n=e();},{equals:()=>false,...r});s.get(),xe(s);let i=()=>{n?.(),s.destroy(),ke(s);};return i[Symbol.dispose]=i,i[U]="effect",i[q]=o??null,i.__RX_COMPUTED__=s,i}function E(e,t={}){let n=t?.equals??Object.is,o=0,r=new te;function s(){return h&&(h.dependencies.set(r,r.subscribe(h.observer)),h.sourceRevisions.set(p,o)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,o++,r.next();}return e}function c(){return o}let p={get:s,set:a,peek:i,getRevision:c,[ge]:r,[U]:"signal",[q]:t?.debug??null};return p}function V(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Re=Symbol("node-component"),K=Symbol("node-internal"),Ze=Symbol("keep-literal"),Y=Symbol("raw-props");var Ie=null;function T(){return Ie}function W(e){Ie=e;}function Te(e){return e?.[Re]||null}function Se(e,t){e[Re]=t;}function G(e,t={disposers:[],id:V()}){return e?.[K]?e[K]:(e&&(e[K]=t),t)}function nt(e){return e[K]}function _(e,t){let n=nt(e);n||(n=G(e)),n.disposers.push(t);}function re(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function S(e,t){let n=T();W(e);try{return t()}finally{W(n);}}var se=new Map,X=new Map,ve=new Map;function $e(e,t){let n=typeof t=="function"?t:r=>!!t?.includes(r),o=Object.create(null);for(let r of Object.keys(e)){let s=e[r];r==="children"||n(r)?o[r]=s:s?.[Ze]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=A(s):o[r]=E(s);}return o}function D(e){let t=e.componentId,n=se.get(t);if(n){se.delete(t);for(let o of n){let r=o();typeof r=="function"&&re(X,t,r);}}}function ot(e){let t=X.get(e);if(t){X.delete(e);for(let n of t)n();}}function rt(e){let t=ve.get(e);if(t){ve.delete(e);for(let n of t)n();}}function Q(e){if(!e)return;let t=G(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=Te(e);if(n&&(ot(n.componentId),rt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;Q(o),o=r;}}}function M(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ne(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function st(e,t,n){let o=V(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=Ne(e)?void 0:e[Y],i={...$e(t??{},s),children:n},a=T(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};W(c);let p;if(Ne(e)){r.ClassConstructor=e;let f=new e(i);r.classInstance=f,typeof f.onMount=="function"&&re(se,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&re(X,o,()=>{f.onUnmount?.();}),p=f.render();}else p=e(i);W(a);let u=it(p);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)G(f,c),Se(f,r);else G(u,c),u instanceof Node&&Se(u,r);return u}};return r}function ce(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{D(t);});}function it(e){return e instanceof Node?e:M(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Ce={className:"class",htmlFor:"for"},Ee=new Set(["value","defaultValue","checked","selected","indeterminate"]),at=new Set(["srcdoc"]),lt=new Set(["href","src","action","formaction","xlink:href"]),ut=new Set(["securitypolicyviolation"]),ct=new Set(["contenteditable","draggable","spellcheck"]);function P(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Fe=Symbol("Fragment");function d(e,t,n){if(e===Fe){let r=document.createDocumentFragment();return ie(r,Me(n)),r}if(typeof e=="function")return st(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let o=document.createElement(e);return t.id&&o.setAttribute("id",t.id),Z(o,t),ie(o,Me(n)),o}function oe(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function ft(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function pt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return at.has(n)?true:lt.has(n)&&t!==null&&t!==void 0&&ft(String(t))}function Le(e){return typeof e!="string"?e:Ce[e]?Ce[e]:e}function dt(e,t){let n=Le(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return ct.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Ae(e,t,n){let o=dt(t,n);if(o===null){e.removeAttribute(t);return}if(pt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function Z(e,t){let n=T();for(let[o,r]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(o!=="id"){if(o=Le(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(P(r)){let s=b(()=>{S(n,()=>{oe(e,r.get());});});_(e,s);}else if(typeof r=="function"){let s=b(()=>{S(n,()=>{oe(e,r());});});_(e,s);}else oe(e,r);continue}if(o==="style"){if(P(r)){let s=b(()=>{S(n,()=>{Object.assign(e.style,r.get());});});_(e,s);}else typeof r=="object"&&r!==null?Object.assign(e.style,r):e.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(ut.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,r);continue}if(P(r)||typeof r=="function"){let s=o,i=b(()=>{S(n,()=>{let a=typeof r=="function"?r():r.get();Ee.has(s)?e[s]=a??"":Ae(e,s,a);});});_(e,i);continue}Ee.has(o)||typeof o=="symbol"?e[o]=r??"":Ae(e,o,r);}}function Me(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ie(e,t){for(let n of t)Oe(e,n);}function Oe(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"){je(e,t);return}if(M(t)){ce(e,t);return}if(P(t)){je(e,()=>t.get());return}if(Array.isArray(t)){ie(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function $(e){let t=null,n=e;return M(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 ee(e,t=true){for(let n of e)t&&Q(n),n.remove();}function je(e,t){let n=T(),o=document.createComment("");e.appendChild(o);let r=[],s=b(()=>{S(n,()=>{let i=t(),{nodes:a,instance:c}=$(i);ee(r),a.length&&o.after(...a),c&&queueMicrotask(()=>D(c)),r=a;});});_(e,s);}function Pe(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(Q(e),e.innerHTML=""),M(t)?ce(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function gt(e,t,n,o){let r=e.getRoot()?.querySelector(t);if(!r)return {container:null,dispose:null};let s=document.createElement("div");s.className=n,r.append(s);let i=Pe(s,o);return {container:s,dispose:i??null}}function De(e,t,n){return gt(e,".mrakomor-footer-end",t,n)}var F={id:"help",label:"Help",keywords:["help","shortcuts"],group:"help",order:1e4,description:"Show keyboard shortcuts and slash commands",handler:e=>{e.mrakomor.command.openHelp?.();}},bt=[{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 yt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):"General"}function ze(e){let t=new Map;for(let n of e){let o=n.group||"general",r=t.get(o)??[];r.push(n),t.set(o,r);}return t}function Ue(e){let t=ze(e),n=[];for(let[o,r]of t)n.push(d("section",{className:"mrakomor-help__section","data-group":o},[d("h3",{className:"mrakomor-help__group"},yt(o)),d("ul",{className:"mrakomor-help__list"},r.map(s=>d("li",{className:"mrakomor-help__item","data-help-id":s.id},[d("div",{className:"mrakomor-help__description"},s.description),d("div",{className:"mrakomor-help__keys"},[...(s.commands??[]).map(i=>d("kbd",{className:"mrakomor-help__kbd"},i)),...(s.shortcuts??[]).map(i=>d("kbd",{className:"mrakomor-help__kbd"},i))])])))]));return d("div",{className:"mrakomor-help",role:"document","aria-label":"Editor help"},[d("header",{className:"mrakomor-help__header"},[d("h2",{className:"mrakomor-help__title"},"Help"),d("p",{className:"mrakomor-help__subtitle"},"Keyboard shortcuts and slash commands")]),d("div",{className:"mrakomor-help__body"},n)])}function xt({mrakomor:e}){let t=null;function n(o={}){e.command.openDialog?.({element:o.element??null,children:Ue(e.register.help.list())},{placement:"center"});}return {registerCommands(o){o.command.openHelp=n;let r=e.register.slashActions;r&&!r.has(F.id)&&r.add(F);for(let s of bt)e.register.help.add(s);e.register.help.add({id:F.id,group:F.group,description:F.description,commands:["/help"],shortcuts:[]});},onMount(){let{dispose:o}=De(e,"mrakomor-help-plugin-container",d("button",{type:"button",className:"mrakomor-footer-action mrakomor-help-trigger","aria-label":"Open help",title:"Keyboard shortcuts and commands",onClick:r=>{n({element:r.currentTarget});}},[d("span",{className:"mrakomor-footer-action__icon","aria-hidden":"true"},"?"),"Help"]));t=o;},onUnmount(){t?.(),t=null;}}}exports.HELP_SLASH_ACTION=F;exports.buildHelpDialogContent=Ue;exports.groupHelpEntries=ze;exports.helpPlugin=xt;
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 #e4e7ec;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 #edf0f3;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 #edf0f3}.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 #e0e4ea;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 Ht=class{next(...t){}error(...t){}complete(...t){}},xe=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"),be=Symbol("@esmj/signals:name");var T=null,st=false,it=[];function G(t){let e=T;T=null;let n=t();return T=e,n}function ho(){st=false;let t=Yt();for(let n of t)n.get();let e=it;it=[];for(let n of e)n();}function zt(){st||(st=true,queueMicrotask(ho));}function ct(t){it.push(t),zt();}var Gt=Symbol("@esmj/signals:internal observable"),H=Symbol("@esmj/signals:original function"),Eo=class extends xe{#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=()=>G(()=>{this.#e.add(t),this.#n();}),t.next[H]=void 0),t instanceof Xt&&t.next[H]===void 0){let e=t.next.bind(t);t.next=()=>G(()=>{this.#e.add(t),e(),this.#n();}),t.next[H]=e;}return this.subscribe(t)}getPending(){let t=[];for(let e of this.#e){if(!e.get[H]){let n=e.get,o=n.bind(e);e.get=()=>G(()=>(this.#e.delete(e),o())),e.get[H]=n;}t.push(e);}return t}unwatch(t){return t.next=t.next[H]?t.next[H]:t.next,t.get=t.get[H]?t.get[H]:t.get,this.#e.delete(t),this.unsubscribe(t)}},ve=null;function qt(t){ve=new Eo(t);}qt(()=>{zt();});function Yt(){return ve.getPending()}function Vt(t){return ve.watch(t)}function Wt(t){return ve.unwatch(t)}var z=Symbol("@esmj/signals:no error"),Xt=class Jt extends Ht{#e=true;#n=false;#r=null;#t=this.#f();#o=null;#i=null;#a=0;#c=new Map;#s=z;constructor(e,n){super(),this.#o=e,this.#i=n,this.debug=n?.debug,this[Be]="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.#a}getDebugInfo(){return {name:this[be],dirty:this.#e,revision:this.#a,sourceDependencies:[...this.#c.keys()]}}#l(){for(let[e,n]of this.#c)if(e instanceof Jt&&G(()=>e.get()),e.getRevision()!==n)return true;return false}next(){this.#e=true,this.#r[Gt].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!==z)&&(this.#c.size===0||this.#l()?this.#m():this.#e=false),T&&T.sourceRevisions.set(this,this.#a),this.#s!==z)throw this.#s;return this.#r.get()}peek(){if(this.#r||(this.#r=S(this.#m(),this.#i)),(this.#e||this.#s!==z)&&(this.#c.size===0||this.#l()?this.#m():this.#e=false),this.#s!==z)throw this.#s;return this.#r.peek()}#m(){this.#n=true,this.#e=false,this.#s=z,this.#u(),this.#t.sourceRevisions.clear();let e=T;T=this.#t;let n;try{n=this.#o();}catch(o){this.#s=o;}return T=e,this.#c=this.#t.sourceRevisions,this.#t.sourceRevisions=new Map,this.#n=false,n instanceof Promise&&(n=n.then(o=>{this.#s=z,this.#r.set(o);}).catch(o=>{this.#s=o;})),this.#s===z&&this.#r&&this.#r.set(n),this.#a++,n}destroy(){this.#u(),this.#c.clear(),this.#e=true,this.#s=z;}};function L(t,e){return new Xt(t,e)}function P(t,e){let n,{debug:o,...r}={},s=L(()=>{n?.(),n=t();},{equals:()=>false,...r});s.get(),Vt(s);let i=()=>{n?.(),s.destroy(),Wt(s);};return i[Symbol.dispose]=i,i[Be]="effect",i[be]=o??null,i.__RX_COMPUTED__=s,i}function S(t,e={}){let n=e?.equals??Object.is,o=0,r=new xe;function s(){return T&&(T.dependencies.set(r,r.subscribe(T.observer)),T.sourceRevisions.set(l,o)),t}function i(){return t}function c(u){if(!n(t,u)){t=u,o++,r.next();}return t}function a(){return o}let l={get:s,set:c,peek:i,getRevision:a,[Gt]:r,[Be]:"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"),yo=Symbol("keep-literal"),De=Symbol("raw-props");function ut(t){return typeof t=="function"?t:t!=null&&typeof t.get=="function"?()=>t.get():()=>t}function ft(t,e){let n=t.children!==void 0?t.children:e;return Array.isArray(n)?n[0]:n}var xo=new Set(["template","script"]);function bo(t,e){let n=(t==null?"span":String(t)).trim(),o=n;xo.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 mt(t,e,n){let o=bo(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,c){if(Reflect.has(s,i))return Reflect.get(s,i,c);if(!e)return;let a=e[i];return typeof a=="function"?a.bind(e):a},set(s,i,c,a){return Reflect.has(s,i)||!e?Reflect.set(s,i,c,a):(e[i]=c,true)},has(s,i){return Reflect.has(s,i)||!!e&&i in e}})}var an=null;function j(){return an}function Le(t){an=t;}function se(t){return t?.[cn]||null}function Qt(t,e){t[cn]=e;}function Te(t,e={disposers:[],id:Me()}){return t?.[we]?t[we]:(t&&(t[we]=e),e)}function So(t){return t[we]}function q(t,e){let n=So(t);n||(n=Te(t)),n.disposers.push(e);}function Ce(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n);}function V(t,e){let n=j();Le(t);try{return e()}finally{Le(n);}}var Oe=new Map,_e=new Map,Zt=new Map;function ln(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?.[yo]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=L(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 c="value"in s?s.value:s.get?.call(t),a="value"in i?i.value:i.get?.call(e);return ie(c,a)})}function pt(t){return {id:Symbol("context-id"),defaultValue:t}}function dt(t,e){let n=j();n&&n.contexts.set(t.id,e);}function gt(t){let e=j();return e?.contexts?.has(t.id)?e.contexts.get(t.id):t.defaultValue}function Pe(t){let e=j();if(!e){console.warn("onMount called outside of a component context");return}Ce(Oe,e.id,t);}function $e(t){let e=j();if(!e){console.warn("onUnmount called outside of a component context");return}Ce(_e,e.id,t);}function R(t){ct(()=>{setTimeout(t,0);});}function ce(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"&&Ce(_e,e,r);}}}function ko(t){let e=_e.get(t);if(e){_e.delete(t);for(let n of e)n();}}function Co(t){let e=Zt.get(t);if(e){Zt.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&&(ko(n.componentId),Co(n.componentId)),t.childNodes){let o=t.firstChild;for(;o;){let r=o.nextSibling;Ne(o),o=r;}}}function X(t){return t!=null&&typeof t=="object"&&typeof t.$constructor=="function"}function en(t){return typeof t=="function"&&typeof t.prototype?.render=="function"}function _o(t,e,n){let o=Me(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=en(t)?void 0:t[De],i={...ln(e??{},s),children:n},c=j(),a={disposers:[],id:o,contexts:new Map(c?.contexts)};Le(a);let l;if(en(t)){r.ClassConstructor=t;let f=new t(i);r.classInstance=f,typeof f.onMount=="function"&&Ce(Oe,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Ce(_e,o,()=>{f.onUnmount?.();}),l=f.render();}else l=t(i);Le(c);let u=No(l);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)Te(f,a),Qt(f,r);else Te(u,a),u instanceof Node&&Qt(u,r);return u}};return r}function ht(t,e){let n=e.$constructor();n instanceof Node&&t.appendChild(n),queueMicrotask(()=>{ce(e);});}function No(t){return t instanceof Node?t:X(t)?t.$constructor():typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):document.createTextNode("")}var tn={className:"class",htmlFor:"for"},nn=new Set(["value","defaultValue","checked","selected","indeterminate"]),Ro=new Set(["srcdoc"]),Ao=new Set(["href","src","action","formaction","xlink:href"]),Io=new Set(["securitypolicyviolation"]),Bo=new Set(["contenteditable","draggable","spellcheck"]);function ke(t){return t!=null&&typeof t=="object"&&typeof t.get=="function"&&!(t instanceof Node)}var un=Symbol("Fragment");function h(t,e,n){if(t===un){let r=document.createDocumentFragment();return lt(r,rn(n)),r}if(typeof t=="function")return _o(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),lt(o,rn(n)),o}function at(t,e){e instanceof DocumentFragment?t.replaceChildren(e):t.innerHTML=e??"";}function vo(t){return typeof t!="string"?false:t.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Mo(t,e){if(typeof t!="string")return false;let n=t.toLowerCase();return Ro.has(n)?true:Ao.has(n)&&e!==null&&e!==void 0&&vo(String(e))}function fn(t){return typeof t!="string"?t:tn[t]?tn[t]:t}function wo(t,e){let n=fn(t),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Bo.has(o)&&(e===true||e===false||e==="true"||e==="false")?String(e):e==null||e===false?null:e}function on(t,e,n){let o=wo(e,n);if(o===null){t.removeAttribute(e);return}if(Mo(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=j();for(let[o,r]of Reflect.ownKeys(e).map(s=>[s,e[s]]))if(o!=="id"){if(o=fn(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,()=>{at(t,r.get());});});q(t,s);}else if(typeof r=="function"){let s=P(()=>{V(n,()=>{at(t,r());});});q(t,s);}else at(t,r);continue}if(o==="style"){if(ke(r)){let s=P(()=>{V(n,()=>{Object.assign(t.style,r.get());});});q(t,s);}else typeof r=="object"&&r!==null?Object.assign(t.style,r):t.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(Io.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 c=typeof r=="function"?r():r.get();nn.has(s)?t[s]=c??"":on(t,s,c);});});q(t,i);continue}nn.has(o)||typeof o=="symbol"?t[o]=r??"":on(t,o,r);}}function rn(t){return t==null?[]:Array.isArray(t)?t.flat(Number.POSITIVE_INFINITY):[t]}function lt(t,e){for(let n of e)mn(t,n);}function mn(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"){sn(t,e);return}if(X(e)){ht(t,e);return}if(ke(e)){sn(t,()=>e.get());return}if(Array.isArray(e)){lt(t,e);return}t.appendChild(document.createTextNode(String(e)));}}function ae(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 Ue(t,e=true){for(let n of t)e&&Ne(n),n.remove();}function sn(t,e){let n=j(),o=document.createComment("");t.appendChild(o);let r=[],s=P(()=>{V(n,()=>{let i=e(),{nodes:c,instance:a}=ae(i);Ue(r),c.length&&o.after(...c),a&&queueMicrotask(()=>ce(a)),r=c;});});q(t,s);}var Ke=class{constructor(t){this.props=t;}};function pn(t,e,n,o){let{equals:r=ie,tagName:s="span",...i}=o??{},c=mt(s,"data-for",i);je(c,i);let a=j(),l=[],u=new Map,f=L(()=>t()),m=P(()=>{let d=f.get(),x=Array.isArray(d)?d:[],C=[],_=[],E=new Set;for(let y=0;y<x.length;y++){let k=x[y],w=e(k,y);if(E.has(w)){console.error(`For: duplicate key "${String(w)}" detected; ignoring later item at index ${y}`);continue}E.add(w),C.push(k),_.push(w);}let b=new Map(l.map(y=>[y.key,y])),A=[];for(let y=0;y<C.length;y++){let k=_[y],w=C[y],Q=b.get(k);if(Q)u.get(k).set(w),A.push(Q),b.delete(k);else {let Ut=S(w,{equals:r});u.set(k,Ut);let uo={...Ut,set(){}},Kt={key:k,nodes:[]};V(a,()=>{let fo=n(uo,y),{nodes:mo,instance:Ft}=ae(fo);Kt.nodes=mo,Ft&&queueMicrotask(()=>ce(Ft));}),A.push(Kt);}}for(let[y,k]of b)Ue(k.nodes),u.delete(y);let N=null;for(let y=A.length-1;y>=0;y--){let k=A[y].nodes;for(let w=k.length-1;w>=0;w--){let Q=k[w];(Q.parentNode!==c||Q.nextSibling!==N)&&c.insertBefore(Q,N),N=Q;}}l=A;});return q(c,m),c}function Et(t,e,n,o){if(typeof t=="function")return pn(t,e,n,o);let{each:r,keyFn:s,equals:i,tagName:c,children:a,...l}=t??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=ut(r),f=ft(t??{},e);return pn(u,s,f,{...l,equals:i,tagName:c})}Et[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=""),X(e)?ht(t,e):e instanceof Node?t.appendChild(e):t.appendChild(document.createTextNode(String(e)));}function gn(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(X(e)?(n=e.$constructor(),queueMicrotask(()=>ce(e))):e instanceof Node?n=e:n=document.createTextNode(String(e)),n instanceof HTMLElement){let o=L(()=>!!t()),r=P(()=>{n.style.display=o.get()?"":"none";});q(n,r);}return n}var O=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 h(this.constructor.nodeName,{},this.props.children)}};var le=class extends O{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return h("b",{},"B")}static match(e){return e.nodeName==="strong"?true:super.match(e)}};var ue=class extends O{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return h("i",{},"I")}};var fe=class extends O{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return h("sub",{},"Sub")}};var me=class extends O{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return h("sup",{},"Sup")}};var pe=class extends O{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return h("u",{},"U")}};var U=Symbol("result-key"),Fe=Symbol("stopped-event");function hn(t,e){let n=!!e.name,o=e[U]||"result",r=o.includes("."),s={error:null,context:{},[U]:o,...e,[o]:n?void 0:ee(e,o),name:t,[Fe]:false,defaultPrevented:false};return r&&(To(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 yt(t,e,n){let o=e.split("."),r=o.pop(),s=ee(t,o.join("."));return s[r]=n}function To(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=hn(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 c of o){if(s&&(s=s.then(a=>(yt(r,r[U],a??ee(r,r[U])),r[Fe]?ee(r,r[U]):c(r)))),!s){if(r[Fe])return r;i=c(r);}i instanceof Promise&&!s?s=i:yt(r,r[U],i??ee(r,r[U]));}return s?s.then(c=>(yt(r,r[U],c??ee(r,r[U])),r)):r}emitParallel(e,n={}){let o=this.listeners(e),r=hn(e,n);return Promise.all(o.map(async s=>await s(r))).then(s=>(r[r[U]]=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 p={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 B(t){return e=>{if(!e.defaultPrevented)return t(e)}}function En({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(p.INSERT_BLOCK_ELEMENT,{...o,options:r});},replaceBlockElement(o,r){n(p.REPLACE_BLOCK_ELEMENT,{...o,options:r});},removeBlockElement(o,r){n(p.REMOVE_BLOCK_ELEMENT,{...o,options:r});},mergeBlockElement(o,r){n(p.MERGE_BLOCK_ELEMENT,{...o,options:r});},insertEntityRange(o,r){n(p.INSERT_ENTITY_RANGE,{...o,options:r});},removeEntityRange(o,r){n(p.REMOVE_ENTITY_RANGE,{...o,options:r});},insertInlineStyleRange(o,r){n(p.INSERT_INLINE_STYLE_RANGE,{...o,options:r});},transformBlockElement(o,r){n(p.TRANSFORM_BLOCK_ELEMENT,{...o,options:r});},moveBlockElement(o,r){n(p.MOVE_BLOCK_ELEMENT,{...o,options:r});}}}}function yn(t){return t.map((e,n)=>({entry:e,index:n})).sort((e,n)=>{let o=e.entry.order??e.index,r=n.entry.order??n.index;return o!==r?o-r:e.index-n.index}).map(({entry:e})=>e)}var de=class extends xe{mrakomor;#e=new Map;#n=null;#r=0;#t;constructor(e,n={}){super(),this.mrakomor=e,this.#t=n.sort??yn;}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 Oo={abortEarly:true};function Ct(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 Do(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(Ct(t.errors[o],n));}function Sn(t,e,n,o){if(n!==false){let r=Ct(t.error,e);return {success:false,error:r,errors:[r]}}Do(t,o,e);}function ze(t){return t?.abortEarly!==void 0?t:Oo}function xt(t,e){v(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,bt=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),St=t=>t===true||t===false,Po=t=>t instanceof Date&&!Number.isNaN(t.getTime()),$o=t=>typeof t=="function",jo=t=>Array.isArray(t),kt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function kn(t,e){let n=D(kt,{...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 v(this,"_parse",(i,c,a)=>{let l=i(c,a);if(!l.success)return l;let u=r(l.data,{context:a?.context});if(!kt(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 m in u)f[m]===void 0&&(f[m]=u[m]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},v(n,"_parse",(r,s,i)=>{let c=r(s,i),{abortEarly:a}=ze(i);if(c.success===false)return c;let l={},u=[];for(let f in t){let m=t[f]._parse(c.data[f],i);if(m.success)l[f]=m.data;else {let d=Sn(m,f,a,u);if(d)return d}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),o}function _t(t){return D(Ae,{...t,type:"string"})}function Nt(t){return D(bt,{...t,type:"number"})}function Rt(t){return D(St,{...t,type:"boolean"})}function At(t){return D(Po,{...t,type:"date"})}function Cn(t){return D($o,{...t,type:"function"})}function _n(t,e){let n=i=>t.includes(i),o=i=>`Invalid ${r} value. Expected ${t.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,r="enum",s=D(n,{message:o,...e,type:r});return s._getDescription=()=>`enum(${t.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>t,s}function Nn(t,e){let n=D(jo,{...e,type:"array"});return n._getDescription=()=>`array(${t._getDescription()})`,n._getDefinition=()=>t,v(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:c}=ze(s);if(i.success===false)return i;let a=[],l=[],u=s;for(let f=0;f<i.data.length;f++){let m={...u,context:{...u?.context,index:f}},d=t._parse(i.data[f],m);if(d.success)a.push(d.data);else {let x=Sn(d,f,c,l);if(x)return x}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:a}}),n}function Rn(){return D(()=>true)}function ge(t,e){return v(e,"_parse",(n,o,r)=>(o=t(o),n(o,r))),e}function An(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: ${kt(r)?JSON.stringify(r):`"${r}"`}`,o=D(()=>false,{message:n,...e,type:"union"});return o._getDefinition=()=>t,v(o,"_parse",(r,s,i)=>{let c=i,a=[];for(let m=0;m<t.length;m++){let d=t[m]._parse(s,c);if(d.success)return d;a.push(d);}let{abortEarly:l}=ze(c),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let m=0;m<a.length;m++){let d=a[m].errors;if(d?.length)for(let x=0;x<d.length;x++)d[x].cause?.key&&f.push(Ct(d[x],`branch ${m}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),o}function In(t,e){let n=D(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=D(()=>true,{type:"contextRef"});return e._getDescription=()=>`contextRef("${t}")`,v(e,"_parse",(n,o,r)=>({success:true,data:r?.context?.[t]})),e}function vn(t,e){return {parse(n,o){let r=t.parse(o?.context??{},o);return e(r).parse(n,o)},safeParse(n,o){let r=t.safeParse(o?.context??{},o);return r.success?e(r.data).safeParse(n,o):r}}}var Mn={boolean(t){let e=t?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return 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},Rt({...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(St(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},Nt({...t,message:e}))},string(t){let e=t?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return ge(n=>St(n)||bt(n)&&Number.isFinite(n)?String(n):n,_t({...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()),bt(n)&&Number.isFinite(n)||o?new Date(o??n):n},At({...t,message:e}))},json(t,e){let n=e?.message??(o=>`Cannot parse "${o}" as JSON.`);return v(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}},wn={},g={object:kn,string:_t,number:Nt,boolean:Rt,date:At,function:Cn,enum:_n,array:Nn,any:Rn,preprocess:ge,union:An,literal:In,contextRef:Bn,withContext:vn,coerce:wn,cast:Mn};function xn(t){return e=>`The value "${e}" must be type of ${t} but is type of "${typeof e}".`}function v(t,e,n){let o=t[e];t[e]=(...r)=>n(o,...r);}function D(t,{type:e="any",name:n,message:o}={}){o=o||xn(e);let r={name:n,message:o,type:e},s={_getName(){return n},_getType(){return e},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let a=t(i);if(a===true)return {success:true,data:i};if(typeof a=="object"&&a?.success===true)return a;let l={message:typeof o=="function"?o(i):o};return {success:false,error:l,errors:[l]}},parse(i,c){let a=this._parse(i,c);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(i,c){return this._parse(i,c)},transform(i){return v(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return xt(this,i=>i===void 0),this},nullable(){return xt(this,i=>i===null),this},nullish(){return xt(this,i=>i==null),this},default(i){return v(this,"_parse",(c,a,l)=>(a===void 0&&(a=typeof i=="function"?i({context:l?.context}):i),c(a,l))),this},catch(i){return v(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:a,error:u.error}):i}}),this},pipe(i){return v(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:c,type:a,jsonSchema:l}={}){if(a&&(c=c||xn(a),e=a),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return v(this,"_parse",(u,f,m)=>{let d=u(f,m),{abortEarly:x}=ze(m);if(!d.success)return d;let C=i(d.data);if(C===true||typeof C=="object"&&C?.success===true)return d;let _={message:typeof c=="function"?c(f):c};return {success:false,error:_,errors:[_]}}),this},clone(){return {...this}}};return bn.length>0?bn.reduce((i,c)=>c(i,t,r)??i,s):s}var bn=[];var Uo=g.object({component:g.function(),id:g.string(),label:g.string(),keywords:g.array(g.string()),group:g.string(),order:g.number().default(({context:t})=>t?.index??0),settings:g.any().optional()});function Ko(t,e){let n=`block:${t}`;return e?.style==="UNORDERED"?`${n}:ul`:e?.style==="ORDERED"?`${n}:ol`:n}function Ln(t,e=0){let n=typeof t=="function",o=n?t:t?.component,r=n?{}:t,s=o.NAMESPACE??"",i=s.split(".").pop()||s,c=r.label||o.LABEL||i||s,a=Array.isArray(o.KEYWORDS)?o.KEYWORDS:[],l=r.keywords?.length?r.keywords.map(String):a.length?a.map(String):[c,i].filter(Boolean).map(String),u=r.settings;return Uo.parse({component:o,id:r.id||Ko(s,u),label:String(c),keywords:l,group:String(r.group||o.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...u?{settings:u}:{}},{context:{index:e}})}var Ge=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 Ln(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 It="molecule.paragraph.Paragraph";var Tn="molecule.external.ExternalComponent",On="namespace.unknown.UnknownComponent";var Dn="molecule.headline.";var Bt=wt(),vt=wt(),Pn=wt(),Fo=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function wt(){return Math.floor(Math.random()*16777215)}function Ho(){return vt=(vt+1)%16777215,vt}function J(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Ho(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Bt>>16&255,Bt>>8&255,Bt&255,Pn>>8&255,Pn&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=Fo[n.charCodeAt(r)];return o}var Ie=Symbol("block-element"),zo=Symbol("block-element-body"),he=Symbol("selectable-element");function qe(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 K(t){return t?qe(t.startContainer,Ie):null}function $n(t){return qe(t,Ie)}function Un(t){return t?qe(t.startContainer,he):null}function jn(t){return qe(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 Kn(t,e){let n=Un(e);return !n||!t?.contains(n)?null:{element:n,index:qo(t,n)}}function Lt(){return window.getSelection()}function F(){let t=Lt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function Tt(){let t=F();if(!t)return 0;t.collapse(true);let e=Un(t),n=K(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,c=t.childNodes,a=Math.min(n,c.length);for(let l=0;l<a;l++)i+=c[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 Hn(t=F()){if(!t||t.collapsed)return null;let e=$n(t.startContainer),n=$n(t.endContainer);if(!e||!n)return null;let o=jn(t.startContainer)??I(e),r=jn(t.endContainer)??I(n);return {startBlock:e,endBlock:n,startOffset:Ee(o,t.startContainer,t.startOffset),endOffset:Ee(r,t.endContainer,t.endOffset)}}function Mt(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=Mt(t,e),o=Lt();o.removeAllRanges(),o.addRange(n);}function I(t){if(!t)return null;let e=zn(t);return e?.firstElementChild??e?.firstChild}function M(t){if(!t?.[Ie])return null;let e=I(t);return e?se(e)?.classInstance:null}function zn(t){if(!t)return null;for(let e of t.children)if(e[zo])return e;return null}function Ot(t){return zn(t)?.childNodes?.[0]?.contentEditable==="true"}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 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 Ve=pt();var We=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=gt(Ve),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=o;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return g.object({component:g.string().default(this.NAMESPACE),properties:g.object().default({}),settings:g.object().default({})}).default({})}static getPropsSchema(){return g.object({state:this.getStateSchema(),observeDOMChanges:g.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(p.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};function $(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 ne({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+=$(r?.text);for(let c of r?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of r?.entityRanges??[])o.push({...c,offset:c.offset+i});}),{text:e,inlineStyleRanges:n,entityRanges:o}}function Xn(t){return {properties:{text:t?.text??"",inlineStyleRanges:t?.inlineStyleRanges??[],entityRanges:t?.entityRanges??[]}}}function Dt(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 Pt(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),c=Kn(i,n),a=c?.element??i??e,l=c?.index??0,u=s[l];return u?{Constructor:r,current:o,element:a,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,c=M(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:r});return}let a=I(i);a?.isConnected&&Y(a,n);};s(),R(s);}function oe(t){let e=t?.component??"";return e===It||e.startsWith(Dn)}function $t(t,e){let n=$(t.properties.text),o=$(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],c=s[n],{originalLineState:a}=Vn(i,o),{newLineState:l}=Vn(c,r),{state:u,cursor:f}=$t(a,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=It,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:F(),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 Wo(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(c=>c.style===e&&c.offset<=n&&c.offset+c.length>=s);return i?r.filter(c=>c!==i):[...r,{style:e,offset:n,length:o}]}function Xo(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function Jo(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!Xo(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 Qo(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(c=>c.offset===r&&c.length===o&&c.entity?.type===s);return i?n.filter(c=>c!==i):[...Jo(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:Wo(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 Qo(t??[],s)}var Xe=class extends We{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:$(this.getState()?.properties?.text).length;Y(this.element,o);};n(),R(n);}onKeydown(e){}static toExchangeState(e){let n=e?.properties,o={text:$(n?.text)};return n?.inlineStyleRanges!==void 0&&(o.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(o.entityRanges=n.entityRanges),ne({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 $t(e,Xn(o))}};var re=class t extends Xe{static get NAMESPACE(){return Tn}static getStateSchema(e){return g.object({component:g.string().default(t.NAMESPACE),componentId:g.string().default(e?.getAttribute("data-componentid")||J()),properties:g.object({}).default({}),settings:g.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 h("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},[h("div",{$ref:o=>{this.root=o;},style:"display: block;",contentEditable:false}),h("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 On}onMount(){let e=h("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);Z(this.root,e);}onUnmount(){this.root.innerHTML="";}};function Zo(t,e){let n=t._getBlockElementByComponentId(e);return M(n)?.isStale?.()??false}function oo(t){return (e,n)=>{if(!ie(e,n))return false;let o=n?.componentId??e?.componentId;return !(o&&Zo(t,o))}}function ro({mrakomor:t}){let e=t.get(),n=oo(e);dt(Ve,e);let o=W(r=>{e._setContentRoot(r??null);});return Pe(()=>{e._onMount();}),$e(()=>{e._onUnmount();}),h("div",{id:e._id,className:"mrakomor-editor"},[h("div",{className:"mrakomor-editor-surface"},[h("div",{className:"mrakomor-tools-container"}),h("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"},$ref:o},[Et(()=>e._getContentState(),r=>r.componentId,(r,s)=>h(()=>{let i;Pe(()=>{i.getNodeComponent=()=>{let l=I(i);return l?se(l):null},e._setBlockElement(i,s);}),$e(()=>{e._removeBlockElement(i);});let c=e.resolveComponent(r.get().component,r),a=e.wrapBlockElement(c);return h("div",{className:"mrakomor-block-element",[Ie]:true,$ref:l=>{i=l;}},a)}),{equals:n})])])])}function Je(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 er(t){let{mrakomor:e}=t,{blockElement:n,range:o,newLineState:r,originalLineState:s,namespace:i,position:c,cursor:a}=t,l,u;if(c||(n?l=e._getBlockElementIndex(n):o&&(l=e._getBlockElementIndex(K(o))),l===void 0||l===-1))return;u=l+1;let f=e.getContent();s&&f.splice(l,1,e.normalizeComponentState(s)),r&&(r.component=i,f.splice(u,0,e.normalizeComponentState(r))),e._setContentState(f),R(()=>{typeof a=="number"&&M(e._getBlockElements()[u])?.setCursor?.({cursor:a});});}function tr(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 c=n??(o?K(o):null),a=e._getBlockElementIndex(c);if(a===-1)return;let l=[...e._getContentState()];l.splice(a,1,...r.map(u=>e.normalizeComponentState(u))),e._setContentState(l),R(()=>{if(typeof s!="number")return;e._syncBlockElementsFromDom();let u=I(e._getBlockElements()[a+i]);u?.isConnected&&Y(u,s);});}function nr(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),c=(t.exchangeState&&ne(t.exchangeState))??s?.toExchangeState?.(r)??ne({properties:r.properties,settings:r.settings}),a=i?.fromExchangeState?.(c)??c;Je(e,n,{...a,component:o,componentId:J()});}function or(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()],[c]=i.splice(r,1);i.splice(s,0,c),e._setContentState(i);}function rr(t){let{mrakomor:e,blockElement:n,range:o}=t,r=e._getBlockElementIndex(n);if(r!==-1){let s=e.getContent();s.splice(r,1),e._setContentState(s);}R(()=>{let s=K(o);Y(I(s),0);});}function sr(t){let{mrakomor:e,state:n,blockElement:o}=t,r=e._getBlockElementState(o);if(!r)return;let s=structuredClone(r),i=n?.offset,c=n?.length,a=n?.entity?.type;s.properties.entityRanges=(s.properties.entityRanges??[]).filter(l=>!(l?.offset===i&&l?.length===c&&l?.entity?.type===a)),Je(e,o,s),e.command.closeDialog?.();}function ir(t){let{mrakomor:e,namespace:n,state:o}=t,r=t.range??F(),s=t.blockElement??K(r),i=Pt(e,s,r);if(!i||i.item.entityRanges===void 0)return;let{Constructor:c,current:a,element:l,itemIndex:u,item:f}=i,m=no(f.entityRanges,l,r,{namespace:n,entityData:o});if(m===null)return;let d=Dt(c,a,u,{entityRanges:m});Je(e,s,d);}function cr(t){let{mrakomor:e,style:n}=t,o=t.range??F(),r=t.blockElement??K(o),s=Pt(e,r,o);if(!s||s.item.inlineStyleRanges===void 0)return;let{Constructor:i,current:c,element:a,itemIndex:l,item:u}=s,f=to(u.inlineStyleRanges,a,o,n);if(f===null)return;let m=Dt(i,c,l,{inlineStyleRanges:f});Je(e,r,m);}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(),c=i[s],a=i[r],l=e.register.blocks.getByNamespace(a.component),u=e.register.blocks.getByNamespace(c.component),f=(t.exchangeState&&ne(t.exchangeState))??u?.toExchangeState?.(c)??ne({properties:c.properties,settings:c.settings}),m=l?.appendExchangeState?.(a,f);m&&(i.splice(s,1),i.splice(r,1,e.normalizeComponentState(m.state)),e._setContentState(i),Jn({mrakomor:e,resultIndex:r,cursor:m.cursor,fallbackBlockElement:o,itemIndex:m.itemIndex}));}function lr(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,c]=G(()=>[e.getContent(),e._getContentState()]);i.length===c.length&&i.every((l,u)=>l===c[u])||e.setContent(i);}function ur(t){let{mrakomor:e,clientX:n,clientY:o}=t;if(typeof o!="number")return;let r=e._getContentRoot(),s=e._getBlockElements(),i=s[0],c=s[s.length-1];if(!r||!i||!c)return;let a=o<i.getBoundingClientRect().top,l=o>c.getBoundingClientRect().bottom;if(!a&&!l)return;if(typeof n=="number"){let f=r.getBoundingClientRect();if(n<f.left||n>f.right)return}let u=I(a?i:c);u?.isConnected&&Y(u,a?0:u.textContent.length);}function fr(t){let e=F();return K(e)?.getNodeComponent?.()?.classInstance?.onKeydown?.(t)}function mr(t){M(t)?.setCursor?.();}function pr(t,e){if(!e)return true;let n=t.cloneRange();return n.setEnd(e,e.childNodes.length),!$(n.toString())}function so(t,e){let{mrakomor:n}=t,o=Hn(e);if(!o||o.startBlock===o.endBlock)return;let r=n._getBlockElementIndex(o.startBlock),s=n._getBlockElementIndex(o.endBlock),i=n.getContent(),c=r>=0?i[r]:void 0,a=s>=0?i[s]:void 0;if(!(r>=0&&s>r&&typeof c?.properties?.text=="string"&&typeof a?.properties?.text=="string"))return;t.preventDefault();let{content:u,cursor:f,resultIndex:m}=Qn(i,{startIndex:r,endIndex:s,startOffset:o.startOffset,endOffset:o.endOffset});n._setContentState(u.map(d=>n.normalizeComponentState(d))),R(()=>{let d=n._getBlockElements()[m];d&&typeof f=="number"&&Y(I(d),f);});}function dr(t){if(t.key!=="Backspace")return;let{mrakomor:e}=t,n=F();if(!n)return;let o=K(n);if(!o)return;if(!n.collapsed){so(t,n);return}let r=o?.previousSibling,s=Ot(r),i=Ot(o),c=I(o),a=!$(c?.textContent);if(!(n.startOffset===0||Tt()===0||a))return;let u=e._getBlockElementIndex(o),f=r?e._getBlockElementIndex(r):-1,m=e._getBlockElementState(o),d=e._getBlockElementState(r),x=r?M(r):null;if(!r||f<0){t.preventDefault();return}if(d&&m&&oe(m)&&x&&!x.isAtomic?.()){if(a&&!oe(d)){t.preventDefault();let C=e.getContent();C.splice(u,1),e._setContentState(C),mr(r);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:o,previousBlockElement:r,range:n});return}x?.isAtomic?.()&&(!s&&n.startOffset===0||o?.textContent==="\xA0"&&!i)&&(t.preventDefault(),e.command.removeBlockElement({blockElement:r,range:n})),m&&!oe(m)&&t.preventDefault();}function gr(t){if(t.key!=="Delete")return;let{mrakomor:e}=t,n=F();if(!n)return;let o=K(n);if(!o)return;if(!n.collapsed){so(t,n);return}let r=I(o);if(!(!$(r?.textContent)||pr(n,r)))return;let c=e._getBlockElementIndex(o),a=o?.nextSibling,l=a?e._getBlockElementIndex(a):-1,u=e._getBlockElementState(o),f=e._getBlockElementState(a),m=M(o),d=a?M(a):null;if(!a||l<0){t.preventDefault();return}if(f&&u&&oe(f)&&m&&!m.isAtomic?.()){let x=I(a);if(!$(x?.textContent)&&!oe(u)){t.preventDefault();let _=e.getContent();_.splice(c+1,1),e._setContentState(_);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:a,previousBlockElement:o,range:n});return}if(d?.isAtomic?.()){t.preventDefault(),e.command.removeBlockElement({blockElement:a,range:n});return}if(u&&!oe(u)){t.preventDefault();return}t.preventDefault();}function Qe(t){return {resolveComponent:e=>e===re.NAMESPACE?re:ye,registerCommands(e){e.emitter.on(p.INSERT_BLOCK_ELEMENT,B(er)),e.emitter.on(p.REPLACE_BLOCK_ELEMENT,B(tr)),e.emitter.on(p.TRANSFORM_BLOCK_ELEMENT,B(nr)),e.emitter.on(p.MOVE_BLOCK_ELEMENT,B(or)),e.emitter.on(p.REMOVE_BLOCK_ELEMENT,B(rr)),e.emitter.on(p.REMOVE_ENTITY_RANGE,B(sr)),e.emitter.on(p.INSERT_ENTITY_RANGE,B(ir)),e.emitter.on(p.INSERT_INLINE_STYLE_RANGE,B(cr)),e.emitter.on(p.MERGE_BLOCK_ELEMENT,B(ar));},registerHandlers(e){e.emitter.on(p.FOCUSOUT,lr),e.emitter.on(p.KEYDOWN,B(fr)),e.emitter.on(p.KEYDOWN,B(dr)),e.emitter.on(p.KEYDOWN,B(gr)),e.emitter.on(p.CLICK,B(ur));},registerListeners(e){let n=e.getRoot(),{signal:o}=e.listenerAbortController;n.addEventListener("keydown",r=>e.emitDomEvent(p.KEYDOWN,r),{signal:o}),n.addEventListener("beforeinput",r=>e.emitDomEvent(p.BEFORE_INPUT,r),{signal:o}),n.addEventListener("input",r=>e.emitDomEvent(p.INPUT,r),{signal:o}),n.addEventListener("focusin",r=>e.emitDomEvent(p.FOCUSIN,r),{signal:o}),n.addEventListener("focusout",r=>e.emitDomEvent(p.FOCUSOUT,r),{signal:o}),n.addEventListener("click",r=>e.emitDomEvent(p.CLICK,r),{signal:o}),document.addEventListener("selectionchange",r=>e.emitDomEvent(p.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 hr(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 Ze(t,e,n){return hr(t,".mrakomor-tools-container",e,n)}var io="mrakomor.dialog.Dialog";function et({open:t,placement:e,positionX:n,positionY:o,block:r,dialogRef:s}){let i=L(()=>{let a=e.get()==="center";return {position:"absolute",zIndex:a?"9100":"9000",top:`${o.get()}px`,left:`${n.get()}px`,...a?{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"}}}),c=L(()=>({position:"absolute",inset:"0",zIndex:"9050",background:"rgba(15, 23, 42, 0.28)",pointerEvents:"all"}));return h("span",{style:{display:"contents"}},[Re(()=>t.get()&&e.get()==="center",h("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:c})),Re(()=>t.get(),h("div",{className:"mrakomor-dialog-container",contenteditable:false,style:i,$ref:s},()=>r.get()))])}et.NAMESPACE=io;function tt({mrakomor:t}){let e=null,n=S(false),o=S(false),r=S("anchor"),s=S(0),i=S(0),c=S(null),a=W(null),l=W(null);function u(){o.set(false),r.set("anchor"),a.set(null),R(()=>{n.set(false);});}return {resolveComponent(f){if(f===io)return et},registerEvents(){p.OPEN_DIALOG="mrakomor:open-dialog",p.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(m,d)=>{f.emit(p.OPEN_DIALOG,{...m,options:d});},f.command.closeDialog=()=>{f.emit(p.CLOSE_DIALOG);};},registerHandlers(){t.emitter.on(p.OPEN_DIALOG,({children:f,element:m,options:d={}})=>{c.set(f??h("div",{},"Empty dialog")),o.set(true),a.set(m??null),r.set(d.placement??"anchor"),R(()=>{let x=t.getRoot(),{x:C,y:_}=d.placement==="center"?Gn(x,l):Ye(x,m??{left:0,top:0},l);s.set(C),i.set(_),n.set(true);});}),t.emitter.on(p.CLOSE_DIALOG,u),t.emitter.on(p.KEYDOWN,f=>{f.key==="Escape"&&o.peek()===true&&t.command.closeDialog();}),t.emitter.on(p.CLICK,f=>{if(o.peek()!==true||n.peek()!==true)return;let m=f.target,d=l&&typeof l.contains=="function"&&l.contains(m),x=a&&typeof a.contains=="function"&&a.contains(m);!d&&!x&&t.command.closeDialog();});},onMount(){let{dispose:f}=Ze(t,"mrakomor-dialog-plugin-container",h(et,{open:o,placement:r,positionX:s,positionY:i,block:c,dialogRef:l}));e=f;},onUnmount(){e?.(),e=null;}}}function Er(){return g.object({id:g.string(),group:g.string().default("general"),description:g.string().default(""),commands:g.array(g.string()).default([]),shortcuts:g.array(g.string()).default([])}).default({})}function co(t){try{return Er().parse(t)}catch{return null}}var nt=class extends de{constructor(e){super(e,{sort:n=>n});}normalize(e){return co(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 yr(t,e=-1){if(!t.length)return h("div",{className:"mrakomor-menu__empty",role:"presentation"},"No results");let n=t.map((o,r)=>h("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 h("span",{style:"display: contents"},n)}function jt({open:t,positionX:e,positionY:n,entries:o,highlightIndex:r,ariaLabel:s,menuRef:i}){let c=L(()=>({left:`${e.get()}px`,top:`${n.get()}px`}));return Re(()=>t.get(),h("div",{className:"mrakomor-menu",role:"listbox","aria-label":()=>s.get(),contenteditable:false,style:c,$ref:i},()=>yr(o.get(),r.get())))}function ot({mrakomor:t}){let e=null,n=null,o=W(null),r=null,s=S(false),i=S(false),c=S(0),a=S(0),l=S([]),u=S(-1),f=S("Menu");function m(E){R(()=>{let b=t.getRoot();if(!b||!E)return;let A=o?.offsetHeight??200,N=b.getBoundingClientRect();if(E.top-N.top>A+8){let{x:k,y:w}=Ye(b,E,{offsetHeight:A},4);c.set(k),a.set(w);}else c.set(E.left-N.left),a.set(E.bottom-N.top+4);s.set(true);});}function d(){i.set(false),r=null,u.set(-1),l.set([]),R(()=>{s.set(false);});}function x(E){!E||!r||r(E);}function C(E){if(i.peek()!==true)return;let b=E.target?.closest?.(".mrakomor-menu__item");if(!b||!n?.contains(b))return;E.preventDefault(),E.stopPropagation();let A=b.getAttribute("data-id"),N=l.peek().find(y=>y.id===A);N&&x(N);}function _(E={}){let{entries:b=[],anchorRect:A,highlightIndex:N=-1,ariaLabel:y="Menu",onSelect:k=null}=E;l.set(b),u.set(N),f.set(y),k!==void 0&&(r=k),i.set(true),A?m(A):s.set(true);}return {registerEvents(){p.OPEN_MENU="mrakomor:open-menu",p.CLOSE_MENU="mrakomor:close-menu",p.UPDATE_MENU="mrakomor:update-menu";},registerCommands(E){E.command.openMenu=b=>{E.emit(p.OPEN_MENU,b);},E.command.updateMenu=b=>{E.emit(p.UPDATE_MENU,b);},E.command.closeMenu=()=>{E.emit(p.CLOSE_MENU);};},registerHandlers(){t.emitter.on(p.OPEN_MENU,_),t.emitter.on(p.UPDATE_MENU,_),t.emitter.on(p.CLOSE_MENU,d),t.emitter.on(p.CLICK,E=>{let b=o?.current??o;i.peek()===true&&s.peek()===true&&b&&typeof b.contains=="function"&&!b.contains(E.target)&&d();}),t.emitter.on(p.KEYDOWN,E=>{E.key==="Escape"&&i.peek()===true&&d();});},onMount(){let{container:E,dispose:b}=Ze(t,"mrakomor-menu-plugin-container",h(jt,{open:i,positionX:c,positionY:a,entries:l,highlightIndex:u,ariaLabel:f,menuRef:o}));n=E,n?.addEventListener("click",C),e=b;},onUnmount(){n?.removeEventListener("click",C),e?.(),e=null,n=null,o.current=null,r=null;}}}function xr(t){return t!=null&&typeof t=="object"&&(typeof Element>"u"?t.nodeType===1:t instanceof Element)}function ao(){return g.object({root:g.any().refine(xr,{message:"root must be a DOM Element"}),id:g.string().optional(),debug:g.boolean().optional(),content:g.array(g.any()).optional(),plugins:g.array(g.function()).optional(),blockComponents:g.array(g.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:g.array(g.any().refine(t=>t!=null&&typeof t=="object"&&typeof t.handler=="function",{message:"slashActions entry must include a handler function"})).optional(),inlineStyles:g.array(g.function()).optional(),entityRanges:g.array(g.function()).optional(),tooltip:g.any().optional()})}function lo(t){return [...t.filter(e=>e!==tt&&e!==ot&&e!==Qe),tt,ot,Qe]}function br(t){ao().parse(t);let e={debug:false,content:[],plugins:[],blockComponents:[],slashActions:[],inlineStyles:[le,ue,pe,fe,me],entityRanges:[],tooltip:{}},n={...e,...t,plugins:lo(t.plugins??e.plugins)},o=new rt(n);return o._init(),o}var rt=class{#e=J();#n;#r=null;#t=[];#o=[];#i;#a=false;listenerAbortController=new AbortController;#c=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:lo(e.plugins??[])},this.register={blocks:new Ge(this),help:new nt(this)};let{emitter:s,command:i}=En({mrakomor:this});this.command=i,this.emitter=s;}_init(){this.#u(),this.#c=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(p.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(p.CONTENT_CHANGE,e)}emitDomEvent(e,n){let{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:c,key:a,isComposing:l,repeat:u,button:f,shiftKey:m,which:d,detail:x,isTrusted:C,target:_,relatedTarget:E,data:b,inputType:A,clientX:N,clientY:y}=n??{},{defaultPrevented:k}=this.emit(e,{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:c,key:a,isComposing:l,repeat:u,button:f,shiftKey:m,which:d,detail:x,isTrusted:C,target:_,relatedTarget:E,data:b,inputType:A,clientX:N,clientY:y});return k&&n?.preventDefault?.(),k}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=>M(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.#c.get()}_setContentState(e=[]){this.#c.set(e),this.emit(p.CONTENT_CHANGE,{content:e}),R(()=>{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 M(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 M(this.#o[n])?.getState()}mount(){let e=Z(this.#n,h(ro,{mrakomor:this}));return this.#a=true,e}unmount(){this.#a&&(this.#a=false,gn(this.#n));}_onUnmount(){this.listenerAbortController.abort(),this.#t.forEach(e=>{e?.onUnmount?.(this);}),this.emitter.removeAllListeners();}_onMount(){this.#t.forEach(e=>{e?.onMount?.(this);}),R(()=>{this._syncBlockElementsFromDom();});}resolveComponent(e,n){let o=this.resolveComponentConstructor(e);return o?h(o,{state:n}):h(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=et;exports.EVENT=p;exports.Italic=ue;exports.Menu=jt;exports.Mrakomor=rt;exports.Subscript=fe;exports.Superscript=me;exports.Underline=pe;exports.createMrakomor=br;exports.defaultMrakomorPlugin=Qe;exports.dialogPlugin=tt;exports.menuPlugin=ot;