@mrakomor/core 0.0.10 → 0.0.11

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.
package/dist/headline.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/headline/Headline.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}
2
- `,document.head.appendChild(n);}}})();var Qe=class{next(...e){}error(...e){}complete(...e){}},ye=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var te=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var S=null,Se=false,be=[];function v(e){let t=S;S=null;let n=e();return S=t,n}function ln(){Se=false;let e=nt();for(let n of e)n.get();let t=be;be=[];for(let n of t)n();}function Ze(){Se||(Se=true,queueMicrotask(ln));}function xe(e){be.push(e),Ze();}var et=Symbol("@esmj/signals:internal observable"),R=Symbol("@esmj/signals:original function"),fn=class extends ye{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>v(()=>{this.#e.add(e),this.#r();}),e.next[R]=void 0),e instanceof st&&e.next[R]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#r();}),e.next[R]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[R]){let n=t.get,r=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),r())),t.get[R]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[R]?e.next[R]:e.next,e.get=e.get[R]?e.get[R]:e.get,this.#e.delete(e),this.unsubscribe(e)}},ne=null;function tt(e){ne=new fn(e);}tt(()=>{Ze();});function nt(){return ne.getPending()}function rt(e){return ne.watch(e)}function ot(e){return ne.unwatch(e)}var k=Symbol("@esmj/signals:no error"),st=class it extends Qe{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#u=null;#i=0;#s=new Map;#t=k;constructor(t,n){super(),this.#c=t,this.#u=n,this.debug=n?.debug,this[te]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#l(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[q],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof it&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==k)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==k)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=k,this.#l(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#c();}catch(r){this.#t=r;}return S=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=k,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===k&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#l(),this.#s.clear(),this.#e=true,this.#t=k;}};function B(e,t){return new st(e,t)}function _(e,t){let n,{debug:r,...o}={},i=B(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),rt(i);let s=()=>{n?.(),i.destroy(),ot(i);};return s[Symbol.dispose]=s,s[te]="effect",s[q]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new ye;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(l,r)),e}function s(){return e}function a(c){if(!n(e,c)){e=c,r++,o.next();}return e}function u(){return r}let l={get:i,set:a,peek:s,getRevision:u,[et]:o,[te]:"signal",[q]:t?.debug??null};return l}function re(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var dt=Symbol("node-component"),oe=Symbol("node-internal"),pn=Symbol("keep-literal"),ue=Symbol("raw-props");var gt=null;function D(){return gt}function se(e){gt=e;}function Me(e){return e?.[dt]||null}function at(e,t){e[dt]=t;}function ie(e,t={disposers:[],id:re()}){return e?.[oe]?e[oe]:(e&&(e[oe]=t),t)}function dn(e){return e[oe]}function L(e,t){let n=dn(e);n||(n=ie(e)),n.disposers.push(t);}function _e(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function T(e,t){let n=D();se(e);try{return t()}finally{se(n);}}var Ne=new Map,ae=new Map,ut=new Map;function Et(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[pn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=B(i):r[o]=I(i);}return r}function we(e){return {id:Symbol("context-id"),defaultValue:e}}function Le(e){let t=D();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function U(e){xe(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ne.get(t);if(n){Ne.delete(t);for(let r of n){let o=r();typeof o=="function"&&_e(ae,t,o);}}}function gn(e){let t=ae.get(e);if(t){ae.delete(e);for(let n of t)n();}}function En(e){let t=ut.get(e);if(t){ut.delete(e);for(let n of t)n();}}function Te(e){if(!e)return;let t=ie(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=Me(e);if(n&&(gn(n.componentId),En(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Te(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ct(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function yn(e,t,n){let r=re(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=ct(e)?void 0:e[ue],s={...Et(t??{},i),children:n},a=D(),u={disposers:[],id:r,contexts:new Map(a?.contexts)};se(u);let l;if(ct(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&_e(Ne,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&_e(ae,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);se(a);let c=Sn(l);if(o.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)ie(f,u),at(f,o);else ie(c,u),c instanceof Node&&at(c,o);return c}};return o}function yt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function Sn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var lt={className:"class",htmlFor:"for"},ft=new Set(["value","defaultValue","checked","selected","indeterminate"]),bn=new Set(["srcdoc"]),xn=new Set(["href","src","action","formaction","xlink:href"]),Cn=new Set(["securitypolicyviolation"]),_n=new Set(["contenteditable","draggable","spellcheck"]);function G(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var St=Symbol("Fragment");function le(e,t,n){if(e===St){let o=document.createDocumentFragment();return Ae(o,mt(n)),o}if(typeof e=="function")return yn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),fe(r,t),Ae(r,mt(n)),r}function Ce(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Nn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function An(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return bn.has(n)?true:xn.has(n)&&t!==null&&t!==void 0&&Nn(String(t))}function bt(e){return typeof e!="string"?e:lt[e]?lt[e]:e}function Rn(e,t){let n=bt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return _n.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function pt(e,t,n){let r=Rn(t,n);if(r===null){e.removeAttribute(t);return}if(An(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function fe(e,t){let n=D();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=bt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(G(o)){let i=_(()=>{T(n,()=>{Ce(e,o.get());});});L(e,i);}else if(typeof o=="function"){let i=_(()=>{T(n,()=>{Ce(e,o());});});L(e,i);}else Ce(e,o);continue}if(r==="style"){if(G(o)){let i=_(()=>{T(n,()=>{Object.assign(e.style,o.get());});});L(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Cn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(G(o)||typeof o=="function"){let i=r,s=_(()=>{T(n,()=>{let a=typeof o=="function"?o():o.get();ft.has(i)?e[i]=a??"":pt(e,i,a);});});L(e,s);continue}ft.has(r)||typeof r=="symbol"?e[r]=o??"":pt(e,r,o);}}function mt(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Ae(e,t){for(let n of t)xt(e,n);}function xt(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){ht(e,t);return}if(j(t)){yt(e,t);return}if(G(t)){ht(e,()=>t.get());return}if(Array.isArray(t)){Ae(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function H(e){let t=null,n=e;return j(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function pe(e,t=true){for(let n of e)t&&Te(n),n.remove();}function ht(e,t){let n=D(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{T(n,()=>{let s=t(),{nodes:a,instance:u}=H(s);pe(o),a.length&&r.after(...a),u&&queueMicrotask(()=>Y(u)),o=a;});});L(e,i);}var Nt=class{constructor(e){this.props=e;}};var Mn={abortEarly:true};function De(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function wn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(De(e.errors[r],n));}function kt(e,t,n,r){if(n!==false){let o=De(e.error,t);return {success:false,error:o,errors:[o]}}wn(e,r,t);}function me(e){return e?.abortEarly!==void 0?e:Mn}function Oe(e,t){g(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Pe=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ie=e=>e===true||e===false,Ln=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Tn=e=>typeof e=="function",On=e=>Array.isArray(e),Be=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function vt(e,t){let n=b(Be,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return g(this,"_parse",(s,a,u)=>{let l=s(a,u);if(!l.success)return l;let c=o(l.data,{context:u?.context});if(!Be(c)){let f={message:`derive() callback must return a plain object of overrides, got ${c===null?"null":typeof c}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let p in c)f[p]===void 0&&(f[p]=c[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...c}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:u}=me(s);if(a.success===false)return a;let l={},c=[];for(let f in e){let p=e[f]._parse(a.data[f],s);if(p.success)l[f]=p.data;else {let m=kt(p,f,u,c);if(m)return m}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),r}function $e(e){return b(W,{...e,type:"string"})}function je(e){return b(Pe,{...e,type:"number"})}function He(e){return b(Ie,{...e,type:"boolean"})}function Fe(e){return b(Ln,{...e,type:"date"})}function Mt(e){return b(Tn,{...e,type:"function"})}function wt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=b(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Lt(e,t){let n=b(On,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,g(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=me(i);if(s.success===false)return s;let u=[],l=[],c=i;for(let f=0;f<s.data.length;f++){let p={...c,context:{...c?.context,index:f}},m=e._parse(s.data[f],p);if(m.success)u.push(m.data);else {let E=kt(m,f,a,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:u}}),n}function Tt(){return b(()=>true)}function F(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Ot(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${Be(o)?JSON.stringify(o):`"${o}"`}`,r=b(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,g(r,"_parse",(o,i,s)=>{let a=s,u=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(i,a);if(m.success)return m;u.push(m);}let{abortEarly:l}=me(a),c={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:c,errors:[c]};let f=[];for(let p=0;p<u.length;p++){let m=u[p].errors;if(m?.length)for(let E=0;E<m.length;E++)m[E].cause?.key&&f.push(De(m[E],`branch ${p}`));}return f.length===0&&f.push(c),{success:false,error:f[0],errors:f}}),r}function Pt(e,t){let n=b(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function It(e){let t=b(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,g(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Bt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Dt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return F(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},He({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return F(n=>{if(Ie(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},je({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ie(n)||Pe(n)&&Number.isFinite(n)?String(n):n,$e({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return W(n)&&(r=n.trim()),Pe(n)&&Number.isFinite(n)||r?new Date(r??n):n},Fe({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return g(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},$t={},d={object:vt,string:$e,number:je,boolean:He,date:Fe,function:Mt,enum:wt,array:Lt,any:Tt,preprocess:F,union:Ot,literal:Pt,contextRef:It,withContext:Bt,coerce:$t,cast:Dt};function At(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function g(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function b(e,{type:t="any",name:n,message:r}={}){r=r||At(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let u=this._parse(s,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success&&(c.data=s(c.data)),c}),this},optional(){return Oe(this,s=>s===void 0),this},nullable(){return Oe(this,s=>s===null),this},nullish(){return Oe(this,s=>s==null),this},default(s){return g(this,"_parse",(a,u,l)=>(u===void 0&&(u=typeof s=="function"?s({context:l?.context}):s),a(u,l))),this},catch(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?c:{success:true,data:typeof s=="function"?s({input:u,error:c.error}):s}}),this},pipe(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?s._parse(c.data,l):c}),this},refine(s,{message:a,type:u,jsonSchema:l}={}){if(u&&(a=a||At(u),t=u),l){let c=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>c;}return g(this,"_parse",(c,f,p)=>{let m=c(f,p),{abortEarly:E}=me(p);if(!m.success)return m;let N=s(m.data);if(N===true||typeof N=="object"&&N?.success===true)return m;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return Rt.length>0?Rt.reduce((s,a)=>a(s,e,o)??s,i):i}var Rt=[];var Ke=Ve(),qe=Ve(),jt=Ve(),Pn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ve(){return Math.floor(Math.random()*16777215)}function In(){return qe=(qe+1)%16777215,qe}function he(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=In(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Ke>>16&255,Ke>>8&255,Ke&255,jt>>8&255,jt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Pn[n.charCodeAt(o)];return r}var Ht=Symbol("block-element"),Bn=Symbol("block-element-body"),Ge=Symbol("selectable-element");function Ue(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function Dn(e){return e?Ue(e.startContainer,Ht):null}function Ft(e){return Ue(e,Ht)}function $n(e){return e?Ue(e.startContainer,Ge):null}function Kt(){return window.getSelection()}function X(){let e=Kt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function qt(){let e=X();if(!e)return 0;e.collapse(true);let t=$n(e),n=Dn(e),r=t??Ye(n);return Vt(r,e.startContainer,e.startOffset)}function Vt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,u=Math.min(n,a.length);for(let l=0;l<u;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function jn(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let i=o.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(r+s>=t)return n.setEnd(i,t-r),n.setStart(i,t-r),n;r+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)o.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function de(e,t){let n=jn(e,t),r=Kt();r.removeAllRanges(),r.addRange(n);}function Ye(e){if(!e)return null;let t=Hn(e);return t?.firstElementChild??t?.firstChild}function Hn(e){if(!e)return null;for(let t of e.children)if(t[Bn])return t;return null}var Gt={INPUT:"mrakomor:input"};var Ut=we();var ge=class extends Nt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Le(Ut),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(Gt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var We="molecule.paragraph.Paragraph";var Yt="molecule.headline.H1",Wt="molecule.headline.H2",Xt="molecule.headline.H3",zt="molecule.headline.H4",Jt="molecule.headline.H5";function M(e){return e===`
2
+ `,document.head.appendChild(n);}}})();var Qe=class{next(...e){}error(...e){}complete(...e){}},Se=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var 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===`
3
3
  `||e===`\r
4
- `?"":e??""}function en({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...o,text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]},...r?{settings:r}:{}}}function tn(e,t){let n=M(e.properties.text),r=M(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function Qt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Zt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function Fn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=Qt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Zt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Qt(e.properties.entityRanges,t),r.properties.entityRanges=Zt(e.properties.entityRanges,t),r.componentId=he(),{originalLineState:n,newLineState:r}}function nn(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Fn(e.getState(),qt(e.element));return e.mrakomor.command.insertBlockElement({range:X(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}var Ee=class extends ge{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:M(this.getState()?.properties?.text).length;de(this.element,r);};n(),U(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return en({originComponent:this.NAMESPACE,properties:{...t?.properties,text:M(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return tn(t,n)}};function rn(e,{component:t,properties:n,settings:r=d.object({}).default({})}){return d.object({component:d.string().default(t),componentId:d.string().default(e?.getAttribute("data-componentid")||he()),properties:d.object(n).default({}),settings:r}).default({})}var O=class extends Ee{constructor(t){super(t),this._level=1;}static getStateSchema(t){return rn(t,{component:this.NAMESPACE,properties:{text:d.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse());return n.properties.text=M(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return le(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Ge]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return M(r)?v(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}nn(this,t,{namespace:We});}#e(t){if(!X()?.collapsed)return;let r=Ft(this.element);if(r?.previousElementSibling||M(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:We});let o=()=>{let i=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),s=Ye(i);s?.isConnected&&de(s,0);};o(),U(o);}},z=class extends O{static get NAMESPACE(){return Yt}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},J=class extends O{static get NAMESPACE(){return Wt}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},Q=class extends O{static get NAMESPACE(){return Xt}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},Z=class extends O{static get NAMESPACE(){return zt}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},ee=class extends O{static get NAMESPACE(){return Jt}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function Kn(){return {resolveConfig:e=>(e.blockComponents.push(z,J,Q,Z,ee),e),resolveComponent:e=>{if(e===z.NAMESPACE)return z;if(e===J.NAMESPACE)return J;if(e===Q.NAMESPACE)return Q;if(e===Z.NAMESPACE)return Z;if(e===ee.NAMESPACE)return ee}}}exports.HeadlineComponent=O;exports.headlinePlugin=Kn;
4
+ `?"":e??""}function en({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},i=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:i},...r?{settings:r}:{}}}function tn(e){let t="",n=[],r=[];return (e??[]).forEach((o,i)=>{i>0&&(t+=`
5
+ `);let s=t.length;t+=N(o?.text);for(let a of o?.inlineStyleRanges??[])n.push({...a,offset:a.offset+s});for(let a of o?.entityRanges??[])r.push({...a,offset:a.offset+s});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function nn(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function rn(e,t){let n=N(e.properties.text),r=N(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function Qt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Zt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function qn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=Qt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Zt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Qt(e.properties.entityRanges,t),r.properties.entityRanges=Zt(e.properties.entityRanges,t),r.componentId=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;
package/dist/headline.mjs CHANGED
@@ -1 +1 @@
1
- export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-UC7W4JIH.mjs';import'./chunk-G2QV4GOO.mjs';import'./chunk-GDID5DFL.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-TX4RCFPO.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';
1
+ export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-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';
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';(function(){if(!(typeof document>"u")){var t="mrakomor/core/style/core.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.mrakomor-editor:focus-visible{outline:none}.mrakomor-editor{display:flex;flex-direction:column;min-height:0}.mrakomor-editor-surface{position:relative;flex:1 1 auto;min-height:0}.mrakomor-tools-container{position:absolute;inset:0;pointer-events:none;z-index:4}.mrakomor-content{position:relative;min-height:0}.mrakomor-content:focus-visible{outline:none}
2
- `,document.head.appendChild(n);}}})();var Ft=class{next(...t){}error(...t){}complete(...t){}},ct=class{#e=new Set;pipe(...t){return t.reduce((e,n)=>n(e),this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t);});}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e);});}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e);});}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#e.delete(t);}};var ve=Symbol("@esmj/signals:type"),ye=Symbol("@esmj/signals:name");var w=null,lt=false,ut=[];function H(t){let e=w;w=null;let n=t();return w=e,n}function co(){lt=false;let t=zt();for(let n of t)n.get();let e=ut;ut=[];for(let n of e)n();}function Ht(){lt||(lt=true,queueMicrotask(co));}function ft(t){ut.push(t),Ht();}var qt=Symbol("@esmj/signals:internal observable"),K=Symbol("@esmj/signals:original function"),lo=class extends ct{#e=new Set;#o=null;constructor(t){super(),this.#o=t,this.pipe(e=>{let n=e.subscribe.bind(e),o=e.unsubscribe.bind(e);return e.subscribe=r=>{n(r),this.#e.add(r);},e.unsubscribe=r=>{o(r),this.#e.delete(r);},e});}watch(t){if(typeof t.next!="function"&&(t.next=()=>H(()=>{this.#e.add(t),this.#o();}),t.next[K]=void 0),t instanceof Wt&&t.next[K]===void 0){let e=t.next.bind(t);t.next=()=>H(()=>{this.#e.add(t),e(),this.#o();}),t.next[K]=e;}return this.subscribe(t)}getPending(){let t=[];for(let e of this.#e){if(!e.get[K]){let n=e.get,o=n.bind(e);e.get=()=>H(()=>(this.#e.delete(e),o())),e.get[K]=n;}t.push(e);}return t}unwatch(t){return t.next=t.next[K]?t.next[K]:t.next,t.get=t.get[K]?t.get[K]:t.get,this.#e.delete(t),this.unsubscribe(t)}},Ie=null;function Gt(t){Ie=new lo(t);}Gt(()=>{Ht();});function zt(){return Ie.getPending()}function Vt(t){return Ie.watch(t)}function Yt(t){return Ie.unwatch(t)}var F=Symbol("@esmj/signals:no error"),Wt=class Xt extends Ft{#e=true;#o=false;#t=null;#n=this.#u();#r=null;#i=null;#c=0;#a=new Map;#s=F;constructor(e,n){super(),this.#r=e,this.#i=n,this.debug=n?.debug,this[ve]="computed",this[ye]=n?.debug??null,this.get=this.get.bind(this);}#l(){for(let{unsubscribe:e}of this.#n.dependencies.values())e();this.#n.dependencies.clear();}#u(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#c}getDebugInfo(){return {name:this[ye],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#a.keys()]}}#m(){for(let[e,n]of this.#a)if(e instanceof Xt&&H(()=>e.get()),e.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[qt].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=C(this.#f(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#m()?this.#f():this.#e=false),w&&w.sourceRevisions.set(this,this.#c),this.#s!==F)throw this.#s;return this.#t.get()}peek(){if(this.#t||(this.#t=C(this.#f(),this.#i)),(this.#e||this.#s!==F)&&(this.#a.size===0||this.#m()?this.#f():this.#e=false),this.#s!==F)throw this.#s;return this.#t.peek()}#f(){this.#o=true,this.#e=false,this.#s=F,this.#l(),this.#n.sourceRevisions.clear();let e=w;w=this.#n;let n;try{n=this.#r();}catch(o){this.#s=o;}return w=e,this.#a=this.#n.sourceRevisions,this.#n.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#s=F,this.#t.set(o);}).catch(o=>{this.#s=o;})),this.#s===F&&this.#t&&this.#t.set(n),this.#c++,n}destroy(){this.#l(),this.#a.clear(),this.#e=true,this.#s=F;}};function B(t,e){return new Wt(t,e)}function D(t,e){let n,{debug:o,...r}={},s=B(()=>{n?.(),n=t();},{equals:()=>false,...r});s.get(),Vt(s);let i=()=>{n?.(),s.destroy(),Yt(s);};return i[Symbol.dispose]=i,i[ve]="effect",i[ye]=o??null,i.__RX_COMPUTED__=s,i}function C(t,e={}){let n=e?.equals??Object.is,o=0,r=new ct;function s(){return w&&(w.dependencies.set(r,r.subscribe(w.observer)),w.sourceRevisions.set(l,o)),t}function i(){return t}function a(u){if(!n(t,u)){t=u,o++,r.next();}return t}function c(){return o}let l={get:s,set:a,peek:i,getRevision:c,[qt]:r,[ve]:"signal",[ye]:e?.debug??null};return l}function Be(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var sn=Symbol("node-component"),Me=Symbol("node-internal"),uo=Symbol("keep-literal"),Oe=Symbol("raw-props");function dt(t){return typeof t=="function"?t:t!=null&&typeof t.get=="function"?()=>t.get():()=>t}function gt(t,e){let n=t.children!==void 0?t.children:e;return Array.isArray(n)?n[0]:n}var fo=new Set(["template","script"]);function mo(t,e){let n=(t==null?"span":String(t)).trim(),o=n;fo.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${t}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),o="span");let r=document.createElement(o);return o==="span"&&(r.style.display="contents"),r.setAttribute(e,Be()),r}function ht(t,e,n){let o=mo(t,e);return n?.id&&o.setAttribute("id",n.id),o}function oe(t){let e=null,n=()=>e,o=s=>(e=s??null,e),r={get:n,set:o,[Symbol.toPrimitive](){return e?String(e):""}};return Object.defineProperty(r,"current",{get(){return e},set(s){o(s);},enumerable:true,configurable:false}),new Proxy(r,{get(s,i,a){if(Reflect.has(s,i))return Reflect.get(s,i,a);if(!e)return;let c=e[i];return typeof c=="function"?c.bind(e):c},set(s,i,a,c){return Reflect.has(s,i)||!e?Reflect.set(s,i,a,c):(e[i]=a,true)},has(s,i){return Reflect.has(s,i)||!!e&&i in e}})}var an=null;function $(){return an}function we(t){an=t;}function re(t){return t?.[sn]||null}function Jt(t,e){t[sn]=e;}function Le(t,e={disposers:[],id:Be()}){return t?.[Me]?t[Me]:(t&&(t[Me]=e),e)}function po(t){return t[Me]}function q(t,e){let n=po(t);n||(n=Le(t)),n.disposers.push(e);}function Se(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n);}function G(t,e){let n=$();we(t);try{return e()}finally{we(n);}}var Te=new Map,Ce=new Map,Qt=new Map;function cn(t,e){let n=typeof e=="function"?e:r=>!!e?.includes(r),o=Object.create(null);for(let r of Object.keys(t)){let s=t[r];r==="children"||n(r)?o[r]=s:s?.[uo]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=B(s):o[r]=C(s);}return o}function se(t,e){if(t===e)return true;if(t==null||e==null||typeof t!="object"||typeof e!="object")return false;let n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?false:n.every(r=>{let s=Object.getOwnPropertyDescriptor(t,r),i=Object.getOwnPropertyDescriptor(e,r);if(!s||!i)return false;let a="value"in s?s.value:s.get?.call(t),c="value"in i?i.value:i.get?.call(e);return se(a,c)})}function Et(t){return {id:Symbol("context-id"),defaultValue:t}}function yt(t,e){let n=$();n&&n.contexts.set(t.id,e);}function bt(t){let e=$();return e?.contexts?.has(t.id)?e.contexts.get(t.id):t.defaultValue}function De(t){let e=$();if(!e){console.warn("onMount called outside of a component context");return}Se(Te,e.id,t);}function Pe(t){let e=$();if(!e){console.warn("onUnmount called outside of a component context");return}Se(Ce,e.id,t);}function R(t){ft(()=>{setTimeout(t,0);});}function ie(t){let e=t.componentId,n=Te.get(e);if(n){Te.delete(e);for(let o of n){let r=o();typeof r=="function"&&Se(Ce,e,r);}}}function go(t){let e=Ce.get(t);if(e){Ce.delete(t);for(let n of e)n();}}function ho(t){let e=Qt.get(t);if(e){Qt.delete(t);for(let n of e)n();}}function ke(t){if(!t)return;let e=Le(t);if(e?.disposers?.length){for(let o of e.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}e.disposers=[];}let n=re(t);if(n&&(go(n.componentId),ho(n.componentId)),t.childNodes){let o=t.firstChild;for(;o;){let r=o.nextSibling;ke(o),o=r;}}}function z(t){return t!=null&&typeof t=="object"&&typeof t.$constructor=="function"}function Zt(t){return typeof t=="function"&&typeof t.prototype?.render=="function"}function Eo(t,e,n){let o=Be(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=Zt(t)?void 0:t[Oe],i={...cn(e??{},s),children:n},a=$(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};we(c);let l;if(Zt(t)){r.ClassConstructor=t;let f=new t(i);r.classInstance=f,typeof f.onMount=="function"&&Se(Te,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Se(Ce,o,()=>{f.onUnmount?.();}),l=f.render();}else l=t(i);we(a);let u=yo(l);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)Le(f,c),Jt(f,r);else Le(u,c),u instanceof Node&&Jt(u,r);return u}};return r}function xt(t,e){let n=e.$constructor();n instanceof Node&&t.appendChild(n),queueMicrotask(()=>{ie(e);});}function yo(t){return t instanceof Node?t:z(t)?t.$constructor():typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):document.createTextNode("")}var en={className:"class",htmlFor:"for"},tn=new Set(["value","defaultValue","checked","selected","indeterminate"]),bo=new Set(["srcdoc"]),xo=new Set(["href","src","action","formaction","xlink:href"]),So=new Set(["securitypolicyviolation"]),Co=new Set(["contenteditable","draggable","spellcheck"]);function xe(t){return t!=null&&typeof t=="object"&&typeof t.get=="function"&&!(t instanceof Node)}var ln=Symbol("Fragment");function E(t,e,n){if(t===ln){let r=document.createDocumentFragment();return pt(r,on(n)),r}if(typeof t=="function")return Eo(t,e||{},n);typeof t!="string"&&(n=e,e=t,t="div"),e=e||{};let o=document.createElement(t);return e.id&&o.setAttribute("id",e.id),$e(o,e),pt(o,on(n)),o}function mt(t,e){e instanceof DocumentFragment?t.replaceChildren(e):t.innerHTML=e??"";}function ko(t){return typeof t!="string"?false:t.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function _o(t,e){if(typeof t!="string")return false;let n=t.toLowerCase();return bo.has(n)?true:xo.has(n)&&e!==null&&e!==void 0&&ko(String(e))}function un(t){return typeof t!="string"?t:en[t]?en[t]:t}function No(t,e){let n=un(t),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Co.has(o)&&(e===true||e===false||e==="true"||e==="false")?String(e):e==null||e===false?null:e}function nn(t,e,n){let o=No(e,n);if(o===null){t.removeAttribute(e);return}if(_o(e,o)){t.removeAttribute(e),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(e)}" on <${t.tagName.toLowerCase()}>`);return}t.setAttribute(e,o);}function $e(t,e){let n=$();for(let[o,r]of Reflect.ownKeys(e).map(s=>[s,e[s]]))if(o!=="id"){if(o=un(o),o==="$ref"){typeof r=="function"?r(t):typeof r=="object"&&r!==null&&(r.current=t);continue}if(o==="$dangerouslySetInnerHTML"){if(xe(r)){let s=D(()=>{G(n,()=>{mt(t,r.get());});});q(t,s);}else if(typeof r=="function"){let s=D(()=>{G(n,()=>{mt(t,r());});});q(t,s);}else mt(t,r);continue}if(o==="style"){if(xe(r)){let s=D(()=>{G(n,()=>{Object.assign(t.style,r.get());});});q(t,s);}else typeof r=="object"&&r!==null?Object.assign(t.style,r):t.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(So.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${t.tagName.toLowerCase()}>`);continue}t.addEventListener(s,r);continue}if(xe(r)||typeof r=="function"){let s=o,i=D(()=>{G(n,()=>{let a=typeof r=="function"?r():r.get();tn.has(s)?t[s]=a??"":nn(t,s,a);});});q(t,i);continue}tn.has(o)||typeof o=="symbol"?t[o]=r??"":nn(t,o,r);}}function on(t){return t==null?[]:Array.isArray(t)?t.flat(Number.POSITIVE_INFINITY):[t]}function pt(t,e){for(let n of e)fn(t,n);}function fn(t,e){if(!(e==null||e===false||e===true)){if(e instanceof Node){t.appendChild(e);return}if(typeof e=="string"||typeof e=="number"){t.appendChild(document.createTextNode(String(e)));return}if(typeof e=="function"){rn(t,e);return}if(z(e)){xt(t,e);return}if(xe(e)){rn(t,()=>e.get());return}if(Array.isArray(e)){pt(t,e);return}t.appendChild(document.createTextNode(String(e)));}}function ae(t){let e=null,n=t;return z(t)&&(e=t,n=t.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:e}:n instanceof Node?{nodes:[n],instance:e}:n==null||n===false||n===true?{nodes:[],instance:e}:{nodes:[document.createTextNode(String(n))],instance:e}}function je(t,e=true){for(let n of t)e&&ke(n),n.remove();}function rn(t,e){let n=$(),o=document.createComment("");t.appendChild(o);let r=[],s=D(()=>{G(n,()=>{let i=e(),{nodes:a,instance:c}=ae(i);je(r),a.length&&o.after(...a),c&&queueMicrotask(()=>ie(c)),r=a;});});q(t,s);}var Ue=class{constructor(t){this.props=t;}};function mn(t,e,n,o){let{equals:r=se,tagName:s="span",...i}=o??{},a=ht(s,"data-for",i);$e(a,i);let c=$(),l=[],u=new Map,f=B(()=>t()),d=D(()=>{let h=f.get(),x=Array.isArray(h)?h:[],_=[],N=[],g=new Set;for(let b=0;b<x.length;b++){let A=x[b],v=e(A,b);if(g.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${b}`);continue}g.add(v),_.push(A),N.push(v);}let y=new Map(l.map(b=>[b.key,b])),k=[];for(let b=0;b<_.length;b++){let A=N[b],v=_[b],U=y.get(A);if(U)u.get(A).set(v),k.push(U),y.delete(A);else {let Ee=C(v,{equals:r});u.set(A,Ee);let at={...Ee,set(){}},X={key:A,nodes:[]};G(c,()=>{let ro=n(at,b),{nodes:so,instance:Kt}=ae(ro);X.nodes=so,Kt&&queueMicrotask(()=>ie(Kt));}),k.push(X);}}for(let[b,A]of y)je(A.nodes),u.delete(b);let S=null;for(let b=k.length-1;b>=0;b--){let A=k[b].nodes;for(let v=A.length-1;v>=0;v--){let U=A[v];(U.parentNode!==a||U.nextSibling!==S)&&a.insertBefore(U,S),S=U;}}l=k;});return q(a,d),a}function St(t,e,n,o){if(typeof t=="function")return mn(t,e,n,o);let{each:r,keyFn:s,equals:i,tagName:a,children:c,...l}=t??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=dt(r),f=gt(t??{},e);return mn(u,s,f,{...l,equals:i,tagName:a})}St[Oe]=t=>t!=="each";function J(t,e){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("mount: container not found");t instanceof DocumentFragment||(ke(t),t.innerHTML=""),z(e)?xt(t,e):e instanceof Node?t.appendChild(e):t.appendChild(document.createTextNode(String(e)));}function dn(t){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("unmount: container not found");ke(t),t.innerHTML="";}function _e(t,e){let n=null;if(z(e)?(n=e.$constructor(),queueMicrotask(()=>ie(e))):e instanceof Node?n=e:n=document.createTextNode(String(e)),n instanceof HTMLElement){let o=B(()=>!!t()),r=D(()=>{n.style.display=o.get()?"":"none";});q(n,r);}return n}var L=class extends Ue{static get nodeName(){return "span"}static get style(){return "SPAN"}static match(e){return e.nodeName===this.nodeName.toUpperCase()||e.style===this.style}getState(){return {style:this.constructor.style}}render(){return E(this.constructor.nodeName,{},this.props.children)}};var ce=class extends L{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return E("b",{},"B")}static match(e){return e.nodeName==="strong"?true:super.match(e)}};var le=class extends L{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return E("i",{},"I")}};var ue=class extends L{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return E("sub",{},"Sub")}};var fe=class extends L{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return E("sup",{},"Sup")}};var me=class extends L{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return E("u",{},"U")}};var j=Symbol("result-key"),Ke=Symbol("stopped-event");function gn(t,e){let n=!!e.name,o=e[j]||"result",r=o.includes("."),s={error:null,context:{},[j]:o,...e,[o]:n?void 0:Q(e,o),name:t,[Ke]:false,defaultPrevented:false};return r&&(Ro(s,o),s[o]=n?void 0:Q(e,o)),s.stopPropagation=()=>{s[Ke]=true;},s.preventDefault=()=>{s.defaultPrevented=true;},s}function Q(t,e){return e===""?t:e.split(".").reduce((o,r)=>o?.[r]??void 0,t)}function Ct(t,e,n){let o=e.split("."),r=o.pop(),s=Q(t,o.join("."));return s[r]=n}function Ro(t,e){let n=e.split(".");n.pop(),n.reduce((o,r)=>o[r]=o[r]??{},t);}var Fe=class{constructor({logger:e,debug:n}={}){this._logger=e??console,this._debug=n??false,this._events=new Map,this.addListener=this.on,this.removeListener=this.off;}emit(e,n={}){let o=this.listeners(e),r=gn(e,n),s=null,i=null;this._debug&&(typeof this._debug=="function"?this._debug(e,r):this._logger.debug(`Event name: ${e}, event: ${r}`));for(let a of o){if(s&&(s=s.then(c=>(Ct(r,r[j],c??Q(r,r[j])),r[Ke]?Q(r,r[j]):a(r)))),!s){if(r[Ke])return r;i=a(r);}i instanceof Promise&&!s?s=i:Ct(r,r[j],i??Q(r,r[j]));}return s?s.then(a=>(Ct(r,r[j],a??Q(r,r[j])),r)):r}emitParallel(e,n={}){let o=this.listeners(e),r=gn(e,n);return Promise.all(o.map(async s=>await s(r))).then(s=>(r[r[j]]=s,r)).catch(s=>{throw r.error=s,s})}listeners(e){return this._events.has(e)?[...this._events.get(e)]:[]}removeAllListeners(e){return e?this.listeners(e).forEach(n=>this.off(e,n)):Array.from(this._events.keys()).forEach(n=>this.removeAllListeners(n))}_addListener(e,n,o){return this._events.has(e)||this._events.set(e,[]),this._events.get(e)[o](n),()=>{this.off(e,n);}}on(e,n){if(typeof n!="function")throw new TypeError("The listener must be a function");return this._addListener(e,n,"push")}prependListener(e,n){return this._addListener(e,n,"unshift")}_addListenerOnce(e,n,o){let r=this[o](e,s=>(r(),n(s)));}once(e,n){return this._addListenerOnce(e,n,"on")}prependOnceListener(e,n){return this._addListenerOnce(e,n,"prependListener")}off(e,n){if(this._events.has(e)){let o=this._events.get(e),r=o.indexOf(n);o.splice(r,1);}}};var m={INSERT_BLOCK_ELEMENT:"mrakomor:insert-block-component",REPLACE_BLOCK_ELEMENT:"mrakomor:replace-block-component",REMOVE_BLOCK_ELEMENT:"mrakomor:remove-block-component",MERGE_BLOCK_ELEMENT:"mrakomor:merge-block-component",INSERT_ENTITY_RANGE:"mrakomor:insert-entity-range",REMOVE_ENTITY_RANGE:"mrakomor:remove-entity-range",INSERT_INLINE_STYLE_RANGE:"mrakomor:insert-inline-style-range",KEYDOWN:"mrakomor:keydown",BEFORE_INPUT:"mrakomor:beforeinput",INPUT:"mrakomor:input",CLICK:"mrakomor:click",FOCUSIN:"mrakomor:focusin",FOCUSOUT:"mrakomor:focusout",SELECTION_CHANGE:"mrakomor:selection-change",CONTENT_CHANGE:"mrakomor:content-change",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element",MOVE_BLOCK_ELEMENT:"mrakomor:move-block-element"};function T(t){return e=>{if(!e.defaultPrevented)return t(e)}}function hn({mrakomor:t}={}){let e=t?.emitter??new Fe;function n(o,r={}){return typeof t?.emit=="function"?t.emit(o,r):e.emit(o,{...r,mrakomor:t})}return {emitter:e,command:{insertBlockElement(o,r){n(m.INSERT_BLOCK_ELEMENT,{...o,options:r});},replaceBlockElement(o,r){n(m.REPLACE_BLOCK_ELEMENT,{...o,options:r});},removeBlockElement(o,r){n(m.REMOVE_BLOCK_ELEMENT,{...o,options:r});},mergeBlockElement(o,r){n(m.MERGE_BLOCK_ELEMENT,{...o,options:r});},insertEntityRange(o,r){n(m.INSERT_ENTITY_RANGE,{...o,options:r});},removeEntityRange(o,r){n(m.REMOVE_ENTITY_RANGE,{...o,options:r});},insertInlineStyleRange(o,r){n(m.INSERT_INLINE_STYLE_RANGE,{...o,options:r});},transformBlockElement(o,r){n(m.TRANSFORM_BLOCK_ELEMENT,{...o,options:r});},moveBlockElement(o,r){n(m.MOVE_BLOCK_ELEMENT,{...o,options:r});}}}}var En=class{#e=new Set;pipe(...t){return vo(...t)(this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t);});}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e);});}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e);});}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#e.delete(t);}};function vo(...t){return e=>Array.from(t).reduce((n,o)=>o(n),e)}function yn(t){return t.map((e,n)=>({entry:e,index:n})).sort((e,n)=>{let o=e.entry.order??e.index,r=n.entry.order??n.index;return o!==r?o-r:e.index-n.index}).map(({entry:e})=>e)}var pe=class extends En{mrakomor;#e=new Map;#o=null;#t=0;#n;constructor(e,n={}){super(),this.mrakomor=e,this.#n=n.sort??yn;}normalize(e,n){throw new Error("Register subclass must implement normalize")}#r(){this.#o=null,this.next(this.list());}#i(e,n=this.#t++){let o=this.normalize(e,n);return o?(this.#e.set(o.id,o),o):null}add(e){if(Array.isArray(e)){let o=[];for(let r of e){let s=this.#i(r,this.#t++);s&&o.push(s);}return o.length&&this.#r(),o}let n=this.#i(e);return n&&this.#r(),n}get(e){return this.#e.get(e)}has(e){return this.#e.has(e)}remove(e){let n=this.#e.delete(e);return n&&this.#r(),n}list(){return this.#o??=this.#n([...this.#e.values()]),this.#o}};var Io={abortEarly:true};function Rt(t,e){if(e===void 0)return t;let n=t?.cause?.key?`${e}.${t.cause.key}`:`${e}`;return {message:`Error parsing key "${n}": ${t.message}`,cause:{key:n}}}function Bo(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(Rt(t.errors[o],n));}function Sn(t,e,n,o){if(n!==false){let r=Rt(t.error,e);return {success:false,error:r,errors:[r]}}Bo(t,o,e);}function He(t){return t?.abortEarly!==void 0?t:Io}function kt(t,e){I(t,"_parse",(n,o,r)=>{let s=n(o,r);return !s.success&&e(o)?{success:true,data:o}:s});}var Ne=t=>typeof t=="string"||t instanceof String,_t=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),Nt=t=>t===true||t===false,Mo=t=>t instanceof Date&&!Number.isNaN(t.getTime()),wo=t=>typeof t=="function",Lo=t=>Array.isArray(t),At=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Cn(t,e){let n=O(At,{...e,type:"object"});n._getDescription=()=>`object({ ${Object.entries(t).map(([r,s])=>`${r}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>t;let o=n;return o.derive=function(r,{when:s="always"}={}){return I(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=r(l.data,{context:c?.context});if(!At(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(s==="missing"){let f={...l.data};for(let d in u)f[d]===void 0&&(f[d]=u[d]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},I(n,"_parse",(r,s,i)=>{let a=r(s,i),{abortEarly:c}=He(i);if(a.success===false)return a;let l={},u=[];for(let f in t){let d=t[f]._parse(a.data[f],i);if(d.success)l[f]=d.data;else {let h=Sn(d,f,c,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),o}function vt(t){return O(Ne,{...t,type:"string"})}function It(t){return O(_t,{...t,type:"number"})}function Bt(t){return O(Nt,{...t,type:"boolean"})}function Mt(t){return O(Mo,{...t,type:"date"})}function kn(t){return O(wo,{...t,type:"function"})}function _n(t,e){let n=i=>t.includes(i),o=i=>`Invalid ${r} value. Expected ${t.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,r="enum",s=O(n,{message:o,...e,type:r});return s._getDescription=()=>`enum(${t.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>t,s}function Nn(t,e){let n=O(Lo,{...e,type:"array"});return n._getDescription=()=>`array(${t._getDescription()})`,n._getDefinition=()=>t,I(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:a}=He(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let f=0;f<i.data.length;f++){let d={...u,context:{...u?.context,index:f}},h=t._parse(i.data[f],d);if(h.success)c.push(h.data);else {let x=Sn(h,f,a,l);if(x)return x}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function An(){return O(()=>true)}function de(t,e){return I(e,"_parse",(n,o,r)=>(o=t(o),n(o,r))),e}function Rn(t,e){let n=r=>`Invalid union value. Expected the value to match one of the schemas:${t.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof r}" with value: ${At(r)?JSON.stringify(r):`"${r}"`}`,o=O(()=>false,{message:n,...e,type:"union"});return o._getDefinition=()=>t,I(o,"_parse",(r,s,i)=>{let a=i,c=[];for(let d=0;d<t.length;d++){let h=t[d]._parse(s,a);if(h.success)return h;c.push(h);}let{abortEarly:l}=He(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let d=0;d<c.length;d++){let h=c[d].errors;if(h?.length)for(let x=0;x<h.length;x++)h[x].cause?.key&&f.push(Rt(h[x],`branch ${d}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),o}function vn(t,e){let n=O(o=>o===t,{message:o=>e?.message?typeof e.message=="function"?e.message(o):e.message:`Expected literal value "${t}", received "${o}"`,name:e?.name,type:"literal"});return n._getDescription=()=>`literal("${t}")`,n._getDefinition=()=>t,n}function In(t){let e=O(()=>true,{type:"contextRef"});return e._getDescription=()=>`contextRef("${t}")`,I(e,"_parse",(n,o,r)=>({success:true,data:r?.context?.[t]})),e}function Bn(t,e){return {parse(n,o){let r=t.parse(o?.context??{},o);return e(r).parse(n,o)},safeParse(n,o){let r=t.safeParse(o?.context??{},o);return r.success?e(r.data).safeParse(n,o):r}}}var Mn={boolean(t){let e=t?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return de(n=>{let o;return Ne(n)&&(o=n.toLowerCase()),o==="true"||o==="yes"||o==="on"||o==="1"||n===1?true:o==="false"||o==="no"||o==="off"||o==="0"||n===0?false:n},Bt({...t,message:e}))},number(t){let e=t?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return de(n=>{if(Nt(n))return Number(n);if(Ne(n)){let o=n.trim();if(o==="")return n;let r=Number(o);if(Number.isFinite(r))return r}return n},It({...t,message:e}))},string(t){let e=t?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return de(n=>Nt(n)||_t(n)&&Number.isFinite(n)?String(n):n,vt({...t,message:e}))},date(t){let e=t?.message??(n=>`Cannot cast "${n}" to a valid date.`);return de(n=>{let o;return Ne(n)&&(o=n.trim()),_t(n)&&Number.isFinite(n)||o?new Date(o??n):n},Mt({...t,message:e}))},json(t,e){let n=e?.message??(o=>`Cannot parse "${o}" as JSON.`);return I(t,"_parse",(o,r,s)=>{if(Ne(r))try{r=JSON.parse(r);}catch{let i={message:typeof n=="function"?n(r):n};return {success:false,error:i,errors:[i]}}return o(r,s)}),t}},wn={},p={object:Cn,string:vt,number:It,boolean:Bt,date:Mt,function:kn,enum:_n,array:Nn,any:An,preprocess:de,union:Rn,literal:vn,contextRef:In,withContext:Bn,coerce:wn,cast:Mn};function bn(t){return e=>`The value "${e}" must be type of ${t} but is type of "${typeof e}".`}function I(t,e,n){let o=t[e];t[e]=(...r)=>n(o,...r);}function O(t,{type:e="any",name:n,message:o}={}){o=o||bn(e);let r={name:n,message:o,type:e},s={_getName(){return n},_getType(){return e},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=t(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof o=="function"?o(i):o};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return kt(this,i=>i===void 0),this},nullable(){return kt(this,i=>i===null),this},nullish(){return kt(this,i=>i==null),this},default(i){return I(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return I(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||bn(c),e=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return I(this,"_parse",(u,f,d)=>{let h=u(f,d),{abortEarly:x}=He(d);if(!h.success)return h;let _=i(h.data);if(_===true||typeof _=="object"&&_?.success===true)return h;let N={message:typeof a=="function"?a(f):a};return {success:false,error:N,errors:[N]}}),this},clone(){return {...this}}};return xn.length>0?xn.reduce((i,a)=>a(i,t,r)??i,s):s}var xn=[];var To=p.object({component:p.function(),id:p.string(),label:p.string(),keywords:p.array(p.string()),group:p.string(),order:p.number().default(({context:t})=>t?.index??0),settings:p.any().optional()});function Oo(t,e){let n=`block:${t}`;return e?.style==="UNORDERED"?`${n}:ul`:e?.style==="ORDERED"?`${n}:ol`:n}function Ln(t,e=0){let n=typeof t=="function",o=n?t:t?.component,r=n?{}:t,s=o.NAMESPACE??"",i=s.split(".").pop()||s,a=r.label||o.LABEL||i||s,c=Array.isArray(o.KEYWORDS)?o.KEYWORDS:[],l=r.keywords?.length?r.keywords.map(String):c.length?c.map(String):[a,i].filter(Boolean).map(String),u=r.settings;return To.parse({component:o,id:r.id||Oo(s,u),label:String(a),keywords:l,group:String(r.group||o.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...u?{settings:u}:{}},{context:{index:e}})}var qe=class t extends pe{#e=null;constructor(e){super(e),this.subscribe(()=>{this.#e=null;});}normalize(e,n){if(e==null)return null;try{return Ln(e,n)}catch{return null}}getByNamespace(e){return this.#o().get(e)}#o(){return this.#e??=t.buildNamespaceMap(this.list()),this.#e}static buildNamespaceMap(e){let n=new Map;for(let o of e){let r=o.component?.NAMESPACE;r&&!n.has(r)&&n.set(r,o.component);}return n}};var wt="molecule.paragraph.Paragraph";var Tn="molecule.external.ExternalComponent",On="namespace.unknown.UnknownComponent";var Dn="molecule.headline.";var Lt=Dt(),Tt=Dt(),Pn=Dt(),Do=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function Dt(){return Math.floor(Math.random()*16777215)}function Po(){return Tt=(Tt+1)%16777215,Tt}function V(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Po(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Lt>>16&255,Lt>>8&255,Lt&255,Pn>>8&255,Pn&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=Do[n.charCodeAt(r)];return o}var Ae=Symbol("block-element"),$o=Symbol("block-element-body"),Ge=Symbol("selectable-element");function ze(t,e){let n=t;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[e]===void 0;)n=n.parentElement;return n??null}function Y(t){return t?ze(t.startContainer,Ae):null}function $n(t){return ze(t,Ae)}function jo(t){return t?ze(t.startContainer,Ge):null}function jn(t){return ze(t,Ge)}function Pt(){return window.getSelection()}function W(){let t=Pt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function $t(){let t=W();if(!t)return 0;t.collapse(true);let e=jo(t),n=Y(t),o=e??M(n);return ge(o,t.startContainer,t.startOffset)}function ge(t,e,n){if(!t)return 0;if(e===t){if(e.nodeType===Node.TEXT_NODE)return n;let i=0,a=t.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].textContent.length;return i}if(e.nodeType===Node.ELEMENT_NODE&&!t.contains(e))return 0;let o=0,r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),s=r.nextNode();for(;s;){if(s===e)return o+n;o+=s.textContent.length,s=r.nextNode();}return o}function Kn(t=W()){if(!t||t.collapsed)return null;let e=$n(t.startContainer),n=$n(t.endContainer);if(!e||!n)return null;let o=jn(t.startContainer)??M(e),r=jn(t.endContainer)??M(n);return {startBlock:e,endBlock:n,startOffset:ge(o,t.startContainer,t.startOffset),endOffset:ge(r,t.endContainer,t.endOffset)}}function Ot(t,e){let n=document.createRange();if(!t)return n;if(e<=0)return n.setStart(t,0),n.collapse(true),n;let o=0,r=[t];for(;r.length>0;){let s=r.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(o+i>=e)return n.setEnd(s,e-o),n.setStart(s,e-o),n;o+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)r.push(s.childNodes[i]);}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function ee(t,e){let n=Ot(t,e),o=Pt();o.removeAllRanges(),o.addRange(n);}function M(t){if(!t)return null;let e=Ve(t);return e?.firstElementChild??e?.firstChild}function P(t){if(!t?.[Ae])return null;let e=M(t);return e?re(e)?.classInstance:null}function Ve(t){if(!t)return null;for(let e of t.children)if(e[$o])return e;return null}function Ye(t,e,n,o=12){let r=t.getBoundingClientRect(),s=typeof e?.getBoundingClientRect=="function"?e.getBoundingClientRect():e??{left:0,top:0},i=n?.offsetHeight??40;return {x:s.left-r.left,y:s.top-r.top-i-o}}function Fn(t,e){let n=t.getBoundingClientRect(),o=e?.offsetWidth??420,r=e?.offsetHeight??320,s=16;return {x:Math.max(s,(n.width-o)/2),y:Math.max(s,(n.height-r)/2)}}var We=Et();var Xe=class extends Ue{state;element;mrakomor;constructor(e){super(e);let{state:n,observeDOMChanges:o=true}=e??{};this.state=n,this.element=null,this.mrakomor=bt(We),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=o;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return p.object({component:p.string().default(this.NAMESPACE),properties:p.object().default({}),settings:p.object().default({})}).default({})}static getPropsSchema(){return p.object({state:this.getStateSchema(),observeDOMChanges:p.boolean().default(true)}).default({})}parseFromHTML(e){return this.constructor.getStateSchema(e).parse()}getState(){if(this._stale){let e=this.element;return this.parseFromHTML(e)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=e=>{let n=e.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(m.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};function te(t){return t===`
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===`
3
3
  `||t===`\r
4
- `?"":t??""}function Re({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{};return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{...r,text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]},...o?{settings:o}:{}}}function Je(t){let e=t?.component??"";return e===wt||e.startsWith(Dn)}function jt(t,e){let n=te(t.properties.text),o=te(e.properties.text);return {state:{...t,properties:{...e.properties,...t.properties,text:n+o,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(r=>({...r,offset:r.offset+n.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(r=>({...r,offset:r.offset+n.length}))]},settings:{...e.settings,...t.settings}},cursor:n.length}}function zn(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],a=s[n],{originalLineState:c}=Gn(i,o),{newLineState:l}=Gn(a,r),{state:u,cursor:f}=jt(c,l);return s.splice(e,n-e+1,u),{content:s,cursor:f,resultIndex:e}}function Hn(t,e){return (t??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)}))}function qn(t,e){return (t??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)}))}function Gn(t,e){let n=structuredClone(t),o=structuredClone(t);return n.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),n.properties.inlineStyleRanges=Hn(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=qn(t.properties.inlineStyleRanges,e),n.properties.entityRanges=Hn(t.properties.entityRanges,e),o.properties.entityRanges=qn(t.properties.entityRanges,e),o.componentId=V(),{originalLineState:n,newLineState:o}}function Vn(t,e){if(e.key!=="Enter")return false;e.preventDefault();let n=wt,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:W(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:n}),true}function Yn(t,e){let n=ge(t,e.startContainer,e.startOffset),o=ge(t,e.endContainer,e.endOffset);return {offset:n,length:Math.max(0,o-n)}}function Fo(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(a=>a.style===e&&a.offset<=n&&a.offset+a.length>=s);return i?r.filter(a=>a!==i):[...r,{style:e,offset:n,length:o}]}function Ho(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function qo(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!Ho(r,e)){o.push(r);continue}r.offset<e.offset&&o.push({...r,length:e.offset-r.offset});let s=r.offset+r.length;s>n&&o.push({...r,offset:n,length:s-n});}return o}function Go(t,e){let n=t??[],o=e?.length??0;if(o===0)return null;let r=e.offset??0,s=e.entity?.type,i=n.find(a=>a.offset===r&&a.length===o&&a.entity?.type===s);return i?n.filter(a=>a!==i):[...qo(n,e),e]}function Wn(t,e,{style:n,range:o}){if(!t||!e?.element||!o)return null;let r=e.read(t);if(r?.inlineStyleRanges===void 0)return null;let{offset:s,length:i}=Yn(e.element,o);return i===0?null:(e.write(t,{inlineStyleRanges:Fo(r.inlineStyleRanges??[],{style:n,offset:s,length:i})}),t)}function Xn(t,e,{state:n,namespace:o,range:r}){if(!t||!e?.element||!r)return null;let s=e.read(t);if(s?.entityRanges===void 0)return null;let i={...n,entity:{type:o,...n?.entity},...Yn(e.element,r)},a=Go(s.entityRanges??[],i);return a===null?null:(e.write(t,{entityRanges:a}),t)}var Qe=class extends Xe{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(e){let n=()=>{if(!this.element?.isConnected)return;let o=typeof e=="number"?e:te(this.getState()?.properties?.text).length;ee(this.element,o);};n(),R(n);}onKeydown(e){}getFormattingTarget(e){return null}static toExchangeState(e){return Re({originComponent:this.NAMESPACE,properties:{...e?.properties,text:te(e?.properties?.text)},settings:e?.settings})}static fromExchangeState(e){return {properties:e?.properties,settings:e?.settings}}static appendExchangeState(e,n){return jt(e,n)}};var ne=class t extends Qe{static get NAMESPACE(){return Tn}static getStateSchema(e){return p.object({component:p.string().default(t.NAMESPACE),componentId:p.string().default(e?.getAttribute("data-componentid")||V()),properties:p.object({}).default({}),settings:p.object({}).default({})}).default({})}constructor(e){super(e),this.root=null;}getState(){return this.state.peek()}isAtomic(){return true}static appendExchangeState(){return null}onMount(){}onUnmount(){}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E("div",{className:e,contentEditable:false,style:"position: relative;",$ref:o=>{this.element=o;},"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[E("div",{$ref:o=>{this.root=o;},style:"display: block;",contentEditable:false}),E("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:true,[Ge]:true},document.createTextNode("\xA0"))])}onKeydown(e){e.key!=="Backspace"&&e.key!=="ArrowUp"&&e.key!=="ArrowDown"&&e.preventDefault(),Vn(this,e);}};var he=class extends ne{static get NAMESPACE(){return On}onMount(){let e=E("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);J(this.root,e);}onUnmount(){this.root.innerHTML="";}};function zo(t,e){let n=t._getBlockElementByComponentId(e);return P(n)?.isStale?.()??false}function Jn(t){return (e,n)=>{if(!se(e,n))return false;let o=n?.componentId??e?.componentId;return !(o&&zo(t,o))}}function Qn({mrakomor:t}){let e=t.get(),n=Jn(e);return yt(We,e),De(()=>{e._onMount();}),Pe(()=>{e._onUnmount();}),E("div",{id:e._id,className:"mrakomor-editor"},[E("div",{className:"mrakomor-editor-surface"},[E("div",{className:"mrakomor-tools-container"}),E("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"}},[St(()=>e._getContentState(),o=>o.componentId,(o,r)=>E(()=>{let s;De(()=>{s.getNodeComponent=()=>{let c=M(s);return c?re(c):null},e._setBlockElement(s,r);}),Pe(()=>{e._removeBlockElement(s);});let i=e.resolveComponent(o.get().component,o),a=e.wrapBlockElement(i);return E("div",{className:"mrakomor-block-element",[Ae]:true,$ref:c=>{s=c;}},a)}),{equals:n})])])])}function Ze(t,e,n){let o=t._getBlockElementIndex(e);if(o===-1)return false;let r=t.getContent();return r.splice(o,1,t.normalizeComponentState(n)),t._setContentState(r),true}function Zn(t,{customHook:e,applyFn:n,applyArgs:o,resolveRange:r=true}){let{mrakomor:s}=t,{blockElement:i,range:a}=t;r&&(a=a??W(),i=i??Y(a));let c=P(i),l=c?.[e]?.(t);if(t.defaultPrevented){l&&Ze(s,i,l);return}let u=c?.getFormattingTarget?.(a);if(!u)return;let f=s._getBlockElementState(i);if(!f)return;let d=n(structuredClone(f),u,{...o,range:a});d&&Ze(s,i,d);}function Vo(t){let{mrakomor:e}=t,{blockElement:n,range:o,newLineState:r,originalLineState:s,namespace:i,position:a,cursor:c}=t,l,u;if(a||(n?l=e._getBlockElementIndex(n):o&&(l=e._getBlockElementIndex(Y(o))),l===void 0||l===-1))return;u=l+1;let f=e.getContent();s&&f.splice(l,1,e.normalizeComponentState(s)),r&&(r.component=i,f.splice(u,0,e.normalizeComponentState(r))),e._setContentState(f),R(()=>{typeof c=="number"&&P(e._getBlockElements()[u])?.setCursor?.(c);});}function Yo(t){let{mrakomor:e}=t,{blockElement:n,range:o,blocks:r,cursor:s,cursorBlockIndex:i=0}=t;if(!Array.isArray(r)||r.length===0)return;let a=n??(o?Y(o):null),c=e._getBlockElementIndex(a);if(c===-1)return;let l=[...e._getContentState()];l.splice(c,1,...r.map(u=>e.normalizeComponentState(u))),e._setContentState(l),R(()=>{if(typeof s!="number")return;e._syncBlockElementsFromDom();let u=M(e._getBlockElements()[c+i]);u?.isConnected&&ee(u,s);});}function Wo(t){let{mrakomor:e,blockElement:n,namespace:o}=t,r=e._getBlockElementState(n);if(!r)return;let s=e.register.blocks.getByNamespace(r.component),i=e.register.blocks.getByNamespace(o),a=t.exchangeState??s?.toExchangeState?.(r)??Re({properties:r.properties,settings:r.settings}),c=i?.fromExchangeState?.(a)??a;Ze(e,n,{...c,component:o,componentId:V()});}function Xo(t){let{mrakomor:e,blockElement:n,targetIndex:o}=t,r=e._getBlockElementIndex(n);if(r===-1||typeof o!="number")return;let s=o>r?o-1:o;if(s===r)return;let i=[...e._getContentState()],[a]=i.splice(r,1);i.splice(s,0,a),e._setContentState(i);}function Jo(t){let{mrakomor:e,blockElement:n,range:o}=t,r=e._getBlockElementIndex(n);if(r!==-1){let s=e.getContent();s.splice(r,1),e._setContentState(s);}R(()=>{let s=Y(o);ee(M(s),0);});}function Qo(t){let{mrakomor:e,state:n,blockElement:o}=t,r=e._getBlockElementState(o);if(!r)return;let s=structuredClone(r),i=n?.offset,a=n?.length,c=n?.entity?.type;s.properties.entityRanges=(s.properties.entityRanges??[]).filter(l=>!(l?.offset===i&&l?.length===a&&l?.entity?.type===c)),Ze(e,o,s),e.command.closeDialog?.();}function Zo(t){Zn(t,{customHook:"insertEntityRange",applyFn:Xn,applyArgs:{state:t.state,namespace:t.namespace}});}function er(t){Zn(t,{customHook:"insertInlineStyleRange",applyFn:Wn,applyArgs:{style:t.style}});}function tr(t){let{mrakomor:e,blockElement:n,previousBlockElement:o}=t,r=e._getBlockElementIndex(o),s=e._getBlockElementIndex(n);if(r===-1||s===-1)return;let i=e.getContent(),a=i[s],c=i[r],l=e.register.blocks.getByNamespace(c.component),u=e.register.blocks.getByNamespace(a.component),f=t.exchangeState??u?.toExchangeState?.(a)??Re({properties:a.properties,settings:a.settings}),d=l?.appendExchangeState?.(c,f);if(!d)return;i.splice(s,1),i.splice(r,1,e.normalizeComponentState(d.state)),e._setContentState(i);let h=()=>{if(typeof d.cursor!="number")return;let x=e._getBlockElements()[r]??o,_=M(x);_?.isConnected&&ee(_,d.cursor);};h(),R(h);}function nr(t){let{mrakomor:e}=t,n=e.getRoot();if(t.relatedTarget instanceof Node&&n.contains(t.relatedTarget))return;let[r,s]=H(()=>[e.getContent(),e._getContentState()]);r.length===s.length&&r.every((a,c)=>a===s[c])||e.setContent(r);}function or(t){let e=W();return Y(e)?.getNodeComponent?.()?.classInstance?.onKeydown?.(t)}function rr(t){P(t)?.setCursor?.();}function sr(t){if(t.key!=="Backspace")return;let{mrakomor:e}=t,n=W();if(!n)return;let o=Y(n);if(!o)return;let r=Ve(o),s=o?.previousSibling,a=Ve(s)?.childNodes?.[0]?.contentEditable==="true",c=r?.childNodes?.[0]?.contentEditable==="true",l=M(o),u=!te(l?.textContent),f=n.collapsed&&(n.startOffset===0||$t()===0||u);if(!n.collapsed){let g=Kn(n);if(g&&g.startBlock!==g.endBlock){let y=e._getBlockElementIndex(g.startBlock),k=e._getBlockElementIndex(g.endBlock),S=e.getContent(),b=y>=0?S[y]:void 0,A=k>=0?S[k]:void 0;if(y>=0&&k>y&&typeof b?.properties?.text=="string"&&typeof A?.properties?.text=="string"){t.preventDefault();let{content:U,cursor:Ee,resultIndex:at}=zn(S,{startIndex:y,endIndex:k,startOffset:g.startOffset,endOffset:g.endOffset});e._setContentState(U.map(X=>e.normalizeComponentState(X))),R(()=>{let X=e._getBlockElements()[at];X&&typeof Ee=="number"&&ee(M(X),Ee);});}}return}if(!f)return;let d=e._getBlockElementIndex(o),h=s?e._getBlockElementIndex(s):-1,x=e._getBlockElementState(o),_=e._getBlockElementState(s),N=s?P(s):null;if(!s||h<0){t.preventDefault();return}if(_&&x&&Je(x)&&N&&!N.isAtomic?.()){if(u&&!Je(_)){t.preventDefault();let g=e.getContent();g.splice(d,1),e._setContentState(g),rr(s);return}t.preventDefault(),e.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:n});return}N?.isAtomic?.()&&(!a&&n.startOffset===0||o?.textContent==="\xA0"&&!c)&&(t.preventDefault(),e.command.removeBlockElement({blockElement:s,range:n})),x&&!Je(x)&&t.preventDefault();}function et(t){return {resolveComponent:e=>e===ne.NAMESPACE?ne:he,registerCommands(e){e.emitter.on(m.INSERT_BLOCK_ELEMENT,T(Vo)),e.emitter.on(m.REPLACE_BLOCK_ELEMENT,T(Yo)),e.emitter.on(m.TRANSFORM_BLOCK_ELEMENT,T(Wo)),e.emitter.on(m.MOVE_BLOCK_ELEMENT,T(Xo)),e.emitter.on(m.REMOVE_BLOCK_ELEMENT,T(Jo)),e.emitter.on(m.REMOVE_ENTITY_RANGE,T(Qo)),e.emitter.on(m.INSERT_ENTITY_RANGE,T(Zo)),e.emitter.on(m.INSERT_INLINE_STYLE_RANGE,T(er)),e.emitter.on(m.MERGE_BLOCK_ELEMENT,T(tr));},registerHandlers(e){e.emitter.on(m.FOCUSOUT,nr),e.emitter.on(m.KEYDOWN,T(or)),e.emitter.on(m.KEYDOWN,T(sr));},registerListeners(e){let n=e.getRoot(),{signal:o}=e.listenerAbortController;n.addEventListener("keydown",r=>e.emitDomEvent(m.KEYDOWN,r),{signal:o}),n.addEventListener("beforeinput",r=>e.emitDomEvent(m.BEFORE_INPUT,r),{signal:o}),n.addEventListener("input",r=>e.emitDomEvent(m.INPUT,r),{signal:o}),n.addEventListener("focusin",r=>e.emitDomEvent(m.FOCUSIN,r),{signal:o}),n.addEventListener("focusout",r=>e.emitDomEvent(m.FOCUSOUT,r),{signal:o}),n.addEventListener("click",r=>e.emitDomEvent(m.CLICK,r),{signal:o}),document.addEventListener("selectionchange",r=>e.emitDomEvent(m.SELECTION_CHANGE,r),{signal:o});}}}(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/dialog/Dialog.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-dialog-container,.mrakomor-dialog-backdrop{pointer-events:all}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between}.dialog[open] .dialog-controls{text-align:right;width:100%}.dialog[open] .dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}.dialog[open] .dialog-container{width:100%}
5
- `,document.head.appendChild(n);}}})();function ir(t,e,n,o){let r=t.getRoot()?.querySelector(e);if(!r)return {container:null,dispose:null};let s=document.createElement("div");s.className=n,r.append(s);let i=J(s,o);return {container:s,dispose:i??null}}function tt(t,e,n){return ir(t,".mrakomor-tools-container",e,n)}var eo="mrakomor.dialog.Dialog";function nt({open:t,placement:e,positionX:n,positionY:o,block:r,dialogRef:s}){let i=B(()=>{let c=e.get()==="center";return {position:"absolute",zIndex:c?"9100":"9000",top:`${o.get()}px`,left:`${n.get()}px`,...c?{padding:0,background:"transparent",border:"none",boxShadow:"none",minWidth:0}:{background:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px 10px",boxShadow:"0 2px 8px rgba(0,0,0,.15)",minWidth:"220px"}}}),a=B(()=>({position:"absolute",inset:"0",zIndex:"9050",background:"rgba(15, 23, 42, 0.28)",pointerEvents:"all"}));return E("span",{style:{display:"contents"}},[_e(()=>t.get()&&e.get()==="center",E("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:a})),_e(()=>t.get(),E("div",{className:"mrakomor-dialog-container",contenteditable:false,style:i,$ref:s},()=>r.get()))])}nt.NAMESPACE=eo;function ot({mrakomor:t}){let e=null,n=C(false),o=C(false),r=C("anchor"),s=C(0),i=C(0),a=C(null),c=oe(),l=oe();function u(){o.set(false),r.set("anchor"),c.set(null),R(()=>{n.set(false);});}return {resolveComponent(f){if(f===eo)return nt},registerEvents(){m.OPEN_DIALOG="mrakomor:open-dialog",m.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(d,h)=>{f.emit(m.OPEN_DIALOG,{...d,options:h});},f.command.closeDialog=()=>{f.emit(m.CLOSE_DIALOG);};},registerHandlers(){t.emitter.on(m.OPEN_DIALOG,({children:f,element:d,options:h={}})=>{a.set(f??E("div",{},"Empty dialog")),o.set(true),c.set(d??null),r.set(h.placement??"anchor"),R(()=>{let x=t.getRoot(),{x:_,y:N}=h.placement==="center"?Fn(x,l):Ye(x,d??{left:0,top:0},l);s.set(_),i.set(N),n.set(true);});}),t.emitter.on(m.CLOSE_DIALOG,u),t.emitter.on(m.KEYDOWN,f=>{f.key==="Escape"&&o.peek()===true&&t.command.closeDialog();}),t.emitter.on(m.CLICK,f=>{if(o.peek()!==true||n.peek()!==true)return;let d=f.target,h=l&&typeof l.contains=="function"&&l.contains(d),x=c&&typeof c.contains=="function"&&c.contains(d);!h&&!x&&t.command.closeDialog();});},onMount(){let{dispose:f}=tt(t,"mrakomor-dialog-plugin-container",E(nt,{open:o,placement:r,positionX:s,positionY:i,block:a,dialogRef:l}));e=f;},onUnmount(){e?.(),e=null;}}}function ar(){return p.object({id:p.string(),group:p.string().default("general"),description:p.string().default(""),commands:p.array(p.string()).default([]),shortcuts:p.array(p.string()).default([])}).default({})}function to(t){try{return ar().parse(t)}catch{return null}}var rt=class extends pe{constructor(e){super(e,{sort:n=>n});}normalize(e){return to(e)}};(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/menu/Menu.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===t});if(!e){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",t),n.textContent=`.mrakomor-menu{position:absolute;z-index:9300;display:flex;flex-direction:column;gap:2px;min-width:160px;max-height:240px;overflow-y:auto;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-menu__item:hover,.mrakomor-menu__item--active{background:#ffffff26}
6
- `,document.head.appendChild(n);}}})();function cr(t,e=-1){if(!t.length)return null;let n=t.map((o,r)=>E("button",{type:"button",role:"option",id:`mrakomor-menu-option-${o.id}`,className:["mrakomor-menu__item",r===e?"mrakomor-menu__item--active":""].filter(Boolean).join(" "),title:o.label,"data-id":o.id,"aria-selected":r===e?"true":"false",onMouseDown:s=>{s.preventDefault();}},o.label));return E("span",{style:"display: contents"},n)}function Ut({open:t,positionX:e,positionY:n,entries:o,highlightIndex:r,ariaLabel:s,menuRef:i}){let a=B(()=>({left:`${e.get()}px`,top:`${n.get()}px`}));return _e(()=>t.get(),E("div",{className:"mrakomor-menu",role:"listbox","aria-label":()=>s.get(),contenteditable:false,style:a,$ref:i},()=>cr(o.get(),r.get())))}function st({mrakomor:t}){let e=null,n=null,o=oe(),r=null,s=C(false),i=C(false),a=C(0),c=C(0),l=C([]),u=C(-1),f=C("Menu");function d(g){R(()=>{let y=t.getRoot();if(!y||!g)return;let k=o?.offsetHeight??200,S=y.getBoundingClientRect();if(g.top-S.top>k+8){let{x:A,y:v}=Ye(y,g,{offsetHeight:k},4);a.set(A),c.set(v);}else a.set(g.left-S.left),c.set(g.bottom-S.top+4);s.set(true);});}function h(){i.set(false),r=null,u.set(-1),l.set([]),R(()=>{s.set(false);});}function x(g){!g||!r||r(g);}function _(g){if(i.peek()!==true)return;let y=g.target?.closest?.(".mrakomor-menu__item");if(!y||!n?.contains(y))return;g.preventDefault(),g.stopPropagation();let k=y.getAttribute("data-id"),S=l.peek().find(b=>b.id===k);S&&x(S);}function N(g={}){let{entries:y=[],anchorRect:k,highlightIndex:S=-1,ariaLabel:b="Menu",onSelect:A=null}=g;l.set(y),u.set(S),f.set(b),A!==void 0&&(r=A),i.set(true),k?d(k):s.set(true);}return {registerEvents(){m.OPEN_MENU="mrakomor:open-menu",m.CLOSE_MENU="mrakomor:close-menu",m.UPDATE_MENU="mrakomor:update-menu";},registerCommands(g){g.command.openMenu=y=>{g.emit(m.OPEN_MENU,y);},g.command.updateMenu=y=>{g.emit(m.UPDATE_MENU,y);},g.command.closeMenu=()=>{g.emit(m.CLOSE_MENU);};},registerHandlers(){t.emitter.on(m.OPEN_MENU,N),t.emitter.on(m.UPDATE_MENU,N),t.emitter.on(m.CLOSE_MENU,h),t.emitter.on(m.CLICK,g=>{let y=o?.current??o;i.peek()===true&&s.peek()===true&&y&&typeof y.contains=="function"&&!y.contains(g.target)&&h();}),t.emitter.on(m.KEYDOWN,g=>{g.key==="Escape"&&i.peek()===true&&h();});},onMount(){let{container:g,dispose:y}=tt(t,"mrakomor-menu-plugin-container",E(Ut,{open:i,positionX:a,positionY:c,entries:l,highlightIndex:u,ariaLabel:f,menuRef:o}));n=g,n?.addEventListener("click",_),e=y;},onUnmount(){n?.removeEventListener("click",_),e?.(),e=null,n=null,o.current=null,r=null;}}}function lr(t){return t!=null&&typeof t=="object"&&(typeof Element>"u"?t.nodeType===1:t instanceof Element)}function no(){return p.object({root:p.any().refine(lr,{message:"root must be a DOM Element"}),id:p.string().optional(),debug:p.boolean().optional(),content:p.array(p.any()).optional(),plugins:p.array(p.function()).optional(),blockComponents:p.array(p.any().refine(t=>typeof t=="function"||t!=null&&typeof t=="object"&&typeof t.component=="function",{message:"blockComponents entry must be a constructor or registration"})).optional(),slashActions:p.array(p.any().refine(t=>t!=null&&typeof t=="object"&&typeof t.handler=="function",{message:"slashActions entry must include a handler function"})).optional(),inlineStyles:p.array(p.function()).optional(),entityRanges:p.array(p.function()).optional(),tooltip:p.any().optional()})}function oo(t){return [...t.filter(e=>e!==ot&&e!==st&&e!==et),ot,st,et]}function ur(t){no().parse(t);let e={debug:false,content:[],plugins:[],blockComponents:[],slashActions:[],inlineStyles:[ce,le,me,ue,fe],entityRanges:[],tooltip:{}},n={...e,...t,plugins:oo(t.plugins??e.plugins)},o=new it(n);return o._init(),o}var it=class{#e=V();#o;#t=[];#n=[];#r;#i=false;listenerAbortController=new AbortController;#c=C([],{debug:"content"});#a=[];command;emitter;register;constructor(e){let{root:n,id:o,content:r}=e;this.#e=o||this.#e,this.#o=n,this.#a=r,this.#n=[],this.#r={...e,plugins:oo(e.plugins??[])},this.register={blocks:new qe(this),help:new rt(this)};let{emitter:s,command:i}=hn({mrakomor:this});this.command=i,this.emitter=s;}_init(){this.#s(),this.#c=C(this._normalizeContentState(this.#a),{debug:"content"});}#s(){this.#t=this.#r.plugins.map(e=>e?.({config:this.#r,root:this.#o,mrakomor:this}))??[],this.#r=this.#t.reduce((e,n)=>n?.resolveConfig?.(e)??e,this.#r),this.register.blocks.add(this.#r.blockComponents??[]),this.#t.forEach(e=>{e?.registerEvents?.(this);}),this.#t.forEach(e=>{e?.registerCommands?.(this);}),this.#t.forEach(e=>{this.emitter.on(m.KEYDOWN,n=>e?.onKeyDown?.(n));}),this.#t.forEach(e=>{e?.registerHandlers?.(this);}),this.#t.forEach(e=>{e?.registerListeners?.(this);});}emit(e,n={}){return this.emitter.emit(e,{...n,mrakomor:this})}on(e,n){return this.emitter.on(e,n)}onChangeContent(e){return this.on(m.CONTENT_CHANGE,e)}emitDomEvent(e,n){let{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:d,which:h,detail:x,isTrusted:_,target:N,relatedTarget:g,data:y,inputType:k}=n??{},{defaultPrevented:S}=this.emit(e,{clipboardData:o,metaKey:r,altKey:s,code:i,ctrlKey:a,key:c,isComposing:l,repeat:u,button:f,shiftKey:d,which:h,detail:x,isTrusted:_,target:N,relatedTarget:g,data:y,inputType:k});return S&&n?.preventDefault?.(),S}getConfig(){return {...this.#r,blockComponents:this.register.blocks.list(),slashActions:this.register.slashActions?.list()??[]}}wrapBlockElement(e){for(let n of this.#t){let o=n.wrapBlockElement?.(e);if(o)return o}return e}getRoot(){return this.#o}get _id(){return this.#e}getContent(){return this.#n.map(n=>P(n)?.getState())}setContent(e=[]){this._setContentState(this._normalizeContentState(e));}_syncBlockElementsFromDom(){let e=this.#o?.querySelector?.(".mrakomor-content");e&&(this.#n=[...e.querySelectorAll(".mrakomor-block-element")]);}_getBlockElements(){return this.#n}_getContentState(){return this.#c.get()}_setContentState(e=[]){this.#c.set(e),this.emit(m.CONTENT_CHANGE,{content:e}),R(()=>{this._syncBlockElementsFromDom();});}_normalizeContentState(e=[]){return e.map(n=>structuredClone(this.normalizeComponentState(n)))??[]}_setBlockElement(e,n=this.#n.length){this.#n.splice(n,0,e);}_removeBlockElement(e){this.#n=this.#n.filter(n=>n!==e);}#l(e){return P(e)?.state?.peek()?.componentId}#u(e){return e?this.#n.findIndex(n=>this.#l(n)===e):-1}_getBlockElementIndex(e){if(!e)return -1;let n=this.#n.indexOf(e);return n!==-1?n:this.#u(this.#l(e))}_getBlockElementByComponentId(e){let n=this.#u(e);return n===-1?null:this.#n[n]}_getBlockElementState(e){let n=this._getBlockElementIndex(e);if(n!==-1)return P(this.#n[n])?.getState()}mount(){let e=J(this.#o,E(Qn,{mrakomor:this}));return this.#i=true,e}unmount(){this.#i&&(this.#i=false,dn(this.#o));}_onUnmount(){this.listenerAbortController.abort(),this.#t.forEach(e=>{e?.onUnmount?.(this);}),this.emitter.removeAllListeners();}_onMount(){this.#t.forEach(e=>{e?.onMount?.(this);}),R(()=>{this._syncBlockElementsFromDom();});}resolveComponent(e,n){let o=this.resolveComponentConstructor(e);return o?E(o,{state:n}):E(he,{state:n})}resolveComponentConstructor(e){let n=this.register.blocks.getByNamespace(e);if(!n){for(let o of this.#t)if(n=o?.resolveComponent?.(e),n)break}return n}normalizeComponentState(e){let n="component"in e?e.component:e.entity.type;return this.resolveComponentConstructor(n)?.getStateSchema()?.parse(e)}};exports.Bold=ce;exports.Dialog=nt;exports.EVENT=m;exports.Italic=le;exports.Menu=Ut;exports.Mrakomor=it;exports.Subscript=ue;exports.Superscript=fe;exports.Underline=me;exports.createMrakomor=ur;exports.defaultMrakomorPlugin=et;exports.dialogPlugin=ot;exports.menuPlugin=st;
4
+ `?"":t??""}function oe({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{},s=Array.isArray(r.items)?r.items:[{text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]}];return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{items:s},...o?{settings:o}:{}}}function 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;